📄 jpeg_enc.h
字号:
/** * @file jpeg_enc.h * @brief The header file for Faraday JPEG Encoder API. * */#ifndef _JPEG_ENC_H_#define _JPEG_ENC_H_/** * By using typedef to create a type name for DMA memory allocation function. * And user can allocate memory on a specified alignment memory * by using the parameter align_size. * * @param size is the bytes to allocate. * @param align_size is the alignment value which must be power of 2. * @param reserved_size is the specifed cache line. * @param phy_ptr is used to return the physical address of allocated aligned memory block. * @return return a void pointer to virtual address of the allocated memory block. * @see FJPEG_ENC_PARAM * @see DMA_FREE_PTR */typedef void *(* DMA_MALLOC_PTR)(unsigned int size,unsigned char align_size,unsigned char reserved_size, void ** phy_ptr);/** * By using typedef to create a type name for DMA memory free function. * And user can use this type of function to free a block of memory that * was allocated by the DMA_MALLOC_PTR type of function. * * @param virt_ptr is a pointer to the memory block with virtual address that was returned * previously by the type of DMA_MALLOC_PTR function. * @param phy_ptr is a pointer to the memory block with physical address that was returned * previously by the type of DMA_MALLOC_PTR function. * @return return void. * @see FJPEG_ENC_PARAM * @see DMA_MALLOC_PTR */typedef void (* DMA_FREE_PTR)(void * virt_ptr, void * phy_ptr);/// The Faraday JPEG Encoder Parameters Structure./** * While creating jpeg encoder object by using FJpegEncCreate() operation, FJPEG_ENC_PARAM * pointer is served as FJpegEncCreate()'s parameter to internally initialize related JPEG encoder * object settings.\n * See @ref jpeg_encoder_ops_grp \n * @see FJpegEncCreate * */typedef struct { /// The base address of hardware core. unsigned int *pu32BaseAddr; /**< User can use this variable to set the base * address of hardware core. */ /// The base address for input YUV buffer. unsigned char *pu8YUVAddr[3]; /**< To set input YUV frame buffer's base address.\n * <B>N.B.</B> : the address must be physical address with <B>8-byte aligned</B>. * @see pu32BaseAddr * @see pu8BitstreamAddr */ /// The number of components in the input YUV image. unsigned char u8NumComponents; /**< This variable tells the number of components in the input * YUV image. The color space used for these components * is <B>YCbCr</B>. If only one component is used, the * component will be <B>Y</B> only. * @see rgComponentInfo */ /// The array of structures to describe each component information about input YUV image. struct { /// The horizontal sampling frequency of this component. unsigned char m_u8HSamplingFrequency; /**< horizontal sampling frequency factor (1..4) for this component.*/ /// The vertical sampling frequency of this component. unsigned char m_u8VSamplingFrequency; /**< vertical sampling frequency factor (1..4) for this component. */ } rgComponentInfo[3]; /**< * According to JFIF standard, the color space is restricted to one or three components. \n * For three components, <B>YCbCr</B> is used. \n * If only one component is used, the component will be <B>Y</B>. \n * Thus, depending on the number of components (indicated by member vairable 'u8NumComponents'), * the following array of component descriptor 'rgComponentInfo' structure are in the * order <B>{ Y, Cb,Cr }</B> respectively. * * Currently, the YUV formats that JPEG encoder supports now are shown below : * - Each component's horizontal and vertical smapling factors are representing * in the form '( <B>HxV</B> )' , where <B>H</B> is horizontal sampling factor * and <B>V</B> is vertical sampling factor: * - '420' : Y ( <B>2x2</B> ) , U ( <B>1x1</B> ) , V ( <B>1x1</B> ) * - '422' : Y ( <B>4x1</B> ) , U ( <B>2x1</B> ) , V ( <B>2x1</B> ) * - '211' : Y ( <B>2x1</B> ) , U ( <B>1x1</B> ) , V ( <B>1x1</B> ) * - '333' : Y ( <B>3x1</B> ) , U ( <B>3x1</B> ) , V ( <B>3x1</B> ) * - '222' : Y ( <B>2x1</B> ) , U ( <B>2x1</B> ) , V ( <B>2x1</B> ) * - '111' : Y ( <B>1x1</B> ) , U ( <B>1x1</B> ) , V ( <B>1x1</B> ) * * @see u8NumComponents */ /// The image quality setting (0 ~ 100) unsigned int u32ImageQuality; /**< This variable can set the encoded image quality. * The higher the image quality setting, the closer the encoded * image will be to the original input YUV image, and , of course, * the larger the JPEG file. * The range for this quality setting is between 0 (worst) to 100 (best). */ /// The restart marker interval. unsigned int u32RestartInterval; /**< This variable specifies the number of MCUs between * restart markers within the compressed data. * If the specified restart interval is zero, then * the restart marker is not used. */ /// The image width in pixels. unsigned int u32ImageWidth; /**< This variable indicates the actual input image width. * */ /// The image height in pixels. unsigned int u32ImageHeight; /**< This variable indicates the actual input image height. * */ /// The output bitstream buffer address while encoding the input YUV image. unsigned char *pu8BitstreamAddr; /**< To set output bitstream buffer's address.\n * This bitstream buffer was provided by user and used * for JPEG encoder while encoding input YUV image.\n * <B>N.B.</B> : the input bitstream buffer address must be <B>physical address</B> with <B>4-byte aligned</B>. * */ /// The function pointer to user-defined DMA memory allocation function. DMA_MALLOC_PTR pfnDmaMalloc; /**< This variable contains the function pointer to the user-defined * DMA malloc function since under OS environment, our hardware device * may need the physical address instead of virtual address. * * @see pfnDmaFree * @see DMA_MALLOC_PTR * @see DMA_FREE_PTR */ /// The function pointer to user-defined DMA free allocation function. DMA_FREE_PTR pfnDmaFree; /**< This variable contains the function pointer to the user-defined * DMA free function since under OS environment, our hardware device * may need the physical address instead of virtual address. * * @see pfnDmaFree * @see DMA_MALLOC_PTR * @see DMA_FREE_PTR */ } FJPEG_ENC_PARAM;#ifndef JPEGENC_EXPOPRT #ifdef __cplusplus #define JPEGENC_EXPOPRT extern "C" #else #define JPEGENC_EXPOPRT extern #endif#endif/***************************************************************************** * JPEG Encoder entry point ****************************************************************************/ /// Faraday JPEG Encoder API Functions Reference./** * * \defgroup jpeg_encoder_ops_grp Faraday JPEG Encoder API Reference * * The following section describes all the operations Faraday JPEG encoder can perform. * * @{ *//// To create an JPEG encoder object and return handle to user./** * And the returned handle have to be used in the rest of JPEG encoder operations. * * @param ptParam is the structure containing necessary encoder object parameters * @return return an JPEG encoder handle (void pointer) * * @see FJPEG_ENC_PARAM * @see FJpegEncEncode * @see FJpegEncDestroy * */JPEGENC_EXPOPRT void * FJpegEncCreate(FJPEG_ENC_PARAM * ptParam);/// To begin to encode input YUV image to JPEG bitstream./** * After calling FJpegEncCreate() function , user can start to encode the input image by * calling this function. * * @param enc_handle is the handle of JPEG encoder object. * @return return void. * * @see FJPEG_ENC_PARAM * @see FJpegEncCreate * @see FJpegEncDestroy * */JPEGENC_EXPOPRT void FJpegEncEncode(void *enc_handle);/// To get encoded bitstream length/** * After input image is encoded, user is able to obtain the encoded bitstream length by * utilizing this function. * * @param enc_handle is the handle of encoder object. * @return return the encoded bitstream length after encoding. * @see FJpegEncEncode * @see FJpegEncDestroy * */JPEGENC_EXPOPRT unsigned int FJpegEncGetBitsLength(void *enc_handle);/// To destroy JPEG encoder object/** * After encoding, we need to release the JPEG encoder object. * * @param enc_handle is the handle of JPEG encoder object. * @return return void. * @see FJpegEncCreate * @see FJpegEncDestroy * */JPEGENC_EXPOPRT void FJpegEncDestroy(void *enc_handle);/** * @} */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -