2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2015 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
#include "COM_OutputFileMultiViewOperation.h"
|
|
|
|
|
|
2023-05-03 11:49:47 +10:00
|
|
|
#include "BLI_fileops.h"
|
2023-09-01 21:37:11 +02:00
|
|
|
#include "BLI_string.h"
|
2023-05-03 11:49:47 +10:00
|
|
|
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_image.h"
|
2022-03-11 17:50:57 +01:00
|
|
|
#include "BKE_image_format.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
|
|
|
|
|
#include "IMB_colormanagement.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_imbuf.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2019-05-01 10:50:02 +10:00
|
|
|
/************************************ OpenEXR Singlelayer Multiview ******************************/
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
|
2022-03-11 18:21:05 +01:00
|
|
|
const Scene *scene,
|
2015-04-06 10:40:12 -03:00
|
|
|
const RenderData *rd,
|
|
|
|
|
const bNodeTree *tree,
|
|
|
|
|
DataType datatype,
|
2022-07-14 21:27:58 -07:00
|
|
|
const ImageFormatData *format,
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *path,
|
2021-10-13 23:01:15 +02:00
|
|
|
const char *view_name,
|
|
|
|
|
const bool save_as_render)
|
2022-03-11 18:21:05 +01:00
|
|
|
: OutputSingleLayerOperation(
|
|
|
|
|
scene, rd, tree, datatype, format, path, view_name, save_as_render)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filepath)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
size_t width = this->get_width();
|
|
|
|
|
size_t height = this->get_height();
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
if (width != 0 && height != 0) {
|
|
|
|
|
void *exrhandle;
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
exrhandle = IMB_exr_get_handle_name(filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return exrhandle;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
IMB_exr_clear_channels(exrhandle);
|
|
|
|
|
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (SceneRenderView *, srv, &rd_->views) {
|
2021-10-13 23:01:04 +02:00
|
|
|
if (BKE_scene_multiview_is_render_view_active(rd_, srv) == false) {
|
2015-04-06 10:40:12 -03:00
|
|
|
continue;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
IMB_exr_add_view(exrhandle, srv->name);
|
2021-10-13 23:01:04 +02:00
|
|
|
add_exr_channels(exrhandle, nullptr, datatype_, srv->name, width, false, nullptr);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_file_ensure_parent_dir_exists(filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
/* prepare the file with all the channels */
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
if (!IMB_exr_begin_write(exrhandle, filepath, width, height, format_.exr_codec, nullptr)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
printf("Error Writing Singlelayer Multiview Openexr\n");
|
|
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IMB_exr_clear_channels(exrhandle);
|
|
|
|
|
return exrhandle;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-06 17:49:09 +01:00
|
|
|
return nullptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution()
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2022-09-25 17:04:52 +10:00
|
|
|
uint width = this->get_width();
|
|
|
|
|
uint height = this->get_height();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (width != 0 && height != 0) {
|
|
|
|
|
void *exrhandle;
|
2023-05-03 14:13:27 +10:00
|
|
|
char filepath[FILE_MAX];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BKE_image_path_from_imtype(filepath,
|
2021-10-13 23:01:04 +02:00
|
|
|
path_,
|
2018-06-05 15:10:33 +02:00
|
|
|
BKE_main_blendfile_path_from_global(),
|
2021-10-13 23:01:04 +02:00
|
|
|
rd_->cfra,
|
2018-06-05 15:10:33 +02:00
|
|
|
R_IMF_IMTYPE_OPENEXR,
|
2021-10-13 23:01:04 +02:00
|
|
|
(rd_->scemode & R_EXTENSION) != 0,
|
2015-04-06 10:40:12 -03:00
|
|
|
true,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
exrhandle = this->get_handle(filepath);
|
2015-06-19 13:00:18 +02:00
|
|
|
add_exr_channels(exrhandle,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr,
|
2021-10-13 23:01:04 +02:00
|
|
|
datatype_,
|
2021-10-13 23:01:15 +02:00
|
|
|
view_name_,
|
2015-06-19 13:00:18 +02:00
|
|
|
width,
|
2022-03-11 18:21:05 +01:00
|
|
|
format_.depth == R_IMF_CHAN_DEPTH_16,
|
2021-10-13 23:01:15 +02:00
|
|
|
output_buffer_);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* memory can only be freed after we write all views to the file */
|
2021-10-13 23:01:15 +02:00
|
|
|
output_buffer_ = nullptr;
|
|
|
|
|
image_input_ = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* ready to close the file */
|
2021-10-13 23:01:15 +02:00
|
|
|
if (BKE_scene_multiview_is_render_view_last(rd_, view_name_)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_write_channels(exrhandle);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* free buffer memory for all the views */
|
2021-10-13 23:01:04 +02:00
|
|
|
free_exr_channels(exrhandle, rd_, nullptr, datatype_);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* remove exr handle and data */
|
|
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 10:50:02 +10:00
|
|
|
/************************************ OpenEXR Multilayer Multiview *******************************/
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
|
2021-01-12 16:19:54 +01:00
|
|
|
const Scene *scene,
|
2015-06-19 13:00:18 +02:00
|
|
|
const RenderData *rd,
|
|
|
|
|
const bNodeTree *tree,
|
|
|
|
|
const char *path,
|
|
|
|
|
char exr_codec,
|
|
|
|
|
bool exr_half_float,
|
2021-10-13 23:01:15 +02:00
|
|
|
const char *view_name)
|
|
|
|
|
: OutputOpenExrMultiLayerOperation(scene, rd, tree, path, exr_codec, exr_half_float, view_name)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filepath)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2022-09-25 17:04:52 +10:00
|
|
|
uint width = this->get_width();
|
|
|
|
|
uint height = this->get_height();
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
if (width != 0 && height != 0) {
|
2023-08-04 08:51:13 +10:00
|
|
|
/* Get a new global handle. */
|
|
|
|
|
void *exrhandle = IMB_exr_get_handle_name(filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return exrhandle;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
IMB_exr_clear_channels(exrhandle);
|
|
|
|
|
|
|
|
|
|
/* check renderdata for amount of views */
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (SceneRenderView *, srv, &rd_->views) {
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (BKE_scene_multiview_is_render_view_active(rd_, srv) == false) {
|
2015-04-06 10:40:12 -03:00
|
|
|
continue;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
IMB_exr_add_view(exrhandle, srv->name);
|
|
|
|
|
|
2022-09-25 17:04:52 +10:00
|
|
|
for (uint i = 0; i < layers_.size(); i++) {
|
2015-06-19 13:00:18 +02:00
|
|
|
add_exr_channels(exrhandle,
|
2021-10-13 23:01:04 +02:00
|
|
|
layers_[i].name,
|
|
|
|
|
layers_[i].datatype,
|
2015-06-19 13:00:18 +02:00
|
|
|
srv->name,
|
|
|
|
|
width,
|
2021-10-13 23:01:04 +02:00
|
|
|
exr_half_float_,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_file_ensure_parent_dir_exists(filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
/* prepare the file with all the channels for the header */
|
2021-10-13 23:01:15 +02:00
|
|
|
StampData *stamp_data = create_stamp_data();
|
2023-05-03 14:13:27 +10:00
|
|
|
if (!IMB_exr_begin_write(exrhandle, filepath, width, height, exr_codec_, stamp_data)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
printf("Error Writing Multilayer Multiview Openexr\n");
|
|
|
|
|
IMB_exr_close(exrhandle);
|
2021-01-12 16:19:54 +01:00
|
|
|
BKE_stamp_data_free(stamp_data);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IMB_exr_clear_channels(exrhandle);
|
2021-01-12 16:19:54 +01:00
|
|
|
BKE_stamp_data_free(stamp_data);
|
2015-04-06 10:40:12 -03:00
|
|
|
return exrhandle;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-06 17:49:09 +01:00
|
|
|
return nullptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution()
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2022-09-25 17:04:52 +10:00
|
|
|
uint width = this->get_width();
|
|
|
|
|
uint height = this->get_height();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (width != 0 && height != 0) {
|
|
|
|
|
void *exrhandle;
|
2023-05-03 14:13:27 +10:00
|
|
|
char filepath[FILE_MAX];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BKE_image_path_from_imtype(filepath,
|
2021-10-13 23:01:04 +02:00
|
|
|
path_,
|
2018-06-05 15:10:33 +02:00
|
|
|
BKE_main_blendfile_path_from_global(),
|
2021-10-13 23:01:04 +02:00
|
|
|
rd_->cfra,
|
2018-06-05 15:10:33 +02:00
|
|
|
R_IMF_IMTYPE_MULTILAYER,
|
2021-10-13 23:01:04 +02:00
|
|
|
(rd_->scemode & R_EXTENSION) != 0,
|
2015-04-06 10:40:12 -03:00
|
|
|
true,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
exrhandle = this->get_handle(filepath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-25 17:04:52 +10:00
|
|
|
for (uint i = 0; i < layers_.size(); i++) {
|
2015-06-19 13:00:18 +02:00
|
|
|
add_exr_channels(exrhandle,
|
2021-10-13 23:01:04 +02:00
|
|
|
layers_[i].name,
|
|
|
|
|
layers_[i].datatype,
|
2021-10-13 23:01:15 +02:00
|
|
|
view_name_,
|
2015-06-19 13:00:18 +02:00
|
|
|
width,
|
2021-10-13 23:01:04 +02:00
|
|
|
exr_half_float_,
|
2021-10-13 23:01:15 +02:00
|
|
|
layers_[i].output_buffer);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-25 17:04:52 +10:00
|
|
|
for (uint i = 0; i < layers_.size(); i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
/* memory can only be freed after we write all views to the file */
|
2021-10-13 23:01:15 +02:00
|
|
|
layers_[i].output_buffer = nullptr;
|
|
|
|
|
layers_[i].image_input = nullptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* ready to close the file */
|
2021-10-13 23:01:15 +02:00
|
|
|
if (BKE_scene_multiview_is_render_view_last(rd_, view_name_)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_write_channels(exrhandle);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* free buffer memory for all the views */
|
2022-09-25 17:04:52 +10:00
|
|
|
for (uint i = 0; i < layers_.size(); i++) {
|
2021-10-13 23:01:04 +02:00
|
|
|
free_exr_channels(exrhandle, rd_, layers_[i].name, layers_[i].datatype);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************** Stereo3D ******************************/
|
|
|
|
|
|
2022-03-11 18:21:05 +01:00
|
|
|
OutputStereoOperation::OutputStereoOperation(const Scene *scene,
|
|
|
|
|
const RenderData *rd,
|
2015-04-06 10:40:12 -03:00
|
|
|
const bNodeTree *tree,
|
|
|
|
|
DataType datatype,
|
2022-07-14 21:27:58 -07:00
|
|
|
const ImageFormatData *format,
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *path,
|
2023-05-03 14:13:27 +10:00
|
|
|
const char *pass_name,
|
2021-10-13 23:01:15 +02:00
|
|
|
const char *view_name,
|
|
|
|
|
const bool save_as_render)
|
2022-03-11 18:21:05 +01:00
|
|
|
: OutputSingleLayerOperation(
|
|
|
|
|
scene, rd, tree, datatype, format, path, view_name, save_as_render)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(pass_name_, pass_name);
|
2021-10-13 23:01:04 +02:00
|
|
|
channels_ = get_datatype_size(datatype);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
void *OutputStereoOperation::get_handle(const char *filepath)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
size_t width = this->get_width();
|
|
|
|
|
size_t height = this->get_height();
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
if (width != 0 && height != 0) {
|
|
|
|
|
void *exrhandle;
|
|
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
exrhandle = IMB_exr_get_handle_name(filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return exrhandle;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
IMB_exr_clear_channels(exrhandle);
|
|
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
for (i = 0; i < 2; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_add_view(exrhandle, names[i]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
return exrhandle;
|
|
|
|
|
}
|
2020-11-06 17:49:09 +01:00
|
|
|
return nullptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void OutputStereoOperation::deinit_execution()
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2022-09-25 17:04:52 +10:00
|
|
|
uint width = this->get_width();
|
|
|
|
|
uint height = this->get_height();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (width != 0 && height != 0) {
|
|
|
|
|
void *exrhandle;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
exrhandle = this->get_handle(path_);
|
2021-10-13 23:01:15 +02:00
|
|
|
float *buf = output_buffer_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* populate single EXR channel with view data */
|
2015-06-19 13:00:18 +02:00
|
|
|
IMB_exr_add_channel(exrhandle,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr,
|
2023-05-03 14:13:27 +10:00
|
|
|
pass_name_,
|
2021-10-13 23:01:15 +02:00
|
|
|
view_name_,
|
2015-06-19 13:00:18 +02:00
|
|
|
1,
|
2021-10-13 23:01:04 +02:00
|
|
|
channels_ * width * height,
|
2015-06-19 13:00:18 +02:00
|
|
|
buf,
|
2022-03-11 18:21:05 +01:00
|
|
|
format_.depth == R_IMF_CHAN_DEPTH_16);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
image_input_ = nullptr;
|
|
|
|
|
output_buffer_ = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* create stereo ibuf */
|
2021-10-13 23:01:15 +02:00
|
|
|
if (BKE_scene_multiview_is_render_view_last(rd_, view_name_)) {
|
2020-11-06 17:49:09 +01:00
|
|
|
ImBuf *ibuf[3] = {nullptr};
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
2023-05-03 14:13:27 +10:00
|
|
|
char filepath[FILE_MAX];
|
2015-04-06 10:40:12 -03:00
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* get rectf from EXR */
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2023-05-03 14:13:27 +10:00
|
|
|
float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, pass_name_, names[i]);
|
2022-03-11 18:21:05 +01:00
|
|
|
ibuf[i] = IMB_allocImBuf(width, height, format_.planes, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
ibuf[i]->channels = channels_;
|
|
|
|
|
ibuf[i]->dither = rd_->dither_intensity;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-18 10:19:01 +02:00
|
|
|
IMB_assign_float_buffer(ibuf[i], rectf, IB_TAKE_OWNERSHIP);
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* do colormanagement in the individual views, so it doesn't need to do in the stereo */
|
2022-03-11 18:21:05 +01:00
|
|
|
IMB_colormanagement_imbuf_for_write(ibuf[i], true, false, &format_);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* create stereo buffer */
|
2022-03-11 18:21:05 +01:00
|
|
|
ibuf[2] = IMB_stereo3d_ImBuf(&format_, ibuf[0], ibuf[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BKE_image_path_from_imformat(filepath,
|
2021-10-13 23:01:04 +02:00
|
|
|
path_,
|
2018-06-05 15:10:33 +02:00
|
|
|
BKE_main_blendfile_path_from_global(),
|
2021-10-13 23:01:04 +02:00
|
|
|
rd_->cfra,
|
2022-03-11 18:21:05 +01:00
|
|
|
&format_,
|
2021-10-13 23:01:04 +02:00
|
|
|
(rd_->scemode & R_EXTENSION) != 0,
|
2015-04-06 10:40:12 -03:00
|
|
|
true,
|
2020-11-06 17:49:09 +01:00
|
|
|
nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BKE_imbuf_write(ibuf[2], filepath, &format_);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* imbuf knows which rects are not part of ibuf */
|
2019-04-23 11:21:22 +10:00
|
|
|
for (i = 0; i < 3; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_freeImBuf(ibuf[i]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|