From 56149ff5ac9b5a287ed74e3bbe141c179a638dfc Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Mar 2013 11:28:59 +0100 Subject: vf_flip: move flipping code to mp_image.c --- video/filter/vf_flip.c | 5 +---- video/mp_image.c | 8 ++++++++ video/mp_image.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/filter/vf_flip.c b/video/filter/vf_flip.c index c94da49403..a28633c7ef 100644 --- a/video/filter/vf_flip.c +++ b/video/filter/vf_flip.c @@ -40,10 +40,7 @@ static int config(struct vf_instance *vf, int width, int height, static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) { - for (int p = 0; p < mpi->num_planes; p++) { - mpi->planes[p] = mpi->planes[p] + mpi->stride[p] * (mpi->plane_h[p] - 1); - mpi->stride[p] = -mpi->stride[p]; - } + mp_image_vflip(mpi); return mpi; } diff --git a/video/mp_image.c b/video/mp_image.c index dd58f131a8..78becf28ea 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -399,6 +399,14 @@ void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1) } } +void mp_image_vflip(struct mp_image *img) +{ + for (int p = 0; p < img->num_planes; p++) { + img->planes[p] = img->planes[p] + img->stride[p] * (img->plane_h[p] - 1); + img->stride[p] = -img->stride[p]; + } +} + enum mp_csp mp_image_csp(struct mp_image *img) { if (img->colorspace != MP_CSP_AUTO) diff --git a/video/mp_image.h b/video/mp_image.h index d51996c226..6ba9393671 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -103,6 +103,7 @@ void mp_image_unrefp(struct mp_image **p_img); void mp_image_clear(struct mp_image *mpi, int x0, int y0, int x1, int y1); void mp_image_crop(struct mp_image *img, int x0, int y0, int x1, int y1); void mp_image_crop_rc(struct mp_image *img, struct mp_rect rc); +void mp_image_vflip(struct mp_image *img); void mp_image_set_size(struct mp_image *mpi, int w, int h); void mp_image_set_display_size(struct mp_image *mpi, int dw, int dh); -- cgit v1.2.3