aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-08-27 10:09:09 +0200
committerAnton Khirnov <anton@khirnov.net>2011-08-31 13:22:53 +0200
commita7cec3a09407f7cf494d84549665d242ad31fc4e (patch)
tree606eb8118105df7196ba9c4dc9118dda4e6fc8d1
parent88262ca87df1054209ef6db255b521e412fd78fc (diff)
downloadffmpeg-a7cec3a09407f7cf494d84549665d242ad31fc4e.tar.gz
libmp3lame: add 'reservoir' private option.
Deprecate CODEC_FLAG2_BIT_RESERVOIR
-rw-r--r--libavcodec/avcodec.h2
-rw-r--r--libavcodec/libmp3lame.c23
-rw-r--r--libavcodec/options.c2
-rw-r--r--libavcodec/version.h3
4 files changed, 29 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f8a8006c89..64226835c2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -628,7 +628,9 @@ typedef struct RcOverride{
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#endif
+#if FF_API_LAME_GLOBAL_OPTS
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
+#endif
#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
#if FF_API_X264_GLOBAL_OPTS
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index 2eeb97d827..b46ce42fb0 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -25,16 +25,20 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "mpegaudio.h"
#include <lame/lame.h>
#define BUFFER_SIZE (7200 + 2*MPA_FRAME_SIZE + MPA_FRAME_SIZE/4)
typedef struct Mp3AudioContext {
+ AVClass *class;
lame_global_flags *gfp;
int stereo;
uint8_t buffer[BUFFER_SIZE];
int buffer_index;
+ int reservoir;
} Mp3AudioContext;
static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
@@ -64,7 +68,10 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA);
}
lame_set_bWriteVbrTag(s->gfp,0);
- lame_set_disable_reservoir(s->gfp, avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR ? 0 : 1);
+#if FF_API_LAME_GLOBAL_OPTIONS
+ s->reservoir = avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR;
+#endif
+ lame_set_disable_reservoir(s->gfp, !s->reservoir);
if (lame_init_params(s->gfp) < 0)
goto err_close;
@@ -213,6 +220,19 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx)
return 0;
}
+#define OFFSET(x) offsetof(Mp3AudioContext, x)
+#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "reservoir", "Use bit reservoir.", OFFSET(reservoir), FF_OPT_TYPE_INT, { 1 }, 0, 1, AE },
+ { NULL },
+};
+
+static const AVClass libmp3lame_class = {
+ .class_name = "libmp3lame encoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
AVCodec ff_libmp3lame_encoder = {
.name = "libmp3lame",
@@ -226,4 +246,5 @@ AVCodec ff_libmp3lame_encoder = {
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.supported_samplerates= sSampleRates,
.long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
+ .priv_class = &libmp3lame_class,
};
diff --git a/libavcodec/options.c b/libavcodec/options.c
index b9918819b1..1344a89c6a 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -431,7 +431,9 @@ static const AVOption options[]={
#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
+#if FF_API_LAME_GLOBAL_OPTS
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"},
+#endif
{"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},
{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 928513f002..0de224bda4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -89,5 +89,8 @@
#ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS
#define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_LAME_GLOBAL_OPTS
+#define FF_API_LAME_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
#endif /* AVCODEC_VERSION_H */