From 37a71e57d404a708505f920f610061ec5c424917 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Apr 2015 21:06:18 +0200 Subject: mp_image: remove redundant flags field Because gcc (and clang) is a goddamn PITA and unnecessarily warns if the universal initializer for structs is used (like mp_image x = {}) and the first member of the struct is also a struct, move the w/h fields to the top. --- sub/draw_bmp.c | 4 ++-- video/mp_image.c | 7 +++---- video/mp_image.h | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 78fb33ca9f..7a60215dba 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -295,7 +295,7 @@ static void draw_ass(struct mp_draw_sub_cache *cache, struct mp_rect bb, cspar.int_bits_out = 8; struct mp_cmat yuv2rgb, rgb2yuv; - bool need_conv = temp->flags & MP_IMGFLAG_YUV; + bool need_conv = temp->fmt.flags & MP_IMGFLAG_YUV; if (need_conv) { mp_get_yuv2rgb_coeffs(&cspar, &yuv2rgb); mp_invert_yuv2rgb(&rgb2yuv, &yuv2rgb); @@ -470,7 +470,7 @@ static struct mp_image *chroma_up(struct mp_draw_sub_cache *cache, int imgfmt, // The temp image is always YUV, but src not necessarily. // Reduce amount of conversions in YUV case (upsampling/shifting only) - if (src->flags & MP_IMGFLAG_YUV) { + if (src->fmt.flags & MP_IMGFLAG_YUV) { temp->params.colorspace = src->params.colorspace; temp->params.colorlevels = src->params.colorlevels; } diff --git a/video/mp_image.c b/video/mp_image.c index c4ad6bd4c2..12b8fc437c 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -146,7 +146,6 @@ void mp_image_setfmt(struct mp_image *mpi, int out_fmt) struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(out_fmt); mpi->params.imgfmt = fmt.id; mpi->fmt = fmt; - mpi->flags = fmt.flags; mpi->imgfmt = fmt.id; mpi->num_planes = fmt.num_planes; mp_image_set_size(mpi, mpi->w, mpi->h); @@ -358,7 +357,7 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src) } dst->params.primaries = src->params.primaries; dst->params.gamma = src->params.gamma; - if ((dst->flags & MP_IMGFLAG_YUV) == (src->flags & MP_IMGFLAG_YUV)) { + if ((dst->fmt.flags & MP_IMGFLAG_YUV) == (src->fmt.flags & MP_IMGFLAG_YUV)) { dst->params.colorspace = src->params.colorspace; dst->params.colorlevels = src->params.colorlevels; dst->params.chroma_location = src->params.chroma_location; @@ -414,9 +413,9 @@ void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1) plane_clear[0] = av_le2ne16(0x0080); } else if (area.imgfmt == IMGFMT_NV12 || area.imgfmt == IMGFMT_NV21) { plane_clear[1] = 0x8080; - } else if (area.flags & MP_IMGFLAG_YUV_P) { + } else if (area.fmt.flags & MP_IMGFLAG_YUV_P) { uint16_t chroma_clear = (1 << area.fmt.plane_bits) / 2; - if (!(area.flags & MP_IMGFLAG_NE)) + if (!(area.fmt.flags & MP_IMGFLAG_NE)) chroma_clear = av_bswap16(chroma_clear); if (area.num_planes > 2) plane_clear[1] = plane_clear[2] = chroma_clear; diff --git a/video/mp_image.h b/video/mp_image.h index 92f779136c..7f29467f24 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -77,7 +77,7 @@ struct mp_image_params { * image data. mp_image_make_writeable() will do that copy if required. */ typedef struct mp_image { - unsigned int flags; // same as fmt.flags + int w, h; // visible dimensions (redundant with params.w/h) struct mp_image_params params; @@ -86,7 +86,6 @@ typedef struct mp_image { enum mp_imgfmt imgfmt; int num_planes; - int w,h; // visible dimensions uint8_t *planes[MP_MAX_PLANES]; int stride[MP_MAX_PLANES]; -- cgit v1.2.3