From cd2f69cdd63d3ca5c2388d9ce6737b3e46bb19b2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 1 Oct 2017 18:10:35 +0200 Subject: [PATCH] avcodec/dvbsubdec: Factor a few expressions out of compute_default_clut() 32% faster loop Signed-off-by: Michael Niedermayer --- libavcodec/dvbsubdec.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index b683109643..ef581a9a3f 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -653,8 +653,8 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) uint8_t list_inv[256]; int counttab[256] = {0}; int count, i, x, y; - -#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]] + ptrdiff_t stride = rect->linesize[0]; +#define V(x,y) rect->data[0][(x) + (y)*stride] for (y = 0; ydata[0][(x) + (y)*rect->linesize[0]] ] +#define L(x,y) list[d[(x) + (y)*stride]] for (i = 0; i<256; i++) { int scoretab[256] = {0}; @@ -673,12 +673,13 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) int bestv = 0; for (y = 0; ydata[0][x + y*rect->linesize[0]]; + uint8_t *d = &rect->data[0][x + y*stride]; + int v = *d; int l_m = list[v]; - int l_l = x ? L(x-1, y) : 1; - int l_r = x+1