diff mbox series

[FFmpeg-devel,6/6] avcodec: move mpeg4 profiles to profiles.h

Message ID 20200511193522.31206-6-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/6] avutil/opt: add AV_OPT_FLAG_CHILD_CONSTS
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Marton Balint May 11, 2020, 7:35 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 doc/codecs.texi            | 17 ++---------------
 libavcodec/mpeg4videoenc.c |  2 ++
 libavcodec/options_table.h |  4 ----
 libavcodec/profiles.h      |  6 ++++++
 libavcodec/v4l2_m2m_enc.c  | 34 ++++++++++++++++++++++------------
 5 files changed, 32 insertions(+), 31 deletions(-)

Comments

Fu, Linjie May 18, 2020, 4:16 a.m. UTC | #1
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Marton Balint
> Sent: Tuesday, May 12, 2020 03:35
> To: ffmpeg-devel@ffmpeg.org
> Cc: Marton Balint <cus@passwd.hu>
> Subject: [FFmpeg-devel] [PATCH 6/6] avcodec: move mpeg4 profiles to
> profiles.h
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  doc/codecs.texi            | 17 ++---------------
>  libavcodec/mpeg4videoenc.c |  2 ++
>  libavcodec/options_table.h |  4 ----
>  libavcodec/profiles.h      |  6 ++++++
>  libavcodec/v4l2_m2m_enc.c  | 34 ++++++++++++++++++++++------------
>  5 files changed, 32 insertions(+), 31 deletions(-)
> 
> diff --git a/doc/codecs.texi b/doc/codecs.texi
> index c08229ba7e..ece8d50edd 100644
> --- a/doc/codecs.texi
> +++ b/doc/codecs.texi
> @@ -837,21 +837,8 @@ Set number of macroblock rows at the bottom which
> are skipped.
> 
>  @item profile @var{integer} (@emph{encoding,audio,video})
> 
> -Possible values:
> -@table @samp
> -@item unknown
> -
> -@item mpeg4_sp
> -
> -@item mpeg4_core
> -
> -@item mpeg4_main
> -
> -@item mpeg4_asp
> -
> -@end table
> -
> -Encoder specific profiles are documented in the relevant encoder
> documentation.
> +Set encoder codec profile. Default value is @samp{unknown}. Encoder
> specific
> +profiles are documented in the relevant encoder documentation.
> 
>  @item level @var{integer} (@emph{encoding,audio,video})
> 
> diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
> index 2cd5a8c015..2e0b119d7f 100644
> --- a/libavcodec/mpeg4videoenc.c
> +++ b/libavcodec/mpeg4videoenc.c
> @@ -27,6 +27,7 @@
>  #include "mpegvideo.h"
>  #include "h263.h"
>  #include "mpeg4video.h"
> +#include "profiles.h"
> 
>  /* The uni_DCtab_* tables below contain unified bits+length tables to
> encode DC
>   * differences in MPEG-4. Unified in the sense that the specification specifies
> @@ -1376,6 +1377,7 @@ static const AVOption options[] = {
>      { "data_partitioning", "Use data partitioning.",
> OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>      { "alternate_scan",    "Enable alternate scantable.",
> OFFSET(alternate_scan),    AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>      FF_MPV_COMMON_OPTS
> +    FF_MPEG4_PROFILE_OPTS
>      { NULL },
>  };
> 
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index 4c7dca696b..6db8facff6 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -262,10 +262,6 @@ static const AVOption avcodec_options[] = {
>  {"skip_bottom", "number of macroblock rows at the bottom which are
> skipped", OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT },
> INT_MIN, INT_MAX, V|D},
>  {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 =
> FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
>  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "avctx.profile"},
> -{"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_MPEG4_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
> -{"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_MPEG4_CORE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
> -{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_MPEG4_MAIN }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
> -{"mpeg4_asp",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E,
> "avctx.profile"},
>  {"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 =
> FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
>  {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 =
> FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
>  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN },
> INT_MIN, INT_MAX, V|A|E, "level"},
> diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
> index d950971875..e414ea77a7 100644
> --- a/libavcodec/profiles.h
> +++ b/libavcodec/profiles.h
> @@ -37,6 +37,12 @@
>      FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO,
> FF_PROFILE_MPEG2_AAC_LOW)\
>      FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he",  NULL, AUDIO,
> FF_PROFILE_MPEG2_AAC_HE)\
> 
> +#define FF_MPEG4_PROFILE_OPTS \
> +    FF_AVCTX_PROFILE_OPTION("mpeg4_sp",      NULL, VIDEO,
> FF_PROFILE_MPEG4_SIMPLE)\
> +    FF_AVCTX_PROFILE_OPTION("mpeg4_core",    NULL, VIDEO,
> FF_PROFILE_MPEG4_CORE)\
> +    FF_AVCTX_PROFILE_OPTION("mpeg4_main",    NULL, VIDEO,
> FF_PROFILE_MPEG4_MAIN)\
> +    FF_AVCTX_PROFILE_OPTION("mpeg4_asp",     NULL, VIDEO,
> FF_PROFILE_MPEG4_ADVANCED_SIMPLE)\
> +
Since it's now searchable according to the AVClass, we may not need
the prefix anymore. (for now it's necessary for the ABI)

Hence would it be better to add some deprecated flags for them and
remove the prefix in future  when avcodec version increase?
(something like FF_API_NEXT)

- Linjie
Marton Balint May 18, 2020, 6:41 p.m. UTC | #2
On Mon, 18 May 2020, Fu, Linjie wrote:

>> diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
>> index d950971875..e414ea77a7 100644
>> --- a/libavcodec/profiles.h
>> +++ b/libavcodec/profiles.h
>> @@ -37,6 +37,12 @@
>>      FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO,
>> FF_PROFILE_MPEG2_AAC_LOW)\
>>      FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he",  NULL, AUDIO,
>> FF_PROFILE_MPEG2_AAC_HE)\
>>
>> +#define FF_MPEG4_PROFILE_OPTS \
>> +    FF_AVCTX_PROFILE_OPTION("mpeg4_sp",      NULL, VIDEO,
>> FF_PROFILE_MPEG4_SIMPLE)\
>> +    FF_AVCTX_PROFILE_OPTION("mpeg4_core",    NULL, VIDEO,
>> FF_PROFILE_MPEG4_CORE)\
>> +    FF_AVCTX_PROFILE_OPTION("mpeg4_main",    NULL, VIDEO,
>> FF_PROFILE_MPEG4_MAIN)\
>> +    FF_AVCTX_PROFILE_OPTION("mpeg4_asp",     NULL, VIDEO,
>> FF_PROFILE_MPEG4_ADVANCED_SIMPLE)\
>> +
> Since it's now searchable according to the AVClass, we may not need
> the prefix anymore. (for now it's necessary for the ABI)
>
> Hence would it be better to add some deprecated flags for them and
> remove the prefix in future  when avcodec version increase?
> (something like FF_API_NEXT)

Yes, can be done later, but this patch is only about moving existing 
option names, not deprecating existing ones and adding new names.

Regards,
Marton
diff mbox series

Patch

diff --git a/doc/codecs.texi b/doc/codecs.texi
index c08229ba7e..ece8d50edd 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -837,21 +837,8 @@  Set number of macroblock rows at the bottom which are skipped.
 
 @item profile @var{integer} (@emph{encoding,audio,video})
 
-Possible values:
-@table @samp
-@item unknown
-
-@item mpeg4_sp
-
-@item mpeg4_core
-
-@item mpeg4_main
-
-@item mpeg4_asp
-
-@end table
-
-Encoder specific profiles are documented in the relevant encoder documentation.
+Set encoder codec profile. Default value is @samp{unknown}. Encoder specific
+profiles are documented in the relevant encoder documentation.
 
 @item level @var{integer} (@emph{encoding,audio,video})
 
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 2cd5a8c015..2e0b119d7f 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -27,6 +27,7 @@ 
 #include "mpegvideo.h"
 #include "h263.h"
 #include "mpeg4video.h"
+#include "profiles.h"
 
 /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
  * differences in MPEG-4. Unified in the sense that the specification specifies
@@ -1376,6 +1377,7 @@  static const AVOption options[] = {
     { "data_partitioning", "Use data partitioning.",      OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
     { "alternate_scan",    "Enable alternate scantable.", OFFSET(alternate_scan),    AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
     FF_MPV_COMMON_OPTS
+    FF_MPEG4_PROFILE_OPTS
     { NULL },
 };
 
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 4c7dca696b..6db8facff6 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -262,10 +262,6 @@  static const AVOption avcodec_options[] = {
 {"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "avctx.profile"},
-{"mpeg4_sp",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_core", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_CORE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"mpeg4_asp",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, V|E, "avctx.profile"},
 {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index d950971875..e414ea77a7 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -37,6 +37,12 @@ 
     FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO, FF_PROFILE_MPEG2_AAC_LOW)\
     FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he",  NULL, AUDIO, FF_PROFILE_MPEG2_AAC_HE)\
 
+#define FF_MPEG4_PROFILE_OPTS \
+    FF_AVCTX_PROFILE_OPTION("mpeg4_sp",      NULL, VIDEO, FF_PROFILE_MPEG4_SIMPLE)\
+    FF_AVCTX_PROFILE_OPTION("mpeg4_core",    NULL, VIDEO, FF_PROFILE_MPEG4_CORE)\
+    FF_AVCTX_PROFILE_OPTION("mpeg4_main",    NULL, VIDEO, FF_PROFILE_MPEG4_MAIN)\
+    FF_AVCTX_PROFILE_OPTION("mpeg4_asp",     NULL, VIDEO, FF_PROFILE_MPEG4_ADVANCED_SIMPLE)\
+
 extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index ebb575f349..a21a7b6c65 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -29,6 +29,7 @@ 
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/opt.h"
+#include "profiles.h"
 #include "v4l2_context.h"
 #include "v4l2_m2m.h"
 #include "v4l2_fmt.h"
@@ -370,10 +371,19 @@  static av_cold int v4l2_encode_close(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(V4L2m2mPriv, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
+#define V4L_M2M_CAPTURE_OPTS \
+    V4L_M2M_DEFAULT_OPTS,\
+    { "num_capture_buffers", "Number of buffers in the capture context", \
+        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 4 }, 4, INT_MAX, FLAGS }
+
+static const AVOption mpeg4_options[] = {
+    V4L_M2M_CAPTURE_OPTS,
+    FF_MPEG4_PROFILE_OPTS
+    { NULL },
+};
+
 static const AVOption options[] = {
-    V4L_M2M_DEFAULT_OPTS,
-    { "num_capture_buffers", "Number of buffers in the capture context",
-        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 4 }, 4, INT_MAX, FLAGS },
+    V4L_M2M_CAPTURE_OPTS,
     { NULL },
 };
 
@@ -383,16 +393,16 @@  static const AVCodecDefault v4l2_m2m_defaults[] = {
     { NULL },
 };
 
-#define M2MENC_CLASS(NAME) \
+#define M2MENC_CLASS(NAME, OPTIONS_NAME) \
     static const AVClass v4l2_m2m_ ## NAME ## _enc_class = { \
         .class_name = #NAME "_v4l2m2m_encoder", \
         .item_name  = av_default_item_name, \
-        .option     = options, \
+        .option     = OPTIONS_NAME, \
         .version    = LIBAVUTIL_VERSION_INT, \
     };
 
-#define M2MENC(NAME, LONGNAME, CODEC) \
-    M2MENC_CLASS(NAME) \
+#define M2MENC(NAME, LONGNAME, OPTIONS_NAME, CODEC) \
+    M2MENC_CLASS(NAME, OPTIONS_NAME) \
     AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \
         .name           = #NAME "_v4l2m2m" , \
         .long_name      = NULL_IF_CONFIG_SMALL("V4L2 mem2mem " LONGNAME " encoder wrapper"), \
@@ -409,8 +419,8 @@  static const AVCodecDefault v4l2_m2m_defaults[] = {
         .wrapper_name   = "v4l2m2m", \
     };
 
-M2MENC(mpeg4,"MPEG4", AV_CODEC_ID_MPEG4);
-M2MENC(h263, "H.263", AV_CODEC_ID_H263);
-M2MENC(h264, "H.264", AV_CODEC_ID_H264);
-M2MENC(hevc, "HEVC",  AV_CODEC_ID_HEVC);
-M2MENC(vp8,  "VP8",   AV_CODEC_ID_VP8);
+M2MENC(mpeg4,"MPEG4", mpeg4_options, AV_CODEC_ID_MPEG4);
+M2MENC(h263, "H.263", options,       AV_CODEC_ID_H263);
+M2MENC(h264, "H.264", options,       AV_CODEC_ID_H264);
+M2MENC(hevc, "HEVC",  options,       AV_CODEC_ID_HEVC);
+M2MENC(vp8,  "VP8",   options,       AV_CODEC_ID_VP8);