summaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-05-25 22:20:39 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-05-25 22:20:39 +0000
commit0871ae1a930122f7124358a0ce3caf81876913a9 (patch)
tree8626d4af558891862dcd1ecc81cb1d949355eb3e /ffmpeg.c
parent46eab09341d3496ad680bb1bf609ea38c7deea66 (diff)
downloadffmpeg-streaming-0871ae1a930122f7124358a0ce3caf81876913a9.zip
ffmpeg-streaming-0871ae1a930122f7124358a0ce3caf81876913a9.tar.gz
Make av_fifo*_read() ignore the available amount of data.
This is more efficient as in practice the check is redundant most of the time. Callers which do not know if enough data is available have to check it with av_fifo_size(). Doing the check in *read() means the caller has no choice to skip the check when its known to be redundant. Also the return value was never documented in a public header so changing it should not break the API. Besides this fixes the case where read() failed on a 100% full fifo. Originally committed as revision 13404 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index dc53f34..5449279 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -592,10 +592,12 @@ static void do_audio_out(AVFormatContext *s,
frame_bytes = enc->frame_size * 2 * enc->channels;
- while (av_fifo_read(&ost->fifo, audio_buf, frame_bytes) == 0) {
+ while (av_fifo_size(&ost->fifo) >= frame_bytes) {
AVPacket pkt;
av_init_packet(&pkt);
+ av_fifo_read(&ost->fifo, audio_buf, frame_bytes);
+
//FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
ret = avcodec_encode_audio(enc, audio_out, audio_out_size,
@@ -1385,9 +1387,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
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(av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes) == 0) {
+ av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes);
ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
- }
enc->frame_size = fs_tmp;
}
if(ret <= 0) {
OpenPOWER on IntegriCloud