VVenC_0">VVenC
VVenC(Fraunhofer Versatile Video Encoder)是由德国弗劳恩霍夫海因里希研究所(Fraunhofer Heinrich Hertz Institute, HHI)开发的一个开源的高效视频编码器。它实现了最新的视频编码标准——Versatile Video Coding (VVC),也被称为H.266。VVC是高效视频编码(HEVC,即H.265)的后继者,其目标是在相同视觉质量下将比特率降低50%。
VVenC的主要特点包括:
- 高效编码:VVenC提供了快速且高效的编码实现,能够在较低的比特率下实现较高的视频质量。
- 感知优化:基于XPSNR视觉模型的感知优化,以提高主观视频质量。
- 并行化支持:支持广泛的帧级和任务级并行化,具有良好的扩展性。
- 速率控制:支持帧级的单遍和双遍速率控制,支持可变比特率(VBR)编码。
- 易用性:提供了五种预定义的质量/速度配置文件,以满足不同应用场景的需求。
VVenC的开发旨在提供一个公开可用、快速且有效的VVC编码器实现,适用于各种实际应用场景。它在处理高分辨率视频(如4K和8K)时表现出色,能够有效降低文件大小,同时保持良好的压缩效果。
VVenC_13">VVenC源码结构
VVenC__16">VVenC 接口函数
vvenc.h
- VVENC_DECL vvencYUVBuffer* vvenc_YUVBuffer_alloc( void ):用于分配一个 vvencYUVBuffer 类型的实例;该函数只分配 vvencYUVBuffer 结构本身,而不分配用于存储图像数据的内存(payload)。所以需要使用另一个函数 vvenc_YUVBuffer_alloc_buffer 来单独分配存储图像数据的内存。
- VVENC_DECL void vvenc_YUVBuffer_free(vvencYUVBuffer *yuvBuffer, bool freePicBuffer ):用于释放 vvencYUVBuffer 类型实例的内存;如果 freePicBuffer 参数被设置为 true,则函数不仅会释放 vvencYUVBuffer 结构本身的内存,还会释放与之关联的图像数据(payload)内存。如果 freePicBuffer 参数被设置为 false,则函数只会释放 vvencYUVBuffer 结构本身的内存,而不会释放与之关联的图像数据内存。
- VVENC_DECL void vvenc_YUVBuffer_default(vvencYUVBuffer *yuvBuffer ):该函数将传入的 vvencYUVBuffer 结构体的所有成员变量设置为默认值。
- VVENC_DECL void vvenc_YUVBuffer_alloc_buffer( vvencYUVBuffer *yuvBuffer, const vvencChromaFormat chFmt, const int frameWidth, const int frameHeight ):该函数为 vvencYUVBuffer 实例分配存储图像数据的内存缓冲区;当不再需要 payload 缓冲区时,应使用 vvenc_YUVBuffer_free_buffer 函数来释放分配的内存。在调用 vvenc_YUVBuffer_alloc_buffer 之前,确保 yuvBuffer 指向的是一个有效的 vvencYUVBuffer 实例,并且该实例已经通过 vvenc_YUVBuffer_alloc 或 vvenc_YUVBuffer_default 进行了初始化。这个函数只负责分配 payload 缓冲区的内存,不负责释放 vvencYUVBuffer 结构体本身的内存。
- VVENC_DECL void vvenc_YUVBuffer_free_buffer( vvencYUVBuffer *yuvBuffer ):这个函数用于释放 vvencYUVBuffer 实例中的 payload 缓冲区所占用的存储空间;在调用 vvenc_YUVBuffer_free_buffer 之前,确保 yuvBuffer 指向的是一个有效的 vvencYUVBuffer 实例,并且该实例的 payload 缓冲区已经被分配。释放 payload 缓冲区后,yuvBuffer 实例将不再包含指向有效图像数据的指针,因此不应再访问这些数据。这个函数只负责释放 payload 缓冲区的内存,不负责释放 vvencYUVBuffer 结构体本身的内存。如果需要释放整个 vvencYUVBuffer 实例,应该使用 vvenc_YUVBuffer_free 函数,并根据需要设置 freePicBuffer 参数。
- VVENC_DECL vvencAccessUnit* vvenc_accessUnit_alloc( void ):该函数用于分配一个 vvencAccessUnit 实例,并将其初始化为默认值;该函数只分配 vvencAccessUnit 结构体本身,而不分配用于存储实际数据的 payload 内存。需要使用另一个函数 vvenc_accessUnit_alloc_payload 来单独分配 payload 内存。当不再需要 vvencAccessUnit 实例时,应使用 vvenc_accessUnit_free 函数来释放分配的内存。
- VVENC_DECL void vvenc_accessUnit_free(vvencAccessUnit *accessUnit, bool freePayload ):该函数用于释放 vvencAccessUnit 实例的内存;如果 freePayload 参数为 true,则函数会释放 accessUnit 实例的 payload 内存(如果尚未释放)。无论 freePayload 的值如何,函数都会释放 accessUnit 实例本身所占用的内存。
- VVENC_DECL void vvenc_accessUnit_alloc_payload(vvencAccessUnit *accessUnit, int payload_size ):这个函数用于为 vvencAccessUnit 实例分配 payload 内存。当不再需要 payload 内存时,可以使用 vvenc_accessUnit_free_payload 函数来单独释放 payload 内存。当 vvencAccessUnit 实例的内存被释放时(例如通过 vvenc_accessUnit_free 函数),payload 内存也会被自动释放。
- VVENC_DECL void vvenc_accessUnit_free_payload(vvencAccessUnit *accessUnit ):释放vvencAccessUnit 实例中 payload 内存
- VVENC_DECL void vvenc_accessUnit_reset(vvencAccessUnit *accessUnit ):该函数将 accessUnit 结构体的所有成员变量(除了 payload 数据)设置为默认值。
- VVENC_DECL void vvenc_accessUnit_default(vvencAccessUnit *accessUnit ):该函数将 accessUnit 结构体的所有成员变量,包括 payload 数据,设置为默认值。
- VVENC_DECL const char* vvenc_get_version( void ):该方法返回编码器版本号作为一个字符串。
- VVENC_DECL vvencEncoder* vvenc_encoder_create( void ):该方法创建 vvenc 编码器实例;创建后,编码器实例需要进一步配置和初始化才能使用
- VVENC_DECL int vvenc_encoder_open( vvencEncoder*, vvenc_config* ): 该方法初始化编码器实例;在创建编码器实例后,通常需要调用此函数来设置编码器的参数,如编码格式、分辨率、码率等。
- VVENC_DECL int vvenc_encoder_close(vvencEncoder *):该方法重置编码器实例,在编码任务完成后,或者在需要重置编码器状态以进行新的编码任务时,可以使用此函数。释放编码器占用的内存资源,确保系统资源的有效管理。
- typedef void (vvencRecYUVBufferCallback)(void, vvencYUVBuffer* ):回调函数,接受一个已经编码图像的重建 YUV 数据
- VVENC_DECL int vvenc_encoder_set_RecYUVBufferCallback(vvencEncoder *, void * ctx, vvencRecYUVBufferCallback callback ):该方法设置回调获取重建 YUV 内存
- VVENC_DECL int vvenc_init_pass( vvencEncoder *, int pass, const char * statsFName ):这个函数用于根据编码器的编码阶段(pass)来初始化编码器实例。
- VVENC_DECL int vvenc_encode( vvencEncoder , vvencYUVBuffer YUVBuffer, vvencAccessUnit* accessUnit, bool* encodeDone ):该方法编码一个图像,并将压缩后的比特流返回到指定的 vvencAccessUnit 结构体中。
- VVENC_DECL int vvenc_get_config( vvencEncoder *,vvenc_config * ):该方法抓取当前编码器配置,如果编码器没有初始化,该方法失败。
- VVENC_DECL int vvenc_reconfig( vvencEncoder *, const vvenc_config * ):该方法重新配置编码器实例,该方法用于在编码器编码过程中动态更改编码器参数;提供了一种灵活的方式来适应编码环境的变化,而无需重新初始化整个编码器。
- VVENC_DECL int vvenc_check_config( vvencEncoder *, const vvenc_config * ):该函数对传入的 vvenc_config 结构体中的参数进行一致性检查和有效性验证;如果编码器未初始化,则函数将失败。
- VVENC_DECL int vvenc_get_headers(vvencEncoder *, vvencAccessUnit * ):该方法返回使用的头信息(SPS、PPS 等),填充到 accessUnit 结构体中。这些头部信息是编码过程中必须的,用于解码器正确解析和解码视频数据。
- VVENC_DECL const char* vvenc_get_last_error( vvencEncoder * ):该方法返回最近出现的 error 作为字符串。
- VVENC_DECL const char* vvenc_get_enc_information( vvencEncoder * ):该方法返回编码器信息作为字符串。
- VVENC_DECL int vvenc_get_num_lead_frames( vvencEncoder * ):该函数用于获取编码器需要的前导帧数量,通常用于运动补偿时间滤波(MCTF)等处理。
- VVENC_DECL int vvenc_get_num_trail_frames( vvencEncoder * ):该函数用于获取编码器需要的尾随帧数量,通常用于运动补偿时间滤波(MCTF)等处理。
- VVENC_DECL int vvenc_print_summary( vvencEncoder * ):该方法打印编码器运行的总结信息。
- VVENC_DECL const char* vvenc_get_error_msg( int nRet ):该函数用于根据传入的错误代码返回相应的错误消息字符串。
- VVENC_DECL int vvenc_set_logging_callback( void * ctx, vvencLoggingCallback callback ):已废弃,这个函数用于注册一个全局的日志消息回调函数到编码器库中。
- VVENC_DECL const char* vvenc_get_compile_info_string( void ):该函数用于生成一个包含编译信息的字符串,包括操作系统、编译器和位深度(例如32位或64位)。
- VVENC_DECL const char* vvenc_set_SIMD_extension( const char* simdId ):该函数用于设置编码器使用的 SIMD(单指令多数据)扩展,并返回当前使用的 SIMD 扩展。
- VVENC_DECL int vvenc_get_width_of_component( const vvencChromaFormat chFmt, const int frameWidth, const int compId ):用于获取视频帧中特定色度格式(Chroma Format)下某个分量(component)的宽度。
- VVENC_DECL int vvenc_get_height_of_component( const vvencChromaFormat chFmt, const int frameHeight, const int compId ):用于获取视频帧中特定色度格式(Chroma Format)下某个分量(component)的高度。
- VVENC_DECL bool vvenc_is_tracing_enabled( void ):该函数用于检查编码器库是否支持跟踪功能(tracing)。跟踪功能通常用于调试和性能分析,可以帮助开发者了解编码器的内部行为和性能表现。
- VVENC_DECL int vvenc_decode_bitstream( const char* FileName, const char* trcFile, const char* trcRule):废弃,用于解码比特流文件。
- 源码:
/* vvenc_YUVBuffer_alloc:Allocates an vvencYUVBuffer instance.The returned vvencYUVBuffer is set to default values.The payload memory must be allocated seperately by using vvenc_YUVBuffer_alloc_buffer.To free the memory use vvenc_YUVBuffer_free.
*/
VVENC_DECL vvencYUVBuffer* vvenc_YUVBuffer_alloc( void );/* vvenc_YUVBuffer_free:release storage of an vvencYUVBuffer instance.The payload memory is also released if the flag freePicBuffer is set.
*/
VVENC_DECL void vvenc_YUVBuffer_free(vvencYUVBuffer *yuvBuffer, bool freePicBuffer );/* vvenc_YUVBuffer_default:Initialize vvencYUVBuffer structure to default values
*/
VVENC_DECL void vvenc_YUVBuffer_default(vvencYUVBuffer *yuvBuffer );/* vvenc_YUVBuffer_alloc_buffer:Allocates the payload buffer of a vvencYUVBuffer instance.To free the buffer memory use vvenc_YUVBuffer_free_buffer.
*/
VVENC_DECL void vvenc_YUVBuffer_alloc_buffer( vvencYUVBuffer *yuvBuffer, const vvencChromaFormat chFmt, const int frameWidth, const int frameHeight );/* vvenc_YUVBuffer_free_buffer:release storage of the payload in a vvencYUVBuffer instance.
*/
VVENC_DECL void vvenc_YUVBuffer_free_buffer( vvencYUVBuffer *yuvBuffer );// ----------------------------------------/* vvenc_accessUnit_alloc:Allocates a vvencAccessUnit instance.The returned accessUnit is set to default values.The payload memory must be allocated seperately by using vvenc_accessUnit_alloc_payload.To free the memory use vvenc_accessUnit_free.
*/
VVENC_DECL vvencAccessUnit* vvenc_accessUnit_alloc( void );/* vvenc_accessUnit_free:release storage of a vvencAccessUnit instance.The payload memory is also released if not done yet.
*/
VVENC_DECL void vvenc_accessUnit_free(vvencAccessUnit *accessUnit, bool freePayload );/* vvenc_accessUnit_alloc_payload:Allocates the memory for a vvencAccessUnit payload.To free the memory use vvenc_accessUnit_free_payload.When the vvencAccessUnit memory is released the payload memory is also released.
*/
VVENC_DECL void vvenc_accessUnit_alloc_payload(vvencAccessUnit *accessUnit, int payload_size );/* vvenc_accessUnit_free_payload:release storage of the payload in a vvencAccessUnit instance.
*/
VVENC_DECL void vvenc_accessUnit_free_payload(vvencAccessUnit *accessUnit );/* vvenc_accessUnit_reset:resets vvencAccessUnit structure to its default values. payload data will not be reset.
*/
VVENC_DECL void vvenc_accessUnit_reset(vvencAccessUnit *accessUnit );/* vvenc_accessUnit_default:Initialize vvencAccessUnit structure to default values (including au payload)
*/
VVENC_DECL void vvenc_accessUnit_default(vvencAccessUnit *accessUnit );/*This method returns the encoder version number as a string.\param None\retval std::string returns the version number
*/
VVENC_DECL const char* vvenc_get_version( void );/* vvenc_encoder_createThis method creates a vvenc encoder instance.\param[in] none.\retval vvencEncoder pointer of the encoder handler if successful, otherwise NULL\pre The encoder must not be initialized (pointer of decoder handler must be null).
*/
VVENC_DECL vvencEncoder* vvenc_encoder_create( void );/* vvenc_encoder_openThis method initializes the encoder instance.This method is used to initially set up the encoder with the assigned encoder parameter struct.The method fails if the encoder is already initialized or if the assigned parameter structdoes not pass the consistency check. Other possibilities for an unsuccessful call are missing encoder license, or a machine withinsufficient CPU capabilities.\param[in] vvencEncoder pointer to opaque handler.\param[in] vvenc_config* pointer to vvenc_config struct that holds initial encoder parameters.\retval int if non-zero an error occurred (see ErrorCodes), otherwise the return value indicates success VVENC_OK\pre The encoder must not be initialized.
*/
VVENC_DECL int vvenc_encoder_open( vvencEncoder*, vvenc_config* );/* vvenc_encoder_closeThis method resets the encoder instance.This method clears the encoder and releases all internally allocated memory.Calling uninit cancels all pending encoding calls. In order to finish pending input pictures use the flush method.\param[in] vvencEncoder pointer to opaque handler.\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre None
*/
VVENC_DECL int vvenc_encoder_close(vvencEncoder *);/* vvencRecYUVBufferCallback:callback function to receive reconstructed yuv data of an encoded picture
*/
typedef void (*vvencRecYUVBufferCallback)(void*, vvencYUVBuffer* );/* vvenc_encoder_set_RecYUVBufferCallbackThis method sets the callback to get the reconstructed YUV buffer.\param[in] vvencEncoder pointer to opaque handler\param[in] ctx pointer of the caller, if not needed set it to null\param[in] implementation of the callback\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre None
*/
VVENC_DECL int vvenc_encoder_set_RecYUVBufferCallback(vvencEncoder *, void * ctx, vvencRecYUVBufferCallback callback );/* vvenc_init_passThis method initializes the encoder instance in dependency to the encoder pass.\param[in] vvencEncoder pointer to opaque handler\param[in] pass number of current pass to init (0: first pass, 1: second pass )\param[in] rate control statistics file name\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre None
*/
VVENC_DECL int vvenc_init_pass( vvencEncoder *, int pass, const char * statsFName );/* vvenc_encodeThis method encodes a picture.Uncompressed input pictures are passed to the encoder in display order. A compressed bitstream chunk is returned by filling the assigned AccessUnit struct.Data in AcccessUnit struct is valid if the encoder call returns success and the UsedSize attribute is non-zero.If the input parameter YUVBuffer is NULL, the encoder just returns a pending bitstream chunk if available.If the call returns VVENC_NOT_ENOUGH_MEM, the payloadSize attribute in AccessUnit struct indicates that the buffer is to small to retrieve the compressed data waiting for delivery.In this case the UsedSize attribute returns the minimum buffersize required to fetch the pending chunk. After allocating sufficient memory the encoder can retry the last call with the parameter pcInputPicture set to NULL to prevent encoding the last picture twice.\param[in] vvencEncoder pointer to opaque handler\param[in] pcYUVBuffer pointer to vvencYUVBuffer structure containing uncompressed picture data and meta information, to flush the encoder YUVBuffer must be NULL.\param[out] accessUnit pointer to vvencAccessUnit that retrieves compressed access units and side information, data is valid if UsedSize attribute is non-zero and the call was successful.\param[out] encodeDone pointer to flag that indicates that the encoder completed the last frame after flushing.\retval int if non-zero an error occurred, otherwise the retval indicates success VVENC_OK\pre The encoder has to be initialized successfully.
*/
VVENC_DECL int vvenc_encode( vvencEncoder *, vvencYUVBuffer* YUVBuffer, vvencAccessUnit* accessUnit, bool* encodeDone );/* vvenc_get_configThis method fetches the current encoder configuration.The method fails if the encoder is not initialized.\param[in] vvencEncoder pointer to opaque handler\param[in] vvenc_config reference to a vvenc_config struct that returns the current encoder setup.\retval int VVENC_ERR_INITIALIZE indicates the encoder was not successfully initialized in advance, otherwise the return value VVENC_OK indicates success.\pre The encoder has to be initialized.
*/
VVENC_DECL int vvenc_get_config( vvencEncoder *,vvenc_config * );/* vvenc_reconfigThis method reconfigures the encoder instance.This method is used to change encoder settings during the encoding process when the encoder was already initialized.Some parameter changes might require an internal encoder restart, especially when previously used parameter sets VPS, SPS or PPSbecome invalid after the parameter change. If changes are limited to TargetBitRate or QP changes then the encoder continues encodingwithout interruption, using the new parameters. Some parameters e.g. NumTheads, are not reconfigurable - in this case the encoder returns an Error.The method fails if the encoder is not initialized or if the assigned parameter set given in vvenc_config structdoes not pass the consistency and parameter check.\param[in] vvencEncoder pointer to opaque handler\param[in] vvenc_config const reference to vvenc_config struct that holds the new encoder parameters.\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre The encoder has to be initialized successfully.
*/
VVENC_DECL int vvenc_reconfig( vvencEncoder *, const vvenc_config * );/* vvenc_check_configThis method checks the passed configuration.The method fails if the encoder is not initialized.\param[in] vvencEncoder pointer to opaque handler\param[in] rcVVCEncParameter reference to an VVCEncParameter struct that returns the current encoder setup.\retval int VVENC_ERR_PARAMETER indicates a parameter error, otherwise the return value VVENC_OK indicates success.
*/
VVENC_DECL int vvenc_check_config( vvencEncoder *, const vvenc_config * );/* vvenc_get_headersThis method returns the headers (SPS,PPS,...) that are used.All init calls (vvenc_encoder_open, vvenc_init_pass) must be called in advance.\param[in] vvencEncoder pointer to opaque handler\param[out] accessUnit pointer to vvencAccessUnit that retrieves compressed access units containing all headers. \retval int negative indicates an error, otherwise the return value VVENC_OK indicates success.
*/
VVENC_DECL int vvenc_get_headers(vvencEncoder *, vvencAccessUnit * );/* vvenc_get_last_errorThis method returns the last occurred error as a string.\param[in] vvencEncoder pointer to opaque handler\retval const char empty string for no error assigned
*/
VVENC_DECL const char* vvenc_get_last_error( vvencEncoder * );/* vvenc_get_enc_informationThis method returns information about the encoder as a string.\param[in] vvencEncoder pointer to opaque handler\retval const char* encoder information
*/
VVENC_DECL const char* vvenc_get_enc_information( vvencEncoder * );/* vvenc_get_num_lead_framesThis method the number of needed lead frames (used for MCTF)\param[in] vvencEncoder pointer to opaque handler\retval number of leading frames
*/
VVENC_DECL int vvenc_get_num_lead_frames( vvencEncoder * );/* vvenc_get_num_trail_framesThis method the number of needed trailing frames (used for MCTF)\param[in] vvencEncoder pointer to opaque handler\retval number of trailing frames
*/
VVENC_DECL int vvenc_get_num_trail_frames( vvencEncoder * );/* vvenc_print_summaryThis method prints the summary of a encoder run.\param[in] vvencEncoder pointer to opaque handler\retval int VVENC_ERR_INITIALIZE indicates the encoder was not successfully initialized in advance, otherwise the return value VVENC_OK indicates success.
*/
VVENC_DECL int vvenc_print_summary( vvencEncoder * );/* vvenc_get_error_msgThis static function returns a string according to the passed parameter nRet.\param[in] nRet return value code to translate\retval[ ] const char* empty string for no error
*/
VVENC_DECL const char* vvenc_get_error_msg( int nRet );/* vvenc_set_logging_callback *deprecated*This method registers a global log message callback function to the encoder library.If no such function has been registered, the library will omit all messages.*deprecated* - This method is deprecated since it uses a global logger and will be removed in the next major version.Please use the method vvenc_set_logging_callback(vvenc_config,void *,vvencLoggingCallback) to register a thread safe local looger\param[in] ctx pointer of the caller, if not needed set it to null\paramin] Log message callback function.\retval int VVENC_ERR_INITIALIZE indicates the encoder was not successfully initialized in advance, otherwise the return value VVENC_OK indicates success.
*/
VVENC_DECL int vvenc_set_logging_callback( void * ctx, vvencLoggingCallback callback );/* vvenc_get_compile_info_stringcreates compile info string containing OS, Compiler and Bit-depth (e.g. 32 or 64 bit).\retval[ ] const char* compiler infoa as string
*/
VVENC_DECL const char* vvenc_get_compile_info_string( void );/* vvenc_set_SIMD_extensiontries to set given simd extensions used. if not supported by CPU, highest possible extension level will be set and returned.\param const char* simdId: empty string to set highest possible extension, otherwise set simd extension\retval[ ] const char* current simd exentsion
*/
VVENC_DECL const char* vvenc_set_SIMD_extension( const char* simdId );/* vvenc_get_height_of_component\param chFmt Chroma Format\param frameWidth width\param compId component ID\retval[ ] width of component
*/
VVENC_DECL int vvenc_get_width_of_component( const vvencChromaFormat chFmt, const int frameWidth, const int compId );/* vvenc_get_height_of_component\param chFmt Chroma Format\param frameHeight\param compId component ID\retval[ ] height of component
*/
VVENC_DECL int vvenc_get_height_of_component( const vvencChromaFormat chFmt, const int frameHeight, const int compId );/* Debug section *//* vvenc_is_tracing_enabledchecks if library has tracing supported enabled (see ENABLE_TRACING).\retval[ ] true if tracing is enabled, else false
*/
VVENC_DECL bool vvenc_is_tracing_enabled( void );/* vvenc_decode_bitstream
* @deprecated\param[in] FileName of bitstream that should be decoded\param[in] trcFile filename of a trace rule file\param[in] trcRule trace rules\retval int VVENC_ERR_INITIALIZE indicates the encoder was not successfully initialized in advance, otherwise the return value VVENC_OK indicates success.
*/
attribute_deprecated
VVENC_DECL int vvenc_decode_bitstream( const char* FileName, const char* trcFile, const char* trcRule);
vvencCfg.h
- VVENC_DECL void vvenc_config_default( vvenc_config *cfg ):这个函数用于将 vvenc_config 结构体的参数初始化为默认值。
- VVENC_DECL int vvenc_init_default( vvenc_config *cfg, int width, int height, int framerate, int targetbitrate, int qp, vvencPresetMode preset ):这个方法使用所有必要的参数(尺寸、帧率、比特率、量化参数和预设)来将 vvenc_config 参数初始化为默认值。
- VVENC_DECL int vvenc_init_preset( vvenc_config *cfg, vvencPresetMode preset ):通过使用 preset 覆盖编码器参数;在它之前vvenc_config_default 或 vvenc_init_default 函数必须首先被调用。
- VVENC_DECL void vvenc_set_msg_callback( vvenc_config *cfg, void * msgCtx, vvencLoggingCallback msgFnc ):该方法注册日志信息回调函数。
- VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *cfg ):该方法用于初始化编码参数,并将所有还未初始化的参数设置为有效值。在它之前vvenc_config_default 或 vvenc_init_default 函数必须首先被调用。
- VVENC_DECL int vvenc_set_param(vvenc_config *cfg, const char *name, const char *value):通过参数名称设置单个编码器参数;必须先调用 vvenc_config_default() 或 vvenc_init_default() 来初始化配置结构体的基本参数。
- VVENC_DECL int vvenc_set_param_list(vvenc_config c, int argc, char argv[] ):通过名称设置一组参数;必须先调用 vvenc_config_default() 或 vvenc_init_default() 来初始化配置结构体的基本参数。
- VVENC_DECL const char* vvenc_get_config_as_string( vvenc_config *cfg, vvencMsgLevel eMsgLevel ):返回编码器配置作为字符串,必须先调用 vvenc_config_default() 或 vvenc_init_default() 来初始化配置结构体的基本参数。
- 源码:
/* vvenc_config_defaultThis method initializes the vvenc_config parameters to default values (constructor).\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\retval none\pre None
*/
VVENC_DECL void vvenc_config_default( vvenc_config *cfg );/* vvenc_init_defaultThis method initializes the vvenc_config parameters to default values by using all requiredparameters size, framerate, bitrate, qp, preset.\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] width source width in pixel\param[in] height source height in pixel\param[in] framerate source frame-rates (Hz)\param[in] targetbitrate bitrate in bps (0: use fix qp, >0: enable rate control)\param[in] qp QP value of key-picture (integer in range 0 to 63, default: 32)\param[in] preset enum of used preset (default: VVENC_MEDIUM)\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre None
*/
VVENC_DECL int vvenc_init_default( vvenc_config *cfg, int width, int height, int framerate, int targetbitrate, int qp, vvencPresetMode preset );/* vvenc_init_presetThis method overwrites encoder parameter by using a preset.\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] preset enum of used preset (default: VVENC_MEDIUM)\retval int if non-zero an error occurred (see ErrorCodes), otherwise VVENC_OK indicates success.\pre vvenc_config_default() or vvenc_init_default() must be called first
*/
VVENC_DECL int vvenc_init_preset( vvenc_config *cfg, vvencPresetMode preset );/* vvenc_set_logging_callbackThis method registers a log message callback function.This callback is automatically used when calling vvenc_encoder_open().If no such function has been registered, the library will omit all messages.\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] msgCtx pointer of the caller, if not needed set it to null\param[in] msgFnc Log message callback function.\retval none
*/
VVENC_DECL void vvenc_set_msg_callback( vvenc_config *cfg, void * msgCtx, vvencLoggingCallback msgFnc );/* vvenc_init_config_parameter (optional)This method initialize the encoder parameter and sets all parameter the are not initialized yet.All not initialized parameters are set to valid values.Is automatically called in vvenc_encoder_open().\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\retval bool if true an error occurred, otherwise false.\pre vvenc_config_default() or vvenc_init_default() must be called first
*/
VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *cfg );/* vvenc_set_param (optional)This method sets one parameter by name.numerical range is not checked until vvenc_init_config_parameter()\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] name option name as stringuse "help", "longhelp", "fullhelp" to print available options\param[in] value option value as stringvalue=NULL means "true" for boolean options, but is a BAD_VALUE for non-booleans.\retval returns 0 on success, or returns one of the following values:VVENC_BAD_VALUE occurs only if it can't even parse the value,VVENC_PARAM_INFO occurs when a information should be printed (e.g. help, version)\pre vvenc_config_default() or vvenc_init_default() must be called first
*/
#define VVENC_PARAM_BAD_NAME (-1)
#define VVENC_PARAM_BAD_VALUE (-2)
#define VVENC_PARAM_INFO (1)
VVENC_DECL int vvenc_set_param(vvenc_config *cfg, const char *name, const char *value);/* vvenc_set_param_list (optional)This method sets a list of parameters by name.arguments must be separated as would be used in command line. e.g.: --bitrate 500000 --framerate 50numerical range is not checked until vvenc_init_config_parameter()\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] argc number or arguments in argv string list\param[in] argv list of char* (argv[]); option name must be defined by prefix -- or -\retval returns 0 on success, > 0 if an information was printed (help), -1 on failure.\pre vvenc_config_default() or vvenc_init_default() must be called first
*/
VVENC_DECL int vvenc_set_param_list(vvenc_config *c, int argc, char* argv[] );/* vvenc_get_config_as_string (optional)This method returns the encoder configuration as string.\param[in] vvenc_config* pointer to vvenc_config struct that contains encoder parameters\param[in] eMsgLevel verbosity level\retval const char* encoder configuration as string\pre vvenc_config_default() or vvenc_init_default() must be called first
*/
VVENC_DECL const char* vvenc_get_config_as_string( vvenc_config *cfg, vvencMsgLevel eMsgLevel );
VVenC__454">VVenC 编码器接口应用
- 可执行程序工具梳理图: