diff mbox series

[FFmpeg-devel,v2,1/7] avcodec/mediacodecenc: make each encoder has its own option

Message ID tencent_891C4E8BA56632D09266CAA7CF6ABA531306@qq.com
State Accepted
Commit 0a0f2d1a8cc4e4f75e18f0d4c1997289e04ecfce
Headers show
Series [FFmpeg-devel,v2,1/7] avcodec/mediacodecenc: make each encoder has its own option | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

zhilizhao(赵志立) Dec. 7, 2022, 9:31 a.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

---
 libavcodec/mediacodecenc.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 69246ad693..4f9185342f 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -480,19 +480,18 @@  static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = {
 
 #define OFFSET(x) offsetof(MediaCodecEncContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-static const AVOption common_options[] = {
-    { "ndk_codec", "Use MediaCodec from NDK",
-                    OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },
-    { "codec_name", "Select codec by name",
-                    OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE },
-    { NULL },
-};
+#define COMMON_OPTION                                                                                       \
+    { "ndk_codec", "Use MediaCodec from NDK",                                                               \
+                    OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },                      \
+    { "codec_name", "Select codec by name",                                                                 \
+                    OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE },                                      \
+
 
 #define MEDIACODEC_ENCODER_CLASS(name)              \
 static const AVClass name ## _mediacodec_class = {  \
     .class_name = #name "_mediacodec",              \
     .item_name  = av_default_item_name,             \
-    .option     = common_options,                   \
+    .option     = name ## _options,                 \
     .version    = LIBAVUTIL_VERSION_INT,            \
 };                                                  \
 
@@ -517,9 +516,17 @@  const FFCodec ff_ ## short_name ## _mediacodec_encoder = {              \
 };                                                                      \
 
 #if CONFIG_H264_MEDIACODEC_ENCODER
+static const AVOption h264_options[] = {
+    COMMON_OPTION
+    { NULL, }
+};
 DECLARE_MEDIACODEC_ENCODER(h264, "H.264", AV_CODEC_ID_H264)
 #endif
 
 #if CONFIG_HEVC_MEDIACODEC_ENCODER
+static const AVOption hevc_options[] = {
+    COMMON_OPTION
+    { NULL, }
+};
 DECLARE_MEDIACODEC_ENCODER(hevc, "H.265", AV_CODEC_ID_HEVC)
 #endif