History

avcodec/aacdec_template: Deduplicate AVClass+AVOptions

Andreas Rheinhardt committed 2 years ago

Commit 980a55f1 parent e3693c65 files · +43 −37Browse files

Unified · Split

5 files
  1. libavcodec/aac/aacdec.c +39 −0
  2. libavcodec/aacdec.c +1 −3
  3. libavcodec/aacdec.h +2 −0
  4. libavcodec/aacdec_fixed.c +1 −2
  5. libavcodec/aacdec_template.c +0 −32
libavcodec/aac/aacdec.c+39−0
@@ -29,13 +29,19 @@ · 28 unmodified lines
2929 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3030 */
3131
32+#include <limits.h>
33+#include <stddef.h>
34+
3235 #include "libavcodec/aacsbr.h"
3336 #include "libavcodec/aacdec.h"
3437 #include "libavcodec/avcodec.h"
3538 #include "libavutil/attributes.h"
39+#include "libavutil/log.h"
3640 #include "libavutil/macros.h"
3741 #include "libavutil/mem.h"
42+#include "libavutil/opt.h"
3843 #include "libavutil/tx.h"
44+#include "libavutil/version.h"
3945
4046 av_cold int ff_aac_decode_close(AVCodecContext *avctx)
4147 {
@@ -69,3 +75,36 @@ av_cold int ff_aac_decode_close(AVCodecContext *avctx) · 27 unmodified lines
6975
7076 return 0;
7177 }
78+
79+#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
80+#define OFF(field) offsetof(AACDecContext, field)
81+static const AVOption options[] = {
82+ /**
83+ * AVOptions for Japanese DTV specific extensions (ADTS only)
84+ */
85+ {"dual_mono_mode", "Select the channel to decode for dual mono",
86+ OFF(force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2,
87+ AACDEC_FLAGS, .unit = "dual_mono_mode"},
88+
89+ {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
90+ {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
91+ {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
92+ {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
93+
94+ { "channel_order", "Order in which the channels are to be exported",
95+ OFF(output_channel_order), AV_OPT_TYPE_INT,
96+ { .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, AACDEC_FLAGS, .unit = "channel_order" },
97+ { "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST,
98+ { .i64 = CHANNEL_ORDER_DEFAULT }, .flags = AACDEC_FLAGS, .unit = "channel_order" },
99+ { "coded", "order in which the channels are coded in the bitstream",
100+ 0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, .unit = "channel_order" },
101+
102+ {NULL},
103+};
104+
105+const AVClass ff_aac_decoder_class = {
106+ .class_name = "AAC decoder",
107+ .item_name = av_default_item_name,
108+ .option = options,
109+ .version = LIBAVUTIL_VERSION_INT,
110+};
libavcodec/aacdec.c+1−3
@@ -36,8 +36,6 @@ · 35 unmodified lines
3636 #define TX_TYPE AV_TX_FLOAT_MDCT
3737
3838 #include "libavutil/float_dsp.h"
39−#include "libavutil/mem.h"
40−#include "libavutil/opt.h"
4139 #include "avcodec.h"
4240 #include "codec_internal.h"
4341 #include "get_bits.h"
@@ -555,6 +553,7 @@ const FFCodec ff_aac_decoder = { · 511 unmodified lines
555553 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),
556554 .p.type = AVMEDIA_TYPE_AUDIO,
557555 .p.id = AV_CODEC_ID_AAC,
556+ .p.priv_class = &ff_aac_decoder_class,
558557 .priv_data_size = sizeof(AACDecContext),
559558 .init = aac_decode_init,
560559 .close = ff_aac_decode_close,
@@ -566,7 +565,6 @@ const FFCodec ff_aac_decoder = { · 5 unmodified lines
566565 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
567566 .p.ch_layouts = ff_aac_ch_layout,
568567 .flush = flush,
569− .p.priv_class = &aac_decoder_class,
570568 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
571569 };
572570
libavcodec/aacdec.h+2−0
@@ -304,6 +304,8 @@ typedef struct AACDecContext { · 303 unmodified lines
304304 #define fdsp RENAME_FIXED(fdsp)
305305 #endif
306306
307+extern const struct AVClass ff_aac_decoder_class;
308+
307309 int ff_aac_decode_close(struct AVCodecContext *avctx);
308310
309311 void ff_aacdec_init_mips(AACDecContext *c);
libavcodec/aacdec_fixed.c+1−2
@@ -62,7 +62,6 @@ · 61 unmodified lines
6262 #define TX_TYPE AV_TX_INT32_MDCT
6363
6464 #include "libavutil/fixed_dsp.h"
65−#include "libavutil/opt.h"
6665 #include "avcodec.h"
6766 #include "codec_internal.h"
6867 #include "get_bits.h"
@@ -498,6 +497,7 @@ const FFCodec ff_aac_fixed_decoder = { · 429 unmodified lines
498497 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),
499498 .p.type = AVMEDIA_TYPE_AUDIO,
500499 .p.id = AV_CODEC_ID_AAC,
500+ .p.priv_class = &ff_aac_decoder_class,
501501 .priv_data_size = sizeof(AACDecContext),
502502 .init = aac_decode_init,
503503 .close = ff_aac_decode_close,
@@ -508,7 +508,6 @@ const FFCodec ff_aac_fixed_decoder = { · 4 unmodified lines
508508 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1,
509509 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
510510 .p.ch_layouts = ff_aac_ch_layout,
511− .p.priv_class = &aac_decoder_class,
512511 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
513512 .flush = flush,
514513 };
libavcodec/aacdec_template.c+0−32
@@ -3401,35 +3401,3 @@ static void aacdec_init(AACDecContext *c) · 3400 unmodified lines
34013401 #endif
34023402 #endif /* !USE_FIXED */
34033403 }
3404−/**
3405− * AVOptions for Japanese DTV specific extensions (ADTS only)
3406− */
3407−#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
3408−#define OFF(field) offsetof(AACDecContext, field)
3409−static const AVOption options[] = {
3410− {"dual_mono_mode", "Select the channel to decode for dual mono",
3411− OFF(force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2,
3412− AACDEC_FLAGS, .unit = "dual_mono_mode"},
3413−
3414− {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
3415− {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
3416− {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
3417− {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, .unit = "dual_mono_mode"},
3418−
3419− { "channel_order", "Order in which the channels are to be exported",
3420− OFF(output_channel_order), AV_OPT_TYPE_INT,
3421− { .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, AACDEC_FLAGS, .unit = "channel_order" },
3422− { "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST,
3423− { .i64 = CHANNEL_ORDER_DEFAULT }, .flags = AACDEC_FLAGS, .unit = "channel_order" },
3424− { "coded", "order in which the channels are coded in the bitstream",
3425− 0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, .unit = "channel_order" },
3426−
3427− {NULL},
3428−};
3429−
3430−static const AVClass aac_decoder_class = {
3431− .class_name = "AAC decoder",
3432− .item_name = av_default_item_name,
3433− .option = options,
3434− .version = LIBAVUTIL_VERSION_INT,
3435−};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t