提交 9b83919f 编写于 作者: A Anton Khirnov

ac3dec: add a drc_scale private option

Deprecate corresponding AVCodecContext option.

This is the first test of decoder private options.
上级 a67c061e
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include "libavutil/crc.h" #include "libavutil/crc.h"
#include "libavutil/opt.h"
#include "internal.h" #include "internal.h"
#include "aac_ac3_parser.h" #include "aac_ac3_parser.h"
#include "ac3_parser.h" #include "ac3_parser.h"
...@@ -1440,6 +1441,20 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx) ...@@ -1440,6 +1441,20 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
return 0; 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 = { AVCodec ff_ac3_decoder = {
.name = "ac3", .name = "ac3",
.type = AVMEDIA_TYPE_AUDIO, .type = AVMEDIA_TYPE_AUDIO,
...@@ -1452,6 +1467,7 @@ AVCodec ff_ac3_decoder = { ...@@ -1452,6 +1467,7 @@ AVCodec ff_ac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) { .sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
}, },
.priv_class = &ac3_decoder_class,
}; };
#if CONFIG_EAC3_DECODER #if CONFIG_EAC3_DECODER
...@@ -1467,5 +1483,6 @@ AVCodec ff_eac3_decoder = { ...@@ -1467,5 +1483,6 @@ AVCodec ff_eac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) { .sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
}, },
.priv_class = &ac3_decoder_class,
}; };
#endif #endif
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#define SPX_MAX_BANDS 17 #define SPX_MAX_BANDS 17
typedef struct { typedef struct {
AVClass *class; ///< class for AVOptions
AVCodecContext *avctx; ///< parent context AVCodecContext *avctx; ///< parent context
GetBitContext gbc; ///< bitstream reader GetBitContext gbc; ///< bitstream reader
uint8_t *input_buffer; ///< temp buffer to prevent overread uint8_t *input_buffer; ///< temp buffer to prevent overread
...@@ -141,6 +142,7 @@ typedef struct { ...@@ -141,6 +142,7 @@ typedef struct {
///@name Dynamic range ///@name Dynamic range
float dynamic_range[2]; ///< dynamic range float dynamic_range[2]; ///< dynamic range
float drc_scale; ///< percentage of dynamic range compression to be applied
///@} ///@}
///@name Bandwidth ///@name Bandwidth
......
...@@ -2544,13 +2544,16 @@ typedef struct AVCodecContext { ...@@ -2544,13 +2544,16 @@ typedef struct AVCodecContext {
int request_channels; int request_channels;
#endif #endif
#if FF_API_DRC_SCALE
/** /**
* Percentage of dynamic range compression to be applied by the decoder. * Percentage of dynamic range compression to be applied by the decoder.
* The default value is 1.0, corresponding to full compression. * The default value is 1.0, corresponding to full compression.
* - encoding: unused * - encoding: unused
* - decoding: Set by user. * - 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 * opaque 64bit number (generally a PTS) that will be reordered and
......
...@@ -413,7 +413,9 @@ static const AVOption options[]={ ...@@ -413,7 +413,9 @@ static const AVOption options[]={
#if FF_API_REQUEST_CHANNELS #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}, {"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D},
#endif #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}, {"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"}, {"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"}, {"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}, {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
......
...@@ -71,5 +71,8 @@ ...@@ -71,5 +71,8 @@
#ifndef FF_API_AVCODEC_OPEN #ifndef FF_API_AVCODEC_OPEN
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54) #define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54)
#endif #endif
#ifndef FF_API_DRC_SCALE
#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册