diff --git a/src/io_pipeline.c b/src/io_pipeline.c index 618d018..f84e868 100644 --- a/src/io_pipeline.c +++ b/src/io_pipeline.c @@ -18,7 +18,6 @@ mp_state_io state_io; MPCamera *mpcamera = NULL; - static MPPipeline *pipeline; static GSource *capture_source; @@ -403,11 +402,23 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state) mpcamera = mp_camera_new(state_io.camera); state_io.mode_preview = NULL; state_io.mode_capture = NULL; + float score = 0; + int area_preview = + state_io.preview_width * state_io.preview_height; for (int m = 0; m < state_io.camera->num_modes; m++) { + float mscore = 0; if (state_io.camera->modes[m]->rate > 29) { + mscore += 1; + } + int mode_area = state_io.camera->modes[m]->width * + state_io.camera->modes[m]->height; + mscore += 1.0f - + (float)(ABS(mode_area - area_preview) / + area_preview); + if (mscore > score) { state_io.mode_preview = state_io.camera->modes[m]; - break; + score = mscore; } } long area = 0;