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

796 lines
37 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 GFMxEnc.h
GFSDK MPEG 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__
#define _GF_MPEG_ENC__
#include "GFVx.h"
#include "GFDef.h"
/** @addtogroup groupMxEnc GFMxEncAPI MPEG4 Encode API
<ul>
<li> @ref pageMxEncAppNotes
<ul>
<li> @ref pageMxEncAppNotes1
</ul>
</ul>
*/
/*@{*/
/** MxEncAPI property flag: Support Simple Profile.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_SIMPLE 0x00000001 //Support Simple Profile
/** MxEncAPI property flag: Support Simple Scale Profile.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_SCALE 0x00000002 //Support Simple Scale Profile
/** MxEncAPI property flag: Support CORE Profile.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_CORE 0x00000004 //Support CORE Profile
/** MxEncAPI property flag: Support MAIN Profile.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_MAIN 0x00000008 //Support MAIN Profile
/** MxEncAPI property flag: Support N_bit profile.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_N_BIT 0x00000010 //Support N_bit Profile
/** MxEncAPI property flag: Support LEVEL 1.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_LEVEL1 0x00000100 //Support LEVEL 1
/** MxEncAPI property flag: Support LEVEL 2.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_LEVEL2 0x00000200 //Support LEVEL 2
/** MxEncAPI property flag: Support LEVEL 3.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_LEVEL3 0x00000400 //Support LEVEL 3
/** MxEncAPI property flag: Support LEVEL 4.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_LEVEL4 0x00000800 //Support LEVEL 4
/** MxEncAPI property flag: Support Data Partitioning Mode.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_DATA_PARTITIONING 0x00001000 //Support Data Partitioning Mode
/** MxEncAPI property flag: Support RVLC Mode.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_RVLC 0x00002000 //Support RVLC Mode
/** MxEncAPI property flag: Support Rate Control.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_RATE_CONTROL 0x00004000
//support rate control
/** MxEncAPI property flag: Support Intra MacroBlock Refreshing.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_IMRF 0x000008000 //Support Intra Macroblock Refreshing
/** MxEncAPI property flag: Support Rotation.
@see GFMxEncGetProperty(), GFPROPERTY::Capability
*/
#define GF_MXENC_CAP_ROTATION 0x000010000 //Support Rotation
/** GFMxEncSetVOL parameter struct. */
typedef struct _GFMXENCVOL
{
NvU32 uiVOLInfo; /**< VOL characteristics */
/**<
<table>
<tr><td>#GF_MXENC_VOL_SHORT_VIDEO_HEADER</td></tr>
<tr><td>#GF_MXENC_VOL_BYPASS_VLC</td></tr>
<tr><td>#GF_MXENC_VOL_RESYNC_MARK_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_DATA_PARTITION_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_REVERSIBLE_VLC_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_RATE_CONTROL_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_STUFFING_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_AUTO_IMRF_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_MC_IMRF_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOL_THUMBNAIL_ENABLE</td></tr>
</table>
*/
PGFRMSURFACE pSrcSurf;/**< Surface to encode*/
PGFRECT pSrcRect; /**<Source image area to encode*/
NvU16 VOPWidth; /**< Width in pixel*/
NvU16 VOPHeight; /**<Height in pixel*/
float fFrameRate; /**<FrameRate per second*/
NvU16 uiMaxBitRate; /**<Kbits/second*/
NvU32 uiBufferSize; /**<Size in DWORDs.This buffer size is used by the Rate Control Algorithm .*/
NvU32 uiTimeIncResolution; /**<For Non-SVH(Short Video Header) mode only*/
PGFRMSURFACE pEncSurf;/**< Reference Surface for encoder*/
PGFRMSURFACE pThumbnailSurface;/**< Surface to store the thumbnail of first encoded frame*/
}GFMXENCVOL, *PGFMXENCVOL;
//uiVOLInfo:
/**GFMXENCVOL::uiVOLInfo : GFMxEncAPI should generate Short Video Header(SVH) format VOP.If this flag is off, GFMxEncAPI should generate Non-SVH(Non Short Video Header) format VOP.*/
#define GF_MXENC_VOL_SHORT_VIDEO_HEADER 0x00000001
/**GFMXENCVOL::uiVOLInfo : GFMxEncAPI should output raw data, bypass VLC.If this flag is off, GFMxEnc should output VLC bit stream*/
#define GF_MXENC_VOL_BYPASS_VLC 0x00000002
/**GFMXENCVOL::uiVOLInfo : Enable Resync Marker*/
#define GF_MXENC_VOL_RESYNC_MARK_ENABLE 0x00000004
/**GFMXENCVOL::uiVOLInfo : Enable Data Partition*/
#define GF_MXENC_VOL_DATA_PARTITION_ENABLE 0x00000008
/**GFMXENCVOL::uiVOLInfo : Enable Reversible VLC Mode*/
#define GF_MXENC_VOL_REVERSIBLE_VLC_ENABLE 0x00000010
/**GFMXENCVOL::uiVOLInfo:Enable Rate Control Algorithm*/
#define GF_MXENC_VOL_RATE_CONTROL_ENABLE 0x00000020
/**GFMXENCVOL::uiVOLInfo:Stuff more bits to prevent buffer under flow*/
#define GF_MXENC_VOL_STUFFING_ENABLE (0x00000040|GF_MXENC_VOL_RATE_CONTROL_ENABLE)
/**GFMXENCVOL::uiVOLInfo : Enable Intra Macroblock Refreshing. This mode could run automatically without application's interaction. Application could change the macroblock's counter range by calling GFMxEncSetVOP if desired */
#define GF_MXENC_VOL_AUTO_IMRF_ENABLE 0x00000080
/**GFMXENCVOL::uiVOLInfo : Enable Intra Macroblock Refreshing with customized counter matrix from application.
When this flag is on, Application must call GFMxEncSetVOP to setup Intra Macroblock Refresh counter matrix. */
#define GF_MXENC_VOL_MC_IMRF_ENABLE 0x00000100
/**GFMXENCVOL::uiVOLInfo : Enable First Frame Thumbnail.It stores the thumbnail of first encoded frame in the surface given by Application.
Height and width of thumbnail is equal to height and width of surface provided.
Thumbnail can be encoded after GFMxEncStart function call*/
#define GF_MXENC_VOL_THUMBNAIL_ENABLE 0x00000200
/** GFMxEncSetVOP parameter struct. */
typedef struct _GFMXENCVOP
{
NvU32 uiVOPInfo; /**<VOP characteristics bitmask
<table>
<tr><td>#GF_MXENC_VOP_4MV_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOP_HALF_PEL_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOP_PACKET_BASED_ON_MB_NUM</td></tr>
<tr><td>#GF_MXENC_VOP_AC_PRE_ALWAYS_ON</td></tr>
<tr><td>#GF_MXENC_VOP_AC_PRE_DYNAMICALLY_ON</td></tr>
<tr><td>#GF_MXENC_VOP_CHANGE_EXPECTED_SIZE</td></tr>
<tr><td>#GF_MXENC_VOP_CHANGE_INITQP</td></tr>
<tr><td>#GF_MXENC_VOP_CHANGE_MIN_MAX_QP</td></tr>
<tr><td>#GF_MXENC_VOP_4MV_ENABLE</td></tr>
<tr><td>#GF_MXENC_VOP_REDUCE_FRAME_RATE</td></tr>
<tr><td>#GF_MXENC_VOP_ENCODE_I_ASAP</td></tr>
<tr><td>#GF_MXENC_VOP_IMRF_CONTROL_IP_RATIO</td></tr>
<tr><td>#GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE</td></tr>
<tr><td>#GF_MXENC_VOP_LOAD_IMRF_MATRIX</td></tr>
<tr><td>#GF_MXENC_VOP_TIMESTAMP_CPU</td></tr>
<tr><td>#GF_MXENC_VOP_TIMESTAMP_VI</td></tr>
<tr><td>#GF_MXENC_VOP_CHANGE_MAX_QP_RELIEF</td></tr>
</table>
*/
NvU16 uiPacketSize; /**< If GF_MXENC_VOP_PACKET_BASED_ON_MB_NUM flag is on, this field tells the number of macroblocks in a packet. Otherwise, this field tells number of bytes in a packet.*/
NvU16 uiIntra_DC_VLC_Thr; /**< Intra DC VLC Threshold*/
NvU16 uiHECNum; /**< Frequency to inset HEC marker. 0 means no HEC marker at all. 1~7 means to insert HEC after 1~7 resync marker(s).*/
NvU16 uiExpectedISize; /**< If next encoded VOP is I, this field tells GFMxEncAPI the size of bit stream which application expects in number of DWORD.*/
NvU16 uiExpectedPSize; /**< If next encoded VOP is P, this field tells GFMxEnc the size of bit stream which application expects in number of DWORD.*/
NvU16 uiInitialIQP; /**< Initial QP value for I VOP*/
NvU16 uiInitialPQP; /**< Initial QP value for P VOP */
NvU16 uiMaxIQP; /**< Max QP value for I VOP*/
NvU16 uiMinIQP; /**< Min QP value for I VOP */
NvU16 uiMaxPQP; /**< Max QP value for P VOP*/
NvU16 uiMinPQP; /**< Min QP value for P VOP */
NvU16 uiMaxQPRelief; /**< Max qp Relief*/
NvU16 uiNumofP; /**< Number of consecutive P VOPs between two I VOPs.*/
NvU16 uiRNumerator; /**< Desired Framerate value. This field must be filled if flag GF_MXENC_VOP_REDUCE_FRAME_RATE is on.*/
NvU16 uiRDenominator; /**< Camera Framerate. This field must be filled if flag GF_MXENC_VOP_REDUCE_FRAME_RATE is on.*/
NvU8 uiIMRFIMinValue; /**< Those values will take effect only when GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever an I VOP is encoded, MxEnc will generate a random number in this range for each macroblock.*/
NvU8 uiIMRFIMaxValue; /**< Those values will take effect only when GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever an I VOP is encoded, MxEnc will generate a random number in this range for each macroblock.*/
NvU8 uiIMRFPMinValue; /**< Those values will take effect only when GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever a Macro Block counter is reduced to 0, an Intra Macro Block will be generated by MxEnc. MxEnc will generate a random number in this range for this macroblock.*/
NvU8 uiIMRFPMaxValue; /**< Those values will take effect only when GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE flag is set. Whenever a Macro Block counter is reduced to 0, an Intra Macro Block will be generated by MxEnc. MxEnc will generate a random number in this range for this macroblock.*/
NvU8 uiIMRFDefaultCounter; /**< This value will be used as the new counter when the refresh counter in the matrix is decreased to 0.*/
NvU8* pMIRFMatrix; /**< 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.*/
NvU32 uiTimeStampModel; /**< Time Stamp Model (VI or CPU).
<table>
<tr><td>#GF_MXENC_VOP_TIMESTAMP_CPU</td></tr>
<tr><td>#GF_MXENC_VOP_TIMESTAMP_VI</td></tr>
</table>
*/
}GFMXENCVOP, *PGFMXENCVOP;
//uiVOPInfo:
/**GFMXENCVOP::uiVOPInfo: Enable 4 motion vectors, GFMxEnc will pick 1 MV or 4 MV, depends on which mode is more efficient.*/
#define GF_MXENC_VOP_4MV_ENABLE 0x00000001
/**GFMXENCVOP::uiVOPInfo : Enable Half Pel Motion Estimation search*/
#define GF_MXENC_VOP_HALF_PEL_ENABLE 0x00000002
/**GFMXENCVOP::uiVOPInfo:New packet based on the number of MBs. Not the length of the bit stream*/
#define GF_MXENC_VOP_PACKET_BASED_ON_MB_NUM 0x00000004
/**GFMXENCVOP::uiVOPInfo:AC prediction always on*/
#define GF_MXENC_VOP_AC_PRE_ALWAYS_ON 0x00000008
/**GFMXENCVOP::uiVOPInfo:AC prediction dynamically on*/
#define GF_MXENC_VOP_AC_PRE_DYNAMICALLY_ON 0x00000010
/**GFMXENCVOP::uiVOPInfo : Change the expected size for I and P encoded frames. uiExpectedISize, uiExpectedPSize must be filled*/
#define GF_MXENC_VOP_CHANGE_EXPECTED_SIZE 0x00000020
/**GFMXENCVOP::uiVOPInfo : Change the initial QP for I and P. uiInitialIQP, uiInitialPQP must be filled*/
#define GF_MXENC_VOP_CHANGE_INITQP 0x00000040
/**GFMXENCVOP::uiVOPInfo : Change the Min and Max QP for I and P frames. uiMaxIQP, uiMinIQP, uiMaxPQP, uiMinPQP must be filled*/
#define GF_MXENC_VOP_CHANGE_MIN_MAX_QP 0x00000080
/**GFMXENCVOP::uiVOPInfo : Reduce the frame rate by skipping certain frames. uiRNumerator and uiRDenominator must be set.*/
#define GF_MXENC_VOP_REDUCE_FRAME_RATE 0x00000100
/**GFMXENCVOP::uiVOPInfo : Encode I VOP as soon as possible*/
#define GF_MXENC_VOP_ENCODE_I_ASAP 0x00000200
/**GFMXENCVOP::uiVOPInfo : Number of P VOPs between two I VOPs controlled by intra macro block refreshing. If this flag is off, it is controlled by uiNumofP*/
#define GF_MXENC_VOP_IMRF_CONTROL_IP_RATIO 0x00000400
/**GFMXENCVOP::uiVOPInfo : Application can change the counter range by setting this flag and give the range in uiIMRFIMinValue, uiIMRFIMaxValue, uiIMRFPMinValue and uiIMRFPMaxValue. Application only can turn on this flag when GF_MXENC_VOL_AUTO_IMRF_ENABLE is on.*/
#define GF_MXENC_VOP_LOAD_IMRF_COUNTER_RANGE 0x00000800
/**GFMXENCVOP::uiVOPInfo : Application must fill in uiIMRFDefaultCounter and pIMRFMatrix when this flag is on. Application only can turn on this flag when GF_MXENC_VOL_MC_IMRF_ENABLE flag is on.*/
#define GF_MXENC_VOP_LOAD_IMRF_MATRIX 0x00001000
/**GFMXENCVOP::uiVOPInfo : Timestamp is provided by CPU*/
#define GF_MXENC_VOP_TIMESTAMP_CPU 0x00010000
/**GFMXENCVOP::uiVOPInfo: Timestamp is generated by VI*/
#define GF_MXENC_VOP_TIMESTAMP_VI 0x00020000
/**GFMXENCVOP::uiVOPInfo : Change MAX QP RELIEF value for Rate Control Algorithm*/
#define GF_MXENC_VOP_CHANGE_MAX_QP_RELIEF 0x00100000
/**typedef struct _GFMXENCRCC*/
typedef struct _GFMXENCRCC
{
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 VOP size in DWORD*/
NvU16 uiMaxISize; /**<Maximum I VOP size in DWORD*/
NvU16 uiSuggestedISize; /**<Suggested I VOP 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 VOP size in DWORD*/
NvU16 uiMaxPSize; /**<Maximum P VOP size in DWORD*/
NvU16 uiSuggestedPSize; /**<Suggested P VOP 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*/
}GFMXENCRCC, *PGFMXENCRCC;
/**typedef struct _GFMXENCFEEDIMAGE*/
typedef struct _GFMXENCFEEDIMAGE
{
NvU32 uiTime; /**<Time stamp value in milliseconds, first VOP may start from 0*/
PGFRMSURFACE pImgSurf;/**<Image surface to be encoded. GFMxEncAPI only supports YUV420/UYVY color type for this surface */
}GFMXENCFEEDIMAGE, *PGFMXENCFEEDIMAGE;
#define GF_MXENC_DEFAULT_WAIT 50
#define GF_MXENC_DEFAULT_NOWAIT -1
/**typedef struct _GFMXENCFETCHVOP*/
typedef struct _GFMXENCFETCHVOP
{
//Filled by the Application
void *pBuf;/**< If GF_MXENC_VOL_BYPASS_VLC is set, the data in this buffer is GFMxEnc Compressed Format Bit Stream; otherwise the data in this buffer is MPEG4 compliant bit stream. Please refer to Programming Guidlines for this format.*/
NvU32 uiSizeofBuf; /**<Number of bytes in pBuf*/
NvU16 *pPacketLengthBuf; /**<To hold each packet data */
NvU32 uiSizeofPLB; /**<Size of PacketLengthBuf in number of NvU16s */
NvU32 uiUTContentSize;/**<Un-transferred content size.The size of bit stream that has not been transferred out yet to the application bit stream buffer.
Number of DWORD. Valid only when application enable rate control.
For source image from CPU case,application need set this field based on ideal transfer rate, since application may flush out the whole buffer before feeding and fetching another VOP.
If more than half of uiBufferSize in GFMXENCVOL has not been transferred out, GFMXEnc will start reducing bit rate. If less than half, GFMXEnc will start increasing bit rate.*/
NvU32 uiTimeOut; /**< in milliseconds
-1: do not wait return immediately
else waits for the specified msecs */
//Filled by GFMxEncAPI
NvU32 uiVOPInfo; /**< VOP INFO.
<table>
<tr><td>#MXENC_VOP_P_VOP</td></tr>
<tr><td>#MXENC_VOP_MORE_FETCH</td></tr>
<tr><td>#MXENC_VOP_PORTION_PACKET</td></tr>
<tr><td>#MXENC_VOP_MORE_VOP</td></tr>
<tr><td>#MXENC_VOP_BEGIN_VOP</td></tr>
<tr><td>#MXENC_VOP_END_VOP</td></tr>
<tr><td>#MXENC_VOP_BUFFER_OVERFLOW</td></tr>
</table>
*/
NvU32 uiAverageQP; /**<Average QP for current frame*/
NvU32 uiTime; /**<Encoded VOP's time stamp in milliseconds. First VOP may start from 0*/
NvU32 uiFetchedSize; /**<Number of available bytes in pBuf */
NvU32 uiPLBSize; /**<Number of available NvU16s in pPacketLengthBuf */
}GFMXENCFETCHVOP, *PGFMXENCFETCHVOP;
/**GFMXENCFETCHVOP::uiVOPInfo:The ecncoded frame is P VOP, if this flag is off, this VOP is I VOP*/
#define MXENC_VOP_P_VOP 0x1
/**GFMXENCFETCHVOP::uiVOPInfo : GFMxEncAPI only fed partial VOP data in pBuf. Application need more calling to fetch the rest of data*/
#define MXENC_VOP_MORE_FETCH 0x2
/**GFMXENCFETCHVOP::uiVOPInfo:The last packet in pBuf only contain partial of packet data, the last entry in pPacketLengthBuf is the size of this partial packet data size.Application need more calling to fetch the rest of data*/
#define MXENC_VOP_PORTION_PACKET (0x4 |MXENC_VOP_MORE_FETCH)
/**GFMXENCFETCHVOP::uiVOPInfo : More VOPs are ready in GFMxEncAPI internal buffer. Application need to fetch as soon as possible */
#define MXENC_VOP_MORE_VOP 0x8
/**GFMXENCFETCHVOP::uiVOPInfo : Fetched data is the begining chunk of new encoded VOP*/
#define MXENC_VOP_BEGIN_VOP 0x10
/**GFMXENCFETCHVOP::uiVOPInfo : Fetched data is the last chunk of the encoded VOP*/
#define MXENC_VOP_END_VOP 0x20
/**GFMXENCFETCHVOP::uiVOPInfo : Buffer Overflow flag for high level application*/
#define MXENC_VOP_BUFFER_OVERFLOW 0x40
/** @name GFMxEncSetAttribute_Definitions
*/
//@{
/**GFMxEncSetAttribute_Definitions*/
/**GFMxEncSetAttribute_Definitions::MXENC_ATTR_KEEP_PREV_ENCODING_INTERNAL_RESOURCE:
To avoid fragmentation of memory, use this flag to keep internal memory
allocated.
*pInfo = 1, application wants GFMxEnc to re-use previous encoding process'
internal resources, those resources refers to some internal buffers.
If the attribute is on, the new encoding process need more resources,
GFMxEnc will release previous internal resource and relocate new resources.
If the new encoding process need equal or less resources, GFMxEnc will use
previous' internal resource. If there is no previous encoding process at all,
GFMxEnc will alloc new resources.
*pInfo = 0, Release previous encoding process' internal resource if GFMxEnc has.
Alloc new resources for current encoding process.
Make sure that you allocate memory for big size encoding and
then use this flag to reuse that memory for smaller size.
*/
#define MXENC_ATTR_KEEP_PREV_ENCODING_INTERNAL_RESOURCE 2
/**GFMxEncSetAttribute_Definitions::MXENC_PREVIEW_ROTATE_BUFFER:
GF4800 supports rotation for video encoding. In the rotated mode,
full frame of video has to be captured before encoder can start encoding.
The YUV4:2:0 data in the rotated buffer can be used for previewing also.
This option can be used to enable the preview from these buffers.
In rotated mode, Encoder has to be on, even for preview.
VI auto trigger will not work if VI is not writing to a YUV4:2:2 memory buf.
GF4800 hardware has two issues:
-In order to get video thru rotator, encoder has to be on.
-In order to use auto VI trigger for SB, VI has to get YUV4:2:2 data to
the memory buffer.
To overcome these issues, we have put some work-around in the MxEncAPI.
MxEncPause(): In the rotated mode, app should call this function right
after video input Vsync to avoid tearing in the recording.
*pInfo = 1 to enable preview from the rotated buffers.
*pInfo = 0 to disable this mode (normal mode)
This option can only be used when MXENC_ATTR_ROTATION is set and/or
GFMxEncSetVOL() option GF_MXENC_VOL_PREPARE_ROTATION is set.
*/
#define MXENC_PREVIEW_ROTATE_BUFFER 3
/**GFMxEncSetAttribute_Definitions::MXENC_GET_PREVIEW_BUFFER:
Rotate buffers are allocated by the API in the GPU memory.
Preview is normally done by App using GFVxBlt() to convert an off-screen YUV
surface to an on-screen RGB rectangular area.
MXENC_GET_PREVIEW_BUFFER option is used in GFMxEncGetAttribute() to obtain
the address (GFRmSurface) of the rotated buffers which is allocated by
GFMxEncAPI. These surfaces should be passed to GFVxBlt() to display camera
data. App must not delete these surfaces. These will be freed by GFMxEncAPI.
This option is available in only when MXENC_PREVIEW_ROTATE_BUFFER is on.
*/
#define MXENC_GET_PREVIEW_BUFFER 4
/**GFMxEncSetAttribute_Definitions::MXENC_ENABLE_INTERRUPT_MODE:
Interrupt mode is supported in MxEncAPI, which will enable to generate the interrupt at the end of each frame encode.
The bitstream will be then read from the DMA buffer and written to the host buffer.
MXENC_ENABLE_INTERRUPT_MODE option is used in GFMxEncGetAttribute() to enable
interrupt support by GFMxEncAPI.
*/
#define MXENC_ENABLE_INTERRUPT_MODE 8
#define MXENC_ATTR_TIMESTAMP 12
#define MXENC_ATTR_TIMEINC_FIELD 0x7F
#define MXENC_ATTR_MODULOTIMEBSE_SHIFT 8
#define MXENC_ATTR_MODESWITCH_SHIFT 9
#define MXENC_ATTR_MODESWITCH_FIELD 512
#define MXENC_ATTR_MODULOTIMEBSE_FIELD 256
#define MXENC_ATTR_INTRAREFRESH_MODE 16
/**GFMxEncSetAttribute_Definitions::MXENC_ATTR_ZOOMENABLE:
To enable zoom capability of the GFMxEncAPI driver. This attribute needs to be SET by the client application,
if the application wants to zoom the encoded video. See application notes for more information about programming
zoom in GFMxEncAPI.
*/
#define MXENC_ATTR_ZOOMENABLE 32
/**GFMxEncSetAttribute_Definitions::MXENC_ATTR_ZOOM:
This attribute needs to be set whenever the client application wants to perform 2x, 3x or 4x zoom.
It is mandatory for the client application to call GFMxEncPause() before and after
GFMxEncSetAttribute() is called with MXENC_ATTR_ZOOM option. See application notes for more information about programming
zoom in GFMxEncAPI.
*/
#define MXENC_ATTR_ZOOM 64
#define MXENC_ATTR_INTRAREFRESH_AUTO 1
#define MXENC_ATTR_INTRAREFRESH_MC 2
typedef enum
{
GFMX_ENC_INTERRUPT_ENABLE,
GFMX_ENC_INTERRUPT_DISABLE,
GFMX_ENC_INTERRUPT_CLEAR
} GFMX_ENC_INTERRUPT_OPERATION_TYPE; // Interrupt operation.
typedef enum
{
GFMX_ENC_FRAME_ENCODE_DONE_INTR
} GFMX_ENC_INTERRUPT_TYPE;
#ifdef __cplusplus
extern "C" { // only need to export C interface if
// used by C++ source code
#endif
// Typesafe functions for opening and closing this component
GF_RETTYPE GFMxEncOpen(GFRmHandle hRm, GFMxEncHandle *phMxEnc,
GF_STATE_TYPE state, GFRmChHandle hCh);
void GFMxEncClose(GFMxEncHandle *phMxEnc);
GF_RETTYPE GFMxEncGetProperty(GFMxEncHandle hMxEnc, PGFPROPERTY pMXProp);
/**< This function returns a variety of information, including the version of the
GFMxEncAPI encoder module. It is a good practice to call this function to query
for the GFMxEncAPI version and its capabilities before using the rest of the
GFMxEncAPI functions.
@param MXhandle (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pMXProp (PGFPROPERTY) Pointer to GFPROPERTY.
MxEncAPI property flag below.
MxEncAPI property flag:
<table>
<tr><td>#GF_MXENC_CAP_SIMPLE</td></tr>
<tr><td>#GF_MXENC_CAP_SCALE</td></tr>
<tr><td>#GF_MXENC_CAP_CORE</td></tr>
<tr><td>#GF_MXENC_CAP_MAIN</td></tr>
<tr><td>#GF_MXENC_CAP_N_BIT</td></tr>
<tr><td>#GF_MXENC_CAP_LEVEL1</td></tr>
<tr><td>#GF_MXENC_CAP_LEVEL2</td></tr>
<tr><td>#GF_MXENC_CAP_LEVEL3</td></tr>
<tr><td>#GF_MXENC_CAP_LEVEL4</td></tr>
<tr><td>#GF_MXENC_CAP_DATA_PARTITIONING</td></tr>
<tr><td>#GF_MXENC_CAP_RVLC</td></tr>
<tr><td>#GF_MXENC_CAP_RATE_CONTROL</td></tr>
<tr><td>#GF_MXENC_CAP_IMRF</td></tr>
<tr><td>#GF_MXENC_CAP_ROTATION</td></tr>
</table>
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_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 MxEncAPI functions.
*/
GF_RETTYPE GFMxEncGetStatus(GFMxEncHandle hMxEnc, NvU32 * pStatus);
/**< This function returns the hardware encoder<65>s status.
@param MXhandle (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (NvU32 * ) @see GFMxEncGetStatus Definitions.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
//pStatus
/**GFMxEncGetStatus Definitions : If hardware encoder is busy encoding VOPs*/
#define GF_ENCODER_BUSY 0x00000001
/**GFMxEncGetStatus Definitions : At least one VOP is ready for fetching */
#define GF_ENCODER_VOP_READY 0x00000002
GF_RETTYPE GFMxEncSetVOL(GFMxEncHandle hMxEnc, PGFMXENCVOL pVOL);
/**< This function sets the characteristics of a new video object layer (VOL) and
tells the GFMxEncAPI the VOL information. The GFMxEncAPI does not
generate a VOL bit stream. The application needs to prepare a VOL by itself.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (PGFMXENCVOL ) Set new VOL information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncSetVOP(GFMxEncHandle hMxEnc, PGFMXENCVOP pVOP);
/**< This function sets the characteristics of a new video object plane (VOP). This
function should be called after GFMxEncSetVOL() and before
GFMxEncStart(). If the application decides to change any VOP information
during the encoding time (after GFMxEncStart()), the application can call
this function to pass the new VOP information to the GFMxEncAPI.
Otherwise, the application should not call this function, allowing the
GFMxEncAPI to reduce overhead.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (PGFMXENCVOP ) Set new VOP information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncRateControlConfig(GFMxEncHandle hMxEnc, PGFMXENCRCC pRCC);
/**< This function initializes the GFMxEncAPI rate control block. This function is
optional for application because the GFMxEncAPI automatically initializes
the rate control block.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (PGFMXENCRCC ) Set rate control information..
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncFeedImage(GFMxEncHandle hMxEnc,
PGFMXENCFEEDIMAGE 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 hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (PGFMXENCFEEDIMAGE ) New image information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncFetchImage(GFMxEncHandle hMxEnc,PGFMXENCFETCHVOP pFetchVOP);
/**< An application should call this function to fetch the encoded VOP bit stream
or encoded raw data. If the source image is from the host, the application
should call this function after GFMxEncFeedImage(). 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<EFBFBD>s frame rate.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param pStatus (PGFMXENCFETCHVOP ) Structure to hold encoded VOP information.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncStart(GFMxEncHandle hMxEnc);
/**< This function starts the GFMxEncAPI module for encoding the bit stream.
The GFMxEncAPI assumes the first VOP it outputs is the first VOP in the
current VOL.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncPause(GFMxEncHandle hMxEnc);
/**< This function pauses the encoding process until GFMxEncPause() is called
again to Resume encoding, or GFMxEncStop() is called to totally stop encoding.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncStop(GFMxEncHandle hMxEnc);
/**< This function stops the encoding process.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncSetupInterrupt(GFMxEncHandle hMxEnc,void (*Inter)(void *), void * IPara);
/**< An application can use this function to set up the interrupt callback function.
This function must be called before GFMxEncStart().
If this function returns GF_SUCCESS, whenever a VOP is ready the
GFMxEncAPI calls the interrupt callback function. Inside of the callback
function, the application can call GFMxEncSetVOP() if it is needed, and call
GFMxEncFetchImage() to fetch the encoded VOP.
If GF_ERROR is returned, the application should use a polling scheme.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@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 GFMxEncAPI_Error_Codes
*/
GF_RETTYPE GFMxEncSetAttribute(GFMxEncHandle hMxEnc, NvU32 uiFeature, NvU32* pInfo);
/**< This function sets a feature of the MPEG encoder hardware.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param uiFeature (NvU32) @see GFMxEncSetAttribute Definitions
@param pInfo (NvU32*) Pointer to the information buffer.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
GFMxEncSetAttribute_Definitions:
<table>
<tr><td>#MXENC_ATTR_KEEP_PREV_ENCODING_INTERNAL_RESOURCE</td></tr>
<tr><td>#MXENC_PREVIEW_ROTATE_BUFFER</td></tr>
<tr><td>#MXENC_GET_PREVIEW_BUFFER</td></tr>
<tr><td>#MXENC_ENABLE_INTERRUPT_MODE</td></tr>
</table>
MXENC_ENABLE_INTERRUPT_MODE MXENC_GET_PREVIEW_BUFFER MXENC_PREVIEW_ROTATE_BUFFER MXENC_ATTR_KEEP_PREV_ENCODING_INTERNAL_RESOURCE
*/
GF_RETTYPE GFMxEncGetAttribute(GFMxEncHandle hMxEnc, NvU32 uiFeature, NvU32* pInfo);
/**< This function gets a feature of the MPEG encoder hardware..
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@param uiFeature (NvU32) see GFMxEncGetAttribute_Definitions below.
@param pInfo (NvU32*) Pointer to the information buffer.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
GFMxEncGetAttribute_Definitions:
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
<table>
<tr><td>#MXENC_ATTR_ROTATION</td></tr>
<tr><td>#MXENC_ATTR_ROTATE_0</td></tr>
<tr><td>#MXENC_ATTR_ROTATE_90</td></tr>
<tr><td>#MXENC_ATTR_ROTATE_180</td></tr>
<tr><td>#MXENC_ATTR_ROTATE_270</td></tr>
<tr><td>#MXENC_ATTR_H_FLIP</td></tr>
<tr><td>#MXENC_ATTR_V_FLIP</td></tr>
</table>
*/
/** @name GFMxEncGetAttribute_Definitions
*/
//@{
/**GFMxEncGetAttribute_Definitions:
*/
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_ROTATION*/
#define MXENC_ATTR_ROTATION 1
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_ROTATE_0*/
#define MXENC_ATTR_ROTATE_0 0x0
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_ROTATE_90*/
#define MXENC_ATTR_ROTATE_90 0x1
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_ROTATE_180*/
#define MXENC_ATTR_ROTATE_180 0x2
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_ROTATE_270*/
#define MXENC_ATTR_ROTATE_270 0x3
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_H_FLIP*/
#define MXENC_ATTR_H_FLIP 0x10
/**GFMxEncGetAttribute_Definitions::MXENC_ATTR_V_FLIP*/
#define MXENC_ATTR_V_FLIP 0x20
//@}
GF_RETTYPE GFMxEncInterruptControl(GFMxEncHandle MxHandle);
/**< This function enables the MxEnc interrupt.
@param hMxEnc (GFMxEncHandle) Handle specific to the GFMxEncAPI.
@retval GF_SUCCESS : If successful.
@retval GF_ERROR : If error.
@see GFMxEncAPI_Error_Codes
*/
/** @name GFMxEncAPI_Error_Codes
*/
//@{
/** GFMXE_SUCCESS*/
#define GFMXE_SUCCESS GF_SUCCESS
/** GFMXE_ERROR_NOT_SUPPORT_FORMAT */
#define GFMXE_ERROR_NOT_SUPPORT_FORMAT (GFMXE_ERROR | 0x00000001)
/** GFMXE_ERROR_INVALID_PARAMETER */
#define GFMXE_ERROR_INVALID_PARAMETER (GFMXE_ERROR | 0x00000002)
/** GFMXE_ERROR_NOT_ENOUGH_EMBEDDED_MEM */
#define GFMXE_ERROR_NOT_ENOUGH_EMBEDDED_MEM (GFMXE_ERROR | 0x00000003)
/** GFMXE_ERROR_SET_ATTRIBUTE_FAILED */
#define GFMXE_ERROR_SET_ATTRIBUTE_FAILED (GFMXE_ERROR | 0x00000004)
//@}
/*@}*/
/** @page pageMxEncAppNotes MxEncAPI Application Notes
@section pageMxEncAppNotes1 Programming Sequence
Todo
*/
#ifdef __cplusplus
} // only need to export C interface if
// used by C++ source code
#endif
#endif //#ifndef _GF_MPEG_ENC__