diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-03 20:30:07 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-03 20:30:07 +0400 |
commit | 38477e1981a7729b02d9a2f45142c53dc78625fe (patch) | |
tree | cb778598d83ad9a9cec2fd88b6ae35173aa1408c /libavfilter/vf_lut.c | |
parent | 002d9ded4a6f982b12cfe14314abb49c9fb55085 (diff) |
vf_lut: avoid rgb component indexing in the inner loop
15k->10k cpu cycles
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_lut.c')
-rw-r--r-- | libavfilter/vf_lut.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index ee485f36a3..b3816c6962 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -244,6 +244,9 @@ static int config_props(AVFilterLink *inlink) for (comp = 0; comp < desc->nb_components; comp++) { double res; + int tcomp; + for (tcomp = 0; lut->rgba_map[tcomp] != comp; tcomp++) + ; /* create the parsed expression */ ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp], @@ -273,8 +276,8 @@ static int config_props(AVFilterLink *inlink) lut->comp_expr_str[comp], val, comp); return AVERROR(EINVAL); } - lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); - av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]); + lut->lut[tcomp][val] = av_clip((int)res, min[comp], max[comp]); + av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[tcomp][val]); } } @@ -298,16 +301,17 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) for (i = 0; i < h; i ++) { int w = inlink->w; + const uint8_t (*tab)[256] = lut->lut; inrow = inrow0; outrow = outrow0; for (j = 0; j < w; j++) { - outrow[0] = lut->lut[lut->rgba_map[0]][inrow[0]]; + outrow[0] = tab[0][inrow[0]]; if (lut->step>1) { - outrow[1] = lut->lut[lut->rgba_map[1]][inrow[1]]; + outrow[1] = tab[1][inrow[1]]; if (lut->step>2) { - outrow[2] = lut->lut[lut->rgba_map[2]][inrow[2]]; + outrow[2] = tab[2][inrow[2]]; if (lut->step>3) { - outrow[3] = lut->lut[lut->rgba_map[3]][inrow[3]]; + outrow[3] = tab[3][inrow[3]]; } } } |