@@ -77,7 +77,8 @@ local GUI = {
77
77
metadata_box = {},
78
78
edit_executables_button = {},
79
79
executable_path_widget = {},
80
- quality_widget = {}
80
+ quality_widget = {},
81
+ gainmap_downsampling_widget = {},
81
82
},
82
83
options = {},
83
84
run = {}
@@ -145,6 +146,7 @@ local function save_preferences()
145
146
dt .preferences .write (namespace , " hdr_capacity_max" , " float" , GUI .optionwidgets .hdr_capacity_max .value )
146
147
end
147
148
dt .preferences .write (namespace , " quality" , " integer" , GUI .optionwidgets .quality_widget .value )
149
+ dt .preferences .write (namespace , " gainmap_downsampling" , " integer" , GUI .optionwidgets .gainmap_downsampling_widget .value )
148
150
end
149
151
150
152
local function default_to (value , default )
@@ -177,6 +179,7 @@ local function load_preferences()
177
179
GUI .optionwidgets .hdr_capacity_max .value = default_to (dt .preferences .read (namespace , " hdr_capacity_max" , " float" ),
178
180
6.0 )
179
181
GUI .optionwidgets .quality_widget .value = default_to (dt .preferences .read (namespace , " quality" , " integer" ), 95 )
182
+ GUI .optionwidgets .gainmap_downsampling_widget .value = default_to (dt .preferences .read (namespace , " gainmap_downsampling" , " integer" ), 0 )
180
183
end
181
184
182
185
-- Changes the combobox selection blindly until a paired config value is set.
@@ -221,6 +224,7 @@ local function assert_settings_correct(encoding_variant)
221
224
hdr_capacity_max = GUI .optionwidgets .hdr_capacity_max .value
222
225
},
223
226
quality = GUI .optionwidgets .quality_widget .value ,
227
+ downsample = 2 ^ GUI .optionwidgets .gainmap_downsampling_widget .value ,
224
228
tmpdir = dt .configuration .tmp_dir ,
225
229
skip_cleanup = false -- keep temporary files around, for debugging.
226
230
}
@@ -531,7 +535,7 @@ local function generate_ultrahdr(encoding_variant, images, settings, step, total
531
535
cmd = settings .bin .ultrahdr_app .. " -m 0 -y " .. df .sanitize_filename (sdr_raw ) .. " -p " ..
532
536
df .sanitize_filename (hdr_raw ) ..
533
537
string.format (" -a 0 -b 3 -c 1 -C 1 -t 2 -M 0 -s 1 -q %d -Q %d -D 1 " , settings .quality ,
534
- settings .quality ) .. " -w " .. tostring (sdr_w - sdr_w % 2 ) .. " -h " .. tostring (sdr_h - sdr_h % 2 ) ..
538
+ settings .quality ) .. string.format ( " -s %d " , settings . downsample ) .. " -w " .. tostring (sdr_w - sdr_w % 2 ) .. " -h " .. tostring (sdr_h - sdr_h % 2 ) ..
535
539
" -z " .. df .sanitize_filename (uhdr )
536
540
if not execute_cmd (cmd , string.format (_ (" Error merging %s" ), uhdr )) then
537
541
return cleanup (), errors
@@ -742,8 +746,10 @@ You can force the image into a specific stack slot by attaching "hdr" / "gainmap
742
746
GUI .run .sensitive = self .selected and self .selected > 0
743
747
if self .selected == ENCODING_VARIANT_SDR_AND_GAINMAP or self .selected == ENCODING_VARIANT_SDR_AUTO_GAINMAP then
744
748
GUI .optionwidgets .metadata_box .visible = true
749
+ GUI .optionwidgets .gainmap_downsampling_widget .visible = false
745
750
else
746
751
GUI .optionwidgets .metadata_box .visible = false
752
+ GUI .optionwidgets .gainmap_downsampling_widget .visible = true
747
753
end
748
754
end ,
749
755
_ (" SDR + gain map" ), -- ENCODING_VARIANT_SDR_AND_GAINMAP
@@ -781,11 +787,26 @@ GUI.optionwidgets.quality_widget = dt.new_widget("slider") {
781
787
end
782
788
}
783
789
790
+ GUI .optionwidgets .gainmap_downsampling_widget = dt .new_widget (" slider" ) {
791
+ label = _ (' gain map downsampling steps' ),
792
+ tooltip = _ (' Exponent (2^x) of the gain map downsampling factor.\n Downsampling reduces the file size, at the expense of quality.\n\n 0 = don\' t downsample the gain map, 7 = maximum downsampling (128x)' ),
793
+ hard_min = 0 ,
794
+ hard_max = 7 ,
795
+ soft_min = 0 ,
796
+ soft_max = 7 ,
797
+ step = 1 ,
798
+ digits = 0 ,
799
+ reset_callback = function (self )
800
+ self .value = 0
801
+ end
802
+ }
803
+
784
804
GUI .optionwidgets .encoding_settings_box = dt .new_widget (" box" ) {
785
805
orientation = " vertical" ,
786
806
GUI .optionwidgets .selection_type_combo ,
787
807
GUI .optionwidgets .encoding_variant_combo ,
788
808
GUI .optionwidgets .quality_widget ,
809
+ GUI .optionwidgets .gainmap_downsampling_widget ,
789
810
GUI .optionwidgets .metadata_box
790
811
}
791
812
0 commit comments