From 1f7096bb581643e3a61b1da7ec1bea474990be24 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 10 Jun 2013 13:54:09 +0000 Subject: Fix #35658: OpenEXR (from Maya) - missing passes Added some special case for two-component channels name. Maybe magic could be simplified to just use last char of channel name as an id, but extra paranoid check never hurts. --- .../blender/imbuf/intern/openexr/openexr_api.cpp | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source/blender/imbuf/intern/openexr/openexr_api.cpp') diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index b0932148076..8159520f693 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -899,12 +899,36 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa printf("multilayer read: bad channel name: %s\n", name); return 0; } + else if (len == 1) { + echan->chan_id = token[0]; + } else if (len > 1) { - BLI_strncpy(tokenbuf, token, len); - printf("multilayer read: channel token too long: %s\n", tokenbuf); - return 0; + bool ok = false; + + if (len == 2) { + /* some multilayers are using two-letter channels name, + * like, MX or NZ, which is basically has structure of + * + * + * This is a bit silly, but see file from [#35658]. + * + * Here we do some magic to distinguish such cases. + */ + if (ELEM3(token[1], 'X', 'Y', 'Z') || + ELEM3(token[1], 'R', 'G', 'B') || + ELEM3(token[1], 'U', 'V', 'A')) + { + echan->chan_id = token[1]; + ok = true; + } + } + + if (ok == false) { + BLI_strncpy(tokenbuf, token, std::min(len + 1, EXR_TOT_MAXNAME)); + printf("multilayer read: channel token too long: %s\n", tokenbuf); + return 0; + } } - echan->chan_id = token[0]; end -= len + 1; /* +1 to skip '.' separator */ /* second token is pass name */ -- cgit v1.2.3