mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-18 13:35:13 +00:00
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>
This commit is contained in:
parent
236aa4de2a
commit
723550d3ca
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user