diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-24 03:09:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-24 03:16:53 +0200 |
commit | 723550d3cadbf671e0990997b969c6722c051543 (patch) | |
tree | c572212d0e42ebfc49881b428b90fc5cd1221199 | |
parent | 236aa4de2a103d36b5f3381717150a6780c46697 (diff) | |
download | ffmpeg-723550d3cadbf671e0990997b969c6722c051543.tar.gz |
avfilter/vf_hqx: optimize table init
5389024880 -> 1389386610 dezicycles
This surely can be optimized more, i just didnt want to cause a slowdown
when trying to make the fate test bitexact.
Further optimization left to ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavfilter/vf_hqx.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/libavfilter/vf_hqx.c b/libavfilter/vf_hqx.c index e7ed9cfb99..4783381565 100644 --- a/libavfilter/vf_hqx.c +++ b/libavfilter/vf_hqx.c @@ -510,14 +510,21 @@ static av_cold int init(AVFilterContext *ctx) static const hqxfunc_t hqxfuncs[] = {hq2x, hq3x, hq4x}; uint32_t c; - for (c = 0; c < FF_ARRAY_ELEMS(hqx->rgbtoyuv); c++) { - const int r = c >> 16 & 0xff; - const int g = c >> 8 & 0xff; - const int b = c & 0xff; - const uint32_t y = (uint32_t)(( 299*r + 587*g + 114*b)/1000); - const uint32_t u = (uint32_t)((-169*r - 331*g + 500*b)/1000) + 128; - const uint32_t v = (uint32_t)(( 500*r - 419*g - 81*b)/1000) + 128; - hqx->rgbtoyuv[c] = (y << 16) + (u << 8) + v; + int bg, rg, g; + + for (bg=-255; bg<256; bg++) { + for (rg=-255; rg<256; rg++) { + const uint32_t u = (uint32_t)((-169*rg + 500*bg)/1000) + 128; + const uint32_t v = (uint32_t)(( 500*rg - 81*bg)/1000) + 128; + int startg = FFMAX3(-bg, -rg, 0); + int endg = FFMIN3(255-bg, 255-rg, 255); + uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000); + c = bg + (rg<<16) + 0x010101 * startg; + for (g = startg; g <= endg; g++) { + hqx->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v; + c+= 0x010101; + } + } } hqx->func = hqxfuncs[hqx->n - 2]; |