aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-03-08 14:16:55 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-03-08 14:16:55 +0000
commit41dd680dd80d93626e133c02b92e31cabb756eeb (patch)
treee21e3fdda1fab791bf322d167be5e02c414e4384 /libavformat
parent48d58e592aa258494beed72954fff74b5827acca (diff)
downloadffmpeg-41dd680dd80d93626e133c02b92e31cabb756eeb.tar.gz
Allocate AVFifoBuffer through the fifo API to reduce future API/ABI issues.
Yes this breaks ABI/API but ive already broken it and will bump avutil major soon. Originally committed as revision 17869 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/audiointerleave.c16
-rw-r--r--libavformat/audiointerleave.h2
-rw-r--r--libavformat/dvenc.c22
-rw-r--r--libavformat/mpegenc.c26
-rw-r--r--libavformat/swf.h2
-rw-r--r--libavformat/swfenc.c14
6 files changed, 41 insertions, 41 deletions
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index d811f21357..a4396f5bfa 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -33,7 +33,7 @@ void ff_audio_interleave_close(AVFormatContext *s)
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == CODEC_TYPE_AUDIO)
- av_fifo_free(&aic->fifo);
+ av_fifo_free(aic->fifo);
}
}
@@ -62,7 +62,7 @@ int ff_audio_interleave_init(AVFormatContext *s,
aic->time_base = time_base;
aic->fifo_size = 100* *aic->samples;
- av_fifo_init(&aic->fifo, 100 * *aic->samples);
+ aic->fifo= av_fifo_alloc(100 * *aic->samples);
}
}
@@ -75,12 +75,12 @@ static int ff_interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt,
AVStream *st = s->streams[stream_index];
AudioInterleaveContext *aic = st->priv_data;
- int size = FFMIN(av_fifo_size(&aic->fifo), *aic->samples * aic->sample_size);
- if (!size || (!flush && size == av_fifo_size(&aic->fifo)))
+ int size = FFMIN(av_fifo_size(aic->fifo), *aic->samples * aic->sample_size);
+ if (!size || (!flush && size == av_fifo_size(aic->fifo)))
return 0;
av_new_packet(pkt, size);
- av_fifo_read(&aic->fifo, pkt->data, size);
+ av_fifo_read(aic->fifo, pkt->data, size);
pkt->dts = pkt->pts = aic->dts;
pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base);
@@ -104,13 +104,13 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
- unsigned new_size = av_fifo_size(&aic->fifo) + pkt->size;
+ unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
if (new_size > aic->fifo_size) {
- if (av_fifo_realloc2(&aic->fifo, new_size) < 0)
+ if (av_fifo_realloc2(aic->fifo, new_size) < 0)
return -1;
aic->fifo_size = new_size;
}
- av_fifo_generic_write(&aic->fifo, pkt->data, pkt->size, NULL);
+ av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
} else {
// rewrite pts and dts to be decoded time line position
pkt->pts = pkt->dts = aic->dts;
diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h
index 10684af50c..c948c366fb 100644
--- a/libavformat/audiointerleave.h
+++ b/libavformat/audiointerleave.h
@@ -27,7 +27,7 @@
#include "avformat.h"
typedef struct {
- AVFifoBuffer fifo;
+ AVFifoBuffer *fifo;
unsigned fifo_size; ///< size of currently allocated FIFO
uint64_t dts; ///< current dts
int sample_size; ///< size of one sample all channels included
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 4551cd516f..c87697dd13 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -38,7 +38,7 @@ struct DVMuxContext {
const DVprofile* sys; /* current DV profile, e.g.: 525/60, 625/50 */
int n_ast; /* number of stereo audio streams (up to 2) */
AVStream *ast[2]; /* stereo audio streams */
- AVFifoBuffer audio_data[2]; /* FIFO for storing excessive amounts of PCM */
+ AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */
int frames; /* current frame number */
time_t start_time; /* recording start time */
int has_audio; /* frame under contruction has audio */
@@ -189,8 +189,8 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
if (of*2 >= size)
continue;
- frame_ptr[d] = av_fifo_peek(&c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
- frame_ptr[d+1] = av_fifo_peek(&c->audio_data[channel], of*2); // that DV is a big-endian PCM
+ frame_ptr[d] = av_fifo_peek(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
+ frame_ptr[d+1] = av_fifo_peek(c->audio_data[channel], of*2); // that DV is a big-endian PCM
}
frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
}
@@ -251,12 +251,12 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
for (i = 0; i < c->n_ast && st != c->ast[i]; i++);
/* FIXME: we have to have more sensible approach than this one */
- if (av_fifo_size(&c->audio_data[i]) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
+ if (av_fifo_size(c->audio_data[i]) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
- av_fifo_generic_write(&c->audio_data[i], data, data_size, NULL);
+ av_fifo_generic_write(c->audio_data[i], data, data_size, NULL);
/* Let us see if we've got enough audio for one DV frame. */
- c->has_audio |= ((reqasize <= av_fifo_size(&c->audio_data[i])) << i);
+ c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
break;
default:
@@ -269,8 +269,8 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
c->has_audio = 0;
for (i=0; i < c->n_ast; i++) {
dv_inject_audio(c, i, *frame);
- av_fifo_drain(&c->audio_data[i], reqasize);
- c->has_audio |= ((reqasize <= av_fifo_size(&c->audio_data[i])) << i);
+ av_fifo_drain(c->audio_data[i], reqasize);
+ c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
}
c->has_video = 0;
@@ -337,10 +337,10 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
c->start_time = (time_t)s->timestamp;
for (i=0; i < c->n_ast; i++) {
- if (c->ast[i] && av_fifo_init(&c->audio_data[i], 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) {
+ if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) {
while (i > 0) {
i--;
- av_fifo_free(&c->audio_data[i]);
+ av_fifo_free(c->audio_data[i]);
}
goto bail_out;
}
@@ -356,7 +356,7 @@ void dv_delete_mux(DVMuxContext *c)
{
int i;
for (i=0; i < c->n_ast; i++)
- av_fifo_free(&c->audio_data[i]);
+ av_fifo_free(c->audio_data[i]);
}
#if CONFIG_DV_MUXER
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 0a740af698..91cfa69bef 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -40,7 +40,7 @@ typedef struct PacketDesc {
} PacketDesc;
typedef struct {
- AVFifoBuffer fifo;
+ AVFifoBuffer *fifo;
uint8_t id;
int max_buffer_size; /* in bytes */
int buffer_index;
@@ -381,7 +381,7 @@ static int mpeg_mux_init(AVFormatContext *ctx)
default:
return -1;
}
- av_fifo_init(&stream->fifo, 16);
+ stream->fifo= av_fifo_alloc(16);
}
bitrate = 0;
audio_bitrate = 0;
@@ -786,7 +786,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
startcode = 0x100 + id;
}
- stuffing_size = payload_size - av_fifo_size(&stream->fifo);
+ stuffing_size = payload_size - av_fifo_size(stream->fifo);
// first byte does not fit -> reset pts/dts + stuffing
if(payload_size <= trailer_size && pts != AV_NOPTS_VALUE){
@@ -913,8 +913,8 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
}
/* output data */
- assert(payload_size - stuffing_size <= av_fifo_size(&stream->fifo));
- av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb);
+ assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
+ av_fifo_generic_read(stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb);
stream->bytes_to_iframe -= payload_size - stuffing_size;
}else{
payload_size=
@@ -1031,7 +1031,7 @@ retry:
for(i=0; i<ctx->nb_streams; i++){
AVStream *st = ctx->streams[i];
StreamInfo *stream = st->priv_data;
- const int avail_data= av_fifo_size(&stream->fifo);
+ const int avail_data= av_fifo_size(stream->fifo);
const int space= stream->max_buffer_size - stream->buffer_index;
int rel_space= 1024*space / stream->max_buffer_size;
PacketDesc *next_pkt= stream->premux_packet;
@@ -1091,7 +1091,7 @@ retry:
st = ctx->streams[best_i];
stream = st->priv_data;
- assert(av_fifo_size(&stream->fifo) > 0);
+ assert(av_fifo_size(stream->fifo) > 0);
assert(avail_space >= s->packet_size || ignore_constraints);
@@ -1107,7 +1107,7 @@ retry:
//av_log(ctx, AV_LOG_DEBUG, "dts:%f pts:%f scr:%f stream:%d\n", timestamp_packet->dts/90000.0, timestamp_packet->pts/90000.0, scr/90000.0, best_i);
es_size= flush_packet(ctx, best_i, timestamp_packet->pts, timestamp_packet->dts, scr, trailer_size);
}else{
- assert(av_fifo_size(&stream->fifo) == trailer_size);
+ assert(av_fifo_size(stream->fifo) == trailer_size);
es_size= flush_packet(ctx, best_i, AV_NOPTS_VALUE, AV_NOPTS_VALUE, scr, trailer_size);
}
@@ -1170,18 +1170,18 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
stream->predecode_packet= pkt_desc;
stream->next_packet= &pkt_desc->next;
- if (av_fifo_realloc2(&stream->fifo, av_fifo_size(&stream->fifo) + size) < 0)
+ if (av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size) < 0)
return -1;
if (s->is_dvd){
if (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
- stream->bytes_to_iframe = av_fifo_size(&stream->fifo);
+ stream->bytes_to_iframe = av_fifo_size(stream->fifo);
stream->align_iframe = 1;
stream->vobu_start_pts = pts;
}
}
- av_fifo_generic_write(&stream->fifo, buf, size, NULL);
+ av_fifo_generic_write(stream->fifo, buf, size, NULL);
for(;;){
int ret= output_packet(ctx, 0);
@@ -1213,8 +1213,8 @@ static int mpeg_mux_end(AVFormatContext *ctx)
for(i=0;i<ctx->nb_streams;i++) {
stream = ctx->streams[i]->priv_data;
- assert(av_fifo_size(&stream->fifo) == 0);
- av_fifo_free(&stream->fifo);
+ assert(av_fifo_size(stream->fifo) == 0);
+ av_fifo_free(stream->fifo);
}
return 0;
}
diff --git a/libavformat/swf.h b/libavformat/swf.h
index 0fee1e6e80..a4638bbfc3 100644
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -75,7 +75,7 @@ typedef struct {
int video_frame_number;
int frame_rate;
int tag;
- AVFifoBuffer audio_fifo;
+ AVFifoBuffer *audio_fifo;
AVCodecContext *audio_enc, *video_enc;
} SWFContext;
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index b433f6b713..7ed8cc3553 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -192,7 +192,7 @@ static int swf_write_header(AVFormatContext *s)
return -1;
}
swf->audio_enc = enc;
- av_fifo_init(&swf->audio_fifo, AUDIO_FIFO_SIZE);
+ swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
} else {
av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
return -1;
@@ -414,12 +414,12 @@ static int swf_write_video(AVFormatContext *s,
swf->swf_frame_number++;
/* streaming sound always should be placed just before showframe tags */
- if (swf->audio_enc && av_fifo_size(&swf->audio_fifo)) {
- int frame_size = av_fifo_size(&swf->audio_fifo);
+ if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
+ int frame_size = av_fifo_size(swf->audio_fifo);
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
put_le16(pb, swf->sound_samples);
put_le16(pb, 0); // seek samples
- av_fifo_generic_read(&swf->audio_fifo, frame_size, &put_buffer, pb);
+ av_fifo_generic_read(swf->audio_fifo, frame_size, &put_buffer, pb);
put_swf_end_tag(s);
/* update FIFO */
@@ -444,12 +444,12 @@ static int swf_write_audio(AVFormatContext *s,
if (swf->swf_frame_number == 16000)
av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
- if (av_fifo_size(&swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
+ if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
return -1;
}
- av_fifo_generic_write(&swf->audio_fifo, buf, size, NULL);
+ av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
swf->sound_samples += enc->frame_size;
/* if audio only stream make sure we add swf frames */
@@ -481,7 +481,7 @@ static int swf_write_trailer(AVFormatContext *s)
if (enc->codec_type == CODEC_TYPE_VIDEO)
video_enc = enc;
else
- av_fifo_free(&swf->audio_fifo);
+ av_fifo_free(swf->audio_fifo);
}
put_swf_tag(s, TAG_END);