Skip to contentSkip to conversation

libv4lconvert: Fix support for compressed bayer formats

PATCH New Ricardo Ribalda Delgado 1 participant 1 message Feb 5, 2019 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libv4lconvert: Fix support for compressed bayer formats

10 bit packet Bayer format broke the support for the other compressed bayer formats.
Due to the fallthrough of the compressed formats, 10b code will be executed for every 10b format.

Fixes c44b30096589 ("libv4l: Add support for BAYER10P format conversion")
---
 lib/libv4lconvert/libv4lconvert.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
lib/libv4lconvert/libv4lconvert.c +18 -8
index b3dbf5a0..718e1d43 100644
@@ -990,12 +990,10 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
 	case V4L2_PIX_FMT_SBGGR10P:
 	case V4L2_PIX_FMT_SGBRG10P:
 	case V4L2_PIX_FMT_SGRBG10P:
-	case V4L2_PIX_FMT_SRGGB10P:
-		if (src_size < ((width * height * 10)/8)) {
-			V4LCONVERT_ERR("short raw bayer10 data frame\n");
-			errno = EPIPE;
-			result = -1;
-		}
+	case V4L2_PIX_FMT_SRGGB10P: {
+
+		int b10format = 1;
+
 		switch (src_pix_fmt) {
 		case V4L2_PIX_FMT_SBGGR10P:
 			src_pix_fmt = V4L2_PIX_FMT_SBGGR8;
@@ -1009,10 +1007,22 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
 		case V4L2_PIX_FMT_SRGGB10P:
 			src_pix_fmt = V4L2_PIX_FMT_SRGGB8;
 			break;
+		default:
+			b10format = 0;
 		}
-		v4lconvert_bayer10p_to_bayer8(src, src, width, height);
-		bytesperline = width;
 
+		if (b10format) {
+			if (src_size < ((width * height * 10)/8)) {
+				V4LCONVERT_ERR
+					("short raw bayer10 data frame\n");
+				errno = EPIPE;
+				result = -1;
+				break;
+			}
+			v4lconvert_bayer10p_to_bayer8(src, src, width, height);
+			bytesperline = width;
+		}
+	}
 	/* Fall-through*/
 	case V4L2_PIX_FMT_SBGGR8:
 	case V4L2_PIX_FMT_SGBRG8:
Signature · 1 line
2.20.1