From e02775f59afb46e8d6a49b8ecf1071a88777aec0 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 27 Jun 2002 23:48:53 +0000 Subject: yvu9 -> yv12 unscaled converter with linear chroma scaling git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6583 b3059339-0415-0410-9bf9-f77b7e298cf2 --- postproc/rgb2rgb.c | 13 +++++++ postproc/rgb2rgb.h | 1 + postproc/rgb2rgb_template.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ postproc/swscale.c | 42 ++++++++++++++++++++- 4 files changed, 143 insertions(+), 2 deletions(-) diff --git a/postproc/rgb2rgb.c b/postproc/rgb2rgb.c index 962a58945f..3878e4835f 100644 --- a/postproc/rgb2rgb.c +++ b/postproc/rgb2rgb.c @@ -512,6 +512,19 @@ void yvu9toyv12(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, #endif } +void planar2x(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride) +{ +#ifdef CAN_COMPILE_X86_ASM + // ordered per speed fasterst first + if(gCpuCaps.hasMMX2) + planar2x_MMX2(src, dst, width, height, srcStride, dstStride); + else if(gCpuCaps.has3DNow) + planar2x_3DNow(src, dst, width, height, srcStride, dstStride); + else +#endif + planar2x_C(src, dst, width, height, srcStride, dstStride); +} + /** * * height should be a multiple of 2 and width should be a multiple of 2 (if this is a diff --git a/postproc/rgb2rgb.h b/postproc/rgb2rgb.h index 9fb6da6ef1..a0ce006103 100644 --- a/postproc/rgb2rgb.h +++ b/postproc/rgb2rgb.h @@ -41,6 +41,7 @@ extern void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t extern void rgb24toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, unsigned int lumStride, unsigned int chromStride, unsigned int srcStride); +extern void planar2x(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride); extern void interleaveBytes(uint8_t *src1, uint8_t *src2, uint8_t *dst, unsigned width, unsigned height, unsigned src1Stride, diff --git a/postproc/rgb2rgb_template.c b/postproc/rgb2rgb_template.c index 015e7f2d56..b6c26a11ee 100644 --- a/postproc/rgb2rgb_template.c +++ b/postproc/rgb2rgb_template.c @@ -1295,6 +1295,95 @@ static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, /* XXX: implement upscaling for U,V */ } +static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride) +{ + int x,y; + + // first line + for(x=0; x>2; + dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2; + dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2; + dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2; + } +#endif + dst[srcWidth*2 -1]= + dst[srcWidth*2 -1 + dstStride]= src[srcWidth-1]; + + dst+=dstStride*2; + src+=srcStride; + } + src-=srcStride; + + // last line + for(x=0; xsrcW); + srcPtr+= srcStride[0]; + dstPtr+= dstStride[0]; + } + } + + if(c->dstFormat==IMGFMT_YV12){ + planar2x(src[1], dst[1], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[1]); + planar2x(src[2], dst[2], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[2]); + }else{ + planar2x(src[1], dst[2], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[2]); + planar2x(src[2], dst[1], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[1]); + } +} + /** * bring pointers in YUV order instead of YVU */ @@ -2051,7 +2079,7 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } -#if 1 + /* simple copy */ if( srcFormat == dstFormat || (srcFormat==IMGFMT_YV12 && dstFormat==IMGFMT_I420) @@ -2067,7 +2095,17 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } -#endif + + if( srcFormat==IMGFMT_YVU9 && (dstFormat==IMGFMT_YV12 || dstFormat==IMGFMT_I420) ) + { + c->swScale= yvu9toyv12Wrapper; + + if(flags&SWS_PRINT_INFO) + MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n", + vo_format_name(srcFormat), vo_format_name(dstFormat)); + return c; + } + /* bgr32to24 & rgb32to24*/ if((srcFormat==IMGFMT_BGR32 && dstFormat==IMGFMT_BGR24) ||(srcFormat==IMGFMT_RGB32 && dstFormat==IMGFMT_RGB24)) -- cgit v1.2.3