openh264 编码参数详细介绍

2024-06-06 07:52

本文主要是介绍openh264 编码参数详细介绍,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

openh264

OpenH264 是 Cisco 开源的一个 H.264 编码器,它支持 H.264 高级视频编码标准。这个编码器库适用于实时通信和流媒体应用,如 WebRTC,并且它是完全免费和开源的。OpenH264 项目在 GitHub 上进行维护,并且有一个活跃的社区,为开发者提供了丰富的文档和示例代码。

TagEncParamBase参数结构体

(SEncParamBase, *PEncParamBase)

  • 说明:基础编码参数结构体
  • EUsageType iUsageType
    • 编码器使用类型,参考EUsageType的定义,主要有相机实时、桌面内容、相机非实时、桌面内容非实时、输入内容所有类型一共五种类型;
/**
* @brief Encoder usage type
*/
typedef enum {CAMERA_VIDEO_REAL_TIME,      ///< camera video for real-time communicationSCREEN_CONTENT_REAL_TIME,    ///< screen content signalCAMERA_VIDEO_NON_REAL_TIME,SCREEN_CONTENT_NON_REAL_TIME,INPUT_CONTENT_TYPE_ALL,
} EUsageType;
  • int iPicWidth
    • 亮度采样的图像宽,如果有多个空域层,则为最大值
  • int iPicHeight
    • 亮度采样的图像高,如果有多个空域层,则为最大值
  • int iTargetBitrate
    • 期望的目标比特率,单位是 bps
  • RC_MODES iRCMode
    • 码率控制方式,可以参考RC_MODES中定义,主要有质量模式、码率模式、自适应质量模式、基于时间戳模式、内置 rc 模式、关闭 rc 模式。
/**
* @brief Enumerate the type of rate control mode
*/
typedef enum {RC_QUALITY_MODE = 0,     ///< quality modeRC_BITRATE_MODE = 1,     ///< bitrate modeRC_BUFFERBASED_MODE = 2, ///< no bitrate control,only using buffer status,adjust the video qualityRC_TIMESTAMP_MODE = 3, //rate control based timestampRC_BITRATE_MODE_POST_SKIP = 4, ///< this is in-building RC MODE, WILL BE DELETED after algorithm tuning!RC_OFF_MODE = -1,         ///< rate control off mode
} RC_MODES;
  • float fMaxFrameRate
    • 最大输入帧率

TagEncParamExt参数结构体

(SEncParamExt)

  • 说明:扩展编码参数结构体
  • EUsageType iUsageType
    • 同TagEncParamBase
  • int iPicWidth
    • 同TagEncParamBase
  • int iPicHeight
    • 同TagEncParamBase
  • int iTargetBitrate
    • 同TagEncParamBase
  • RC_MODES iRCMode
    • 同TagEncParamBase
  • float fMaxFrameRate
    • 同TagEncParamBase
  • int iTemporalLayerNum
    • 时域分层数,最大时域层等于 4
  • int iSpatialLayerNum
    • 空域分层数,取值在 1~MAX_SPATIAL_LAYER_NUM,其中MAX_SPATIAL_LAYER_NUM取值 4
  • SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM]
    • 空域层配置,最大 4 层,为不同的空域层配置编码相关参数,具体可以参考SSpatialLayerConfig结构体
/**
* @brief  Structure for spatial layer configuration
*/
typedef struct {int   iVideoWidth;           ///< width of picture in luminance samples of a layerint   iVideoHeight;          ///< height of picture in luminance samples of a layerfloat fFrameRate;            ///< frame rate specified for a layerint   iSpatialBitrate;       ///< target bitrate for a spatial layer, in unit of bpsint   iMaxSpatialBitrate;    ///< maximum  bitrate for a spatial layer, in unit of bpsEProfileIdc  uiProfileIdc;   ///< value of profile IDC (PRO_UNKNOWN for auto-detection)ELevelIdc    uiLevelIdc;     ///< value of profile IDC (0 for auto-detection)int          iDLayerQp;      ///< value of level IDC (0 for auto-detection)SSliceArgument sSliceArgument;// Note: members bVideoSignalTypePresent through uiColorMatrix below are also defined in SWelsSPS in parameter_sets.h.bool      bVideoSignalTypePresent;  // false => do not write any of the following information to the headerunsigned charuiVideoFormat;        // EVideoFormatSPS; 3 bits in header; 0-5 => component, kpal, ntsc, secam, mac, undefbool      bFullRange;         // false => analog video data range [16, 235]; true => full data range [0,255]bool      bColorDescriptionPresent; // false => do not write any of the following three items to the headerunsigned charuiColorPrimaries;     // EColorPrimaries; 8 bits in header; 0 - 9 => ???, bt709, undef, ???, bt470m, bt470bg,//    smpte170m, smpte240m, film, bt2020unsigned charuiTransferCharacteristics;  // ETransferCharacteristics; 8 bits in header; 0 - 15 => ???, bt709, undef, ???, bt470m, bt470bg, smpte170m,//   smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12unsigned charuiColorMatrix;        // EColorMatrix; 8 bits in header (corresponds to FFmpeg "colorspace"); 0 - 10 => GBR, bt709,//   undef, ???, fcc, bt470bg, smpte170m, smpte240m, YCgCo, bt2020nc, bt2020cbool bAspectRatioPresent; ///< aspect ratio present in VUIESampleAspectRatio eAspectRatio; ///< aspect ratio idcunsigned short sAspectRatioExtWidth; ///< use if aspect ratio idc == 255unsigned short sAspectRatioExtHeight; ///< use if aspect ratio idc == 255} SSpatialLayerConfig;
  • ECOMPLEXITY_MODE iComplexityMode
    • 复杂度模式,用来平衡编码复杂度和编码质量,具体可参考ECOMPLEXITY_MODE 共用体,取值有LOW_COMPLEXITY、MEDIUM_COMPLEXITY、HIGH_COMPLEXITY三种模式
/**
* @brief Enumulate the complexity mode
*/
typedef enum {LOW_COMPLEXITY = 0,              ///< the lowest compleixty,the fastest speed,MEDIUM_COMPLEXITY,          ///< medium complexity, medium speed,medium qualityHIGH_COMPLEXITY             ///< high complexity, lowest speed, high quality
} ECOMPLEXITY_MODE;
  • unsigned int uiIntraPeriod
    • 帧内编码帧的间隔,即 GOP 长度
  • int iNumRefFrame
    • 被使用的参考帧的数量
  • EParameterSetStrategy eSpsPpsIdStrategy
    • 在不同的 ID 中SPS/PPS 使用不同的策略,具体可以参考EParameterSetStrategy中定义,主要有固定 ID、每个 IDR 帧增加 ID、使用现有的 sps、使用现有 sps 同时 pps 增加、使用现有的 sps、pps。
/*** @brief Enumulate for the stategy of SPS/PPS strategy*/
typedef enum {CONSTANT_ID = 0,           ///< constant id in SPS/PPSINCREASING_ID = 0x01,      ///< SPS/PPS id increases at each IDRSPS_LISTING  = 0x02,       ///< using SPS in the existing list if possibleSPS_LISTING_AND_PPS_INCREASING  = 0x03,SPS_PPS_LISTING  = 0x06,
} EParameterSetStrategy;
  • bool bPrefixNalAddingCtrl
    • false 不使用Prefix NAL,true 使用Prefix NAL
    • Prefix NAL(前缀NAL单元)是视频编码中,特别是在H.264/AVC标准里使用的一种技术。它是一种特定的NAL单元,用于在发送新的NAL单元之前提供一些额外的信息或控制指令。这种前缀可以包含重要的编码参数,比如时间戳信息、解码参数集合(如SPS和PPS)的变化信息等。
  • bool bEnableSSEI
    • false 不使用 SSEI,true 使用 SSEI,todo:计划移除 SSEI 接口
  • bool bSimulcastAVC
    • false 使用 svc 语法为更高层当空域层多于 1 层时,true 使用Simulcast avc
  • int iPaddingFlag
    • 0 不填充,1 填充,
  • int iEntropyCodingModeFlag
    • 熵编码方式,0 为 cavlc,1 为 cabac
  • bool bEnableFrameSkip
    • false 无法跳帧,即使 vbv缓存溢出,true 允许跳帧保持码率在限制范围内
  • int iMaxBitrate
    • 最大码率,单位是 bps,如果不需要设置为UNSPECIFIED_BIT_RATE
  • int iMaxQp
    • 编码器支持的最大 qp 值
  • int iMinQp
    • 编码器支持的最小 qp 值
  • unsigned int uiMaxNalSize
    • 最大 NAL 大小,对于动态切片模式,该值不应该为0
  • bool bEnableLongTermReference
    • 长参考开关,1 开启长参考,0 关闭长参考
  • int iLTRRefNum
    • 长参考帧数量,todo:还不支持任意设置
  • unsigned int iLtrMarkPeriod
    • 在反馈中标记长参考的间隔周期
  • unsigned short iMultipleThreadIdc
    • 多线程设置,0 auto, 1 禁用多线程,大于 1 时计数多线程数量
  • bool bUseLoadBalancing
    • 仅当uiSliceMode=1或3时使用,将在多线程编码的运行期间更改图片的切片,因此每次运行的结果可能不同
  • int iLoopFilterDisableIdc
    • 去块环路滤波器,0:开启,1:关闭,2:开启,除了切片边界
  • int iLoopFilterAlphaC0Offset
    • Alpha偏移量设置,取值范围[-6, 6],默认 0
  • int iLoopFilterBetaOffset
    • Beta偏移量设置,取值范围[-6, 6],默认 0
  • bool bEnableDenoise
    • 去噪控制
  • bool bEnableBackgroundDetection
    • 背景检测控制
  • bool bEnableAdaptiveQuant
    • 自适应量化控制
  • bool bEnableFrameCroppingFlag
    • 使能帧裁剪标志:在应用中始终为TRUE
  • bool bEnableSceneChangeDetect
    • 场景变化检测
  • bool bIsLosslessLink
    • 长参考高级设置

编码参数默认设置

  • 在 param_svc.h 文件中FillDefault (SEncParamExt& param)函数设置编码参数默认值。
static void FillDefault (SEncParamExt& param) {memset (&param, 0, sizeof (param));param.uiIntraPeriod         = 0;                    // intra period (multiple of GOP size as desired)param.iNumRefFrame          = AUTO_REF_PIC_COUNT;// number of reference frame usedparam.iPicWidth             = 0;    //   actual input picture widthparam.iPicHeight            = 0;    //   actual input picture heightparam.fMaxFrameRate         = MAX_FRAME_RATE;       // maximal frame rate [Hz / fps]param.iComplexityMode       = LOW_COMPLEXITY;param.iTargetBitrate        = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC moduleparam.iMaxBitrate           = UNSPECIFIED_BIT_RATE;param.iMultipleThreadIdc    = 1;param.bUseLoadBalancing = true;param.iLTRRefNum            = 0;param.iLtrMarkPeriod        = 30;   //the min distance of two int32_t referencesparam.bEnableSSEI           = false;param.bSimulcastAVC         = false;param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application// false: Streaming Video Sharing; true: Video Conferencing Meeting;/* Deblocking loop filter */param.iLoopFilterDisableIdc         = 0;    // 0: on, 1: off, 2: on except for slice boundariesparam.iLoopFilterAlphaC0Offset      = 0;    // AlphaOffset: valid range [-6, 6], default 0param.iLoopFilterBetaOffset         = 0;    // BetaOffset:  valid range [-6, 6], default 0/* Rate Control */param.iRCMode                       = RC_QUALITY_MODE;param.iPaddingFlag                  = 0;param.iEntropyCodingModeFlag        = 0;param.bEnableDenoise                = false;        // denoise controlparam.bEnableSceneChangeDetect      = true;         // scene change detection controlparam.bEnableBackgroundDetection    = true;         // background detection controlparam.bEnableAdaptiveQuant          = true;         // adaptive quantization controlparam.bEnableFrameSkip              = true;         // frame skippingparam.bEnableLongTermReference      = false;        // long term reference controlparam.eSpsPpsIdStrategy             = INCREASING_ID;// pSps pPps id addition controlparam.bPrefixNalAddingCtrl          = false;        // prefix NAL adding controlparam.iSpatialLayerNum              = 1;            // number of dependency(Spatial/CGS) layers used to be encodedparam.iTemporalLayerNum             = 1;            // number of temporal layer specifiedparam.iMaxQp = QP_MAX_VALUE;param.iMinQp = QP_MIN_VALUE;param.iUsageType = CAMERA_VIDEO_REAL_TIME;param.uiMaxNalSize = 0;param.bIsLosslessLink = false;for (int32_t iLayer = 0; iLayer < MAX_SPATIAL_LAYER_NUM; iLayer++) {param.sSpatialLayers[iLayer].uiProfileIdc = PRO_UNKNOWN;param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_UNKNOWN;param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;param.sSpatialLayers[iLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;param.sSpatialLayers[iLayer].sSliceArgument.uiSliceMode = SM_SINGLE_SLICE;param.sSpatialLayers[iLayer].sSliceArgument.uiSliceNum = 0; //AUTO, using number of CPU coresparam.sSpatialLayers[iLayer].sSliceArgument.uiSliceSizeConstraint = 1500;param.sSpatialLayers[iLayer].bAspectRatioPresent = false; // do not write any of the following information to the headerparam.sSpatialLayers[iLayer].eAspectRatio = ASP_UNSPECIFIED;param.sSpatialLayers[iLayer].sAspectRatioExtWidth = 0;param.sSpatialLayers[iLayer].sAspectRatioExtHeight = 0;const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)param.sSpatialLayers[iLayer].sSliceArgument.uiSliceMbNum[idx] = 0; //default, using one row a slice if uiSliceMode is SM_RASTER_MODE// See codec_app_def.h for more info about members bVideoSignalTypePresent through uiColorMatrix.  The default values// used below preserve the previous behavior; i.e., no additional information will be written to the output file.param.sSpatialLayers[iLayer].bVideoSignalTypePresent = false;     // do not write any of the following information to the headerparam.sSpatialLayers[iLayer].uiVideoFormat = VF_UNDEF;        // undefinedparam.sSpatialLayers[iLayer].bFullRange = false;            // analog video data range [16, 235]param.sSpatialLayers[iLayer].bColorDescriptionPresent = false;    // do not write any of the following three items to the headerparam.sSpatialLayers[iLayer].uiColorPrimaries = CP_UNDEF;       // undefinedparam.sSpatialLayers[iLayer].uiTransferCharacteristics = TRC_UNDEF; // undefinedparam.sSpatialLayers[iLayer].uiColorMatrix = CM_UNDEF;        // undefined}}

这篇关于openh264 编码参数详细介绍的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1035518

相关文章

Java内存分配与JVM参数详解(推荐)

《Java内存分配与JVM参数详解(推荐)》本文详解JVM内存结构与参数调整,涵盖堆分代、元空间、GC选择及优化策略,帮助开发者提升性能、避免内存泄漏,本文给大家介绍Java内存分配与JVM参数详解,... 目录引言JVM内存结构JVM参数概述堆内存分配年轻代与老年代调整堆内存大小调整年轻代与老年代比例元空

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

SpringBoot整合liteflow的详细过程

《SpringBoot整合liteflow的详细过程》:本文主要介绍SpringBoot整合liteflow的详细过程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋...  liteflow 是什么? 能做什么?总之一句话:能帮你规范写代码逻辑 ,编排并解耦业务逻辑,代码

浏览器插件cursor实现自动注册、续杯的详细过程

《浏览器插件cursor实现自动注册、续杯的详细过程》Cursor简易注册助手脚本通过自动化邮箱填写和验证码获取流程,大大简化了Cursor的注册过程,它不仅提高了注册效率,还通过友好的用户界面和详细... 目录前言功能概述使用方法安装脚本使用流程邮箱输入页面验证码页面实战演示技术实现核心功能实现1. 随机

c++中的set容器介绍及操作大全

《c++中的set容器介绍及操作大全》:本文主要介绍c++中的set容器介绍及操作大全,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录​​一、核心特性​​️ ​​二、基本操作​​​​1. 初始化与赋值​​​​2. 增删查操作​​​​3. 遍历方

HTML img标签和超链接标签详细介绍

《HTMLimg标签和超链接标签详细介绍》:本文主要介绍了HTML中img标签的使用,包括src属性(指定图片路径)、相对/绝对路径区别、alt替代文本、title提示、宽高控制及边框设置等,详细内容请阅读本文,希望能对你有所帮助... 目录img 标签src 属性alt 属性title 属性width/h

CSS3打造的现代交互式登录界面详细实现过程

《CSS3打造的现代交互式登录界面详细实现过程》本文介绍CSS3和jQuery在登录界面设计中的应用,涵盖动画、选择器、自定义字体及盒模型技术,提升界面美观与交互性,同时优化性能和可访问性,感兴趣的朋... 目录1. css3用户登录界面设计概述1.1 用户界面设计的重要性1.2 CSS3的新特性与优势1.

CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比

《CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比》CSS中的position属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布... css 中的 position 属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布局和层叠关

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4

SpringBoot整合Flowable实现工作流的详细流程

《SpringBoot整合Flowable实现工作流的详细流程》Flowable是一个使用Java编写的轻量级业务流程引擎,Flowable流程引擎可用于部署BPMN2.0流程定义,创建这些流程定义的... 目录1、流程引擎介绍2、创建项目3、画流程图4、开发接口4.1 Java 类梳理4.2 查看流程图4