summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-26 21:32:35 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:13 +0100
commite16fab8822b8c7fe6b8623d78da449cb2e93eeef (patch)
treef51469528c64e6cb1a0bd73efc4c41b214735981 /video
parent54dffdbbe6d02fd3aa3c3a6a85f4aa47559cacdd (diff)
downloadmpv-e16fab8822b8c7fe6b8623d78da449cb2e93eeef.tar.bz2
mpv-e16fab8822b8c7fe6b8623d78da449cb2e93eeef.tar.xz
vf_rotate: support more image formats
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_rotate.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c
index b4e8fe59bd..1d80725ba3 100644
--- a/video/filter/vf_rotate.c
+++ b/video/filter/vf_rotate.c
@@ -66,15 +66,19 @@ static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcst
}
}
-//===========================================================================//
-
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt){
+static int config(struct vf_instance *vf, int width, int height,
+ int d_width, int d_height,
+ unsigned int flags, unsigned int outfmt)
+{
if (vf->priv->direction & 4) {
- if (width<height) vf->priv->direction&=3;
+ if (width < height)
+ vf->priv->direction &= 3;
}
- return vf_next_config(vf,height,width,d_height,d_width,flags,outfmt);
+ struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(outfmt);
+ int a_w = MP_ALIGN_DOWN(width, desc.align_x);
+ int a_h = MP_ALIGN_DOWN(height, desc.align_y);
+ vf_rescale_dsize(vf, &d_width, &d_height, width, height, a_w, a_h);
+ return vf_next_config(vf, a_h, a_w, d_height, d_width, flags, outfmt);
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -85,39 +89,26 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
struct mp_image *dmpi = vf_alloc_out_image(vf);
mp_image_copy_attributes(dmpi, mpi);
- if(mpi->flags&MP_IMGFLAG_PLANAR){
- rotate(dmpi->planes[0],mpi->planes[0],
- dmpi->stride[0],mpi->stride[0],
- dmpi->w,dmpi->h,1,vf->priv->direction);
- rotate(dmpi->planes[1],mpi->planes[1],
- dmpi->stride[1],mpi->stride[1],
- dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction);
- rotate(dmpi->planes[2],mpi->planes[2],
- dmpi->stride[2],mpi->stride[2],
- dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction);
- } else {
- rotate(dmpi->planes[0],mpi->planes[0],
- dmpi->stride[0],mpi->stride[0],
- dmpi->w,dmpi->h,dmpi->bpp>>3,vf->priv->direction);
+ for (int p = 0; p < mpi->num_planes; p++) {
+ rotate(dmpi->planes[p],mpi->planes[p], dmpi->stride[p],mpi->stride[p],
+ dmpi->plane_w[p], dmpi->plane_h[p], mpi->fmt.bytes[p],
+ vf->priv->direction);
}
talloc_free(mpi);
return dmpi;
}
-//===========================================================================//
-
-static int query_format(struct vf_instance *vf, unsigned int fmt){
- if(IMGFMT_IS_RGB(fmt)) return vf_next_query_format(vf, fmt);
- // we can support only symmetric (chroma_x_shift==chroma_y_shift) YUV formats:
- switch(fmt) {
- case IMGFMT_Y8:
- case IMGFMT_444P:
- case IMGFMT_420P:
- case IMGFMT_410P:
- return vf_next_query_format(vf, fmt);
- }
- return 0;
+static int query_format(struct vf_instance *vf, unsigned int fmt)
+{
+ struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
+ if (!(desc.flags & MP_IMGFLAG_BYTE_ALIGNED))
+ return 0;
+ if (desc.chroma_xs != desc.chroma_ys)
+ return 0;
+ if (desc.num_planes == 1 && (desc.chroma_xs || desc.chroma_ys))
+ return 0;
+ return vf_next_query_format(vf, fmt);
}
static int vf_open(vf_instance_t *vf, char *args){