summaryrefslogtreecommitdiff
path: root/libavcodec/libmp3lame.c
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 /libavcodec/libmp3lame.c
parent88262ca87df1054209ef6db255b521e412fd78fc (diff)
libmp3lame: add 'reservoir' private option.
Deprecate CODEC_FLAG2_BIT_RESERVOIR
Diffstat (limited to 'libavcodec/libmp3lame.c')
-rw-r--r--libavcodec/libmp3lame.c23
1 files changed, 22 insertions, 1 deletions
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,
};