From 15c7f7a33968edebe305e2845b32eb2383457d46 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 19 Dec 2012 12:04:57 +0100 Subject: video: cleanup: move and rename vf_mpi_clear and vf_clone_attributes These functions weren't specific to video filters and were misplaced in vf.c. Move them to mp_image.c. Fix the big endian test in vf_mpi_clear/mp_image_clear, which has been messed up in 74df1d. --- video/filter/vf.c | 73 ------------------------------------------------ video/filter/vf.h | 3 -- video/filter/vf_expand.c | 12 ++++---- 3 files changed, 6 insertions(+), 82 deletions(-) (limited to 'video/filter') diff --git a/video/filter/vf.c b/video/filter/vf.c index 1d21413787..f286da8a4f 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -118,58 +118,6 @@ const m_obj_list_t vf_obj_list = { M_ST_OFF(vf_info_t, opts) }; -//============================================================================ -// mpi stuff: - -void vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h) -{ - int y; - if (mpi->flags & MP_IMGFLAG_PLANAR) { - y0 &= ~1; - h += h & 1; - for (y = y0; y < y0 + h; y += 2) { - memset(mpi->planes[0] + x0 + mpi->stride[0] * y, 0, w); - memset(mpi->planes[0] + x0 + mpi->stride[0] * (y + 1), 0, w); - memset(mpi->planes[1] + (x0 >> mpi->chroma_x_shift) + - mpi->stride[1] * (y >> mpi->chroma_y_shift), - 128, (w >> mpi->chroma_x_shift)); - memset(mpi->planes[2] + (x0 >> mpi->chroma_x_shift) + - mpi->stride[2] * (y >> mpi->chroma_y_shift), - 128, (w >> mpi->chroma_x_shift)); - } - return; - } - // packed: - for (y = y0; y < y0 + h; y++) { - unsigned char *dst = mpi->planes[0] + mpi->stride[0] * y + - (mpi->bpp >> 3) * x0; - if (mpi->flags & MP_IMGFLAG_YUV) { - unsigned int *p = (unsigned int *) dst; - int size = (mpi->bpp >> 3) * w / 4; - int i; -#ifdef BIG_ENDIAN -#define CLEAR_PACKEDYUV_PATTERN 0x00800080 -#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000 -#else -#define CLEAR_PACKEDYUV_PATTERN 0x80008000 -#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080 -#endif - if (mpi->flags & MP_IMGFLAG_SWAPPED) { - for (i = 0; i < size - 3; i += 4) - p[i] = p[i + 1] = p[i + 2] = p[i + 3] = CLEAR_PACKEDYUV_PATTERN_SWAPPED; - for (; i < size; i++) - p[i] = CLEAR_PACKEDYUV_PATTERN_SWAPPED; - } else { - for (i = 0; i < size - 3; i += 4) - p[i] = p[i + 1] = p[i + 2] = p[i + 3] = CLEAR_PACKEDYUV_PATTERN; - for (; i < size; i++) - p[i] = CLEAR_PACKEDYUV_PATTERN; - } - } else - memset(dst, 0, (mpi->bpp >> 3) * w); - } -} - // Get a new image for filter output, with size and pixel format according to // the last vf_config call. struct mp_image *vf_alloc_out_image(struct vf_instance *vf) @@ -364,27 +312,6 @@ unsigned int vf_match_csp(vf_instance_t **vfp, const unsigned int *list, return best; } -void vf_clone_mpi_attributes(mp_image_t *dst, mp_image_t *src) -{ - dst->pict_type = src->pict_type; - dst->fields = src->fields; - dst->qscale_type = src->qscale_type; - dst->pts = src->pts; - if (dst->w == src->w && dst->h == src->h) { - dst->qstride = src->qstride; - dst->qscale = src->qscale; - dst->display_w = src->display_w; - dst->display_h = src->display_h; - } - if ((dst->flags & MP_IMGFLAG_YUV) == (src->flags & MP_IMGFLAG_YUV)) { - dst->colorspace = src->colorspace; - dst->levels = src->levels; - } - if (dst->imgfmt == IMGFMT_PAL8 && src->imgfmt == IMGFMT_PAL8) { - memcpy(dst->planes[1], src->planes[1], MP_PALETTE_SIZE); - } -} - // Used by filters to add a filtered frame to the output queue. // Ownership of img is transferred from caller to the filter chain. void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img) diff --git a/video/filter/vf.h b/video/filter/vf.h index 187af302ad..358b8135f5 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -102,8 +102,6 @@ typedef struct vf_seteq { #define VFCTRL_SET_YUV_COLORSPACE 22 // arg is struct mp_csp_details* #define VFCTRL_GET_YUV_COLORSPACE 23 // arg is struct mp_csp_details* -// functions: -void vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h); struct mp_image *vf_alloc_out_image(struct vf_instance *vf); void vf_make_out_image_writeable(struct vf_instance *vf, struct mp_image *img); @@ -124,7 +122,6 @@ vf_instance_t *vf_add_before_vo(vf_instance_t **vf, char *name, char **args); unsigned int vf_match_csp(vf_instance_t **vfp, const unsigned int *list, unsigned int preferred); -void vf_clone_mpi_attributes(mp_image_t *dst, mp_image_t *src); // default wrappers: int vf_next_config(struct vf_instance *vf, diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c index 5f5ffcae7f..5ce5db16bd 100644 --- a/video/filter/vf_expand.c +++ b/video/filter/vf_expand.c @@ -129,15 +129,15 @@ static void clear_borders(struct vf_instance *vf, struct mp_image *dmpi, int w, int h) { // upper border (over the full width) - vf_mpi_clear(dmpi, 0, 0, vf->priv->exp_w, vf->priv->exp_y); + mp_image_clear(dmpi, 0, 0, vf->priv->exp_w, vf->priv->exp_y); // lower border - vf_mpi_clear(dmpi, 0, vf->priv->exp_y + h, vf->priv->exp_w, - vf->priv->exp_h - (vf->priv->exp_y + h)); + mp_image_clear(dmpi, 0, vf->priv->exp_y + h, vf->priv->exp_w, + vf->priv->exp_h - (vf->priv->exp_y + h)); // left - vf_mpi_clear(dmpi, 0, vf->priv->exp_y, vf->priv->exp_x, h); + mp_image_clear(dmpi, 0, vf->priv->exp_y, vf->priv->exp_x, h); // right - vf_mpi_clear(dmpi, vf->priv->exp_x + w, vf->priv->exp_y, - vf->priv->exp_w - (vf->priv->exp_x + w), h); + mp_image_clear(dmpi, vf->priv->exp_x + w, vf->priv->exp_y, + vf->priv->exp_w - (vf->priv->exp_x + w), h); } static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -- cgit v1.2.3