Commit 6fc8c4cc authored by Jean Delvare's avatar Jean Delvare Committed by Michael Niedermayer

lavfi/delogo: don't recompute the same difference again and again

The top left hand corner pixel coordinates are already stored in
logo_x1 and logo_y1 so don't recompute each of them 6 times for every
iteration.

This is a simple code optimization, result is obviously the same. The
performance gain is small (about 2% in my tests) but still good to
have, and the new code is clearer.
Signed-off-by: 's avatarJean Delvare <khali@linux-fr.org>
Reviewed-by; Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c6c22312
......@@ -100,21 +100,21 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1) * sar.num;
interp =
(topleft[src_linesize*(y-logo_y -yclipt)] +
topleft[src_linesize*(y-logo_y-1-yclipt)] +
topleft[src_linesize*(y-logo_y+1-yclipt)]) * weightl
(topleft[src_linesize*(y-logo_y1)] +
topleft[src_linesize*(y-logo_y1-1)] +
topleft[src_linesize*(y-logo_y1+1)]) * weightl
+
(topright[src_linesize*(y-logo_y-yclipt)] +
topright[src_linesize*(y-logo_y-1-yclipt)] +
topright[src_linesize*(y-logo_y+1-yclipt)]) * weightr
(topright[src_linesize*(y-logo_y1)] +
topright[src_linesize*(y-logo_y1-1)] +
topright[src_linesize*(y-logo_y1+1)]) * weightr
+
(topleft[x-logo_x-xclipl] +
topleft[x-logo_x-1-xclipl] +
topleft[x-logo_x+1-xclipl]) * weightt
(topleft[x-logo_x1] +
topleft[x-logo_x1-1] +
topleft[x-logo_x1+1]) * weightt
+
(botleft[x-logo_x-xclipl] +
botleft[x-logo_x-1-xclipl] +
botleft[x-logo_x+1-xclipl]) * weightb;
(botleft[x-logo_x1] +
botleft[x-logo_x1-1] +
botleft[x-logo_x1+1]) * weightb;
interp /= (weightl + weightr + weightt + weightb) * 3U;
if (y >= logo_y+band && y < logo_y+logo_h-band &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment