summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authormplayer-svn <svn@mplayerhq.hu>2011-11-22 19:33:29 +0000
committerwm4 <wm4@nowhere>2012-08-03 01:35:03 +0200
commitd9d80705e62c99e4a3d3dbc56684a66aa63b4412 (patch)
treeabd1593ee6475f85523650f8297c8c83aec9b1c2 /libmpcodecs
parent7e2b159f022a9efb9b81d98cda0b64c69aa5a6b4 (diff)
downloadmpv-d9d80705e62c99e4a3d3dbc56684a66aa63b4412.tar.bz2
mpv-d9d80705e62c99e4a3d3dbc56684a66aa63b4412.tar.xz
vf_expand: add sanity checks
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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34356 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/vf_expand.c21
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;