linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Ribalda Delgado <ricardo@ribalda.com>
To: Hans de Goede <hdegoede@redhat.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Gregor Jasny <gjasny@googlemail.com>,
	linux-media@vger.kernel.org, daniel@qtec.com
Cc: Ricardo Ribalda Delgado <ricardo@ribalda.com>
Subject: [PATCH] libv4lconvert: Fix support for compressed bayer formats
Date: Tue,  5 Feb 2019 18:06:44 +0100	[thread overview]
Message-ID: <20190205170644.29751-1-ricardo@ribalda.com> (raw)

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")
Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>
---
 lib/libv4lconvert/libv4lconvert.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
index b3dbf5a0..718e1d43 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -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:
-- 
2.20.1


                 reply	other threads:[~2019-02-05 17:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190205170644.29751-1-ricardo@ribalda.com \
    --to=ricardo@ribalda.com \
    --cc=daniel@qtec.com \
    --cc=gjasny@googlemail.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).