📄 jpegdec.h
字号:
// **************************************************************************// (C)Copyright Cheertek Inc. 2003-2006,// J500, all right reserved.//// Product : CT909//// Author : Cheertek (J500 Tommy)// Purpose : JPEG Decoder// Sources : // **************************************************************************//#ifndef __JPEG_DECODER_H__#define __JPEG_DECODER_H__#ifdef __cplusplusextern "C" {#endif //__cplusplus#include "haljpeg.h"//#include "jpegfmt.h"// *** PLATFORM dependent ***////tommy0.80: separate error msgs from debug msgs#define JPEG_DECODER_ERRMSG// Compile for eCos909/ CheerDVD, with threads and using synchronization mechanisms#define JPEG_DECODER_ECOS//tommy1.21: define JPEG thread timed-out seconds for wait VDRemainder//tommy1.50: 2 is enough, but it's better to use 3 for worst loader/servo case.#define JPEG_WAIT_VDREM_TIMEDOUT_COUNT (COUNT_3_SEC)//tommy2.05: define JPU scale sampling mechanism: INTERPOLATION or NEAREST#define JPEG_SCALE_SAMPLING_INTERPOLATION//#define JPEG_SCALE_SAMPLING_NEAREST//tommy2.11: fix CT909S JPU horizontal scale down defect#define PATCH_CT909S_JPU_SCALE_DOWN//tommy2.11: [test code] patch src width to eliminate possible fractal part#undef PATCH_CT909S_JPU_SCALE_DOWN_2//tommy2.16: switch to apply CT909S' JPU SC+FR combo-operation feature//#define USE_JPU_SCFR_COMBO_OPERATION_PATCH//tommy2.17: switch to check and print for HVSC_FACTOR horizontal scale-down defect#ifdef PATCH_CT909S_JPU_SCALE_DOWN #undef CHECK_AND_PRINT_FOR_CT909S_JPU_SCALE_DOWN#endif#undef NO_USE_JPU_SCFR_COMBO_OPERATION_PATCH//senshong2.17:switch to use JPU SC+FR combo or use JPU SC and JPU FR//#define NOT_USE_JPU_SCFR_COMBO//#define JPEG_DEC_DEBUG#define JPEG_DRAM_16M 1#define JPEG_DRAM_32M 2#define JPEG_DRAM_64M 3#define JPEG_EFFECT_NONE 0#define JPEG_EFFECT_TRUE 1#define JPEG_EFFECT_DISP_BUFFER_2_TO_0 1#define JPEG_EFFECT_DISP_BUFFER_1_TO_0 2#define JPEG_DISP_SIZE_FOR_16M 0x69000//tommy2.16: macroes for VPU lock and unlock////#if (PLATFORM == ECOS_OS) && !defined(ECOS909) #define LOCK_MUTEX_VPU OS_LockMutex(&__mutexGDIIdle); #define UNLOCK_MUTEX_VPU OS_UnlockMutex(&__mutexGDIIdle);//#else //(PLATFORM == ECOS_OS) && !defined(ECOS909) //#define LOCK_MUTEX_VPU //#define UNLOCK_MUTEX_VPU //#endif //(PLATFORM == ECOS_OS) && !defined(ECOS909)//tommy2.16: fix the extra pixels by first failed writing ("writo") of CT909S' JPU FR operation#define PATCH_CT909S_JPU_FLIPROTATE_FIRST_WRITO//tommy2.16b: fix the interpolation defect of CT909S' JPU SC+FR operation (within vertical scaling)#define PATCH_CT909S_JPU_SCFR_VERTICAL_SCALE//#define CT909P_SUPPORT_MJPEG// --------------------// public declarations// --------------------//Parse the header of normal JPEG or thumbnail//VOID JPEG_ParseHeader(BYTE bType, BYTE bDecodeBuff);//bType://JPEG_PARSE_TYPE_NORMAL Parse the normal JPEG.//JPEG_PARSE_TYPE_THUMBNAIL Parse the thumbnail. If there is no thumbnail in the file, parse the normal JPEG automatically.//tommy0.67://bDecodeBuff: specify the protected buffer; 0 or 1.//Decode JPEG//VOID JPEG_Decode(PJPEGDECODE pDecode);#ifdef SUPPORT_MOTION_JPEGVOID JPEG_MotionDecode(VOID);#endif//pDecode: The decoding relative attributes.//Do zoom/rotate/flip operations//VOID JPEG_Operate(PJPEGSCALING pScaling);//pScaling: The scaling relative attributes.//Do "reset" before decoding each JPEG picture//VOID JPEG_Reset(VOID);//Preset the frame buffer//VOID JPEG_PresetFrameBuf(BYTE bBuffer, URECT *pRect, DWORD dwColor);//bBuffer: Frame buffer 0 or 1. //wWidth: The width of the block we want to fill in the frame buffer. (pixels)//wHeight: The height of the block we want to fill in the frame buffer. (pixels)//dwColor: The color we want to fill into the frame buffer.//Call this function to get the status of JPEG Decoder.//BYTE JPEG_Status(BYTE bStatusType);//bStatusType://JPEG_PARSE_HEADER Get "parse header" status.//JPEG_DECODE Get "Decode" status.//JPEG_OPERATION Get "Operate" status.//JPEG_PSFB Get "Preset frame buffer" status.//JPEG_RESET Get "reset" status.//return://JPEG_STATUS_UNFINISH The action is unfinished.//JPEG_STATUS_UNSUPPORT This return value is for "parse header" to represent that the JPEG file can't be decoded in our solution.//JPEG_STATUS_OK The action is OK.//JPEG_STATUS_FAIL The action is failed.//Abort JPEG decoding.//VOID JPEG_Abort(VOID);VOID JPEG_SetSharpRatio(WORD wFristNoInterpolnterpolation,WORD wSecondNoInterpolnterpolation);// --------------------// local macro definitions// --------------------// MACRO definitions// IS THERE ANY TESTBENCH for these MACROES?#define MBINT_CTL_JPEG_ST (0x800)// align to 32x.#define ALIGN32(src) (((src) + 31) & 0xffe0)#define STRIP32(src) ((src) & 0xffe0)// align to 16x.#define ALIGN16(src) (((src) + 15) & 0xfff0)#define STRIP16(src) ((src) & 0xfff0)// align to 4x.#define ALIGN04(src) (((src) + 3) & 0xfffc)#define STRIP04(src) ((src) & 0xfffc)// align to 8x.#define ALIGN08(src) (((src) + 7) & 0xfff8)#define STRIP08(src) ((src) & 0xfff8)// align to 2x.#define ALIGN02(src) (((src) + 1) & 0xfffe)#define STRIP02(src) ((src) & 0xfffe)// set value for the REG_JPU_CTL// required parameters and their mapping field:////make sure GPU_OP = 0, for JPU operation#ifdef JPEG_SCALE_SAMPLING_INTERPOLATION #define TRANS_JPU_CTL(type, op, uv) ((0 << 28) | ((type) << 12) | ((op)) | ((uv) << 3)) #define TRANS_JPU_CTL_FR(type, op, frtype, uv) (((type) << 12) | ((op)) | ((frtype) << 8) | ((uv) << 3)) #define TRANS_JPU_CTL_NO_INTERPOLATION(type, op, uv) ((0 << 28) | JPU_V_NEAREST_EN | JPU_H_NEAREST_EN | ((type) << 12) | ((op)) | ((uv) << 3))#else //NEAREST #define TRANS_JPU_CTL(type, op, uv) ((0 << 28) | JPU_V_NEAREST_EN | JPU_H_NEAREST_EN | ((type) << 12) | ((op)) | ((uv) << 3)) #define TRANS_JPU_CTL_FR(type, op, frtype, uv) (JPU_V_NEAREST_EN | JPU_H_NEAREST_EN | ((type) << 12) | ((op)) | ((frtype) << 8) | ((uv) << 3))#endif// set register REG_MC_CTL for MC scaling H/V ratios// mcctl[2:1], horizontal scale down setting// mcctl[4:3], vertical scale down setting// clear the bits of vertical and horizontal scaling ratios first.// then fill mask-ed ratio values into these bit fields.////tommy1.50: fix CLEAR_MCCTL_SCALE//#define CLEAR_MCCTL_SCALE() (REG_MC_CTL &= 0xe1)#define CLEAR_MCCTL_SCALE() (REG_MC_CTL &= 0xFFFFFFE1)#define TRANS_MCCTL_SCALE(v_ratio,h_ratio) ((((v_ratio) & 0x3) << 3) | (((h_ratio) & 0x3) << 1))#ifdef CT909G_IC_SYSTEM#define TRANS_JPGHV_SCALE(y_v_ratio,y_h_ratio,uv_v_ratio,uv_h_ratio) ((((y_h_ratio) & 0x3) ) | (((uv_h_ratio) & 0x3) << 2) |(((uv_h_ratio) & 0x3) << 4) |(((y_v_ratio) & 0x3) << 6) |(((uv_v_ratio) & 0x3) << 8)|(((uv_v_ratio) & 0x3) << 10))#endif// calculate value for JPU's heiwid_src and heiwid_dst registers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -