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
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 */30 */
31 31
32#include <limits.h>
33#include <stddef.h>
34
32#include "libavcodec/aacsbr.h"35#include "libavcodec/aacsbr.h"
33#include "libavcodec/aacdec.h"36#include "libavcodec/aacdec.h"
34#include "libavcodec/avcodec.h"37#include "libavcodec/avcodec.h"
35#include "libavutil/attributes.h"38#include "libavutil/attributes.h"
39#include "libavutil/log.h"
36#include "libavutil/macros.h"40#include "libavutil/macros.h"
37#include "libavutil/mem.h"41#include "libavutil/mem.h"
42#include "libavutil/opt.h"
38#include "libavutil/tx.h"43#include "libavutil/tx.h"
44#include "libavutil/version.h"
39 45
40av_cold int ff_aac_decode_close(AVCodecContext *avctx)46av_cold int ff_aac_decode_close(AVCodecContext *avctx)
41{47{
@@ -69,3 +75,36 @@ av_cold int ff_aac_decode_close(AVCodecContext *avctx) · 27 unmodified lines
69 75
70 return 0;76 return 0;
71}77}
78
79#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
80#define OFF(field) offsetof(AACDecContext, field)
81static 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
105const 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
36#define TX_TYPE AV_TX_FLOAT_MDCT36#define TX_TYPE AV_TX_FLOAT_MDCT
37 37
38#include "libavutil/float_dsp.h"38#include "libavutil/float_dsp.h"
39#include "libavutil/mem.h"
40#include "libavutil/opt.h"
41#include "avcodec.h"39#include "avcodec.h"
42#include "codec_internal.h"40#include "codec_internal.h"
43#include "get_bits.h"41#include "get_bits.h"
@@ -555,6 +553,7 @@ const FFCodec ff_aac_decoder = { · 511 unmodified lines
555 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),553 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),
556 .p.type = AVMEDIA_TYPE_AUDIO,554 .p.type = AVMEDIA_TYPE_AUDIO,
557 .p.id = AV_CODEC_ID_AAC,555 .p.id = AV_CODEC_ID_AAC,
556 .p.priv_class = &ff_aac_decoder_class,
558 .priv_data_size = sizeof(AACDecContext),557 .priv_data_size = sizeof(AACDecContext),
559 .init = aac_decode_init,558 .init = aac_decode_init,
560 .close = ff_aac_decode_close,559 .close = ff_aac_decode_close,
@@ -566,7 +565,6 @@ const FFCodec ff_aac_decoder = { · 5 unmodified lines
566 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,565 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
567 .p.ch_layouts = ff_aac_ch_layout,566 .p.ch_layouts = ff_aac_ch_layout,
568 .flush = flush,567 .flush = flush,
569 .p.priv_class = &aac_decoder_class,
570 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),568 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
571};569};
572 570
libavcodec/aacdec.h+2−0
@@ -304,6 +304,8 @@ typedef struct AACDecContext { · 303 unmodified lines
304#define fdsp RENAME_FIXED(fdsp)304#define fdsp RENAME_FIXED(fdsp)
305#endif305#endif
306 306
307extern const struct AVClass ff_aac_decoder_class;
308
307int ff_aac_decode_close(struct AVCodecContext *avctx);309int ff_aac_decode_close(struct AVCodecContext *avctx);
308 310
309void ff_aacdec_init_mips(AACDecContext *c);311void ff_aacdec_init_mips(AACDecContext *c);
libavcodec/aacdec_fixed.c+1−2
@@ -62,7 +62,6 @@ · 61 unmodified lines
62#define TX_TYPE AV_TX_INT32_MDCT62#define TX_TYPE AV_TX_INT32_MDCT
63 63
64#include "libavutil/fixed_dsp.h"64#include "libavutil/fixed_dsp.h"
65#include "libavutil/opt.h"
66#include "avcodec.h"65#include "avcodec.h"
67#include "codec_internal.h"66#include "codec_internal.h"
68#include "get_bits.h"67#include "get_bits.h"
@@ -498,6 +497,7 @@ const FFCodec ff_aac_fixed_decoder = { · 429 unmodified lines
498 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),497 CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),
499 .p.type = AVMEDIA_TYPE_AUDIO,498 .p.type = AVMEDIA_TYPE_AUDIO,
500 .p.id = AV_CODEC_ID_AAC,499 .p.id = AV_CODEC_ID_AAC,
500 .p.priv_class = &ff_aac_decoder_class,
501 .priv_data_size = sizeof(AACDecContext),501 .priv_data_size = sizeof(AACDecContext),
502 .init = aac_decode_init,502 .init = aac_decode_init,
503 .close = ff_aac_decode_close,503 .close = ff_aac_decode_close,
@@ -508,7 +508,6 @@ const FFCodec ff_aac_fixed_decoder = { · 4 unmodified lines
508 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1,508 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1,
509 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,509 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
510 .p.ch_layouts = ff_aac_ch_layout,510 .p.ch_layouts = ff_aac_ch_layout,
511 .p.priv_class = &aac_decoder_class,
512 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),511 .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
513 .flush = flush,512 .flush = flush,
514};513};
libavcodec/aacdec_template.c+0−32
@@ -3401,35 +3401,3 @@ static void aacdec_init(AACDecContext *c) · 3400 unmodified lines
3401#endif3401#endif
3402#endif /* !USE_FIXED */3402#endif /* !USE_FIXED */
3403}3403}
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)
3409static 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
3430static 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