[Ffmpeg-devel] [PATCH] watermark.c optimizations for single-frame input (previous patch included)
Michael Niedermayer
michaelni
Fri Oct 20 16:20:26 CEST 2006
Hi
On Fri, Oct 20, 2006 at 04:41:41PM +0300, Mihail Stoyanov wrote:
> This patch optimizes watermark.c in 2 ways
> 1. Checks if the current pixel RGB (of the input image) is equal to the
> threshold before doing any other calculations, thus skipping useless
> itterations.
>
> 2. When using single-frame watermark input...
> Checks the starting & ending coordinates (actually rectangle) of the actual
> watermark (inside the watermark input) using threshold comparison.
> In that way only the area which contains the actual watermark is applied
> over the movie source reducing the itterations - "for (y...)" & "for
> (x...)" and greatly improving the covert times.
> It also have checks if the watermark source is multi-frame and disables the
> optimization
>
> NOTE: These optimizations are applied ONLY if you are using mode 0 (the
> default)
>
> Benchmarks
> --------------------------
> Original watermark.c
> -> Convert time: 00:31
>
> Patched watermark.c when using multi-frame watermark source (a.k.a animated
> images or movies)
> -> Convert time: 00:26
>
> Patched watermark.c when using single-frame watermark source (a.k.a. image)
> -> Convert time: 00:18
great
[...]
> @@ -140,6 +148,10 @@
> ci->thrR = 0x80;
> ci->thrG = 0x80;
> ci->thrB = 0x80;
> + ci->x1 = ci->y1 = 10000; // it's ugly, i know :)
INT_MAX
[...]
> }
> + if (ci->do_optimize) {
> + start_x = ci->x1;
> + start_y = ci->y1;
> + end_x = ci->x2;
> + end_y = ci->y2;
> + }
tabs are not allowed in ffmpeg (they tend cause a big mess as not everyone
uses 8space tabs)
[...]
> + if (thrR == (int)((pixelm >> 16) & 0xff) &&
> + thrG == (int)((pixelm >> 8) & 0xff) &&
> + thrB == (int)((pixelm >> 0) & 0xff)) {
precalculate thr= thrB + (thrG<<8) + (thrR<<16)
and then use if(thr == pixelm)
or
if(thr == (pixelm & 0xFFFFFF))
or something like that
[...]
--
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
More information about the ffmpeg-devel
mailing list