[MPlayer-dev-eng] [PATCH]Support packed YUV422 in vo vdpau

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Mar 28 18:54:57 CET 2009


On Sat, Mar 28, 2009 at 06:44:55PM +0100, Carl Eugen Hoyos wrote:
> @@ -174,7 +174,6 @@
>  static int                                vid_surface_num;
>  static uint32_t                           vid_width, vid_height;
>  static uint32_t                           image_format;
> -static const VdpChromaType                vdp_chroma_type = VDP_CHROMA_TYPE_420;

Hm, why remove it?

> @@ -598,7 +598,11 @@
>      if (vdp_flip_queue == VDP_INVALID_HANDLE && win_x11_init_vdpau_flip_queue())
>          return -1;
>  
> -    if (create_vdp_mixer(vdp_chroma_type))
> +    chroma_type = image_format == IMGFMT_YUY2 || image_format == IMGFMT_UYVY ?
> +                  VDP_CHROMA_TYPE_422 :
> +                  VDP_CHROMA_TYPE_420;
> +
> +    if (create_vdp_mixer(chroma_type))
>          return -1;
>  
>      surface_num = 0;
> @@ -882,12 +887,32 @@
>          }
>      } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
>          VdpStatus vdp_st;
> +        VdpYCbCrFormat pixel_format;
> +        VdpChromaType chroma_type;
>          void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
> -        struct vdpau_render_state *rndr = get_surface(deint_counter);
> +        struct vdpau_render_state *rndr;
> +        switch (image_format) {
> +            case IMGFMT_YV12:
> +                pixel_format = VDP_YCBCR_FORMAT_YV12;
> +                chroma_type  = VDP_CHROMA_TYPE_420;
> +                break;
> +            case IMGFMT_NV12:
> +                pixel_format = VDP_YCBCR_FORMAT_NV12;
> +                chroma_type  = VDP_CHROMA_TYPE_420;
> +                break;
> +            case IMGFMT_YUY2:
> +                pixel_format = VDP_YCBCR_FORMAT_YUYV;
> +                chroma_type  = VDP_CHROMA_TYPE_422;
> +                break;
> +            case IMGFMT_UYVY:
> +                pixel_format = VDP_YCBCR_FORMAT_UYVY;
> +                chroma_type  = VDP_CHROMA_TYPE_422;
> +        }

Adding two different ways to calculate the same thing is rarely more
than a cause for future problems.

> +        rndr = get_surface(deint_counter, chroma_type);

Also since chroma_type stays constant for all get_surface calls for the
same video, I think it is confusing to make it a function argument.

> @@ -906,7 +931,7 @@
>      if (!IMGFMT_IS_VDPAU(image_format)) return VO_FALSE;
>      if (mpi->type != MP_IMGTYPE_NUMBERED) return VO_FALSE;
>  
> -    rndr = get_surface(mpi->number);
> +    rndr = get_surface(mpi->number, VDP_CHROMA_TYPE_420);

I know the current code is already like that, but what happens with
hardware-decoding 422-coded MPEG-2 (ffmpeg -vcodec mpeg2video -pix_fmt
yuv422p or e.g. the output of the FFmpeg mxf_d10 regression test).



More information about the MPlayer-dev-eng mailing list