📄 hal_jpeg.h
字号:
/************************************************************************
; HAL_JPEG.h
;
; The routines in this file comprise the jpeg codec setting
;
; The Function is basic operation of LCDC
;
; Copyright (c) 2002 Epson Research and Development, Inc.
;
; All Rights Reserved.
; 2002.11.12 D Eric Start.
;
;************************************************************************/
#ifndef __HAL_JPEG_H__
#define __HAL_JPEG_H__
typedef enum
{
ErrorDetectFunctionOff=0,
ErrorDetectFunctionOn=1,
DataReviseFunctionOn=2
} JpegRSTMarkerOpSel;
typedef enum
{
Enc=0x0000,
Dec=0x0001
} JpegOpSel;
typedef enum
{
YUVFmt444=0,
YUVFmt422=1,
YUVFmt420=2,
YUVFmt411=3
} JpegYUVFmtSel;
typedef enum
{
NoError=0x0000,
RestartIntervalError=0x000B,
ImageSizeError=0x000C
} JpegErrorStatus;
typedef enum
{
JpegEncodeDecode=0x00,
YUVDataInputFromHostDisplay422=0x01,
YUVDataToHost_BypassJpeg_YUV422=0x03,
YUVDataInputFromHostDisplay420=0x05,
YUVDataToHost_BypassJpeg_YUV420=0x07
} JpegOpMode;
typedef enum
{
JpegFileOut=0x4000, // During Jpeg file output
FifoThrshStatusMask=0x3000, // Fifo threshold status
EncSizeLimit=0x0800, // Exceeded the Enc size limit
FifoThrshTrigger=0x0400, // Exceeded the Fifo threshold
FifoBufFull=0x0200, // Fifo is full
FifoBufEmpty=0x0100, // Fifo is empty
JpegDecComplete=0x020c, // Jpeg Dec is completed
JpegDecMarkerRd=0x010c, // Jpeg Dec marker Rd
SizeMismatch=0x0008, // File size in maker is different from the actual size
LnBufOverflow=0x004c, // Line Buf overflow error
JpegCodecInt=0x0002, // Jpeg codec interrupt
AllStatusClear=0xFFFF
} JpegStatusFlag;
typedef enum
{
IntEnc=0x0E06,
IntDec=0x013A,
IntCap=0x0604,
IntDis=0x0000
} JpegIntCtl;
typedef enum
{
NoThrsh=0,
ThrshAt4Bytes=1,
ThrshAtQuarterFull=2,
ThrshAtHalfFull=3
} JpegFifoThrsh;
typedef enum
{
CircuitView=0,
CircuitCap=1
} JpegCircuitSel;
typedef struct tagJENCODEINFO // jpeg encode information
{
unsigned long MemoryStart; // Memroy Start Address ( FIFO Start address )
char * pszFileName;
unsigned char ScalingRate;
ResizeScalingMode ScalingMode;
JpegFifoThrsh FifoThreshold;
BOOL YUVOutDataRange;
unsigned short XStart;
unsigned short YStart;
unsigned short Width;
unsigned short Height;
unsigned char * pBuffer;
unsigned long BufferSize;
unsigned long EncodedSize;
unsigned char FifoSizeIn4KB;
JpegOpMode OpMode;
BOOL Verbose;
unsigned long Delay;
BOOL InitCap;
JpegYUVFmtSel CaptureYUVFmt;
unsigned char Quality;
unsigned long FrameCount;
BOOL Pause;
BOOL ExcludeBugs;
} JENCODEINFO;
typedef struct tagJDECODEINFO // jpeg decode information
{
unsigned char * pJPEGData; // pointer to JPEG data
unsigned long JPEGDataSize; // JPEG data size
unsigned short YRCOutputBpp; // color format of data from YRC
unsigned long YRCOutputDispAddr; // data from YRC is written to FrameBuffer starting from OutputDispAddr;
unsigned short DesiredDispX; // Desired Display X coordinate
unsigned short DesiredDispY; // Desired Display Y coordinate
unsigned short ActualDispX; // Actual Display X coordinate
unsigned short ActualDispY; // Actual Display Y coordinate
} JDECODEINFO;
typedef struct tagJDECODEINITINFO // jpeg encode initial information
{
unsigned short RSTMarkerSetting;
unsigned short FIFOSizeIn4KB; //75064 range from 1 to 32, 1 for 4K, 32 for 32*4k=128k
//13712 range from 1 to 16, 1 for 4k, 16 for 16*4k=64k
//JPEG FIFO start is fixed at address 0.
unsigned long Pauses; //bit field for control individual pauses
BOOL CameraClkOff;
BOOL ExcludeBugs;
} JDECODEINITINFO;
typedef struct
{
BOOL NoInit;
BOOL ExcludeBugs;
BOOL Loop;
BOOL MainWin;
BOOL Pauses;
unsigned short RSTMarkerSetting;
unsigned short FIFOSizeIn4KB;
// Indirectly set information.
unsigned long JPGFileSize;
unsigned long TotalVmem; // Total video memory on the card.
// Main Window setting
unsigned short MainWidth; // Width (in pixels) of the mode.
unsigned short MainHeight; // Height (in pixels) of the mode.
unsigned short MainBpp; // Bits per pixel.
unsigned short MainStride; // Number of bytes from one line to the next.
unsigned short MainSwivel; // Current SwivelView (0,90,180,270)
unsigned long MainStartAddr;
// PIP setting
unsigned long PIPStartAddr; //PIP windows Start Address
unsigned short PIPBpp; // Bits per pixel.
unsigned short PIPStride; // Number of bytes from one line to the next.
unsigned short PIPSwivel; // Current SwivelView (0,90,180,270)
unsigned short PIPWidth; // Width (in pixels).
unsigned short PIPHeight; // Height (in pixels).
unsigned short PIPx; // PIP left position (unaware of any h/w rotation)
unsigned short PIPy; // PIP top position (unaware of any h/w rotation)
unsigned short PIPxSize; // PIP horizontal size (unaware of any h/w rotation)
unsigned short PIPySize; // PIP vertical size (unaware of any h/w rotation)
// YUV to RGB converter setting
unsigned long YUVWrtStartAddr; // YUV Image Input Write Start Adress
BOOL fOrthogonal; // Main and PiP window orientations are perpendicular (at 90 degree right angle)
} CONTROL_INFO;
//return values for jpegDecodeGetLastError()
#define JDECODE_ERR_NONE 0 // No error
#define JDECODE_ERR_RESIZE_CUT 1 // ResizeSetCuttingAddress() error
#define JDECODE_ERR_FILE_SIZE_MISMATCH 2 // File Size mismatch error during JPEG Decode
#define JDECODE_ERR_YRC_OUTPUT_BPP 3 // YUV/RGB Converter output BPP is set wrong
#define JDECODE_ERR_RST 4 // Invalide RST Marker Setting
#define JDECODE_ERR_FIFO_SIZE 5 // Invalid FIFO size
#define JDECODE_ERR_RESIZE_SCALE 6 // Reqired Resize scaling fact is too big to be handled by h/w
//bit field for control individual pauses in jpegDecode().
//these control is for h/w debug/test only, press a key would continue JPEG decode.
#define JDECODE_PAUSE_BEFORE_CODEC_START 1 // Pause before JPEG Codec Starts
#define JDECODE_PAUSE_AFTER_LAST_FIFO_WRT 2 // Pause after last byte is written to JPEG FIFO (reg[9A6h])
#define JDECODE_PAUSE_AFTER_SET_VIEW_RESIZE 4 // Pause after setting view-resizer, allow testers to change reg[944h] to reg[94ah] properly.
//RSTMarkerSetting values
#define RST_ERRDETECT_DATAREVISE_OFF 0 // RST marker error detect & data revise function off (default)
#define RST_ERRDETECT_ON 0 // RST marker error detect function on
#define RST_DATAREVISE_ON 0 // RST marker data revise function on
// return values for jpegEncodeGetLastError()
#define JENCODE_ERR_NONE 0
#define JENCODE_ERR_LINEBUF_OVERFLOW 1
#define JENCODE_ERR_ENCSIZELIMIT 2
#define JENCODE_ERR_NO_FIFO_DATA 3
#define JENCODE_ERR_FIFO_FULL 4
#define JENCODE_ERR_NULL_BUFFER 5
#define JENCODE_ERR_ZERO_BUFFER_SIZE 6
#define JENCODE_ERR_NO_ENDOFIMAGE 7
#define JENCODE_ERR_FIFO_SIZE_ZERO 8
#define JENCODE_ERR_DIM_RESTRICT 9
#define RESIZE_MAX_XPOSITION 0x0400
#define RESIZE_MAX_YPOSITION 0x0200
#define VIEW_CIRCUIT 0
#define CAPTURE_CIRCUIT 1
//-----------------------------------------------------------------------------
// JPEG processing
//-----------------------------------------------------------------------------
// Bits
// JPEG Control Register
#define JPEG_SOFTWARE_RESET 0x80
#define JPEG_ENA 0x00
#define JPEG_YUV_RANGE_SELECT1 0x10
#define JPEG_YUV_RANGE_SELECT0 0x00
#define JPEG_MODULE_CLOCK_ON 0x01
#define JPEG_MODULE_CLOCK_OFF 0x00
// JPEG Status Flag Register
#define JPEG_FILE_OUTPUT 0x4000 // During JPEG file output
#define FIFO_THRESHOLD_STATUS_MASK 0x3000 // FIFO threshold status
#define ENCODE_SIZE_LIMIT_VIOLATION 0x800 // Exceeded the encode size limit
#define FIFO_THRESHOLD_TRIGGER 0x400 // Exceeded the FIFO threshold
#define FIFO_BUFFER_FULL 0x200 // FIFO is full
#define FIFO_BUFFER_EMPTY 0x100 // FIFO is empty
#define JPEG_DECODE_COMPLETE 0x20 // JPEG decode is completed
#define JPEG_DECODE_MARKER_READ 0x10 // JPEG decode marker read
#define JPEG_FILE_SIZE_MISMATCH 0x8 // File size in maker is different from the actual size
#define JPEG_LINE_BUFFER_OVERFLOW 0x4 // Line buffer overflow error
#define JPEG_CODEC_INT 0x2 // JPEG codec interrupt
#define JPEG_ERR_SET_SIZE_DECODE 0x8000 // borrow the reserve bit to signal error while setting view-resize for JPG decode
#define ALL_STATUS_CLEAR 0xFFFF
// JPEG Interrupt Control Register
#define ENCODE_SIZE_LIMIT_OVER_INT_ENA 0x0800
#define ENCODE_SIZE_LIMIT_OVER_INT_DIS 0x0000
#define FIFO_THRESHOLD_TRIGGER_INT_ENA 0x0400
#define FIFO_THRESHOLD_TRIGGER_INT_DIS 0x0000
#define FIFO_BUFFER_FULL_INT_ENA 0x0200
#define FIFO_BUFFER_FULL_INT_DIS 0x0000
#define FIFO_BUFFER_EMPTY_INT_ENA 0x0100
#define FIFO_BUFFER_EMPTY_INT_DIS 0x0000
#define JPEG_DECODE_COMPLETE_INT_ENA 0x0020
#define JPEG_DECODE_COMPLETE_INT_DIS 0x0000
#define DECODE_MARKER_READ_INT_ENA 0x0010
#define DECODE_MARKER_READ_INT_DIS 0x0000
#define SIZE_MISMATCH_INT_ENA 0x0008
#define SIZE_MISMATCH_INT_DIS 0x0000
#define LINE_BUFFER_OVERFLOW_INT_ENA 0x0004
#define LINE_BUFFER_OVERFLOW_INT_DIS 0x0000
#define JPEG_CODEC_INT_ENA 0x0002
#define JPEG_CODEC_INT_DIS 0x0000
// JPEG Start/Stop Control Register
#define JPEG_START_CTRL 0x0001
#define JPEG_STOP_CTRL 0x0000
#define VGA_V_Size 480
#define VGA_H_Size 640
#define CIF_V_Size 288
#define CIF_H_Size 352
#define QCIF_V_Size 144
#define QCIF_H_Size 176
#define LCD_V_Size 220
#define LCD_H_Size 176
// Codec Command Set Register
#define CODEC_SOFT_RESET 0x80
#define CODEC_START 0x01
// Codec Operation Status Register
#define CODEC_STOP 0x00
#define CODEC_RUN 0x01
void JpegOpModeSetting(JpegYUVFmtSel yuvFmtSel, JpegOpSel jpegOpSel,BOOL markerInsert);
void JpegMarkerInsertSet( BOOL enable );
BOOL JpegMarkerInsertGet( void );
void JpegDNLInsertSet( BOOL enable );
BOOL JpegDNLInsertGet( void );
void JpegOpSelSet( JpegOpSel opSel );
JpegOpSel JpegOpSelGet( void );
void JpegYUVFmtSelSet( JpegYUVFmtSel yuvFmtSel );
JpegYUVFmtSel JpegYUVFmtSelGet( void );
void JpegCommandSetting( BOOL opEn, BOOL swReset, JENCODEINFO* pJEncodeInfo );
void JpegCodecSWResetSet( BOOL reset );
BOOL JpegCodecSWResetGet( void );
void JpegOpEnSet( BOOL start );
BOOL JpegOpStatusGet( void );
void JpegQuantTableNumSet( BOOL color1, BOOL color2, BOOL color3 );
unsigned char JpegQuantTableNumGet( unsigned char color );
void JpegHuffmanTableNumSet(BOOL dcColor1,BOOL acColor1,BOOL dcColor2,BOOL acColor2,BOOL dcColor3,BOOL acColor3 );
unsigned char JpegHuffmanTableNumGet( unsigned char color, BOOL ac );
void JpegDRISettingSet( unsigned short minimumCodedUnit );
unsigned short JpegDRISettingGet( void );
void JpegVertPixelSizeSet( unsigned short verticalPixelSize );
unsigned short JpegVertPixelSizeGet( void );
void JpegHorizPixelSizeSet( unsigned short horizontalPixelSize );
unsigned short JpegHorizPixelSizeGet( void );
unsigned short JpegDNLValueSettingGet( void );
void JpegRSTMarkerOpSelSet( JpegRSTMarkerOpSel rstMarkerOpSel );
JpegRSTMarkerOpSel JpegRSTMarkerOpSelGet( void );
JpegErrorStatus JpegErrorStatusGet( void );
void JpegReviseCodeEnSet(BOOL start);
void LoadTable( unsigned short index, unsigned short* pTable, unsigned long size );
void JpegLoadQuantizationTables( void );
void JPEGQuantQualitySet( unsigned char Quality );
void JpegLoadHuffmanTables( void );
void JpegCtlSet( BOOL moduleOn, JpegOpMode opMode, BOOL yuvOutRangeSel, BOOL swReset, JENCODEINFO* pJEncodeInfo );
void JpegCtlSWResetSet( void );
void JpegYUVOutDataRangeSelSet( BOOL YUVOutRangeSel );
BOOL JpegYUVOutDataRangeSelGet( void );
void JpegOpModeSet( JpegOpMode opMode );
JpegOpMode JpegOpModeGet( void );
void JpegModuleOnSet( BOOL on );
BOOL JpegModuleOnGet( void );
void JpegFifoClearThrshInt( void );
void JpegStatusFlagSet( JpegStatusFlag flag );
JpegStatusFlag JpegStatusFlagGet( void );
unsigned short JpegRawStatusFlagGet( void );
void JpegFifoThrshTrigEnSet( BOOL enable );
void JpegIntCtlSet( JpegIntCtl ctl );
JpegIntCtl JpegIntCtlGet( void );
void JpegCodeStartCtlSet( BOOL start, JENCODEINFO* pJEncodeInfo );
BOOL JpegCodeStartCtlGet( void );
void JpegFifoCtl( JpegFifoThrsh TriggerThreshold, BOOL clear, JENCODEINFO* pJEncodeInfo );
void JpegFifoClear( JENCODEINFO* pJEncodeInfo );
void JpegFifoThrshSelSet( JpegFifoThrsh fifoThrsh );
JpegFifoThrsh JpegFifoThrshSelGet( void );
BOOL JpegFifoDirectionGet( void );
BOOL JpegFifoBufEmptyGet( void );
BOOL JpegFifoBufFullGet( void );
JpegFifoThrsh JpegFifoThrshStatusGet( void );
void JpegFifoSizeSet( unsigned char fifoSize );
unsigned char JpegFifoSizeGet( void );
unsigned long JpegFifoValidDataSizeGet( void );
unsigned char * JpegFifoRdPointerGet( void );
unsigned char* JpegFifoWrPointerGet( void );
void JpegEncSizeLimitSet( unsigned long encSizeLimit );
unsigned long JpegEncSizeLimitGet( void );
unsigned long JpegEncSizeResultGet( void );
void JpegFileSizeSet( unsigned long fileSize );
unsigned long JpegFileSizeGet( void );
BOOL JpegLnBufEmptyStatusGet( void );
BOOL JpegLnBufFullStatusGet( void );
BOOL JpegDrainFifo( unsigned short ** ppCurrent, unsigned long bufferSize, JENCODEINFO* pJEncodeInfo );
long JpegEncodeGetLastError( void );
void JpegEncodeSetLastError( long lastError );
#endif // __HAL_JPEG_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -