diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-08 06:29:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-08 06:38:00 +0300 |
commit | 171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 (patch) | |
tree | ea51f4fa508a39807e6f6d333b2d53af8a2b9fc1 /source/blender/imbuf | |
parent | 4bf3ca20165959f98c7c830a138ba2901d3dd851 (diff) |
Cleanup: use array syntax for sizeof with fixed values
Also order sizeof(..) first to promote other values to size_t.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/cineon/cineon_dpx.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/cineon/logImageCore.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/colormanagement.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/divers.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jp2.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/moviecache.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/rectop.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/rotate.c | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/scaling.c | 18 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util_gpu.c | 4 |
11 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 18942c9abb8..50785d7a857 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -139,7 +139,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon /* don't use the float buffer to save 8 bpp picture to prevent color banding * (there's no dithering algorithm behind the logImageSetDataRGBA function) */ - fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), + fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, "fbuf in imb_save_dpx_cineon"); for (y = 0; y < ibuf->y; y++) { @@ -158,7 +158,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon IMB_rect_from_float(ibuf); } - fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), + fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, "fbuf in imb_save_dpx_cineon"); if (fbuf == NULL) { printf("DPX/Cineon: error allocating memory.\n"); diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index 362a558b505..6a81abd96e3 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -483,7 +483,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB memcpy(&mergedElement, &logImage->element[0], sizeof(LogImageElement)); mergedElement.descriptor = -1; mergedElement.depth = logImage->depth; - memset(&sortedElementData, -1, 8 * sizeof(int)); + memset(&sortedElementData, -1, sizeof(int[8])); /* Try to know how to assemble the elements */ for (i = 0; i < logImage->numElements; i++) { diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 08e1bc5f674..2c42d59a2d9 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2342,7 +2342,7 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, } } else { - memcpy(out, in, sizeof(float) * 4 * width); + memcpy(out, in, sizeof(float[4]) * width); } } } @@ -3511,7 +3511,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, size_t display_offset = ((size_t)display_stride * i + xmin) * 4; memcpy( - display_buffer + display_offset, byte_buffer + byte_offset, 4 * sizeof(char) * width); + display_buffer + display_offset, byte_buffer + byte_offset, sizeof(char[4]) * width); } } } diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index bcc8488089d..798849f2dd4 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -666,7 +666,7 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, if (profile_to == profile_from) { /* same profile, copy */ - memcpy(to, from, sizeof(uchar) * 4 * width); + memcpy(to, from, sizeof(uchar[4]) * width); } else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert to sRGB to linear */ @@ -785,7 +785,7 @@ void IMB_float_from_rect(ImBuf *ibuf) size_t size; size = ((size_t)ibuf->x) * ibuf->y; - size = size * 4 * sizeof(float); + size = sizeof(float[4]) * size; ibuf->channels = 4; rect_float = MEM_callocN(size, "IMB_float_from_rect"); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index a5b977be2ce..2244a9c3051 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -896,7 +896,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) h = ibuf->y; /* initialize image components */ - memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t)); + memset(&cmptparm, 0, sizeof(opj_image_cmptparm_t[4])); for (i = 0; i < numcomps; i++) { cmptparm[i].prec = prec; cmptparm[i].bpp = prec; diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index f7b033869e3..e395222a214 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -536,7 +536,7 @@ void IMB_moviecache_get_cache_segments( if (totseg) { int b, *points; - points = MEM_callocN(2 * sizeof(int) * totseg, "movieclip cache segments"); + points = MEM_callocN(sizeof(int[2]) * totseg, "movieclip cache segments"); /* fill */ for (a = 0, b = 0; a < totframe; a++) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index a4e4d41472f..67bb3677834 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1976,7 +1976,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, const bool has_luma = exr_has_luma(*file); FrameBuffer frameBuffer; float *first; - int xstride = sizeof(float) * 4; + int xstride = sizeof(float[4]); int ystride = -xstride * width; imb_addrectfloatImBuf(ibuf); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 91787d64525..8b4f33bb306 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -610,7 +610,7 @@ void IMB_rectblend(ImBuf *dbuf, } if (do_float) { - memcpy(drectf, srectf, width * sizeof(float) * 4); + memcpy(drectf, srectf, sizeof(float[4]) * width); drectf += destskip * 4; srectf += srcskip * 4; } diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 17b485b5171..c2fc2190ce5 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -108,11 +108,11 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { - memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], 4 * sizeof(float)); + memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], sizeof(float[4])); memcpy(&ibuf->rect_float[((x * yi) + xr) * 4], &ibuf->rect_float[((x * yi) + xl) * 4], - 4 * sizeof(float)); - memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, 4 * sizeof(float)); + sizeof(float[4])); + memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, sizeof(float[4])); } } } diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index cecb683b0bd..1fd9bba68f3 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -886,7 +886,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) } if (ibuf->rect) { - unsigned char *newrect = MEM_mallocN(newx * newy * sizeof(int), "q_scale rect"); + unsigned char *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect"); q_scale_byte((unsigned char *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectImBuf(ibuf); @@ -894,7 +894,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) ibuf->rect = (unsigned int *)newrect; } if (ibuf->rect_float) { - float *newrect = MEM_mallocN(newx * newy * 4 * sizeof(float), "q_scale rectfloat"); + float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat"); q_scale_float(ibuf->rect_float, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectfloatImBuf(ibuf); ibuf->mall |= IB_rectfloat; @@ -927,13 +927,13 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) } if (do_rect) { - _newrect = MEM_mallocN(newx * ibuf->y * sizeof(uchar) * 4, "scaledownx"); + _newrect = MEM_mallocN(sizeof(uchar[4]) * newx * ibuf->y, "scaledownx"); if (_newrect == NULL) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaledownxf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1068,13 +1068,13 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) } if (do_rect) { - _newrect = MEM_mallocN(newy * ibuf->x * sizeof(uchar) * 4, "scaledowny"); + _newrect = MEM_mallocN(sizeof(uchar[4]) * newy * ibuf->x, "scaledowny"); if (_newrect == NULL) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaledownyf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newy * ibuf->x, "scaledownyf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1225,7 +1225,7 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx) } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaleupxf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1401,7 +1401,7 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy) } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(ibuf->x * newy * sizeof(float) * 4, "scaleupyf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * ibuf->x * newy, "scaleupyf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1703,7 +1703,7 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy } if (do_float) { - _newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * newy, "scalefastimbuf f"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index 1a46572fb20..58ff8473a85 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -103,7 +103,7 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, * convention, no colorspace conversion needed. But we do require 4 channels * currently. */ if (ibuf->channels != 4 || !store_premultiplied) { - data_rect = MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__); + data_rect = MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__); *r_freedata = true; if (data_rect == NULL) { @@ -123,7 +123,7 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, * We must also convert to premultiplied for correct texture interpolation * and consistency with float images. */ if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) { - data_rect = MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__); + data_rect = MEM_mallocN(sizeof(uchar[4]) * ibuf->x * ibuf->y, __func__); *r_freedata = true; if (data_rect == NULL) { |