Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2017-10-20 16:18:26 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-11-08 01:20:22 +0300
commit2a097527f20da98bb4c1199c2854a15eea241153 (patch)
tree57915a10d37a0451c8493297f2a3ed62a7b264f9 /source/blender/blenkernel
parented7260071bc397dd389737088fce869e8adc0dc3 (diff)
Fix various issues with (multiview) OpenEXR file save/load.
* Fix saving a multiview render from the image editor giving invalid files. * Fix failure to load multiview images with a single view per part. * Fix loss of multiview metadata when saving/loading a single view. * Fix Z-Buffer writing option for single layer EXR not being respected. Multiview EXRs are now always handled as multilayer internally, significantly reducing the amount of code. Reviewed By: dfelinto Differential Revision: https://developer.blender.org/D2887
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/image.c118
1 files changed, 9 insertions, 109 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 4cdf98285c0..9ba7cc1c679 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2924,7 +2924,8 @@ bool BKE_image_is_multilayer(Image *ima)
bool BKE_image_is_multiview(Image *ima)
{
- return (BLI_listbase_count_ex(&ima->views, 2) > 1);
+ ImageView *view = ima->views.first;
+ return (view && (view->next || view->name[0]));
}
bool BKE_image_is_stereo(Image *ima)
@@ -3030,51 +3031,6 @@ void BKE_image_backup_render(Scene *scene, Image *ima, bool free_current_slot)
ima->last_render_slot = slot;
}
-/**************************** multiview save openexr *********************************/
-#ifdef WITH_OPENEXR
-static const char *image_get_view_cb(void *base, const int view_id)
-{
- Image *ima = base;
- ImageView *iv = BLI_findlink(&ima->views, view_id);
- return iv ? iv->name : "";
-}
-#endif /* WITH_OPENEXR */
-
-#ifdef WITH_OPENEXR
-static ImBuf *image_get_buffer_cb(void *base, const int view_id)
-{
- Image *ima = base;
- ImageUser iuser = {0};
-
- iuser.view = view_id;
- iuser.ok = 1;
-
- BKE_image_multiview_index(ima, &iuser);
-
- return image_acquire_ibuf(ima, &iuser, NULL);
-}
-#endif /* WITH_OPENEXR */
-
-bool BKE_image_save_openexr_multiview(Image *ima, ImBuf *ibuf, const char *filepath, const int flags)
-{
-#ifdef WITH_OPENEXR
- char name[FILE_MAX];
- bool ok;
-
- BLI_strncpy(name, filepath, sizeof(name));
- BLI_path_abs(name, G.main->name);
-
- ibuf->userdata = ima;
- ok = IMB_exr_multiview_save(ibuf, name, flags, BLI_listbase_count(&ima->views), image_get_view_cb, image_get_buffer_cb);
- ibuf->userdata = NULL;
-
- return ok;
-#else
- UNUSED_VARS(ima, ibuf, filepath, flags);
- return false;
-#endif
-}
-
/**************************** multiview load openexr *********************************/
static void image_add_view(Image *ima, const char *viewname, const char *filepath)
@@ -3107,51 +3063,6 @@ static void image_add_view(Image *ima, const char *viewname, const char *filepat
}
}
-#ifdef WITH_OPENEXR
-static void image_add_view_cb(void *base, const char *str)
-{
- Image *ima = base;
- image_add_view(ima, str, ima->name);
-}
-
-static void image_add_buffer_cb(void *base, const char *str, ImBuf *ibuf, const int frame)
-{
- Image *ima = base;
- int id;
- bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
- const char *colorspace = ima->colorspace_settings.name;
- const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
-
- if (ibuf == NULL)
- return;
-
- id = BLI_findstringindex(&ima->views, str, offsetof(ImageView, name));
-
- if (id == -1)
- return;
-
- if (ibuf->channels >= 3)
- IMB_colormanagement_transform(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
- colorspace, to_colorspace, predivide);
-
- image_assign_ibuf(ima, ibuf, id, frame);
- IMB_freeImBuf(ibuf);
-}
-#endif /* WITH_OPENEXR */
-
-/* after imbuf load, openexr type can return with a exrhandle open */
-/* in that case we have to build a render-result */
-#ifdef WITH_OPENEXR
-static void image_create_multiview(Image *ima, ImBuf *ibuf, const int frame)
-{
- BKE_image_free_views(ima);
-
- IMB_exr_multiview_convert(ibuf->userdata, ima, image_add_view_cb, image_add_buffer_cb, frame);
-
- IMB_exr_close(ibuf->userdata);
-}
-#endif /* WITH_OPENEXR */
-
/* after imbuf load, openexr type can return with a exrhandle open */
/* in that case we have to build a render-result */
#ifdef WITH_OPENEXR
@@ -3263,16 +3174,10 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons
if (ibuf) {
#ifdef WITH_OPENEXR
- /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
- /* handle singlelayer multiview case assign ibuf based on available views */
- if (IMB_exr_has_singlelayer_multiview(ibuf->userdata)) {
- image_create_multiview(ima, ibuf, frame);
- IMB_freeImBuf(ibuf);
- ibuf = NULL;
- }
- else if (IMB_exr_has_multilayer(ibuf->userdata)) {
- /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
+ /* Handle multilayer and multiview cases, don't assign ibuf here.
+ * will be set layer in BKE_image_acquire_ibuf from ima->rr. */
+ if (IMB_exr_has_multilayer(ibuf->userdata)) {
image_create_multilayer(ima, ibuf, frame);
ima->type = IMA_TYPE_MULTILAYER;
IMB_freeImBuf(ibuf);
@@ -3561,14 +3466,9 @@ static ImBuf *load_image_single(
if (ibuf) {
#ifdef WITH_OPENEXR
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
- if (IMB_exr_has_singlelayer_multiview(ibuf->userdata)) {
- /* handle singlelayer multiview case assign ibuf based on available views */
- image_create_multiview(ima, ibuf, cfra);
- IMB_freeImBuf(ibuf);
- ibuf = NULL;
- }
- else if (IMB_exr_has_multilayer(ibuf->userdata)) {
- /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_acquire_ibuf */
+ /* Handle multilayer and multiview cases, don't assign ibuf here.
+ * will be set layer in BKE_image_acquire_ibuf from ima->rr. */
+ if (IMB_exr_has_multilayer(ibuf->userdata)) {
image_create_multilayer(ima, ibuf, cfra);
ima->type = IMA_TYPE_MULTILAYER;
IMB_freeImBuf(ibuf);
@@ -4408,7 +4308,7 @@ void BKE_image_update_frame(const Main *bmain, int cfra)
void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
{
- if (BKE_image_is_multiview(ima) && (ima->rr == NULL)) {
+ if (BKE_image_is_multiview(ima)) {
ImageView *iv = BLI_findlink(&ima->views, iuser->view);
if (iv->filepath[0])
BLI_strncpy(filepath, iv->filepath, FILE_MAX);