| 1 | #include <stdlib.h> |
|---|
| 2 | #include "dsthalcommon.h" |
|---|
| 3 | #include "dsthal_photoview.h" |
|---|
| 4 | |
|---|
| 5 | //#include "dstddcap.h" |
|---|
| 6 | //#include "dstddav.h" |
|---|
| 7 | #include "dstjpeg.h" |
|---|
| 8 | |
|---|
| 9 | //extern DST_CAP g_dstcap; |
|---|
| 10 | |
|---|
| 11 | //extern DST_VID g_dstvid; |
|---|
| 12 | //extern ACL_HANDLE g_DSTChip; |
|---|
| 13 | |
|---|
| 14 | //static DS_S8 wMoveStep = 0; |
|---|
| 15 | //static DS_S8 hMoveStep = 0; |
|---|
| 16 | |
|---|
| 17 | /* |
|---|
| 18 | b_ThbImage : 0 -> thumbnail image is not made. |
|---|
| 19 | 1 -> make thumbnail image |
|---|
| 20 | */ |
|---|
| 21 | #define PanelWidth 1366 |
|---|
| 22 | #define PanelHeight 768 |
|---|
| 23 | #define MulShift 2048 |
|---|
| 24 | |
|---|
| 25 | #define ZoomWidth 19 // 1366 * 0.05(5%) |
|---|
| 26 | #define ZoomHeight 34 // 768 * 0.05(5%) |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | int DHL_GetJpegExif(JpgFileInfo *file, DS_U8 b_ThbImage) |
|---|
| 30 | { |
|---|
| 31 | unsigned int width, height; |
|---|
| 32 | #if 1 |
|---|
| 33 | unsigned char p1[180][180*3]; |
|---|
| 34 | int Wi, Wi_1, Wj, Wj_1; |
|---|
| 35 | int Mwh; |
|---|
| 36 | unsigned int org_width, org_height; |
|---|
| 37 | int ii, jj,ret = 2; |
|---|
| 38 | #else |
|---|
| 39 | unsigned char pw[180][180][3]; |
|---|
| 40 | unsigned char p1[180][180][3]; |
|---|
| 41 | #endif |
|---|
| 42 | DS_S32 x,y,k,i,j; |
|---|
| 43 | char **image, **imageold; |
|---|
| 44 | |
|---|
| 45 | #if 1 |
|---|
| 46 | |
|---|
| 47 | if( file->exifInfo && file->exifInfo->ThumbnailImage ) |
|---|
| 48 | { |
|---|
| 49 | printf("skiled %s\n", __FUNCTION__); |
|---|
| 50 | return 0; |
|---|
| 51 | } |
|---|
| 52 | // if( (ret = JpegDec(TRUE,file->Name,b_ThbImage, file)) < 2 ) return ret; |
|---|
| 53 | #else |
|---|
| 54 | JpegDec(TRUE,file->Name,b_ThbImage, file); |
|---|
| 55 | #endif |
|---|
| 56 | image = file->exifInfo->ThumbnailImage; |
|---|
| 57 | width = file->exifInfo->ThumbnailWidth; |
|---|
| 58 | height = file->exifInfo->ThumbnailHeight; |
|---|
| 59 | imageold =file->exifInfo->ThumbnailImage; |
|---|
| 60 | |
|---|
| 61 | //printf("DHL_GetJpegExif %d\n",get_thumbnail_pitch() ); |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | org_width =file->exifInfo->ThumbnailWidth ; |
|---|
| 65 | org_height=file->exifInfo->ThumbnailHeight; |
|---|
| 66 | |
|---|
| 67 | /* |
|---|
| 68 | JPEG image? width/height´Ãfile->...->ThumbnailWidth(Height)?. |
|---|
| 69 | ? °ª8·Ã¸¸µé°Ã´ÃThumbnail image ũ±â¸?dôà |
|---|
| 70 | */ |
|---|
| 71 | //printf("width %d, height%d\n", org_width, org_height); |
|---|
| 72 | |
|---|
| 73 | if(image == NULL) |
|---|
| 74 | { |
|---|
| 75 | printf("||||| %s %d||||||\n", __FUNCTION__, __LINE__); |
|---|
| 76 | return ret; |
|---|
| 77 | } |
|---|
| 78 | if(org_width>org_height) |
|---|
| 79 | { |
|---|
| 80 | if(org_width==ThumbnailResoltuion) |
|---|
| 81 | { |
|---|
| 82 | printf("Oops: Original Thumbnail is too large to scale\n"); |
|---|
| 83 | return ret; |
|---|
| 84 | } |
|---|
| 85 | width = ThumbnailResoltuion; |
|---|
| 86 | height = org_height*ThumbnailResoltuion/org_width; |
|---|
| 87 | } |
|---|
| 88 | else |
|---|
| 89 | { |
|---|
| 90 | if(org_height==ThumbnailResoltuion) |
|---|
| 91 | { |
|---|
| 92 | printf("Oops: Original Thumbnail is too large to scale\n"); |
|---|
| 93 | return ret; |
|---|
| 94 | } |
|---|
| 95 | width = org_width * ThumbnailResoltuion/ org_height; |
|---|
| 96 | height = ThumbnailResoltuion; |
|---|
| 97 | } |
|---|
| 98 | #if 1 |
|---|
| 99 | /* |
|---|
| 100 | original image¸¦ º¹»ç´Ù |
|---|
| 101 | */ |
|---|
| 102 | for(y=0;y<file->exifInfo->ThumbnailHeight;y++) |
|---|
| 103 | { |
|---|
| 104 | for(x=0; x<file->exifInfo->ThumbnailWidth; x++) |
|---|
| 105 | { |
|---|
| 106 | for(k=0;k<3;k++) |
|---|
| 107 | { |
|---|
| 108 | p1[y][x*3+k] = image[y][x*3+k]; |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | image memory¸¦ allocÇ´Ù |
|---|
| 115 | */ |
|---|
| 116 | //printf("height %d width %d\n", height,width); |
|---|
| 117 | image = (char**) malloc(height*sizeof(char*)); |
|---|
| 118 | if(image == NULL) |
|---|
| 119 | { |
|---|
| 120 | printf("error malloc fail %s %d\n", __FUNCTION__, __LINE__); |
|---|
| 121 | return 2; |
|---|
| 122 | } |
|---|
| 123 | for(y=0;y<height;y++) |
|---|
| 124 | { |
|---|
| 125 | image[y] = malloc(width*3); |
|---|
| 126 | if( image[y] == NULL) |
|---|
| 127 | { |
|---|
| 128 | printf("error malloc fail %s %d\n", __FUNCTION__, __LINE__); |
|---|
| 129 | for(x=0;x<y;x++) |
|---|
| 130 | { |
|---|
| 131 | free(image[x]); |
|---|
| 132 | } |
|---|
| 133 | free(image); |
|---|
| 134 | return 2; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | #if 0 |
|---|
| 139 | for(k=0; k<3; k++) |
|---|
| 140 | { |
|---|
| 141 | image[0][0+k] = p1[0][0+k]; |
|---|
| 142 | image[height-1][(width-1)*3+k] = p1[org_height-1][(org_width-1)*3+k]; |
|---|
| 143 | } |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|
| 146 | Mwh = (width-1)*(height-1); |
|---|
| 147 | for(y=0; y<height; y++) |
|---|
| 148 | { |
|---|
| 149 | j = ((org_height-1)*y)/(height-1); |
|---|
| 150 | Wj = (j+1)*(height-1)-(org_height-1)*y; |
|---|
| 151 | Wj_1 = (org_height-1)*y-(height-1)*j; |
|---|
| 152 | |
|---|
| 153 | for(x=0; x<width; x++) |
|---|
| 154 | { |
|---|
| 155 | i = ((org_width-1)*x)/(width-1); |
|---|
| 156 | Wi= (i+1)*(width-1)-(org_width-1)*x; |
|---|
| 157 | Wi_1 = (org_width-1)*x - (width-1)*i; |
|---|
| 158 | |
|---|
| 159 | for(k=0; k<3; k++) |
|---|
| 160 | { |
|---|
| 161 | if(i==(org_width-1)) ii=i; |
|---|
| 162 | else ii=i+1; |
|---|
| 163 | if(j==(org_height-1)) jj=j; |
|---|
| 164 | else jj=j+1; |
|---|
| 165 | |
|---|
| 166 | image[y][x*3+k] = |
|---|
| 167 | (p1[j ][i*3+k]*Wi+p1[j ][ii*3+k]*Wi_1)*Wj /Mwh+ |
|---|
| 168 | (p1[jj][i*3+k]*Wi+p1[jj][ii*3+k]*Wi_1)*Wj_1/Mwh; |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| 172 | // printf("end %s\n", __FUNCTION__); |
|---|
| 173 | |
|---|
| 174 | for(i=0;i<file->exifInfo->ThumbnailHeight;i++) |
|---|
| 175 | free(imageold[i]); |
|---|
| 176 | free(imageold); |
|---|
| 177 | file->exifInfo->ThumbnailImage = image; |
|---|
| 178 | file->exifInfo->ThumbnailWidth = width; |
|---|
| 179 | file->exifInfo->ThumbnailHeight = height; |
|---|
| 180 | #endif |
|---|
| 181 | return ret; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | void DHL_DrawJpegThumbnail(JpgFileInfo *file, DS_U32 xPos, DS_U32 yPos) |
|---|
| 185 | { |
|---|
| 186 | int i; |
|---|
| 187 | // DS_U16 pitch; |
|---|
| 188 | |
|---|
| 189 | //pitch = get_thumbnail_pitch(); |
|---|
| 190 | |
|---|
| 191 | if(file == NULL || file->exifInfo == NULL) |
|---|
| 192 | { |
|---|
| 193 | if( file == NULL) |
|---|
| 194 | printf("file is NULL\n"); |
|---|
| 195 | if(file->exifInfo == NULL) |
|---|
| 196 | printf("file->exifInfo == NULL\n"); |
|---|
| 197 | return; |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | if(file->exifInfo->ThumbnailImage == NULL) |
|---|
| 201 | { |
|---|
| 202 | printf("no thumbnail image\n"); |
|---|
| 203 | return; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | for(i=0;i<file->exifInfo->ThumbnailHeight;i++) |
|---|
| 207 | { |
|---|
| 208 | if( file->exifInfo->ThumbnailImage[i] == NULL) |
|---|
| 209 | { |
|---|
| 210 | printf("file->exifInfo->ThumbnailImage[i] == NULL\n"); |
|---|
| 211 | return; |
|---|
| 212 | } |
|---|
| 213 | #if USE_ACL |
|---|
| 214 | sun_put_pixel_rows(TRUE, pitch, file->exifInfo->ThumbnailWidth,file->exifInfo->ThumbnailImage[i],i,xPos, yPos); |
|---|
| 215 | #endif |
|---|
| 216 | } |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | static int jpeg_message_q_id; |
|---|
| 220 | char jpeg_decoding_cancel; |
|---|
| 221 | typedef struct{ |
|---|
| 222 | char type; // 0 : jpeg decoding . 1 : cancel |
|---|
| 223 | char rotate; |
|---|
| 224 | char jpegRotate; |
|---|
| 225 | char *Name; |
|---|
| 226 | DS_U32 ImgWidthSize; |
|---|
| 227 | DS_U32 ImgHeightSize; |
|---|
| 228 | } JpegDecodeMsg; |
|---|
| 229 | |
|---|
| 230 | JpgFileInfo g_current_display_jpeg; |
|---|
| 231 | |
|---|
| 232 | void dhl_task_jpegdecoding(void) |
|---|
| 233 | { |
|---|
| 234 | JpegDecodeMsg JpegMsg; |
|---|
| 235 | DS_U32 read_len; |
|---|
| 236 | int ret=0 ; |
|---|
| 237 | JpgFileInfo *file; |
|---|
| 238 | unsigned int width,height; |
|---|
| 239 | file = &g_current_display_jpeg; |
|---|
| 240 | |
|---|
| 241 | float WidthRatio = 0.0, HeightRatio = 0.0; |
|---|
| 242 | DS_U32 x=0, y=0, w=0, h=0; |
|---|
| 243 | DS_U8 rotate; |
|---|
| 244 | DS_U32 tmp_width, tmp_height; |
|---|
| 245 | |
|---|
| 246 | while(1) |
|---|
| 247 | { |
|---|
| 248 | OS_ReceiveMessage(jpeg_message_q_id, (DS_U32 *)&JpegMsg, sizeof(JpegDecodeMsg), &read_len); |
|---|
| 249 | if(JpegMsg.type == 1) |
|---|
| 250 | { |
|---|
| 251 | printf("jpeg task is exit\n"); |
|---|
| 252 | return; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | strcpy( file->Name , JpegMsg.Name); |
|---|
| 256 | file->RotationInfo = JpegMsg.rotate; |
|---|
| 257 | file->JpegRotateInfo = JpegMsg.jpegRotate; |
|---|
| 258 | file->ImgWidthSize = JpegMsg.ImgWidthSize; |
|---|
| 259 | file->ImgHeightSize = JpegMsg.ImgHeightSize; |
|---|
| 260 | file->exifInfo = NULL; |
|---|
| 261 | free(JpegMsg.Name); |
|---|
| 262 | |
|---|
| 263 | // g_current_display_jpeg = *gp_CurSelectJpeg; |
|---|
| 264 | // printf("g_current_display_jpeg name %s\n", g_current_display_jpeg.Name); |
|---|
| 265 | |
|---|
| 266 | //fprintf(stderr,"|%s|%d|\n",__FUNCTION__,__LINE__); |
|---|
| 267 | //getchar(); |
|---|
| 268 | |
|---|
| 269 | DHL_DISP_MuteMain(1); |
|---|
| 270 | // if(! file->RotationInfo ) |
|---|
| 271 | { |
|---|
| 272 | // ret = JpegDec(FALSE, file->Name, 0, file); |
|---|
| 273 | if( ret == 0 || ret == 1) return ; |
|---|
| 274 | |
|---|
| 275 | rotate = file->RotationInfo ; |
|---|
| 276 | file->JpegRotateInfo = 0; |
|---|
| 277 | |
|---|
| 278 | if( rotate == EnRotate90 || rotate == EnRotate270) |
|---|
| 279 | { |
|---|
| 280 | tmp_height = file->ImgWidthSize ; |
|---|
| 281 | tmp_width = file->ImgHeightSize ; |
|---|
| 282 | } |
|---|
| 283 | else |
|---|
| 284 | { |
|---|
| 285 | tmp_width = file->ImgWidthSize ; |
|---|
| 286 | tmp_height = file->ImgHeightSize ; |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | WidthRatio = tmp_width / 1366.0; |
|---|
| 290 | HeightRatio = tmp_height / 768.0; |
|---|
| 291 | |
|---|
| 292 | printf("Ratio W %f H %f\n", WidthRatio, HeightRatio); |
|---|
| 293 | |
|---|
| 294 | if( WidthRatio > HeightRatio ) |
|---|
| 295 | { |
|---|
| 296 | w = PanelWidth; |
|---|
| 297 | h = tmp_height * PanelWidth / tmp_width ; |
|---|
| 298 | |
|---|
| 299 | x = 0; |
|---|
| 300 | y = (PanelHeight - h) / 2; |
|---|
| 301 | printf("draw x %ld y = %ld w %ld height %ld\n", x, y, w, h); |
|---|
| 302 | } |
|---|
| 303 | else |
|---|
| 304 | { |
|---|
| 305 | w = tmp_width * PanelHeight / tmp_height ; |
|---|
| 306 | h = PanelHeight; |
|---|
| 307 | |
|---|
| 308 | x = (PanelWidth - w) / 2; |
|---|
| 309 | y = 0; |
|---|
| 310 | printf("draw x %ld y = %ld w %ld h %ld\n", x, y, w, h); |
|---|
| 311 | } |
|---|
| 312 | } |
|---|
| 313 | // else |
|---|
| 314 | { |
|---|
| 315 | DHL_JpegRotate(file,rotate, w, h); |
|---|
| 316 | } |
|---|
| 317 | // *gp_CurSelectJpeg = g_current_display_jpeg; |
|---|
| 318 | DHL_DISP_MuteMain(0); |
|---|
| 319 | //fprintf(stderr,"|%s|%d|\n",__FUNCTION__,__LINE__); |
|---|
| 320 | //getchar(); |
|---|
| 321 | |
|---|
| 322 | #if 0 |
|---|
| 323 | width = jpgifno.ImgWidthSize; |
|---|
| 324 | height = jpgifno.ImgHeightSize; |
|---|
| 325 | #endif |
|---|
| 326 | width = file->ImgWidthSize ; |
|---|
| 327 | height =file->ImgHeightSize ; |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | printf("h %d w %d \n", height, width ); |
|---|
| 331 | |
|---|
| 332 | #if USE_ACL |
|---|
| 333 | ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); |
|---|
| 334 | ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width, height, &pitch)); |
|---|
| 335 | |
|---|
| 336 | file->pitch = pitch; |
|---|
| 337 | |
|---|
| 338 | offset = g_dstvid.uFrameBuffBaseOffset; |
|---|
| 339 | |
|---|
| 340 | ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); |
|---|
| 341 | |
|---|
| 342 | DD_CAP_DisconnectCompVidVc(); |
|---|
| 343 | |
|---|
| 344 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL)); |
|---|
| 345 | |
|---|
| 346 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp) ); |
|---|
| 347 | ovlRect.Left = x; |
|---|
| 348 | ovlRect.Top = y; |
|---|
| 349 | ovlRect.Width = w; |
|---|
| 350 | ovlRect.Height = h; |
|---|
| 351 | // ovlRect.Left = 0; |
|---|
| 352 | // ovlRect.Top = 0; |
|---|
| 353 | // ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 354 | // ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 355 | |
|---|
| 356 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, |
|---|
| 357 | &ovlRect, |
|---|
| 358 | g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 359 | #endif |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | int DHL_JpegDecoding(JpgFileInfo *file) |
|---|
| 365 | { |
|---|
| 366 | int ret=0; |
|---|
| 367 | static char JpegTaskCreateFlag = 0; |
|---|
| 368 | JpegDecodeMsg JpegMsg; |
|---|
| 369 | |
|---|
| 370 | // gp_CurSelectJpeg = file; |
|---|
| 371 | |
|---|
| 372 | if(JpegTaskCreateFlag == 0) |
|---|
| 373 | { |
|---|
| 374 | JpegTaskCreateFlag = 1; |
|---|
| 375 | jpeg_message_q_id = OS_CreateMessageQueue("gCCManagerMsgQ", 0/*OS_MSGQ_FIFO*/, 100, sizeof(JpegDecodeMsg)); |
|---|
| 376 | OS_SpawnTask((void(*))dhl_task_jpegdecoding, "jpeg task", 10, 1000, (DS_U32)NULL); |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | // JpgFileInfo jpgifno; |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | printf("size of int %d short %d long %d\n", sizeof(int), sizeof(short), sizeof(long)); |
|---|
| 383 | DHL_DTV_StopAV(); |
|---|
| 384 | DHL_CAP_Stop(0,0); |
|---|
| 385 | |
|---|
| 386 | JpegMsg.Name = malloc(sizeof(file->Name) + 1); |
|---|
| 387 | |
|---|
| 388 | strcpy(JpegMsg.Name , file->Name); |
|---|
| 389 | JpegMsg.type = 0; |
|---|
| 390 | JpegMsg.rotate = file->RotationInfo; |
|---|
| 391 | JpegMsg.jpegRotate = file->JpegRotateInfo; |
|---|
| 392 | JpegMsg.ImgWidthSize = file->ImgWidthSize; |
|---|
| 393 | JpegMsg.ImgHeightSize = file->ImgHeightSize; |
|---|
| 394 | |
|---|
| 395 | OS_SendMessage(jpeg_message_q_id, (DS_U32 *)&JpegMsg, sizeof(JpegDecodeMsg)); |
|---|
| 396 | /* |
|---|
| 397 | ret = JpegDec(FALSE, file->Name, 0, file); |
|---|
| 398 | if( ret == 0 || ret == 1) return ret; |
|---|
| 399 | |
|---|
| 400 | if( file->RotationInfo ) |
|---|
| 401 | DHL_JpegRotate(file,file->RotationInfo); |
|---|
| 402 | |
|---|
| 403 | #if 0 |
|---|
| 404 | width = jpgifno.ImgWidthSize; |
|---|
| 405 | height = jpgifno.ImgHeightSize; |
|---|
| 406 | #endif |
|---|
| 407 | width = file->ImgWidthSize ; |
|---|
| 408 | height =file->ImgHeightSize ; |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | // printf("h %d w %d \n", height, width ); |
|---|
| 412 | |
|---|
| 413 | // printf("g_dstcap.hOvlCap %u g_dstvid.hOVL %u\n", g_dstcap.hOvlCap , g_dstvid.hOVL); |
|---|
| 414 | #if 1 |
|---|
| 415 | ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); |
|---|
| 416 | |
|---|
| 417 | |
|---|
| 418 | ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width, height, &pitch)); |
|---|
| 419 | |
|---|
| 420 | offset = g_dstvid.uFrameBuffBaseOffset; |
|---|
| 421 | |
|---|
| 422 | ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); |
|---|
| 423 | |
|---|
| 424 | DD_CAP_DisconnectCompVidVc(); |
|---|
| 425 | #endif |
|---|
| 426 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL)); |
|---|
| 427 | |
|---|
| 428 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp) ); |
|---|
| 429 | // ovlRect.Left = x; |
|---|
| 430 | // ovlRect.Top = y; |
|---|
| 431 | // ovlRect.Width = w; |
|---|
| 432 | // ovlRect.Height = h; |
|---|
| 433 | ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 434 | ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 435 | |
|---|
| 436 | #if 0 |
|---|
| 437 | printf("ovl w %d h %d\n", ovlRect.Width , ovlRect.Height); |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | if( (100 * bmpimage.height) / bmpimage.width) > ((100* g_dstvid.OvlOptions.DestinationHeight) / g_dstvid.OvlOptions.DestinationWidth)) |
|---|
| 441 | { |
|---|
| 442 | ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 443 | ovlRect.Width = (g_dstvid.OvlOptions.DestinationHeight* bmpimage.width) / bmpimage.height ; |
|---|
| 444 | ovlRect.Left = (g_dstvid.OvlOptions.DestinationHeight - ovlRect.Width ) /2; |
|---|
| 445 | } |
|---|
| 446 | else |
|---|
| 447 | { |
|---|
| 448 | ovlRect.Height = (g_dstvid.OvlOptions.DestinationWidth * bmpimage.height) / bmpimage.width; |
|---|
| 449 | ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 450 | |
|---|
| 451 | ovlRect.Top = (g_dstvid.OvlOptions.DestinationWidth - ovlRect.Height )/2 ; |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | printf("bmp l %d t %d w %d h %d panel w %d h %d\n",ovlRect.Left, ovlRect.Top, bmpimage.width, bmpimage.height, |
|---|
| 455 | ovlRect.Width, ovlRect.Height); |
|---|
| 456 | #endif |
|---|
| 457 | |
|---|
| 458 | #if 1 |
|---|
| 459 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, |
|---|
| 460 | &ovlRect, |
|---|
| 461 | g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 462 | #endif |
|---|
| 463 | */ |
|---|
| 464 | |
|---|
| 465 | // DD_VIDEO_ConnectCompOvl(TRUE); |
|---|
| 466 | |
|---|
| 467 | #if USE_ACL |
|---|
| 468 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Enable(g_dstcap.hOvlCap , TRUE )); |
|---|
| 469 | printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclDisp_SetEnable( g_dstcap.hDisp, TRUE)); |
|---|
| 470 | #endif |
|---|
| 471 | return ret; |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | void DHL_FreeThumbnailImage(JpgFileInfo *file) |
|---|
| 475 | { |
|---|
| 476 | int i; |
|---|
| 477 | if(file->exifInfo) |
|---|
| 478 | { |
|---|
| 479 | if(file->exifInfo->ThumbnailImage == NULL) |
|---|
| 480 | { |
|---|
| 481 | //printf("Image is empty in %s\n", __FUNCTION__); |
|---|
| 482 | fprintf(stderr, "Image is empty in %s | %d |\n", __FUNCTION__, __LINE__); |
|---|
| 483 | return; |
|---|
| 484 | } |
|---|
| 485 | } |
|---|
| 486 | else |
|---|
| 487 | { |
|---|
| 488 | fprintf(stderr, "Exif is empty in %s | %d |\n", __FUNCTION__, __LINE__); |
|---|
| 489 | return; |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | for(i=0;i<file->exifInfo->ThumbnailHeight;i++) |
|---|
| 493 | free(file->exifInfo->ThumbnailImage[i]); |
|---|
| 494 | free(file->exifInfo->ThumbnailImage); |
|---|
| 495 | printf("|| %s %d %s||\n", __FUNCTION__, __LINE__, file->Name); |
|---|
| 496 | file->exifInfo->ThumbnailImage = NULL; |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | void DHL_FreeJpegThumbnailImage(ExifInfo *pe) |
|---|
| 500 | { |
|---|
| 501 | int i; |
|---|
| 502 | if(pe) |
|---|
| 503 | { |
|---|
| 504 | if(pe->ThumbnailImage == NULL) |
|---|
| 505 | { |
|---|
| 506 | fprintf(stderr, "Image is empty in %s | %d |\n", __FUNCTION__, __LINE__); |
|---|
| 507 | return; |
|---|
| 508 | } |
|---|
| 509 | } |
|---|
| 510 | else |
|---|
| 511 | { |
|---|
| 512 | fprintf(stderr, "Exif is empty in %s | %d |\n", __FUNCTION__, __LINE__); |
|---|
| 513 | return; |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | for(i=0;i<pe-> ThumbnailHeight;i++) |
|---|
| 517 | free(pe->ThumbnailImage[i]); |
|---|
| 518 | free(pe->ThumbnailImage); |
|---|
| 519 | pe->ThumbnailImage = NULL; |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | // this function remove all exif information as well as thumbnail image |
|---|
| 523 | |
|---|
| 524 | void DHL_FreeExif(ExifInfo *pe) |
|---|
| 525 | { |
|---|
| 526 | ExifInfo *pt; |
|---|
| 527 | |
|---|
| 528 | pt=pe; |
|---|
| 529 | while(pt) |
|---|
| 530 | { |
|---|
| 531 | pe = pt->next; |
|---|
| 532 | if(pt->EntryValue) free( pt->EntryValue); |
|---|
| 533 | free(pt); |
|---|
| 534 | pt = pe; |
|---|
| 535 | } |
|---|
| 536 | } |
|---|
| 537 | |
|---|
| 538 | void DHL_FreeJpegExif(ExifInfo *pe) |
|---|
| 539 | { |
|---|
| 540 | if(pe->ThumbnailImage) |
|---|
| 541 | DHL_FreeJpegThumbnailImage(pe); |
|---|
| 542 | |
|---|
| 543 | DHL_FreeExif(pe); |
|---|
| 544 | } |
|---|
| 545 | |
|---|
| 546 | void DHL_JpegThumbnailRotate(JpgFileInfo *file,EnRotate rotate, DS_U32 xPos, DS_U32 yPos) |
|---|
| 547 | { |
|---|
| 548 | ExifInfo *pEx; |
|---|
| 549 | int i,Tx,Ty,t11,t12, t21,t22; |
|---|
| 550 | int k,x,y,X,Y,MX, MY; |
|---|
| 551 | int MaxX,MaxY; |
|---|
| 552 | char **image, **timage; |
|---|
| 553 | |
|---|
| 554 | pEx = file->exifInfo; |
|---|
| 555 | MaxX = pEx->ThumbnailWidth; |
|---|
| 556 | MaxY = pEx->ThumbnailHeight; |
|---|
| 557 | |
|---|
| 558 | printf("%s is %s\n", file->Name, __FUNCTION__); |
|---|
| 559 | printf("rotate %d file->RotationInfo %d file->ThmRotateInfo %d, jpeg rot %d\n", |
|---|
| 560 | rotate, file->RotationInfo, file->ThmRotateInfo , file->JpegRotateInfo); |
|---|
| 561 | |
|---|
| 562 | file->RotationInfo = rotate ; |
|---|
| 563 | rotate = (rotate + EnRotateEnd - file->ThmRotateInfo) % EnRotateEnd; |
|---|
| 564 | file->ThmRotateInfo = file->RotationInfo; |
|---|
| 565 | printf("diff rotate %d\n", rotate); |
|---|
| 566 | printf("pEx->ThumbnailWidth %d , pEx->ThumbnailHeight %d\n", pEx->ThumbnailWidth, pEx->ThumbnailHeight); |
|---|
| 567 | |
|---|
| 568 | Tx = Ty = 0; |
|---|
| 569 | t11 = t12 = t21 = t22 = 0; |
|---|
| 570 | |
|---|
| 571 | //if(file->NoDraw == 0) |
|---|
| 572 | //DHL_JpegThumbnailclear(xPos, yPos); |
|---|
| 573 | switch(rotate) |
|---|
| 574 | { |
|---|
| 575 | case EnRotate90: |
|---|
| 576 | // Ty = pEx->ThumbnailWidth; |
|---|
| 577 | t12 = 1; |
|---|
| 578 | t21 = -1; |
|---|
| 579 | MY = MaxX; |
|---|
| 580 | MX = MaxY; |
|---|
| 581 | Ty = MaxX-1; |
|---|
| 582 | break; |
|---|
| 583 | case EnRotate180: |
|---|
| 584 | Tx = pEx->ThumbnailWidth-1; |
|---|
| 585 | Ty = pEx->ThumbnailHeight-1; |
|---|
| 586 | t11 = t22 = -1; |
|---|
| 587 | MX = pEx->ThumbnailWidth; |
|---|
| 588 | MY = pEx->ThumbnailHeight; |
|---|
| 589 | break; |
|---|
| 590 | case EnRotate270: |
|---|
| 591 | t12 = -1; |
|---|
| 592 | t21 = 1; |
|---|
| 593 | MY = MaxX; |
|---|
| 594 | MX = MaxY; |
|---|
| 595 | Tx = MaxY - 1; |
|---|
| 596 | break; |
|---|
| 597 | default: |
|---|
| 598 | if( file->NoDraw == 0) |
|---|
| 599 | DHL_DrawJpegThumbnail(file,xPos,yPos); |
|---|
| 600 | return; |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | printf("MX %d MY %d Tx %d Ty %d\n", MX, MY, Tx, Ty); |
|---|
| 604 | |
|---|
| 605 | image = (char**)malloc(sizeof(char*)*MY); // MaxX |
|---|
| 606 | if(image == NULL) |
|---|
| 607 | { |
|---|
| 608 | printf("Error malloc in %d %s\n", __LINE__,__FUNCTION__); |
|---|
| 609 | return; |
|---|
| 610 | } |
|---|
| 611 | for(y=0;y<MY;y++) |
|---|
| 612 | { |
|---|
| 613 | image[y] = (char*)malloc(MX*3); // MaxY |
|---|
| 614 | if(image[y]==NULL) |
|---|
| 615 | { |
|---|
| 616 | printf("Error malloc in %d %s\n", __LINE__,__FUNCTION__); |
|---|
| 617 | return; |
|---|
| 618 | } |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | for(y=0;y< MaxY /*pEx->ThumbnailHeight*/;y++) |
|---|
| 622 | { |
|---|
| 623 | for(x=0;x< MaxX /*pEx->ThumbnailWidth*/;x++) |
|---|
| 624 | { |
|---|
| 625 | X = Tx + t11 * x + t12 * y; // max MaxY |
|---|
| 626 | Y = Ty + t21 * x + t22 * y; // max MaxX |
|---|
| 627 | |
|---|
| 628 | // printf("x %d y %d => X %d , Y %d\n", x,y,X,Y); |
|---|
| 629 | |
|---|
| 630 | #if 1 |
|---|
| 631 | if( X >= MX|| X < 0) |
|---|
| 632 | { |
|---|
| 633 | printf("x%d y%d \n:", x,y); |
|---|
| 634 | printf("memory fail : X %d \n",X); |
|---|
| 635 | return; |
|---|
| 636 | } |
|---|
| 637 | if( Y >= MY || Y < 0) |
|---|
| 638 | { |
|---|
| 639 | printf("x%d y%d \n:", x,y); |
|---|
| 640 | printf("memory fail : Y %d \n",Y); |
|---|
| 641 | return; |
|---|
| 642 | } |
|---|
| 643 | #endif |
|---|
| 644 | |
|---|
| 645 | for(k=0;k<3;k++) |
|---|
| 646 | { |
|---|
| 647 | image[Y][X*3+k] = pEx->ThumbnailImage[y][x*3+k]; // MaxX, MaxY |
|---|
| 648 | //Maxx, MaxY |
|---|
| 649 | } |
|---|
| 650 | } |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | timage = file->exifInfo->ThumbnailImage; |
|---|
| 654 | x = file->exifInfo->ThumbnailWidth; |
|---|
| 655 | y = file->exifInfo->ThumbnailHeight; |
|---|
| 656 | |
|---|
| 657 | file->exifInfo->ThumbnailImage = image; |
|---|
| 658 | file->exifInfo->ThumbnailWidth = MX; |
|---|
| 659 | file->exifInfo->ThumbnailHeight = MY; |
|---|
| 660 | |
|---|
| 661 | if( file->NoDraw == 0) |
|---|
| 662 | DHL_DrawJpegThumbnail(file,xPos,yPos); |
|---|
| 663 | |
|---|
| 664 | // file->exifInfo->ThumbnailImage = timage; |
|---|
| 665 | // file->exifInfo->ThumbnailWidth = x; |
|---|
| 666 | // file->exifInfo->ThumbnailHeight = y; |
|---|
| 667 | |
|---|
| 668 | for(i=0;i<y;i++) |
|---|
| 669 | free(timage[i]); |
|---|
| 670 | free(timage); |
|---|
| 671 | printf("end pEx->ThumbnailWidth %d , pEx->ThumbnailHeight %d\n", pEx->ThumbnailWidth, pEx->ThumbnailHeight); |
|---|
| 672 | } |
|---|
| 673 | |
|---|
| 674 | void DHL_JpegRotate(JpgFileInfo *file, EnRotate rotate, DS_U32 width, DS_U32 height) |
|---|
| 675 | { |
|---|
| 676 | DS_U32 new_pitch; |
|---|
| 677 | #if USE_ACL |
|---|
| 678 | ACL_RESULT rc; |
|---|
| 679 | #endif |
|---|
| 680 | int Tx,Ty,t11,t12, t21,t22; |
|---|
| 681 | int x,y,X,Y,MX, MY,k; |
|---|
| 682 | int MaxX,MaxY; |
|---|
| 683 | DS_U8 *u8src, *u8des; |
|---|
| 684 | #if USE_ACL |
|---|
| 685 | DS_U32 *u32src, *u32des, *u32org, *u32org1; |
|---|
| 686 | DS_U32 u32tmp, u32_old; |
|---|
| 687 | DS_U32 index, u32cnt,ulSrcAlignment; |
|---|
| 688 | char *p; |
|---|
| 689 | ACL_RECT ovlRect; |
|---|
| 690 | DS_U32 offset; |
|---|
| 691 | #endif |
|---|
| 692 | |
|---|
| 693 | float WidthRatio = 0.0, HeightRatio = 0.0; |
|---|
| 694 | #if USE_ACL |
|---|
| 695 | DS_U32 xpos=0, ypos=0; |
|---|
| 696 | #endif |
|---|
| 697 | DS_U32 w=0, h=0; |
|---|
| 698 | |
|---|
| 699 | MaxX = file->ImgWidthSize; |
|---|
| 700 | MaxY = file->ImgHeightSize; |
|---|
| 701 | |
|---|
| 702 | Tx = Ty = 0; |
|---|
| 703 | t11 = t12 = t21 = t22 = 0; |
|---|
| 704 | printf("MaxX MaxY %d %d\n", MaxX, MaxY); |
|---|
| 705 | |
|---|
| 706 | printf("Cur Rotate %d new rotate %d jpeg rotate %d\n", file->RotationInfo , rotate, file->JpegRotateInfo ); |
|---|
| 707 | |
|---|
| 708 | if( file->RotationInfo == rotate && file->JpegRotateInfo == rotate ) return; |
|---|
| 709 | |
|---|
| 710 | |
|---|
| 711 | file->NoDraw = 1; |
|---|
| 712 | if( file->exifInfo && file->exifInfo->ThumbnailImage) |
|---|
| 713 | DHL_JpegThumbnailRotate(file, rotate, 0,0); |
|---|
| 714 | file->NoDraw = 0; |
|---|
| 715 | DHL_DISP_MuteMain(1); |
|---|
| 716 | file->RotationInfo = rotate ; |
|---|
| 717 | |
|---|
| 718 | rotate = (rotate + EnRotateEnd - file->JpegRotateInfo ) % EnRotateEnd; |
|---|
| 719 | file->JpegRotateInfo = file->RotationInfo; |
|---|
| 720 | |
|---|
| 721 | switch(rotate) |
|---|
| 722 | { |
|---|
| 723 | case EnRotate90: |
|---|
| 724 | t12 = 1; |
|---|
| 725 | t21 = -1; |
|---|
| 726 | MY = MaxX; |
|---|
| 727 | MX = MaxY; |
|---|
| 728 | Ty = MaxX-1; |
|---|
| 729 | break; |
|---|
| 730 | case EnRotate180: |
|---|
| 731 | Tx = MaxX-1; |
|---|
| 732 | Ty = MaxY-1; |
|---|
| 733 | t11 = t22 = -1; |
|---|
| 734 | MX = MaxX; |
|---|
| 735 | MY = MaxY; |
|---|
| 736 | break; |
|---|
| 737 | case EnRotate270: |
|---|
| 738 | t12 = -1; |
|---|
| 739 | t21 = 1; |
|---|
| 740 | MY = MaxX; |
|---|
| 741 | MX = MaxY; |
|---|
| 742 | Tx = MaxY - 1; |
|---|
| 743 | break; |
|---|
| 744 | default: |
|---|
| 745 | return; |
|---|
| 746 | } |
|---|
| 747 | |
|---|
| 748 | printf("MX MY %d %d\n", MX, MY); |
|---|
| 749 | |
|---|
| 750 | #if USE_ACL |
|---|
| 751 | u32org = (DS_U32*)g_dstvid.pFrameBuff ; |
|---|
| 752 | #endif |
|---|
| 753 | |
|---|
| 754 | new_pitch = file->pitch; |
|---|
| 755 | #if 0 |
|---|
| 756 | // if( rotate == EnRotate180 || rotate==EnRotate0) |
|---|
| 757 | { |
|---|
| 758 | printf("rotate 180 maxY/2 %d pitch %d\n", MaxY/2, file->pitch); |
|---|
| 759 | |
|---|
| 760 | for(y=0;y<(MaxY/2);y++) |
|---|
| 761 | { |
|---|
| 762 | u32src = u32org + file->pitch * y; |
|---|
| 763 | u32des = u32org + file->pitch * (MaxY - 1 - y) + MaxX - 1; |
|---|
| 764 | for(x=0;x<MaxX;x++) |
|---|
| 765 | { |
|---|
| 766 | u32tmp = *(u32des - x); |
|---|
| 767 | *(u32des - x) = *(u32src + x); |
|---|
| 768 | *(u32src + x) = u32tmp; |
|---|
| 769 | } |
|---|
| 770 | } |
|---|
| 771 | if(MaxY & 1) |
|---|
| 772 | { |
|---|
| 773 | y = MaxY/2 + 1; |
|---|
| 774 | u32src = u32org + file->pitch * y; |
|---|
| 775 | u32des = u32org + file->pitch * (MaxY - 1 - y) + MaxX - 1; |
|---|
| 776 | for(x=0;x<MaxX/2;x++) |
|---|
| 777 | { |
|---|
| 778 | u32tmp = *(u32des - x); |
|---|
| 779 | *(u32des - x) = *(u32src + x); |
|---|
| 780 | *(u32src + x) = u32tmp; |
|---|
| 781 | } |
|---|
| 782 | } |
|---|
| 783 | } |
|---|
| 784 | else |
|---|
| 785 | #endif |
|---|
| 786 | { |
|---|
| 787 | #if USE_ACL |
|---|
| 788 | ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, MX, MY, &new_pitch)); |
|---|
| 789 | printf("new pitch %d pitch %d\n", new_pitch, file->pitch); |
|---|
| 790 | |
|---|
| 791 | u8des = (DS_U8*)g_dstvid.pFrameBuff + (file->pitch * MaxY)*4; |
|---|
| 792 | u8src = (DS_U8*)g_dstvid.pFrameBuff ; |
|---|
| 793 | #else |
|---|
| 794 | u8des = 0; |
|---|
| 795 | u8src = 0; |
|---|
| 796 | #endif |
|---|
| 797 | |
|---|
| 798 | for(y=0;y< MaxY /*pEx->ThumbnailHeight*/;y++) |
|---|
| 799 | { |
|---|
| 800 | |
|---|
| 801 | for(x=0;x< MaxX /*pEx->ThumbnailWidth*/;x++) |
|---|
| 802 | { |
|---|
| 803 | X = Tx + t11 * x + t12 * y; // max MaxY |
|---|
| 804 | Y = Ty + t21 * x + t22 * y; // max MaxX |
|---|
| 805 | |
|---|
| 806 | for(k=0;k<4;k++) |
|---|
| 807 | { |
|---|
| 808 | *(u8des+(Y*new_pitch+X)*4+k) = *(u8src+(y*file->pitch+x)*4+k); |
|---|
| 809 | } |
|---|
| 810 | } |
|---|
| 811 | } |
|---|
| 812 | |
|---|
| 813 | #if USE_ACL |
|---|
| 814 | u8des = g_dstvid.pFrameBuff ; |
|---|
| 815 | u8src = g_dstvid.pFrameBuff + (file->pitch * MaxY)*4; |
|---|
| 816 | #endif |
|---|
| 817 | for(y=0;y< MY/*pEx->ThumbnailHeight*/;y++) |
|---|
| 818 | { |
|---|
| 819 | for(x=0;x< MX /*pEx->ThumbnailWidth*/;x++) |
|---|
| 820 | { |
|---|
| 821 | for(k=0;k<4;k++) |
|---|
| 822 | { |
|---|
| 823 | *(u8des + (y * new_pitch + x)*4 + k) = *(u8src + (y * new_pitch + x)*4 + k); |
|---|
| 824 | } |
|---|
| 825 | } |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | #if USE_ACL |
|---|
| 829 | ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); |
|---|
| 830 | ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, MX, MY, &new_pitch)); |
|---|
| 831 | offset = g_dstvid.uFrameBuffBaseOffset; |
|---|
| 832 | |
|---|
| 833 | ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); |
|---|
| 834 | |
|---|
| 835 | DD_CAP_DisconnectCompVidVc(); |
|---|
| 836 | |
|---|
| 837 | AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL); |
|---|
| 838 | |
|---|
| 839 | AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp); |
|---|
| 840 | #endif |
|---|
| 841 | |
|---|
| 842 | height = MY; |
|---|
| 843 | width = MX; |
|---|
| 844 | |
|---|
| 845 | WidthRatio = width / 1366.0; |
|---|
| 846 | HeightRatio = height / 768.0; |
|---|
| 847 | |
|---|
| 848 | if( WidthRatio > HeightRatio ) |
|---|
| 849 | { |
|---|
| 850 | w = PanelWidth; |
|---|
| 851 | h = height * PanelWidth / width ; |
|---|
| 852 | |
|---|
| 853 | x = 0; |
|---|
| 854 | y = (PanelHeight - h) / 2; |
|---|
| 855 | } |
|---|
| 856 | else |
|---|
| 857 | { |
|---|
| 858 | w = width * PanelHeight / height ; |
|---|
| 859 | h = PanelHeight; |
|---|
| 860 | |
|---|
| 861 | x = (PanelWidth - w) / 2; |
|---|
| 862 | y = 0; |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | #if USE_ACL |
|---|
| 866 | ovlRect.Left = x; |
|---|
| 867 | ovlRect.Top = y; |
|---|
| 868 | ovlRect.Width = w; |
|---|
| 869 | ovlRect.Height = h; |
|---|
| 870 | |
|---|
| 871 | // ovlRect.Left = 0; |
|---|
| 872 | // ovlRect.Top = 0; |
|---|
| 873 | // ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 874 | // ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 875 | |
|---|
| 876 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, |
|---|
| 877 | &ovlRect, |
|---|
| 878 | g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 879 | #endif |
|---|
| 880 | } |
|---|
| 881 | g_current_display_jpeg.ImgWidthSize = MX; |
|---|
| 882 | g_current_display_jpeg.ImgHeightSize = MY; |
|---|
| 883 | g_current_display_jpeg.pitch = new_pitch; |
|---|
| 884 | file->ImgHeightSize = MY ; |
|---|
| 885 | file->ImgWidthSize = MX ; |
|---|
| 886 | /* |
|---|
| 887 | ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 888 | ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 889 | |
|---|
| 890 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, |
|---|
| 891 | &ovlRect, |
|---|
| 892 | g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 893 | */ |
|---|
| 894 | DHL_DISP_MuteMain(0); |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | void DHL_ZoomInOutJpeg(JpgFileInfo *file, DS_U32 width, DS_U32 height, ZoomStatus zoom) |
|---|
| 898 | { |
|---|
| 899 | #if USE_ACL |
|---|
| 900 | ACL_RECT dstRect, cropRect; |
|---|
| 901 | float WidthRatio = 0.0, HeightRatio = 0.0; |
|---|
| 902 | DS_U32 x=0, y=0, w=0, h=0; |
|---|
| 903 | |
|---|
| 904 | // ACLFAIL( AclOvl_GetCropWindow(hOVL,ACL_OVL_CROP_SRC,&ovlRect), dhlResult); |
|---|
| 905 | // ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width+40, height+70, &pitch)); |
|---|
| 906 | |
|---|
| 907 | DHL_DISP_MuteMain(1); |
|---|
| 908 | |
|---|
| 909 | WidthRatio = file->ImgWidthSize / 1366.0; |
|---|
| 910 | HeightRatio = file->ImgHeightSize / 768.0; |
|---|
| 911 | |
|---|
| 912 | AclOvl_GetCropWindow(g_dstcap.hOvlCap,ACL_OVL_CROP_SRC,&cropRect); |
|---|
| 913 | AclOvl_GetDstWindow(g_dstcap.hOvlCap,&dstRect); |
|---|
| 914 | |
|---|
| 915 | printf("WidthRatio %f HeightRatio %f\n", WidthRatio, HeightRatio); |
|---|
| 916 | printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); |
|---|
| 917 | printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); |
|---|
| 918 | |
|---|
| 919 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 920 | /////////// Center 위치에서 zoom in, out 실행해야 함. move 한만큼 되돌림. |
|---|
| 921 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 922 | |
|---|
| 923 | cropRect.Top += hMoveStep * ZoomHeight; |
|---|
| 924 | cropRect.Left += wMoveStep * ZoomWidth; |
|---|
| 925 | |
|---|
| 926 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 927 | hMoveStep = wMoveStep = 0; |
|---|
| 928 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 929 | |
|---|
| 930 | |
|---|
| 931 | switch(zoom) |
|---|
| 932 | { |
|---|
| 933 | case ZoomIn: |
|---|
| 934 | if(WidthRatio > HeightRatio) |
|---|
| 935 | { |
|---|
| 936 | if(cropRect.Height > ZoomHeight * 2) |
|---|
| 937 | { |
|---|
| 938 | if(dstRect.Height + ZoomHeight * 2 <= PanelHeight) |
|---|
| 939 | dstRect.Height += ZoomHeight * 2; |
|---|
| 940 | else |
|---|
| 941 | dstRect.Height = PanelHeight; |
|---|
| 942 | cropRect.Left += ZoomWidth; |
|---|
| 943 | cropRect.Width -= ZoomWidth * 2; |
|---|
| 944 | |
|---|
| 945 | if(dstRect.Top >= ZoomHeight) |
|---|
| 946 | { |
|---|
| 947 | dstRect.Top -= ZoomHeight; |
|---|
| 948 | cropRect.Top = dstRect.Top; |
|---|
| 949 | cropRect.Height = dstRect.Height; |
|---|
| 950 | } |
|---|
| 951 | else if(dstRect.Top > 0) // 0 < dstRect.Top < ZoomHeight |
|---|
| 952 | { |
|---|
| 953 | cropRect.Top = ZoomHeight - dstRect.Top; |
|---|
| 954 | cropRect.Height = PanelHeight - cropRect.Top * 2; |
|---|
| 955 | dstRect.Top = 0; |
|---|
| 956 | } |
|---|
| 957 | else // dstRect.Top == 0 |
|---|
| 958 | { |
|---|
| 959 | dstRect.Top = 0; |
|---|
| 960 | cropRect.Top += ZoomHeight; |
|---|
| 961 | cropRect.Height -= ZoomHeight * 2; |
|---|
| 962 | } |
|---|
| 963 | } |
|---|
| 964 | } |
|---|
| 965 | else |
|---|
| 966 | { |
|---|
| 967 | if(cropRect.Height > ZoomHeight * 2) |
|---|
| 968 | { |
|---|
| 969 | if(dstRect.Width + ZoomWidth * 2 <= PanelWidth) |
|---|
| 970 | dstRect.Width += ZoomWidth * 2; |
|---|
| 971 | else |
|---|
| 972 | dstRect.Width = PanelWidth; |
|---|
| 973 | cropRect.Top += ZoomHeight; |
|---|
| 974 | cropRect.Height -= ZoomHeight * 2; |
|---|
| 975 | |
|---|
| 976 | if(dstRect.Left >= ZoomWidth) |
|---|
| 977 | { |
|---|
| 978 | dstRect.Left -= ZoomWidth; |
|---|
| 979 | cropRect.Left = dstRect.Left; |
|---|
| 980 | cropRect.Width = dstRect.Width; |
|---|
| 981 | } |
|---|
| 982 | else if(dstRect.Left > 0) // 0 < dstRect.Left < 19 |
|---|
| 983 | { |
|---|
| 984 | cropRect.Left = ZoomWidth - dstRect.Left; |
|---|
| 985 | cropRect.Width = PanelWidth - cropRect.Left * 2; |
|---|
| 986 | dstRect.Left = 0; |
|---|
| 987 | } |
|---|
| 988 | else // dstRect.Top == 0 |
|---|
| 989 | { |
|---|
| 990 | dstRect.Left = 0; |
|---|
| 991 | cropRect.Left += ZoomWidth; |
|---|
| 992 | cropRect.Width -= ZoomWidth * 2; |
|---|
| 993 | } |
|---|
| 994 | |
|---|
| 995 | /* |
|---|
| 996 | if(cropRect.Width > 19 * 2) |
|---|
| 997 | { |
|---|
| 998 | dstRect.Width += 19*2; |
|---|
| 999 | cropRect.Top += 34; |
|---|
| 1000 | cropRect.Height -= 34 * 2; |
|---|
| 1001 | |
|---|
| 1002 | if(dstRect.Left >= 19) |
|---|
| 1003 | { |
|---|
| 1004 | dstRect.Left -= 19; |
|---|
| 1005 | cropRect.Left = dstRect.Left; |
|---|
| 1006 | cropRect.Width = dstRect.Width; |
|---|
| 1007 | } |
|---|
| 1008 | else |
|---|
| 1009 | { |
|---|
| 1010 | dstRect.Left = 0; |
|---|
| 1011 | cropRect.Left += 19; |
|---|
| 1012 | cropRect.Width -= 19*2; |
|---|
| 1013 | } |
|---|
| 1014 | */ |
|---|
| 1015 | } |
|---|
| 1016 | } |
|---|
| 1017 | break; |
|---|
| 1018 | case ZoomOut: |
|---|
| 1019 | if( WidthRatio > HeightRatio ) |
|---|
| 1020 | { |
|---|
| 1021 | if(cropRect.Left >= ZoomWidth) |
|---|
| 1022 | { |
|---|
| 1023 | cropRect.Left -= ZoomWidth; |
|---|
| 1024 | cropRect.Width += ZoomWidth * 2; |
|---|
| 1025 | |
|---|
| 1026 | if(cropRect.Height + ZoomHeight * 2 < PanelHeight) |
|---|
| 1027 | { |
|---|
| 1028 | dstRect.Top = 0; |
|---|
| 1029 | dstRect.Height = PanelHeight; |
|---|
| 1030 | cropRect.Top -= ZoomHeight; |
|---|
| 1031 | cropRect.Height += ZoomHeight * 2; |
|---|
| 1032 | |
|---|
| 1033 | } |
|---|
| 1034 | |
|---|
| 1035 | else if( (cropRect.Height < PanelHeight) && (dstRect.Top == 0) ) // && cropRect.Height + 34*2 >= 768 |
|---|
| 1036 | { |
|---|
| 1037 | dstRect.Height = PanelHeight - cropRect.Top * 2 - (dstRect.Height - cropRect.Height - cropRect.Top); |
|---|
| 1038 | dstRect.Top = ZoomHeight - cropRect.Top; |
|---|
| 1039 | cropRect.Top = dstRect.Top; |
|---|
| 1040 | cropRect.Height = PanelHeight - (dstRect.Height - cropRect.Height - cropRect.Top); |
|---|
| 1041 | } |
|---|
| 1042 | else // dstRect.Top >= 0 |
|---|
| 1043 | { |
|---|
| 1044 | dstRect.Height -= ZoomHeight * 2; |
|---|
| 1045 | dstRect.Top += ZoomHeight; |
|---|
| 1046 | cropRect.Top = dstRect.Top; |
|---|
| 1047 | cropRect.Height = dstRect.Height; |
|---|
| 1048 | } |
|---|
| 1049 | } |
|---|
| 1050 | } |
|---|
| 1051 | else |
|---|
| 1052 | { |
|---|
| 1053 | if(cropRect.Top >= ZoomHeight) |
|---|
| 1054 | { |
|---|
| 1055 | cropRect.Top -= ZoomHeight; |
|---|
| 1056 | cropRect.Height += ZoomHeight * 2; |
|---|
| 1057 | |
|---|
| 1058 | if( (cropRect.Width + ZoomWidth * 2 < PanelWidth) && (dstRect.Left == 0) ) |
|---|
| 1059 | { |
|---|
| 1060 | dstRect.Left = 0; |
|---|
| 1061 | dstRect.Width = PanelWidth; |
|---|
| 1062 | cropRect.Left -= ZoomWidth; |
|---|
| 1063 | cropRect.Width += ZoomWidth * 2; |
|---|
| 1064 | |
|---|
| 1065 | } |
|---|
| 1066 | else if( (cropRect.Width < PanelWidth) && (dstRect.Left == 0) ) // && cropRect.Width + 19*2 >= 1366 |
|---|
| 1067 | { |
|---|
| 1068 | dstRect.Width = PanelWidth - ZoomWidth * 2 + cropRect.Left * 2; |
|---|
| 1069 | dstRect.Left = ZoomWidth - cropRect.Left; |
|---|
| 1070 | cropRect.Left = dstRect.Left; |
|---|
| 1071 | cropRect.Width = dstRect.Width; //1366 - 19 * 2 + cropRect.Left * 2; |
|---|
| 1072 | } |
|---|
| 1073 | else // dstRect.Top >= 0 |
|---|
| 1074 | { |
|---|
| 1075 | dstRect.Width -= ZoomWidth * 2; |
|---|
| 1076 | dstRect.Left += ZoomWidth; |
|---|
| 1077 | cropRect.Left = dstRect.Left; |
|---|
| 1078 | cropRect.Width = dstRect.Width; |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | } |
|---|
| 1082 | } |
|---|
| 1083 | |
|---|
| 1084 | printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); |
|---|
| 1085 | printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); |
|---|
| 1086 | |
|---|
| 1087 | AclOvl_SetDstWindow(g_dstcap.hOvlCap,&dstRect,g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 1088 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1089 | |
|---|
| 1090 | DHL_DISP_MuteMain(0); |
|---|
| 1091 | |
|---|
| 1092 | #if 0 |
|---|
| 1093 | WidthRatio = file->ImgWidthSize / 1366.0; |
|---|
| 1094 | HeightRatio = file->ImgHeightSize / 768.0; |
|---|
| 1095 | |
|---|
| 1096 | printf("Ratio W %f H %f\n", WidthRatio, HeightRatio); |
|---|
| 1097 | |
|---|
| 1098 | if( WidthRatio > HeightRatio ) |
|---|
| 1099 | { |
|---|
| 1100 | w = PanelWidth; |
|---|
| 1101 | h = file->ImgHeightSize * PanelWidth / file->ImgWidthSize; |
|---|
| 1102 | |
|---|
| 1103 | x = 0; |
|---|
| 1104 | y = (PanelHeight - h) / 2; |
|---|
| 1105 | printf("draw x %d y = %d w %d height %d\n", x, y, w, h); |
|---|
| 1106 | |
|---|
| 1107 | } |
|---|
| 1108 | else |
|---|
| 1109 | { |
|---|
| 1110 | w = file->ImgWidthSize * PanelHeight / file->ImgHeightSize; |
|---|
| 1111 | h = PanelHeight; |
|---|
| 1112 | |
|---|
| 1113 | x = (PanelWidth - w) / 2; |
|---|
| 1114 | y = 0; |
|---|
| 1115 | printf("draw x %d y = %d w %d h %d\n", x, y, w, h); |
|---|
| 1116 | } |
|---|
| 1117 | |
|---|
| 1118 | curJpegWidth = w; |
|---|
| 1119 | curJpegHeight = h; |
|---|
| 1120 | |
|---|
| 1121 | DHL_DISP_MuteMain(1); |
|---|
| 1122 | |
|---|
| 1123 | switch(zoom) |
|---|
| 1124 | { |
|---|
| 1125 | case Original: |
|---|
| 1126 | dstRect.Left = x; |
|---|
| 1127 | dstRect.Top = y; |
|---|
| 1128 | dstRect.Width = w; |
|---|
| 1129 | dstRect.Height = h; |
|---|
| 1130 | |
|---|
| 1131 | cropRect.Left = x; |
|---|
| 1132 | cropRect.Top = y; |
|---|
| 1133 | cropRect.Width = w; |
|---|
| 1134 | cropRect.Height = h; |
|---|
| 1135 | case FirstStep: |
|---|
| 1136 | if( WidthRatio > HeightRatio ) |
|---|
| 1137 | { |
|---|
| 1138 | dstRect.Left = x; |
|---|
| 1139 | dstRect.Top = y - ZoomHeight; |
|---|
| 1140 | dstRect.Width = w; |
|---|
| 1141 | dstRect.Height = h + ZoomHeight * 2; |
|---|
| 1142 | |
|---|
| 1143 | cropRect.Left = dstRect.Left + ZoomWidth; |
|---|
| 1144 | cropRect.Top = dstRect.Top; |
|---|
| 1145 | cropRect.Width = dstRect.Width - ZoomWidth * 2; |
|---|
| 1146 | cropRect.Height = dstRect.Height; |
|---|
| 1147 | } |
|---|
| 1148 | else |
|---|
| 1149 | { |
|---|
| 1150 | dstRect.Left = x - ZoomWidth; |
|---|
| 1151 | dstRect.Top = y; |
|---|
| 1152 | dstRect.Width = w + ZoomWidth * 2; |
|---|
| 1153 | dstRect.Height = h; |
|---|
| 1154 | |
|---|
| 1155 | cropRect.Left = dstRect.Left; |
|---|
| 1156 | cropRect.Top = dstRect.Top + ZoomHeight; |
|---|
| 1157 | cropRect.Width = dstRect.Width; |
|---|
| 1158 | cropRect.Height = dstRect.Height - ZoomHeight * 2; |
|---|
| 1159 | } |
|---|
| 1160 | break; |
|---|
| 1161 | case SecondStep: |
|---|
| 1162 | if( WidthRatio > HeightRatio ) |
|---|
| 1163 | { |
|---|
| 1164 | dstRect.Left = x; |
|---|
| 1165 | if(dstRect.Top > ZoomHeight * 2) |
|---|
| 1166 | dstRect.Top = y - ZoomHeight * 2; |
|---|
| 1167 | else |
|---|
| 1168 | dstRect.Top = 0; |
|---|
| 1169 | dstRect.Width = w; |
|---|
| 1170 | dstRect.Height = h + ZoomHeight * 2 * 2; |
|---|
| 1171 | |
|---|
| 1172 | cropRect.Left = dstRect.Left + ZoomWidth * 2; |
|---|
| 1173 | cropRect.Top = dstRect.Top; |
|---|
| 1174 | cropRect.Width = dstRect.Width - ZoomWidth * 2 * 2; |
|---|
| 1175 | cropRect.Height = dstRect.Height; |
|---|
| 1176 | } |
|---|
| 1177 | else |
|---|
| 1178 | { |
|---|
| 1179 | dstRect.Left = x - ZoomWidth * 2; |
|---|
| 1180 | dstRect.Top = y; |
|---|
| 1181 | dstRect.Width = w + ZoomWidth * 2 * 2; |
|---|
| 1182 | dstRect.Height = h; |
|---|
| 1183 | |
|---|
| 1184 | cropRect.Left = dstRect.Left; |
|---|
| 1185 | cropRect.Top = dstRect.Top + ZoomHeight * 2; |
|---|
| 1186 | cropRect.Width = dstRect.Width; |
|---|
| 1187 | cropRect.Height = dstRect.Height - ZoomHeight * 2 * 2; |
|---|
| 1188 | } |
|---|
| 1189 | break; |
|---|
| 1190 | case ThirdStep: |
|---|
| 1191 | if( WidthRatio > HeightRatio ) |
|---|
| 1192 | { |
|---|
| 1193 | dstRect.Left = x; |
|---|
| 1194 | dstRect.Top = y - ZoomHeight * 3; |
|---|
| 1195 | dstRect.Width = w; |
|---|
| 1196 | dstRect.Height = h + ZoomHeight * 3 * 2; |
|---|
| 1197 | |
|---|
| 1198 | cropRect.Left = dstRect.Left + ZoomWidth * 3; |
|---|
| 1199 | cropRect.Top = dstRect.Top; |
|---|
| 1200 | cropRect.Width = dstRect.Width - ZoomWidth * 3 * 2; |
|---|
| 1201 | cropRect.Height = dstRect.Height; |
|---|
| 1202 | } |
|---|
| 1203 | else |
|---|
| 1204 | { |
|---|
| 1205 | dstRect.Left = x - ZoomWidth * 3; |
|---|
| 1206 | dstRect.Top = y; |
|---|
| 1207 | dstRect.Width = w + ZoomWidth * 3 * 2; |
|---|
| 1208 | dstRect.Height = h; |
|---|
| 1209 | |
|---|
| 1210 | cropRect.Left = dstRect.Left; |
|---|
| 1211 | cropRect.Top = dstRect.Top + ZoomHeight * 3; |
|---|
| 1212 | cropRect.Width = dstRect.Width; |
|---|
| 1213 | cropRect.Height = dstRect.Height - ZoomHeight * 3 * 2; |
|---|
| 1214 | } |
|---|
| 1215 | break; |
|---|
| 1216 | case ForthStep: |
|---|
| 1217 | if( WidthRatio > HeightRatio ) |
|---|
| 1218 | { |
|---|
| 1219 | dstRect.Left = x; |
|---|
| 1220 | dstRect.Top = y - ZoomHeight * 4; |
|---|
| 1221 | dstRect.Width = w; |
|---|
| 1222 | dstRect.Height = h + ZoomHeight * 4 * 2; |
|---|
| 1223 | |
|---|
| 1224 | cropRect.Left = dstRect.Left + ZoomWidth * 4; |
|---|
| 1225 | cropRect.Top = dstRect.Top; |
|---|
| 1226 | cropRect.Width = dstRect.Width - ZoomWidth * 4 * 2; |
|---|
| 1227 | cropRect.Height = dstRect.Height; |
|---|
| 1228 | } |
|---|
| 1229 | else |
|---|
| 1230 | { |
|---|
| 1231 | dstRect.Left = x - ZoomWidth * 4; |
|---|
| 1232 | dstRect.Top = y; |
|---|
| 1233 | dstRect.Width = w + ZoomWidth * 4 * 2; |
|---|
| 1234 | dstRect.Height = h; |
|---|
| 1235 | |
|---|
| 1236 | cropRect.Left = dstRect.Left; |
|---|
| 1237 | cropRect.Top = dstRect.Top + ZoomHeight * 4; |
|---|
| 1238 | cropRect.Width = dstRect.Width; |
|---|
| 1239 | cropRect.Height = dstRect.Height - ZoomHeight * 4 * 2; |
|---|
| 1240 | } |
|---|
| 1241 | break; |
|---|
| 1242 | default: |
|---|
| 1243 | return; |
|---|
| 1244 | } |
|---|
| 1245 | // printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); |
|---|
| 1246 | // printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); |
|---|
| 1247 | |
|---|
| 1248 | AclOvl_SetDstWindow(g_dstcap.hOvlCap,&dstRect,g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 1249 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1250 | |
|---|
| 1251 | DHL_DISP_MuteMain(0); |
|---|
| 1252 | |
|---|
| 1253 | printf("|%s|current Jpeg %d %d\n", __FUNCTION__, g_current_display_jpeg.ImgWidthSize, g_current_display_jpeg.ImgHeightSize); |
|---|
| 1254 | // g_current_display_jpeg.ImgWidthSize = ovlRect.Width; |
|---|
| 1255 | // g_current_display_jpeg.ImgHeightSize = ovlRect.Height; |
|---|
| 1256 | // g_current_display_jpeg.pitch = new_pitch; |
|---|
| 1257 | // file->ImgHeightSize = MY ; |
|---|
| 1258 | // file->ImgWidthSize = MX ; |
|---|
| 1259 | #endif |
|---|
| 1260 | #endif |
|---|
| 1261 | |
|---|
| 1262 | } |
|---|
| 1263 | |
|---|
| 1264 | void DHL_MoveJpeg(JpgFileInfo *t, Direction dr) |
|---|
| 1265 | { |
|---|
| 1266 | #if USE_ACL |
|---|
| 1267 | ACL_RECT cropRect, dstRect; |
|---|
| 1268 | |
|---|
| 1269 | AclOvl_GetDstWindow(g_dstcap.hOvlCap,&dstRect); |
|---|
| 1270 | AclOvl_GetCropWindow(g_dstcap.hOvlCap,ACL_OVL_CROP_SRC,&cropRect); |
|---|
| 1271 | |
|---|
| 1272 | printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); |
|---|
| 1273 | printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); |
|---|
| 1274 | switch(dr) |
|---|
| 1275 | { |
|---|
| 1276 | case MoveUp: |
|---|
| 1277 | // if(curJpegHeight >= 768) |
|---|
| 1278 | { |
|---|
| 1279 | if( (cropRect.Top >= ZoomHeight) && (dstRect.Height >= PanelHeight) ) |
|---|
| 1280 | { |
|---|
| 1281 | cropRect.Top -= ZoomHeight; |
|---|
| 1282 | hMoveStep++; |
|---|
| 1283 | } |
|---|
| 1284 | // else |
|---|
| 1285 | // cropRect.Top = 0; |
|---|
| 1286 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1287 | } |
|---|
| 1288 | break; |
|---|
| 1289 | case MoveDown: |
|---|
| 1290 | // if(curJpegHeight >= 768) |
|---|
| 1291 | { |
|---|
| 1292 | if( (cropRect.Height + cropRect.Top < PanelHeight) && (dstRect.Height >= PanelHeight) ) |
|---|
| 1293 | { |
|---|
| 1294 | cropRect.Top += ZoomHeight; |
|---|
| 1295 | hMoveStep--; |
|---|
| 1296 | } |
|---|
| 1297 | // else |
|---|
| 1298 | // cropRect.Top = 768 - cropRect.Height; |
|---|
| 1299 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1300 | } |
|---|
| 1301 | break; |
|---|
| 1302 | case MoveLeft: |
|---|
| 1303 | // if(curJpegWidth >= 1366) |
|---|
| 1304 | { |
|---|
| 1305 | if( (cropRect.Left >= ZoomWidth) && (dstRect.Width >= PanelWidth) ) |
|---|
| 1306 | { |
|---|
| 1307 | cropRect.Left -= ZoomWidth; |
|---|
| 1308 | wMoveStep++; |
|---|
| 1309 | } |
|---|
| 1310 | // else |
|---|
| 1311 | // cropRect.Left = 0; |
|---|
| 1312 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1313 | } |
|---|
| 1314 | break; |
|---|
| 1315 | case MoveRight: |
|---|
| 1316 | // if(curJpegWidth >= 1366) |
|---|
| 1317 | { |
|---|
| 1318 | if( (cropRect.Width + cropRect.Left < PanelWidth) && (dstRect.Width >= PanelWidth) ) |
|---|
| 1319 | { |
|---|
| 1320 | cropRect.Left += ZoomWidth; |
|---|
| 1321 | wMoveStep--; |
|---|
| 1322 | } |
|---|
| 1323 | // else |
|---|
| 1324 | // cropRect.Left = 768 - cropRect.Width; |
|---|
| 1325 | AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); |
|---|
| 1326 | } |
|---|
| 1327 | break; |
|---|
| 1328 | } |
|---|
| 1329 | #endif |
|---|
| 1330 | } |
|---|
| 1331 | |
|---|
| 1332 | #if 1 |
|---|
| 1333 | void DHL_JpegThumbnailclear(DS_U32 xpos, DS_U32 ypos) |
|---|
| 1334 | { |
|---|
| 1335 | #if USE_ACL |
|---|
| 1336 | DS_U32 x,y,k; |
|---|
| 1337 | char *p; |
|---|
| 1338 | DS_U32 pitch; |
|---|
| 1339 | |
|---|
| 1340 | //pitch = get_thumbnail_pitch(); |
|---|
| 1341 | |
|---|
| 1342 | // xpos = ((xpos - 28 ) / 214) * 214 + 28; |
|---|
| 1343 | // ypos = ((ypos - 83 ) / 205) * 205 + 83; |
|---|
| 1344 | |
|---|
| 1345 | // printf("pitch %d in %s\n", pitch, __FUNCTION__); |
|---|
| 1346 | for(y=0;y<ThumbnailFrameSize;y++) |
|---|
| 1347 | { |
|---|
| 1348 | for(x=0;x<ThumbnailFrameSize;x++) |
|---|
| 1349 | { |
|---|
| 1350 | p = g_dstvid.pFrameBuff + ((pitch * (ypos + y)) + x + xpos) * 4; |
|---|
| 1351 | for(k=0;k<3;k++) |
|---|
| 1352 | *p++ = 0xff; |
|---|
| 1353 | } |
|---|
| 1354 | } |
|---|
| 1355 | #endif |
|---|
| 1356 | } |
|---|
| 1357 | |
|---|
| 1358 | #if USE_ACL |
|---|
| 1359 | static char *s_DumpMemory[ThumbnailFrameSize*4]; |
|---|
| 1360 | #endif |
|---|
| 1361 | |
|---|
| 1362 | void DHL_DumpReadJpegBG(DS_U32 xpos, DS_U32 ypos) |
|---|
| 1363 | { |
|---|
| 1364 | #if USE_ACL |
|---|
| 1365 | DS_U32 x,y,k; |
|---|
| 1366 | unsigned char *p; |
|---|
| 1367 | DS_U32 pitch; |
|---|
| 1368 | //pitch = get_thumbnail_pitch(); |
|---|
| 1369 | // printf("pitch %d in %s\n", pitch, __FUNCTION__); |
|---|
| 1370 | |
|---|
| 1371 | // s_DumpMemory = (char*)malloc(sizeof(char*) * ThumbnailFrameSize); |
|---|
| 1372 | s_DumpMemory = (char(*)[ThumbnailFrameSize*4])(g_dstvid.pFrameBuff + pitch * PanelHeight*4); |
|---|
| 1373 | |
|---|
| 1374 | for(y=0;y<ThumbnailFrameSize;y++) |
|---|
| 1375 | { |
|---|
| 1376 | // s_DumpMemory[y] = malloc(ThumbnailFrameSize * 4 ); |
|---|
| 1377 | for(x=0;x<ThumbnailFrameSize;x++) |
|---|
| 1378 | { |
|---|
| 1379 | p = g_dstvid.pFrameBuff + ((pitch * (ypos + y)) + x + xpos) * 4; |
|---|
| 1380 | for(k=0;k<4;k++) |
|---|
| 1381 | s_DumpMemory[y][x*4 + k] = *p++; |
|---|
| 1382 | } |
|---|
| 1383 | } |
|---|
| 1384 | #endif |
|---|
| 1385 | } |
|---|
| 1386 | |
|---|
| 1387 | void DHL_DumpWriteJpegBG(DS_U32 xpos, DS_U32 ypos) |
|---|
| 1388 | { |
|---|
| 1389 | #if USE_ACL |
|---|
| 1390 | DS_U32 x,y,k; |
|---|
| 1391 | unsigned char *p; |
|---|
| 1392 | DS_U32 pitch; |
|---|
| 1393 | |
|---|
| 1394 | if( s_DumpMemory == NULL) |
|---|
| 1395 | return; |
|---|
| 1396 | |
|---|
| 1397 | //pitch = get_thumbnail_pitch(); |
|---|
| 1398 | // printf("pitch %d in %s\n", pitch, __FUNCTION__); |
|---|
| 1399 | for(y=0;y<ThumbnailFrameSize;y++) |
|---|
| 1400 | { |
|---|
| 1401 | for(x=0;x<ThumbnailFrameSize;x++) |
|---|
| 1402 | { |
|---|
| 1403 | p = g_dstvid.pFrameBuff + ((pitch * (ypos + y)) + x + xpos) * 4; |
|---|
| 1404 | for(k=0;k<4;k++) |
|---|
| 1405 | *p++ = s_DumpMemory[y][x*4 + k]; |
|---|
| 1406 | } |
|---|
| 1407 | // free(s_DumpMemory[y]); |
|---|
| 1408 | } |
|---|
| 1409 | // free(s_DumpMemory); |
|---|
| 1410 | s_DumpMemory = NULL; |
|---|
| 1411 | #endif |
|---|
| 1412 | } |
|---|
| 1413 | |
|---|
| 1414 | #endif |
|---|
| 1415 | void DHL_ScreenClear(void); |
|---|
| 1416 | void DHL_ThumbnailStart(void) |
|---|
| 1417 | { |
|---|
| 1418 | #if USE_ACL |
|---|
| 1419 | DS_U16 pitch,width,height, ulSrcAlignment; |
|---|
| 1420 | ACL_RESULT rc; |
|---|
| 1421 | DS_U32 offset; |
|---|
| 1422 | ACL_RECT ovlRect; |
|---|
| 1423 | |
|---|
| 1424 | printf("%s is start\n", __FUNCTION__); |
|---|
| 1425 | |
|---|
| 1426 | if(DD_VIDEO_IsStarted() && !DHL_AV_IsPIPActive()) |
|---|
| 1427 | { |
|---|
| 1428 | DHL_AV_Stop(); |
|---|
| 1429 | } |
|---|
| 1430 | //2. If cap AV started on normal mode, stop it before cap start. |
|---|
| 1431 | if(DD_CAP_IsStartedVideo() && !DHL_AV_IsPIPActive()) |
|---|
| 1432 | { |
|---|
| 1433 | DHL_CAP_Stop(); |
|---|
| 1434 | } |
|---|
| 1435 | |
|---|
| 1436 | if( g_dstcap.hOvlCap == 0) |
|---|
| 1437 | { |
|---|
| 1438 | DD_CAP_OpenCompOvlCap(); |
|---|
| 1439 | } |
|---|
| 1440 | |
|---|
| 1441 | if( g_dstcap.hDisp == 0) |
|---|
| 1442 | { |
|---|
| 1443 | DD_CAP_OpenCompDisp(); |
|---|
| 1444 | } |
|---|
| 1445 | ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); |
|---|
| 1446 | |
|---|
| 1447 | width = PanelWidth; |
|---|
| 1448 | height = PanelHeight; |
|---|
| 1449 | |
|---|
| 1450 | ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width, height, &pitch)); |
|---|
| 1451 | |
|---|
| 1452 | offset = g_dstvid.uFrameBuffBaseOffset; |
|---|
| 1453 | |
|---|
| 1454 | ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); |
|---|
| 1455 | |
|---|
| 1456 | DD_CAP_DisconnectCompVidVc(); |
|---|
| 1457 | AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL); |
|---|
| 1458 | |
|---|
| 1459 | AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp); |
|---|
| 1460 | ovlRect.Left = 0; |
|---|
| 1461 | ovlRect.Top = 0; |
|---|
| 1462 | ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 1463 | ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 1464 | |
|---|
| 1465 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, |
|---|
| 1466 | &ovlRect, |
|---|
| 1467 | g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 1468 | |
|---|
| 1469 | AclOvl_Enable(g_dstcap.hOvlCap , TRUE ); |
|---|
| 1470 | AclDisp_SetEnable( g_dstcap.hDisp, TRUE); |
|---|
| 1471 | DHL_ScreenClear(); |
|---|
| 1472 | #endif |
|---|
| 1473 | } |
|---|
| 1474 | |
|---|
| 1475 | void DHL_JpegAppCallBack(void (*func)(JpegEvent*)) |
|---|
| 1476 | { |
|---|
| 1477 | //dhl_set_jpeg_callback (func); |
|---|
| 1478 | } |
|---|
| 1479 | |
|---|
| 1480 | void DHL_ScreenClear(void) |
|---|
| 1481 | { |
|---|
| 1482 | #if USE_ACL |
|---|
| 1483 | DS_U32 x,y,k,i; |
|---|
| 1484 | char *p; |
|---|
| 1485 | char **pp; |
|---|
| 1486 | DS_U32 pitch, ulSrcAlignment=0, offset; |
|---|
| 1487 | DS_U32 xpos=0, ypos=0; |
|---|
| 1488 | //ACL_RECT dstRect, ovlRect; |
|---|
| 1489 | unsigned char *image_ptr; |
|---|
| 1490 | |
|---|
| 1491 | DHL_DISP_MuteMain(1); |
|---|
| 1492 | pp = (char **)malloc(PanelHeight * sizeof(char *)); |
|---|
| 1493 | |
|---|
| 1494 | for(y=0;y<PanelHeight;y++) |
|---|
| 1495 | { |
|---|
| 1496 | pp[y] = (char *)malloc(PanelWidth*3); |
|---|
| 1497 | for(x=0;x<PanelWidth * 3;x++) |
|---|
| 1498 | pp[y][x] = 0xff; |
|---|
| 1499 | } |
|---|
| 1500 | |
|---|
| 1501 | // printf("pitch %d in %s\n", pitch, __FUNCTION__); |
|---|
| 1502 | |
|---|
| 1503 | for(i=0;i<PanelHeight;i++) |
|---|
| 1504 | { |
|---|
| 1505 | sun_put_pixel_rows(TRUE, pitch, PanelWidth, pp[i], i, 0, 0); |
|---|
| 1506 | } |
|---|
| 1507 | |
|---|
| 1508 | for(i=0;i<PanelHeight;i++) |
|---|
| 1509 | free(pp[i]); |
|---|
| 1510 | free(pp); |
|---|
| 1511 | |
|---|
| 1512 | offset = g_dstvid.uFrameBuffBaseOffset; |
|---|
| 1513 | |
|---|
| 1514 | ovlRect.Left = 0; |
|---|
| 1515 | ovlRect.Top = 0; |
|---|
| 1516 | ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; |
|---|
| 1517 | ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; |
|---|
| 1518 | |
|---|
| 1519 | AclOvl_SetDstWindow(g_dstcap.hOvlCap, &ovlRect, g_dstvid.OvlOptions.PreserveAspectRatio); |
|---|
| 1520 | |
|---|
| 1521 | DHL_DISP_MuteMain(0); |
|---|
| 1522 | #endif |
|---|
| 1523 | } |
|---|
| 1524 | |
|---|
| 1525 | void DHL_JpegCancel(void) |
|---|
| 1526 | { |
|---|
| 1527 | jpeg_decoding_cancel = 1; |
|---|
| 1528 | } |
|---|
| 1529 | |
|---|
| 1530 | |
|---|
| 1531 | ExifCode RecordedIFDtag[] = |
|---|
| 1532 | { |
|---|
| 1533 | ExifCode_Make , |
|---|
| 1534 | ExifCode_Model , |
|---|
| 1535 | //ExifCode_StripOffset , |
|---|
| 1536 | |
|---|
| 1537 | ExifCode_FNumber , |
|---|
| 1538 | //ExifCode_ExifIFDPointer , |
|---|
| 1539 | //ExifCode_GPSInfoIFDPointer |
|---|
| 1540 | ExifCode_ISOSpeedRatings , |
|---|
| 1541 | ExifCode_ExposureTime , |
|---|
| 1542 | ExifCode_DateTime , |
|---|
| 1543 | ExifCode_ExposureBiasValue , |
|---|
| 1544 | ExifCode_Flash , |
|---|
| 1545 | ExifCode_ExposureMode |
|---|
| 1546 | }; |
|---|