[FFmpeg-cvslog] ac3dec: add a drc_scale private option

Anton Khirnov git at videolan.org
Mon Jul 11 05:52:39 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri May 20 22:37:59 2011 +0200| [9b83919f44eb1c87dc9431112944f0cccf6a599f] | committer: Anton Khirnov

ac3dec: add a drc_scale private option

Deprecate corresponding AVCodecContext option.

This is the first test of decoder private options.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b83919f44eb1c87dc9431112944f0cccf6a599f
---

 libavcodec/ac3dec.c  |   17 +++++++++++++++++
 libavcodec/ac3dec.h  |    2 ++
 libavcodec/avcodec.h |    5 ++++-
 libavcodec/options.c |    2 ++
 libavcodec/version.h |    3 +++
 5 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 42b62ef..663acc0 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 aed8743..a7cebaf 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 ba0c636..7c7a0c6 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 ae9e0c9..545887a 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 f4a0ecd..7e4c02d 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 */



More information about the ffmpeg-cvslog mailing list