diff options
author | Justin Ruggles <jruggle@earthlink.net> | 2006-06-24 09:25:21 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-06-24 09:25:21 +0000 |
commit | cef7cc72321670a37b758cb9a3382ddf609876aa (patch) | |
tree | 8c13d71407b8570c9597fad83d040e988195450a /ffmpeg.c | |
parent | a66d63a94e0ad40646731886ce47e135a7154634 (diff) | |
download | ffmpeg-cef7cc72321670a37b758cb9a3382ddf609876aa.tar.gz |
CODEC_CAP_SMALL_LAST_FRAME patch by Justin Ruggles jruggle earthlink net
Originally committed as revision 5512 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -1358,12 +1358,29 @@ static int output_packet(AVInputStream *ist, int ist_index, if (ost->encoding_needed) { for(;;) { AVPacket pkt; + int fifo_bytes; av_init_packet(&pkt); pkt.stream_index= ost->index; switch(ost->st->codec->codec_type) { case CODEC_TYPE_AUDIO: - ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL); + fifo_bytes = fifo_size(&ost->fifo, NULL); + ret = 0; + /* encode any samples remaining in fifo */ + if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { + int fs_tmp = enc->frame_size; + enc->frame_size = fifo_bytes / (2 * enc->channels); + if(fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes, + &ost->fifo.rptr) == 0) { + ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples); + } + enc->frame_size = fs_tmp; + if(ret <= 0) { + ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL); + } + } else { + ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL); + } audio_size += ret; pkt.flags |= PKT_FLAG_KEY; break; |