Deprecate corresponding AVCodecContext option.
This is the first test of decoder private options.
---
libavcodec/ac3dec.c | 15 +++++++++++++++
libavcodec/ac3dec.h | 2 ++
libavcodec/avcodec.h | 5 ++++-
libavcodec/options.c | 2 ++
libavcodec/version.h | 3 +++
5 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 2966c33..04ffc36 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "libavutil/crc.h"
+#include "libavutil/opt.h"
#include "internal.h"
#include "aac_ac3_parser.h"
#include "ac3_parser.h"
@@ -1440,6 +1441,18 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
return 0;
}
+static const AVOption options[] = {
+ { "drc_scale", "percentage of dynamic range compression to apply",
offsetof(AC3DecodeContext, drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0.0,
1.0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
+ { NULL},
+};
+
+static const AVClass ac3_decoder_class = {
+ .class_name = "AC3 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_ac3_decoder = {
.name = "ac3",
.type = AVMEDIA_TYPE_AUDIO,
@@ -1452,6 +1465,7 @@ AVCodec ff_ac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
+ .priv_class = &ac3_decoder_class,
};
#if CONFIG_EAC3_DECODER
@@ -1467,5 +1481,6 @@ AVCodec ff_eac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
+ .priv_class = &ac3_decoder_class,
};
#endif
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index f0ab75a..70ba06a 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -63,6 +63,7 @@
#define SPX_MAX_BANDS 17
typedef struct {
+ AVClass *class; ///< class for AVOptions
AVCodecContext *avctx; ///< parent context
GetBitContext gbc; ///< bitstream reader
uint8_t *input_buffer; ///< temp buffer to prevent
overread
@@ -141,6 +142,7 @@ typedef struct {
///@defgroup dynrng dynamic range
float dynamic_range[2]; ///< dynamic range
+ float drc_scale; ///< percentage of dynamic range
compression to be applied
///@}
///@defgroup bandwidth bandwidth
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a97f1f9..b0f07ce 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2541,13 +2541,16 @@ typedef struct AVCodecContext {
int request_channels;
#endif
+#if FF_API_DRC_SCALE
/**
* Percentage of dynamic range compression to be applied by the decoder.
* The default value is 1.0, corresponding to full compression.
* - encoding: unused
* - decoding: Set by user.
+ * @deprecated use AC3 decoder private option instead.
*/
- float drc_scale;
+ attribute_deprecated float drc_scale;
+#endif
/**
* opaque 64bit number (generally a PTS) that will be reordered and
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 58292d7..17a3037 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -413,7 +413,9 @@ static const AVOption options[]={
#if FF_API_REQUEST_CHANNELS
{"request_channels", "set desired number of audio channels",
OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D},
#endif
+#if FF_API_DRC_SCALE
{"drc_scale", "percentage of dynamic range compression to apply",
OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0.0, 1.0, A|D},
+#endif
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl =
CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"},
{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0,
FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E,
"flags2"},
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT,
{.dbl = DEFAULT }, INT_MIN, INT_MAX},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0def0d1..20b1725 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -65,5 +65,8 @@
#ifndef FF_API_FLAC_GLOBAL_OPTS
#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_DRC_SCALE
+#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
#endif /* AVCODEC_VERSION_H */
--
1.7.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel