>From 1c1a4a862e0a1bcce0b2876d34bac1245b44181e Mon Sep 17 00:00:00 2001 From: Keiji Costantini Date: Thu, 10 Jul 2008 12:50:48 +0900 Subject: [PATCH] Dither Variables moved to context, and adjusted. TODO:adjust yuv2rgb_template.c and test. --- swscale.c | 84 ++++++++++++++++++++++++---------------------------- swscale_internal.h | 6 ++++ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/swscale.c b/swscale.c index 26d003b..71c8bcb 100644 --- a/swscale.c +++ b/swscale.c @@ -181,12 +181,6 @@ static unsigned char clip_table[768]; static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b); -extern const uint8_t dither_2x2_4[2][8]; -extern const uint8_t dither_2x2_8[2][8]; -extern const uint8_t dither_8x8_32[8][8]; -extern const uint8_t dither_8x8_73[8][8]; -extern const uint8_t dither_8x8_220[8][8]; - const char *sws_format_name(enum PixelFormat format) { switch (format) { @@ -479,12 +473,12 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil case PIX_FMT_RGB565:\ case PIX_FMT_BGR565:\ {\ - const int dr1= dither_2x2_8[y&1 ][0];\ - const int dg1= dither_2x2_4[y&1 ][0];\ - const int db1= dither_2x2_8[(y&1)^1][0];\ - const int dr2= dither_2x2_8[y&1 ][1];\ - const int dg2= dither_2x2_4[y&1 ][1];\ - const int db2= dither_2x2_8[(y&1)^1][1];\ + const int dr1= c->dither_2x2_8[y&1 ][0];\ + const int dg1= c->dither_2x2_4[y&1 ][0];\ + const int db1= c->dither_2x2_8[(y&1)^1][0];\ + const int dr2= c->dither_2x2_8[y&1 ][1];\ + const int dg2= c->dither_2x2_4[y&1 ][1];\ + const int db2= c->dither_2x2_8[(y&1)^1][1];\ func(uint16_t)\ ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\ ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\ @@ -494,12 +488,12 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil case PIX_FMT_RGB555:\ case PIX_FMT_BGR555:\ {\ - const int dr1= dither_2x2_8[y&1 ][0];\ - const int dg1= dither_2x2_8[y&1 ][1];\ - const int db1= dither_2x2_8[(y&1)^1][0];\ - const int dr2= dither_2x2_8[y&1 ][1];\ - const int dg2= dither_2x2_8[y&1 ][0];\ - const int db2= dither_2x2_8[(y&1)^1][1];\ + const int dr1= c->dither_2x2_8[y&1 ][0];\ + const int dg1= c->dither_2x2_8[y&1 ][1];\ + const int db1= c->dither_2x2_8[(y&1)^1][0];\ + const int dr2= c->dither_2x2_8[y&1 ][1];\ + const int dg2= c->dither_2x2_8[y&1 ][0];\ + const int db2= c->dither_2x2_8[(y&1)^1][1];\ func(uint16_t)\ ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\ ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\ @@ -509,8 +503,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil case PIX_FMT_RGB8:\ case PIX_FMT_BGR8:\ {\ - const uint8_t * const d64= dither_8x8_73[y&7];\ - const uint8_t * const d32= dither_8x8_32[y&7];\ + const uint8_t * const d64= c->dither_8x8_73[y&7];\ + const uint8_t * const d32= c->dither_8x8_32[y&7];\ func(uint8_t)\ ((uint8_t*)dest)[i2+0]= r[Y1+d32[(i2+0)&7]] + g[Y1+d32[(i2+0)&7]] + b[Y1+d64[(i2+0)&7]];\ ((uint8_t*)dest)[i2+1]= r[Y2+d32[(i2+1)&7]] + g[Y2+d32[(i2+1)&7]] + b[Y2+d64[(i2+1)&7]];\ @@ -520,8 +514,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil case PIX_FMT_RGB4:\ case PIX_FMT_BGR4:\ {\ - const uint8_t * const d64= dither_8x8_73 [y&7];\ - const uint8_t * const d128=dither_8x8_220[y&7];\ + const uint8_t * const d64= c->dither_8x8_73 [y&7];\ + const uint8_t * const d128=c->dither_8x8_220[y&7];\ func(uint8_t)\ ((uint8_t*)dest)[i]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]]\ + ((r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]])<<4);\ @@ -531,8 +525,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil case PIX_FMT_RGB4_BYTE:\ case PIX_FMT_BGR4_BYTE:\ {\ - const uint8_t * const d64= dither_8x8_73 [y&7];\ - const uint8_t * const d128=dither_8x8_220[y&7];\ + const uint8_t * const d64= c->dither_8x8_73 [y&7];\ + const uint8_t * const d128=c->dither_8x8_220[y&7];\ func(uint8_t)\ ((uint8_t*)dest)[i2+0]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]];\ ((uint8_t*)dest)[i2+1]= r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]];\ @@ -541,7 +535,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil break;\ case PIX_FMT_MONOBLACK:\ {\ - const uint8_t * const d128=dither_8x8_220[y&7];\ + const uint8_t * const d128=c->dither_8x8_220[y&7];\ uint8_t *g= c->table_gU[128] + c->table_gV[128];\ for (i=0; idither_8x8_220[y&7];\ int error_new=0;\ int error_in3=0;\ int f=0;\ @@ -661,12 +655,12 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l case PIX_FMT_RGB565: case PIX_FMT_BGR565: { - const int dr1= dither_2x2_8[y&1 ][0]; - const int dg1= dither_2x2_4[y&1 ][0]; - const int db1= dither_2x2_8[(y&1)^1][0]; - const int dr2= dither_2x2_8[y&1 ][1]; - const int dg2= dither_2x2_4[y&1 ][1]; - const int db2= dither_2x2_8[(y&1)^1][1]; + const int dr1= c->dither_2x2_8[y&1 ][0]; + const int dg1= c->dither_2x2_4[y&1 ][0]; + const int db1= c->dither_2x2_8[(y&1)^1][0]; + const int dr2= c->dither_2x2_8[y&1 ][1]; + const int dg2= c->dither_2x2_4[y&1 ][1]; + const int db2= c->dither_2x2_8[(y&1)^1][1]; YSCALE_YUV_2_RGBX_C(uint16_t) ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1]; ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2]; @@ -676,12 +670,12 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l case PIX_FMT_RGB555: case PIX_FMT_BGR555: { - const int dr1= dither_2x2_8[y&1 ][0]; - const int dg1= dither_2x2_8[y&1 ][1]; - const int db1= dither_2x2_8[(y&1)^1][0]; - const int dr2= dither_2x2_8[y&1 ][1]; - const int dg2= dither_2x2_8[y&1 ][0]; - const int db2= dither_2x2_8[(y&1)^1][1]; + const int dr1= c->dither_2x2_8[y&1 ][0]; + const int dg1= c->dither_2x2_8[y&1 ][1]; + const int db1= c->dither_2x2_8[(y&1)^1][0]; + const int dr2= c->dither_2x2_8[y&1 ][1]; + const int dg2= c->dither_2x2_8[y&1 ][0]; + const int db2= c->dither_2x2_8[(y&1)^1][1]; YSCALE_YUV_2_RGBX_C(uint16_t) ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1]; ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2]; @@ -691,8 +685,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l case PIX_FMT_RGB8: case PIX_FMT_BGR8: { - const uint8_t * const d64= dither_8x8_73[y&7]; - const uint8_t * const d32= dither_8x8_32[y&7]; + const uint8_t * const d64= c->dither_8x8_73[y&7]; + const uint8_t * const d32= c->dither_8x8_32[y&7]; YSCALE_YUV_2_RGBX_C(uint8_t) ((uint8_t*)dest)[i2+0]= r[Y1+d32[(i2+0)&7]] + g[Y1+d32[(i2+0)&7]] + b[Y1+d64[(i2+0)&7]]; ((uint8_t*)dest)[i2+1]= r[Y2+d32[(i2+1)&7]] + g[Y2+d32[(i2+1)&7]] + b[Y2+d64[(i2+1)&7]]; @@ -702,8 +696,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l case PIX_FMT_RGB4: case PIX_FMT_BGR4: { - const uint8_t * const d64= dither_8x8_73 [y&7]; - const uint8_t * const d128=dither_8x8_220[y&7]; + const uint8_t * const d64= c->dither_8x8_73 [y&7]; + const uint8_t * const d128=c->dither_8x8_220[y&7]; YSCALE_YUV_2_RGBX_C(uint8_t) ((uint8_t*)dest)[i]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]] +((r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]])<<4); @@ -713,8 +707,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l case PIX_FMT_RGB4_BYTE: case PIX_FMT_BGR4_BYTE: { - const uint8_t * const d64= dither_8x8_73 [y&7]; - const uint8_t * const d128=dither_8x8_220[y&7]; + const uint8_t * const d64= c->dither_8x8_73 [y&7]; + const uint8_t * const d128=c->dither_8x8_220[y&7]; YSCALE_YUV_2_RGBX_C(uint8_t) ((uint8_t*)dest)[i2+0]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]]; ((uint8_t*)dest)[i2+1]= r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]]; @@ -723,7 +717,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l break; case PIX_FMT_MONOBLACK: { - const uint8_t * const d128=dither_8x8_220[y&7]; + const uint8_t * const d128=c->dither_8x8_220[y&7]; uint8_t *g= c->table_gU[128] + c->table_gV[128]; int acc=0; for (i=0; i