27 #include <lame/lame.h>
41 #define BUFFER_SIZE (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4+1000) // FIXME: Buffer size to small? Adding 1000 to make up for it.
46 lame_global_flags *
gfp;
97 if ((s->
gfp = lame_init()) == NULL)
110 lame_set_quality(s->
gfp, 5);
116 lame_set_VBR(s->
gfp, vbr_default);
121 lame_set_VBR(s->
gfp, vbr_abr);
122 lame_set_VBR_mean_bitrate_kbps(s->
gfp, avctx->
bit_rate / 1000);
129 lame_set_bWriteVbrTag(s->
gfp,0);
135 if (lame_init_params(s->
gfp) < 0) {
141 avctx->
delay = lame_get_encoder_delay(s->
gfp) + 528 + 1;
149 for (ch = 0; ch < avctx->
channels; ch++) {
171 #define ENCODE_BUFFER(func, buf_type, buf_name) do { \
172 lame_result = func(s->gfp, \
173 (const buf_type *)buf_name[0], \
174 (const buf_type *)buf_name[1], frame->nb_samples, \
175 s->buffer + s->buffer_index, \
176 s->buffer_size - s->buffer_index); \
201 for (ch = 0; ch < avctx->
channels; ch++) {
203 (
const float *)frame->
data[ch],
218 if (lame_result < 0) {
219 if (lame_result == -1) {
221 "lame: output buffer too small (buffer index: %d, free bytes: %d)\n",
253 len = hdr.frame_size;
256 if (len <= s->buffer_index) {
273 #define OFFSET(x) offsetof(LAMEContext, x)
274 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
295 44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000, 0
299 .
name =
"libmp3lame",