[Ffmpeg-devel] Re: [Ffmpeg-cvslog] r7570 - trunk/libavutil/fifo.c
Michael Niedermayer
michaelni
Fri Jan 19 03:48:15 CET 2007
Hi
On Thu, Jan 18, 2007 at 04:41:21PM -0800, Roman Shaposhnik wrote:
[...]
>
> > the extra if() also should disapear for av_fifo_read() if its inlined
> > and the body of the while loop will be executed just once normally
> > and rarely twice, but never more often then twice
> >
> > do you know of any specific places in libav* where there are so many
> > calls to av_fifo_*read() that this could matter?
>
> Nope. All I care about is av_fifo_peek() ;-)
attached patch removes it and makes your code about 35% faster ;)
and i suspect it can be made even faster, of course this is not possible
with a av_fifo_peek like system
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
Index: libavformat/dvenc.c
===================================================================
--- libavformat/dvenc.c (revision 7537)
+++ libavformat/dvenc.c (working copy)
@@ -177,21 +177,33 @@
static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
{
- int i, j, d, of, size;
+ int i, j, d, size;
+ uint8_t *fifo_ptr, *fifo_end;
+ AVFifoBuffer *f= &c->audio_data[channel];
size = 4 * dv_audio_frame_size(c->sys, c->frames);
frame_ptr += channel * c->sys->difseg_size * 150 * 80;
for (i = 0; i < c->sys->difseg_size; i++) {
frame_ptr += 6 * 80; /* skip DIF segment header */
for (j = 0; j < 9; j++) {
dv_write_pack(dv_aaux_packs_dist[i][j], c, &frame_ptr[3], i >= c->sys->difseg_size/2);
- for (d = 8; d < 80; d+=2) {
- of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride;
- if (of*2 >= size)
- continue;
+ fifo_ptr = f->rptr + 2*c->sys->audio_shuffle[i][j];
+ fifo_end = FFMIN(f->end, f->rptr + size);
+ for (d = 8; d < 80; d+=2, fifo_ptr += 2*c->sys->audio_stride) {
+ if (fifo_ptr >= fifo_end)
+ break;
- frame_ptr[d] = av_fifo_peek(&c->audio_data[channel], of*2+1); // FIXME: may be 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 ] = fifo_ptr[1];// FIXME: may be we have to admit that DV is a big endian PCM
+ frame_ptr[d+1] = fifo_ptr[0];
}
+ fifo_ptr -= f->end - f->buffer;
+ fifo_end = f->rptr + size - f->end + f->buffer;
+ for (; d < 80; d+=2, fifo_ptr += 2*c->sys->audio_stride) {
+ if (fifo_ptr >= fifo_end)
+ break;
+
+ frame_ptr[d ] = fifo_ptr[1];// FIXME: may be we have to admit that DV is a big endian PCM
+ frame_ptr[d+1] = fifo_ptr[0];
+ }
frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070119/eb35afb8/attachment.pgp>
More information about the ffmpeg-devel
mailing list