[Ffmpeg-devel] [PATCH] watermark.c optimizations forsingle-frameinput (previous patch included)
Mihail Stoyanov
screamer
Sat Oct 21 16:21:08 CEST 2006
Hello
----- Original Message -----
From: "Michael Niedermayer" <michaelni at gmx.at>
To: "FFmpeg development discussions and patches" <ffmpeg-devel at mplayerhq.hu>
Sent: Friday, October 20, 2006 6:38 PM
Subject: Re: [Ffmpeg-devel] [PATCH] watermark.c optimizations
forsingle-frameinput (previous patch included)
> Hi
> [cut]
>
> maybe you might want to try, START/STOP_TIMER (see libavutil/common.h)
> they are much more accurate for testing the speed of some code
>
Yes. Thanks a lot. Using internal timers (not depending on raid controller
operations) makes sense.
> also in the original code and your patched code
>
> // R
> tmp = (int)((pixel >> 16) & 0xff) + (int)((pixelm >> 16) &
> 0xff) - thrR;
> if (tmp > 255) tmp = 255;
> if (tmp < 0) tmp = 0;
> pixel_meck |= (tmp << 16) & 0xff0000;
> // G
> tmp = (int)((pixel >> 8) & 0xff) + (int)((pixelm >> 8) &
> 0xff) - thrG;
> if (tmp > 255) tmp = 255;
> if (tmp < 0) tmp = 0;
> pixel_meck |= (tmp << 8) & 0xff00;
> // B
> tmp = (int)((pixel >> 0) & 0xff) + (int)((pixelm >> 0) &
> 0xff) - thrB;
> if (tmp > 255) tmp = 255;
> if (tmp < 0) tmp = 0;
> pixel_meck |= (tmp << 0) & 0xff;
>
> the & 0xff0000, & 0xff00 and & 0xff do nothing they can be removed
> and maybe you want to try
> if(tmp&(~255)) tmp= ((-tmp)>>31)&0xFF;
> instead of the tmp>255 and tmp<0 its one check instead of 2
>
Thanks for the "tmp" check. It is faster now :)
With the current optimizations the code it works just great.
Now the bottleneck is the RGB convert on every frame.
The normal running time is 18 seconds
I have test-removed the "for (y)" and "for (x)" cycles and i'm getting
running times around 17 seconds (measured in my external bench). That's 1
second less.
The running time without any watermarking is 12 seconds.
Which means that for 1439 frames (my example video), 608x336 pixels each, it
takes 5 seconds to convert fromRGB and toRGB without doing anything else.
I'm not deep at all with ffmpeg so do you have any ideas about it?
P.S. i'm preparing a third patch of watermark.c which include your
optimizations + optimizations when using mode 1
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In the past you could go to a library and read, borrow or copy any book
> Today you'd get arrested for mere telling someone where the library is
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list