summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libvo/vo_svga.c69
-rw-r--r--postproc/yuv2rgb.c173
2 files changed, 230 insertions, 12 deletions
diff --git a/libvo/vo_svga.c b/libvo/vo_svga.c
index 367855f419..c5c465a9c7 100644
--- a/libvo/vo_svga.c
+++ b/libvo/vo_svga.c
@@ -64,7 +64,7 @@ static uint32_t pformat;
#define BPP_32 8
#define BPP_8 16
#define BPP_4 32
-#define BPP_2 64
+#define BPP_1 64
static uint8_t bpp_avail = 0;
static uint8_t checked = 0;
@@ -131,7 +131,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
case 65536: bpp_avail |= BPP_16; break;
case 256 : bpp_avail |= BPP_8; break;
case 16 : bpp_avail |= BPP_4; break;
- case 2 : bpp_avail |= BPP_2; break;
+ case 2 : bpp_avail |= BPP_1; break;
}
switch (list->modeinfo.bytesperpixel) {
case 3: bpp_avail |= BPP_24; break;
@@ -193,6 +193,18 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
return(1);
}
break;
+ case 4: if (!(bpp_avail & BPP_4)) {
+ printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
+ printf("vo_svga: Maybe you should try -bpp\n");
+ return(1);
+ }
+ break;
+ case 1: if (!(bpp_avail & BPP_1)) {
+ printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
+ printf("vo_svga: Maybe you should try -bpp\n");
+ return(1);
+ }
+ break;
}
} else {
bpp = vo_dbpp;
@@ -224,6 +236,16 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
return(1);
}
break;
+ case 4: if (!(bpp_avail & BPP_4)) {
+ printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
+ return(1);
+ }
+ break;
+ case 1: if (!(bpp_avail & BPP_1)) {
+ printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
+ return(1);
+ }
+ break;
}
}
@@ -236,6 +258,12 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
if (verbose) {
switch (list->modeinfo.colors) {
+ case 2 : printf("vo_svga: vid_mode: %d, %dx%d 1bpp\n",
+ list->modenum,list->modeinfo.width,list->modeinfo.height);
+ break;
+ case 16 : printf("vo_svga: vid_mode: %d, %dx%d 4bpp\n",
+ list->modenum,list->modeinfo.width,list->modeinfo.height);
+ break;
case 256 : printf("vo_svga: vid_mode: %d, %dx%d 8bpp\n",
list->modenum,list->modeinfo.width,list->modeinfo.height);
break;
@@ -296,6 +324,22 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
}
break;
+ case 4: if (list->modeinfo.colors ==16)
+ if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
+ vid_mode = list->modenum;
+ buf_w = list->modeinfo.width;
+ buf_h = list->modeinfo.height;
+ res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
+ }
+ break;
+ case 1: if (list->modeinfo.colors == 2)
+ if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
+ vid_mode = list->modenum;
+ buf_w = list->modeinfo.width;
+ buf_h = list->modeinfo.height;
+ res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
+ }
+ break;
}
}
list = list->next;
@@ -319,6 +363,14 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
buf_h = list->modeinfo.height;
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
switch(list->modeinfo.colors) {
+ case 2:
+ bpp=1;
+ bpp_conv=0;
+ break;
+ case 16:
+ bpp=4;
+ bpp_conv=0;
+ break;
case 256:
bpp=8;
bpp_conv=0;
@@ -359,12 +411,18 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
if(bpp==8){
int i;
for(i=0; i<256; i++)
- vga_setpalette(i, (i>>2)&0x38, (i<<1)&0x38, (i<<4)&0x30);
+ vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21);
+ }
+ /* set 121 palette for 4 bpp */
+ else if(bpp==4){
+ int i;
+ for(i=0; i<16; i++)
+ vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63);
}
WIDTH=vga_getxdim();
HEIGHT=vga_getydim();
- BYTESPERPIXEL=(bpp+1)>>3;
+ BYTESPERPIXEL=(bpp+4)>>3;
LINEWIDTH=WIDTH*BYTESPERPIXEL;
vga_setlinearaddressing();
if(oldmethod) {
@@ -563,6 +621,8 @@ static int checksupportedmodes() {
if (vga_hasmode(i) > 0) {
minfo = vga_getmodeinfo(i);
switch (minfo->colors) {
+ case 2 : bpp_avail |= BPP_1 ; break;
+ case 16 : bpp_avail |= BPP_4 ; break;
case 256 : bpp_avail |= BPP_8 ; break;
case 32768: bpp_avail |= BPP_15; break;
case 65536: bpp_avail |= BPP_16; break;
@@ -607,6 +667,7 @@ static uint32_t query_format(uint32_t format) {
case 8 : if ((format == IMGFMT_RGB8 ) || (format == IMGFMT_BGR8))
return ((bpp_avail & BPP_8 ) ? 1 : 0);
break;
+ //FIXME RGB4 RGB1 ?
}
} else {
switch (format) {
diff --git a/postproc/yuv2rgb.c b/postproc/yuv2rgb.c
index 07487027f6..ef653f8f8b 100644
--- a/postproc/yuv2rgb.c
+++ b/postproc/yuv2rgb.c
@@ -87,20 +87,42 @@ uint64_t __attribute__((aligned(8))) dither8[2]={
0x0602060206020602LL,
0x0004000400040004LL,};
-uint8_t __attribute__((aligned(8))) dither32[4][8]={
+uint8_t __attribute__((aligned(8))) dither_4x4_32[4][8]={
{ 0,16, 6,22, 0,16, 6,22},
{28, 8,24,14,28, 8,24,14},
{ 4,20, 2,18, 4,20, 2,18},
{26,12,30,10,26,12,30,10},
};
-uint8_t __attribute__((aligned(8))) dither64[4][8]={
+uint8_t __attribute__((aligned(8))) dither_4x4_64[4][8]={
{ 8,40, 4,36, 8,40, 4,36,},
{52,24,60,20,52,24,60,20,},
{00,32,12,44,00,32,12,44,},
{56,16,48,28,56,16,48,28,},
};
+uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={
+{ 0, 48, 12, 60, 3, 51, 15, 63, },
+{ 32, 16, 44, 28, 35, 19, 47, 31, },
+{ 8, 56, 4, 52, 11, 59, 7, 55, },
+{ 40, 24, 36, 20, 43, 27, 39, 23, },
+{ 2, 50, 14, 62, 1, 49, 13, 61, },
+{ 34, 18, 46, 30, 33, 17, 45, 29, },
+{ 10, 58, 6, 54, 9, 57, 5, 53, },
+{ 42, 26, 38, 22, 41, 25, 37, 21, },
+};
+
+uint8_t __attribute__((aligned(8))) dither_8x8_128[8][8]={
+{ 68, 36, 92, 60, 66, 34, 90, 58, },
+{ 20, 116, 12, 108, 18, 114, 10, 106, },
+{ 84, 52, 76, 44, 82, 50, 74, 42, },
+{ 0, 96, 24, 120, 6, 102, 30, 126, },
+{ 64, 32, 88, 56, 70, 38, 94, 62, },
+{ 16, 112, 8, 104, 22, 118, 14, 110, },
+{ 80, 48, 72, 40, 86, 54, 78, 46, },
+{ 4, 100, 28, 124, 2, 98, 26, 122, },
+};
+
#undef HAVE_MMX
#undef ARCH_X86
@@ -447,7 +469,6 @@ static void yuv2rgb_c_8 (uint8_t * py_1, uint8_t * py_2,
}
}
-// 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_8_ordered_dither (uint8_t * py_1, uint8_t * py_2,
uint8_t * pu, uint8_t * pv,
@@ -462,8 +483,8 @@ static void yuv2rgb_c_8_ordered_dither (uint8_t * py_1, uint8_t * py_2,
dst_2 = _dst_2;
while (h_size--) {
- uint8_t *d32= dither32[v_pos&3];
- uint8_t *d64= dither64[v_pos&3];
+ uint8_t *d32= dither_4x4_32[v_pos&3];
+ uint8_t *d64= dither_4x4_64[v_pos&3];
#define DST1a(i) \
Y = py_1[2*i]; \
@@ -514,6 +535,102 @@ static void yuv2rgb_c_8_ordered_dither (uint8_t * py_1, uint8_t * py_2,
}
}
+
+// 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_4 (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, out;
+ 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);
+ DST2(0);
+
+ RGB(1);
+ DST2(1);
+ DST1(1);
+
+ RGB(2);
+ DST1(2);
+ DST2(2);
+
+ RGB(3);
+ DST2(3);
+ DST1(3);
+
+ pu += 4;
+ pv += 4;
+ py_1 += 8;
+ py_2 += 8;
+ dst_1 += 8;
+ dst_2 += 8;
+ }
+}
+
+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--) {
+ uint8_t *d64= dither_8x8_64 [v_pos&7];
+ uint8_t *d128=dither_8x8_128[v_pos&7];
+
+#define DST1bpp4(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) \
+ 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]; \
+ dst_2[2*i+1] = r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]];
+
+
+ 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 += 8;
+ dst_2 += 8;
+ }
+}
+
+
static int div_round (int dividend, int divisor)
{
if (dividend > 0)
@@ -530,6 +647,8 @@ static void yuv2rgb_c_init (int bpp, int mode)
uint16_t *table_16 = 0;
uint8_t *table_8 = 0;
uint8_t *table_332 = 0;
+ uint8_t *table_121 = 0;
+ uint8_t *table_1 = 0;
int entry_size = 0;
void *table_r = 0, *table_g = 0, *table_b = 0;
@@ -623,7 +742,8 @@ static void yuv2rgb_c_init (int bpp, int mode)
table_g = table_332 + 197 + 2*682;
for (i = -197; i < 256+197; i++) {
- int j = table_Y[i+384] >> 5;
+ int j = (table_Y[i+384] - 16) >> 5;
+ if(j<0) j=0;
if (mode == MODE_RGB)
j <<= 5;
@@ -631,7 +751,8 @@ static void yuv2rgb_c_init (int bpp, int mode)
((uint8_t *)table_r)[i] = j;
}
for (i = -132; i < 256+132; i++) {
- int j = table_Y[i+384] >> 5;
+ int j = (table_Y[i+384] - 16) >> 5;
+ if(j<0) j=0;
if (mode == MODE_BGR)
j <<= 1;
@@ -639,7 +760,8 @@ static void yuv2rgb_c_init (int bpp, int mode)
((uint8_t *)table_g)[i] = j << 2;
}
for (i = -232; i < 256+232; i++) {
- int j = table_Y[i+384] >> 6;
+ int j = (table_Y[i+384] - 32) >> 6;
+ if(j<0) j=0;
if (mode == MODE_BGR)
j <<= 6;
@@ -647,6 +769,41 @@ static void yuv2rgb_c_init (int bpp, int mode)
((uint8_t *)table_b)[i] = j;
}
break;
+ case 4:
+ yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4;
+
+ table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
+
+ entry_size = sizeof (uint8_t);
+ table_r = table_121 + 197;
+ table_b = table_121 + 197 + 685;
+ table_g = table_121 + 197 + 2*682;
+
+ for (i = -197; i < 256+197; i++) {
+ int j = (table_Y[i+384] - 64) >> 7;
+ if(j<0) j=0;
+
+ if (mode == MODE_RGB)
+ j <<= 3;
+
+ ((uint8_t *)table_r)[i] = j;
+ }
+ for (i = -132; i < 256+132; i++) {
+ int j = (table_Y[i+384] - 32) >> 6;
+ if(j<0) j=0;
+
+ ((uint8_t *)table_g)[i] = j << 1;
+ }
+ for (i = -232; i < 256+232; i++) {
+ int j =(table_Y[i+384] - 64) >> 7;
+ if(j<0) j=0;
+
+ if (mode == MODE_BGR)
+ j <<= 3;
+
+ ((uint8_t *)table_b)[i] = j;
+ }
+ break;
default:
mp_msg(MSGT_SWS,MSGL_ERR,"%ibpp not supported by yuv2rgb\n", bpp);