From 1ebd94cc2494af313491400a2bcac2094bb3dc0b Mon Sep 17 00:00:00 2001 From: qijinquan Date: Wed, 1 Jun 2022 13:46:22 +0800 Subject: [PATCH] feat: Add bitRatemode, frameRate and measuredFrameRate in config Signed-off-by: qijinquan --- codec/hal/include/codec_config_parser.h | 4 +++ codec/hal/src/codec_config_parser.c | 25 +++++++++++++------ .../interfaces/include/codec_component_type.h | 20 +++++++++++++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/codec/hal/include/codec_config_parser.h b/codec/hal/include/codec_config_parser.h index f13f9c4cc7..e5bdb17f63 100644 --- a/codec/hal/include/codec_config_parser.h +++ b/codec/hal/include/codec_config_parser.h @@ -52,6 +52,10 @@ #define CODEC_CONFIG_KEY_SUPPORT_PIXEL_FMTS "supportPixelFmts" #define CODEC_CONFIG_KEY_BLOCK_SIZE_WIDTH "blockSizeWidth" #define CODEC_CONFIG_KEY_BLOCK_SIZE_HEIGHT "blockSizeHeight" +#define CODEC_CONFIG_KEY_MIN_FRAME_RATE "minFrameRate" +#define CODEC_CONFIG_KEY_MAX_FRAME_RATE "maxFrameRate" +#define CODEC_CONFIG_KEY_BITE_RATE_MODE "bitRateMode" +#define CODEC_CONFIG_KEY_MESURED_FRAME_RATE "measuredFrameRate" #define CODEC_CONFIG_KEY_SAMPLE_FORMATS "sampleFormats" #define CODEC_CONFIG_KEY_SAMPLE_RATE "sampleRate" diff --git a/codec/hal/src/codec_config_parser.c b/codec/hal/src/codec_config_parser.c index 675dd7da38..8f4f8c72f8 100644 --- a/codec/hal/src/codec_config_parser.c +++ b/codec/hal/src/codec_config_parser.c @@ -137,7 +137,9 @@ static int32_t GetVideoPortCapability(const struct DeviceResourceIface *iface, {CODEC_CONFIG_KEY_MIN_BLOCKS_PER_SECOND, (uint32_t*)&cap->port.video.blocksPerSecond.min, 0}, {CODEC_CONFIG_KEY_MAX_BLOCKS_PER_SECOND, (uint32_t*)&cap->port.video.blocksPerSecond.max, 0}, {CODEC_CONFIG_KEY_BLOCK_SIZE_WIDTH, (uint32_t*)&cap->port.video.blockSize.width, 0}, - {CODEC_CONFIG_KEY_BLOCK_SIZE_HEIGHT, (uint32_t*)&cap->port.video.blockSize.height, 0} + {CODEC_CONFIG_KEY_BLOCK_SIZE_HEIGHT, (uint32_t*)&cap->port.video.blockSize.height, 0}, + {CODEC_CONFIG_KEY_MIN_FRAME_RATE, (uint32_t *)&cap->port.video.frameRate.min, 0}, + {CODEC_CONFIG_KEY_MAX_FRAME_RATE, (uint32_t *)&cap->port.video.frameRate.max, 0} }; int32_t count = sizeof(nodeAttrs) / sizeof(ConfigUintNodeAttr); @@ -150,14 +152,21 @@ static int32_t GetVideoPortCapability(const struct DeviceResourceIface *iface, } } - ConfigUintArrayNodeAttr attr = {CODEC_CONFIG_KEY_SUPPORT_PIXEL_FMTS, - cap->port.video.supportPixFmts, PIX_FORMAT_NUM, OMX_COLOR_FormatUnused}; - if (GetUintTableConfig(iface, childNode, &attr) != HDF_SUCCESS) { - HDF_LOGE("%{public}s, failed to get %{public}s.%{public}s!", - __func__, childNode->name, CODEC_CONFIG_KEY_SUPPORT_PIXEL_FMTS); - return HDF_FAILURE; - } + ConfigUintArrayNodeAttr arrayAttrs[] = { + {CODEC_CONFIG_KEY_SUPPORT_PIXEL_FMTS, cap->port.video.supportPixFmts, PIX_FORMAT_NUM, OMX_COLOR_FormatUnused}, + {CODEC_CONFIG_KEY_BITE_RATE_MODE, (int32_t *)cap->port.video.bitRatemode, BIT_RATE_MODE_NUM, + BIT_RATE_MODE_INVALID}, + {CODEC_CONFIG_KEY_MESURED_FRAME_RATE, cap->port.video.measuredFrameRate, MEASURED_FRAME_RATE_NUM, 0} + }; + count = sizeof(arrayAttrs) / sizeof(ConfigUintArrayNodeAttr); + for (int32_t i = 0; i < count; i++) { + if (GetUintTableConfig(iface, childNode, &arrayAttrs[i]) != HDF_SUCCESS) { + HDF_LOGE("%{public}s, failed to get %{public}s.%{public}s!", __func__, childNode->name, + nodeAttrs[i].attrName); + return HDF_FAILURE; + } + } return HDF_SUCCESS; } diff --git a/codec/interfaces/include/codec_component_type.h b/codec/interfaces/include/codec_component_type.h index bb2f229eb8..f7f5067673 100644 --- a/codec/interfaces/include/codec_component_type.h +++ b/codec/interfaces/include/codec_component_type.h @@ -118,6 +118,23 @@ typedef enum { * @brief Defines the video encoding and decoding capabilities. */ #define PIX_FORMAT_NUM 16 /** Size of the supported pixel format array */ +#define BIT_RATE_MODE_NUM 5 /* Size of the array bit rate mode. */ +#define MEASURED_FRAME_RATE_NUM 32 /* Size of the array measured frame rate. */ + +typedef enum { + BIT_RATE_MODE_INVALID, + /** Variable Bit Rate. */ + BIT_RATE_MODE_VBR, + /* Constant Bit Rate. */ + BIT_RATE_MODE_CBR, + /* Constant Quality. */ + BIT_RATE_MODE_CQ, + /* Constrained VariableBit Rate. */ + BIT_RATE_MODE_VCBR, + /* Average Bit Rate. */ + BIT_RATE_MODE_ABR, +} BitRateMode; + typedef struct { Rect minSize; /** Minimum resolution supported. */ Rect maxSize; /** Maximum resolution supported. */ @@ -127,6 +144,9 @@ typedef struct { Rect blockSize; /** Block size supported. */ int32_t supportPixFmts[PIX_FORMAT_NUM]; /** Supported pixel format. For details, see {@link OMX_COLOR_FORMATTYPE}. */ + BitRateMode bitRatemode[BIT_RATE_MODE_NUM]; /* Bit Rate Mode. For details, see {@link BitRateMode}. */ + RangeValue frameRate; /* Frame Rate. */ + int32_t measuredFrameRate[MEASURED_FRAME_RATE_NUM]; /* Measured Frame Rate. */ } VideoPortCap; /** -- Gitee