[MPlayer-cvslog] r37195 - in trunk: libmpcodecs/ae_lame.c libmpcodecs/ae_twolame.c mencoder.c
reimar
subversion at mplayerhq.hu
Sat May 10 21:59:40 CEST 2014
Author: reimar
Date: Sat May 10 21:59:40 2014
New Revision: 37195
Log:
mencoder: Support flushing audio encoders at end of stream.
Modified:
trunk/libmpcodecs/ae_lame.c
trunk/libmpcodecs/ae_twolame.c
trunk/mencoder.c
Modified: trunk/libmpcodecs/ae_lame.c
==============================================================================
--- trunk/libmpcodecs/ae_lame.c Sat May 10 21:59:38 2014 (r37194)
+++ trunk/libmpcodecs/ae_lame.c Sat May 10 21:59:40 2014 (r37195)
@@ -136,7 +136,9 @@ static int get_frame_size(audio_encoder_
static int encode_lame(audio_encoder_t *encoder, uint8_t *dest, void *src, int len, int max_size)
{
int n = 0;
- if(encoder->params.channels == 1)
+ if (!src)
+ n = lame_encode_flush(lame, dest, max_size);
+ else if (encoder->params.channels == 1)
n = lame_encode_buffer(lame, (short *)src, (short *)src, len/2, dest, max_size);
else
n = lame_encode_buffer_interleaved(lame,(short *)src, len/4, dest, max_size);
Modified: trunk/libmpcodecs/ae_twolame.c
==============================================================================
--- trunk/libmpcodecs/ae_twolame.c Sat May 10 21:59:38 2014 (r37194)
+++ trunk/libmpcodecs/ae_twolame.c Sat May 10 21:59:40 2014 (r37195)
@@ -112,6 +112,9 @@ static int encode_twolame(audio_encoder_
mpae_twolame_ctx *ctx = encoder->priv;
int ret_size = 0, r2;
+ if (!src)
+ return twolame_encode_flush(ctx->twolame_ctx, dest, max_size);
+
len /= (2*encoder->params.channels);
ret_size = twolame_encode_buffer_interleaved(ctx->twolame_ctx, src, len, dest, max_size);
r2 = mp_decode_mp3_header(dest);
Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c Sat May 10 21:59:38 2014 (r37194)
+++ trunk/mencoder.c Sat May 10 21:59:40 2014 (r37195)
@@ -1340,7 +1340,7 @@ if(sh_audio){
len = dec_audio(sh_audio, aencoder->decode_buffer, len);
mux_a->buffer_len += aencoder->encode(aencoder, mux_a->buffer + mux_a->buffer_len,
- aencoder->decode_buffer, len, mux_a->buffer_size-mux_a->buffer_len);
+ len <= 0 && sh_audio->ds->eof ? NULL : aencoder->decode_buffer, len, mux_a->buffer_size-mux_a->buffer_len);
if(mux_a->buffer_len < mux_a->wf->nBlockAlign)
len = 0;
else
@@ -1362,10 +1362,13 @@ if(sh_audio){
len = dec_audio(sh_audio,aencoder->decode_buffer, aencoder->decode_buffer_size);
if(len <= 0)
{
- len = 0;
- break;
- }
- len = aencoder->encode(aencoder, mux_a->buffer + mux_a->buffer_len, aencoder->decode_buffer, len, mux_a->buffer_size-mux_a->buffer_len);
+ // try flushing encoder
+ if (sh_audio->ds->eof)
+ len = aencoder->encode(aencoder, mux_a->buffer + mux_a->buffer_len, NULL, 0, mux_a->buffer_size-mux_a->buffer_len);
+ if (len <= 0)
+ break;
+ } else
+ len = aencoder->encode(aencoder, mux_a->buffer + mux_a->buffer_len, aencoder->decode_buffer, len, mux_a->buffer_size-mux_a->buffer_len);
mux_a->buffer_len += len;
}
}
More information about the MPlayer-cvslog
mailing list