Mercurial > mplayer.hg
changeset 6456:f0b64210ce97
1bpp support
author | michael |
---|---|
date | Mon, 17 Jun 2002 12:40:40 +0000 |
parents | c4078c1f9d53 |
children | 95918d5066b6 |
files | libvo/vo_svga.c postproc/yuv2rgb.c |
diffstat | 2 files changed, 125 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_svga.c Mon Jun 17 08:18:45 2002 +0000 +++ b/libvo/vo_svga.c Mon Jun 17 12:40:40 2002 +0000 @@ -423,7 +423,11 @@ WIDTH=vga_getxdim(); HEIGHT=vga_getydim(); BYTESPERPIXEL=(bpp+4)>>3; - LINEWIDTH=WIDTH*BYTESPERPIXEL; + if(bpp==1) + LINEWIDTH=(WIDTH+7)/8; + else + LINEWIDTH=WIDTH*BYTESPERPIXEL; + vga_setlinearaddressing(); if(oldmethod) { buffer=malloc(HEIGHT*LINEWIDTH); @@ -453,7 +457,11 @@ if (pformat == IMGFMT_YV12) { yuv2rgb_init(bpp, MODE_RGB); - yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL); + if(bpp==1) + yuvbuf = malloc((maxw+7)/8 * maxh); + else + yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL); + if (yuvbuf == NULL) { printf("vo_svga: yuvbuf -> Not enough memory for buffering!\n"); uninit(); @@ -476,7 +484,10 @@ static uint32_t draw_frame(uint8_t *src[]) { if (pformat == IMGFMT_YV12) { - yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2); + if(bpp==1) + yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, (orig_w+7)/8, orig_w, orig_w / 2); + else + yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2); src[0] = yuvbuf; } if (bpp_conv) { @@ -509,8 +520,11 @@ int w, int h, int x, int y) { uint8_t *src = yuvbuf; uint32_t sw, sh; - - yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]); + if(bpp==1) + yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, (orig_w+7)/8, stride[0], stride[1]); + else + yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]); + putbox(x + x_pos, y + y_pos, w, h, src, 1); return (0); @@ -699,15 +713,21 @@ static void putbox(int x, int y, int w, int h, uint8_t *buf, int prog) { int base, add, wid; + if(bpp==1) + wid=(w+7)/8; + else + wid=w*BYTESPERPIXEL; + if(oldmethod) { - wid=w*BYTESPERPIXEL; add=wid*prog; while( (h--) > 0 ) { - memcpy(buffer+x*BYTESPERPIXEL+(y++)*LINEWIDTH, buf, wid); + if(bpp==1) + memcpy(buffer+(x+7)/8+(y++)*LINEWIDTH, buf, wid); + else + memcpy(buffer+x*BYTESPERPIXEL+(y++)*LINEWIDTH, buf, wid); buf+=add; } } else { - wid=w*BYTESPERPIXEL; add=wid*prog; base=frame*HEIGHT; while( (h--) > 0 ) {
--- a/postproc/yuv2rgb.c Mon Jun 17 08:18:45 2002 +0000 +++ b/postproc/yuv2rgb.c Mon Jun 17 12:40:40 2002 +0000 @@ -26,7 +26,7 @@ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * MMX/MMX2 Template stuff from Michael Niedermayer (michaelni@gmx.at) (needed for fast movntq support) - * 8bpp support by Michael Niedermayer (michaelni@gmx.at) + * 1,4,8bpp support by Michael Niedermayer (michaelni@gmx.at) */ #include <stdio.h> @@ -87,18 +87,15 @@ 0x0602060206020602LL, 0x0004000400040004LL,}; -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))) 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_32[8][8]={ +{ 17, 9, 23, 15, 16, 8, 22, 14, }, +{ 5, 29, 3, 27, 4, 28, 2, 26, }, +{ 21, 13, 19, 11, 20, 12, 18, 10, }, +{ 0, 24, 6, 30, 1, 25, 7, 31, }, +{ 16, 8, 22, 14, 17, 9, 23, 15, }, +{ 4, 28, 2, 26, 5, 29, 3, 27, }, +{ 20, 12, 18, 10, 21, 13, 19, 11, }, +{ 1, 25, 7, 31, 0, 24, 6, 30, }, }; uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={ @@ -174,7 +171,7 @@ int rgb_stride, int y_stride, int uv_stride) { v_size >>= 1; - + while (v_size--) { yuv2rgb_c_internal (py, py + y_stride, pu, pv, dst, dst + rgb_stride, h_size, v_size<<1); @@ -483,48 +480,36 @@ dst_2 = _dst_2; while (h_size--) { - uint8_t *d32= dither_4x4_32[v_pos&3]; - uint8_t *d64= dither_4x4_64[v_pos&3]; - -#define DST1a(i) \ + uint8_t *d32= dither_8x8_32[v_pos&7]; + uint8_t *d64= dither_8x8_64[v_pos&7]; +#define DST1bpp8(i,o) \ Y = py_1[2*i]; \ - dst_1[2*i] = r[Y+d32[0]] + g[Y+d32[0]] + b[Y+d64[0]]; \ + dst_1[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \ Y = py_1[2*i+1]; \ - dst_1[2*i+1] = r[Y+d32[1]] + g[Y+d32[1]] + b[Y+d64[1]]; + dst_1[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]]; -#define DST2a(i) \ +#define DST2bpp8(i,o) \ Y = py_2[2*i]; \ - dst_2[2*i] = r[Y+d32[8]] + g[Y+d32[8]] + b[Y+d64[8]]; \ + dst_2[2*i] = r[Y+d32[8+o]] + g[Y+d32[8+o]] + b[Y+d64[8+o]]; \ Y = py_2[2*i+1]; \ - dst_2[2*i+1] = r[Y+d32[9]] + g[Y+d32[9]] + b[Y+d64[9]]; + dst_2[2*i+1] = r[Y+d32[9+o]] + g[Y+d32[9+o]] + b[Y+d64[9+o]]; -#define DST1b(i) \ - Y = py_1[2*i]; \ - dst_1[2*i] = r[Y+d32[2]] + g[Y+d32[2]] + b[Y+d64[2]]; \ - Y = py_1[2*i+1]; \ - dst_1[2*i+1] = r[Y+d32[3]] + g[Y+d32[3]] + b[Y+d64[3]]; - -#define DST2b(i) \ - Y = py_2[2*i]; \ - dst_2[2*i] = r[Y+d32[10]] + g[Y+d32[10]] + b[Y+d64[10]]; \ - Y = py_2[2*i+1]; \ - dst_2[2*i+1] = r[Y+d32[11]] + g[Y+d32[11]] + b[Y+d64[11]]; RGB(0); - DST1a(0); - DST2a(0); + DST1bpp8(0,0); + DST2bpp8(0,0); RGB(1); - DST2b(1); - DST1b(1); + DST2bpp8(1,2); + DST1bpp8(1,2); RGB(2); - DST1a(2); - DST2a(2); + DST1bpp8(2,4); + DST2bpp8(2,4); RGB(3); - DST2b(3); - DST1b(3); + DST2bpp8(3,6); + DST1bpp8(3,6); pu += 4; pv += 4; @@ -630,6 +615,59 @@ } } +static void yuv2rgb_c_1_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; + g= table_gU[128] + table_gV[128]; + + while (h_size--) { + uint8_t *d128=dither_8x8_128[v_pos&7]; + char out_1=0, out_2=0; + +#define DST1bpp1(i,o) \ + Y = py_1[2*i]; \ + out_1+= out_1 + g[Y+d128[0+o]]; \ + Y = py_1[2*i+1]; \ + out_1+= out_1 + g[Y+d128[1+o]]; + +#define DST2bpp1(i,o) \ + Y = py_2[2*i]; \ + out_2+= out_2 + g[Y+d128[8+o]]; \ + Y = py_2[2*i+1]; \ + out_2+= out_2 + g[Y+d128[9+o]]; + + DST1bpp1(0,0); + DST2bpp1(0,0); + + DST2bpp1(1,2); + DST1bpp1(1,2); + + DST1bpp1(2,4); + DST2bpp1(2,4); + + DST2bpp1(3,6); + DST1bpp1(3,6); + + dst_1[0]= out_1; + dst_2[0]= out_2; + + pu += 4; + pv += 4; + py_1 += 8; + py_2 += 8; + dst_1 ++; + dst_2 ++; + } +} + static int div_round (int dividend, int divisor) { @@ -805,6 +843,23 @@ } break; + case 1: + yuv2rgb_c_internal = yuv2rgb_c_1_ordered_dither; + + table_1 = malloc ((132*2 + 256) * sizeof (uint8_t)); + + entry_size = sizeof (uint8_t); + table_g = table_1 + 132; + table_r = table_b = NULL; + + for (i = -132; i < 256+132; i++) { + int j = (table_Y[i+384] - 64) >> 7; + if(j<0) j=0; + + ((uint8_t *)table_g)[i] = j; + } + break; + default: mp_msg(MSGT_SWS,MSGL_ERR,"%ibpp not supported by yuv2rgb\n", bpp); //exit (1);