[XviD-devel] YUV panar
Ivan Kalvachev
ivan at cacad.com
Thu Nov 6 02:23:25 CET 2003
Ivan Kalvachev said:
> Hi,
> I had took a look of xvid decoder routines, and i had found some things
> that are could be done better.
> What I am talking about? The basic thing - colorspaces. And especially
> YUV one.
> So what are the issues.
> 1. I run into XVID_CSP_USER, the same colorspace name exist in api3, but
> is used with completely different purpose (in api4 it is changed to
> XVID_CSP_INTERNAL)
> This is quite confusing and misleading, I recommend to remove it.
>
> 2. The XVID_CSP_USER in api4 is the only colorspace method that correctly
> uses YUV's dec.output.plane[] and dec.output.stride[].
> XVID_CSP_YV12 and XVID_CSP_I420 are calculating their own UV planes
> according to Y plane. I guess this i some legacy win32 issue, but this may
> lead to segfault as e.g. MPlayer uses memaling for each plane.
> These one plane calculations should be moved from xvid and put into vfw &
> dshow!
> I know that you would try keep it, and will try to argue that it is good
> as it is, but believe me, it is lame.
>
> 3. Why YV12 have swapped UV planes? Read the www.fourcc.org and
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/graphics/hh/graphics/dxvaguide_7xgn.asp
> I420 is the one that have UV planes swapped not YV12!!!!
> And IYUV is not YV12! It is Inverted YUV.
> I guess that vfw and dshow have another UV swapping (just like ve_xvid
> used
> to have) and that they should also be fixed. (yeh right before release
> //--------------------------------------------------------------------
>
> So in short. USER becomes I420. YV12 becomes USER with normal order UV
> planes.
> VFW and DSHOW filter got fixed to normal behavior.
>
> I know these are minor issues, but they are affecting the API, and it is
> good to be sorted out ASAP, and to have clean API for the release.
> I have done patch, but be careful with it, it is not tested!
> (well it works with mplayer)
>
> Best Regards
> Ivan Kalvachev
> iive
> _______________________________________________
It looks like my patch have been removed from your mail list agent.
You'd better fix it, becouse i haven't gzip,bzip2,zip etc, it was quite
small already. Oh yes, I see attachment sigh in my mailbox for this
letter.
So I post the patch inside the letter and attach it again.
//-------------------------------------------
diff -Naurdb /develop/xvid/api4/xvidcore/src/encoder.c src/encoder.c
--- /develop/xvid/api4/xvidcore/src/encoder.c 2003-10-27
21:50:50.000000000 +0200
+++ src/encoder.c 2003-11-01 17:39:42.000000000 +0200
@@ -654,7 +654,7 @@
data.max_quant[i] = pEnc->mbParam.max_quant[i];
}
- data.reference.csp = XVID_CSP_USER;
+ data.reference.csp = XVID_CSP_YV12;
data.reference.plane[0] = pEnc->reference->image.y;
data.reference.plane[1] = pEnc->reference->image.u;
data.reference.plane[2] = pEnc->reference->image.v;
@@ -662,7 +662,7 @@
data.reference.stride[1] = pEnc->mbParam.edged_width/2;
data.reference.stride[2] = pEnc->mbParam.edged_width/2;
- data.current.csp = XVID_CSP_USER;
+ data.current.csp = XVID_CSP_YV12;
data.current.plane[0] = frame->image.y;
data.current.plane[1] = frame->image.u;
data.current.plane[2] = frame->image.v;
@@ -688,7 +688,7 @@
} else { /* XVID_PLG_AFTER */
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) {
- data.original.csp = XVID_CSP_USER;
+ data.original.csp = XVID_CSP_YV12;
data.original.plane[0] = original->y;
data.original.plane[1] = original->u;
data.original.plane[2] = original->v;
diff -Naurdb /develop/xvid/api4/xvidcore/src/image/image.c src/image/image.c
--- /develop/xvid/api4/xvidcore/src/image/image.c 2003-10-04
02:08:55.000000000 +0300
+++ src/image/image.c 2003-11-01 17:46:13.000000000 +0200
@@ -622,20 +622,12 @@
interlacing?uyvyi_to_yv12_c:uyvy_to_yv12_c, 2);
break;
- case XVID_CSP_I420:
- yv12_to_yv12(image->y, image->u, image->v, edged_width,
edged_width2,
- src[0], src[0] + src_stride[0]*height, src[0] +
src_stride[0]*height + (src_stride[0]/2)*height2,
- src_stride[0], src_stride[0]/2, width, height,
(csp & XVID_CSP_VFLIP));
- break
- ;
- case XVID_CSP_YV12: /* u/v swapped */
+ case XVID_CSP_I420: /* u/v swapped */
yv12_to_yv12(image->y, image->v, image->u, edged_width,
edged_width2,
- src[0], src[0] + src_stride[0]*height, src[0] +
src_stride[0]*height + (src_stride[0]/2)*height2,
- src_stride[0], src_stride[0]/2, width, height,
(csp & XVID_CSP_VFLIP));
+ src[0], src[1], src[2], src_stride[0], src_stride[1],
+ width, height, (csp & XVID_CSP_VFLIP));
break;
-
- case XVID_CSP_USER:
- /*XXX: support for different u & v strides */
+ case XVID_CSP_YV12:
yv12_to_yv12(image->y, image->u, image->v, edged_width,
edged_width2,
src[0], src[1], src[2], src_stride[0], src_stride[1],
width, height, (csp & XVID_CSP_VFLIP));
@@ -792,23 +784,15 @@
return 0;
case XVID_CSP_I420:
- yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0]
+ dst_stride[0]*height + (dst_stride[0]/2)*height2
,
- dst_stride[0], dst_stride[0]/2,
+ yv12_to_yv12(dst[0], dst[2], dst[1],
+ dst_stride[0], dst_stride[1], /* v:
dst_stride[2] */
image->y, image->u, image->v, edged_width,
edged_width2,
width, height, (csp & XVID_CSP_VFLIP));
return 0;
-
- case XVID_CSP_YV12: /* u,v swapped */
- yv12_to_yv12(dst[0], dst[0] + dst_stride[0]*height, dst[0]
+ dst_stride[0]*height + (dst_stride[0]/2)*height2
,
- dst_stride[0], dst_stride[0]/2,
- image->y, image->v, image->u, edged_width,
edged_width2,
- width, height, (csp & XVID_CSP_VFLIP));
- return 0;
-
- case XVID_CSP_USER : /* u,v swapped */
+ case XVID_CSP_YV12:
yv12_to_yv12(dst[0], dst[1], dst[2],
dst_stride[0], dst_stride[1], /* v:
dst_stride[2] */
- image->y, image->v, image->u, edged_width,
edged_width2,
+ image->y, image->u, image->v, edged_width,
edged_width2,
width, height, (csp & XVID_CSP_VFLIP));
return 0;
diff -Naurdb /develop/xvid/api4/xvidcore/src/xvid.h src/xvid.h
--- /develop/xvid/api4/xvidcore/src/xvid.h 2003-10-09
22:18:07.000000000 +0300
+++ src/xvid.h 2003-11-01 17:45:55.000000000 +0200
@@ -96,9 +96,9 @@
/* colorspace values */
-#define XVID_CSP_USER (1<< 0) /* 4:2:0 planar */
-#define XVID_CSP_I420 (1<< 1) /* 4:2:0 packed(planar win32) */
-#define XVID_CSP_YV12 (1<< 2) /* 4:2:0 packed(planar win32) */
+#define XVID_CSP_YV12 (1<< 0) /* 4:2:0 planar */
+#define XVID_CSP_I420 (1<< 1) /* 4:2:0 planar */
+#define XVID_CSP_FREE (1<< 2) /* fell free to remove it */
#define XVID_CSP_YUY2 (1<< 3) /* 4:2:2 packed */
#define XVID_CSP_UYVY (1<< 4) /* 4:2:2 packed */
#define XVID_CSP_YVYU (1<< 5) /* 4:2:2 packed */
More information about the XviD-devel
mailing list