[MPlayer-cvslog] r34356 - trunk/libmpcodecs/vf_expand.c

reimar subversion at mplayerhq.hu
Tue Nov 22 20:33:29 CET 2011


Author: reimar
Date: Tue Nov 22 20:33:29 2011
New Revision: 34356

Log:
Make vf expand more picky:
refuse operating on compressed or hwaccel formats and
fix up offsets that would cause color corruption for YUV
formats with downsampled chroma.

Modified:
   trunk/libmpcodecs/vf_expand.c

Modified: trunk/libmpcodecs/vf_expand.c
==============================================================================
--- trunk/libmpcodecs/vf_expand.c	Tue Nov 22 20:31:29 2011	(r34355)
+++ trunk/libmpcodecs/vf_expand.c	Tue Nov 22 20:33:29 2011	(r34356)
@@ -218,11 +218,13 @@ static void draw_osd(struct vf_instance 
 static int config(struct vf_instance *vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
+    mp_image_t test_mpi;
     if(outfmt == IMGFMT_MPEGPES) {
       vf->priv->passthrough = 1;
       return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
     }
-    if (outfmt == IMGFMT_IF09) return 0;
+    mp_image_setfmt(&test_mpi, outfmt);
+    if (outfmt == IMGFMT_IF09 || !test_mpi.bpp) return 0;
     vf->priv->exp_x = vf->priv->cfg_exp_x;
     vf->priv->exp_y = vf->priv->cfg_exp_y;
     vf->priv->exp_w = vf->priv->cfg_exp_w;
@@ -255,6 +257,23 @@ static int config(struct vf_instance *vf
 
     if(vf->priv->exp_x<0 || vf->priv->exp_x+width>vf->priv->exp_w) vf->priv->exp_x=(vf->priv->exp_w-width)/2;
     if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2;
+    if(test_mpi.flags & MP_IMGFLAG_YUV) {
+        int x_align_mask = (1 << test_mpi.chroma_x_shift) - 1;
+        int y_align_mask = (1 << test_mpi.chroma_y_shift) - 1;
+        // For 1-plane format non-aligned offsets will completely
+        // destroy the colours, for planar it will break the chroma
+        // sampling position.
+        if (vf->priv->exp_x & x_align_mask) {
+            vf->priv->exp_x &= ~x_align_mask;
+            mp_msg(MSGT_VFILTER, MSGL_ERR, "Specified x offset not supported "
+                   "for YUV, reduced to %i.\n", vf->priv->exp_x);
+        }
+        if (vf->priv->exp_y & y_align_mask) {
+            vf->priv->exp_y &= ~y_align_mask;
+            mp_msg(MSGT_VFILTER, MSGL_ERR, "Specified y offset not supported "
+                   "for YUV, reduced to %i.\n", vf->priv->exp_y);
+        }
+    }
     vf->priv->fb_ptr=NULL;
 
     if(!opt_screen_size_x && !opt_screen_size_y){


More information about the MPlayer-cvslog mailing list