📄 haljpeg.~c
字号:
#include "winav.h"#include "ctkav.h"#include "jpegdec.h"#include "jpegfmt.h"#include "haljpeg.h"#include "cc.h"#include "hal.h"#include "disp.h"#include "utl.h"#include "infofilter.h"#include "mmanager.h"#ifdef ECOS909#if (PLATFORM == ECOS_OS)#include "ecoscc.h"#endif#endif//Temp variablesBYTE _bHALJPEGTemp, _bHALJPEGTemp1;WORD _wHALJPEGTemp, _wHALJPEGTemp1;//Global variables for HALJPEG module usage onlyBYTE _bHALJPEGFit; //The JPEG fit width or fit height?BYTE _bHALJPEGScalingAll; //Extract "all" image from original buffer or not.BYTE _bHALJPEGZoomRate; //Real zoom rate * 100BYTE _bJPEGZoomMethod; //We can use "clip" command to zoom JPEG or just scaling it.BYTE _bJPEGIsEncodeMode; //Chekc current whether is JPEG encoded modeWORD _wHALJPEGScalingRate; //Real scaling rate * 1000WORD _wHALJPEGRealWidth; //JPEG real widthWORD _wHALJPEGRealHeight; //JPEG real heightWORD _wHALJPEGExtractHStart; //The horizontal starting position to extract the JPEG from original buffer.WORD _wHALJPEGExtractVStart; //The vertical starting position to extract the JPEG from original buffer.WORD _wHALJPEGExtractWidth; //The width to extract the JPEG from original buffer.WORD _wHALJPEGExtractHeight; //The height to extract the JPEG from original buffer.WORD _wHALJPEGClipHStart; //The horizontal starting position to clip the picture.WORD _wHALJPEGClipVStart; //The vertical starting position to clip the picture.WORD _wHALJPEGClipWidth; //The width to clip the picture.WORD _wHALJPEGClipHeight; //The height to clip the picture.WORD _wHALJPEGScalingWidth; //The width after scaling.WORD _wHALJPEGScalingHeight; //The height after scaling.JPEGSCALING _HALJPEGScaling; //The Scaling structure.JPEGDECODE _HALJPEGDecode; //The Decode structure.DWORD _dwHALJPEGCheckTime;WORD _wHALJPEGBackupRealWidth; //JPEG real widthWORD _wHALJPEGBackupRealHeight; //JPEG real width//Global variables for other module usage.BYTE __bHALJPEGEffect; //The effect of slide transitionBYTE _bHALJPEGRandomEffectType = 0; //Keep the real effect for random effect. Thus, we can complete the effect if need.JPEGSETTING __HALJPEGSetting; //The JPEG setting before decoding/operating a JPEG. Note: The caller should fill the attributes.WIN_PARAMETER _JPEGClipWinParameter;BYTE __wHALJPEGCurrentDisplayBuf; //Keep current display buffer //CoCo2.77//Senshong2.78: add effect block counterDWORD _wHALJPEGBlockCounter;extern DWORD __dwCoded_Picture_Width;extern DWORD __dwCoded_Picture_Height;extern WIN_PARAMETER MainVideoInfo;extern BYTE __bThumbnailMode;extern BYTE __dwMMJPEGPreview;#ifdef SUPPORT_JPEGDEC_ON_PROC2extern void _ChangeDSPCode(BYTE bType);#endif //SUPPORT_JPEGDEC_ON_PROC2// LLY2.21a create ...// ****************************************************************************************// Function : HALJPEG_ConfigFrame()// Description : Used to config JPEG slide show and preview mode frame buffer address// Arguments : None// Return : None// ****************************************************************************************void HALJPEG_ConfigFrame(BYTE bMode){#ifndef JPG_SINGLE_FRAME_BUFFER DWORD dwDisplyBuff1;#endif // #ifndef JPG_SINGLE_FRAME_BUFFER extern WORD __wFrameWidth; #ifdef JPG_SINGLE_FRAME_BUFFER // LLY2.22, the display frame buffer setting are different between slide show and preview/ thumbnail#ifdef JPEG_SINGLE_BUFFER_FULL_SCREEN JPEG_DisplayFullScreen(1);// 0: Not full screen,1: full screen#endif JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_END_SLIDESHOW, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_END_THUMBNAIL, JPEG_DRAM_16M); if(bMode==HALJPEG_FRAME_BUFFER_SLIDE_SHOW) {#ifdef JPEG_SINGLE_BUFFER_FULL_SCREEN DISP_FrameBufferSet(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_ST_SLIDESHOW, (DS_FRAMEBUF_END_SLIDESHOW - (HALJPEG_DISPLAY_BUF_WIDTH*HALJPEG_DISPLAY_BUF_HEIGHT*3/2)),DS_FRAMEBUF_ST_SLIDESHOW, 0x9D80);#else DISP_FrameBufferSet(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_ST_SLIDESHOW, (DS_FRAMEBUF_END_SLIDESHOW - JPEG_DISP_SIZE_FOR_16M),DS_FRAMEBUF_ST_SLIDESHOW, Y_MAXSIZE_8C00); #endif } else {#ifdef JPEG_SINGLE_BUFFER_FULL_SCREEN DISP_FrameBufferSet(DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, 0x9D80);#else DISP_FrameBufferSet(DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_THUMBNAIL, Y_MAXSIZE_8C00);#endif }#else#if (DRAM_CONFIGURATION_TYPE_DVD == DRAM_SIZE_64) dwDisplyBuff1 = JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST, (DS_FRAMEBUF_ST+DS_FRAMEBUF_SIZE-1), DS_JPG_ORG_BUFF_ST, DS_JPG_ORG_BUFF_END, JPEG_DRAM_64M);#elif (DRAM_CONFIGURATION_TYPE_DVD == DRAM_SIZE_32) dwDisplyBuff1 = JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST, (DS_FRAMEBUF_ST+DS_FRAMEBUF_SIZE-1), 0, 0, JPEG_DRAM_32M);#endif DISP_FrameBufferSet(DS_FRAMEBUF_ST, dwDisplyBuff1, DS_FRAMEBUF_ST, DS_FRAMEBUF_ST, Y_MAXSIZE_A8C0);#endif //JPG_SINGLE_FRAME_BUFFER DISP_FrameBufferMode(FALSE, FALSE); //Senshong2.78:reset block counter _wHALJPEGBlockCounter = 0; // LLY2.30, give frame buffer width base on global define __wFrameWidth = HALJPEG_DISPLAY_BUF_WIDTH;}//***************************************************************************// Function : HALJPEG_Initial// Abstract : Call this funciton when decoding the JPEG at first time.// Arguments : none.// Return : none.// Side Effect : none.// Notes ://***************************************************************************void HALJPEG_Initial(void){//senshong2.38a: add code to load jpeg decoder to processor 2,when playback jpeg#ifdef SUPPORT_JPEGDEC_ON_PROC2#ifdef SUPPORT_JPEG_AUDIO_PLAYING if (!__bMMJPEGAudioMode)#endif //SUPPORT_JPEG_AUDIO_PLAYING {#ifndef CT909P_IC_SYSTEM JPEGDEC_ConfigProcessor(0); _ChangeDSPCode(HAL_VIDEO_JPG);#endif //#ifndef CT909P_IC_SYSTEM }#endif //SUPPORT_JPEGDEC_ON_PROC2 //Stop video decoder, reset buffer and reset parser HAL_Reset(HAL_RESET_VIDEO); // wyc0.66, need to reset it and must put these code after HAL_Reset(HAL_RESET_VIDEO), otherwise JPG decode error after first picture. //__bLOGO = LOGO_JPEG; //__bAudioType = HAL_AUDIO_NONE; //Can't set the audio type because we may slide show with audio playing //Set A/V buffer //HAL_SetBuffer(HAL_SETBUFFER_AV, HAL_BUFFERMODE_JPEG); //Disable video. //Set the source (display buffer) for main video. //__dwCoded_Picture_Width = HALJPEG_DISPLAY_BUF_WIDTH; //__dwCoded_Picture_Height = HALJPEG_DISPLAY_BUF_HEIGHT; //DISP_MainVideoSet(&MainVideoInfo, __dwCoded_Picture_Width, __dwCoded_Picture_Height, DISP_NEXTVSYNC); // LLY2.21, remove turn-off main video procedure into UTL_Config_FrameBuffer() //DISP_DisplayCtrl(DISP_MAINVIDEO, FALSE); //The Display should be closed after the main vedio has set. // LLY2.21, call UTL_Config_FrameBuffer() set desired frame buffer mode // LLY2.22, remove it since _UTL_ProgVideoOnly() will set it. //UTL_Config_FrameBuffer(UTL_FRAMEBUF_JPEG_SLIDE); // LLY2.21a, remove following procedure // Since, UTL_Config_FrameBuffer() will config the frame buffer mode.#if 0// DISP_DisplayCtrl(DISP_MAINVIDEO, FALSE); //UTL_DelayTime(COUNT_50_MSEC,1); OS_DelayTime(COUNT_50_MSEC); //CoCo1.20, reduce code size /* //Set display frame buffer. __dwDISPf0_addr = JPEGFMT_BUFF_DISP0; __dwDISPf1_addr = JPEGFMT_BUFF_DISP1; // Chuan0.66, __wDISPY_MaxSize declare as DWORD __dwDISPY_MaxSize = Y_MAXSIZE_A8C0; DISP_FrameBufferSet(DISP_MAINVIDEO); //CoCo0.90, set the address of the frame buffer for PIP //Set display frame buffer. __dwDISPpf0_addr = JPEGFMT_BUFF_DISP0; __dwDISPpf1_addr = JPEGFMT_BUFF_DISP1; DISP_FrameBufferSet(DISP_PIP); */ // Chuan0.90, Set MainVideo & PIP at the same time. // wyc2.17-909S, make frame buff0 as slide show buffer and buff1 as thumbnail buffer when single buffer mode.#ifdef JPG_SINGLE_FRAME_BUFFER dwDisplyBuff1 = JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_END_SLIDESHOW, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_END_THUMBNAIL, JPEG_DRAM_16M); //DISP_FrameBufferSet(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_ST_THUMBNAIL, DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_ST_SLIDESHOW, Y_MAXSIZE_8C00); //DISP_FrameBufferSet(DS_FRAMEBUF_ST_SLIDESHOW,(DS_FRAMEBUF_ST_SLIDESHOW + JPEG_DISP_SIZE_FOR_16M), (DS_FRAMEBUF_ST_SLIDESHOW + (JPEG_DISP_SIZE_FOR_16M*2)),DS_FRAMEBUF_END_THUMBNAIL, Y_MAXSIZE_8C00); DISP_FrameBufferSet(DS_FRAMEBUF_ST_SLIDESHOW, DS_FRAMEBUF_ST_THUMBNAIL, (DS_FRAMEBUF_ST_SLIDESHOW + (JPEG_DISP_SIZE_FOR_16M*2)),DS_FRAMEBUF_ST_THUMBNAIL, Y_MAXSIZE_8C00);#else#if (DRAM_CONFIGURATION_TYPE_DVD == DRAM_SIZE_64) dwDisplyBuff1 = JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST, (DS_FRAMEBUF_ST+DS_FRAMEBUF_SIZE-1), DS_JPG_ORG_BUFF_ST, DS_JPG_ORG_BUFF_END, JPEG_DRAM_64M);#elif (DRAM_CONFIGURATION_TYPE_DVD == DRAM_SIZE_32) dwDisplyBuff1 = JPEG_SetFrameBufferAddress(DS_FRAMEBUF_ST, (DS_FRAMEBUF_ST+DS_FRAMEBUF_SIZE-1), 0, 0, JPEG_DRAM_32M);#endif DISP_FrameBufferSet(DS_FRAMEBUF_ST, dwDisplyBuff1, DS_FRAMEBUF_ST, DS_FRAMEBUF_ST, Y_MAXSIZE_A8C0);#endif //JPG_SINGLE_FRAME_BUFFER DISP_FrameBufferMode(FALSE, FALSE);#endif // #if 0 //__DISPFrameInfo[0].bSrcFrame = 1; //__DISPFrameInfo[0].bDispFrame = 1; //__DISPFrameInfo[1].bSrcFrame = 1; //__DISPFrameInfo[1].bDispFrame = 1; /* __DISPFrameInfo[0].bSrcFrame = 1; __DISPFrameInfo[0].bDispFrame = 1; __DISPFrameInfo[0].bBFR_Mode = 0; __DISPFrameInfo[1].bSrcFrame = 1; __DISPFrameInfo[1].bDispFrame = 1; __DISPFrameInfo[1].bBFR_Mode = 0; __DISPFrameInfo[2].bSrcFrame = 1; __DISPFrameInfo[2].bDispFrame = 1; __DISPFrameInfo[2].bBFR_Mode = 0; */ //Set the source (display buffer) for main video. /* __dwCoded_Picture_Width = HALJPEG_DISPLAY_BUF_WIDTH; __dwCoded_Picture_Height = HALJPEG_DISPLAY_BUF_HEIGHT; DISP_MainVideoSet(&MainVideoInfo, __dwCoded_Picture_Width, __dwCoded_Picture_Height, DISP_NEXTVSYNC); */ HALJPEG_SetDisplay(); //Do jpeg reset // Chuan0.67, Don't do jpeg_reset when no any bits in. //HALJPEG_Reset();}//***************************************************************************// Function : HALJPEG_Reset// Abstract : Call this function to do JPEG reset when decoding each JPEG file.// Arguments : none.// Return : none.// Side Effect : none.// Notes ://***************************************************************************void HALJPEG_Reset(void){ //Abort current JPEG decoder action first when JPEG reset. HALJPEG_Abort(); OS_YieldThread(); //Call JPEG Decoder's reset function. JPEG_Reset(); _dwHALJPEGCheckTime=OS_GetSysTimer(); while((OS_GetSysTimer()-_dwHALJPEGCheckTime) < COUNT_5_SEC) { if (HALJPEG_Status(HALJPEG_RESET) == JPEG_STATUS_OK) { break; } OS_YieldThread(); }}//***************************************************************************// Function : HALJPEG_ParseHeader// Abstract : CCall this function to parse JPEG's header.// Arguments : bParseType: HALJPEG_PARSE_TYPE_NORMAL==>Parse the normal JPEG.// : HALJPEG_PARSE_TYPE_THUMBNAIL==>Parse the thumbnail.// : If there is no thumbnail in the file, parse the normal JPEG automatically.// Return : none.// Side Effect : none.// Notes ://***************************************************************************void HALJPEG_ParseHeader(BYTE bParseType, BYTE bDecodeBuf){ //CoCo2.76, put LOGO flag here to mean that the JPEG is starting to decode and background will be JPEG. //Don't put it in HALJPEG_Initial() because it may let LOGO re-decoded (screen will flash.) in some cases. __bLOGO = LOGO_JPEG; JPEG_SetSharpRatio(0,0); //senshong:get the mode that want to check current whether is encoded mode _bJPEGIsEncodeMode = 0; JPEG_ParseHeader(bParseType, bDecodeBuf); _bJPEGIsEncodeMode = bParseType;#if (DRAM_CONFIGURATION_TYPE_DVD == DRAM_SIZE_16) HALJPEG_SetDisplay();#endif}//***************************************************************************// Function : HALJPEG_Decode// Abstract : Call this function to decode the JPEG file.// Arguments : bFrameBuf: Decode the JPEG to the frame buffer 0 or 1.// Return : none.// Side Effect : none.// Notes ://***************************************************************************#ifdef SUPPORT_HAL_JPEG_AUTO_RATIOextern BYTE Get_Setup_Display_Type_16_9(void);WORD Get_HalJpeg_Panel_Ratio(WORD TempJPEGRealWidth,WORD TempJPEGRealHeight){ WORD WidthHeightRatio;#ifdef SUPPORT_LOGO_AUTO_FULL_SCREEN extern BYTE DisplayLogoFlag; if(DisplayLogoFlag) { WidthHeightRatio=TempJPEGRealWidth*10/TempJPEGRealHeight; WidthHeightRatio=WidthHeightRatio*256+10; return WidthHeightRatio; }#endif if(Get_Setup_Display_Type_16_9()) { WidthHeightRatio=16; WidthHeightRatio=WidthHeightRatio*256+9; } else { #ifdef SUPPORT_JPEG_AUTO_AND_FULL_SCREEN WidthHeightRatio=TempJPEGRealWidth*10/TempJPEGRealHeight; if((WidthHeightRatio>=13)&&(WidthHeightRatio<=19)) { WidthHeightRatio=WidthHeightRatio*256+10; } else { WidthHeightRatio=16; WidthHeightRatio=WidthHeightRatio*256+9; }#else WidthHeightRatio=4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -