diff mbox series

[FFmpeg-devel] Add support for LJ92 compressed MLV files, attempt 02

Message ID CAB+1MHrHm1gS-OC=LzuyAOTQR-k0FjJfi9WyxY4XY2ZPYAaxkQ@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] Add support for LJ92 compressed MLV files, attempt 02 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

South East Oct. 24, 2024, 5:59 p.m. UTC
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.

Sample LJ92 MLV file:
https://0x0.st/XlFm.mlv

FATE tests pass locally.  It was not obvious from the Developer guide how
to get this working.  The claim is "Running ’make fate’ accomplishes
[running local FATE tests]", but this of course does not work until
you rsync the samples, build FATE etc, which is not mentioned:
https://www.ffmpeg.org/developer.html#Regression-tests-1

I suggest adding something like "but WILL NOT work until it is configured",
before "please see fate.html for details".  This would make it clearer
that you NEED to follow the link, rather than it existing as reference
material should you want it in the future.  Simply running "make fate"
fails, but in a way that looked like a normal test failure to me;
I assumed upstream was broken since the failure was repeatable and
occured without my changes.

There is a long comment in patch 0001 that I don't expect to survive review,
but provides context for the code change.  As an ffmpeg noob I can't
make a good judgement on what level of commenting is appropriate.

For reference, attempt 1 can be seen in the archives, here:
https://ffmpeg.org//pipermail/ffmpeg-devel/2024-October/335245.html
diff mbox series

Patch

From db0f076e8f724deee604af7a1a85c1d130f1f87d Mon Sep 17 00:00:00 2001
From: stephen-e <33672591+reticulatedpines@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