Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/python.cpp
| Show First 20 Lines • Show All 729 Lines • ▼ Show 20 Lines | static bool image_parse_filepaths(PyObject *pyfilepaths, vector<string> &filepaths) | ||||
| } | } | ||||
| Py_DECREF(sequence); | Py_DECREF(sequence); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *keywords) | static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *keywords) | ||||
| { | { | ||||
| #if 1 | |||||
| (void)args; | |||||
| (void)keywords; | |||||
| #else | |||||
| static const char *keyword_list[] = { | static const char *keyword_list[] = { | ||||
| "preferences", "scene", "view_layer", "input", "output", "tile_size", "samples", NULL}; | "preferences", "scene", "view_layer", "input", "output", NULL}; | ||||
| PyObject *pypreferences, *pyscene, *pyviewlayer; | PyObject *pypreferences, *pyscene, *pyviewlayer; | ||||
| PyObject *pyinput, *pyoutput = NULL; | PyObject *pyinput, *pyoutput = NULL; | ||||
| int tile_size = 0, samples = 0; | |||||
| if (!PyArg_ParseTupleAndKeywords(args, | if (!PyArg_ParseTupleAndKeywords(args, | ||||
| keywords, | keywords, | ||||
| "OOOO|Oii", | "OOOO|O", | ||||
| (char **)keyword_list, | (char **)keyword_list, | ||||
| &pypreferences, | &pypreferences, | ||||
| &pyscene, | &pyscene, | ||||
| &pyviewlayer, | &pyviewlayer, | ||||
| &pyinput, | &pyinput, | ||||
| &pyoutput, | &pyoutput)) { | ||||
| &tile_size, | |||||
| &samples)) { | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Get device specification from preferences and scene. */ | /* Get device specification from preferences and scene. */ | ||||
| PointerRNA preferencesptr; | PointerRNA preferencesptr; | ||||
| RNA_pointer_create( | RNA_pointer_create( | ||||
| NULL, &RNA_Preferences, (void *)PyLong_AsVoidPtr(pypreferences), &preferencesptr); | NULL, &RNA_Preferences, (void *)PyLong_AsVoidPtr(pypreferences), &preferencesptr); | ||||
| BL::Preferences b_preferences(preferencesptr); | BL::Preferences b_preferences(preferencesptr); | ||||
| PointerRNA sceneptr; | PointerRNA sceneptr; | ||||
| RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyscene), &sceneptr); | RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyscene), &sceneptr); | ||||
| BL::Scene b_scene(sceneptr); | BL::Scene b_scene(sceneptr); | ||||
| DeviceInfo device = blender_device_info(b_preferences, b_scene, true); | DeviceInfo device = blender_device_info(b_preferences, b_scene, true); | ||||
| /* Get denoising parameters from view layer. */ | /* Get denoising parameters from view layer. */ | ||||
| PointerRNA viewlayerptr; | PointerRNA viewlayerptr; | ||||
| RNA_pointer_create((ID *)PyLong_AsVoidPtr(pyscene), | RNA_pointer_create((ID *)PyLong_AsVoidPtr(pyscene), | ||||
| &RNA_ViewLayer, | &RNA_ViewLayer, | ||||
| PyLong_AsVoidPtr(pyviewlayer), | PyLong_AsVoidPtr(pyviewlayer), | ||||
| &viewlayerptr); | &viewlayerptr); | ||||
| PointerRNA cviewlayer = RNA_pointer_get(&viewlayerptr, "cycles"); | BL::ViewLayer b_view_layer(viewlayerptr); | ||||
| DenoiseParams params; | DenoiseParams params = BlenderSync::get_denoise_params(b_scene, b_view_layer, true); | ||||
| params.radius = get_int(cviewlayer, "denoising_radius"); | params.use = true; | ||||
| params.strength = get_float(cviewlayer, "denoising_strength"); | |||||
| params.feature_strength = get_float(cviewlayer, "denoising_feature_strength"); | |||||
| params.relative_pca = get_boolean(cviewlayer, "denoising_relative_pca"); | |||||
| params.neighbor_frames = get_int(cviewlayer, "denoising_neighbor_frames"); | |||||
| /* Parse file paths list. */ | /* Parse file paths list. */ | ||||
| vector<string> input, output; | vector<string> input, output; | ||||
| if (!image_parse_filepaths(pyinput, input)) { | if (!image_parse_filepaths(pyinput, input)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Show All 11 Lines | if (input.empty()) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (input.size() != output.size()) { | if (input.size() != output.size()) { | ||||
| PyErr_SetString(PyExc_ValueError, "Number of input and output file paths does not match."); | PyErr_SetString(PyExc_ValueError, "Number of input and output file paths does not match."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Create denoiser. */ | /* Create denoiser. */ | ||||
| DenoiserPipeline denoiser(device); | DenoiserPipeline denoiser(device, params); | ||||
| denoiser.params = params; | |||||
| denoiser.input = input; | denoiser.input = input; | ||||
| denoiser.output = output; | denoiser.output = output; | ||||
| if (tile_size > 0) { | |||||
| denoiser.tile_size = make_int2(tile_size, tile_size); | |||||
| } | |||||
| if (samples > 0) { | |||||
| denoiser.samples_override = samples; | |||||
| } | |||||
| /* Run denoiser. */ | /* Run denoiser. */ | ||||
| if (!denoiser.run()) { | if (!denoiser.run()) { | ||||
| PyErr_SetString(PyExc_ValueError, denoiser.error.c_str()); | PyErr_SetString(PyExc_ValueError, denoiser.error.c_str()); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| #endif | |||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *merge_func(PyObject * /*self*/, PyObject *args, PyObject *keywords) | static PyObject *merge_func(PyObject * /*self*/, PyObject *args, PyObject *keywords) | ||||
| { | { | ||||
| static const char *keyword_list[] = {"input", "output", NULL}; | static const char *keyword_list[] = {"input", "output", NULL}; | ||||
| PyObject *pyinput, *pyoutput = NULL; | PyObject *pyinput, *pyoutput = NULL; | ||||
| ▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines | |||||