changeset 30115:ad61464d02a7

Add support for YUV format with alpha and fix the codecs.conf entry for vp6a to use it. Fixes playback of samples in http://samples.mplayerhq.hu/FLV/flash_with_alpha/
author reimar
date Thu, 31 Dec 2009 23:45:07 +0000
parents 7470ba76f228
children f2d9ce0a6b28
files codec-cfg.c etc/codecs.conf fmt-conversion.c libmpcodecs/img_format.c libmpcodecs/img_format.h libmpcodecs/mp_image.c libmpcodecs/mp_image.h libmpcodecs/vf_scale.c m_option.c
diffstat 9 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/codec-cfg.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/codec-cfg.c	Thu Dec 31 23:45:07 2009 +0000
@@ -161,6 +161,7 @@
 		{"444P16", IMGFMT_444P16},
 		{"422P16", IMGFMT_422P16},
 		{"420P16", IMGFMT_420P16},
+		{"420A",  IMGFMT_420A},
 		{"444P",  IMGFMT_444P},
 		{"422P",  IMGFMT_422P},
 		{"411P",  IMGFMT_411P},
--- a/etc/codecs.conf	Thu Dec 31 23:39:21 2009 +0000
+++ b/etc/codecs.conf	Thu Dec 31 23:45:07 2009 +0000
@@ -2060,7 +2060,7 @@
   fourcc VP6A
   driver ffmpeg
   dll "vp6a"
-  out I420,YUY2,YV12
+  out 420A
 
 videocodec ffvp6f
   info "FFmpeg VP6 Flash"
--- a/fmt-conversion.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/fmt-conversion.c	Thu Dec 31 23:45:07 2009 +0000
@@ -59,6 +59,9 @@
     {IMGFMT_422P,  PIX_FMT_YUV422P},
     {IMGFMT_444P,  PIX_FMT_YUV444P},
     {IMGFMT_440P,  PIX_FMT_YUV440P},
+
+    {IMGFMT_420A,  PIX_FMT_YUVA420P},
+
     {IMGFMT_420P16_LE,  PIX_FMT_YUV420P16LE},
     {IMGFMT_420P16_BE,  PIX_FMT_YUV420P16BE},
     {IMGFMT_422P16_LE,  PIX_FMT_YUV422P16LE},
--- a/libmpcodecs/img_format.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/libmpcodecs/img_format.c	Thu Dec 31 23:45:07 2009 +0000
@@ -43,6 +43,7 @@
 	case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian";
 	case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian";
 	case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian";
+	case IMGFMT_420A: return "Planar 420P with alpha";
 	case IMGFMT_444P: return "Planar 444P";
 	case IMGFMT_422P: return "Planar 422P";
 	case IMGFMT_411P: return "Planar 411P";
@@ -96,6 +97,7 @@
     case IMGFMT_420P16_LE:
     case IMGFMT_420P16_BE:
         bpp_factor = 2;
+    case IMGFMT_420A:
     case IMGFMT_I420:
     case IMGFMT_IYUV:
     case IMGFMT_YV12:
@@ -136,6 +138,8 @@
     if (x_shift) *x_shift = xs;
     if (y_shift) *y_shift = ys;
     bpp = 8 + (16 >> (xs + ys));
+    if (format == IMGFMT_420A)
+        bpp += 8;
     bpp *= bpp_factor;
     return err ? 0 : bpp;
 }
--- a/libmpcodecs/img_format.h	Thu Dec 31 23:39:21 2009 +0000
+++ b/libmpcodecs/img_format.h	Thu Dec 31 23:45:07 2009 +0000
@@ -73,6 +73,10 @@
 #define IMGFMT_411P 0x50313134
 #define IMGFMT_440P 0x50303434
 #define IMGFMT_HM12 0x32314D48
+
+// 4:2:0 planar with alpha
+#define IMGFMT_420A 0x41303234
+
 #define IMGFMT_444P16_LE 0x51343434
 #define IMGFMT_444P16_BE 0x34343451
 #define IMGFMT_422P16_LE 0x51323234
--- a/libmpcodecs/mp_image.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/libmpcodecs/mp_image.c	Thu Dec 31 23:45:07 2009 +0000
@@ -19,24 +19,26 @@
   if (mpi->imgfmt == IMGFMT_IF09) {
     mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
                             mpi->chroma_width*mpi->chroma_height);
-    /* export delta table */
-    mpi->planes[3]=mpi->planes[0]+(mpi->width*mpi->height)+2*(mpi->chroma_width*mpi->chroma_height);
   } else
     mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
   if (mpi->flags&MP_IMGFLAG_PLANAR) {
     int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
     // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
-    mpi->stride[0]=bpp*mpi->width;
+    mpi->stride[0]=mpi->stride[3]=bpp*mpi->width;
     if(mpi->num_planes > 2){
       mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width;
       if(mpi->flags&MP_IMGFLAG_SWAPPED){
         // I420/IYUV  (Y,U,V)
         mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
         mpi->planes[2]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height;
+        if (mpi->num_planes > 3)
+            mpi->planes[3]=mpi->planes[2]+mpi->stride[2]*mpi->chroma_height;
       } else {
         // YV12,YVU9,IF09  (Y,V,U)
         mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height;
         mpi->planes[1]=mpi->planes[2]+mpi->stride[1]*mpi->chroma_height;
+        if (mpi->num_planes > 3)
+            mpi->planes[3]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height;
       }
     } else {
       // NV12/NV21
--- a/libmpcodecs/mp_image.h	Thu Dec 31 23:39:21 2009 +0000
+++ b/libmpcodecs/mp_image.h	Thu Dec 31 23:45:07 2009 +0000
@@ -145,6 +145,7 @@
 	mpi->flags|=MP_IMGFLAG_SWAPPED;
     case IMGFMT_YV12:
 	return;
+    case IMGFMT_420A:
     case IMGFMT_IF09:
 	mpi->num_planes=4;
     case IMGFMT_YVU9:
@@ -210,6 +211,7 @@
 }
 
 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt);
+void mp_image_alloc_planes(mp_image_t *mpi);
 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi);
 
 #endif /* MPLAYER_MP_IMAGE_H */
--- a/libmpcodecs/vf_scale.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/libmpcodecs/vf_scale.c	Thu Dec 31 23:45:07 2009 +0000
@@ -61,6 +61,7 @@
     IMGFMT_I420,
     IMGFMT_420P16_LE,
     IMGFMT_420P16_BE,
+    IMGFMT_420A,
     IMGFMT_IYUV,
     IMGFMT_YVU9,
     IMGFMT_IF09,
@@ -480,6 +481,7 @@
     case IMGFMT_422P:
     case IMGFMT_411P:
     case IMGFMT_440P:
+    case IMGFMT_420A:
     case IMGFMT_444P16_LE:
     case IMGFMT_444P16_BE:
     case IMGFMT_422P16_LE:
--- a/m_option.c	Thu Dec 31 23:39:21 2009 +0000
+++ b/m_option.c	Thu Dec 31 23:45:07 2009 +0000
@@ -1041,6 +1041,7 @@
   {"444p16", IMGFMT_444P16},
   {"422p16", IMGFMT_422P16},
   {"420p16", IMGFMT_420P16},
+  {"420a", IMGFMT_420A},
   {"444p", IMGFMT_444P},
   {"422p", IMGFMT_422P},
   {"411p", IMGFMT_411P},