raspicam: Fix for Luma mode double sized files in timelapse
authorJames Hughes <james.hughes@raspberrypi.org>
Tue, 17 Jan 2017 10:33:40 +0000 (10:33 +0000)
committerpopcornmix <popcornmix@gmail.com>
Tue, 24 Jan 2017 22:23:22 +0000 (22:23 +0000)
Implemented a fix provided by 6x9, ensures that zero or small
camera callback buffer lengths are handled correctly

Fix for issue 365

host_applications/linux/apps/raspicam/RaspiStillYUV.c
host_applications/linux/apps/raspicam/RaspiVidYUV.c

index 5f88e87475ce0a369b14fac6f65ee0d35ece3c80..d95bafc949d2f54278171f906e8cf08ddb8b2b9b 100644 (file)
@@ -57,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <unistd.h>
 #include <errno.h>
 
-#define VERSION_STRING "v1.3.5"
+#define VERSION_STRING "v1.3.6"
 
 #include "bcm_host.h"
 #include "interface/vcos/vcos.h"
@@ -579,7 +579,7 @@ static void camera_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buff
       int bytes_to_write = buffer->length;
 
       if (pData->pstate->onlyLuma)
-         bytes_to_write = port->format->es->video.width * port->format->es->video.height;
+         bytes_to_write = vcos_min(buffer->length, port->format->es->video.width * port->format->es->video.height);
 
       if (bytes_to_write && pData->file_handle)
       {
index 7838f1235df25464358fce308893ec220a9db664..af9c4320dc73e9081b4f98a58a83d7b2eb28db75 100644 (file)
@@ -58,7 +58,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <memory.h>
 #include <sysexits.h>
 
-#define VERSION_STRING "v1.3.12"
+#define VERSION_STRING "v1.3.13"
 
 #include "bcm_host.h"
 #include "interface/vcos/vcos.h"
@@ -706,9 +706,8 @@ static void camera_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buff
       int bytes_written = 0;
       int bytes_to_write = buffer->length;
 
-      if (buffer->length && pData->pstate->onlyLuma)
-         bytes_to_write = port->format->es->video.width * port->format->es->video.height;
-
+      if (pData->pstate->onlyLuma)
+         bytes_to_write = vcos_min(buffer->length, port->format->es->video.width * port->format->es->video.height);
 
       vcos_assert(pData->file_handle);