diff options
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 30 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_metadata.h | 5 | ||||
-rw-r--r-- | source/blender/imbuf/intern/IMB_filetype.h | 22 | ||||
-rw-r--r-- | source/blender/imbuf/intern/anim_movie.c | 11 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/radiance_hdr.c | 31 |
8 files changed, 52 insertions, 53 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 65d7631445d..c7481c6ea67 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -544,7 +544,7 @@ bool IMB_prepare_write_ImBuf(bool isfloat, struct ImBuf *ibuf); */ bool IMB_ispic(const char *filepath); bool IMB_ispic_type_matches(const char *filepath, int filetype); -int IMB_ispic_type_from_memory(const unsigned char *buf, size_t buf_size); +int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size); int IMB_ispic_type(const char *filepath); /** @@ -972,20 +972,28 @@ void IMB_update_gpu_texture_sub(struct GPUTexture *tex, /** * \attention defined in stereoimbuf.c */ -void IMB_stereo3d_write_dimensions( - char mode, bool is_squeezed, size_t width, size_t height, size_t *r_width, size_t *r_height); -void IMB_stereo3d_read_dimensions( - char mode, bool is_squeezed, size_t width, size_t height, size_t *r_width, size_t *r_height); +void IMB_stereo3d_write_dimensions(char mode, + bool is_squeezed, + const size_t width, + const size_t height, + size_t *r_width, + size_t *r_height); +void IMB_stereo3d_read_dimensions(char mode, + bool is_squeezed, + const size_t width, + const size_t height, + size_t *r_width, + size_t *r_height); int *IMB_stereo3d_from_rect(struct ImageFormatData *im_format, - size_t x, - size_t y, - size_t channels, + const size_t x, + const size_t y, + const size_t channels, int *rect_left, int *rect_right); float *IMB_stereo3d_from_rectf(struct ImageFormatData *im_format, - size_t x, - size_t y, - size_t channels, + const size_t x, + const size_t y, + const size_t channels, float *rectf_left, float *rectf_right); /** diff --git a/source/blender/imbuf/IMB_metadata.h b/source/blender/imbuf/IMB_metadata.h index 50982d08c3e..652ce913ee5 100644 --- a/source/blender/imbuf/IMB_metadata.h +++ b/source/blender/imbuf/IMB_metadata.h @@ -58,7 +58,10 @@ void IMB_metadata_free(struct IDProperty *metadata); * \param len: length of value buffer allocated by user. * \return 1 (true) if metadata is present and value for the key found, 0 (false) otherwise. */ -bool IMB_metadata_get_field(struct IDProperty *metadata, const char *key, char *value, size_t len); +bool IMB_metadata_get_field(struct IDProperty *metadata, + const char *key, + char *value, + const size_t len); /** * Set user data in the metadata. diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index bf6aef3ecd3..104458ffa7a 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -41,7 +41,7 @@ typedef struct ImFileType { * \note that this may only read in a small part of the files header, * see: #IMB_ispic_type for details. */ - bool (*is_a)(const unsigned char *buf, size_t size); + bool (*is_a)(const unsigned char *buf, const size_t size); /** Load an image from memory. */ struct ImBuf *(*load)(const unsigned char *mem, @@ -93,7 +93,7 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); /** \name Format: PNG (#IMB_FTYPE_PNG) * \{ */ -bool imb_is_a_png(const unsigned char *mem, size_t size); +bool imb_is_a_png(const unsigned char *mem, const size_t size); struct ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, @@ -106,7 +106,7 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags); /** \name Format: TARGA (#IMB_FTYPE_TGA) * \{ */ -bool imb_is_a_targa(const unsigned char *buf, size_t size); +bool imb_is_a_targa(const unsigned char *buf, const size_t size); struct ImBuf *imb_loadtarga(const unsigned char *mem, size_t size, int flags, @@ -119,7 +119,7 @@ bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags); /** \name Format: IRIS (#IMB_FTYPE_IMAGIC) * \{ */ -bool imb_is_a_iris(const unsigned char *mem, size_t size); +bool imb_is_a_iris(const unsigned char *mem, const size_t size); /** * Read in a B/W RGB or RGBA iris image file and return an image buffer. */ @@ -135,7 +135,7 @@ bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags); /** \name Format: JP2 (#IMB_FTYPE_JP2) * \{ */ -bool imb_is_a_jp2(const unsigned char *buf, size_t size); +bool imb_is_a_jp2(const unsigned char *buf, const size_t size); struct ImBuf *imb_load_jp2(const unsigned char *mem, size_t size, int flags, @@ -151,7 +151,7 @@ bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags); /** \name Format: JPEG (#IMB_FTYPE_JPG) * \{ */ -bool imb_is_a_jpeg(const unsigned char *mem, size_t size); +bool imb_is_a_jpeg(const unsigned char *mem, const size_t size); bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags); struct ImBuf *imb_load_jpeg(const unsigned char *buffer, size_t size, @@ -164,7 +164,7 @@ struct ImBuf *imb_load_jpeg(const unsigned char *buffer, /** \name Format: BMP (#IMB_FTYPE_BMP) * \{ */ -bool imb_is_a_bmp(const unsigned char *buf, size_t size); +bool imb_is_a_bmp(const unsigned char *buf, const size_t size); struct ImBuf *imb_bmp_decode(const unsigned char *mem, size_t size, int flags, @@ -178,7 +178,7 @@ bool imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags); /** \name Format: CINEON (#IMB_FTYPE_CINEON) * \{ */ -bool imb_is_a_cineon(const unsigned char *buf, size_t size); +bool imb_is_a_cineon(const unsigned char *buf, const size_t size); bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags); struct ImBuf *imb_load_cineon(const unsigned char *mem, size_t size, @@ -191,7 +191,7 @@ struct ImBuf *imb_load_cineon(const unsigned char *mem, /** \name Format: DPX (#IMB_FTYPE_DPX) * \{ */ -bool imb_is_a_dpx(const unsigned char *buf, size_t size); +bool imb_is_a_dpx(const unsigned char *buf, const size_t size); bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags); struct ImBuf *imb_load_dpx(const unsigned char *mem, size_t size, @@ -204,7 +204,7 @@ struct ImBuf *imb_load_dpx(const unsigned char *mem, /** \name Format: HDR (#IMB_FTYPE_RADHDR) * \{ */ -bool imb_is_a_hdr(const unsigned char *buf, size_t size); +bool imb_is_a_hdr(const unsigned char *buf, const size_t size); struct ImBuf *imb_loadhdr(const unsigned char *mem, size_t size, int flags, @@ -218,7 +218,7 @@ bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags); * \{ */ void imb_inittiff(void); -bool imb_is_a_tiff(const unsigned char *buf, size_t size); +bool imb_is_a_tiff(const unsigned char *buf, const size_t size); /** * Loads a TIFF file. * \param mem: Memory containing the TIFF file. diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 6a05b681c88..1d81653c7cd 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -879,7 +879,7 @@ static void ffmpeg_postprocess(struct anim *anim) dst2, dstStride2); # else - /* Scale with swscale. */ + /* Scale with swscale then flip image over Y axis. */ int *dstStride = anim->pFrameRGB->linesize; uint8_t **dst = anim->pFrameRGB->data; const int dstStride2[4] = {dstStride[0], 0, 0, 0}; @@ -896,12 +896,11 @@ static void ffmpeg_postprocess(struct anim *anim) dst2, dstStride2); - /* Flip destination image buffer over Y axis. */ - bottom = (unsigned char *)dst[0]; - top = bottom + anim->x * (anim->y - 1) * 4; + bottom = (unsigned char *)ibuf->rect; + top = bottom + ibuf->x * (ibuf->y - 1) * 4; - h = (anim->y + 1) / 2; - w = anim->x; + h = (ibuf->y + 1) / 2; + w = ibuf->x; for (y = 0; y < h; y++) { unsigned char tmp[4]; diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index 2d540f13a52..931c4f267f9 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -26,7 +26,7 @@ extern "C" { #endif -bool imb_is_a_dds(const unsigned char *mem, size_t size); +bool imb_is_a_dds(const unsigned char *mem, const size_t size); bool imb_save_dds(struct ImBuf *ibuf, const char *name, int flags); struct ImBuf *imb_load_dds(const unsigned char *mem, size_t size, diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.h b/source/blender/imbuf/intern/oiio/openimageio_api.h index 1201bd1b5e0..659050cdb00 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.h +++ b/source/blender/imbuf/intern/oiio/openimageio_api.h @@ -31,7 +31,7 @@ extern "C" { struct ImBuf; -bool imb_is_a_photoshop(const unsigned char *mem, size_t size); +bool imb_is_a_photoshop(const unsigned char *mem, const size_t size); int imb_save_photoshop(struct ImBuf *ibuf, const char *name, int flags); diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index 4321c95db30..14336620926 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -36,7 +36,7 @@ void imb_exitopenexr(void); * Test presence of OpenEXR file. * \param mem: pointer to loaded OpenEXR bit-stream. */ -bool imb_is_a_openexr(const unsigned char *mem, size_t size); +bool imb_is_a_openexr(const unsigned char *mem, const size_t size); bool imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags); diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 925ef0a8502..7f4e4dd31df 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -77,7 +77,7 @@ static const unsigned char *oldreadcolrs(RGBE *scan, scan[0][BLU] = *mem++; scan[0][EXP] = *mem++; if (scan[0][RED] == 1 && scan[0][GRN] == 1 && scan[0][BLU] == 1) { - for (i = scan[0][EXP] << rshift; i > 0 && len > 0; i--) { + for (i = scan[0][EXP] << rshift; i > 0; i--) { COPY_RGBE(scan[-1], scan[0]); scan++; len--; @@ -227,7 +227,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, int found = 0; int width = 0, height = 0; const unsigned char *ptr, *mem_eof = mem + size; - char oriY[3], oriX[3]; + char oriY[80], oriX[80]; if (!imb_is_a_hdr(mem, size)) { return NULL; @@ -244,33 +244,22 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, } } - if ((found && (x < (size - 1))) == 0) { + if ((found && (x < (size + 2))) == 0) { /* Data not found! */ return NULL; } - x++; - - /* sscanf requires a null-terminated buffer argument */ - char buf[32] = {0}; - memcpy(buf, &mem[x], MIN2(sizeof(buf) - 1, size - x)); - - if (sscanf(buf, "%2s %d %2s %d", (char *)&oriY, &height, (char *)&oriX, &width) != 4) { - return NULL; - } - - if (width < 1 || height < 1) { + if (sscanf((const char *)&mem[x + 1], + "%79s %d %79s %d", + (char *)&oriY, + &height, + (char *)&oriX, + &width) != 4) { return NULL; } - /* Checking that width x height does not extend past mem_eof is not easily possible - * since the format uses RLE compression. Can cause excessive memory allocation to occur. */ - /* find end of this line, data right behind it */ - ptr = (const unsigned char *)strchr((const char *)&mem[x], '\n'); - if (ptr == NULL || ptr >= mem_eof) { - return NULL; - } + ptr = (const unsigned char *)strchr((const char *)&mem[x + 1], '\n'); ptr++; if (flags & IB_test) { |