# HG changeset patch # User michael # Date 1034469038 0 # Node ID c6aa14b47d035c8e3be2227cfd8b98689b7ddac9 # Parent 41e8d0916c6063233ecfa3c99accf797a8e44c38 yuy2 output support diff -r 41e8d0916c60 -r c6aa14b47d03 libmpcodecs/vf_scale.c --- a/libmpcodecs/vf_scale.c Sat Oct 12 20:02:01 2002 +0000 +++ b/libmpcodecs/vf_scale.c Sun Oct 13 00:30:38 2002 +0000 @@ -53,6 +53,7 @@ IMGFMT_411P, IMGFMT_Y800, IMGFMT_Y8, + IMGFMT_YUY2, 0 }; @@ -176,7 +177,7 @@ MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, vf->priv->w, vf->priv->h); vf->priv->ctx->swScale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride); - + if(vf->priv->w==mpi->w && vf->priv->h==mpi->h){ // just conversion, no scaling -> keep postprocessing data // this way we can apply pp filter to non-yv12 source using scaler diff -r 41e8d0916c60 -r c6aa14b47d03 postproc/swscale.c --- a/postproc/swscale.c Sat Oct 12 20:02:01 2002 +0000 +++ b/postproc/swscale.c Sun Oct 13 00:30:38 2002 +0000 @@ -18,7 +18,7 @@ /* supported Input formats: YV12, I420/IYUV, YUY2, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09 - supported output formats: YV12, I420/IYUV, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09 + supported output formats: YV12, I420/IYUV, YUY2, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09 {BGR,RGB}{1,4,8,15,16} support dithering unscaled special converters (YV12=I420=IYUV, Y800=Y8) @@ -114,7 +114,7 @@ || (x)==IMGFMT_RGB32|| (x)==IMGFMT_RGB24\ || (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9\ || (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P) -#define isSupportedOut(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 \ +#define isSupportedOut(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YUY2\ || (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P\ || isRGB(x) || isBGR(x)\ || (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9) @@ -420,7 +420,8 @@ } } -#define YSCALE_YUV_2_RGBX_C(type) \ + +#define YSCALE_YUV_2_X_C(type) \ for(i=0; i<(dstW>>1); i++){\ int j;\ int Y1=0;\ @@ -454,48 +455,60 @@ else if(U<0) U=0;\ if(V>255) V=255;\ else if(V<0) V=0;\ - }\ + } + +#define YSCALE_YUV_2_RGBX_C(type) \ + YSCALE_YUV_2_X_C(type)\ r = c->table_rV[V];\ g = c->table_gU[U] + c->table_gV[V];\ b = c->table_bU[U];\ -#define YSCALE_YUV_2_RGB2_C(type) \ +#define YSCALE_YUV_2_2_C \ for(i=0; i<(dstW>>1); i++){\ const int i2= 2*i;\ int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19;\ int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19;\ int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19;\ int V= (uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19;\ + +#define YSCALE_YUV_2_RGB2_C(type) \ + YSCALE_YUV_2_2_C\ type *r, *b, *g;\ r = c->table_rV[V];\ g = c->table_gU[U] + c->table_gV[V];\ b = c->table_bU[U];\ -#define YSCALE_YUV_2_RGB1_C(type) \ +#define YSCALE_YUV_2_1_C \ for(i=0; i<(dstW>>1); i++){\ const int i2= 2*i;\ int Y1= buf0[i2 ]>>7;\ int Y2= buf0[i2+1]>>7;\ int U= (uvbuf1[i ])>>7;\ int V= (uvbuf1[i+2048])>>7;\ + +#define YSCALE_YUV_2_RGB1_C(type) \ + YSCALE_YUV_2_1_C\ type *r, *b, *g;\ r = c->table_rV[V];\ g = c->table_gU[U] + c->table_gV[V];\ b = c->table_bU[U];\ -#define YSCALE_YUV_2_RGB1B_C(type) \ +#define YSCALE_YUV_2_1B_C \ for(i=0; i<(dstW>>1); i++){\ const int i2= 2*i;\ int Y1= buf0[i2 ]>>7;\ int Y2= buf0[i2+1]>>7;\ int U= (uvbuf0[i ] + uvbuf1[i ])>>8;\ int V= (uvbuf0[i+2048] + uvbuf1[i+2048])>>8;\ + +#define YSCALE_YUV_2_RGB1B_C(type) \ + YSCALE_YUV_2_1B_C\ type *r, *b, *g;\ r = c->table_rV[V];\ g = c->table_gU[U] + c->table_gV[V];\ b = c->table_bU[U];\ -#define YSCALE_YUV_2_ANYRGB_C(func)\ +#define YSCALE_YUV_2_ANYRGB_C(func, func2)\ switch(c->dstFormat)\ {\ case IMGFMT_BGR32:\ @@ -644,6 +657,14 @@ */\ }\ break;\ + case IMGFMT_YUY2:\ + func2\ + ((uint8_t*)dest)[2*i2+0]= Y1;\ + ((uint8_t*)dest)[2*i2+1]= U;\ + ((uint8_t*)dest)[2*i2+2]= Y2;\ + ((uint8_t*)dest)[2*i2+3]= V;\ + } \ + break;\ }\ @@ -769,6 +790,14 @@ } } break; + case IMGFMT_YUY2: + YSCALE_YUV_2_X_C(void) + ((uint8_t*)dest)[2*i2+0]= Y1; + ((uint8_t*)dest)[2*i2+1]= U; + ((uint8_t*)dest)[2*i2+2]= Y2; + ((uint8_t*)dest)[2*i2+3]= V; + } + break; } } diff -r 41e8d0916c60 -r c6aa14b47d03 postproc/swscale_template.c --- a/postproc/swscale_template.c Sat Oct 12 20:02:01 2002 +0000 +++ b/postproc/swscale_template.c Sun Oct 13 00:30:38 2002 +0000 @@ -1127,7 +1127,7 @@ default: break; } #endif //HAVE_MMX -YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C) +YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_2_C) } /** @@ -1265,9 +1265,9 @@ #endif if( uvalpha < 2048 ) { - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C) + YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_1_C) }else{ - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C) + YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_1B_C) } }