1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

ac3dec: add a drc_scale private option

Deprecate corresponding AVCodecContext option.

This is the first test of decoder private options.
This commit is contained in:
Anton Khirnov 2011-05-20 22:37:59 +02:00
parent a67c061e0f
commit 9b83919f44
5 changed files with 28 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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},

View File

@ -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 */