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/GFMxEncH264.h
2010-10-16 00:02:07 +06:00

789 lines
40 KiB
C
Executable File
Raw Blame History

/* 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 GFMxEncH264.h
GFSDK H264 Encode API header file.
*/
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the GFMXENC_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// GFMXENC_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifndef _GF_MPEG_ENC_H264__
#define _GF_MPEG_ENC_H264__
#include "GFVx.h"
#include "GFDef.h"
/** @addtogroup groupMxEncH264 MxEncH264API H264 Encode API
<ul>
<li> @ref pageMxEncH264AppNotes
<ul>
<li> @ref pageMxEncH264AppNotes1
</ul>
</ul>
*/
/*@{*/
/** @name GFMxEncH264 API Property Caps */
//@{
/** MxEncH264API property flag: Support baseline Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_BASELINE 0x00000001 //support baseline profile
/** MxEncH264API property flag: Support Main Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_MAIN 0x00000002 //support main profile
/** MxEncH264API property flag: Support extended Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_EXTENDED 0x00000004 //support extended profile
/** MxEncH264API property flag: Support high 10 Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_HIGH10 0x00000008 //support high 10 profile
/** MxEncH264API property flag: Support high 422 Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_HIGH422 0x00000010 //support high 422 profile
/** MxEncH264API property flag: Support high 444 Profile.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_HIGH444 0x00000020 //support high 444 profile
/** MxEncH264API property flag: Level_IDC following H.264 spec definition.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_LEVEL_IDC(Capability) \
((Capability >> 12) & 0xfff)//Level_IDC following H.264 spec definition
/** MxEncH264API property flag: Support data partitioning mode.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_DATA_PARTITIONING 0x10000000 //support data partitioning mode
/** MxEncH264API property flag: Support rate control.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_RATE_CONTROL 0x20000000 //support rate control
/** MxEncH264API property flag: Support intra macro block refreshing.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_IMRF 0x40000000 //support intra macro block refreshing
/** MxEncH264API property flag: Support rotation.
@see MxEncH264GetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_H264_CAP_ROTATION 0x80000000 //support rotation
//@}
/**typedef struct GFMXENCH264SETSEQUENCE_TAG*/
typedef struct GFMXENCH264SETSEQUENCE_TAG
{
NvU32 SequenceInfo; /**< Sequence characteristics */
/**<
<table>
<tr><td>#GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET0_FLAG</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET1_FLAG</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET2_FLAG </td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_DELTA_PIC_ORDER_ALWAYS_ZERO_FLAG</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_FRAME_MBS_ONLY_FLAG </td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_RATE_CONTROL_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_AUTO_IMRF_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_MC_IMRF_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_REALTIME_ENCODE</td></tr>
<tr><td>#GF_MXENC_H264_SEQUENCE_DEBLK_I_SLICE</td></tr>
</table>
*/
NvU32 profile_idc; /**<Profile IDC, Baseline profile*/
NvU32 level_idc; /**<Level IDC, Level 1.3 */
NvU32 seq_parameter_set_id; /**<Sequence Parameter set ID */
NvU32 log2_max_frame_num_minus_4; /**< Specifies the value of the variable MaxFrameNum, default value is 4*/
NvU32 pic_order_cnt_type; /**<Specifies the method to decode picture order count, default value is 0 */
NvU32 log2_max_pic_order_cnt_lsb_minus_4; /**< only available when pic_order_cnt_type is 0 */
NvU32 offset_for_non_ref_pic; /**< only available when pic_order_cnt_type is 1 */
NvU32 offset_for_top_to_bottom_field; /**< only available when pic_order_cnt_type is 1 */
NvU32 num_ref_frames_in_pic_order_cnt_cycle; /**< only available when pic_order_cnt_type is 1 */
NvU32 *poffset_for_ref_frame; /**<only available when pic_order_cnt_type is 1 */
NvU32 num_ref_frames; /**<Number of reference frames */
PGFRMSURFACE *pSurfaces; /**< List of the surfaces of the reference frames */
NvU32 pic_width; /**< Picture Width in pixel*/
NvU32 pic_height; /**< Picture Height in pixel*/
PGFRMSURFACE pSrcSurf; /**< Surface to be encoded. If the source image is from a camera, set this field to NULL.*/
PGFRECT pSrcRect; /**<Source image area to encode*/
float fFrameRate; /**<Frame rate per second. This is the real input frame rate. For example, if encoding image is from camera, fFrameRate should be the camera frame rate. Not the encoded bit stream's frame rate.*/
NvU32 uiMaxBitRate; /**<Kbits/second*/
NvU32 uiBufferSize; /**<Size in DWORDs. This buffer is created and managed by the application to temporarily hold the encoded bitstream before transferring the bitstream out.*/
NvU32 uiTimeIncResolution; /**<Time increment resolution */
}GFMXENCH264SETSEQUENCE, *PGFMXENCH264SETSEQUENCE;
/** @name GFMxEncH264 API Setsequence::SequenceInfo */
//@{
/**GFMXENCH264SETSEQUENCE::SequenceInfo :The encoded bitstream is compliant to constraint set0 .*/
#define GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET0_FLAG 0x00000001
/**GFMXENCH264SETSEQUENCE::SequenceInfo :The encoded bitstream is compliant to constraint set1 .*/
#define GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET1_FLAG 0x00000002
/**GFMXENCH264SETSEQUENCE::SequenceInfo :The encoded bitstream is compliant to constraint set2 .*/
#define GF_MXENC_H264_SEQUENCE_CONSTRAINT_SET2_FLAG 0x00000004
/**GFMXENCH264SETSEQUENCE::SequenceInfo :Equal to 1 specifies that delta_pic_order_cnt[0] and delta_pic_order_cnt[1] are not present in the slice header and shall be inferred to zero .*/
#define GF_MXENC_H264_SEQUENCE_DELTA_PIC_ORDER_ALWAYS_ZERO_FLAG 0x00000008
/**GFMXENCH264SETSEQUENCE::SequenceInfo :Equal to 1 specifies that every coded picture of the video sequence is a coded frame containing only frame macroblocks .*/
#define GF_MXENC_H264_SEQUENCE_FRMAE_MBS_ONLY_FLAG 0x00000010
/**GFMXENCH264SETSEQUENCE::SequenceInfo :When set, it enables sequence rate control .*/
#define GF_MXENC_H264_SEQUENCE_RATE_CONTROL_ENABLE 0x00000020
/**GFMXENCH264SETSEQUENCE::SequenceInfo : Enable intra Macro Block refreshing. This mode could run automatically, without any APPs interaction. APPs could change the macroblocks, counter range by calling GFMxEncH264SetPicture if desired.*/
#define GF_MXENC_H264_SEQUENCE_AUTO_IMRF_ENABLE 0x00000040
/**GFMXENCH264SETSEQUENCE::SequenceInfo : Enable intra macro block refreshing with customized counter matrix from APP, When this flag is on, Apps must call GFMxEnc264SetPicture to setup intra macro block, refresh counter matrix .*/
#define GF_MXENC_H264_SEQUENCE_MC_IMRF_ENABLE 0x00000080
/**GFMXENCH264SETSEQUENCE::SequenceInfo : Inform firmware for realtime encode.*/
#define GF_MXENC_H264_SEQUENCE_REALTIME_ENCODE 0x00000100
/**GFMXENCH264SETSEQUENCE::SequenceInfo : Turn off/on deblocking for I-frames, since I frames inherently have large cyclecount, and adding deblocking may cause a frameskip .*/
#define GF_MXENC_H264_SEQUENCE_DEBLK_I_SLICE 0x00000200
//@}
/** typedef struct GFMXENCH264SETPICTURE_TAG */
typedef struct GFMXENCH264SETPICTURE_TAG
{
NvU32 PictureInfo; /**<Picture characteristics */
/**<
<table>
<tr><td>#GF_MXENC_H264_PICTURE_CHANGE_INIT_QP</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_REDUCE_FRAME_RATE</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_ENCODE_IDR_ASAP </td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_CHANGE_MIN_MAX_QP</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_LOAD_IMRF_MATRIX </td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_4MV_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_HALF_PEL_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_DEBLK_FILTER_ENABLE</td></tr>
<tr><td>#GF_MXENC_H264_PICTURE_MULTI_SLICE_ENABLE</td></tr>
</table>
*/
NvU32 numofSlicesGroup; /**< Number of slice groups, default value = 0 */
NvU32 sliceGroupMapType; /**< default value is 0 , interleaved slice groups */
NvU32 num_of_ref_idx_10_active; /**< Specifies the maximum reference index for reference picture list 0 ,default value is 0 */
NvU32 num_of_ref_idx_11_active; /**< Default value is 0 */
NvS32 pic_init_qp; /**< Initial value of the slice QP*/
NvS32 pic_init_qs; /**< Initial value of the slice QS */
NvS32 chroma_qp_index_offset; /**< Specifies the offset that shall be added to QPY and QSY for addressing the table of QPC values. The value of chroma_qp_index_offset shall be in the range of -12 to +12, inclusive. */
NvU32 uiMaxIDRQP; /**< Max QP value for IDR */
NvU32 uiMinIDRQP; /**< Min QP value for IDR */
NvU32 uiMaxNONIDRQP; /**< Max QP value for non-IDR picture */
NvU32 uiMinNONIDRQP; /**< Min QP value for non-IDR picture */
NvU32 SliceAlpha; /**< Aplha value for Deblocking */
NvU32 SliceBeta; /**< Beta value for Deblocking */
/**< Packetisation for H264*/
NvU32 uiPacketCtrlDisable; /**< Disables the packet mode control */
NvU32 uiPacketMode; /**< If 1 ,then in macroblock mode else in bytes mode, bytes mode not supported */
NvU32 uiPacketSize; /**< Packet size in MBs or bytes, packet size in bytes is not supported, Value can range from zero to the number of MBs in a frame */
NvU32 uiNumofPicBetween2IDRs; /**< Number of P frames in between consecutive I Frames */
NvU32 uiRNumerator; /**< Desired Framerate value. This field must be filled if flag GF_MXENC_H264_PICTURE_REDUCE_FRAME_RATE is on. */
NvU32 uiRDenominator; /**< Camera Framerate. This field must be filled if flag F_MXENC_H264_PICTURE_REDUCE_FRAME_RATE is on. */
NvU32 uiIMRFIMinValue; /**< Those values will take effect only when GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever an I frame is encoded, MxEncH264 will generate a random number in this range for each macroblock */
NvU32 uiIMRFIMaxValue; /**< Those values will take effect only when GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever an I frame is encoded, MxEncH264 will generate a random number in this range for each macroblock. */
NvU32 uiIMRFPMinValue; /**< Those values will take effect only when GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever a Macro Block counter is reduced to 0, an Intra Macro Block will be generated by MxEncH264. MxEncH264 will generate a random number in this range for this macroblock. */
NvU32 uiIMRFPMaxValue; /**< Those values will take effect only when GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever a Macro Block counter is reduced to 0, an Intra Macro Block will be generated by MxEncH264. MxEncH264 will generate a random number in this range for this macroblock. */
NvU32 uiIMRFDefaultCounter; /**< This value will be used as the new counter when the refresh counter in the matrix is decreased to 0. */
NvU8 *pIMRFMatrix; /**< Pointer to an array that holds counter for each Macro Block. When this counter is decreased to 0, one Intra Macro Block will be inserted.*/
} GFMXENCH264SETPICTURE, *PGFMXENCH264SETPICTURE;
/** @name GFMxEncH264 API Setpicture::PictureInfo */
//@{
/**GFMXENCH264SETPICTURE::PictureInfo: When application enables this flag, application must set pic_init_qp, pic_init_qs and chroma_qp_index_offset.*/
#define GF_MXENC_H264_PICTURE_CHANGE_INIT_QP 0x00000001
/**GFMXENCH264SETPICTURE::PictureInfo:Reduce the frame rate by skipping certain frames, Must set uiRNumerator and uiRDenominator.*/
#define GF_MXENC_H264_PICTURE_REDUCE_FRAME_RATE 0x00000002
/**GFMXENCH264SETPICTURE::PictureInfo: Encode IDR as soon as possible .*/
#define GF_MXENC_H264_PICTURE_ENCODE_IDR_ASAP 0x00000004
/**GFMXENCH264SETPICTURE::PictureInfo:When application set this flag, application must set uiMaxIDRQP, uiMinIDRQP, uiMaxNONIDRQP and uiMinNONIDRQP .*/
#define GF_MXENC_H264_PICTURE_CHANGE_MIN_MAX_QP 0x00000008
/**GFMXENCH264SETPICTURE::PictureInfo:Application changes the counter range by setting this, flag and giving the range in uiIMRFIMinValue uiIMRFIMaxValue, uiIMRFPMinValue, and uiIMRFPMaxValue, Applications can turn on this flag only when GF_MXENC_H264_SEQUENCE_AUTO_IMRF_ENABLE is on.*/
#define GF_MXENC_H264_PICTURE_LOAD_IMRF_COUNTER_RANGE 0x00000010
/**GFMXENCH264SETPICTURE::PictureInfo: Application must fill in uiIMRFDefaultCounter and pIMRFMatrix if this flag is on, Application can turn on flag only if GF_MXENC_H264_PICTURE_MC_IMRF_ENABLE is on .*/
#define GF_MXENC_H264_PICTURE_LOAD_IMRF_MATRIX 0x00000020
/**GFMXENCH264SETPICTURE::PictureInfo: Enable 4 motion vectors, GFMxEncH264 will pick 1 MV or 4 MV, depends on which mode is more efficient.*/
#define GF_MXENC_H264_PICTURE_4MV_ENABLE 0x00000040
/**GFMXENCH264SETPICTURE::PictureInfo: Enable half pel motion estimation search.*/
#define GF_MXENC_H264_PICTURE_HALF_PEL_ENABLE 0x00000080
/**GFMXENCH264SETPICTURE::PictureInfo: Enable Deblocking.*/
#define GF_MXENC_H264_PICTURE_DEBLK_FILTER_ENABLE 0x00000100
/**GFMXENCH264SETPICTURE::PictureInfo: Enable Multi Slicing. Mutli-slicing is not supported*/
#define GF_MXENC_H264_PICTURE_MULTI_SLICE_ENABLE 0x00000200
//@}
/** typedef struct GFMXENCH264RCC_TAG */
typedef struct GFMXENCH264RCC_TAG
{
NvU16 uiIQP; /**<Regular QP value for I*/
NvU16 uiMinIQP; /**<Minimum QP value for I*/
NvU16 uiMaxIQP; /**<Maximum QP value for I*/
NvU16 uiMinISize; /**<Minimum I picture size in DWORD*/
NvU16 uiMaxISize; /**<Maximum I picture size in DWORD*/
NvU16 uiSuggestedISize; /**<Suggested I picture size in DWORD*/
NvU16 uiPQP; /**<Regular QP value for P*/
NvU16 uiMinPQP; /**<Minimum QP value for P*/
NvU16 uiMaxPQP; /**<Maximum QP value for P*/
NvU16 uiMinPSize; /**<Minimum P picture size in DWORD*/
NvU16 uiMaxPSize; /**<Maximum P picture size in DWORD*/
NvU16 uiSuggestedPSize; /**<Suggested P picture size in DWORD*/
NvU16 uiUnderFlowThr; /**<Underflow threshold in DWORD*/
NvU16 uiOverFlowThr; /**<Overflow threshold in DWORD*/
NvU16 uiSkipVOPThr; /**<Skip VOP if the buffer over this threshold*/
}GFMXENCH264RCC, *PGFMXENCH264RCC;
/**typedef struct GFMXENCH264FEEDIMAGE_TAG*/
typedef struct GFMXENCH264FEEDIMAGE_TAG
{
NvU32 uiTime; /**< Frame time in milliseconds, First picture may start from 0. */
PGFRMSURFACE pImgSurf; /**< Image to be encoded, GFMxEncH264FeedImage can support the GF_SURFACE_YUV420, GF_SURFACE_YUYV, GF_SURFACE_YVYU, GF_SURFACE_UYVY, and GF_SURFACE_VYUY formats. */
}GFMXENCH264FEEDIMAGE, *PGFMXENCH264FEEDIMAGE;
/**typedef struct GFMXENCH264FETCHNALS_TAG*/
typedef struct GFMXENCH264FETCHNALS_TAG
{
//Filled by Application
void *pBuf; /**< GFMxEncH264API fills this buffer with H264 encoded bitstream, must be 32 bit aligned */
NvU32 uiSizeofBuf; /**< Size of pBuf */
NvU16 *pNALsLengthBuf; /**< NAL unit length in bytes. If encoder application wants know each NAL unit's size, this field should be set. If this field is NULL, the GFMxEncAPI does not output any NAL unit size information */
NvU32 uiTimeOut; /**< In milliseconds. If 0, return immediately if there is no NAL unit ready. If -1, wait until NAL unit is ready*/
//Filled in by the GFMxEncH264API
NvU32 uiNALsInfo; /**< Information on NAL unit returned by GFMxEncH264FetchNALs() function. */
/**<
<table>
<tr><td>#GF_MXENC_H264_NALS_SEQUENCE_PARAMETER_SET</td></tr>
<tr><td>#GF_MXENC_H264_NALS_PICTURE_PARAMETER_SET</td></tr>
<tr><td>#GF_MXENC_H264_NALS_IDR_PIC </td></tr>
<tr><td>#GF_MXENC_H264_NALS_NON_IDR_PIC</td></tr>
<tr><td>#GF_MXENC_H264_NALS_BEGIN_ACCESS_UNIT</td></tr>
<tr><td>#GF_MXENC_H264_NALS_PARTIAL_ACCESS_UNIT</td></tr>
<tr><td>#GF_MXENC_H264_NALS_END_ACCESS_UNIT</td></tr>
<tr><td>#GF_MXENC_H264_NALS_DATA_NOT_READY</td></tr>
<tr><td>#GF_MXENC_H264_NALS_MORE_FETCH</td></tr>
<tr><td>#GF_MXENC_H264_NALS_MORE_NALS</td></tr>
</table>
*/
NvU32 uiTime; /**< In milliseconds, the encoded picture's time stamp. First picture may start from 0. */
NvU32 uiFetchedSize; /**< Number of available bytes */
}GFMXENCH264FETCHNALS, *PGFMXENCH264FETCHNALS;
/** @name GFMXENCH264FETCHNALS::uiNALsInfo definitions */
//@{
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current NAL unit is a Sequence Parameter Set. */
#define GF_MXENC_H264_NALS_SEQUENCE_PARAMETER_SET 0x00000001
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current NAL unit is a Picture Parameter Set. */
#define GF_MXENC_H264_NALS_PICTURE_PARAMETER_SET 0x00000002
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current NAL unit belongs to an IDR Pic. */
#define GF_MXENC_H264_NALS_IDR_PIC 0x00000004
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current NAL unit belongs to a Non-IDR Pic. */
#define GF_MXENC_H264_NALS_NON_IDR_PIC 0x00000008
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current data is the start of a new Access Unit. */
#define GF_MXENC_H264_NALS_BEGIN_ACCESS_UNIT 0x00000010
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current data is a Partial Access Unit. */
#define GF_MXENC_H264_NALS_PARTIAL_ACCESS_UNIT 0x00000020
/**GFMXENCH264FETCHNALS::uiNALsInfo:Current data is the End of the Access Unit. */
#define GF_MXENC_H264_NALS_END_ACCESS_UNIT 0x00000040
/**GFMXENCH264FETCHNALS::uiNALsInfo:Data of current NAL is not ready yet.*/
#define GF_MXENC_H264_NALS_DATA_NOT_READY 0x00000080
/**GFMXENCH264FETCHNALS::uiNALsInfo: Present NAL unit is larger than application's buffer size. Call FetchNALs again to get remaining data.*/
#define GF_MXENC_H264_NALS_MORE_FETCH 0x00000100
/** GFMXENCH264FETCHNALS::uiNALsInfo: More NALs are encoded and ready to be fetched by the application. */
#define GF_MXENC_H264_NALS_MORE_NALS 0x00000200
//@}
/** @name GFMxEncH264SetAttribute Definitions */
//@{
/**GFMxEncH264SetAttribute_Definitions::MXENC_H264_ATTR_ROTATION:
GF4800 and subsequent generation of GPUs have rotator block which can rotate
video frame before encoding. In a normal mode a Encoder doesn't need to
capture whole video frame before encoding but in rotation mode, it needs to
capture full video frame (YUV4:2:0) before encoding. This means rotation
mode requires more memory.
This option can be used to enable rotation with 4 basic modes which can be
ORed with two h-flip and v-flip options.
Total of 8 unique combination of rotation modes are available.
*pInfo rotation degree used with MXENC_ATTR_ROTATION
*/
#define MXENC_H264_ATTR_ROTATION 1
#define MXENC_H264_ATTR_ROTATE_0 0x0 /**< No rotation */
#define MXENC_H264_ATTR_ROTATE_90 0x1 /**< Rotate by 90 degree */
#define MXENC_H264_ATTR_ROTATE_180 0x2 /**< Rotate by 180 degree */
#define MXENC_H264_ATTR_ROTATE_270 0x3 /**< Rotate by 270 degree */
#define MXENC_H264_ATTR_H_FLIP 0x10 /**< Flip horizontally */
#define MXENC_H264_ATTR_V_FLIP 0x20 /**< Flip vertically */
/**GFMxEncH264SetAttribute_Definitions:MXENC_H264_INTRAREFRESH_MODE
This option allows you to change the INTRA REFRESH mode while encoding is in progress.
With this option, the application can switch/Turn ON MXENC_H264_INTRAREFRESH_AUTO or
MXENC_H264_INTRAREFRESH_MC. After switching to MXENC_H264_INTRAREFRESH_MC mode, the application
has to call GFMxEncH264SetPicture() with pPicture:pIMRFMatrix specifying the Intra Refresh pattern
*/
#define MXENC_H264_INTRAREFRESH_MODE 2
#define MXENC_H264_INTRAREFRESH_AUTO 0x1 /**< Set Intrarefresh pattern in Auto mode */
#define MXENC_H264_INTRAREFRESH_MC 0x2 /**< Set Intrarefresh pattern in Motion Compensated mode */
//@}
/** typedef enum GFMX_ENC_H264_INTERRUPT_OPERATION_TYPE : Set Interrupt Operation to perform */
typedef enum
{
GFMX_ENC_H264_INTERRUPT_ENABLE, /**< Enable Interrupt */
GFMX_ENC_H264_INTERRUPT_DISABLE, /**< Disable Interrupt */
GFMX_ENC_H264_INTERRUPT_CLEAR /**< Clear Interrupt */
} GFMX_ENC_H264_INTERRUPT_OPERATION_TYPE; // Interrupt operation.
/** typedef enum GFMX_ENC_H264_INTERRUPT_TYPE : Interrupt type*/
typedef enum
{
GFMX_ENC_H264_FRAME_ENCODE_DONE_INTR /**< Frame Encode Done Interrupt */
} GFMX_ENC_H264_INTERRUPT_TYPE;
#ifdef __cplusplus
extern "C" { // only need to export C interface if
// used by C++ source code
#endif
/** MxEncH264API virtual function pointer table.
These functions serve as the entry point to the MxEncH264API from the application.
*/
typedef struct _GFMXEncH264TABLE
{
GF_RETTYPE (* MxEncH264GetProperty)(GFMxEncH264Handle hMxEncH264, PGFPROPERTY pMXProp );
/**< This function returns a variety of information, including the version of the
GFMxEncH264API encoder module. It is a good practice to call this function to query
for the GFMxEncH264API version and its capabilities before using the rest of the
GFMxEncH264API functions.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pMXProp (PGFPROPERTY) Pointer to GFPROPERTY.
MxEncH264API property flag below.
MxEncH264API property flag:
<table>
<tr><td>#GF_MXENC_H264_CAP_BASELINE</td></tr>
<tr><td>#GF_MXENC_H264_CAP_MAIN</td></tr>
<tr><td>#GF_MXENC_H264_CAP_EXTENDED</td></tr>
<tr><td>#GF_MXENC_H264_CAP_HIGH10</td></tr>
<tr><td>#GF_MXENC_H264_CAP_HIGH422</td></tr>
<tr><td>#GF_MXENC_H264_CAP_HIGH444</td></tr>
<tr><td>#GF_MXENC_H264_CAP_LEVEL_IDC</td></tr>
<tr><td>#GF_MXENC_H264_CAP_DATA_PARTITIONING </td></tr>
<tr><td>#GF_MXENC_H264_CAP_RATE_CONTROL</td></tr>
<tr><td>#GF_MXENC_H264_CAP_IMRF</td></tr>
<tr><td>#GF_MXENC_H264_CAP_ROTATION</td></tr>
</table>
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
It is a good practice to call this function to query for the API version
and its capabilities before using the rest of the MxEncH264API functions.
*/
GF_RETTYPE (* MxEncH264GetStatus)(GFMxEncH264Handle hMxEncH264, NvU32 * pStatus);
/**< This function returns the hardware encoder<65>s status.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pStatus (NvU32 * ) Status returned by the encoder. @see GFMxEncH264GetStatus Definitions.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264SetSequence)(GFMxEncH264Handle hMxEncH264, PGFMXENCH264SETSEQUENCE pSequence);
/**< This function sets the characteristics of a new H264 video sequence and
tells the GFMxEncH264API the sequence information. The GFMxEncH264API does not
generate a sequence bit stream. The application needs to prepare a sequence by itself.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pSequence (PGFMXENCH264SETSEQUENCE ) Set new sequence information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264SetPicture)(GFMxEncH264Handle hMxEncH264, PGFMXENCH264SETPICTURE pPicture);
/**< This function sets the characteristics of a new picture. This
function should be called after GFMxEncH264SetSequence() and before
GFMxEncH264Start(). If the application decides to change any picture information
during the encoding time (after GFMxEncH264Start()), the application can call
this function to pass the new picture information to the GFMxEncH264API.
Otherwise, the application should not call this function, allowing the
GFMxEncH264API to reduce overhead.
@paramhMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pPicture (PGFMXENCH264SETPICTURE ) Set new picture information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264RateControlConfig)(GFMxEncH264Handle hMxEncH264, PGFMXENCH264RCC pRCC);
/**< This function initializes the GFMxEncH264API rate control block. This function is
optional for application because the GFMxEncH264API automatically initializes
the rate control block.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pRCC (PGFMXENCH264RCC ) Set rate control information..
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264FeedImage)(GFMxEncH264Handle hMxEncH264,
PGFMXENCH264FEEDIMAGE pFeedImage);
/**< The application can call this function if the application has the source image to feed to the encoder.
This function should not be called if the image comes directly from the video
input port (VIP), for example, from a camera.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pStatus (PGFMXENCH264FEEDIMAGE ) New image information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264FetchNALs)(GFMxEncH264Handle hMxEncH264,
PGFMXENCH264FETCHNALS pFetchNALs);
/**< An application should call this function to fetch the encoded NAL bit stream
or encoded raw data. If the source image is from the host, the application
should call this function after GFMxEnch264FeedImage(). If the source image is
from a video camera connected to the VIP and the application is using a
polling scheme, the application should call this function at least at the
camera<72>s frame rate.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param pFetchNALs (PGFMXENCH264FETCHNALS ) Structure to hold encoded NAL information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264Start)(GFMxEncH264Handle hMxEncH264);
/**< This function starts the GFMxEncH264API module for encoding the bit stream.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264Pause)(GFMxEncH264Handle hMxEncH264);
/**< This function pauses the encoding process until GFMxEnch264Pause() is called
again to Resume encoding, or GFMxEncH264Stop() is called to totally stop encoding.
@param hMxEnc (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264Stop)(GFMxEncH264Handle hMxEncH264);
/**< This function stops the encoding process.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264SetupInterrupt)(GFMxEncH264Handle hMxEncH264,
void (*Inter)(void *), void * IPara);
/**< An application can use this function to set up the interrupt callback function.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param (*Inter)(void *) (void) Pointer to encoder application<6F>s interrupt callback function.
@param IPara (void *) Pointer to parameter of encoder application<6F>s interrupt callback function.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
*/
GF_RETTYPE (* MxEncH264SetAttribute)(GFMxEncH264Handle hMxEncH264, NvU32 uiFeature, NvU32* pInfo);
/**< This function sets a feature of the H264 encoder.
@param hMxEncH264 (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param uiFeature (NvU32) @see GFMxEncH264SetAttribute Definitions
@param pInfo (NvU32*) Pointer to the information buffer.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncH264API_Error_Codes
GFMxEncH264SetAttribute_Definitions:
<table>
<tr><td>#MXENC_H264_ATTR_ROTATION</td></tr>
<tr><td>#MXENC_H264_INTRAREFRESH_MODE</td></tr>
</table>
*/
GF_RETTYPE (* MxEncH264GetAttribute)(GFMxEncH264Handle hMxEncH264, NvU32 uiFeature, NvU32* pInfo);
/**< This function gets a feature of the H264 encoder.
@param hMxEnc (GFMxEncH264Handle) Handle specific to the GFMxEncH264API.
@param uiFeature (NvU32) see GFMxEncH264GetAttribute_Definitions below.
@param pInfo (NvU32*) Pointer to the information buffer.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
}GFMXENCH264TABLE, *PGFMXENCH264TABLE;
// Typesafe functions for opening and closing this component
GF_RETTYPE GFMxEncH264Open(GFRmHandle hRm, GFMxEncH264Handle *phMxEncH264,
GF_STATE_TYPE state, GFRmChHandle hCh);
/**< Typesafe function for opening the H264 Encoder component.
@param hRm (GFRmHandle) RM Handle got from GFRmOpen.
@param phMxEncH264 (GFMxEncH264Handle *) Handle specific to the GFMxEncH264API is returned in this.
@param state (GF_STATE_TYPE) .
@param hCh (GFRmChHandle) Channel handle
*/
void GFMxEncH264Close(GFMxEncH264Handle *phMxEncH264);
/**< Typesafe function for closing the H264 Encoder component.
@param phMxEncH264 (GFMxEncH264Handle *) Pointer to handle specific to H264 encoder component.
*/
/** @name GFMxEncH264GetStatus Definitions */
//@{
#define GF_ENCODER_BUSY 0x00000001 /**< Encoder is busy */
#define GF_ENCODER_VOP_READY 0x00000002 /**< At least one VOP is ready for fetching */
//@}
/** @name GFMxEncH264API Helper Macros. */
//@{
#define GFMxEncH264GetProperty(hMxEncH264, pMXProp) \
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264GetProperty(hMxEncH264, pMXProp)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264GetProperty
*/
#define GFMxEncH264GetStatus(hMxEncH264, pStatus) \
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264GetStatus(hMxEncH264, pStatus)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264GetStatus
*/
#define GFMxEncH264SetSequence(hMxEncH264, pSequence) \
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264SetSequence(hMxEncH264, pSequence)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264SetSequence
*/
#define GFMxEncH264SetPicture(hMxEncH264, pPicture)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264SetPicture(hMxEncH264, pPicture)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264SetPicture
*/
#define GFMxEncH264RateControlConfig(hMxEncH264, pRCC)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264RateControlConfig(hMxEncH264, pRCC)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264RateControlConfig
*/
#define GFMxEncH264FeedImage(hMxEncH264, pFeedImage)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264FeedImage(hMxEncH264, pFeedImage)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264FeedImage
*/
#define GFMxEncH264FetchNALs(hMxEncH264, pFetchNALs)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264FetchNALs(hMxEncH264, pFetchNALs)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264FetchNALs
*/
#define GFMxEncH264Start(hMxEncH264)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264Start(hMxEncH264)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264Start
*/
#define GFMxEncH264Pause(hMxEncH264)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264Pause(hMxEncH264)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264Pause
*/
#define GFMxEncH264Stop(hMxEncH264)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264Stop(hMxEncH264)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264Stop
*/
#define GFMxEncH264SetupInterrupt(hMxEncH264, Inter,IPara)\
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264SetupInterrupt(hMxEncH264, Inter,IPara)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264SetupInterrupt
*/
#define GFMxEncH264SetAttribute(hMxEncH264, uiFeature, pInfo) \
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264SetAttribute(hMxEncH264, uiFeature, pInfo)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264SetAttribute
*/
#define GFMxEncH264GetAttribute(hMxEncH264, uiFeature, pInfo) \
((PGFMXENCH264TABLE)hMxEncH264)->MxEncH264GetAttribute(hMxEncH264, uiFeature, pInfo)
/**< Helper macro for GFMxEncH264API.
@see GFMXENCH264TABLE::MxEncH264GetAttribute
*/
//@}
/** @name GFMxEncH264API_Error_Codes
*/
//@{
/** GFMXEH264_SUCCESS*/
#define GFMXEH264_SUCCESS GF_SUCCESS
/** GGFMXEH264_ERROR_NOT_SUPPORT_FORMAT*/
#define GFMXEH264_ERROR_NOT_SUPPORT_FORMAT (GFMXEH264_ERROR | 0x00000001)
/** GFMXEH264_ERROR_INVALID_PARAMETER*/
#define GFMXEH264_ERROR_INVALID_PARAMETER (GFMXEH264_ERROR | 0x00000002)
/** GFMXEH264_ERROR_NOT_ENOUGH_EMBEDDED_MEM*/
#define GFMXEH264_ERROR_NOT_ENOUGH_EMBEDDED_MEM (GFMXEH264_ERROR | 0x00000003)
//@}
/*@}*/
/** @page pageMxEncH264AppNotes MxEncH264API Application Notes
@section pageMxEncH264AppNotes1 Programming Sequence
The following procedure requires that GFRmOpen() is called first to start GFSDK usage. The description is for a typical case
where encoding of video being captured from a camera is done and preview shown on the display.
1. Initialize the display panel by using GFRmIxInit().\n
2. Open the display component by calling GFDxOpen() to get the GFMxDecAPI Dxhandle.\n
3. Initialize the display start address, stride and bits per pixel using GFDxSetDisplay().\n
4. Get the various attributes of the display panel (width, height, etc) using GFDxGetAttribute().\n
5. For clearing the screen, open the graphics component using GFGxOpen() and use GFGxFillRect() for filling the screen with
some color (say, green).\n
6. Open the Vx component using GFVxOpen() and get the GFVxAPI VxHandle. \n
7. Setup the camera. \n
8. Initialize VIP. \n
9. Obtain the handle specific to H264 encoder by calling GFMxEncH264Open(). \n
10. Call GFMxEncH264GetProperty() to query properties. Check whether this version can support the desired H264 profile and level. \n
11. If supported, call GFRmSurfaceAlloc() to allocate one surface for encoding purposes. \n
12. Call GFMxEncH264SetAttribute() if specific features need to be set. \n
13. Call GFMxEncH264SetSequence() for configuring the characteristics of a new H264 video sequence. \n
14. Call GFMxEncH264SetPicture() for setting the characteristics of a new picture. \n
15. If the current source image is from the CPU, the application should call GFMxEncH264FeedImage() to feed the
image to the GFMxEncH264API. If the current source image is coming from the VIP (for example. camera input), the
application should skip the GFMxEncH264FeedImage() call.
16. If the application uses an interrupt scheme, it must implement a callback function and set it up using GFMxEncH264SetupInterrupt.
Inside of the callback function, the application should call GFMxEncH264FetchNALs() to retrieve the encoded NALs. \n
17. Start the encoding by calling GFMxEncH264Start(). \n
18. The application should periodically call the callback function to get the data from the encoder. \n
19. The encoder can be paused by calling GFMxEncH264Pause() and can be resumed by calling GFMxEncH264Pause() again. \n
20. Before exiting, call GFMxEncH264Stop() to stop the encoder. \n
21. Call the callback function after waiting for some time to get the data for the last frame encoded. \n
22. Free all relevent resources and call GFMxEncH264Close() to free the H264 encoder component. \n
*/
#ifdef __cplusplus
} // only need to export C interface if
// used by C++ source code
#endif
#endif //#ifndef _GF_MPEG_ENC_H264__