From: Thierry Escande <thierry.escande@collabora.com>
To: Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 5/8] [media] s5p-jpeg: Split s5p_jpeg_parse_hdr()
Date: Tue, 27 Jun 2017 18:08:51 +0200 [thread overview]
Message-ID: <1498579734-1594-6-git-send-email-thierry.escande@collabora.com> (raw)
In-Reply-To: <1498579734-1594-1-git-send-email-thierry.escande@collabora.com>
This patch moves the subsampling value decoding read from the jpeg
header into its own function. This new function is called
s5p_jpeg_subsampling_decode() and returns true if it successfully
decodes the subsampling value, false otherwise.
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
drivers/media/platform/s5p-jpeg/jpeg-core.c | 42 ++++++++++++++++-------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 1769744..0783809 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1096,6 +1096,29 @@ static void skip(struct s5p_jpeg_buffer *buf, long len)
get_byte(buf);
}
+static bool s5p_jpeg_subsampling_decode(struct s5p_jpeg_ctx *ctx,
+ unsigned int subsampling)
+{
+ switch (subsampling) {
+ case 0x11:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444;
+ break;
+ case 0x21:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422;
+ break;
+ case 0x22:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
+ break;
+ case 0x33:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
unsigned long buffer, unsigned long size,
struct s5p_jpeg_ctx *ctx)
@@ -1207,26 +1230,9 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
}
}
- if (notfound || !sos)
+ if (notfound || !sos || !s5p_jpeg_subsampling_decode(ctx, subsampling))
return false;
- switch (subsampling) {
- case 0x11:
- ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444;
- break;
- case 0x21:
- ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422;
- break;
- case 0x22:
- ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
- break;
- case 0x33:
- ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
- break;
- default:
- return false;
- }
-
result->w = width;
result->h = height;
result->sos = sos;
--
2.7.4
next prev parent reply other threads:[~2017-06-27 16:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170627160906epcas4p369a67fdb1b8f6898a1f1b4ddb7927995@epcas4p3.samsung.com>
2017-06-27 16:08 ` [PATCH v3 0/8] [media] s5p-jpeg: Various fixes and improvements Thierry Escande
2017-06-27 16:08 ` [PATCH v3 1/8] [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf Thierry Escande
2017-06-29 12:03 ` Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 2/8] [media] s5p-jpeg: Correct WARN_ON statement for checking subsampling Thierry Escande
2017-06-29 12:03 ` Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 3/8] [media] s5p-jpeg: Handle parsing error in s5p_jpeg_parse_hdr() Thierry Escande
2017-06-29 12:04 ` Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 4/8] [media] s5p-jpeg: Don't use temporary structure in s5p_jpeg_buf_queue Thierry Escande
2017-06-29 12:04 ` Andrzej Pietrasiewicz
2017-06-29 20:12 ` Jacek Anaszewski
2017-06-27 16:08 ` Thierry Escande [this message]
2017-06-29 12:04 ` [PATCH v3 5/8] [media] s5p-jpeg: Split s5p_jpeg_parse_hdr() Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 6/8] [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format Thierry Escande
2017-06-29 12:04 ` Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 7/8] [media] s5p-jpeg: Add support for resolution change event Thierry Escande
2017-06-29 12:04 ` Andrzej Pietrasiewicz
2017-06-27 16:08 ` [PATCH v3 8/8] [media] s5p-jpeg: Add stream error handling for Exynos5420 Thierry Escande
2017-06-29 12:05 ` Andrzej Pietrasiewicz
2017-06-29 12:02 ` [PATCH v3 0/8] [media] s5p-jpeg: Various fixes and improvements Andrzej Pietrasiewicz
2017-06-29 20:13 ` Jacek Anaszewski
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=1498579734-1594-6-git-send-email-thierry.escande@collabora.com \
--to=thierry.escande@collabora.com \
--cc=andrzej.p@samsung.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@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).