[FFmpeg-cvslog] r17873 - in trunk: ffmpeg.c libavformat/audiointerleave.c libavutil/fifo.c

Reimar Döffinger Reimar.Doeffinger
Mon Mar 9 10:30:24 CET 2009


On Mon, Mar 09, 2009 at 03:35:15AM +0100, Michael Niedermayer wrote:
> On Mon, Mar 09, 2009 at 12:39:23AM +0100, Reimar D?ffinger wrote:
> > On Sun, Mar 08, 2009 at 11:40:46PM +0100, Michael Niedermayer wrote:
> > > On Sun, Mar 08, 2009 at 03:43:51PM +0100, Reimar D?ffinger wrote:
> > > > On Sun, Mar 08, 2009 at 03:42:11PM +0100, reimar wrote:
> > > > > Author: reimar
> > > > > Date: Sun Mar  8 15:42:11 2009
> > > > > New Revision: 17873
> > > > > 
> > > > > Log:
> > > > > Replace all uses of the replaced av_fifo_read by av_fifo_generic_read
> > > > 
> > > > Btw. is it intentional/is there a rationale behind the different order
> > > > of parameters for av_fifo_generic_read and av_fifo_generic_write?
> > > 
> > > not that i remember but IMHO dst & context should be on the left.
> > 
> > I guess it is because depending on how you see it, it is not dst but an
> > argument to the function.
> > Should I reorder it into context, dest, buf_size, func? Or is there too
> > much risk of confusing everyone and so not worth doing?
> 
> iam in favor of the reordering, current code looks odd ...

Ok, I'd then apply attached patch around the end of the day if nobody
objects.
It is not really better for the cases that use a read function (though
IMO it is not worse either), but at least it is consistent and looks
better for the simpler case.
-------------- next part --------------
diff --git a/doc/APIchanges b/doc/APIchanges
index e46c977..b8a3f11 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,8 @@ API changes, most recent first:
 20090308 - r17869 - lavu 50.0.0  - AVFifoBuffer
   av_fifo_init, av_fifo_read, av_fifo_write and av_fifo_realloc were dropped and replaced
   by av_fifo_alloc, av_fifo_generic_read, av_fifo_generic_write and av_fifo_realloc2.
+  In addition, the order of the function arguments of av_fifo_generic_read were changed
+  to match av_fifo_generic_write.
   The AVFifoBuffer/struct AVFifoBuffer may only be used in an opaque way by applications,
   they may not use sizeof() or directly access members.
 
diff --git a/ffmpeg.c b/ffmpeg.c
index 8a5e0e4..8431b0c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -672,7 +672,7 @@ static void do_audio_out(AVFormatContext *s,
             AVPacket pkt;
             av_init_packet(&pkt);
 
-            av_fifo_generic_read(ost->fifo, frame_bytes, NULL, audio_buf);
+            av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
 
             //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
 
@@ -1452,7 +1452,7 @@ 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);
-                                av_fifo_generic_read(ost->fifo, fifo_bytes, NULL, samples);
+                                av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL);
                                     ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
                                 enc->frame_size = fs_tmp;
                             }
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index 11f0093..a3a6531 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -80,7 +80,7 @@ static int ff_interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt,
         return 0;
 
     av_new_packet(pkt, size);
-    av_fifo_generic_read(aic->fifo, size, NULL, pkt->data);
+    av_fifo_generic_read(aic->fifo, pkt->data, size, NULL);
 
     pkt->dts = pkt->pts = aic->dts;
     pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base);
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 91cfa69..5b949fe 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -914,7 +914,7 @@ 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);
+        av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &put_buffer);
         stream->bytes_to_iframe -= payload_size - stuffing_size;
     }else{
         payload_size=
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 7ed8cc3..8caf0d1 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -419,7 +419,7 @@ static int swf_write_video(AVFormatContext *s,
         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, pb, frame_size, &put_buffer);
         put_swf_end_tag(s);
 
         /* update FIFO */
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 9a9a139..52ace0e 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -63,7 +63,7 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) {
 
         if (!f2)
             return -1;
-        av_fifo_generic_read(f, len, NULL, f2->buffer);
+        av_fifo_generic_read(f, f2->buffer, len, NULL);
         f2->wptr += len;
         f2->wndx += len;
         av_free(f->buffer);
@@ -96,7 +96,7 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void
 }
 
 
-int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
+int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int))
 {
 // Read memory barrier needed for SMP here in theory
     do {
diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index f64914f..d353844 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -68,7 +68,7 @@ int av_fifo_size(AVFifoBuffer *f);
  * @param *func generic read function
  * @param *dest data destination
  */
-int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest);
+int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
 
 /**
  * Feeds data from a user-supplied callback to an AVFifoBuffer.



More information about the ffmpeg-cvslog mailing list