Move postprocessor script to a gsetting (MR 18)
This commit is contained in:
@@ -11,5 +11,14 @@
|
|||||||
up after processing.
|
up after processing.
|
||||||
</description>
|
</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="postprocessor" type='s'>
|
||||||
|
<default>''</default>
|
||||||
|
<summary>Path to the postprocessor script</summary>
|
||||||
|
<description>
|
||||||
|
When set this will define the absolute path to a postprocessor to use after
|
||||||
|
taking a picture. When empty megapixels will default to the legacy
|
||||||
|
postprocess.sh lookup
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
@@ -81,8 +81,6 @@ static int preview_height;
|
|||||||
|
|
||||||
static int device_rotation;
|
static int device_rotation;
|
||||||
|
|
||||||
static bool save_dng;
|
|
||||||
|
|
||||||
struct control_state {
|
struct control_state {
|
||||||
bool gain_is_manual;
|
bool gain_is_manual;
|
||||||
int gain;
|
int gain;
|
||||||
@@ -344,7 +342,6 @@ update_process_pipeline()
|
|||||||
.camera = camera,
|
.camera = camera,
|
||||||
.mode = mode,
|
.mode = mode,
|
||||||
.burst_length = burst_length,
|
.burst_length = burst_length,
|
||||||
.save_dng = save_dng,
|
|
||||||
.preview_width = preview_width,
|
.preview_width = preview_width,
|
||||||
.preview_height = preview_height,
|
.preview_height = preview_height,
|
||||||
.device_rotation = device_rotation,
|
.device_rotation = device_rotation,
|
||||||
@@ -691,7 +688,6 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
|||||||
preview_width = state->preview_width;
|
preview_width = state->preview_width;
|
||||||
preview_height = state->preview_height;
|
preview_height = state->preview_height;
|
||||||
device_rotation = state->device_rotation;
|
device_rotation = state->device_rotation;
|
||||||
save_dng = state->save_dng;
|
|
||||||
|
|
||||||
if (camera) {
|
if (camera) {
|
||||||
struct control_state previous_desired = desired_controls;
|
struct control_state previous_desired = desired_controls;
|
||||||
|
@@ -18,7 +18,6 @@ struct mp_io_pipeline_state {
|
|||||||
bool exposure_is_manual;
|
bool exposure_is_manual;
|
||||||
int exposure;
|
int exposure;
|
||||||
|
|
||||||
bool save_dng;
|
|
||||||
bool flash_enabled;
|
bool flash_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
26
src/main.c
26
src/main.c
@@ -55,8 +55,6 @@ static bool has_auto_focus_start;
|
|||||||
|
|
||||||
static bool flash_enabled = false;
|
static bool flash_enabled = false;
|
||||||
|
|
||||||
static bool setting_save_dng;
|
|
||||||
|
|
||||||
static MPProcessPipelineBuffer *current_preview_buffer = NULL;
|
static MPProcessPipelineBuffer *current_preview_buffer = NULL;
|
||||||
static int preview_buffer_width = -1;
|
static int preview_buffer_width = -1;
|
||||||
static int preview_buffer_height = -1;
|
static int preview_buffer_height = -1;
|
||||||
@@ -110,7 +108,6 @@ update_io_pipeline()
|
|||||||
.gain = gain,
|
.gain = gain,
|
||||||
.exposure_is_manual = exposure_is_manual,
|
.exposure_is_manual = exposure_is_manual,
|
||||||
.exposure = exposure,
|
.exposure = exposure,
|
||||||
.save_dng = setting_save_dng,
|
|
||||||
.flash_enabled = flash_enabled,
|
.flash_enabled = flash_enabled,
|
||||||
};
|
};
|
||||||
mp_io_pipeline_update_state(&io_state);
|
mp_io_pipeline_update_state(&io_state);
|
||||||
@@ -701,14 +698,6 @@ static void
|
|||||||
run_close_settings_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
run_close_settings_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||||
{
|
{
|
||||||
gtk_stack_set_visible_child_name(GTK_STACK(main_stack), "main");
|
gtk_stack_set_visible_child_name(GTK_STACK(main_stack), "main");
|
||||||
|
|
||||||
// Update settings
|
|
||||||
bool save_dng = g_settings_get_boolean(settings, "save-raw");
|
|
||||||
|
|
||||||
if (save_dng != setting_save_dng) {
|
|
||||||
setting_save_dng = save_dng;
|
|
||||||
update_io_pipeline();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1061,13 +1050,26 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
|
|
||||||
// Setup settings
|
// Setup settings
|
||||||
settings = g_settings_new("org.postmarketos.Megapixels");
|
settings = g_settings_new("org.postmarketos.Megapixels");
|
||||||
|
char* setting_postproc = g_settings_get_string(settings, "postprocessor");
|
||||||
|
|
||||||
|
// Initialize the postprocessing gsetting to the old processor if
|
||||||
|
// it was not set yet
|
||||||
|
if(setting_postproc == NULL || setting_postproc[0] == '\0') {
|
||||||
|
printf("Initializing postprocessor gsetting\n");
|
||||||
|
setting_postproc = malloc(512);
|
||||||
|
if(!mp_process_find_processor(setting_postproc)) {
|
||||||
|
printf("No processor found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
g_settings_set_string(settings, "postprocessor", setting_postproc);
|
||||||
|
printf("Initialized postprocessor to %s\n", setting_postproc);
|
||||||
|
}
|
||||||
g_settings_bind(settings,
|
g_settings_bind(settings,
|
||||||
"save-raw",
|
"save-raw",
|
||||||
setting_dng_button,
|
setting_dng_button,
|
||||||
"active",
|
"active",
|
||||||
G_SETTINGS_BIND_DEFAULT);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
|
|
||||||
setting_save_dng = g_settings_get_boolean(settings, "save-raw");
|
|
||||||
|
|
||||||
// Listen for phosh rotation
|
// Listen for phosh rotation
|
||||||
GDBusConnection *conn =
|
GDBusConnection *conn =
|
||||||
|
@@ -22,7 +22,6 @@ static const float colormatrix_srgb[] = { 3.2409, -1.5373, -0.4986, -0.9692, 1.8
|
|||||||
static MPPipeline *pipeline;
|
static MPPipeline *pipeline;
|
||||||
|
|
||||||
static char burst_dir[23];
|
static char burst_dir[23];
|
||||||
static char processing_script[512];
|
|
||||||
|
|
||||||
static volatile bool is_capturing = false;
|
static volatile bool is_capturing = false;
|
||||||
static volatile int frames_processed = 0;
|
static volatile int frames_processed = 0;
|
||||||
@@ -53,10 +52,10 @@ static int exposure;
|
|||||||
|
|
||||||
static bool flash_enabled;
|
static bool flash_enabled;
|
||||||
|
|
||||||
static bool save_dng;
|
|
||||||
|
|
||||||
static char capture_fname[255];
|
static char capture_fname[255];
|
||||||
|
|
||||||
|
static GSettings *settings;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
register_custom_tiff_tags(TIFF *tif)
|
register_custom_tiff_tags(TIFF *tif)
|
||||||
{
|
{
|
||||||
@@ -77,8 +76,8 @@ register_custom_tiff_tags(TIFF *tif)
|
|||||||
sizeof(custom_fields) / sizeof(custom_fields[0]));
|
sizeof(custom_fields) / sizeof(custom_fields[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
find_processor(char *script)
|
mp_process_find_processor(char *script)
|
||||||
{
|
{
|
||||||
char filename[] = "postprocess.sh";
|
char filename[] = "postprocess.sh";
|
||||||
|
|
||||||
@@ -118,11 +117,7 @@ static void
|
|||||||
setup(MPPipeline *pipeline, const void *data)
|
setup(MPPipeline *pipeline, const void *data)
|
||||||
{
|
{
|
||||||
TIFFSetTagExtender(register_custom_tiff_tags);
|
TIFFSetTagExtender(register_custom_tiff_tags);
|
||||||
|
settings = g_settings_new("org.postmarketos.Megapixels");
|
||||||
if (!find_processor(processing_script)) {
|
|
||||||
g_printerr("Could not find any post-process script\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -655,6 +650,9 @@ process_capture_burst(GdkTexture *thumb)
|
|||||||
timestamp);
|
timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool save_dng = g_settings_get_boolean(settings, "save-raw");
|
||||||
|
char* postprocessor = g_settings_get_string(settings, "postprocessor");
|
||||||
|
|
||||||
char save_dng_s[2] = "0";
|
char save_dng_s[2] = "0";
|
||||||
if (save_dng) {
|
if (save_dng) {
|
||||||
save_dng_s[0] = '1';
|
save_dng_s[0] = '1';
|
||||||
@@ -668,7 +666,7 @@ process_capture_burst(GdkTexture *thumb)
|
|||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE,
|
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE,
|
||||||
&error,
|
&error,
|
||||||
processing_script,
|
postprocessor,
|
||||||
burst_dir,
|
burst_dir,
|
||||||
capture_fname,
|
capture_fname,
|
||||||
save_dng_s,
|
save_dng_s,
|
||||||
@@ -863,7 +861,6 @@ update_state(MPPipeline *pipeline, const struct mp_process_pipeline_state *state
|
|||||||
device_rotation = state->device_rotation;
|
device_rotation = state->device_rotation;
|
||||||
|
|
||||||
burst_length = state->burst_length;
|
burst_length = state->burst_length;
|
||||||
save_dng = state->save_dng;
|
|
||||||
|
|
||||||
// gain_is_manual = state->gain_is_manual;
|
// gain_is_manual = state->gain_is_manual;
|
||||||
gain = state->gain;
|
gain = state->gain;
|
||||||
|
@@ -27,10 +27,10 @@ struct mp_process_pipeline_state {
|
|||||||
bool has_auto_focus_start;
|
bool has_auto_focus_start;
|
||||||
|
|
||||||
bool flash_enabled;
|
bool flash_enabled;
|
||||||
|
|
||||||
bool save_dng;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool mp_process_find_processor(char *script);
|
||||||
|
|
||||||
void mp_process_pipeline_start();
|
void mp_process_pipeline_start();
|
||||||
void mp_process_pipeline_stop();
|
void mp_process_pipeline_stop();
|
||||||
void mp_process_pipeline_sync();
|
void mp_process_pipeline_sync();
|
||||||
|
Reference in New Issue
Block a user