This repository has been archived on 2025-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
android-g900/Start_WM/test6/inc/GFJxDec.h
2010-10-16 00:02:07 +06:00

509 lines
19 KiB
C
Executable File

/* Copyright (c) 2006 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an
* express license agreement from NVIDIA Corporation is strictly prohibited.
*/
/** @file GFJxDec.h
GFSDK JPEG Decode API header file.
*/
#ifndef _GF_JPEG_DEC__
#define _GF_JPEG_DEC__
#include "nvtypes.h"
#include "GFVx.h"
#ifdef __cplusplus
extern "C" { // only need to export C interface if
// used by C++ source code
#endif
/** @addtogroup groupJx JxDecAPI JPEG Decoder API
*/
/* <ul>
<li> @ref pageGxAppNotes
<ul>
<li> @ref pageGxAppNotes1
</ul>
</ul>
*/
/*@{*/
// JXDECCapFlags
/** JxDecAPI property flag: Support for Sequential encoded JPEG.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_SEQUENTIAL_DCT 0x00000001
/** JxDecAPI property flag: Support for Progressive encoded JPEG.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_PROGRESS_DCT 0x00000002
/** JxDecAPI property flag: Support for lossless encoded JPEG.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_LOSSLESS 0x00000004
/** JxDecAPI property flag: Support for hierarchical encoded JPEG.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_HIERARCHICAL 0x00000008
/** JxDecAPI property flag: Support for 8 bits encoded JPEG.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_8_BIT 0x00000010
/** JxDecAPI property flag: "No" Support for 12 bits encoded JPEG Presently.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_12_BIT 0x00000020
/** JxDecAPI property flag: Support for Interleaved mode.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_INTERLEAVE 0x00000040
/** JxDecAPI property flag: "No" Support presently for Interleaved mode.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_NO_INTERLEAVE 0x00000080
/** JxDecAPI property flag: Support for Huffman Coding.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_HUFFMAN 0x00000100
/** JxDecAPI property flag: No Support for Arithematic Coding presently.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_ARITHMETIC 0x00000200
/** JxDecAPI property flag: No Support for Interchange format coding.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_INTERCHANGE 0x00000400
/** JxDecAPI property flag: Support for Pixel Based Cropping(MCU based Cropping).
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_CROPPING 0x00001000
/** JxDecAPI property flag: Support for YUV444 encoded JPEG images.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_YUV444 0x00002000
/** JxDecAPI property flag: Support for YUV422 encoded JPEG images.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_YUV422 0x00004000
/** JxDecAPI property flag: YUV422 Rotation Supported.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_ROTATED_YUV422 0x00008000
/** JxDecAPI property flag: Support for YUV420 encoded JPEG images.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_YUV420 0x00010000
/** JxDecAPI property flag: Support for Gray Scale encoded JPEG images.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_GRAY_SCALE 0x00020000
/** JxDecAPI property flag: Support for Extended RGB format 24/32 bpp.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_EXTEND_RGB 0x00040000
/** JxDecAPI property flag: Support for YUV420 output decoded format.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_420_OUTPUT 0x00080000
/** JxDecAPI property flag: Support for YUV422 output decoded format.
@see GFJxDecGetProperty(), GFPROPERTY::Capability
*/
#define GF_JXDEC_CAP_422_OUTPUT 0x00100000
/** Image source dimensions and color format of the input JPEG to be decoded.
This structure is passed as parameter to GFJxDecGetImageInfo().
@see GFRMSURFACE::ColorFormat, GFJxDecGetImageInfo()
*/
typedef struct _GFJXDECIMAGEINFO
{
NvU32 IIFlag; /**< Deprecated, do not use.
This variable is set to the same error code as returned by GFJxDecGetImageInfo().
@deprecated
*/
NvU32 Width; /**< Width of the input image */
NvU32 Height; /**< Height of the input image */
NvU32 ColorFormat; /**< Color Format of input image (YUV420, YUV422, ...)
@see GFRMSURFACE.ColorFormat */
}GFJXDECIMAGEINFO, *PGFJXDECIMAGEINFO;
/** GFJxDecStart parameter structure.
This structure specifies target surface, scaling, source
and destination cropping for the decode operation.
@see GFJxDecStart()
*/
typedef struct _GFJXDECSTART
{
NvU32 SFlag; /**< Deprecated, do not use. @deprecated */
PGFRMSURFACE pDestSurf; /**< Destination Surface to hold the decoded image.
The color format of the surface controls the output color format.
If no destination cropping rectangle is given, the decoded picture
is scaled to match the surface size.
*/
PGFRECT pCroppingRect; /**< Source cropping area to be decoded, or NULL for no cropping.
Top-left position of the cropping rectangle must be aligned
to an MCU boundary.
*/
PGFRECT pDestRect; /**< Destination cropping area, or NULL for no cropping.
If a destination cropping rectangle is given, the decoded picture
will be scaled to fit this rectangle.
*/
NvU32 Error; /**< Deprecated, do not use.
This variable will be set to the same value as returned by GFJxDecStart().
@deprecated
*/
} GFJXDECSTART, *PGFJXDECSTART;
//SFlag: not used anymore. Cropping is decided on whether
//the pCroppingRect is NULL or not
#define GF_JXDEC_SFLAG_CROPPING 0
/** GF_DECODER_IDLE is returned if hardware decoder is idle by GFJxDecGetStatus().
@see GFJxDecGetStatus()
*/
#define GF_DECODER_IDLE 0x00000001
/** GF_DECODER_BUSY is returned if hardware decoder is busy by GFJxDecGetStatus().
@see GFJxDecGetStatus()
*/
#define GF_DECODER_BUSY 0x00000002
/** JxDecAPI Pass JX_DEC_SET_READBITSTREAM to GFJxDecSet to register call back function
@see GFJxDecSet()
*/
#define JX_DEC_SET_READBITSTREAM 1
/** Structure holding the callback function pointer.
Used in registering the callback function
*/
typedef struct _GFJXDECCALLBACK
{
void *pPara; /**< Not used anymore */
NvU32 (*pCallBack)(void * pPara, NvU8 ** ppBuffer, NvS32 * BufferLength);
/**<
Application callback function pointer.
Register a callback function for fetching JPEG Image data.
@param *pPara Not used anymore
@param ppBuffer Buffer Pointer
@param BufferLength Buffer Length in bytes, 0 if no bytes read.
@retval The number of bytes read successfully, 0 if no bytes read.
*/
}GFJXDECCALLBACK, *PGFJXDECCALLBACK;
/** Structure holding the callback function pointer.
Used in registering the callback function
*/
typedef struct _GFJXDECGETIMAGECALLBACK
{
void *pPara;
/**< pPara is a parameter passed from application,
and application wants API to call back with this parameter
*/
NvU32 (*pCallBack)(void * pPara, PGFRMSURFACE pImageSurf, PGFRECT pImageRect, NvU32 uiImageFlag);
/**<
Application callback function pointer.
Register a callback function for fetching decoded JPEG Image data.
@param *pPara Parameter to pass on to application callback function
@param pImageSurf Surface Pointer
@param pImageRect Source rectangle
@param uiImageFlag
<table>
<tr><td>#JX_DEC_IF_LAST_PORTION_IMAGE</td>
<td>This is the last portion of decoded image</td></tr>
</table>
@retval 0
*/
}GFJXDECGETIMAGECALLBACK, *PGFJXDECGETIMAGECALLBACK;
/** This is the last portion of the Image.
@see GFJXDECGETIMAGECALLBACK
*/
#define JX_DEC_IF_LAST_PORTION_IMAGE 0x00000001 //this is the last portion of decoded image
//Attribute uiFeature
/** Set get decoded image call back(inorder to dump the decoded YUV from JPEG).
@see GFJXDECGETIMAGECALLBACK, GFJxDecGetImageInfo
*/
#define JX_DEC_GETIMAGE 0x00000001
/** Pass JX_DEC_GETIMAGE_COLORFORMAT with GFJxDecGetAttribute to get JPEG image color format. */
#define JX_DEC_GETIMAGE_COLORFORMAT 0x00000002
/** Call this function get the JxDec Component's handle.
@param hRm (#GFRmHandle) Handle to the Resource Manager
@param phJxDec (#GFJxDECHandle) Pointer to the JxDecAPI Handle
@param state Set to Default state.
@param hCh (#GFRmChHandle) Channel Handle
@retval #GF_SUCCESS JxDec component registered successfully
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE GFJxDecOpen(GFRmHandle hRm, GFJxDecHandle *phJxDec, GF_STATE_TYPE state, GFRmChHandle hCh);
/** The function releases the JxDec's Component handle.
@param phJxDec (#GFJxDECHandle) Pointer to the JxDecAPI Handle
*/
void GFJxDecClose(GFJxDecHandle *phJxDec);
/** This function returns version and capabilities of JPEG decoder.
@param hJxDec Handle to JxDecAPI
@param pJXProp Pointer to property structure to be filled in
@retval #GF_SUCCESS \a pJXProp filled in successfully
@retval #GF_ERROR Some error occured
@see GFPROPERTY
*/
GF_RETTYPE GFJxDecGetProperty(GFJxDecHandle hJxDec, PGFPROPERTY pJXProp);
/** This function returns the status of the JPEG Decoder
@param hJxDec Handle to JxDecAPI
@param pStatus Returns status, GF_DECODER_BUSY or GF_DECODER_IDLE.
*/
GF_RETTYPE GFJxDecGetStatus(GFJxDecHandle hJxDec, NvU32* pStatus);
/** The funtion gets the information about the input image and fills it into the pInfo
If the function fails, it will return an error code describing the failure cause.
@param hJxDec Handle to JxDecAPI
@param pInfo Pointer to Image Information structure to be filled in
@retval GF_SUCCESS \a pInfo filled in successfully
@retval GF_JXDEC_IFLAG_INVALID_MARKER Invalid Marker in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_HDR_LEN Invalid header (marker) length in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_SIG Invalid Image Signature(eg: JFIF, AVI, ..) in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_DQT Invalid Quantization Table in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_DHT Invalid Huffman Tables in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_VALUE Invalid image parameters (eg: width, height , ...) in JPEG file
@retval GF_JXDEC_IFLAG_INVALID_FORMAT Invalid format in JPEG file
@retval GF_JXDEC_IFLAG_PROGRESSIVE_MARKER Invalid Marker in JPEG file
@see GFJXDECIMAGEINFO
*/
GF_RETTYPE GFJxDecGetImageInfo(GFJxDecHandle hJxDec, PGFJXDECIMAGEINFO pInfo);
/** This function sets up a callback function
@param hJxDec Handle to JxDecAPI
@param uiFeature Feature ID to set
@param pInfo Feature specific parameter
<table>
<tr><th>\a uiFeature</th>
<th>\a pInfo interpretation</th>
<th>Meaning</th></tr>
<tr><td>JX_DEC_SET_READBITSTREAM</td>
<td>GFJXDECCALLBACK*</td>
<td>Set up Jpeg bitstream feed callback</td></tr>
</table>
@retval #GF_SUCCESS If successful
@retval #GFJXD_ERROR_INVALID_PARAMETER Invalid parameter
@see GFJXDECCALLBACK
*/
GF_RETTYPE GFJxDecSet(GFJxDecHandle hJxDec, NvU32 uiFeature, void* pInfo);
/** Set attributes for the decoder.
@param hJxDec Handle to JxDecAPI,
@param attrID Attribute ID to be set
@param pInfo Attruvyte specific parameter
<table>
<tr><td>#JX_DEC_GETIMAGE </td>
<td>Get the YUV decoded JPEG image into a file, Sets the decoder image callback</td></tr>
<tr><td>#JX_DEC_GETIMAGE_COLORFORMAT </td>
<td>Set get decoded image color format.</td></tr>
</table>
@retval #GF_SUCCESS
*/
GF_RETTYPE GFJxDecSetAttribute(GFJxDecHandle hJxDec, NvU32 attrID, NvU32* pInfo);
/** Gets attributes for the decoder
@param hJxDec Handle to JxDecAPI,
@param attrID Attribute ID to read
@param pInfo Pointer to block returning attribute specific data
<table>
<tr><td>#JX_DEC_GETIMAGE </td>
<td>Get the YUV decoded JPEG image into a file, Sets the decoder image callback</td></tr>
<tr><td>#JX_DEC_GETIMAGE_COLORFORMAT </td>
<td>Set get decoded image color format.</td></tr>
</table>
*/
GF_RETTYPE GFJxDecGetAttribute(GFJxDecHandle hJxDec, NvU32 attrID, NvU32* pInfo);
/** Setup JxDecAPI for JPEG decoding a frame.
If GFJxDecStart() fails, it will return an error code describing the failure cause.
If GFJxDecStart() succeeded, GFJxDecEnd() must be called later.
@param hJxDec Handle to JxDecAPI
@param pStart Pointer to #GFJXDECSTART parameter structure.
@retval GF_SUCCESS Success
@retval GFRM_ERROR_OUT_MEMORY Not enough free GPU or system memory
@retval GF_JXDEC_NOT_SUPPORT_DESTSURFACE_FORMAT Destination Surface format not supported by the decoder
@retval GF_JXDEC_DECODER_WIDTH_TOO_BIG Image source width exceeds max decoder width
@retval GF_JXDEC_DECODER_HEIGHT_TOO_BIG Image source height exceeds max decoder height
@see GFJXDECSTART, GFJxDecSetAttribute(),GFJxDecEnd()
*/
GF_RETTYPE GFJxDecStart(GFJxDecHandle hJxDec, PGFJXDECSTART pStart);
/** Decode the image
@param hJxDec Handle to JxDecAPI
@param uiFlag Reserved, must be 0.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see GFJxDecGetImageInfo(), GFJxDecStart(), GFJxDecSetAttribute(), GFJxDecEnd()
*/
GF_RETTYPE GFJxDecDecodeImage(GFJxDecHandle hJxDec, NvU32 uiFlag);
/** End or cancel decoding a frame.
Must be called only, if GFJxDecStart() has been called before.
@param hJxDec Handle to JxDecAPI
*/
GF_RETTYPE GFJxDecEnd(GFJxDecHandle hJxDec);
/** GFJxDecAPI Error Codes. */
enum
{
/** GFJxDecAPI API called with invalid parameters. */
GFJXD_ERROR_INVALID_PARAMETER = GFJXD_ERROR,
/** Operation not supported. */
GFJXD_ERROR_NOT_SUPPORTED,
/** Encountered incomplete bitstream during decoding. */
GFJXD_ERROR_INCOMPLETE_BITSTREAM,
/** GFJxDecStart() return code: Can't support this destination surface type.
@see GFJXDECSTART, GFJxDecStart()
*/
GF_JXDEC_NOT_SUPPORT_DESTSURFACE_FORMAT,
/** GFJxDecStart() return code: Image width is too big for hardware decoder to handle
@see GFJXDECSTART, GFJxDecStart()
*/
GF_JXDEC_DECODER_WIDTH_TOO_BIG,
/** GFJxDecStart() return code: Image height is too big for hardware decoder to handle
@see GFJXDECSTART, GFJxDecStart()
*/
GF_JXDEC_DECODER_HEIGHT_TOO_BIG,
/** GFJxDecGetImageInfo() return code: If set then the input marker is Invalid,
if unset its a valid marker.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_MARKER,
/** GFJxDecGetImageInfo() return code: If set then the Header Length is Invalid,
if unset its a valid header length.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_HDR_LEN,
/** GFJxDecGetImageInfo() return code: If set then the Signature(eg: JFIF, AVI, ..) is Invalid,
if unset its a valid signature.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_SIG,
/** GFJxDecGetImageInfo() return code: If set then the there occured an error in reading the Quantization Table,
if unset the Quantization Table was read clean.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_DQT,
/** GFJxDecGetImageInfo() return code: If set then the Huffman Tables were not loaded properly
if unset Huffman Tables were loaded.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_DHT,
/** GFJxDecGetImageInfo() return code: If set then there was an invalid value(eg : erroneous/incomplete bitstream) in the stream,
if unset its a valid Iflag.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_VALUE,
/** GFJxDecGetImageInfo() return code: If set then the progressive marker not supported,
if unset its a valid marker.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_PROGRESSIVE_MARKER,
/** GFJxDecGetImageInfo() return code: If set then there was an invalid header format encountered in the stream,
if unset its a valid Iflag.
@see GFJXDECIMAGEINFO, GFJxDecGetImageInfo()
*/
GF_JXDEC_IFLAG_INVALID_FORMAT
};
/** @page pageJxDecAppNotes JxDecAPI Application Notes
@section pageJxDecAppNotes Programming Sequence
The following procedure requires that GFRmOpen() is called first to start GFSDK usage.
-# Call GFJxDecOpen() to obtain JxDecHandle which will be passed to different functions of JxDecAPI.
-# Query the properties through GFJxDecGetProperty() to check whether the desired JxDec features can be supported.
-# Call GFRmSurfaceAlloc() to allocate one surface to hold the decoded image.
-# Register the call back function using GFJxDecSet()
-# Call GFJxDecGetImageInfo() to get the JPEG image information, such as width and height.
-# GFJxDecStart() is the next function to call. This function will setup the decoder.
-# Call GFJxDecDecodeImage() to do the real decoding.
-# After the whole bitstream has been fed, call GFJxDecEnd() to end the decoding process.
-# Release surface by calling GFRmSurfaceFree().
-# Release JPEG decoder by calling GFJxDecClose().
*/
/*@}*/
#ifdef __cplusplus
}
#endif
#endif