diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-03-18 19:06:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-21 18:38:13 +0300 |
commit | 1897df891cc6fa64a240a531853cddd1b52a78a5 (patch) | |
tree | fdef61ce07d0523db1114f2092b9a052e4e54015 /source/blender | |
parent | 6e4d2fa9140864a13356b07ffca082817822987f (diff) |
Cleanup: move OpenEXR channel name construction to OpenEXR code
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 30 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_multi.h | 7 | ||||
-rw-r--r-- | source/blender/render/intern/render_result.c | 53 |
3 files changed, 45 insertions, 45 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 418a4724c00..09d567c7827 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -78,6 +78,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) } #include "BLI_blenlib.h" #include "BLI_math_color.h" +#include "BLI_string_utils.h" #include "BLI_threads.h" #include "BKE_idprop.h" @@ -1491,6 +1492,35 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa return 1; } +void IMB_exr_channel_name(char *fullname, + const char *layname, + const char *passname, + const char *viewname, + const char *chan_id, + const int channel) +{ + const char *strings[4]; + int strings_len = 0; + + if (layname && layname[0]) { + strings[strings_len++] = layname; + } + if (passname && passname[0]) { + strings[strings_len++] = passname; + } + if (viewname && viewname[0]) { + strings[strings_len++] = viewname; + } + + char token[2]; + if (channel >= 0) { + ARRAY_SET_ITEMS(token, chan_id[channel], '\0'); + strings[strings_len++] = token; + } + + BLI_string_join_array_by_sep_char(fullname, EXR_PASS_MAXNAME, '.', strings, strings_len); +} + static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname) { ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name)); diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index f5a2f983b18..32a06a50c12 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -105,6 +105,13 @@ void IMB_exr_add_view(void *handle, const char *name); bool IMB_exr_has_multilayer(void *handle); +void IMB_exr_channel_name(char *fullname, + const char *layname, + const char *passname, + const char *viewname, + const char *chan_id, + const int channel); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/source/blender/render/intern/render_result.c b/source/blender/render/intern/render_result.c index 62948d052ba..f4ae3caa77b 100644 --- a/source/blender/render/intern/render_result.c +++ b/source/blender/render/intern/render_result.c @@ -162,37 +162,6 @@ void render_result_views_shallowdelete(RenderResult *rr) } } -static char *set_pass_name(char *outname, const char *name, int channel, const char *chan_id) -{ - const char *strings[2]; - int strings_len = 0; - strings[strings_len++] = name; - char token[2]; - if (channel >= 0) { - ARRAY_SET_ITEMS(token, chan_id[channel], '\0'); - strings[strings_len++] = token; - } - BLI_string_join_array_by_sep_char(outname, EXR_PASS_MAXNAME, '.', strings, strings_len); - return outname; -} - -static void set_pass_full_name( - char *fullname, const char *name, int channel, const char *view, const char *chan_id) -{ - const char *strings[3]; - int strings_len = 0; - strings[strings_len++] = name; - if (view && view[0]) { - strings[strings_len++] = view; - } - char token[2]; - if (channel >= 0) { - ARRAY_SET_ITEMS(token, chan_id[channel], '\0'); - strings[strings_len++] = token; - } - BLI_string_join_array_by_sep_char(fullname, EXR_PASS_MAXNAME, '.', strings, strings_len); -} - /********************************** New **************************************/ static void render_layer_allocate_pass(RenderResult *rr, RenderPass *rp) @@ -238,20 +207,14 @@ RenderPass *render_layer_add_pass(RenderResult *rr, BLI_strncpy(rpass->name, name, sizeof(rpass->name)); BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id)); BLI_strncpy(rpass->view, viewname, sizeof(rpass->view)); - set_pass_full_name(rpass->fullname, rpass->name, -1, rpass->view, rpass->chan_id); + IMB_exr_channel_name(rpass->fullname, NULL, rpass->name, rpass->view, rpass->chan_id, -1); if (rl->exrhandle) { int a; for (a = 0; a < channels; a++) { char passname[EXR_PASS_MAXNAME]; - IMB_exr_add_channel(rl->exrhandle, - rl->name, - set_pass_name(passname, rpass->name, a, rpass->chan_id), - viewname, - 0, - 0, - NULL, - false); + IMB_exr_channel_name(passname, NULL, rpass->name, NULL, rpass->chan_id, a); + IMB_exr_add_channel(rl->exrhandle, rl->name, passname, viewname, 0, 0, NULL, false); } } @@ -620,7 +583,7 @@ static void ml_addpass_cb(void *base, rpass->rect = rect; BLI_strncpy(rpass->name, name, EXR_PASS_MAXNAME); BLI_strncpy(rpass->view, view, sizeof(rpass->view)); - set_pass_full_name(rpass->fullname, name, -1, view, rpass->chan_id); + IMB_exr_channel_name(rpass->fullname, NULL, name, view, rpass->chan_id, -1); if (view[0] != '\0') { rpass->view_id = BLI_findstringindex(&rr->views, view, offsetof(RenderView, name)); @@ -899,7 +862,7 @@ bool RE_WriteRenderResult(ReportList *reports, const char *chan_id = "RGBA"; if (multi_layer) { - set_pass_name(passname, "Combined", a, chan_id); + IMB_exr_channel_name(passname, NULL, "Combined", NULL, chan_id, a); BLI_strncpy(layname, "Composite", sizeof(layname)); } else { @@ -961,7 +924,7 @@ bool RE_WriteRenderResult(ReportList *reports, char layname[EXR_PASS_MAXNAME]; if (multi_layer) { - set_pass_name(passname, rp->name, a, rp->chan_id); + IMB_exr_channel_name(passname, NULL, rp->name, NULL, rp->chan_id, a); BLI_strncpy(layname, rl->name, sizeof(layname)); } else { @@ -1097,12 +1060,12 @@ int render_result_exr_file_read_path(RenderResult *rr, char fullname[EXR_PASS_MAXNAME]; for (a = 0; a < xstride; a++) { - set_pass_full_name(fullname, rpass->name, a, rpass->view, rpass->chan_id); + IMB_exr_channel_name(fullname, NULL, rpass->name, rpass->view, rpass->chan_id, a); IMB_exr_set_channel( exrhandle, rl->name, fullname, xstride, xstride * rectx, rpass->rect + a); } - set_pass_full_name(rpass->fullname, rpass->name, -1, rpass->view, rpass->chan_id); + IMB_exr_channel_name(rpass->fullname, NULL, rpass->name, rpass->view, rpass->chan_id, -1); } } |