[Bf-blender-cvs] [d75a10e] multiview: Getting rid of the OpenEXR Multiview in the UI

Dalai Felinto noreply at git.blender.org
Wed Sep 17 14:12:21 CEST 2014


Commit: d75a10e986a1938a8247d7ec640406da0f65bcb2
Author: Dalai Felinto
Date:   Thu Sep 11 23:37:32 2014 +0200
Branches: multiview
https://developer.blender.org/rBd75a10e986a1938a8247d7ec640406da0f65bcb2

Getting rid of the OpenEXR Multiview in the UI

===================================================================

M	source/blender/blenkernel/intern/image.c
M	source/blender/compositor/nodes/COM_OutputFileNode.cpp
M	source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
M	source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
M	source/blender/compositor/operations/COM_OutputFileOperation.h
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/imbuf/intern/openexr/openexr_api.cpp
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/render/intern/source/pipeline.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 30d0d4b..9ea2f42 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1213,7 +1213,7 @@ int BKE_imtype_to_ftype(const char imtype)
 	else if (imtype == R_IMF_IMTYPE_TIFF)
 		return TIF;
 #endif
-	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER, R_IMF_IMTYPE_MULTIVIEW))
+	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER))
 		return OPENEXR;
 #ifdef WITH_CINEON
 	else if (imtype == R_IMF_IMTYPE_CINEON)
@@ -1292,7 +1292,7 @@ int BKE_imtype_supports_zbuf(const char imtype)
 {
 	switch (imtype) {
 		case R_IMF_IMTYPE_IRIZ:
-		case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER or R_IMF_IMTYPE_MULTIVIEW */
+		case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
 			return 1;
 	}
 	return 0;
@@ -1326,7 +1326,6 @@ int BKE_imtype_requires_linear_float(const char imtype)
 		case R_IMF_IMTYPE_RADHDR:
 		case R_IMF_IMTYPE_OPENEXR:
 		case R_IMF_IMTYPE_MULTILAYER:
-		case R_IMF_IMTYPE_MULTIVIEW:
 			return true;
 	}
 	return 0;
@@ -1348,7 +1347,6 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file)
 		case R_IMF_IMTYPE_TIFF:
 		case R_IMF_IMTYPE_OPENEXR:
 		case R_IMF_IMTYPE_MULTILAYER:
-		case R_IMF_IMTYPE_MULTIVIEW:
 		case R_IMF_IMTYPE_DDS:
 		case R_IMF_IMTYPE_JP2:
 		case R_IMF_IMTYPE_QUICKTIME:
@@ -1382,7 +1380,6 @@ char BKE_imtype_valid_depths(const char imtype)
 		case R_IMF_IMTYPE_OPENEXR:
 			return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
 		case R_IMF_IMTYPE_MULTILAYER:
-		case R_IMF_IMTYPE_MULTIVIEW:
 			return R_IMF_CHAN_DEPTH_32;
 		/* eeh, cineon does some strange 10bits per channel */
 		case R_IMF_IMTYPE_DPX:
@@ -1426,7 +1423,6 @@ char BKE_imtype_from_arg(const char *imtype_arg)
 #ifdef WITH_OPENEXR
 	else if (!strcmp(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR;
 	else if (!strcmp(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER;
-	else if (!strcmp(imtype_arg, "MULTIVIEW")) return R_IMF_IMTYPE_MULTIVIEW;
 #endif
 	else if (!strcmp(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG;
 	else if (!strcmp(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER;
@@ -1492,7 +1488,7 @@ static bool do_add_image_extension(char *string, const char imtype, const ImageF
 	}
 #endif
 #ifdef WITH_OPENEXR
-	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER, R_IMF_IMTYPE_MULTIVIEW)) {
+	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
 		if (!BLI_testextensie(string, extension_test = ".exr"))
 			extension = extension_test;
 	}
@@ -2129,7 +2125,7 @@ void BKE_imbuf_prepare_write(ImBuf *ibuf, ImageFormatData *imf)
 	}
 #endif
 #ifdef WITH_OPENEXR
-	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER, R_IMF_IMTYPE_MULTIVIEW)) {
+	else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
 		ibuf->ftype = OPENEXR;
 		if (imf->depth == R_IMF_CHAN_DEPTH_16)
 			ibuf->ftype |= OPENEXR_HALF;
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index 967c373..a6a4688 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -38,6 +38,7 @@ OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode)
 void OutputFileNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
 {
 	NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
+	const bool is_multiview = (context.getRenderData()->scemode & R_MULTIVIEW);
 	
 	if (!context.isRendering()) {
 		/* only output files when rendering a sequence -
@@ -47,12 +48,12 @@ void OutputFileNode::convertToOperations(NodeConverter &converter, const Composi
 		return;
 	}
 	
-	if (ELEM(storage->format.imtype, R_IMF_IMTYPE_MULTILAYER, R_IMF_IMTYPE_MULTIVIEW)) {
+	if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
 		/* single output operation for the multilayer file */
 		OutputOpenExrMultiLayerOperation *outputOperation;
 
-		if (storage->format.imtype == R_IMF_IMTYPE_MULTIVIEW) {
-			outputOperation = new OutputOpenExrMultiViewOperation(
+		if (is_multiview && storage->format.views_format == R_IMF_VIEWS_MULTIVIEW) {
+			outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(
 			        context.getRenderData(), context.getbNodeTree(), storage->base_path, storage->format.exr_codec, context.getViewName());
 		} else {
 			outputOperation = new OutputOpenExrMultiLayerOperation(
@@ -80,7 +81,6 @@ void OutputFileNode::convertToOperations(NodeConverter &converter, const Composi
 	else {  /* single layer format */
 		int num_inputs = getNumberOfInputSockets();
 		bool previewAdded = false;
-		const bool is_mono = BKE_scene_num_views(context.getRenderData()) < 2;
 		for (int i = 0; i < num_inputs; ++i) {
 			NodeInput *input = getInputSocket(i);
 			if (input->isLinked()) {
@@ -93,14 +93,12 @@ void OutputFileNode::convertToOperations(NodeConverter &converter, const Composi
 
 				NodeOperation *outputOperation = NULL;
 
-				if (format->imtype == R_IMF_IMTYPE_MULTIVIEW) {
-					outputOperation = new OutputOpenExrMultiViewOperation(
-					        context.getRenderData(), context.getbNodeTree(), path, format->exr_codec, context.getViewName());
-
-					((OutputOpenExrMultiViewOperation *)outputOperation)->add_layer(sockdata->layer, input->getDataType(), true);
-					converter.mapInputSocket(input, outputOperation->getInputSocket(0));
+				if (is_multiview && format->views_format == R_IMF_VIEWS_MULTIVIEW) {
+					outputOperation = new OutputOpenExrSingleLayerMultiViewOperation(
+					        context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
+					        context.getViewSettings(), context.getDisplaySettings(), context.getViewName());
 				}
-				else if (is_mono || (format->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
+				else if ((!is_multiview) || (format->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
 					outputOperation = new OutputSingleLayerOperation(
 					        context.getRenderData(), context.getbNodeTree(), input->getDataType(), format, path,
 					        context.getViewSettings(), context.getDisplaySettings(), context.getViewName());
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index 0eaf865..6e125ee 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -43,13 +43,106 @@ extern "C" {
 	#include "IMB_imbuf_types.h"
 }
 
-OutputOpenExrMultiViewOperation::OutputOpenExrMultiViewOperation(
+/************************************  OpenEXR Singlelayer Multiview *****************************************/
+
+OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
+        const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
+        const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
+        const char *viewName):
+        OutputSingleLayerOperation(rd, tree, datatype, format, path, viewSettings, displaySettings, viewName)
+{
+}
+
+void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char* filename)
+{
+	size_t width = this->getWidth();
+	size_t height = this->getHeight();
+	SceneRenderView *srv;
+
+	if (width != 0 && height != 0) {
+		void *exrhandle;
+
+		exrhandle = IMB_exr_get_handle_name(filename);
+
+		if (!BKE_scene_render_view_first(this->m_rd, this->m_viewName))
+			return exrhandle;
+
+		IMB_exr_clear_channels(exrhandle);
+
+		for (srv = (SceneRenderView *) this->m_rd->views.first; srv; srv = srv->next)
+			if (BKE_scene_render_view_active(this->m_rd, srv))
+				IMB_exr_add_view(exrhandle, srv->name);
+
+		return exrhandle;
+	}
+	return NULL;
+}
+
+void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
+{
+	unsigned int width = this->getWidth();
+	unsigned int height = this->getHeight();
+
+	if (width != 0 && height != 0) {
+		void *exrhandle;
+		float *buf = this->m_outputBuffer;
+		Main *bmain = G.main; /* TODO, have this passed along */
+		char filename[FILE_MAX];
+
+		BKE_makepicstring_from_type(filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR,
+		                            (this->m_rd->scemode & R_EXTENSION), true, "");
+
+		exrhandle = this->get_handle(filename);
+
+		IMB_exr_clear_channels(exrhandle);
+
+		/* create channels */
+		switch (this->m_datatype) {
+			case COM_DT_VALUE:
+				IMB_exr_add_channel(exrhandle, 0, "V", this->m_viewName, 1, width, buf);
+				break;
+			case COM_DT_VECTOR:
+				IMB_exr_add_channel(exrhandle, 0, "X", this->m_viewName, 3, 3 * width, buf);
+				IMB_exr_add_channel(exrhandle, 0, "Y", this->m_viewName, 3, 3 * width, buf + 1);
+				IMB_exr_add_channel(exrhandle, 0, "Z", this->m_viewName, 3, 3 * width, buf + 2);
+				break;
+			case COM_DT_COLOR:
+				IMB_exr_add_channel(exrhandle, 0, "R", this->m_viewName, 4, 4 * width, buf);
+				IMB_exr_add_channel(exrhandle, 0, "G", this->m_viewName, 4, 4 * width, buf + 1);
+				IMB_exr_add_channel(exrhandle, 0, "B", this->m_viewName, 4, 4 * width, buf + 2);
+				IMB_exr_add_channel(exrhandle, 0, "A", this->m_viewName, 4, 4 * width, buf + 3);
+				break;
+			default:
+				break;
+		}
+
+		/* the actual writing */
+		IMB_exrmultiview_write_channels(exrhandle, this->m_viewName);
+
+		if (this->m_outputBuffer)
+			MEM_freeN(this->m_outputBuffer);
+
+		if (this->m_imageInput)
+			MEM_freeN(this->m_imageInput);
+
+		this->m_outputBuffer = NULL;
+		this->m_imageInput = NULL;
+
+		/* ready to close the file */
+		if (BKE_scene_render_view_last(this->m_rd, this->m_viewName))
+			IMB_exr_close(exrhandle);
+	}
+}
+
+/************************************  OpenEXR Multilayer Multiview *****************************************/
+
+OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
         const RenderData *rd, const bNodeTree *tree, const char *path, ch

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list