Revision f5a478f6 libavformat/gxfenc.c

View differences:

libavformat/gxfenc.c
20 20
#include "avformat.h"
21 21
#include "gxf.h"
22 22
#include "riff.h"
23
#include "fifo.h"
23 24

  
24 25
#define GXF_AUDIO_PACKET_SIZE 65536
25 26

  
26 27
typedef struct GXFStreamContext {
27 28
    AVCodecContext *codec;
28
    FifoBuffer audio_buffer;
29
    AVFifoBuffer audio_buffer;
29 30
    uint32_t track_type;
30 31
    uint32_t sample_size;
31 32
    uint32_t sample_rate;
......
604 605
            sc->fields = -2;
605 606
            gxf->audio_tracks++;
606 607
            gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
607
            fifo_init(&sc->audio_buffer, 3*GXF_AUDIO_PACKET_SIZE);
608
            av_fifo_init(&sc->audio_buffer, 3*GXF_AUDIO_PACKET_SIZE);
608 609
        } else if (sc->codec->codec_type == CODEC_TYPE_VIDEO) {
609 610
            /* FIXME check from time_base ? */
610 611
            if (sc->codec->height == 480 || sc->codec->height == 512) { /* NTSC or NTSC+VBI */
......
670 671

  
671 672
    for (i = 0; i < s->nb_streams; ++i) {
672 673
        if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
673
            fifo_free(&gxf->streams[i].audio_buffer);
674
            av_fifo_free(&gxf->streams[i].audio_buffer);
674 675
        }
675 676
        if (s->streams[i]->codec->frame_number > gxf->nb_frames)
676 677
            gxf->nb_frames = 2 * s->streams[i]->codec->frame_number;
......
762 763

  
763 764
static int gxf_new_audio_packet(GXFContext *gxf, GXFStreamContext *sc, AVPacket *pkt, int flush)
764 765
{
765
    int size = flush ? fifo_size(&sc->audio_buffer, NULL) : GXF_AUDIO_PACKET_SIZE;
766
    int size = flush ? av_fifo_size(&sc->audio_buffer) : GXF_AUDIO_PACKET_SIZE;
766 767

  
767 768
    if (!size)
768 769
        return 0;
769 770
    av_new_packet(pkt, size);
770
    fifo_read(&sc->audio_buffer, pkt->data, size, NULL);
771
    av_fifo_read(&sc->audio_buffer, pkt->data, size);
771 772
    pkt->stream_index = sc->index;
772 773
    pkt->dts = sc->current_dts;
773 774
    sc->current_dts += size / 2; /* we only support 16 bit pcm mono for now */
......
784 785
        if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
785 786
            GXFStreamContext *sc = &gxf->streams[i];
786 787
            if (pkt && pkt->stream_index == i) {
787
                fifo_write(&sc->audio_buffer, pkt->data, pkt->size, NULL);
788
                av_fifo_write(&sc->audio_buffer, pkt->data, pkt->size);
788 789
                pkt = NULL;
789 790
            }
790
            if (flush || fifo_size(&sc->audio_buffer, NULL) >= GXF_AUDIO_PACKET_SIZE) {
791
            if (flush || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) {
791 792
                if (gxf_new_audio_packet(gxf, sc, &new_pkt, flush) > 0) {
792 793
                    pkt = &new_pkt;
793 794
                    break; /* add pkt right now into list */

Also available in: Unified diff