summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-05-20 22:37:59 +0200
committerAnton Khirnov <anton@khirnov.net>2011-07-10 17:07:12 +0200
commit9b83919f44eb1c87dc9431112944f0cccf6a599f (patch)
treed5dc047b684367ed16ec2124467bc4fc315dec04
parenta67c061e0f3b55ffcc96f336fc0998e44b86c8e4 (diff)
downloadffmpeg-9b83919f44eb1c87dc9431112944f0cccf6a599f.tar.gz
ac3dec: add a drc_scale private option
Deprecate corresponding AVCodecContext option. This is the first test of decoder private options.
-rw-r--r--libavcodec/ac3dec.c17
-rw-r--r--libavcodec/ac3dec.h2
-rw-r--r--libavcodec/avcodec.h5
-rw-r--r--libavcodec/options.c2
-rw-r--r--libavcodec/version.h3
5 files changed, 28 insertions, 1 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 42b62ef701..663acc0ac9 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,20 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
return 0;
}
+#define OFFSET(x) offsetof(AC3DecodeContext, x)
+#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
+static const AVOption options[] = {
+ { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {1.0}, 0.0, 1.0, PAR },
+ { NULL},
+};
+
+static const AVClass ac3_decoder_class = {
+ .class_name = "(E-)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 +1467,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 +1483,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 aed87432f5..a7cebafbe9 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 {
///@name Dynamic range
float dynamic_range[2]; ///< dynamic range
+ float drc_scale; ///< percentage of dynamic range compression to be applied
///@}
///@name Bandwidth
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ba0c636292..7c7a0c6a97 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2544,13 +2544,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 ae9e0c902d..545887a7c1 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 f4a0ecd868..7e4c02d91e 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -71,5 +71,8 @@
#ifndef FF_API_AVCODEC_OPEN
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_DRC_SCALE
+#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
#endif /* AVCODEC_VERSION_H */