1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

fixing rgb4 & bgr4 (2 pixels per byte)

adding bg4b & rg4b (1 pixel per byte)

Originally committed as revision 9172 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
This commit is contained in:
Michael Niedermayer 2003-01-30 09:15:09 +00:00
parent 782c5984f1
commit f17457ac49
2 changed files with 150 additions and 12 deletions

View File

@ -583,6 +583,17 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
break;\
case IMGFMT_RGB4:\
case IMGFMT_BGR4:\
{\
const uint8_t * const d64= dither_8x8_73 [y&7];\
const uint8_t * const d128=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);\
}\
}\
break;\
case IMGFMT_RG4B:\
case IMGFMT_BG4B:\
{\
const uint8_t * const d64= dither_8x8_73 [y&7];\
const uint8_t * const d128=dither_8x8_220[y&7];\
@ -747,6 +758,17 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
break;
case IMGFMT_RGB4:
case IMGFMT_BGR4:
{
const uint8_t * const d64= dither_8x8_73 [y&7];
const uint8_t * const d128=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);
}
}
break;
case IMGFMT_RG4B:
case IMGFMT_BG4B:
{
const uint8_t * const d64= dither_8x8_73 [y&7];
const uint8_t * const d128=dither_8x8_220[y&7];

View File

@ -608,6 +608,118 @@ static void yuv2rgb_c_4 (uint8_t * py_1, uint8_t * py_2,
dst_1 = _dst_1;
dst_2 = _dst_2;
while (h_size--) {
int acc;
#define DST1_4(i) \
Y = py_1[2*i]; \
acc = r[Y] + g[Y] + b[Y]; \
Y = py_1[2*i+1]; \
acc |= (r[Y] + g[Y] + b[Y])<<4;\
dst_1[i] = acc;
#define DST2_4(i) \
Y = py_2[2*i]; \
acc = r[Y] + g[Y] + b[Y]; \
Y = py_2[2*i+1]; \
acc |= (r[Y] + g[Y] + b[Y])<<4;\
dst_2[i] = acc;
RGB(0);
DST1_4(0);
DST2_4(0);
RGB(1);
DST2_4(1);
DST1_4(1);
RGB(2);
DST1_4(2);
DST2_4(2);
RGB(3);
DST2_4(3);
DST1_4(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 4;
dst_2 += 4;
}
}
static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
uint8_t * pu, uint8_t * pv,
void * _dst_1, void * _dst_2, int h_size, int v_pos)
{
int U, V, Y;
uint8_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
h_size >>= 3;
dst_1 = _dst_1;
dst_2 = _dst_2;
while (h_size--) {
const uint8_t *d64= dither_8x8_73[v_pos&7];
const uint8_t *d128=dither_8x8_220[v_pos&7];
int acc;
#define DST1bpp4(i,o) \
Y = py_1[2*i]; \
acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
Y = py_1[2*i+1]; \
acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4;\
dst_1[i]= acc;
#define DST2bpp4(i,o) \
Y = py_2[2*i]; \
acc = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \
Y = py_2[2*i+1]; \
acc |= (r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]])<<4;\
dst_2[i]= acc;
RGB(0);
DST1bpp4(0,0);
DST2bpp4(0,0);
RGB(1);
DST2bpp4(1,2);
DST1bpp4(1,2);
RGB(2);
DST1bpp4(2,4);
DST2bpp4(2,4);
RGB(3);
DST2bpp4(3,6);
DST1bpp4(3,6);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 4;
dst_2 += 4;
}
}
// This is exactly the same code as yuv2rgb_c_32 except for the types of
// r, g, b, dst_1, dst_2
static void yuv2rgb_c_4b (uint8_t * py_1, uint8_t * py_2,
uint8_t * pu, uint8_t * pv,
void * _dst_1, void * _dst_2, int h_size, int v_pos)
{
int U, V, Y;
uint8_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
h_size >>= 3;
dst_1 = _dst_1;
dst_2 = _dst_2;
while (h_size--) {
RGB(0);
DST1(0);
@ -634,7 +746,7 @@ static void yuv2rgb_c_4 (uint8_t * py_1, uint8_t * py_2,
}
}
static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
static void yuv2rgb_c_4b_ordered_dither (uint8_t * py_1, uint8_t * py_2,
uint8_t * pu, uint8_t * pv,
void * _dst_1, void * _dst_2, int h_size, int v_pos)
{
@ -650,13 +762,13 @@ static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
const uint8_t *d64= dither_8x8_73[v_pos&7];
const uint8_t *d128=dither_8x8_220[v_pos&7];
#define DST1bpp4(i,o) \
#define DST1bpp4b(i,o) \
Y = py_1[2*i]; \
dst_1[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
Y = py_1[2*i+1]; \
dst_1[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
#define DST2bpp4(i,o) \
#define DST2bpp4b(i,o) \
Y = py_2[2*i]; \
dst_2[2*i] = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \
Y = py_2[2*i+1]; \
@ -664,20 +776,20 @@ static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
RGB(0);
DST1bpp4(0,0);
DST2bpp4(0,0);
DST1bpp4b(0,0);
DST2bpp4b(0,0);
RGB(1);
DST2bpp4(1,2);
DST1bpp4(1,2);
DST2bpp4b(1,2);
DST1bpp4b(1,2);
RGB(2);
DST1bpp4(2,4);
DST2bpp4(2,4);
DST1bpp4b(2,4);
DST2bpp4b(2,4);
RGB(3);
DST2bpp4(3,6);
DST1bpp4(3,6);
DST2bpp4b(3,6);
DST1bpp4b(3,6);
pu += 4;
pv += 4;
@ -879,7 +991,11 @@ void *yuv2rgb_c_init (unsigned bpp, int mode, void *table_rV[256], void *table_g
}
break;
case 4:
yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4;
case 4|128:
if(bpp==4)
yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4;
else
yuv2rgb_c_internal = yuv2rgb_c_4b_ordered_dither; //yuv2rgb_c_4;
table_start= table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));