static int gxf_new_audio_packet(GXFContext *gxf, GXFStreamContext *sc, AVPacket *pkt, int flush) { int size = flush ? av_fifo_size(&sc->audio_buffer) : GXF_AUDIO_PACKET_SIZE; if (!size) return 0; av_new_packet(pkt, size); av_fifo_read(&sc->audio_buffer, pkt->data, size); pkt->stream_index = sc->index; pkt->dts = sc->current_dts; sc->current_dts += size / 2; /* we only support 16 bit pcm mono for now */ return size; }
/** * Resizes a FIFO. */ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) { unsigned int old_size= f->end - f->buffer; if(old_size < new_size){ int len= av_fifo_size(f); AVFifoBuffer f2; av_fifo_init(&f2, new_size); av_fifo_read(f, f2.buffer, len); f2.wptr += len; av_free(f->buffer); *f= f2; } }
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) { unsigned int old_size= f->end - f->buffer; if(old_size <= new_size){ int len= av_fifo_size(f); AVFifoBuffer f2; if (av_fifo_init(&f2, new_size) < 0) return -1; av_fifo_read(f, f2.buffer, len); f2.wptr += len; av_free(f->buffer); *f= f2; } return 0; }