[MPlayer-users] Adding support for Theora 4:2:2 and 4:4:4 video files

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Feb 14 12:29:13 CET 2010


On Fri, Feb 12, 2010 at 10:28:58PM +0100, Giorgio wrote:
>  // to set/get/query special features/parameters
>  static int control(sh_video_t *sh,int cmd,void* arg,...){
> +    theora_struct_t *context = (theora_struct_t *)sh->context;

Useless cast.

>      switch(cmd) {
>      case VDCTRL_QUERY_FORMAT:
> -        if ((*((int*)arg)) == IMGFMT_YV12)
> -	    return CONTROL_TRUE;
> +    if ((*((int*)arg)) == IMGFMT_YV12  &&  context->inf.pixelformat == OC_PF_420) return CONTROL_TRUE;
> +    if ((*((int*)arg)) == IMGFMT_422P  &&  context->inf.pixelformat == OC_PF_422) return CONTROL_TRUE;
> +    if ((*((int*)arg)) == IMGFMT_444P  &&  context->inf.pixelformat == OC_PF_444) return CONTROL_TRUE;

Make a function that converts the context->inf.pixelformat to the corresponding IMGFMT_ and use
that in both places.

>  	return CONTROL_FALSE;
>      }
> -
>      return CONTROL_UNKNOWN;

Unrelated/cosmetic change.

> @@ -73,6 +75,8 @@
>      switch(sh->codec->outfmt[sh->outfmtidx])
>      {
>         case IMGFMT_YV12: /* well, this should work... */ break;
> +       case IMGFMT_422P: break;
> +       case IMGFMT_444P: break;
>         default:
>  	  mp_msg (MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",
>  		  sh->codec->outfmt[sh->outfmtidx]);

I removed this useless piece of code.

> @@ -133,7 +137,14 @@
>  
>      mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n");
>  
> -    return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12);
> +    switch(context->inf.pixelformat) {
> +        case OC_PF_420:
> +        return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12);
> +        case OC_PF_422:
> +        return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_422P);
> +        case OC_PF_444:
> +        return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_444P);
> +    }		

Trailing whitespace and also code duplication (see my suggestion about the conversion function
for how to avoid it.
Apart from that I think it looks ok.


More information about the MPlayer-users mailing list