summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-05-23 04:07:25 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-05-23 04:07:25 +0000
commitb10d7e4e3afd21d10bd53d3c839cf3eb151c63d7 (patch)
treef5c5aef003cf0af7fdbd13f6676df2f10f79cf8c /ffmpeg.c
parentc43accabd3eb1936bce242346237b9660cc7fd31 (diff)
pad last audio frame when encoding
Originally committed as revision 18907 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index f2c1e79329..6c8923da39 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1464,11 +1464,20 @@ static int output_packet(AVInputStream *ist, int ist_index,
fifo_bytes = av_fifo_size(ost->fifo);
ret = 0;
/* encode any samples remaining in fifo */
- if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
+ if (fifo_bytes > 0) {
int osize = av_get_bits_per_sample_format(enc->sample_fmt) >> 3;
int fs_tmp = enc->frame_size;
- enc->frame_size = fifo_bytes / (osize * enc->channels);
+
av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL);
+ if (enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
+ enc->frame_size = fifo_bytes / (osize * enc->channels);
+ } else { /* pad */
+ int frame_bytes = enc->frame_size*osize*enc->channels;
+ if (samples_size < frame_bytes)
+ av_exit(1);
+ memset((uint8_t*)samples+fifo_bytes, 0, frame_bytes - fifo_bytes);
+ }
+
ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,
ost->st->time_base.num, enc->sample_rate);