From 90aebc52f106ce7f68e7e9c155a29929df0d76bf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 1 Mar 2024 01:00:08 +0100 Subject: [PATCH 08/38] avcodec/aacdec_template: Deduplicate AVClass+AVOptions Signed-off-by: Andreas Rheinhardt --- libavcodec/aac/aacdec.c | 39 ++++++++++++++++++++++++++++++++++++ libavcodec/aacdec.c | 3 +-- libavcodec/aacdec.h | 2 ++ libavcodec/aacdec_fixed.c | 3 +-- libavcodec/aacdec_template.c | 32 ----------------------------- 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 021f94e1e5..4095509d16 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -29,13 +29,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include + #include "libavcodec/aacsbr.h" #include "libavcodec/aacdec.h" #include "libavcodec/avcodec.h" #include "libavutil/attributes.h" +#include "libavutil/log.h" #include "libavutil/macros.h" #include "libavutil/mem.h" +#include "libavutil/opt.h" #include "libavutil/tx.h" +#include "libavutil/version.h" av_cold int ff_aac_decode_close(AVCodecContext *avctx) { @@ -69,3 +75,36 @@ av_cold int ff_aac_decode_close(AVCodecContext *avctx) return 0; } + +#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM +#define OFF(field) offsetof(AACDecContext, field) +static const AVOption options[] = { + /** + * AVOptions for Japanese DTV specific extensions (ADTS only) + */ + {"dual_mono_mode", "Select the channel to decode for dual mono", + OFF(force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, + AACDEC_FLAGS, .unit = "dual_mono_mode"}, + + {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, + {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, + {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, + {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, + + { "channel_order", "Order in which the channels are to be exported", + OFF(output_channel_order), AV_OPT_TYPE_INT, + { .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, AACDEC_FLAGS, .unit = "channel_order" }, + { "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST, + { .i64 = CHANNEL_ORDER_DEFAULT }, .flags = AACDEC_FLAGS, .unit = "channel_order" }, + { "coded", "order in which the channels are coded in the bitstream", + 0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, .unit = "channel_order" }, + + {NULL}, +}; + +const AVClass ff_aac_decoder_class = { + .class_name = "AAC decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index cfad0ab01a..86b9161e64 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -36,7 +36,6 @@ #define TX_TYPE AV_TX_FLOAT_MDCT #include "libavutil/float_dsp.h" -#include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" #include "get_bits.h" @@ -554,6 +553,7 @@ const FFCodec ff_aac_decoder = { CODEC_LONG_NAME("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, + .p.priv_class = &ff_aac_decoder_class, .priv_data_size = sizeof(AACDecContext), .init = aac_decode_init, .close = ff_aac_decode_close, @@ -565,7 +565,6 @@ const FFCodec ff_aac_decoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.ch_layouts = ff_aac_ch_layout, .flush = flush, - .p.priv_class = &aac_decoder_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), }; diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h index cb9d1637b3..b05e68f51c 100644 --- a/libavcodec/aacdec.h +++ b/libavcodec/aacdec.h @@ -304,6 +304,8 @@ typedef struct AACDecContext { #define fdsp RENAME_FIXED(fdsp) #endif +extern const struct AVClass ff_aac_decoder_class; + int ff_aac_decode_close(struct AVCodecContext *avctx); void ff_aacdec_init_mips(AACDecContext *c); diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index 4a5f678bca..8ed98226e9 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -62,7 +62,6 @@ #define TX_TYPE AV_TX_INT32_MDCT #include "libavutil/fixed_dsp.h" -#include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" #include "get_bits.h" @@ -498,6 +497,7 @@ const FFCodec ff_aac_fixed_decoder = { CODEC_LONG_NAME("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, + .p.priv_class = &ff_aac_decoder_class, .priv_data_size = sizeof(AACDecContext), .init = aac_decode_init, .close = ff_aac_decode_close, @@ -508,7 +508,6 @@ const FFCodec ff_aac_fixed_decoder = { .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.ch_layouts = ff_aac_ch_layout, - .p.priv_class = &aac_decoder_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), .flush = flush, }; diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 1d1be6306d..8ee62f7764 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -3400,35 +3400,3 @@ static void aacdec_init(AACDecContext *c) #endif #endif /* !USE_FIXED */ } -/** - * AVOptions for Japanese DTV specific extensions (ADTS only) - */ -#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM -#define OFF(field) offsetof(AACDecContext, field) -static const AVOption options[] = { - {"dual_mono_mode", "Select the channel to decode for dual mono", - OFF(force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, - AACDEC_FLAGS, .unit = "dual_mono_mode"}, - - {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, - {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, - {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, - {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"}, - - { "channel_order", "Order in which the channels are to be exported", - OFF(output_channel_order), AV_OPT_TYPE_INT, - { .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, AACDEC_FLAGS, .unit = "channel_order" }, - { "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST, - { .i64 = CHANNEL_ORDER_DEFAULT }, .flags = AACDEC_FLAGS, .unit = "channel_order" }, - { "coded", "order in which the channels are coded in the bitstream", - 0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, .unit = "channel_order" }, - - {NULL}, -}; - -static const AVClass aac_decoder_class = { - .class_name = "AAC decoder", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; -- 2.43.0.381.gb435a96ce8