diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-09-12 20:39:24 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-09-12 21:21:13 +0300 |
commit | bc15c83afaf952f9c9651866923c4980d7934259 (patch) | |
tree | 9c25f62a18a0a9f955d96e510d4b3e7de9ba2240 /source/blender/imbuf/intern | |
parent | 100fe61f7c5be981193a46776cef5ba4df64eb31 (diff) |
Fix T100886: error saving side-by-side stereo EXR image of depth pass
The stereo saving code that combines two image buffers into one did not work
correctly when the number of channels is not equal to 4.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/stereoimbuf.c | 30 |
4 files changed, 26 insertions, 16 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 8b9ad94de0c..868040dc17a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -364,7 +364,7 @@ void *imb_alloc_pixels( return MEM_callocN(size, name); } -bool imb_addrectfloatImBuf(ImBuf *ibuf) +bool imb_addrectfloatImBuf(ImBuf *ibuf, const unsigned int channels) { if (ibuf == NULL) { return false; @@ -374,8 +374,8 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf) imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */ } - ibuf->channels = 4; - if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(float), __func__))) { + ibuf->channels = channels; + if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(float), __func__))) { ibuf->mall |= IB_rectfloat; ibuf->flags |= IB_rectfloat; return true; @@ -536,7 +536,7 @@ bool IMB_initImBuf( } if (flags & IB_rectfloat) { - if (imb_addrectfloatImBuf(ibuf) == false) { + if (imb_addrectfloatImBuf(ibuf, ibuf->channels) == false) { return false; } } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index eb6ce5df794..aaeb407abc4 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -2058,7 +2058,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t xstride = sizeof(float[4]); size_t ystride = -xstride * width; - imb_addrectfloatImBuf(ibuf); + imb_addrectfloatImBuf(ibuf, 4); /* Inverse correct first pixel for data-window * coordinates (- dw.min.y because of y flip). */ diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 4d6dfac0ba0..e27d649ccbe 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -646,7 +646,7 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors if (ibuf && ((flags & IB_test) == 0)) { if (bit_depth == 16) { - imb_addrectfloatImBuf(ibuf); + imb_addrectfloatImBuf(ibuf, 4); png_set_swap(png_ptr); pixels16 = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(png_uint_16), "pixels"); diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c index 2a0baaf6172..ba1840a5fcd 100644 --- a/source/blender/imbuf/intern/stereoimbuf.c +++ b/source/blender/imbuf/intern/stereoimbuf.c @@ -761,11 +761,14 @@ ImBuf *IMB_stereo3d_ImBuf(const ImageFormatData *im_format, ImBuf *ibuf_left, Im IMB_stereo3d_write_dimensions( im_format->stereo3d_format.display_mode, false, ibuf_left->x, ibuf_left->y, &width, &height); - ibuf_stereo = IMB_allocImBuf( - width, height, ibuf_left->planes, (is_float ? IB_rectfloat : IB_rect)); + ibuf_stereo = IMB_allocImBuf(width, height, ibuf_left->planes, 0); - ibuf_stereo->rect_colorspace = ibuf_left->rect_colorspace; - ibuf_stereo->float_colorspace = ibuf_left->float_colorspace; + if (is_float) { + imb_addrectfloatImBuf(ibuf_stereo, ibuf_left->channels); + } + else { + imb_addrectImBuf(ibuf_stereo); + } ibuf_stereo->flags = ibuf_left->flags; @@ -773,7 +776,7 @@ ImBuf *IMB_stereo3d_ImBuf(const ImageFormatData *im_format, ImBuf *ibuf_left, Im is_float, ibuf_left->x, ibuf_left->y, - 4, + ibuf_left->channels, (int *)ibuf_left->rect, (int *)ibuf_right->rect, (int *)ibuf_stereo->rect, @@ -1286,10 +1289,17 @@ void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, &width, &height); - ibuf_left = IMB_allocImBuf( - width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect)); - ibuf_right = IMB_allocImBuf( - width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect)); + ibuf_left = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, 0); + ibuf_right = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, 0); + + if (is_float) { + imb_addrectfloatImBuf(ibuf_left, ibuf_stereo3d->channels); + imb_addrectfloatImBuf(ibuf_right, ibuf_stereo3d->channels); + } + else { + imb_addrectImBuf(ibuf_left); + imb_addrectImBuf(ibuf_right); + } ibuf_left->flags = ibuf_stereo3d->flags; ibuf_right->flags = ibuf_stereo3d->flags; @@ -1307,7 +1317,7 @@ void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, is_float, ibuf_left->x, ibuf_left->y, - 4, + ibuf_left->channels, (int *)ibuf_left->rect, (int *)ibuf_right->rect, (int *)ibuf_stereo3d->rect, |