Mercurial > mplayer.hg
changeset 6451:ed906af317da
8bpp support (no dithering yet, use -vop noise for now)
author | michael |
---|---|
date | Sun, 16 Jun 2002 20:25:50 +0000 |
parents | 07ffd7003dd8 |
children | dae4143c636b |
files | libvo/vo_svga.c postproc/yuv2rgb.c |
diffstat | 2 files changed, 130 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_svga.c Sun Jun 16 14:03:54 2002 +0000 +++ b/libvo/vo_svga.c Sun Jun 16 20:25:50 2002 +0000 @@ -62,6 +62,9 @@ #define BPP_16 2 #define BPP_24 4 #define BPP_32 8 +#define BPP_8 16 +#define BPP_4 32 +#define BPP_2 64 static uint8_t bpp_avail = 0; static uint8_t checked = 0; @@ -126,6 +129,9 @@ switch (list->modeinfo.colors) { case 32768: bpp_avail |= BPP_15; break; 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; } switch (list->modeinfo.bytesperpixel) { case 3: bpp_avail |= BPP_24; break; @@ -181,6 +187,12 @@ } } break; + case 8: if (!(bpp_avail & BPP_8)) { + 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; @@ -207,6 +219,11 @@ return(1); } break; + case 8: if (!(bpp_avail & BPP_8)) { + 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; } } @@ -219,6 +236,9 @@ if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) { if (verbose) { switch (list->modeinfo.colors) { + case 256 : printf("vo_svga: vid_mode: %d, %dx%d 8bpp\n", + list->modenum,list->modeinfo.width,list->modeinfo.height); + break; case 32768: printf("vo_svga: vid_mode: %d, %dx%d 15bpp\n", list->modenum,list->modeinfo.width,list->modeinfo.height); break; @@ -268,11 +288,19 @@ res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; } break; + case 8: if (list->modeinfo.colors == 256) + 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; } - + if((vo_subdevice) && (strlen(vo_subdevice)>2)) { if(!strncmp(vo_subdevice,"old",3)) { oldmethod=1; @@ -291,6 +319,10 @@ buf_h = list->modeinfo.height; res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; switch(list->modeinfo.colors) { + case 256: + bpp=8; + bpp_conv=0; + break; case 32768: bpp=16; bpp_conv=1; @@ -321,7 +353,14 @@ printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode); uninit(); return(1); // error - } + } + + /* set 332 palette for 8 bpp */ + if(bpp==8){ + int i; + for(i=0; i<256; i++) + vga_setpalette(i, (i>>2)&0x38, (i<<1)&0x38, (i<<4)&0x30); + } WIDTH=vga_getxdim(); HEIGHT=vga_getydim(); @@ -524,6 +563,7 @@ if (vga_hasmode(i) > 0) { minfo = vga_getmodeinfo(i); switch (minfo->colors) { + case 256 : bpp_avail |= BPP_8 ; break; case 32768: bpp_avail |= BPP_15; break; case 65536: bpp_avail |= BPP_16; break; } @@ -564,21 +604,24 @@ case 15: if ((format == IMGFMT_RGB15) || (format == IMGFMT_BGR15)) return ((bpp_avail & BPP_15) ? 1 : 0); break; + case 8 : if ((format == IMGFMT_RGB8 ) || (format == IMGFMT_BGR8)) + return ((bpp_avail & BPP_8 ) ? 1 : 0); + break; } } else { switch (format) { - case IMGFMT_RGB32: + case IMGFMT_RGB32: case IMGFMT_BGR32: return ((bpp_avail & BPP_32) ? 1 : 0); break; - case IMGFMT_RGB24: + case IMGFMT_RGB24: case IMGFMT_BGR24: { res = (bpp_avail & BPP_24) ? 1 : 0; if (!res) res = (bpp_avail & BPP_32) ? 1 : 0; return (res); } break; - case IMGFMT_RGB16: + case IMGFMT_RGB16: case IMGFMT_BGR16: return ((bpp_avail & BPP_16) ? 1 : 0); break; - case IMGFMT_RGB15: + case IMGFMT_RGB15: case IMGFMT_BGR15: { res = (bpp_avail & BPP_15) ? 1 : 0; if (!res) @@ -586,6 +629,8 @@ return (res); } break; case IMGFMT_YV12: return (1); break; + case IMGFMT_RGB8: + case IMGFMT_BGR8: return ((bpp_avail & BPP_8) ? 1 : 0); break; } } return (0); @@ -599,7 +644,7 @@ while( (h--) > 0 ) { memcpy(buffer+x*BYTESPERPIXEL+(y++)*LINEWIDTH, buf, wid); buf+=add; - } + } } else { wid=w*BYTESPERPIXEL; add=wid*prog;
--- a/postproc/yuv2rgb.c Sun Jun 16 14:03:54 2002 +0000 +++ b/postproc/yuv2rgb.c Sun Jun 16 20:25:50 2002 +0000 @@ -392,6 +392,47 @@ } } +// 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 (uint8_t * py_1, uint8_t * py_2, + uint8_t * pu, uint8_t * pv, + void * _dst_1, void * _dst_2, int h_size) +{ + 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); + 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 int div_round (int dividend, int divisor) { if (dividend > 0) @@ -407,6 +448,7 @@ uint32_t *table_32 = 0; uint16_t *table_16 = 0; uint8_t *table_8 = 0; + uint8_t *table_332 = 0; int entry_size = 0; void *table_r = 0, *table_g = 0, *table_b = 0; @@ -489,6 +531,42 @@ } break; + case 8: + yuv2rgb_c_internal = yuv2rgb_c_8; + + table_332 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); + + entry_size = sizeof (uint8_t); + table_r = table_332 + 197; + table_b = table_332 + 197 + 685; + table_g = table_332 + 197 + 2*682; + + for (i = -197; i < 256+197; i++) { + int j = table_Y[i+384] >> 5; + + if (mode == MODE_RGB) + j <<= 5; + + ((uint8_t *)table_r)[i] = j; + } + for (i = -132; i < 256+132; i++) { + int j = table_Y[i+384] >> 5; + + if (mode == MODE_BGR) + j <<= 1; + + ((uint8_t *)table_g)[i] = j << 2; + } + for (i = -232; i < 256+232; i++) { + int j = table_Y[i+384] >> 6; + + if (mode == MODE_BGR) + j <<= 6; + + ((uint8_t *)table_b)[i] = j; + } + break; + default: mp_msg(MSGT_SWS,MSGL_ERR,"%ibpp not supported by yuv2rgb\n", bpp); //exit (1);