[FFmpeg-devel] [PATCH 08/10] avfilter/vf_colorkey: avoid unnecessary floating point multiply

Ganesh Ajjanagadde gajjanag at mit.edu
Tue Dec 8 21:41:50 CET 2015


On Tue, Dec 8, 2015 at 1:52 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Dec 07, 2015 at 06:07:03PM -0500, Ganesh Ajjanagadde wrote:
>> On Sun, Nov 22, 2015 at 12:05 PM, Ganesh Ajjanagadde
>> <gajjanagadde at gmail.com> wrote:
>> > Normalization can be pulled outside the sqrt.
>> >
>> > Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> > ---
>> >  libavfilter/vf_colorkey.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/libavfilter/vf_colorkey.c b/libavfilter/vf_colorkey.c
>> > index 2f670d9..4daf2f5 100644
>> > --- a/libavfilter/vf_colorkey.c
>> > +++ b/libavfilter/vf_colorkey.c
>> > @@ -42,7 +42,7 @@ static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, uin
>> >      int dg = (int)g - ctx->colorkey_rgba[1];
>> >      int db = (int)b - ctx->colorkey_rgba[2];
>> >
>> > -    double diff = sqrt((dr * dr + dg * dg + db * db) / (255.0 * 255.0));
>> > +    double diff = sqrt(dr * dr + dg * dg + db * db) / 255.0;
>> >
>> >      if (ctx->blend > 0.0001) {
>> >          return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 255.0;
>> > --
>> > 2.6.2
>> >
>>
>> Really just a cosmetic (i.e I have reworded commit message), if people
>> don't want it, I will drop. Just requesting a resolution on it.
>
> iam not maintainer of this but LGTM

Looks like there is something more nontrivial here: why isn't a sqrtf
being done since the numbers are anyway small, and other surrounding
values are floating point. This function lies in relatively speed
relevant code.

Will investigate sometime, unless the maintainer offers insight here.
Patch shelved, thanks.

>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> While the State exists there can be no freedom; when there is freedom there
> will be no State. -- Vladimir Lenin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list