From: Michael Niedermayer Date: Wed, 6 Feb 2002 21:59:23 +0000 (+0000) Subject: 101 (yuv2rgb with mpeg1,...) ;) X-Git-Tag: v0.5~18044 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6654a5464a77bb885ce0d17224f9edbe07d67ba;p=platform%2Fupstream%2Flibav.git 101 (yuv2rgb with mpeg1,...) ;) simple copy if possible (same format, no scaling, ...) Originally committed as revision 4556 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc --- diff --git a/postproc/swscale.c b/postproc/swscale.c index d86edf1..21f1466 100644 --- a/postproc/swscale.c +++ b/postproc/swscale.c @@ -557,7 +557,7 @@ void SwScale_YV12slice(unsigned char* src[], int srcStride[], int srcSliceY , if(!context) context=getSwsContextFromCmdLine(srcW, srcH, IMGFMT_YV12, dstW, dstH, dstFormat); - swScale(context, src, srcStride, srcSliceY, srcSliceH, dst, dstStride3); + context->swScale(context, src, srcStride, srcSliceY, srcSliceH, dst, dstStride3); } // will use sws_flags & src_filter (from cmd line) @@ -1111,12 +1111,110 @@ cpuCaps= gCpuCaps; /* Warper functions for yuv2bgr */ static void planarYuvToBgr(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, - int srcSliceH, uint8_t* dst[], int dstStride[]){ + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; if(c->srcFormat==IMGFMT_YV12) - yuv2rgb( dst[0],src[0],src[1],src[2],c->srcW,c->srcH,dstStride[0],srcStride[0],srcStride[1] ); + yuv2rgb( dst,src[0],src[1],src[2],c->srcW,srcSliceH,dstStride[0],srcStride[0],srcStride[1] ); else /* I420 & IYUV */ - yuv2rgb( dst[0],src[0],src[2],src[1],c->srcW,c->srcH,dstStride[0],srcStride[0],srcStride[1] ); + yuv2rgb( dst,src[0],src[2],src[1],c->srcW,srcSliceH,dstStride[0],srcStride[0],srcStride[1] ); +} + +/* unscaled copy like stuff (assumes nearly identical formats) */ +static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + + int srcStride[3]; + uint8_t *src[3]; + uint8_t *dst[3]; + + if(c->srcFormat == IMGFMT_I420){ + src[0]= srcParam[0]; + src[1]= srcParam[2]; + src[2]= srcParam[1]; + srcStride[0]= srcStrideParam[0]; + srcStride[1]= srcStrideParam[2]; + srcStride[2]= srcStrideParam[1]; + } + else if(c->srcFormat==IMGFMT_YV12){ + src[0]= srcParam[0]; + src[1]= srcParam[1]; + src[2]= srcParam[2]; + srcStride[0]= srcStrideParam[0]; + srcStride[1]= srcStrideParam[1]; + srcStride[2]= srcStrideParam[2]; + } + else if(isPacked(c->srcFormat) || isGray(c->srcFormat)){ + src[0]= srcParam[0]; + src[1]= + src[2]= NULL; + srcStride[0]= srcStrideParam[0]; + srcStride[1]= + srcStride[2]= 0; + } + + if(c->dstFormat == IMGFMT_I420){ + dst[0]= dstParam[0]; + dst[1]= dstParam[2]; + dst[2]= dstParam[1]; + + }else{ + dst[0]= dstParam[0]; + dst[1]= dstParam[1]; + dst[2]= dstParam[2]; + } + + if(isPacked(c->srcFormat)) + { + if(dstStride[0]==srcStride[0]) + memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]); + else + { + int i; + uint8_t *srcPtr= src[0]; + uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY; + int length; + + if(c->srcFormat==IMGFMT_YUY2) length= c->srcW*2; + else if(c->srcFormat==IMGFMT_BGR15) length= c->srcW*2; + else if(c->srcFormat==IMGFMT_BGR16) length= c->srcW*2; + else if(c->srcFormat==IMGFMT_BGR24) length= c->srcW*3; + else if(c->srcFormat==IMGFMT_BGR32) length= c->srcW*4; + else return; /* that shouldnt happen */ + + for(i=0; isrcW : ((c->srcW+1)>>1); + int y= plane==0 ? srcSliceY: ((srcSliceY+1)>>1); + int height= plane==0 ? srcSliceH: ((srcSliceH+1)>>1); +printf("%d %d %d %d %d %d\n", plane, length, y, height, dstStride[plane], srcStride[plane] ); + if(dstStride[plane]==srcStride[plane]) + memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]); + else + { + int i; + uint8_t *srcPtr= src[plane]; + uint8_t *dstPtr= dst[plane] + dstStride[plane]*y; + for(i=0; iswScale= planarYuvToBgr; - + + if(flags&SWS_PRINT_INFO) + printf("SwScaler: using unscaled %s -> %s special converter\n", + vo_format_name(srcFormat), vo_format_name(dstFormat)); + return c; + } + + /* simple copy */ + if(srcFormat == dstFormat || (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat))) + { + c->swScale= simpleCopy; + if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat));