#include #include "dsthalcommon.h" #include "dsthal_photoview.h" //#include "dstddcap.h" //#include "dstddav.h" #include "dstjpeg.h" //extern DST_CAP g_dstcap; //extern DST_VID g_dstvid; //extern ACL_HANDLE g_DSTChip; //static DS_S8 wMoveStep = 0; //static DS_S8 hMoveStep = 0; /* b_ThbImage : 0 -> thumbnail image is not made. 1 -> make thumbnail image */ #define PanelWidth 1366 #define PanelHeight 768 #define MulShift 2048 #define ZoomWidth 19 // 1366 * 0.05(5%) #define ZoomHeight 34 // 768 * 0.05(5%) int DHL_GetJpegExif(JpgFileInfo *file, DS_U8 b_ThbImage) { unsigned int width, height; #if 1 unsigned char p1[180][180*3]; int Wi, Wi_1, Wj, Wj_1; int Mwh; unsigned int org_width, org_height; int ii, jj,ret = 2; #else unsigned char pw[180][180][3]; unsigned char p1[180][180][3]; #endif DS_S32 x,y,k,i,j; char **image, **imageold; #if 1 if( file->exifInfo && file->exifInfo->ThumbnailImage ) { printf("skiled %s\n", __FUNCTION__); return 0; } // if( (ret = JpegDec(TRUE,file->Name,b_ThbImage, file)) < 2 ) return ret; #else JpegDec(TRUE,file->Name,b_ThbImage, file); #endif image = file->exifInfo->ThumbnailImage; width = file->exifInfo->ThumbnailWidth; height = file->exifInfo->ThumbnailHeight; imageold =file->exifInfo->ThumbnailImage; //printf("DHL_GetJpegExif %d\n",get_thumbnail_pitch() ); org_width =file->exifInfo->ThumbnailWidth ; org_height=file->exifInfo->ThumbnailHeight; /* JPEG image? width/height´Âfile->...->ThumbnailWidth(Height)?. ? °ª8·Î¸¸µé°í´ÂThumbnail image ũ±â¸?dÇ´Ù */ //printf("width %d, height%d\n", org_width, org_height); if(image == NULL) { printf("||||| %s %d||||||\n", __FUNCTION__, __LINE__); return ret; } if(org_width>org_height) { if(org_width==ThumbnailResoltuion) { printf("Oops: Original Thumbnail is too large to scale\n"); return ret; } width = ThumbnailResoltuion; height = org_height*ThumbnailResoltuion/org_width; } else { if(org_height==ThumbnailResoltuion) { printf("Oops: Original Thumbnail is too large to scale\n"); return ret; } width = org_width * ThumbnailResoltuion/ org_height; height = ThumbnailResoltuion; } #if 1 /* original image¸¦ º¹»ç´Ù */ for(y=0;yexifInfo->ThumbnailHeight;y++) { for(x=0; xexifInfo->ThumbnailWidth; x++) { for(k=0;k<3;k++) { p1[y][x*3+k] = image[y][x*3+k]; } } } /* image memory¸¦ allocÇ´Ù */ //printf("height %d width %d\n", height,width); image = (char**) malloc(height*sizeof(char*)); if(image == NULL) { printf("error malloc fail %s %d\n", __FUNCTION__, __LINE__); return 2; } for(y=0;yexifInfo->ThumbnailHeight;i++) free(imageold[i]); free(imageold); file->exifInfo->ThumbnailImage = image; file->exifInfo->ThumbnailWidth = width; file->exifInfo->ThumbnailHeight = height; #endif return ret; } void DHL_DrawJpegThumbnail(JpgFileInfo *file, DS_U32 xPos, DS_U32 yPos) { int i; // DS_U16 pitch; //pitch = get_thumbnail_pitch(); if(file == NULL || file->exifInfo == NULL) { if( file == NULL) printf("file is NULL\n"); if(file->exifInfo == NULL) printf("file->exifInfo == NULL\n"); return; } if(file->exifInfo->ThumbnailImage == NULL) { printf("no thumbnail image\n"); return; } for(i=0;iexifInfo->ThumbnailHeight;i++) { if( file->exifInfo->ThumbnailImage[i] == NULL) { printf("file->exifInfo->ThumbnailImage[i] == NULL\n"); return; } #if USE_ACL sun_put_pixel_rows(TRUE, pitch, file->exifInfo->ThumbnailWidth,file->exifInfo->ThumbnailImage[i],i,xPos, yPos); #endif } } static int jpeg_message_q_id; char jpeg_decoding_cancel; typedef struct{ char type; // 0 : jpeg decoding . 1 : cancel char rotate; char jpegRotate; char *Name; DS_U32 ImgWidthSize; DS_U32 ImgHeightSize; } JpegDecodeMsg; JpgFileInfo g_current_display_jpeg; void dhl_task_jpegdecoding(void) { JpegDecodeMsg JpegMsg; DS_U32 read_len; int ret=0 ; JpgFileInfo *file; unsigned int width,height; file = &g_current_display_jpeg; float WidthRatio = 0.0, HeightRatio = 0.0; DS_U32 x=0, y=0, w=0, h=0; DS_U8 rotate; DS_U32 tmp_width, tmp_height; while(1) { OS_ReceiveMessage(jpeg_message_q_id, (DS_U32 *)&JpegMsg, sizeof(JpegDecodeMsg), &read_len); if(JpegMsg.type == 1) { printf("jpeg task is exit\n"); return; } strcpy( file->Name , JpegMsg.Name); file->RotationInfo = JpegMsg.rotate; file->JpegRotateInfo = JpegMsg.jpegRotate; file->ImgWidthSize = JpegMsg.ImgWidthSize; file->ImgHeightSize = JpegMsg.ImgHeightSize; file->exifInfo = NULL; free(JpegMsg.Name); // g_current_display_jpeg = *gp_CurSelectJpeg; // printf("g_current_display_jpeg name %s\n", g_current_display_jpeg.Name); //fprintf(stderr,"|%s|%d|\n",__FUNCTION__,__LINE__); //getchar(); DHL_DISP_MuteMain(1); // if(! file->RotationInfo ) { // ret = JpegDec(FALSE, file->Name, 0, file); if( ret == 0 || ret == 1) return ; rotate = file->RotationInfo ; file->JpegRotateInfo = 0; if( rotate == EnRotate90 || rotate == EnRotate270) { tmp_height = file->ImgWidthSize ; tmp_width = file->ImgHeightSize ; } else { tmp_width = file->ImgWidthSize ; tmp_height = file->ImgHeightSize ; } WidthRatio = tmp_width / 1366.0; HeightRatio = tmp_height / 768.0; printf("Ratio W %f H %f\n", WidthRatio, HeightRatio); if( WidthRatio > HeightRatio ) { w = PanelWidth; h = tmp_height * PanelWidth / tmp_width ; x = 0; y = (PanelHeight - h) / 2; printf("draw x %ld y = %ld w %ld height %ld\n", x, y, w, h); } else { w = tmp_width * PanelHeight / tmp_height ; h = PanelHeight; x = (PanelWidth - w) / 2; y = 0; printf("draw x %ld y = %ld w %ld h %ld\n", x, y, w, h); } } // else { DHL_JpegRotate(file,rotate, w, h); } // *gp_CurSelectJpeg = g_current_display_jpeg; DHL_DISP_MuteMain(0); //fprintf(stderr,"|%s|%d|\n",__FUNCTION__,__LINE__); //getchar(); #if 0 width = jpgifno.ImgWidthSize; height = jpgifno.ImgHeightSize; #endif width = file->ImgWidthSize ; height =file->ImgHeightSize ; printf("h %d w %d \n", height, width ); #if USE_ACL ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width, height, &pitch)); file->pitch = pitch; offset = g_dstvid.uFrameBuffBaseOffset; ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); DD_CAP_DisconnectCompVidVc(); printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL)); printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp) ); ovlRect.Left = x; ovlRect.Top = y; ovlRect.Width = w; ovlRect.Height = h; // ovlRect.Left = 0; // ovlRect.Top = 0; // ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; // ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; AclOvl_SetDstWindow(g_dstcap.hOvlCap, &ovlRect, g_dstvid.OvlOptions.PreserveAspectRatio); #endif } } int DHL_JpegDecoding(JpgFileInfo *file) { int ret=0; static char JpegTaskCreateFlag = 0; JpegDecodeMsg JpegMsg; // gp_CurSelectJpeg = file; if(JpegTaskCreateFlag == 0) { JpegTaskCreateFlag = 1; jpeg_message_q_id = OS_CreateMessageQueue("gCCManagerMsgQ", 0/*OS_MSGQ_FIFO*/, 100, sizeof(JpegDecodeMsg)); OS_SpawnTask((void(*))dhl_task_jpegdecoding, "jpeg task", 10, 1000, (DS_U32)NULL); } // JpgFileInfo jpgifno; printf("size of int %d short %d long %d\n", sizeof(int), sizeof(short), sizeof(long)); DHL_DTV_StopAV(); DHL_CAP_Stop(0,0); JpegMsg.Name = malloc(sizeof(file->Name) + 1); strcpy(JpegMsg.Name , file->Name); JpegMsg.type = 0; JpegMsg.rotate = file->RotationInfo; JpegMsg.jpegRotate = file->JpegRotateInfo; JpegMsg.ImgWidthSize = file->ImgWidthSize; JpegMsg.ImgHeightSize = file->ImgHeightSize; OS_SendMessage(jpeg_message_q_id, (DS_U32 *)&JpegMsg, sizeof(JpegDecodeMsg)); /* ret = JpegDec(FALSE, file->Name, 0, file); if( ret == 0 || ret == 1) return ret; if( file->RotationInfo ) DHL_JpegRotate(file,file->RotationInfo); #if 0 width = jpgifno.ImgWidthSize; height = jpgifno.ImgHeightSize; #endif width = file->ImgWidthSize ; height =file->ImgHeightSize ; // printf("h %d w %d \n", height, width ); // printf("g_dstcap.hOvlCap %u g_dstvid.hOVL %u\n", g_dstcap.hOvlCap , g_dstvid.hOVL); #if 1 ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width, height, &pitch)); offset = g_dstvid.uFrameBuffBaseOffset; ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); DD_CAP_DisconnectCompVidVc(); #endif printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL)); printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp) ); // ovlRect.Left = x; // ovlRect.Top = y; // ovlRect.Width = w; // ovlRect.Height = h; ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; #if 0 printf("ovl w %d h %d\n", ovlRect.Width , ovlRect.Height); if( (100 * bmpimage.height) / bmpimage.width) > ((100* g_dstvid.OvlOptions.DestinationHeight) / g_dstvid.OvlOptions.DestinationWidth)) { ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; ovlRect.Width = (g_dstvid.OvlOptions.DestinationHeight* bmpimage.width) / bmpimage.height ; ovlRect.Left = (g_dstvid.OvlOptions.DestinationHeight - ovlRect.Width ) /2; } else { ovlRect.Height = (g_dstvid.OvlOptions.DestinationWidth * bmpimage.height) / bmpimage.width; ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; ovlRect.Top = (g_dstvid.OvlOptions.DestinationWidth - ovlRect.Height )/2 ; } printf("bmp l %d t %d w %d h %d panel w %d h %d\n",ovlRect.Left, ovlRect.Top, bmpimage.width, bmpimage.height, ovlRect.Width, ovlRect.Height); #endif #if 1 AclOvl_SetDstWindow(g_dstcap.hOvlCap, &ovlRect, g_dstvid.OvlOptions.PreserveAspectRatio); #endif */ // DD_VIDEO_ConnectCompOvl(TRUE); #if USE_ACL printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclOvl_Enable(g_dstcap.hOvlCap , TRUE )); printf("|%s|%d| result = %d\n",__FUNCTION__,__LINE__,AclDisp_SetEnable( g_dstcap.hDisp, TRUE)); #endif return ret; } void DHL_FreeThumbnailImage(JpgFileInfo *file) { int i; if(file->exifInfo) { if(file->exifInfo->ThumbnailImage == NULL) { //printf("Image is empty in %s\n", __FUNCTION__); fprintf(stderr, "Image is empty in %s | %d |\n", __FUNCTION__, __LINE__); return; } } else { fprintf(stderr, "Exif is empty in %s | %d |\n", __FUNCTION__, __LINE__); return; } for(i=0;iexifInfo->ThumbnailHeight;i++) free(file->exifInfo->ThumbnailImage[i]); free(file->exifInfo->ThumbnailImage); printf("|| %s %d %s||\n", __FUNCTION__, __LINE__, file->Name); file->exifInfo->ThumbnailImage = NULL; } void DHL_FreeJpegThumbnailImage(ExifInfo *pe) { int i; if(pe) { if(pe->ThumbnailImage == NULL) { fprintf(stderr, "Image is empty in %s | %d |\n", __FUNCTION__, __LINE__); return; } } else { fprintf(stderr, "Exif is empty in %s | %d |\n", __FUNCTION__, __LINE__); return; } for(i=0;i ThumbnailHeight;i++) free(pe->ThumbnailImage[i]); free(pe->ThumbnailImage); pe->ThumbnailImage = NULL; } // this function remove all exif information as well as thumbnail image void DHL_FreeExif(ExifInfo *pe) { ExifInfo *pt; pt=pe; while(pt) { pe = pt->next; if(pt->EntryValue) free( pt->EntryValue); free(pt); pt = pe; } } void DHL_FreeJpegExif(ExifInfo *pe) { if(pe->ThumbnailImage) DHL_FreeJpegThumbnailImage(pe); DHL_FreeExif(pe); } void DHL_JpegThumbnailRotate(JpgFileInfo *file,EnRotate rotate, DS_U32 xPos, DS_U32 yPos) { ExifInfo *pEx; int i,Tx,Ty,t11,t12, t21,t22; int k,x,y,X,Y,MX, MY; int MaxX,MaxY; char **image, **timage; pEx = file->exifInfo; MaxX = pEx->ThumbnailWidth; MaxY = pEx->ThumbnailHeight; printf("%s is %s\n", file->Name, __FUNCTION__); printf("rotate %d file->RotationInfo %d file->ThmRotateInfo %d, jpeg rot %d\n", rotate, file->RotationInfo, file->ThmRotateInfo , file->JpegRotateInfo); file->RotationInfo = rotate ; rotate = (rotate + EnRotateEnd - file->ThmRotateInfo) % EnRotateEnd; file->ThmRotateInfo = file->RotationInfo; printf("diff rotate %d\n", rotate); printf("pEx->ThumbnailWidth %d , pEx->ThumbnailHeight %d\n", pEx->ThumbnailWidth, pEx->ThumbnailHeight); Tx = Ty = 0; t11 = t12 = t21 = t22 = 0; //if(file->NoDraw == 0) //DHL_JpegThumbnailclear(xPos, yPos); switch(rotate) { case EnRotate90: // Ty = pEx->ThumbnailWidth; t12 = 1; t21 = -1; MY = MaxX; MX = MaxY; Ty = MaxX-1; break; case EnRotate180: Tx = pEx->ThumbnailWidth-1; Ty = pEx->ThumbnailHeight-1; t11 = t22 = -1; MX = pEx->ThumbnailWidth; MY = pEx->ThumbnailHeight; break; case EnRotate270: t12 = -1; t21 = 1; MY = MaxX; MX = MaxY; Tx = MaxY - 1; break; default: if( file->NoDraw == 0) DHL_DrawJpegThumbnail(file,xPos,yPos); return; } printf("MX %d MY %d Tx %d Ty %d\n", MX, MY, Tx, Ty); image = (char**)malloc(sizeof(char*)*MY); // MaxX if(image == NULL) { printf("Error malloc in %d %s\n", __LINE__,__FUNCTION__); return; } for(y=0;yThumbnailHeight*/;y++) { for(x=0;x< MaxX /*pEx->ThumbnailWidth*/;x++) { X = Tx + t11 * x + t12 * y; // max MaxY Y = Ty + t21 * x + t22 * y; // max MaxX // printf("x %d y %d => X %d , Y %d\n", x,y,X,Y); #if 1 if( X >= MX|| X < 0) { printf("x%d y%d \n:", x,y); printf("memory fail : X %d \n",X); return; } if( Y >= MY || Y < 0) { printf("x%d y%d \n:", x,y); printf("memory fail : Y %d \n",Y); return; } #endif for(k=0;k<3;k++) { image[Y][X*3+k] = pEx->ThumbnailImage[y][x*3+k]; // MaxX, MaxY //Maxx, MaxY } } } timage = file->exifInfo->ThumbnailImage; x = file->exifInfo->ThumbnailWidth; y = file->exifInfo->ThumbnailHeight; file->exifInfo->ThumbnailImage = image; file->exifInfo->ThumbnailWidth = MX; file->exifInfo->ThumbnailHeight = MY; if( file->NoDraw == 0) DHL_DrawJpegThumbnail(file,xPos,yPos); // file->exifInfo->ThumbnailImage = timage; // file->exifInfo->ThumbnailWidth = x; // file->exifInfo->ThumbnailHeight = y; for(i=0;iThumbnailWidth %d , pEx->ThumbnailHeight %d\n", pEx->ThumbnailWidth, pEx->ThumbnailHeight); } void DHL_JpegRotate(JpgFileInfo *file, EnRotate rotate, DS_U32 width, DS_U32 height) { DS_U32 new_pitch; #if USE_ACL ACL_RESULT rc; #endif int Tx,Ty,t11,t12, t21,t22; int x,y,X,Y,MX, MY,k; int MaxX,MaxY; DS_U8 *u8src, *u8des; #if USE_ACL DS_U32 *u32src, *u32des, *u32org, *u32org1; DS_U32 u32tmp, u32_old; DS_U32 index, u32cnt,ulSrcAlignment; char *p; ACL_RECT ovlRect; DS_U32 offset; #endif float WidthRatio = 0.0, HeightRatio = 0.0; #if USE_ACL DS_U32 xpos=0, ypos=0; #endif DS_U32 w=0, h=0; MaxX = file->ImgWidthSize; MaxY = file->ImgHeightSize; Tx = Ty = 0; t11 = t12 = t21 = t22 = 0; printf("MaxX MaxY %d %d\n", MaxX, MaxY); printf("Cur Rotate %d new rotate %d jpeg rotate %d\n", file->RotationInfo , rotate, file->JpegRotateInfo ); if( file->RotationInfo == rotate && file->JpegRotateInfo == rotate ) return; file->NoDraw = 1; if( file->exifInfo && file->exifInfo->ThumbnailImage) DHL_JpegThumbnailRotate(file, rotate, 0,0); file->NoDraw = 0; DHL_DISP_MuteMain(1); file->RotationInfo = rotate ; rotate = (rotate + EnRotateEnd - file->JpegRotateInfo ) % EnRotateEnd; file->JpegRotateInfo = file->RotationInfo; switch(rotate) { case EnRotate90: t12 = 1; t21 = -1; MY = MaxX; MX = MaxY; Ty = MaxX-1; break; case EnRotate180: Tx = MaxX-1; Ty = MaxY-1; t11 = t22 = -1; MX = MaxX; MY = MaxY; break; case EnRotate270: t12 = -1; t21 = 1; MY = MaxX; MX = MaxY; Tx = MaxY - 1; break; default: return; } printf("MX MY %d %d\n", MX, MY); #if USE_ACL u32org = (DS_U32*)g_dstvid.pFrameBuff ; #endif new_pitch = file->pitch; #if 0 // if( rotate == EnRotate180 || rotate==EnRotate0) { printf("rotate 180 maxY/2 %d pitch %d\n", MaxY/2, file->pitch); for(y=0;y<(MaxY/2);y++) { u32src = u32org + file->pitch * y; u32des = u32org + file->pitch * (MaxY - 1 - y) + MaxX - 1; for(x=0;xpitch * y; u32des = u32org + file->pitch * (MaxY - 1 - y) + MaxX - 1; for(x=0;xpitch); u8des = (DS_U8*)g_dstvid.pFrameBuff + (file->pitch * MaxY)*4; u8src = (DS_U8*)g_dstvid.pFrameBuff ; #else u8des = 0; u8src = 0; #endif for(y=0;y< MaxY /*pEx->ThumbnailHeight*/;y++) { for(x=0;x< MaxX /*pEx->ThumbnailWidth*/;x++) { X = Tx + t11 * x + t12 * y; // max MaxY Y = Ty + t21 * x + t22 * y; // max MaxX for(k=0;k<4;k++) { *(u8des+(Y*new_pitch+X)*4+k) = *(u8src+(y*file->pitch+x)*4+k); } } } #if USE_ACL u8des = g_dstvid.pFrameBuff ; u8src = g_dstvid.pFrameBuff + (file->pitch * MaxY)*4; #endif for(y=0;y< MY/*pEx->ThumbnailHeight*/;y++) { for(x=0;x< MX /*pEx->ThumbnailWidth*/;x++) { for(k=0;k<4;k++) { *(u8des + (y * new_pitch + x)*4 + k) = *(u8src + (y * new_pitch + x)*4 + k); } } } #if USE_ACL ACLLOG(AclOvl_SetSrcFormat (g_dstcap.hOvlCap, ACL_DATA_FORMAT_ARGB8888_32BPP, &ulSrcAlignment)); ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, MX, MY, &new_pitch)); offset = g_dstvid.uFrameBuffBaseOffset; ACLLOG(AclOvl_SetSrcOffset (g_dstvid.hOVL, offset, FALSE)); DD_CAP_DisconnectCompVidVc(); AclVdc_Disconnect(g_dstvid.hVDC,ACL_OVL,g_dstvid.hOVL); AclOvl_Connect(g_dstcap.hOvlCap, ACL_DISP,g_dstcap.hDisp); #endif height = MY; width = MX; WidthRatio = width / 1366.0; HeightRatio = height / 768.0; if( WidthRatio > HeightRatio ) { w = PanelWidth; h = height * PanelWidth / width ; x = 0; y = (PanelHeight - h) / 2; } else { w = width * PanelHeight / height ; h = PanelHeight; x = (PanelWidth - w) / 2; y = 0; } #if USE_ACL ovlRect.Left = x; ovlRect.Top = y; ovlRect.Width = w; ovlRect.Height = h; // ovlRect.Left = 0; // ovlRect.Top = 0; // ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; // ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; AclOvl_SetDstWindow(g_dstcap.hOvlCap, &ovlRect, g_dstvid.OvlOptions.PreserveAspectRatio); #endif } g_current_display_jpeg.ImgWidthSize = MX; g_current_display_jpeg.ImgHeightSize = MY; g_current_display_jpeg.pitch = new_pitch; file->ImgHeightSize = MY ; file->ImgWidthSize = MX ; /* ovlRect.Width = g_dstvid.OvlOptions.DestinationWidth; ovlRect.Height = g_dstvid.OvlOptions.DestinationHeight; AclOvl_SetDstWindow(g_dstcap.hOvlCap, &ovlRect, g_dstvid.OvlOptions.PreserveAspectRatio); */ DHL_DISP_MuteMain(0); } void DHL_ZoomInOutJpeg(JpgFileInfo *file, DS_U32 width, DS_U32 height, ZoomStatus zoom) { #if USE_ACL ACL_RECT dstRect, cropRect; float WidthRatio = 0.0, HeightRatio = 0.0; DS_U32 x=0, y=0, w=0, h=0; // ACLFAIL( AclOvl_GetCropWindow(hOVL,ACL_OVL_CROP_SRC,&ovlRect), dhlResult); // ACLLOG(AclOvl_SetSrcWindowSize (g_dstcap.hOvlCap, width+40, height+70, &pitch)); DHL_DISP_MuteMain(1); WidthRatio = file->ImgWidthSize / 1366.0; HeightRatio = file->ImgHeightSize / 768.0; AclOvl_GetCropWindow(g_dstcap.hOvlCap,ACL_OVL_CROP_SRC,&cropRect); AclOvl_GetDstWindow(g_dstcap.hOvlCap,&dstRect); printf("WidthRatio %f HeightRatio %f\n", WidthRatio, HeightRatio); printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); ///////////////////////////////////////////////////////////////////////// /////////// Center 위치에서 zoom in, out 실행해야 함. move 한만큼 되돌림. ///////////////////////////////////////////////////////////////////////// cropRect.Top += hMoveStep * ZoomHeight; cropRect.Left += wMoveStep * ZoomWidth; AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); hMoveStep = wMoveStep = 0; ///////////////////////////////////////////////////////////////////////// switch(zoom) { case ZoomIn: if(WidthRatio > HeightRatio) { if(cropRect.Height > ZoomHeight * 2) { if(dstRect.Height + ZoomHeight * 2 <= PanelHeight) dstRect.Height += ZoomHeight * 2; else dstRect.Height = PanelHeight; cropRect.Left += ZoomWidth; cropRect.Width -= ZoomWidth * 2; if(dstRect.Top >= ZoomHeight) { dstRect.Top -= ZoomHeight; cropRect.Top = dstRect.Top; cropRect.Height = dstRect.Height; } else if(dstRect.Top > 0) // 0 < dstRect.Top < ZoomHeight { cropRect.Top = ZoomHeight - dstRect.Top; cropRect.Height = PanelHeight - cropRect.Top * 2; dstRect.Top = 0; } else // dstRect.Top == 0 { dstRect.Top = 0; cropRect.Top += ZoomHeight; cropRect.Height -= ZoomHeight * 2; } } } else { if(cropRect.Height > ZoomHeight * 2) { if(dstRect.Width + ZoomWidth * 2 <= PanelWidth) dstRect.Width += ZoomWidth * 2; else dstRect.Width = PanelWidth; cropRect.Top += ZoomHeight; cropRect.Height -= ZoomHeight * 2; if(dstRect.Left >= ZoomWidth) { dstRect.Left -= ZoomWidth; cropRect.Left = dstRect.Left; cropRect.Width = dstRect.Width; } else if(dstRect.Left > 0) // 0 < dstRect.Left < 19 { cropRect.Left = ZoomWidth - dstRect.Left; cropRect.Width = PanelWidth - cropRect.Left * 2; dstRect.Left = 0; } else // dstRect.Top == 0 { dstRect.Left = 0; cropRect.Left += ZoomWidth; cropRect.Width -= ZoomWidth * 2; } /* if(cropRect.Width > 19 * 2) { dstRect.Width += 19*2; cropRect.Top += 34; cropRect.Height -= 34 * 2; if(dstRect.Left >= 19) { dstRect.Left -= 19; cropRect.Left = dstRect.Left; cropRect.Width = dstRect.Width; } else { dstRect.Left = 0; cropRect.Left += 19; cropRect.Width -= 19*2; } */ } } break; case ZoomOut: if( WidthRatio > HeightRatio ) { if(cropRect.Left >= ZoomWidth) { cropRect.Left -= ZoomWidth; cropRect.Width += ZoomWidth * 2; if(cropRect.Height + ZoomHeight * 2 < PanelHeight) { dstRect.Top = 0; dstRect.Height = PanelHeight; cropRect.Top -= ZoomHeight; cropRect.Height += ZoomHeight * 2; } else if( (cropRect.Height < PanelHeight) && (dstRect.Top == 0) ) // && cropRect.Height + 34*2 >= 768 { dstRect.Height = PanelHeight - cropRect.Top * 2 - (dstRect.Height - cropRect.Height - cropRect.Top); dstRect.Top = ZoomHeight - cropRect.Top; cropRect.Top = dstRect.Top; cropRect.Height = PanelHeight - (dstRect.Height - cropRect.Height - cropRect.Top); } else // dstRect.Top >= 0 { dstRect.Height -= ZoomHeight * 2; dstRect.Top += ZoomHeight; cropRect.Top = dstRect.Top; cropRect.Height = dstRect.Height; } } } else { if(cropRect.Top >= ZoomHeight) { cropRect.Top -= ZoomHeight; cropRect.Height += ZoomHeight * 2; if( (cropRect.Width + ZoomWidth * 2 < PanelWidth) && (dstRect.Left == 0) ) { dstRect.Left = 0; dstRect.Width = PanelWidth; cropRect.Left -= ZoomWidth; cropRect.Width += ZoomWidth * 2; } else if( (cropRect.Width < PanelWidth) && (dstRect.Left == 0) ) // && cropRect.Width + 19*2 >= 1366 { dstRect.Width = PanelWidth - ZoomWidth * 2 + cropRect.Left * 2; dstRect.Left = ZoomWidth - cropRect.Left; cropRect.Left = dstRect.Left; cropRect.Width = dstRect.Width; //1366 - 19 * 2 + cropRect.Left * 2; } else // dstRect.Top >= 0 { dstRect.Width -= ZoomWidth * 2; dstRect.Left += ZoomWidth; cropRect.Left = dstRect.Left; cropRect.Width = dstRect.Width; } } } } printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); AclOvl_SetDstWindow(g_dstcap.hOvlCap,&dstRect,g_dstvid.OvlOptions.PreserveAspectRatio); AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); DHL_DISP_MuteMain(0); #if 0 WidthRatio = file->ImgWidthSize / 1366.0; HeightRatio = file->ImgHeightSize / 768.0; printf("Ratio W %f H %f\n", WidthRatio, HeightRatio); if( WidthRatio > HeightRatio ) { w = PanelWidth; h = file->ImgHeightSize * PanelWidth / file->ImgWidthSize; x = 0; y = (PanelHeight - h) / 2; printf("draw x %d y = %d w %d height %d\n", x, y, w, h); } else { w = file->ImgWidthSize * PanelHeight / file->ImgHeightSize; h = PanelHeight; x = (PanelWidth - w) / 2; y = 0; printf("draw x %d y = %d w %d h %d\n", x, y, w, h); } curJpegWidth = w; curJpegHeight = h; DHL_DISP_MuteMain(1); switch(zoom) { case Original: dstRect.Left = x; dstRect.Top = y; dstRect.Width = w; dstRect.Height = h; cropRect.Left = x; cropRect.Top = y; cropRect.Width = w; cropRect.Height = h; case FirstStep: if( WidthRatio > HeightRatio ) { dstRect.Left = x; dstRect.Top = y - ZoomHeight; dstRect.Width = w; dstRect.Height = h + ZoomHeight * 2; cropRect.Left = dstRect.Left + ZoomWidth; cropRect.Top = dstRect.Top; cropRect.Width = dstRect.Width - ZoomWidth * 2; cropRect.Height = dstRect.Height; } else { dstRect.Left = x - ZoomWidth; dstRect.Top = y; dstRect.Width = w + ZoomWidth * 2; dstRect.Height = h; cropRect.Left = dstRect.Left; cropRect.Top = dstRect.Top + ZoomHeight; cropRect.Width = dstRect.Width; cropRect.Height = dstRect.Height - ZoomHeight * 2; } break; case SecondStep: if( WidthRatio > HeightRatio ) { dstRect.Left = x; if(dstRect.Top > ZoomHeight * 2) dstRect.Top = y - ZoomHeight * 2; else dstRect.Top = 0; dstRect.Width = w; dstRect.Height = h + ZoomHeight * 2 * 2; cropRect.Left = dstRect.Left + ZoomWidth * 2; cropRect.Top = dstRect.Top; cropRect.Width = dstRect.Width - ZoomWidth * 2 * 2; cropRect.Height = dstRect.Height; } else { dstRect.Left = x - ZoomWidth * 2; dstRect.Top = y; dstRect.Width = w + ZoomWidth * 2 * 2; dstRect.Height = h; cropRect.Left = dstRect.Left; cropRect.Top = dstRect.Top + ZoomHeight * 2; cropRect.Width = dstRect.Width; cropRect.Height = dstRect.Height - ZoomHeight * 2 * 2; } break; case ThirdStep: if( WidthRatio > HeightRatio ) { dstRect.Left = x; dstRect.Top = y - ZoomHeight * 3; dstRect.Width = w; dstRect.Height = h + ZoomHeight * 3 * 2; cropRect.Left = dstRect.Left + ZoomWidth * 3; cropRect.Top = dstRect.Top; cropRect.Width = dstRect.Width - ZoomWidth * 3 * 2; cropRect.Height = dstRect.Height; } else { dstRect.Left = x - ZoomWidth * 3; dstRect.Top = y; dstRect.Width = w + ZoomWidth * 3 * 2; dstRect.Height = h; cropRect.Left = dstRect.Left; cropRect.Top = dstRect.Top + ZoomHeight * 3; cropRect.Width = dstRect.Width; cropRect.Height = dstRect.Height - ZoomHeight * 3 * 2; } break; case ForthStep: if( WidthRatio > HeightRatio ) { dstRect.Left = x; dstRect.Top = y - ZoomHeight * 4; dstRect.Width = w; dstRect.Height = h + ZoomHeight * 4 * 2; cropRect.Left = dstRect.Left + ZoomWidth * 4; cropRect.Top = dstRect.Top; cropRect.Width = dstRect.Width - ZoomWidth * 4 * 2; cropRect.Height = dstRect.Height; } else { dstRect.Left = x - ZoomWidth * 4; dstRect.Top = y; dstRect.Width = w + ZoomWidth * 4 * 2; dstRect.Height = h; cropRect.Left = dstRect.Left; cropRect.Top = dstRect.Top + ZoomHeight * 4; cropRect.Width = dstRect.Width; cropRect.Height = dstRect.Height - ZoomHeight * 4 * 2; } break; default: return; } // printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); // printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); AclOvl_SetDstWindow(g_dstcap.hOvlCap,&dstRect,g_dstvid.OvlOptions.PreserveAspectRatio); AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); DHL_DISP_MuteMain(0); printf("|%s|current Jpeg %d %d\n", __FUNCTION__, g_current_display_jpeg.ImgWidthSize, g_current_display_jpeg.ImgHeightSize); // g_current_display_jpeg.ImgWidthSize = ovlRect.Width; // g_current_display_jpeg.ImgHeightSize = ovlRect.Height; // g_current_display_jpeg.pitch = new_pitch; // file->ImgHeightSize = MY ; // file->ImgWidthSize = MX ; #endif #endif } void DHL_MoveJpeg(JpgFileInfo *t, Direction dr) { #if USE_ACL ACL_RECT cropRect, dstRect; AclOvl_GetDstWindow(g_dstcap.hOvlCap,&dstRect); AclOvl_GetCropWindow(g_dstcap.hOvlCap,ACL_OVL_CROP_SRC,&cropRect); printf("dstRect.Left %d dstRect.Top = %d dstRect.Width = %d dstRect.Height %d\n", dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height); printf("cropRect.Left %d cropRect.Top = %d cropRect.Width = %d cropRect.Height %d\n", cropRect.Left, cropRect.Top, cropRect.Width, cropRect.Height); switch(dr) { case MoveUp: // if(curJpegHeight >= 768) { if( (cropRect.Top >= ZoomHeight) && (dstRect.Height >= PanelHeight) ) { cropRect.Top -= ZoomHeight; hMoveStep++; } // else // cropRect.Top = 0; AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); } break; case MoveDown: // if(curJpegHeight >= 768) { if( (cropRect.Height + cropRect.Top < PanelHeight) && (dstRect.Height >= PanelHeight) ) { cropRect.Top += ZoomHeight; hMoveStep--; } // else // cropRect.Top = 768 - cropRect.Height; AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); } break; case MoveLeft: // if(curJpegWidth >= 1366) { if( (cropRect.Left >= ZoomWidth) && (dstRect.Width >= PanelWidth) ) { cropRect.Left -= ZoomWidth; wMoveStep++; } // else // cropRect.Left = 0; AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); } break; case MoveRight: // if(curJpegWidth >= 1366) { if( (cropRect.Width + cropRect.Left < PanelWidth) && (dstRect.Width >= PanelWidth) ) { cropRect.Left += ZoomWidth; wMoveStep--; } // else // cropRect.Left = 768 - cropRect.Width; AclOvl_SetCropWindow(g_dstcap.hOvlCap, 0,&cropRect); } break; } #endif } #if 1 void DHL_JpegThumbnailclear(DS_U32 xpos, DS_U32 ypos) { #if USE_ACL DS_U32 x,y,k; char *p; DS_U32 pitch; //pitch = get_thumbnail_pitch(); // xpos = ((xpos - 28 ) / 214) * 214 + 28; // ypos = ((ypos - 83 ) / 205) * 205 + 83; // printf("pitch %d in %s\n", pitch, __FUNCTION__); for(y=0;y