DVSDK码率控制的理解

来源:互联网 发布:macair windows 编辑:程序博客网 时间:2024/05/24 01:59

1.动态参数和静态参数:

创建编码器的时候,有params和dynParams两种参数,顾名思义,Venc根据params创建,运行过程中又可以对dynParams改变配置

Venc1_Handle Venc1_create(Engine_Handle hEngine, Char *codecName,

                          VIDENC1_Params *params,

                          VIDENC1_DynamicParams *dynParams)

typedef struct IVIDENC1_Params {
    XDAS_Int32 size;            /**< @sizeField */
    XDAS_Int32 encodingPreset;  /**< Encoding preset. */
    XDAS_Int32 rateControlPreset;/**< @copydoc IVIDEO_RateControlPreset
                                 *
                                 *   @sa IVIDEO_RateControlPreset
                                 */
    XDAS_Int32 maxHeight;       /**< Maximum height. */
    XDAS_Int32 maxWidth;        /**< Maximum width. */
    XDAS_Int32 maxFrameRate;    /**< Maximum frame rate in fps * 1000.
                                 *   For example, if max frame rate is 30
                                 *   frames per second, set this field
                                 *   to 30000.
                                 */
    XDAS_Int32 maxBitRate;      /**< Maximum bit rate, bits per second. */
    XDAS_Int32 dataEndianness;  /**< Endianness of output data.
                                 *
                                 *   @sa    XDM_DataFormat
                                 */
    XDAS_Int32 maxInterFrameInterval;/**< I to P frame distance. e.g. = 1 if
                                 *   no B frames, 2 to insert one B frame.
                                 *
                                 *   @remarks   This is used for setting the
                                 *              maximum number of B frames
                                 *              between two refererence frames.
                                 */
    XDAS_Int32 inputChromaFormat;/**< Chroma format for the input buffer.
                                 *
                                 *   @sa XDM_ChromaFormat
                                 */
    XDAS_Int32 inputContentType;/**< Video content type of the buffer being
                                 *   encoded.
                                 *
                                 *   @sa IVIDEO_ContentType
                                 */
    XDAS_Int32 reconChromaFormat;/**< Chroma formats for the reconstruction
                                 *   buffers.
                                 *
                                 *   @remarks   The application should set
                                 *              this to #XDM_CHROMA_NA
                                 *              if reconstruction
                                 *              buffers are not
                                 *              required.
                                 *
                                 *   @sa XDM_ChromaFormat
                                 */
} IVIDENC1_Params;typedef struct IVIDENC1_DynamicParams {
    XDAS_Int32 size;            /**< @sizeField */
    XDAS_Int32 inputHeight;     /**< Input frame height. */
    XDAS_Int32 inputWidth;      /**< Input frame width. */
    XDAS_Int32 refFrameRate;    /**< Reference, or input, frame rate in
                                 *   fps * 1000.
                                 *
                                 *   @remarks   For example, if ref frame
                                 *              rate is 30 frames per second,
                                 *              this field will be 30000.
                                 */
    XDAS_Int32 targetFrameRate; /**< Target frame rate in
                                 *   fps * 1000.
                                 *
                                 *   @remarks   For example, if target frame
                                 *              rate is 30 frames per second,
                                 *              this field will be 30000.
                                 */
    XDAS_Int32 targetBitRate;   /**< Target bit rate in bits per second. */
    XDAS_Int32 intraFrameInterval;/**< The number of frames between two I
                                 *    frames.  For example, 30.
                                 *
                                 *    @remarks  For example, this field will be:
                                 *      - 0 - Only first frame to be intra
                                 *        coded.  e.g. IPPPPPP...
                                 *      - 1 - No inter frames (all intra
                                 *        frames).
                                 *      - 2 - Consecutive IPIPIP... sequence (if
                                 *        no B frames).
                                 *      - 3 - IPPIPP... or IPBIPBI... and so on.
                                 */
    XDAS_Int32 generateHeader;  /**< @copydoc XDM_EncMode
                                 *
                                 *   @sa XDM_EncMode
                                 */
    XDAS_Int32 captureWidth;    /**< DEFAULT(0): use imagewidth as
                                 *   pitch else use given capture
                                 *   width for pitch provided it
                                 *   is greater than image width.
                                 */
    XDAS_Int32 forceFrame;      /**< Force the current (immediate) frame to be
                                 *   encoded as a specific frame type.
                                 *
                                 *   @remarks   For example, this field will be:
                                 *     - IVIDEO_NA_FRAME - No forcing of any
                                 *       specific frame type for the frame.
                                 *     - IVIDEO_I_FRAME - Force the frame to be
                                 *       encoded as I frame.
                                 *     - IVIDEO_IDR_FRAME - Force the frame to
                                 *       be encoded as an IDR frame (specific
                                 *       to H.264 codecs).
                                 *     - IVIDEO_P_FRAME - Force the frame to be
                                 *       encoded as a P frame.
                                 *     - IVIDEO_B_FRAME - Force the frame to be
                                 *       encoded as a B frame.
                                 *
                                 *   @sa IVIDEO_FrameType.
                                 */
    XDAS_Int32 interFrameInterval;/**< Number of B frames between two reference
                                 *   frames; that is, the number of B frames
                                 *   between two P frames or I/P frames.
                                 *   DEFAULT(0).
                                 *
                                 *   @remarks   For example, this field will be:
                                 *     - 0 - to use maxInterFrameInterval.
                                 *     - 1 - 0 B frames between two reference
                                 *       frames.
                                 *     - 2 - 1 B frame between two reference
                                 *       frames.
                                 *     - 3 - 2 B frames between two reference
                                 *       frames.
                                 *     - and so on...
                                 *
                                 *   @sa IVIDENC1_Params.maxInterFrameInterval.
                                 */
    XDAS_Int32 mbDataFlag;      /**< Flag to indicate that the algorithm should
                                 *   use MB data supplied in additional buffer
                                 *   within inBufs.
                                 */
} IVIDENC1_DynamicParams;

2.重要参数

若要进行码率和帧率控制,首先静态参数中,rateControlPreset是非常重要的一个参数,可选项有以下五种,其中CBR和VBR是我们要进行选择的,若不需要对码率帧率控制可直接选择NONE。

CBR编码时,在配置为较低比特率的时候,帧率也会随之下降,若采用VBR编码,可以始终保持较高的帧率,因为CBR是很定比特率编码,而VBR是根据图片复杂度优化。较少的变化采用较少的bit,复杂的地方采用较多的bit。因此码率较高的时候,CBR速度快,码率低的时候VBR较能改变图片质量。

IVIDEO_LOW_DELAY = 1,   /**< CBR rate control for video conferencing. */
    IVIDEO_STORAGE = 2,     /**< VBR rate control for local storage (DVD)
                             *   recording.
                             */
    IVIDEO_TWOPASS = 3,     /**< Two pass rate control for non real time
                             *   applications.
                             */
    IVIDEO_NONE = 4,        /**< No configurable video rate control
                              *  mechanism.
                              */
    IVIDEO_USER_DEFINED = 5,/**< User defined configuration using extended
                             *   parameters.

在动态参数中,有两个值是同一个意思,可能是为了兼容性考虑,targetFrameRate是DM6467要配置的,refFrameRate虽然可以置之不理,但是当两个值设置为一致时,配置才不会报错, 

XDAS_Int32 refFrameRate;    /**< Reference, or input, frame rate in
                                 *   fps * 1000.
                                 *
                                 *   @remarks   For example, if ref frame
                                 *              rate is 30 frames per second,
                                 *              this field will be 30000.
                                 */
    XDAS_Int32 targetFrameRate; /**< Target frame rate in
                                 *   fps * 1000.
                                 *
                                 *   @remarks   For example, if target frame
                                 *              rate is 30 frames per second,
                                 *              this field will be 30000.
                                 */


0 0
原创粉丝点击