summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_crop.c
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2016-06-25 02:25:44 +0200
committerMartin Herkt <lachs0r@srsfckn.biz>2016-06-25 02:25:44 +0200
commitad56f2c46ac6deec86870ec10f2a11a644df07d4 (patch)
tree89f2d90c5586560911e67c872b530c77f151168d /video/filter/vf_crop.c
parent0536841647ef7931bffb4386d8ffbb5b2b568e8a (diff)
parent393bb2a565dc1e27812e1dd20747814892f80da2 (diff)
downloadmpv-ad56f2c46ac6deec86870ec10f2a11a644df07d4.tar.bz2
mpv-ad56f2c46ac6deec86870ec10f2a11a644df07d4.tar.xz
Merge branch 'master' into release/current
Diffstat (limited to 'video/filter/vf_crop.c')
-rw-r--r--video/filter/vf_crop.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c
index 89b2b6fde1..6f9a788fef 100644
--- a/video/filter/vf_crop.c
+++ b/video/filter/vf_crop.c
@@ -51,10 +51,23 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
// rounding:
+ int orig_x = vf->priv->crop_x;
+ int orig_y = vf->priv->crop_y;
+
struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt);
- vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x);
- vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y);
+ if (fmt.flags & MP_IMGFLAG_HWACCEL) {
+ vf->priv->crop_x = 0;
+ vf->priv->crop_y = 0;
+ } else {
+ vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x);
+ vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y);
+ }
+
+ if (vf->priv->crop_x != orig_x || vf->priv->crop_y != orig_y) {
+ MP_WARN(vf, "Adjusting crop origin to %d/%d for pixel format alignment.\n",
+ vf->priv->crop_x, vf->priv->crop_y);
+ }
// check:
if(vf->priv->crop_w+vf->priv->crop_x>width ||
@@ -71,17 +84,19 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
{
- mp_image_crop(mpi, vf->priv->crop_x, vf->priv->crop_y,
- vf->priv->crop_x + vf->priv->crop_w,
- vf->priv->crop_y + vf->priv->crop_h);
+ if (mpi->fmt.flags & MP_IMGFLAG_HWACCEL) {
+ mp_image_set_size(mpi, vf->fmt_out.w, vf->fmt_out.h);
+ } else {
+ mp_image_crop(mpi, vf->priv->crop_x, vf->priv->crop_y,
+ vf->priv->crop_x + vf->priv->crop_w,
+ vf->priv->crop_y + vf->priv->crop_h);
+ }
return mpi;
}
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
- if (!IMGFMT_IS_HWACCEL(fmt))
- return vf_next_query_format(vf, fmt);
- return 0;
+ return vf_next_query_format(vf, fmt);
}
static int vf_open(vf_instance_t *vf){