summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmpcodecs/vf_scale.c8
-rw-r--r--libvo/vo_aa.c4
-rw-r--r--libvo/vo_x11.c5
-rw-r--r--postproc/swscale.c82
-rw-r--r--postproc/swscale.h2
-rw-r--r--postproc/swscale_internal.h3
6 files changed, 55 insertions, 49 deletions
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 7539b90a6c..cb2c323ec6 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -166,9 +166,9 @@ static int config(struct vf_instance_s* vf,
int_sws_flags|= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT;
int_sws_flags|= vf->priv->param << SWS_PARAM_SHIFT;
vf->priv->ctx=sws_getContext(width,height,
- (outfmt==IMGFMT_I420 || outfmt==IMGFMT_IYUV)?IMGFMT_YV12:outfmt,
+ outfmt,
vf->priv->w,vf->priv->h,
- (best==IMGFMT_I420 || best==IMGFMT_IYUV)?IMGFMT_YV12:best,
+ best,
int_sws_flags, srcFilter, dstFilter);
if(!vf->priv->ctx){
// error...
@@ -229,7 +229,7 @@ static void draw_slice(struct vf_instance_s* vf,
return;
}
// printf("vf_scale::draw_slice() y=%d h=%d\n",y,h);
- sws_scale(vf->priv->ctx,src,stride,y,h,dmpi->planes,dmpi->stride);
+ sws_scale_ordered(vf->priv->ctx,src,stride,y,h,dmpi->planes,dmpi->stride);
}
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
@@ -244,7 +244,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
dmpi=vf_get_image(vf->next,vf->priv->fmt,
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
vf->priv->w, vf->priv->h);
- sws_scale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride);
+ sws_scale_ordered(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride);
}
diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c
index 770a1c45ec..a8ee832b39 100644
--- a/libvo/vo_aa.c
+++ b/libvo/vo_aa.c
@@ -360,7 +360,7 @@ draw_frame(uint8_t *src[]) {
break;
}
- sws_scale(sws,src,stride,0,src_height,image,image_stride);
+ sws_scale_ordered(sws,src,stride,0,src_height,image,image_stride);
/* Now 'ASCIInate' the image */
if (fast)
@@ -380,7 +380,7 @@ draw_slice(uint8_t *src[], int stride[],
int dx2 = screen_x + ((x+w) * screen_w / src_width);
int dy2 = screen_y + ((y+h) * screen_h / src_height);
- sws_scale(sws,src,stride,y,h,image,image_stride);
+ sws_scale_ordered(sws,src,stride,y,h,image,image_stride);
/* Now 'ASCIInate' the image */
if (fast)
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index 0306f06f0d..8953b73646 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -241,7 +241,6 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t
title = strdup("MPlayer X11 (XImage/Shm) render");
in_format=format;
- if(in_format==IMGFMT_I420 || in_format==IMGFMT_IYUV) in_format=IMGFMT_YV12;
srcW= width;
srcH= height;
vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
@@ -508,13 +507,13 @@ static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y
{
dstStride[0]= -image_width*((bpp+7)/8);
dst[0]=ImageData - dstStride[0]*(image_height-1);
- sws_scale(swsContext,src,stride,y,h,dst, dstStride);
+ sws_scale_ordered(swsContext,src,stride,y,h,dst, dstStride);
}
else
{
dstStride[0]=image_width*((bpp+7)/8);
dst[0]=ImageData;
- sws_scale(swsContext,src,stride,y,h,dst, dstStride);
+ sws_scale_ordered(swsContext,src,stride,y,h,dst, dstStride);
}
return 0;
}
diff --git a/postproc/swscale.c b/postproc/swscale.c
index 985bfdbc6d..ee230b7a26 100644
--- a/postproc/swscale.c
+++ b/postproc/swscale.c
@@ -104,18 +104,18 @@ untested special converters
#endif
//FIXME replace this with something faster
-#define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YVU9 \
+#define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YVU9 \
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P)
#define isYUV(x) ((x)==IMGFMT_UYVY || (x)==IMGFMT_YUY2 || isPlanarYUV(x))
#define isGray(x) ((x)==IMGFMT_Y800)
#define isRGB(x) (((x)&IMGFMT_RGB_MASK)==IMGFMT_RGB)
#define isBGR(x) (((x)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
-#define isSupportedIn(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
+#define isSupportedIn(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
|| (x)==IMGFMT_BGR32|| (x)==IMGFMT_BGR24|| (x)==IMGFMT_BGR16|| (x)==IMGFMT_BGR15\
|| (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 || (x)==IMGFMT_YUY2\
+#define isSupportedOut(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YUY2\
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P\
|| isRGB(x) || isBGR(x)\
|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9)
@@ -1626,10 +1626,8 @@ static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
}
}
dst = dstParam[1] + dstStride[1]*srcSliceY;
- if(c->srcFormat==IMGFMT_YV12)
- interleaveBytes( src[1],src[2],dst,c->srcW,srcSliceH,srcStride[1],srcStride[2],dstStride[0] );
- else /* I420 & IYUV */
- interleaveBytes( src[2],src[1],dst,c->srcW,srcSliceH,srcStride[2],srcStride[1],dstStride[0] );
+ interleaveBytes( src[1],src[2],dst,c->srcW,srcSliceH,srcStride[1],srcStride[2],dstStride[0] );
+
return srcSliceH;
}
@@ -1637,10 +1635,8 @@ static int PlanarToYuy2Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
int srcSliceH, uint8_t* dstParam[], int dstStride[]){
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
- if(c->srcFormat==IMGFMT_YV12)
- yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] );
- else /* I420 & IYUV */
- yv12toyuy2( src[0],src[2],src[1],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] );
+ yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] );
+
return srcSliceH;
}
@@ -1764,15 +1760,15 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
/**
* bring pointers in YUV order instead of YVU
*/
-inline static void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]){
- if(format == IMGFMT_YV12 || format == IMGFMT_YVU9
+static inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]){
+ if(format == IMGFMT_YV12 || format == IMGFMT_YVU9
|| format == IMGFMT_444P || format == IMGFMT_422P || format == IMGFMT_411P){
sortedP[0]= p[0];
- sortedP[1]= p[1];
- sortedP[2]= p[2];
+ sortedP[1]= p[2];
+ sortedP[2]= p[1];
sortedStride[0]= stride[0];
- sortedStride[1]= stride[1];
- sortedStride[2]= stride[2];
+ sortedStride[1]= stride[2];
+ sortedStride[2]= stride[1];
}
else if(isPacked(format) || isGray(format))
{
@@ -1783,14 +1779,14 @@ inline static void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStrid
sortedStride[1]=
sortedStride[2]= 0;
}
- else if(format == IMGFMT_I420)
+ else if(format == IMGFMT_I420 || format == IMGFMT_IYUV)
{
sortedP[0]= p[0];
- sortedP[1]= p[2];
- sortedP[2]= p[1];
+ sortedP[1]= p[1];
+ sortedP[2]= p[2];
sortedStride[0]= stride[0];
- sortedStride[1]= stride[2];
- sortedStride[2]= stride[1];
+ sortedStride[1]= stride[1];
+ sortedStride[2]= stride[2];
}else{
MSG_ERR("internal error in orderYUV\n");
}
@@ -1864,7 +1860,8 @@ static int remove_dup_fourcc(int fourcc)
{
switch(fourcc)
{
- case IMGFMT_IYUV: return IMGFMT_I420;
+ case IMGFMT_I420:
+ case IMGFMT_IYUV: return IMGFMT_YV12;
case IMGFMT_Y8 : return IMGFMT_Y800;
case IMGFMT_IF09: return IMGFMT_YVU9;
default: return fourcc;
@@ -1879,7 +1876,6 @@ static void getSubSampleFactors(int *h, int *v, int format){
*v=0;
break;
case IMGFMT_YV12:
- case IMGFMT_I420:
case IMGFMT_Y800: //FIXME remove after different subsamplings are fully implemented
*h=1;
*v=1;
@@ -1983,24 +1979,24 @@ int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int
return 0;
}
-SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
+SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int dstH, int origDstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter){
SwsContext *c;
int i;
int usesFilter;
int unscaled, needsDither;
+ int srcFormat, dstFormat;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#ifdef ARCH_X86
if(gCpuCaps.hasMMX)
asm volatile("emms\n\t"::: "memory");
#endif
if(swScale==NULL) globalInit();
-//srcFormat= IMGFMT_Y800;
-//dstFormat= IMGFMT_Y800;
+
/* avoid dupplicate Formats, so we dont need to check to much */
- srcFormat = remove_dup_fourcc(srcFormat);
- dstFormat = remove_dup_fourcc(dstFormat);
+ srcFormat = remove_dup_fourcc(origSrcFormat);
+ dstFormat = remove_dup_fourcc(origDstFormat);
unscaled = (srcW == dstW && srcH == dstH);
needsDither= (isBGR(dstFormat) || isRGB(dstFormat))
@@ -2041,6 +2037,8 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
+ c->origDstFormat= origDstFormat;
+ c->origSrcFormat= origSrcFormat;
usesFilter=0;
if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1;
@@ -2081,17 +2079,17 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(unscaled && !usesFilter)
{
/* yv12_to_nv12 */
- if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_NV12)
+ if(srcFormat == IMGFMT_YV12 && dstFormat == IMGFMT_NV12)
{
c->swScale= PlanarToNV12Wrapper;
}
/* yuv2bgr */
- if((srcFormat==IMGFMT_YV12 || srcFormat==IMGFMT_I420 || srcFormat==IMGFMT_422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
+ if((srcFormat==IMGFMT_YV12 || srcFormat==IMGFMT_422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
{
c->swScale= yuv2rgb_get_func_ptr(c);
}
- if( srcFormat==IMGFMT_YVU9 && (dstFormat==IMGFMT_YV12 || dstFormat==IMGFMT_I420) )
+ if( srcFormat==IMGFMT_YVU9 && dstFormat==IMGFMT_YV12 )
{
c->swScale= yvu9toyv12Wrapper;
}
@@ -2115,7 +2113,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
c->swScale= rgb2rgbWrapper;
/* yv12_to_yuy2 */
- if((srcFormat == IMGFMT_YV12||srcFormat==IMGFMT_I420)&&dstFormat == IMGFMT_YUY2)
+ if(srcFormat == IMGFMT_YV12 && dstFormat == IMGFMT_YUY2)
{
c->swScale= PlanarToYuy2Wrapper;
}
@@ -2123,8 +2121,6 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
/* simple copy */
if( srcFormat == dstFormat
- || (srcFormat==IMGFMT_YV12 && dstFormat==IMGFMT_I420)
- || (srcFormat==IMGFMT_I420 && dstFormat==IMGFMT_YV12)
|| (isPlanarYUV(srcFormat) && isGray(dstFormat))
|| (isPlanarYUV(dstFormat) && isGray(srcFormat))
)
@@ -2372,6 +2368,15 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
}
/**
+ * swscale warper, so we dont need to export the SwsContext.
+ * assumes planar YUV to be in YUV order instead of YVU
+ */
+int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]){
+ c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
+}
+
+/**
* swscale warper, so we dont need to export the SwsContext
*/
int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
@@ -2380,11 +2385,10 @@ int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcS
int dstStride[3];
uint8_t *src[3];
uint8_t *dst[3];
-
- sws_orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
- sws_orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam);
+ sws_orderYUV(c->origSrcFormat, src, srcStride, srcParam, srcStrideParam);
+ sws_orderYUV(c->origDstFormat, dst, dstStride, dstParam, dstStrideParam);
//printf("sws: slice %d %d\n", srcSliceY, srcSliceH);
- return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
+ c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
}
/**
diff --git a/postproc/swscale.h b/postproc/swscale.h
index 22ffba8feb..a7dca14ddc 100644
--- a/postproc/swscale.h
+++ b/postproc/swscale.h
@@ -104,6 +104,8 @@ struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, i
SwsFilter *srcFilter, SwsFilter *dstFilter);
int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
+int sws_scale_ordered(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]);
void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); //FIXME try to seperate this
diff --git a/postproc/swscale_internal.h b/postproc/swscale_internal.h
index 84f6db96a2..85caead3ad 100644
--- a/postproc/swscale_internal.h
+++ b/postproc/swscale_internal.h
@@ -35,7 +35,8 @@ typedef struct SwsContext{
int chrSrcW, chrSrcH, chrDstW, chrDstH;
int lumXInc, chrXInc;
int lumYInc, chrYInc;
- int dstFormat, srcFormat;
+ int dstFormat, srcFormat; ///< format 4:2:0 type is allways YV12
+ int origDstFormat, origSrcFormat; ///< format
int chrSrcHSubSample, chrSrcVSubSample;
int chrIntHSubSample, chrIntVSubSample;
int chrDstHSubSample, chrDstVSubSample;