@@ -569,25 +569,28 @@ bool _capture_is_buffer_valid(const us_capture_s *cap, const struct v4l2_buffer
569
569
if (us_is_jpeg (cap -> run -> format )) {
570
570
if (buf -> bytesused < 125 ) {
571
571
// https://stackoverflow.com/questions/2253404/what-is-the-smallest-valid-jpeg-file-size-in-bytes
572
- _LOG_DEBUG ("Discarding invalid frame, too small to be a valid JPEG: bytesused=%u" , buf -> bytesused );
572
+ _LOG_DEBUG ("Discarding invalid frame, too small to be a valid JPEG: bytesused=%u" ,
573
+ buf -> bytesused );
573
574
return false;
574
575
}
575
576
576
577
const u16 begin_marker = (((u16 )(data [0 ]) << 8 ) | data [1 ]);
577
578
if (begin_marker != 0xFFD8 ) {
578
- _LOG_DEBUG ("Discarding JPEG frame with invalid header: begin_marker=0x%04x, bytesused=%u" , begin_marker , buf -> bytesused );
579
+ _LOG_DEBUG ("Discarding JPEG frame with invalid header: begin_marker=0x%04x, bytesused=%u" ,
580
+ begin_marker , buf -> bytesused );
579
581
return false;
580
582
}
581
583
582
- const u8 * const end_ptr = data + buf -> bytesused ;
583
- const u8 * const eoi_ptr = end_ptr - 2 ;
584
- const u16 eoi_marker = (((u16 )(eoi_ptr [0 ]) << 8 ) | eoi_ptr [1 ]);
585
- if (eoi_marker != 0xFFD9 && eoi_marker != 0xD900 && eoi_marker != 0x0000 ) {
584
+ const u8 * const end_ptr = data + buf -> bytesused - 2 ;
585
+ const u16 end_marker = (((u16 )(end_ptr [0 ]) << 8 ) | end_ptr [1 ]);
586
+ if (end_marker != 0xFFD9 && end_marker != 0xD900 && end_marker != 0x0000 ) {
586
587
if (!cap -> allow_truncated_frames ) {
587
- _LOG_DEBUG ("Discarding truncated JPEG frame: eoi_marker=0x%04x, bytesused=%u" , eoi_marker , buf -> bytesused );
588
+ _LOG_DEBUG ("Discarding truncated JPEG frame: end_marker=0x%04x, bytesused=%u" ,
589
+ end_marker , buf -> bytesused );
588
590
return false;
589
591
}
590
- _LOG_DEBUG ("Got truncated JPEG frame: eoi_marker=0x%04x, bytesused=%u" , eoi_marker , buf -> bytesused );
592
+ _LOG_DEBUG ("Got truncated JPEG frame: end_marker=0x%04x, bytesused=%u" ,
593
+ end_marker , buf -> bytesused );
591
594
}
592
595
}
593
596
0 commit comments