changeset 10742:794b55a44528

basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
author alex
date Sun, 31 Aug 2003 20:45:06 +0000
parents fec729835823
children 3d1eab0d9c5a
files libmpcodecs/img_format.c libmpcodecs/img_format.h libmpcodecs/mp_image.h libmpcodecs/vd_raw.c
diffstat 4 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/img_format.c	Sun Aug 31 20:36:33 2003 +0000
+++ b/libmpcodecs/img_format.c	Sun Aug 31 20:45:06 2003 +0000
@@ -32,6 +32,7 @@
 	case IMGFMT_422P: return("Planar 422P");
 	case IMGFMT_411P: return("Planar 411P");
 	case IMGFMT_NV12: return("Planar NV12");
+	case IMGFMT_NV21: return("Planar NV21");
         case IMGFMT_HM12: return("Planar NV12 Macroblock");
 	case IMGFMT_IUYV: return("Packed IUYV");
 	case IMGFMT_IY41: return("Packed IY41");
--- a/libmpcodecs/img_format.h	Sun Aug 31 20:36:33 2003 +0000
+++ b/libmpcodecs/img_format.h	Sun Aug 31 20:45:06 2003 +0000
@@ -44,6 +44,7 @@
 #define IMGFMT_Y800 0x30303859
 #define IMGFMT_Y8   0x20203859
 #define IMGFMT_NV12 0x3231564E
+#define IMGFMT_NV21 0x3132564E
 
 /* unofficial Planar Formats, FIXME if official 4CC exists */
 #define IMGFMT_444P 0x50343434
--- a/libmpcodecs/mp_image.h	Sun Aug 31 20:36:33 2003 +0000
+++ b/libmpcodecs/mp_image.h	Sun Aug 31 20:45:06 2003 +0000
@@ -183,6 +183,17 @@
 	mpi->bpp=16;
 	mpi->num_planes=1;
 	return;
+    case IMGFMT_NV12:
+	mpi->flags|=MP_IMGFLAG_SWAPPED;
+    case IMGFMT_NV21:
+	mpi->flags|=MP_IMGFLAG_PLANAR;
+	mpi->bpp=12;
+	mpi->num_planes=2;
+	mpi->chroma_width=(mpi->width>>0);
+	mpi->chroma_height=(mpi->height>>1);
+	mpi->chroma_x_shift=0;
+	mpi->chroma_y_shift=1;
+	return;
     }
     printf("mp_image: Unknown out_fmt: 0x%X\n",out_fmt);
     mpi->bpp=0;
--- a/libmpcodecs/vd_raw.c	Sun Aug 31 20:36:33 2003 +0000
+++ b/libmpcodecs/vd_raw.c	Sun Aug 31 20:45:06 2003 +0000
@@ -68,13 +68,18 @@
 	mpi->planes[0]=data;
 	mpi->stride[0]=mpi->width;
 	frame_size=mpi->stride[0]*mpi->h;
-        if(mpi->flags&MP_IMGFLAG_YUV) {
+	if((mpi->imgfmt == IMGFMT_NV12) || (mpi->imgfmt == IMGFMT_NV21))
+	{
+	    mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
+	    mpi->stride[1]=mpi->chroma_width;
+	    frame_size+=mpi->chroma_width*mpi->chroma_height;
+	} else if(mpi->flags&MP_IMGFLAG_YUV) {
+    	    int cb=2, cr=1;
+    	    if(mpi->flags&MP_IMGFLAG_SWAPPED) {
+        	cb=1; cr=2;
+    	    }
             // Support for some common Planar YUV formats
 	    /* YV12,I420,IYUV */
-            int cb=2, cr=1;
-            if(mpi->flags&MP_IMGFLAG_SWAPPED) {
-                cb=1; cr=2;
-            }
             mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height;
             mpi->stride[cb]=mpi->chroma_width;
             mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height;