diff options
Diffstat (limited to 'libmpcodecs/vf_expand.c')
-rw-r--r-- | libmpcodecs/vf_expand.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c index 6cc7a810b6..a5ce57fa98 100644 --- a/libmpcodecs/vf_expand.c +++ b/libmpcodecs/vf_expand.c @@ -132,11 +132,13 @@ static int config(struct vf_instance *vf, unsigned int flags, unsigned int outfmt) { struct MPOpts *opts = vf->opts; + 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; @@ -169,6 +171,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); + } + } if(!opts->screen_size_x && !opts->screen_size_y){ d_width=d_width*vf->priv->exp_w/width; |