ffmpeg has existing support for MLV raw video files; libavformat/mlvdec.c. Since this was added, MLV has been extended to support LJ92 compressed image data. These patches build on lossless DNG support in 7.2-dev to enable handling LJ92 MLV via existing libavcodec/mjpegdec.c code.
I can provide MLV sample files if desired, being raw video these tend to be large. Thanks to JEEB and Lynne for help via IRC.
From 94ce8688af3a2c748de4021687b5d45a0a6b7be2 Mon Sep 17 00:00:00 2001 From: stephen-e <33672591+reticulatedpi...@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:35:49 +0100 Subject: [PATCH 2/2] avformat/mlvdec: add LJ92 support MLV files can contain LJ92 compressed raw video data. MJPEG codec can be used to handle these. --- libavformat/mlvdec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c index 1a6d38f37c..2eb21a3aab 100644 --- a/libavformat/mlvdec.c +++ b/libavformat/mlvdec.c @@ -44,8 +44,9 @@ #define MLV_AUDIO_CLASS_WAV 1 -#define MLV_CLASS_FLAG_DELTA 0x40 #define MLV_CLASS_FLAG_LZMA 0x80 +#define MLV_CLASS_FLAG_DELTA 0x40 +#define MLV_CLASS_FLAG_LJ92 0x20 typedef struct { AVIOContext *pb[101]; @@ -298,9 +299,12 @@ static int read_header(AVFormatContext *avctx) if ((mlv->class[0] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA))) avpriv_request_sample(avctx, "compression"); vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; - switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)) { + switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA|MLV_CLASS_FLAG_LJ92)) { case MLV_VIDEO_CLASS_RAW: - vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + if (mlv->class[0] & MLV_CLASS_FLAG_LJ92) + vst->codecpar->codec_id = AV_CODEC_ID_MJPEG; + else + vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; break; case MLV_VIDEO_CLASS_YUV: vst->codecpar->format = AV_PIX_FMT_YUV420P; -- 2.45.2
From bda19449cce6ae028ef751f0f4f21da63214ab3f Mon Sep 17 00:00:00 2001 From: stephen-e <33672591+reticulatedpi...@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(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 86ec58713c..9c990f3e03 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -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
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".