From 199bdd0bf5043c9f0c6720f86df1ea0a69a93eee Mon Sep 17 00:00:00 2001 From: dev-zut Date: Wed, 25 Jun 2025 17:10:45 +0800 Subject: [PATCH 1/2] add b-frame ndk interface Signed-off-by: dev-zut --- multimedia/av_codec/native_avcapability.h | 4 +++ multimedia/av_codec/native_avcodec_base.h | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/multimedia/av_codec/native_avcapability.h b/multimedia/av_codec/native_avcapability.h index dd17584d429..07c94177ba4 100644 --- a/multimedia/av_codec/native_avcapability.h +++ b/multimedia/av_codec/native_avcapability.h @@ -86,6 +86,10 @@ typedef enum OH_AVCapabilityFeature { VIDEO_ENCODER_LONG_TERM_REFERENCE = 1, /** Feature for codec supports low latency. It is used in video encoder and video decoder. */ VIDEO_LOW_LATENCY = 2, + /** Feature for codec supports B-frame encoding. It is only used in video encoder. + * @since 20 + */ + VIDEO_ENCODER_B_FRAME = 7, } OH_AVCapabilityFeature; /** diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 0aa105bb412..28db7ca43af 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1059,6 +1059,36 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_FRAME_AFTER; * @since 18 */ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_MAX_COUNT; +/** + * @brief Key to enable B-frame encoding, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise. + * + * This is an optional key that applies only to video encoder, default is 0.\n + * If enabled, the video encoder will use B-frame, the decode order will be different from the display order.\n + * For unsupported platforms, Configuring this key will have no effect.\n + * Platform capability can be checked via {@link OH_AVCapability_IsFeatureSupported} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * It's only used in configuration phase.\n + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME; + +/** + * @brief Key for describing the maximum B-frame count of video encoder, value type is int32_t. + * + * Note: This key is only for querying the capability of the codec currently. + * Usage specifications: + * 1. Check feature support via {@link OH_AVCapability_IsFeatureSupported} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * 2. Obtain OH_AVFormat handle via {@link OH_AVCapability_GetFeatureProperties} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * 3. Get maximum B-frame count via {@link OH_AVFormat_GetIntValue} with this key.\n + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_MAX_B_FRAMES; /** * @brief Key to set the region of interest(ROI) as QpOffset-Rects, value type is string in the format * "Top1,Left1-Bottom1,Right1=Offset1;Top2,Left2-Bottom2,Right2=Offset2;". Each "Top,Left-Bottom,Right=Offset" -- Gitee From f33de53c61bedc239706c6a3372a72308c581a7a Mon Sep 17 00:00:00 2001 From: dev-zut Date: Wed, 25 Jun 2025 17:24:36 +0800 Subject: [PATCH 2/2] add b-frame ndk interface Signed-off-by: dev-zut --- .../codec_base/libnative_media_codecbase.ndk.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json index 1533b86665e..40d01650473 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -443,6 +443,14 @@ "first_introduced": "20", "name": "OH_MD_KEY_ENABLE_SYNC_MODE" }, + { + "first_introduced": "20", + "name": "OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME" + }, + { + "first_introduced": "20", + "name": "OH_MD_KEY_VIDEO_ENCODER_MAX_B_FRAMES" + }, { "first_introduced": "10", "name": "OH_AVCodec_GetCapability" -- Gitee