Message ID | 1396876573-15811-7-git-send-email-j.anaszewski@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Jacek, On 7 April 2014 18:46, Jacek Anaszewski <j.anaszewski@samsung.com> wrote: > Prevent decompression of a JPEG 4:2:0 with odd width to > the YUV 4:2:0 compliant formats for Exynos4x12 SoCs and > adjust capture format to RGB565 in such a case. This is > required because the configuration would produce a raw > image with broken luma component. > > Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> > --- <snip> > + if (ctx->subsampling == V4L2_JPEG_CHROMA_SUBSAMPLING_420 && > + (ctx->out_q.w & 1) && > + (pix->pixelformat == V4L2_PIX_FMT_NV12 || > + pix->pixelformat == V4L2_PIX_FMT_NV21 || > + pix->pixelformat == V4L2_PIX_FMT_YUV420)) { > + pix->pixelformat = V4L2_PIX_FMT_RGB565; > + fmt = s5p_jpeg_find_format(ctx, pix->pixelformat, > + FMT_TYPE_CAPTURE); > + v4l2_info(&ctx->jpeg->v4l2_dev, > + "Adjusted capture fourcc to RGB565. Decompression\n" > + "of a JPEG file with 4:2:0 subsampling and odd\n" > + "width to the YUV 4:2:0 compliant formats produces\n" > + "a raw image with broken luma component.\n"); This could be made a comment in the code rather than a info message.
On 04/08/2014 09:49 AM, Sachin Kamat wrote: > Hi Jacek, > > On 7 April 2014 18:46, Jacek Anaszewski <j.anaszewski@samsung.com> wrote: >> Prevent decompression of a JPEG 4:2:0 with odd width to >> the YUV 4:2:0 compliant formats for Exynos4x12 SoCs and >> adjust capture format to RGB565 in such a case. This is >> required because the configuration would produce a raw >> image with broken luma component. >> >> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> >> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> >> --- > <snip> > >> + if (ctx->subsampling == V4L2_JPEG_CHROMA_SUBSAMPLING_420 && >> + (ctx->out_q.w & 1) && >> + (pix->pixelformat == V4L2_PIX_FMT_NV12 || >> + pix->pixelformat == V4L2_PIX_FMT_NV21 || >> + pix->pixelformat == V4L2_PIX_FMT_YUV420)) { >> + pix->pixelformat = V4L2_PIX_FMT_RGB565; >> + fmt = s5p_jpeg_find_format(ctx, pix->pixelformat, >> + FMT_TYPE_CAPTURE); >> + v4l2_info(&ctx->jpeg->v4l2_dev, >> + "Adjusted capture fourcc to RGB565. Decompression\n" >> + "of a JPEG file with 4:2:0 subsampling and odd\n" >> + "width to the YUV 4:2:0 compliant formats produces\n" >> + "a raw image with broken luma component.\n"); > > This could be made a comment in the code rather than a info message. > Hello Sachin, Thanks for the review. I put it into info message because this is rather hard for the user to figure out why the adjustment occurred, bearing in mind that JPEG with the same subsampling and even width is decompressed properly. This is not a common adjustment like alignment, and thus in my opinion it requires displaying the information. Are there some rules that say what cases are relevant for using the v4l2_info macro? Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Jacek, On 9 April 2014 13:01, Jacek Anaszewski <j.anaszewski@samsung.com> wrote: > On 04/08/2014 09:49 AM, Sachin Kamat wrote: >> > Hello Sachin, > > Thanks for the review. I put it into info message because this is > rather hard for the user to figure out why the adjustment occurred, > bearing in mind that JPEG with the same subsampling and even width > is decompressed properly. This is not a common adjustment like > alignment, and thus in my opinion it requires displaying the > information. Are there some rules that say what cases are relevant > for using the v4l2_info macro? Not really, but generally info messages are concise and detailed explanations provided as part of comments.
On 04/09/2014 09:56 AM, Sachin Kamat wrote: > Hi Jacek, > > On 9 April 2014 13:01, Jacek Anaszewski <j.anaszewski@samsung.com> wrote: >> On 04/08/2014 09:49 AM, Sachin Kamat wrote: >>> > >> Hello Sachin, >> >> Thanks for the review. I put it into info message because this is >> rather hard for the user to figure out why the adjustment occurred, >> bearing in mind that JPEG with the same subsampling and even width >> is decompressed properly. This is not a common adjustment like >> alignment, and thus in my opinion it requires displaying the >> information. Are there some rules that say what cases are relevant >> for using the v4l2_info macro? > > Not really, but generally info messages are concise and detailed explanations > provided as part of comments. > Thanks for the explanation, I will stick to it. Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index d266e78..9228bcb 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1064,15 +1064,17 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; } + if ((ctx->jpeg->variant->version != SJPEG_EXYNOS4) || + (ctx->mode != S5P_JPEG_DECODE)) + goto exit; + /* * The exynos4x12 device requires resulting YUV image * subsampling not to be lower than the input jpeg subsampling. * If this requirement is not met then downgrade the requested * capture format to the one with subsampling equal to the input jpeg. */ - if ((ctx->jpeg->variant->version == SJPEG_EXYNOS4) && - (ctx->mode == S5P_JPEG_DECODE) && - (fmt->flags & SJPEG_FMT_NON_RGB) && + if ((fmt->flags & SJPEG_FMT_NON_RGB) && (fmt->subsampling < ctx->subsampling)) { ret = s5p_jpeg_adjust_fourcc_to_subsampling(ctx->subsampling, fmt->fourcc, @@ -1085,6 +1087,22 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, FMT_TYPE_CAPTURE); } + if (ctx->subsampling == V4L2_JPEG_CHROMA_SUBSAMPLING_420 && + (ctx->out_q.w & 1) && + (pix->pixelformat == V4L2_PIX_FMT_NV12 || + pix->pixelformat == V4L2_PIX_FMT_NV21 || + pix->pixelformat == V4L2_PIX_FMT_YUV420)) { + pix->pixelformat = V4L2_PIX_FMT_RGB565; + fmt = s5p_jpeg_find_format(ctx, pix->pixelformat, + FMT_TYPE_CAPTURE); + v4l2_info(&ctx->jpeg->v4l2_dev, + "Adjusted capture fourcc to RGB565. Decompression\n" + "of a JPEG file with 4:2:0 subsampling and odd\n" + "width to the YUV 4:2:0 compliant formats produces\n" + "a raw image with broken luma component.\n"); + } + +exit: return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_CAPTURE); }