Re-enable zbar, don't crash application if using an unsupported pixel format for preview for zbar
This commit is contained in:
@@ -183,24 +183,25 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
|
||||
libmegapixels_mode_width_to_bytes(image->format, image->width);
|
||||
int padding_bytes =
|
||||
libmegapixels_mode_width_to_padding(image->format, image->width);
|
||||
uint32_t pixel_format = libmegapixels_format_to_v4l_pixfmt(image->format);
|
||||
size_t i = 0, padding_offset = 0;
|
||||
size_t offset;
|
||||
/* TODO: implement
|
||||
switch (image->pixel_format) {
|
||||
case MP_PIXEL_FMT_BGGR8:
|
||||
case MP_PIXEL_FMT_GBRG8:
|
||||
case MP_PIXEL_FMT_GRBG8:
|
||||
case MP_PIXEL_FMT_RGGB8:
|
||||
|
||||
switch (pixel_format) {
|
||||
case V4L2_PIX_FMT_SBGGR8:
|
||||
case V4L2_PIX_FMT_SGBRG8:
|
||||
case V4L2_PIX_FMT_SGRBG8:
|
||||
case V4L2_PIX_FMT_SRGGB8:
|
||||
for (int y = 0; y < image->height; y += 2) {
|
||||
for (int x = 0; x < row_length; x += 2) {
|
||||
data[i++] = image->data[x + row_length * y];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MP_PIXEL_FMT_BGGR10P:
|
||||
case MP_PIXEL_FMT_GBRG10P:
|
||||
case MP_PIXEL_FMT_GRBG10P:
|
||||
case MP_PIXEL_FMT_RGGB10P:
|
||||
case V4L2_PIX_FMT_SBGGR10P:
|
||||
case V4L2_PIX_FMT_SGBRG10P:
|
||||
case V4L2_PIX_FMT_SGRBG10P:
|
||||
case V4L2_PIX_FMT_SRGGB10P:
|
||||
// Skip 5th byte of each 4-pixel segment by incrementing an
|
||||
// offset every time a 5th byte is reached, making the
|
||||
// X coordinate land on the next byte:
|
||||
@@ -225,7 +226,8 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
printf("Preview pixel format not supported - zbar won't work\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create image for zbar
|
||||
@@ -261,7 +263,6 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
|
||||
mp_zbar_image_unref(image);
|
||||
|
||||
++frames_processed;
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user