Revision 0871ae1a

View differences:

ffmpeg.c
592 592

  
593 593
        frame_bytes = enc->frame_size * 2 * enc->channels;
594 594

  
595
        while (av_fifo_read(&ost->fifo, audio_buf, frame_bytes) == 0) {
595
        while (av_fifo_size(&ost->fifo) >= frame_bytes) {
596 596
            AVPacket pkt;
597 597
            av_init_packet(&pkt);
598 598

  
599
            av_fifo_read(&ost->fifo, audio_buf, frame_bytes);
600

  
599 601
            //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
600 602

  
601 603
            ret = avcodec_encode_audio(enc, audio_out, audio_out_size,
......
1385 1387
                            if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
1386 1388
                                int fs_tmp = enc->frame_size;
1387 1389
                                enc->frame_size = fifo_bytes / (2 * enc->channels);
1388
                                if(av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes) == 0) {
1390
                                av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes);
1389 1391
                                    ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
1390
                                }
1391 1392
                                enc->frame_size = fs_tmp;
1392 1393
                            }
1393 1394
                            if(ret <= 0) {
libavformat/mpegenc.c
913 913
        }
914 914

  
915 915
        /* output data */
916
        if(av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb) < 0)
917
            return -1;
916
        assert(payload_size - stuffing_size <= av_fifo_size(&stream->fifo));
917
        av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb);
918 918
        stream->bytes_to_iframe -= payload_size - stuffing_size;
919 919
    }else{
920 920
        payload_size=
libavutil/fifo.c
45 45
    return size;
46 46
}
47 47

  
48
/**
49
 * Get data from the fifo (returns -1 if not enough data).
50
 */
51 48
int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
52 49
{
53 50
    return av_fifo_generic_read(f, buf_size, NULL, buf);
......
97 94
}
98 95

  
99 96

  
100
/** get data from the fifo (return -1 if not enough data) */
101 97
int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
102 98
{
103
    int size = av_fifo_size(f);
104

  
105
    if (size < buf_size)
106
        return -1;
107 99
    do {
108 100
        int len = FFMIN(f->end - f->rptr, buf_size);
109 101
        if(func) func(dest, f->rptr, len);

Also available in: Unified diff