[Bf-blender-cvs] [b2900ad098] temp-cycles-denoising: Cycles Denoising: Remove standalone denoising Python API function

Lukas Stockner noreply at git.blender.org
Mon Feb 13 02:05:44 CET 2017


Commit: b2900ad0985335e04e0557e57c168e0782b82d16
Author: Lukas Stockner
Date:   Sat Feb 11 03:37:56 2017 +0100
Branches: temp-cycles-denoising
https://developer.blender.org/rBb2900ad0985335e04e0557e57c168e0782b82d16

Cycles Denoising: Remove standalone denoising Python API function

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

M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/render/CMakeLists.txt
D	intern/cycles/render/denoising.cpp
D	intern/cycles/render/denoising.h

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

diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 0cdb55b21a..5ec6aa43d6 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -29,8 +29,6 @@
 #include "util_string.h"
 #include "util_types.h"
 
-#include "denoising.h"
-
 #ifdef WITH_OSL
 #include "osl.h"
 
@@ -762,34 +760,6 @@ static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
 	return list;
 }
 
-static PyObject *denoise_files_func(PyObject * /*self*/, PyObject *args, PyObject *keywords)
-{
-	SessionParams session_params;
-	session_params.samples = 128;
-	session_params.threads = 0;
-
-	int half_output = 0, use_gpu = 0;
-	const char *output = NULL, *filename = NULL;
-
-	static const char* keylist[] = {"filename", "output", "half_float", "use_gpu", "samples", "threads", "tile_x", "tile_y", "filter_strength", "filter_weight_adjust"};
-	if(!PyArg_ParseTupleAndKeywords(args, keywords, "ss|ppiiiiff", const_cast<char **>(keylist), &filename, &output, &half_output, &use_gpu,
-	                                &session_params.samples, &session_params.threads, &session_params.tile_size.x, &session_params.tile_size.y,
-	                                &session_params.filter_strength, &session_params.filter_weight_adjust)) {
-		return NULL;
-	}
-	session_params.output_half_float = (half_output > 0);
-	session_params.output_path = string(output);
-
-	BL::UserPreferences b_userpref(get_user_preferences());
-	session_params.device = BlenderSync::get_device_info(b_userpref, use_gpu);
-
-	if(denoise_standalone(session_params, filename)) {
-		Py_RETURN_TRUE;
-	}
-	Py_RETURN_FALSE;
-}
-
-
 static PyMethodDef methods[] = {
 	{"init", init_func, METH_VARARGS, ""},
 	{"exit", exit_func, METH_VARARGS, ""},
@@ -812,7 +782,6 @@ static PyMethodDef methods[] = {
 
 	{"can_postprocess", can_postprocess_func, METH_VARARGS, ""},
 	{"postprocess", postprocess_func, METH_VARARGS, ""},
-	{"denoise_files", (PyCFunction)denoise_files_func, METH_VARARGS|METH_KEYWORDS, ""},
 
 	/* Debugging routines */
 	{"debug_flags_update", debug_flags_update_func, METH_VARARGS, ""},
diff --git a/intern/cycles/render/CMakeLists.txt b/intern/cycles/render/CMakeLists.txt
index caf7ea0ac2..8eaa9de387 100644
--- a/intern/cycles/render/CMakeLists.txt
+++ b/intern/cycles/render/CMakeLists.txt
@@ -23,7 +23,6 @@ set(SRC
 	buffers.cpp
 	camera.cpp
 	constant_fold.cpp
-	denoising.cpp
 	film.cpp
 	graph.cpp
 	image.cpp
@@ -53,7 +52,6 @@ set(SRC_HEADERS
 	buffers.h
 	camera.h
 	constant_fold.h
-	denoising.h
 	film.h
 	graph.h
 	image.h
diff --git a/intern/cycles/render/denoising.cpp b/intern/cycles/render/denoising.cpp
deleted file mode 100644
index b88316eae7..0000000000
--- a/intern/cycles/render/denoising.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-#include "denoising.h"
-
-#include "util_image.h"
-
-CCL_NAMESPACE_BEGIN
-
-typedef class PassTypeInfo
-{
-public:
-	PassTypeInfo(DenoisingPassType type, int num_channels, string channels)
-	 : type(type), num_channels(num_channels), channels(channels) {}
-	PassTypeInfo() : type(DENOISING_PASS_NONE), num_channels(0), channels("") {}
-
-	DenoisingPassType type;
-	int num_channels;
-	string channels;
-
-	bool operator<(const PassTypeInfo &other) const {
-		return type < other.type;
-	}
-} PassTypeInfo;
-
-static map<string, PassTypeInfo> denoise_passes_init()
-{
-	map<string, PassTypeInfo> passes;
-
-	passes["Denoising Normal"]          = PassTypeInfo(DENOISING_PASS_NORMAL,     3, "XYZ");
-	passes["Denoising Normal Variance"] = PassTypeInfo(DENOISING_PASS_NORMAL_VAR, 3, "XYZ");
-	passes["Denoising Albedo"]          = PassTypeInfo(DENOISING_PASS_ALBEDO,     3, "RGB");
-	passes["Denoising Albedo Variance"] = PassTypeInfo(DENOISING_PASS_ALBEDO_VAR, 3, "RGB");
-	passes["Denoising Depth"]           = PassTypeInfo(DENOISING_PASS_DEPTH,      1, "Z");
-	passes["Denoising Depth Variance"]  = PassTypeInfo(DENOISING_PASS_DEPTH_VAR,  1, "Z");
-	passes["Denoising Shadow A"]        = PassTypeInfo(DENOISING_PASS_SHADOW_A,   3, "ABV");
-	passes["Denoising Shadow B"]        = PassTypeInfo(DENOISING_PASS_SHADOW_B,   3, "ABV");
-	passes["Denoising Noisy"]           = PassTypeInfo(DENOISING_PASS_NOISY,      3, "RGB");
-	passes["Denoising Noisy Variance"]  = PassTypeInfo(DENOISING_PASS_NOISY_VAR,  3, "RGB");
-	passes["Denoising Clean"]           = PassTypeInfo(DENOISING_PASS_CLEAN,      3, "RGB");
-
-	return passes;
-}
-
-static map<string, PassTypeInfo> denoise_passes_map = denoise_passes_init();
-
-static bool split_channel(string full_channel, string &layer, string &pass, string &channel)
-{
-	/* Splits channel name into <layer>.<pass>.<channel> */
-	if(std::count(full_channel.begin(), full_channel.end(), '.') != 2) {
-		return false;
-	}
-
-	int first_dot = full_channel.find(".");
-	int second_dot = full_channel.rfind(".");
-	layer = full_channel.substr(0, first_dot);
-	pass = full_channel.substr(first_dot + 1, second_dot - first_dot - 1);
-	channel = full_channel.substr(second_dot + 1);
-
-	return true;
-}
-
-static int find_channel(string channels, string channel)
-{
-	if(channel.length() != 1) return -1;
-	size_t pos = channels.find(channel);
-	if(pos == string::npos) return -1;
-	return pos;
-}
-
-static RenderBuffers* load_frame(string file, Device *device, RenderBuffers *buffers, int samples)
-{
-	ImageInput *frame = ImageInput::open(file);
-	if(!frame) {
-		printf("ERROR: Frame %s: Couldn't open file!\n", file.c_str());
-		delete buffers;
-		return NULL;
-	}
-
-	const ImageSpec &spec = frame->spec();
-
-	if(buffers) {
-		if(spec.width != buffers->params.width || spec.height != buffers->params.height) {
-			printf("ERROR: Frame %s: Has different size!\n", file.c_str());
-			delete buffers;
-			return NULL;
-		}
-	}
-
-	/* Find a single RenderLayer to load. */
-	string renderlayer = "";
-	string layer, pass, channel;
-	for(int i = 0; i < spec.nchannels; i++) {
-		if(!split_channel(spec.channelnames[i], layer, pass, channel)) continue;
-		if(pass == "Denoising Noisy") {
-			renderlayer = layer;
-			break;
-		}
-	}
-
-	if(renderlayer != "") {
-		/* Find all passes that the frame contains. */
-		int passes = DENOISING_PASS_NONE;
-		map<DenoisingPassType, int> num_channels;
-		map<PassTypeInfo, int3> channel_ids;
-		for(int i = 0; i < spec.nchannels; i++) {
-			if(!split_channel(spec.channelnames[i], layer, pass, channel)) continue;
-			if(layer != renderlayer) {
-				/* The channel belongs to another RenderLayer. */
-				continue;
-			}
-			if(denoise_passes_map.count(pass)) {
-				PassTypeInfo type = denoise_passes_map[pass];
-				assert(type.num_channels <= 3);
-				/* Pass was found, count the channels. */
-				size_t channel_id = find_channel(type.channels, channel);
-				if(channel_id != -1) {
-					/* This channel is part of the pass, so count it. */
-					num_channels[type.type]++;
-					/* Remember which OIIO channel belongs to which pass. */
-					channel_ids[type][channel_id] = i;
-					if(num_channels[type.type] == type.num_channels) {
-						/* We found all the channels of the pass! */
-						passes |= type.type;
-					}
-				}
-			}
-		}
-
-		/* The buffer always needs to include all the required denoising passes. */
-		if((~passes & DENOISING_PASS_REQUIRED) == 0) {
-			printf("Frame %s: Found all needed passes!\n", file.c_str());
-
-			if(buffers == NULL) {
-				BufferParams params;
-				params.width  = params.full_width  = params.final_width  = spec.width;
-				params.height = params.full_height = params.final_height = spec.height;
-				params.full_x = params.full_y = 0;
-				params.denoising_passes = true;
-				params.selective_denoising = (passes & DENOISING_PASS_CLEAN);
-				params.cross_denoising = (passes & DENOISING_PASS_NOISY_B) && (passes & DENOISING_PASS_NOISY_B_VAR);
-
-				buffers = new RenderBuffers(device);
-				buffers->reset(device, params);
-			}
-
-			int4 rect = make_int4(0, 0, buffers->params.width, buffers->params.height);
-			float *pass_data = new float[4*buffers->params.width*buffers->params.height];
-
-			/* Read all the passes from the file. */
-			for(map<PassTypeInfo, int3>::iterator i = channel_ids.begin(); i != channel_ids.end(); i++)
-			{
-				for(int c = 0; c < i->first.num_channels; c++) {
-					int xstride = i->first.num_channels*sizeof(float);
-					int ystride = spec.width * xstride;
-					printf("Reading pass %s!            \r", spec.channelnames[i->second[c]].c_str());
-					fflush(stdout);
-					frame->read_image(i->second[c], i->second[c]+1, TypeDesc::FLOAT, pass_data + c, xstride, ystride);
-				}
-				buffers->get_denoising_rect(i->first.type, 1.0f, samples, i->first.num_channels, rect, pass_data, true);
-			}
-
-			/* Read combined pass. */
-			int read_combined = 0;
-			for(int i = 0; i < spec.nchannels; i++) {
-				if(!split_channel(spec.channelnames[i], layer, pass, channel)) continue;
-				if(layer != renderlayer || pass != "Combined") continue;
-
-				size_t channel_id = find_channel("RGBA", channel);
-				if(channel_id != -1) {
-					int xstride = 4*sizeof(float);
-					int ystride = spec.width * xstride;
-					printf("Reading pass %s!            \n", spec.channelnames[i].c_str());
-					fflush(stdout);
-					frame->read_image(i, i+1, TypeDesc::FLOAT, pass_data + channel_id, xstride, ystride);
-					read_combined++;
-				}
-			}
-			if(read_combined < 4) {
-				printf("ERROR: Frame %s: Missing combined pass!\n", file.c_str());
-				delete buffers;
-				delete[] pass_data;
-				return NULL;
-			}
-
-			buffers->get_pass_rect(PASS_COMBINED, 1.0f, samples, 4, rect, pass_data, true);
-
-			delete[] pass_data;
-		}
-		else {
-			printf("ERROR: Frame %s: Missing some pass!\n", file.c_str());
-			delete buffers;
-			return NULL;
-		}
-	}
-	else {
-		printf("ERROR: Frame %s: Didn't fine a suitable RenderLayer!\n", file.c_str());
-		delete buffers;
-		return NULL;
-	}
-
-	frame->close();
-	ImageInput::destroy(frame);
-
-	return buffers;
-}
-
-bool denoise_standalone(SessionParams &session_params,
-                        string filename)
-{
-	session_params.only_denoise = true;
-	session_params.progressive_refine = false;
-	session_params.progressive = false;
-	session_params.background = true;
-	session_params.tile_order = TILE_BOTTOM_TO_TOP;
-	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list