From bda19449cce6ae028ef751f0f4f21da63214ab3f Mon Sep 17 00:00:00 2001
From: stephen-e <33672591+reticulatedpines@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:32:01 +0100
Subject: [PATCH 1/2] avcodec/mjpegdec: set bayer flag based on pix_fmt
dng_decode_jpeg() does this directly in tiff.c,
this change allows signalling via the pixel format
(to support LJ92 compressed raw video in MLV containers,
which is the next commit).
---
libavcodec/mjpegdec.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
@@ -409,6 +409,15 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
return AVERROR_PATCHWELCOME;
}
+ // If the given pixel format is Bayer, set the flag (this makes LJ92 MLV files work)
+ s->pix_desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
+ if (!s->pix_desc) {
+ av_log(s->avctx, AV_LOG_ERROR, "Could not get a pixel format descriptor.\n");
+ return AVERROR_BUG;
+ }
+ if (s->pix_desc->flags & AV_PIX_FMT_FLAG_BAYER)
+ s->bayer = 1;
+
if (s->bayer) {
if (nb_components == 2) {
/* Bayer images embedded in DNGs can contain 2 interleaved components and the
@@ -718,12 +727,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
- s->pix_desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
- if (!s->pix_desc) {
- av_log(s->avctx, AV_LOG_ERROR, "Could not get a pixel format descriptor.\n");
- return AVERROR_BUG;
- }
-
if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt && !size_change) {
s->avctx->pix_fmt = s->hwaccel_pix_fmt;
} else {
--
2.45.2