FreeCalypso > hg > fc-magnetite
comparison src/aci2/mfw/mfw_fv.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 26 Sep 2016 00:29:36 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 2:c41a534f33c6 | 3:93999a60b835 |
|---|---|
| 1 /* | |
| 2 +--------------------------------------------------------------------+ | |
| 3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_fv.c $| | |
| 4 | $Author:: NDH $Revision:: 1 $| | |
| 5 | CREATED: 21.05.04 $Modtime:: 21.05.04 14:58 $| | |
| 6 | STATE : code | | |
| 7 +--------------------------------------------------------------------+ | |
| 8 | |
| 9 MODULE : MFW_FV | |
| 10 | |
| 11 PURPOSE : This module contains File Viewer Interface functions. | |
| 12 | |
| 13 HISTORY : | |
| 14 Oct 06, 2005 REF: SPR 34560 xdeepadh | |
| 15 Description: File Viewer: Image stored in the FFS is not displayed in the file viewer | |
| 16 Solution: Screen updation will be performed , soon after the decoding/color conversion | |
| 17 of the image is completed. | |
| 18 | |
| 19 Aug 22, 2005 REF: ENH 31154 xdeepadh | |
| 20 Description: Application to Test Camera | |
| 21 Solution: Implemeted the Fileviewer to view the jpeg images.Camera Application to | |
| 22 preview,capture and save image has been implemented. | |
| 23 | |
| 24 */ | |
| 25 | |
| 26 #define ENTITY_MFW | |
| 27 /* | |
| 28 ** Include Files | |
| 29 */ | |
| 30 | |
| 31 /* includes */ | |
| 32 #include <string.h> | |
| 33 #include "typedefs.h" | |
| 34 #include "mfw_mfw.h" | |
| 35 #include "mfw_sys.h" | |
| 36 #include "mfw_fv.h" | |
| 37 | |
| 38 //Includes of IMGIL | |
| 39 #include "img/imgil1_api.h" | |
| 40 #include "img/imgil1_i.h" | |
| 41 #include "gil/gil_gpf.h" | |
| 42 #include "dspl.h" | |
| 43 | |
| 44 | |
| 45 | |
| 46 //Variable defines | |
| 47 | |
| 48 T_IMG_YUV_BUFFER qcif_yuv_tempbuf; | |
| 49 extern UINT8 qcif_yuv_lum[FV_DSPL_VOLUME]; //decoded and Scaled lum buffer | |
| 50 extern UINT8 qcif_yuv_cb[FV_SCALE_VOLUME]; //decoded and Scaled cb buffer | |
| 51 extern UINT8 qcif_yuv_cr[FV_SCALE_VOLUME]; //decoded and Scaled cr buffer | |
| 52 | |
| 53 extern UINT8 qcif_rgb_array[ FV_DSPL_VOLUME * 2]; //Color converted buffer to view | |
| 54 extern UINT8 rgb_img_process_array[FV_DSPL_VOLUME * 2]; //Color converted buffer for zoom/rotate | |
| 55 | |
| 56 T_IMG_YUV_BUFFER qcif_process_buffer; | |
| 57 extern UINT8 qcif_yuv_process_lum[FV_DSPL_VOLUME ]; //lum buffer for rotate and zoom | |
| 58 extern UINT8 qcif_yuv_process_cb[FV_SCALE_VOLUME]; //cb buffer for rotate and zoom | |
| 59 extern UINT8 qcif_yuv_process_cr[FV_SCALE_VOLUME]; //cr buffer for rotate and zoom | |
| 60 | |
| 61 extern UBYTE zoom_flag; | |
| 62 extern UBYTE rotate_flag; | |
| 63 | |
| 64 //Function Prototypes | |
| 65 static void mfw_fv_change_format_cb(void *parameter); | |
| 66 static void mfw_fv_zoom_cb(void *parameter); | |
| 67 static void mfw_fv_rotate_cb(void *parameter); | |
| 68 static void mfw_fv_color_convert_cb(void *parameter); | |
| 69 static void mfw_fv_process_cb(void *parameter); | |
| 70 GLOBAL UBYTE mfw_fv_display_image_in_center( | |
| 71 USHORT in_Width, | |
| 72 USHORT in_Height, | |
| 73 void * in_BmpPtr, | |
| 74 USHORT in_index, | |
| 75 int bmpFormat, | |
| 76 USHORT dsplWidth, | |
| 77 USHORT dsplHeight); | |
| 78 | |
| 79 | |
| 80 | |
| 81 /******************************************************************************* | |
| 82 | |
| 83 $Function: mfw_fv_decode_image | |
| 84 | |
| 85 $Description: decode the jpeg image | |
| 86 | |
| 87 $Returns: Status | |
| 88 | |
| 89 $Arguments: inputbuffer -Input Buffer | |
| 90 size- Size of the Input Buffer | |
| 91 | |
| 92 | |
| 93 *******************************************************************************/ | |
| 94 | |
| 95 int mfw_fv_decode_image(UBYTE * inputbuffer, int size) | |
| 96 { | |
| 97 T_IMG_CHANGE_FORMAT_PARAM change_param; | |
| 98 T_IMG_RETURN ret; | |
| 99 | |
| 100 TRACE_EVENT("mfw_fv_decode_image"); | |
| 101 | |
| 102 qcif_yuv_tempbuf.lum = qcif_yuv_lum; | |
| 103 qcif_yuv_tempbuf.cb = qcif_yuv_cb; | |
| 104 qcif_yuv_tempbuf.cr = qcif_yuv_cr; | |
| 105 qcif_yuv_tempbuf.width = FV_DSPL_WIDTH; | |
| 106 qcif_yuv_tempbuf.height =FV_DSPL_HEIGHT; | |
| 107 | |
| 108 change_param.input_image_format = IMG_FORMAT_JPG ; | |
| 109 change_param.decode_param.x_offset = 0; | |
| 110 change_param.decode_param.y_offset = 0; | |
| 111 change_param.decode_param.sampling_factor = 1; | |
| 112 change_param.decode_param.num_rows = 0; | |
| 113 change_param.decode_param.scaling_factor = 2; | |
| 114 //This is the dummy parameter .The source color format will be retrieved by reading the jpeg header. | |
| 115 change_param.output_format.color_format = IMG_YUV420; | |
| 116 //The width and height should not be taken based on the resolution. | |
| 117 change_param.output_format.resolution = 0; | |
| 118 change_param.output_format.x_length = FV_DSPL_WIDTH; | |
| 119 change_param.output_format.y_length = FV_DSPL_HEIGHT; | |
| 120 | |
| 121 //Call the Change Format API to decode/scale and color convert | |
| 122 //Decode and Scale the input image. | |
| 123 | |
| 124 ret = imgil_change_format((UINT8*)inputbuffer,size,change_param,&qcif_yuv_tempbuf,mfw_fv_change_format_cb,NULL); | |
| 125 | |
| 126 if(ret == IMG_OK) | |
| 127 { | |
| 128 TRACE_EVENT("mfw_fv_decode_image---OK"); | |
| 129 return 1; | |
| 130 } | |
| 131 else | |
| 132 { | |
| 133 TRACE_EVENT("mfw_fv_decode_image--FAIL"); | |
| 134 return 0; | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 | |
| 139 /******************************************************************************* | |
| 140 | |
| 141 $Function: mfw_fv_change_format_cb | |
| 142 | |
| 143 $Description: Callback for img_change_format. | |
| 144 | |
| 145 $Returns: None | |
| 146 | |
| 147 $Arguments: Callback Parameter | |
| 148 | |
| 149 *******************************************************************************/ | |
| 150 static void mfw_fv_change_format_cb(void *parameter) | |
| 151 { | |
| 152 T_IMG_RETURN ret; | |
| 153 T_IMG_COLORCONV_PARAM color_param; | |
| 154 UBYTE color_format; | |
| 155 | |
| 156 TRACE_EVENT("mfw_fv_change_format_cb()"); | |
| 157 color_param.actWidht = qcif_yuv_tempbuf.width; | |
| 158 color_param.actHeight = qcif_yuv_tempbuf.height; | |
| 159 color_param.srcClrFfmt =qcif_yuv_tempbuf.color_format; | |
| 160 color_param.numBytes = 0; | |
| 161 color_param.destClrFmt = IMG_RGB565 ; | |
| 162 | |
| 163 //Call the Color Conversion API | |
| 164 memset(qcif_rgb_array,0,sizeof(qcif_rgb_array)); | |
| 165 imgil_color_convert(&qcif_yuv_tempbuf,color_param,qcif_rgb_array,mfw_fv_color_convert_cb); | |
| 166 } | |
| 167 | |
| 168 /******************************************************************************* | |
| 169 | |
| 170 $Function: mfw_fv_color_convert_cb | |
| 171 | |
| 172 $Description: Callback for imgil_color_convert API. | |
| 173 | |
| 174 $Returns: None | |
| 175 | |
| 176 $Arguments: Callback Parameter | |
| 177 | |
| 178 *******************************************************************************/ | |
| 179 static void mfw_fv_color_convert_cb(void *parameter) | |
| 180 { | |
| 181 TRACE_EVENT("mfw_fv_color_convert_cb()"); | |
| 182 //Draw the image on the LCD | |
| 183 mfw_fv_display_image_in_center(qcif_yuv_tempbuf.width,qcif_yuv_tempbuf.height, qcif_rgb_array,0,0x05,FV_DSPL_WIDTH,FV_DSPL_HEIGHT); | |
| 184 } | |
| 185 | |
| 186 /******************************************************************************* | |
| 187 | |
| 188 $Function: mfw_fv_zoom_image | |
| 189 | |
| 190 $Description: zoom the jpeg image | |
| 191 | |
| 192 $Returns: Status | |
| 193 | |
| 194 $Arguments:None | |
| 195 | |
| 196 | |
| 197 *******************************************************************************/ | |
| 198 | |
| 199 SHORT mfw_fv_zoom_image() | |
| 200 { | |
| 201 T_IMG_SCALE_PARAM scale_param; | |
| 202 T_IMG_RETURN ret; | |
| 203 | |
| 204 TRACE_FUNCTION("mfw_fv_zoom_image"); | |
| 205 | |
| 206 qcif_process_buffer.lum = qcif_yuv_process_lum; | |
| 207 qcif_process_buffer.cb = qcif_yuv_process_cb; | |
| 208 qcif_process_buffer.cr = qcif_yuv_process_cr; | |
| 209 qcif_process_buffer.width =0; | |
| 210 qcif_process_buffer.height=0; | |
| 211 | |
| 212 scale_param.srcClrFmt = qcif_yuv_tempbuf.color_format; | |
| 213 | |
| 214 //Set the Zoom Parameters | |
| 215 if(zoom_flag == FV_ZOOM_OUT) | |
| 216 { | |
| 217 //Zoom out the complete image to a smaller size | |
| 218 scale_param.x_offset = 0 ; | |
| 219 scale_param.y_offset = 0; | |
| 220 scale_param.cropWidth = qcif_yuv_tempbuf.width ; | |
| 221 scale_param.cropHeight = qcif_yuv_tempbuf.height; | |
| 222 qcif_process_buffer.width = qcif_yuv_tempbuf.width - MFW_ZOOM_WIDTH_DELTA; | |
| 223 qcif_process_buffer.height = qcif_yuv_tempbuf.height - MFW_ZOOM_HEIGHT_DELTA; | |
| 224 | |
| 225 } | |
| 226 else //FV_ZOOM_IN | |
| 227 { | |
| 228 //Zoom out the central portion of the image to the display width and height | |
| 229 scale_param.x_offset=MFW_ZOOM_WIDTH_DELTA ; | |
| 230 scale_param.y_offset=MFW_ZOOM_HEIGHT_DELTA; | |
| 231 scale_param.cropWidth=qcif_yuv_tempbuf.width - 2 * MFW_ZOOM_WIDTH_DELTA; | |
| 232 scale_param.cropHeight=qcif_yuv_tempbuf.height - 2 * MFW_ZOOM_HEIGHT_DELTA; | |
| 233 qcif_process_buffer.width = FV_DSPL_WIDTH; | |
| 234 qcif_process_buffer.height = FV_DSPL_HEIGHT; | |
| 235 | |
| 236 } | |
| 237 | |
| 238 //Call the Scaling API to zoom in or out based on the scaling parameters | |
| 239 memset(qcif_yuv_process_lum,0,sizeof(qcif_yuv_process_lum)); | |
| 240 memset(qcif_yuv_process_cb,0,sizeof(qcif_yuv_process_cb)); | |
| 241 memset(qcif_yuv_process_cr,0,sizeof(qcif_yuv_process_cr)); | |
| 242 ret = imgil_scale(&qcif_yuv_tempbuf,scale_param,&qcif_process_buffer,mfw_fv_zoom_cb); | |
| 243 return 1; | |
| 244 } | |
| 245 | |
| 246 /******************************************************************************* | |
| 247 | |
| 248 $Function: mfw_fv_zoom_cb | |
| 249 | |
| 250 $Description: Callback function for imgil_scale | |
| 251 | |
| 252 $Returns: None | |
| 253 | |
| 254 $Arguments: Callback Parameter | |
| 255 | |
| 256 *******************************************************************************/ | |
| 257 static void mfw_fv_zoom_cb(void *parameter) | |
| 258 { | |
| 259 | |
| 260 T_IMG_COLORCONV_PARAM color_param; | |
| 261 | |
| 262 TRACE_EVENT("mfw_fv_zoom_cb()"); | |
| 263 | |
| 264 //Set the color conversion parameters | |
| 265 color_param.actWidht = qcif_process_buffer.width; | |
| 266 color_param.actHeight =qcif_process_buffer.height ; | |
| 267 color_param.srcClrFfmt = qcif_yuv_tempbuf.color_format; | |
| 268 color_param.numBytes = 0; | |
| 269 color_param.destClrFmt = IMG_RGB565 ; | |
| 270 | |
| 271 memset(rgb_img_process_array,0,sizeof(rgb_img_process_array)); | |
| 272 //Call the Color Conversion API | |
| 273 imgil_color_convert(&qcif_process_buffer,color_param,rgb_img_process_array,mfw_fv_process_cb); | |
| 274 } | |
| 275 | |
| 276 /******************************************************************************* | |
| 277 | |
| 278 $Function: mfw_fv_process_cb | |
| 279 | |
| 280 $Description: Callback for imgil_color_convert API while zooming and rotating | |
| 281 | |
| 282 $Returns: None | |
| 283 | |
| 284 $Arguments: Callback Parameter | |
| 285 | |
| 286 *******************************************************************************/ | |
| 287 static void mfw_fv_process_cb(void *parameter) | |
| 288 { | |
| 289 TRACE_EVENT("mfw_fv_process_cb()"); | |
| 290 | |
| 291 //Draw the image on the LCD | |
| 292 mfw_fv_display_image_in_center(qcif_process_buffer.width,qcif_process_buffer.height,rgb_img_process_array,0,BMP_FORMAT_16BIT_LCD_COMPRESSED_COLOUR,FV_DSPL_WIDTH,FV_DSPL_HEIGHT); | |
| 293 | |
| 294 if( rotate_flag == FV_ROTATE_90 || rotate_flag == FV_ROTATE_270) | |
| 295 { | |
| 296 //Unset the flag | |
| 297 rotate_flag = FV_ROTATE_360; | |
| 298 } | |
| 299 else if(zoom_flag == FV_ZOOM_OUT || zoom_flag == FV_ZOOM_IN) | |
| 300 { | |
| 301 //Unset the flag | |
| 302 zoom_flag = FV_NO_ZOOM; | |
| 303 } | |
| 304 } | |
| 305 | |
| 306 /******************************************************************************* | |
| 307 | |
| 308 $Function: mfw_fv_rotate_image | |
| 309 | |
| 310 $Description: Rotate the jpeg image | |
| 311 | |
| 312 $Returns: Status | |
| 313 | |
| 314 $Arguments: None | |
| 315 | |
| 316 | |
| 317 *******************************************************************************/ | |
| 318 | |
| 319 SHORT mfw_fv_rotate_image() | |
| 320 { | |
| 321 T_IMG_ROTATION_PARAM rotate_param; | |
| 322 T_IMG_RETURN ret; | |
| 323 | |
| 324 TRACE_FUNCTION("mfw_fv_rotate_image"); | |
| 325 | |
| 326 qcif_process_buffer.lum = qcif_yuv_process_lum; | |
| 327 qcif_process_buffer.cb = qcif_yuv_process_cb; | |
| 328 qcif_process_buffer.cr = qcif_yuv_process_cr; | |
| 329 qcif_process_buffer.width =qcif_yuv_tempbuf.width; | |
| 330 qcif_process_buffer.height=qcif_yuv_tempbuf.height; | |
| 331 | |
| 332 //Set the Rotate Parameters | |
| 333 if(rotate_flag == FV_ROTATE_90) | |
| 334 { | |
| 335 rotate_param.rotate_flag = 1 ; | |
| 336 } | |
| 337 else if(rotate_flag == FV_ROTATE_180) | |
| 338 { | |
| 339 rotate_param.rotate_flag = 2 ; | |
| 340 } | |
| 341 else if(rotate_flag == FV_ROTATE_270) | |
| 342 { | |
| 343 rotate_param.rotate_flag = 3 ; | |
| 344 } | |
| 345 | |
| 346 rotate_param.srcClrFmt = qcif_yuv_tempbuf.color_format; | |
| 347 | |
| 348 memset(qcif_yuv_process_lum,0,sizeof(qcif_yuv_process_lum)); | |
| 349 memset(qcif_yuv_process_cb,0,sizeof(qcif_yuv_process_cb)); | |
| 350 memset(qcif_yuv_process_cr,0,sizeof(qcif_yuv_process_cr)); | |
| 351 //Call the Rotate API to rotate by the set degree | |
| 352 ret = imgil_rotate(&qcif_yuv_tempbuf,rotate_param,&qcif_process_buffer,mfw_fv_rotate_cb); | |
| 353 return 1; | |
| 354 } | |
| 355 | |
| 356 | |
| 357 /******************************************************************************* | |
| 358 | |
| 359 $Function: mfw_fv_rotate_cb | |
| 360 | |
| 361 $Description: Callback function for imgil_roate | |
| 362 | |
| 363 $Returns: None | |
| 364 | |
| 365 $Arguments: Callback Parameter | |
| 366 | |
| 367 *******************************************************************************/ | |
| 368 static void mfw_fv_rotate_cb(void *parameter) | |
| 369 { | |
| 370 T_IMG_COLORCONV_PARAM color_param; | |
| 371 | |
| 372 TRACE_EVENT("mfw_fv_rotate_cb()"); | |
| 373 | |
| 374 //Set the Color Conversion Parameters | |
| 375 color_param.actWidht = qcif_process_buffer.width; | |
| 376 color_param.actHeight = qcif_process_buffer.height; | |
| 377 color_param.actWidht = qcif_process_buffer.width; | |
| 378 color_param.actHeight = qcif_process_buffer.height; | |
| 379 color_param.srcClrFfmt =qcif_yuv_tempbuf.color_format; | |
| 380 color_param.numBytes = 0; | |
| 381 color_param.destClrFmt = IMG_RGB565 ; | |
| 382 | |
| 383 memset(rgb_img_process_array,0,sizeof(rgb_img_process_array)); | |
| 384 //Call the color Conversion API | |
| 385 imgil_color_convert(&qcif_process_buffer,color_param,rgb_img_process_array,mfw_fv_process_cb); | |
| 386 } | |
| 387 | |
| 388 /******************************************************************************* | |
| 389 | |
| 390 $Function: mfw_fv_init | |
| 391 | |
| 392 $Description: This function initialises the imgil interface. | |
| 393 | |
| 394 $Returns: None | |
| 395 | |
| 396 $Arguments: None | |
| 397 | |
| 398 *******************************************************************************/ | |
| 399 void mfw_fv_init(void) | |
| 400 { | |
| 401 TRACE_EVENT("mfw_fv_init()"); | |
| 402 // Initialize IMGIL interface. | |
| 403 if (imgil_init() != RV_OK) | |
| 404 { | |
| 405 // @todo : use correct return code for error cases ! | |
| 406 return ; | |
| 407 } | |
| 408 } | |
| 409 | |
| 410 /******************************************************************************* | |
| 411 | |
| 412 $Function: mfw_fv_exit | |
| 413 | |
| 414 $Description: This function will tidy up any resources used by the Mfw FileViewer Module | |
| 415 on Power Down | |
| 416 | |
| 417 $Returns: None | |
| 418 | |
| 419 $Arguments: None | |
| 420 | |
| 421 *******************************************************************************/ | |
| 422 void mfw_fv_exit(void) | |
| 423 { | |
| 424 TRACE_EVENT("mfw_fv_exit()"); | |
| 425 /* nothing to do here... RAM will be automatically cleaned, and the flash wasn't modified */ | |
| 426 } | |
| 427 | |
| 428 /*********************************************************************************************************************** | |
| 429 $Function: mfw_fv_display_image_in_center | |
| 430 | |
| 431 $Description: This function will display the image in the center | |
| 432 | |
| 433 $Returns: None | |
| 434 | |
| 435 $Arguments: None | |
| 436 | |
| 437 ***********************************************************************************************************************/ | |
| 438 GLOBAL UBYTE mfw_fv_display_image_in_center( | |
| 439 USHORT in_Width, | |
| 440 USHORT in_Height, | |
| 441 void * in_BmpPtr, | |
| 442 USHORT in_index, | |
| 443 int bmpFormat, | |
| 444 USHORT dsplWidth, | |
| 445 USHORT dsplHeight) | |
| 446 { | |
| 447 int x_offset,y_offset; | |
| 448 x_offset = (dsplWidth - in_Width) / 2 ; | |
| 449 y_offset = (dsplHeight- in_Height) / 2 ; | |
| 450 | |
| 451 TRACE_EVENT_P2("width and height are %d ---%d",in_Width,in_Height); | |
| 452 TRACE_EVENT_P2("x and y offset are %d ---%d",x_offset,y_offset); | |
| 453 | |
| 454 if(zoom_flag == FV_ZOOM_OUT) | |
| 455 { | |
| 456 dspl_BitBlt2(x_offset,11,in_Width,in_Height,in_BmpPtr,in_index,bmpFormat); | |
| 457 //Oct 06, 2005 REF: SPR 34560 xdeepadh | |
| 458 //Screen updation will be performed , soon after the decoding/color conversion | |
| 459 //of the image is completed. | |
| 460 dspl_Enable(1); | |
| 461 } | |
| 462 else | |
| 463 { | |
| 464 #if 0 | |
| 465 if(in_Height < dsplHeight) | |
| 466 { | |
| 467 TRACE_EVENT("The height is lesser "); | |
| 468 | |
| 469 dspl_BitBlt2(x_offset,11,in_Width,in_Height,in_BmpPtr,in_index,bmpFormat); | |
| 470 } | |
| 471 else | |
| 472 { | |
| 473 #endif | |
| 474 dspl_BitBlt2(x_offset,0,in_Width,in_Height,in_BmpPtr,in_index,bmpFormat); | |
| 475 //Oct 06, 2005 REF: SPR 34560 xdeepadh | |
| 476 //Screen updation will be performed , soon after the decoding/color conversion | |
| 477 //of the image is completed. | |
| 478 dspl_Enable(1); | |
| 479 } | |
| 480 return 1; | |
| 481 } | |
| 482 | |
| 483 | |
| 484 |
