summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-19 22:56:11 +0200
committerwm4 <wm4@nowhere>2016-05-19 22:56:11 +0200
commite431a7bbfd86e667f8bbf871247c2afd97931b97 (patch)
tree46d590b9e43ce8ec69e2dd9b068334c9c384a951
parent05b3a8cd1413c3903e4713ad7748739d39ac7781 (diff)
downloadmpv-e431a7bbfd86e667f8bbf871247c2afd97931b97.tar.bz2
mpv-e431a7bbfd86e667f8bbf871247c2afd97931b97.tar.xz
vf_crop: support opaque hardware decoding formats
Cropping usually happens by adjusting the plane start pointers and the image size. The former is obviously not possible for opaque hwaccel formats, but the latter must work. Since the code already takes care of aligning the top/left crop origin to chroma alignment, simply set the crop origin to 0/0 in the hwaccel case. Also add a message if such an adjustment happens. Supporting this isn't worth much; the main usefulness is with debugging.
-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){