diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-06-01 11:30:07 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-06-01 11:30:07 +0000 |
commit | 0093ac5b9f4ff7dd11996cdaa3df5dcdd15ef8ee (patch) | |
tree | 6e23313e7b64b95b4dfc1a51ba83aeadc92bbc2e /libswscale/yuv2rgb.c | |
parent | 79513857ba8169f5aed17d978a2b3eac9b59fe25 (diff) | |
download | ffmpeg-0093ac5b9f4ff7dd11996cdaa3df5dcdd15ef8ee.tar.gz |
Move internal scale context fields initialization from
sws_setColorspaceDetails() to ff_yuv2rgb_c_init_tables().
Allow to factorize duplicated code.
Originally committed as revision 31300 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
Diffstat (limited to 'libswscale/yuv2rgb.c')
-rw-r--r-- | libswscale/yuv2rgb.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index f47b15d6ee..70841a8f07 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -620,6 +620,14 @@ static void fill_gv_table(int table[256], const int elemsize, const int inc) } } +static uint16_t roundToInt16(int64_t f) +{ + int r= (f + (1<<15))>>16; + if (r<-0x7FFF) return 0x8000; + else if (r> 0x7FFF) return 0x7FFF; + else return r; +} + av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { @@ -675,6 +683,22 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int cgv = (cgv*contrast * saturation) >> 32; oy -= 256*brightness; + c->uOffset= 0x0400040004000400LL; + c->vOffset= 0x0400040004000400LL; + c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL; + c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL; + c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL; + c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL; + c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL; + c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL; + + c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy <<13); + c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9); + c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13); + c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13); + c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13); + c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13); + //scale coefficients by cy crv = ((crv << 16) + 0x8000) / cy; cbu = ((cbu << 16) + 0x8000) / cy; |