From 8afc25d710d8520b454d48b7744dde4812feef74 Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 31 Dec 2009 23:45:07 +0000 Subject: 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/ git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30157 b3059339-0415-0410-9bf9-f77b7e298cf2 --- codec-cfg.c | 1 + etc/codecs.conf | 2 +- fmt-conversion.c | 3 +++ libmpcodecs/img_format.c | 4 ++++ libmpcodecs/img_format.h | 4 ++++ libmpcodecs/mp_image.c | 8 +++++--- libmpcodecs/mp_image.h | 2 ++ libmpcodecs/vf_scale.c | 2 ++ m_option.c | 1 + 9 files changed, 23 insertions(+), 4 deletions(-) diff --git a/codec-cfg.c b/codec-cfg.c index a0be5df810..840fb94ec1 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -161,6 +161,7 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int {"444P16", IMGFMT_444P16}, {"422P16", IMGFMT_422P16}, {"420P16", IMGFMT_420P16}, + {"420A", IMGFMT_420A}, {"444P", IMGFMT_444P}, {"422P", IMGFMT_422P}, {"411P", IMGFMT_411P}, diff --git a/etc/codecs.conf b/etc/codecs.conf index 3d88972068..be548cac61 100644 --- a/etc/codecs.conf +++ b/etc/codecs.conf @@ -2060,7 +2060,7 @@ videocodec ffvp6a fourcc VP6A driver ffmpeg dll "vp6a" - out I420,YUY2,YV12 + out 420A videocodec ffvp6f info "FFmpeg VP6 Flash" diff --git a/fmt-conversion.c b/fmt-conversion.c index 8455277164..9371ab1a11 100644 --- a/fmt-conversion.c +++ b/fmt-conversion.c @@ -59,6 +59,9 @@ static const struct { {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}, diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c index d29f47fb1c..cc7bee10b8 100644 --- a/libmpcodecs/img_format.c +++ b/libmpcodecs/img_format.c @@ -43,6 +43,7 @@ const char *vo_format_name(int format) 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 @@ int mp_get_chroma_shift(int format, int *x_shift, int *y_shift) 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 @@ int mp_get_chroma_shift(int format, int *x_shift, int *y_shift) 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; } diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index 5d3a48caaf..6bab56632d 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -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 diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c index 02e72bfb24..1bc0492e9c 100644 --- a/libmpcodecs/mp_image.c +++ b/libmpcodecs/mp_image.c @@ -19,24 +19,26 @@ void mp_image_alloc_planes(mp_image_t *mpi) { 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 diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h index c4773ce0da..a53ef8a5ad 100644 --- a/libmpcodecs/mp_image.h +++ b/libmpcodecs/mp_image.h @@ -145,6 +145,7 @@ static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ 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 @@ static inline void free_mp_image(mp_image_t* mpi){ } 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 */ diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index f2b375a26f..0131b36d82 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -61,6 +61,7 @@ static unsigned int outfmt_list[]={ IMGFMT_I420, IMGFMT_420P16_LE, IMGFMT_420P16_BE, + IMGFMT_420A, IMGFMT_IYUV, IMGFMT_YVU9, IMGFMT_IF09, @@ -480,6 +481,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ case IMGFMT_422P: case IMGFMT_411P: case IMGFMT_440P: + case IMGFMT_420A: case IMGFMT_444P16_LE: case IMGFMT_444P16_BE: case IMGFMT_422P16_LE: diff --git a/m_option.c b/m_option.c index fbde88736b..8c5c42982d 100644 --- a/m_option.c +++ b/m_option.c @@ -1041,6 +1041,7 @@ static struct { {"444p16", IMGFMT_444P16}, {"422p16", IMGFMT_422P16}, {"420p16", IMGFMT_420P16}, + {"420a", IMGFMT_420A}, {"444p", IMGFMT_444P}, {"422p", IMGFMT_422P}, {"411p", IMGFMT_411P}, -- cgit v1.2.3