From 6d5cbe258365b53785c0ee3c45a97e7c0026632a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 22 Mar 2021 11:02:32 -0400 Subject: [PATCH] Make incorrect dimensions non-fatal if the monitor dimensions are larger than what is expected, so at least there is enough ram to store the image --- src/zm_local_camera.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index b5c0ab665..b464c4d96 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -798,10 +798,10 @@ void LocalCamera::Initialise() { ); if ( v4l2_data.fmt.fmt.pix.width != width ) { - Warning("Failed to set requested width"); + Warning("Failed to set requested width"); } if ( v4l2_data.fmt.fmt.pix.height != height ) { - Warning("Failed to set requested height"); + Warning("Failed to set requested height"); } /* Buggy driver paranoia. */ @@ -2087,8 +2087,11 @@ int LocalCamera::Capture(ZMPacket &zm_packet) { buffer_bytesused = v4l2_data.bufptr->bytesused; bytes += buffer_bytesused; - if ( (v4l2_data.fmt.fmt.pix.width * v4l2_data.fmt.fmt.pix.height) != (width * height) ) { - Fatal("Captured image dimensions differ: V4L2: %dx%d monitor: %dx%d", + if ( (v4l2_data.fmt.fmt.pix.width * v4l2_data.fmt.fmt.pix.height) > (width * height) ) { + Fatal("Captured image dimensions larger than image buffer: V4L2: %dx%d monitor: %dx%d", + v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height, width, height); + } else if ( (v4l2_data.fmt.fmt.pix.width * v4l2_data.fmt.fmt.pix.height) != (width * height) ) { + Error("Captured image dimensions differ: V4L2: %dx%d monitor: %dx%d", v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height, width, height); } } // end if v4l2