diff --git a/src/omv/imlib/framebuffer.c b/src/omv/imlib/framebuffer.c index 5a04c2b5d..9be467439 100644 --- a/src/omv/imlib/framebuffer.c +++ b/src/omv/imlib/framebuffer.c @@ -113,15 +113,13 @@ static void initialize_jpeg_buf_from_image(image_t *img) } } -void framebuffer_update_jpeg_buffer(image_t *src) +void framebuffer_update_jpeg_buffer(bool swapfb) { - image_t main_fb_src; static int overflow_count = 0; - if (src == NULL) { - framebuffer_initialize_image(&main_fb_src); - src = &main_fb_src; - } + image_t main_fb_src; + framebuffer_initialize_image(&main_fb_src); + image_t *src = &main_fb_src; if (framebuffer->streaming_enabled && jpeg_framebuffer->enabled) { if (src->bpp > 3) { diff --git a/src/omv/imlib/framebuffer.h b/src/omv/imlib/framebuffer.h index 35cc07e26..663e24e2b 100644 --- a/src/omv/imlib/framebuffer.h +++ b/src/omv/imlib/framebuffer.h @@ -75,7 +75,7 @@ void framebuffer_initialize_image(image_t *img); // Compress src image to the JPEG buffer if src is mutable, otherwise copy src to the JPEG buffer // if the src is JPEG and fits in the JPEG buffer, or encode and stream src image to the IDE if not. // If src == NULL use main framebuffer as source image. -void framebuffer_update_jpeg_buffer(image_t *src); +void framebuffer_update_jpeg_buffer(bool swapfb); // Set the framebuffer w, h and bpp. void framebuffer_set(int32_t w, int32_t h, int32_t bpp); diff --git a/src/omv/modules/py_fir.c b/src/omv/modules/py_fir.c index 947143490..e971d93de 100644 --- a/src/omv/modules/py_fir.c +++ b/src/omv/modules/py_fir.c @@ -1088,7 +1088,7 @@ mp_obj_t py_fir_snapshot(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) } if (copy_to_fb) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); } image_t dst_img; diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index f8720cd45..4993795c9 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -940,7 +940,7 @@ static mp_obj_t py_image_to(int bpp, const uint16_t *default_color_palette, bool } if (copy_to_fb && copy) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); } image_t dst_img; @@ -1205,7 +1205,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_save_obj, 2, py_image_save); static mp_obj_t py_image_flush(mp_obj_t img_obj) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_flush_obj, py_image_flush); @@ -6574,7 +6574,7 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg } if (copy_to_fb) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); } return py_image_from_struct(&image); diff --git a/src/omv/modules/py_imageio.c b/src/omv/modules/py_imageio.c index 299c82243..b2b92f180 100644 --- a/src/omv/modules/py_imageio.c +++ b/src/omv/modules/py_imageio.c @@ -156,7 +156,7 @@ mp_obj_t py_imageio_read(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) } if (copy_to_fb) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); } if (0) { diff --git a/src/omv/ports/nrf/sensor.c b/src/omv/ports/nrf/sensor.c index 485c7f54b..01dd177a5 100644 --- a/src/omv/ports/nrf/sensor.c +++ b/src/omv/ports/nrf/sensor.c @@ -998,7 +998,7 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) // Compress the framebuffer for the IDE preview, only if it's not the first frame, // the framebuffer is enabled and the image sensor does not support JPEG encoding. // Note: This doesn't run unless the IDE is connected and the framebuffer is enabled. - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); noInterrupts(); diff --git a/src/omv/ports/stm32/sensor.c b/src/omv/ports/stm32/sensor.c index 52f557bcf..d7c7b20e1 100644 --- a/src/omv/ports/stm32/sensor.c +++ b/src/omv/ports/stm32/sensor.c @@ -1282,7 +1282,7 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) // Compress the framebuffer for the IDE preview, only if it's not the first frame, // the framebuffer is enabled and the image sensor does not support JPEG encoding. // Note: This doesn't run unless the IDE is connected and the framebuffer is enabled. - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); // Make sure the raw frame fits into the FB. It will be switched from RGB565 to BAYER // first to save space before being cropped until it fits. diff --git a/src/omv/sensors/lepton.c b/src/omv/sensors/lepton.c index 4ddce5d33..61baac338 100644 --- a/src/omv/sensors/lepton.c +++ b/src/omv/sensors/lepton.c @@ -484,7 +484,7 @@ static int sensor_check_buffsize(sensor_t *sensor) static int snapshot(sensor_t *sensor, image_t *image, uint32_t flags) { - framebuffer_update_jpeg_buffer(NULL); + framebuffer_update_jpeg_buffer(false); if (sensor_check_buffsize(sensor) == -1) { return -1;