PR #25686 opened by dukesook
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25686
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25686.patch

# Summary of changes

This PR adds support to read and uncompressed RGB-24 MP4 file as defined in 
[ISO/IEC 23001-17:2024](https://www.iso.org/standard/82528.html)

### fate-sample
```
fate-suite/mov/uncv-rgb24.mp4
```

Test File on Google Drive: 
[uncv-rgb24.mp4](https://drive.google.com/file/d/1sO6a5YWkLCxhcZeoUwYzJ3jKFiyVvUpa/view?usp=drive_link)
<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg

-->



>From 867907ed3f26420c2187661b25bdd825f32ed091 Mon Sep 17 00:00:00 2001
From: Devon Sookhoo <[email protected]>
Date: Mon, 2 Nov 2026 10:14:57 -0700
Subject: [PATCH] Read ISO/IEC 23001-17:2024 - Uncompressed ISOBMFF RGB-24

---
 libavcodec/rawdec.c           |  3 +-
 libavformat/demux.c           |  2 ++
 libavformat/isom_tags.c       |  1 +
 libavformat/mov.c             | 41 ++++++++++++++++++++++
 tests/fate/mov.mak            |  3 ++
 tests/ref/fate/mov-uncv-rgb24 | 65 +++++++++++++++++++++++++++++++++++
 6 files changed, 114 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/mov-uncv-rgb24

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 53d1fba5839..29e3606ea5d 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -81,7 +81,8 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
         avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
                                       avctx->bits_per_coded_sample);
-    else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != 
MKTAG('B','I','T', 0))
+    else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != 
MKTAG('B','I','T', 0) &&
+             avctx->codec_tag != MKTAG('u','n','c','v'))
         avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, 
avctx->codec_tag);
     else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
         avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 359ae2612bc..5b77099e614 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2652,6 +2652,8 @@ static int parameters_from_context(AVFormatContext *ic, 
AVCodecParameters *par,
         par->color_space = par_tmp->color_space;
     if (par_tmp->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
         par->chroma_location = par_tmp->chroma_location;
+    if (par_tmp->format != AV_PIX_FMT_NONE && par->codec_type == 
AVMEDIA_TYPE_VIDEO)
+        par->format = par_tmp->format;
 
     /* A failed avcodec_open2() zeroes ch_layout through
      * ff_codec_close() -> av_opt_free(); do not copy that empty layout
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index 06166c0fa88..9aed152606c 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -54,6 +54,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_RAWVIDEO, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 
8 Bit */
     { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '2', '0') }, /* Radius DV YUV PAL 
*/
     { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '1', '1') }, /* Radius DV YUV NTSC 
*/
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('u', 'n', 'c', 'v') }, /* ISO/IEC 23001-17 - 
The official ISO-BMFF carriage of uncompressed video and images */
 
     { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'k') }, /* uncompressed 10-bit 
RGB */
     { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'g') }, /* uncompressed 10-bit 
RGB */
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 786994699e7..95f7b4f54df 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10293,6 +10293,46 @@ static int mov_read_mhac(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
     return ret;
 }
 
+static int mov_read_uncc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+    AVStream *st;
+    int version;
+    uint32_t profile;
+
+    if (c->fc->nb_streams < 1)
+        return 0;
+    st = c->fc->streams[c->fc->nb_streams - 1];
+
+    if (atom.size < 8)
+        return AVERROR_INVALIDDATA;
+
+    version = avio_r8(pb);
+    avio_rb24(pb); /* flags */
+    profile = avio_rl32(pb);
+
+    if (version == 1) {
+        switch (profile) {
+            case MKTAG('r','g','b','3'):
+                st->codecpar->format = AV_PIX_FMT_RGB24;
+                break;
+            case MKTAG('r','g','b','a'):
+                st->codecpar->format = AV_PIX_FMT_RGBA;
+                break;
+            default:
+                av_log(c->fc, AV_LOG_WARNING, "Unknown uncC profile: %s\n", 
av_fourcc2str(profile));
+                break;
+        }
+    } else if (version == 0) {
+        av_log(c->fc, AV_LOG_WARNING, "TODO: uncC version 0 not yet 
implemented\n");
+        return AVERROR_PATCHWELCOME;
+    } else {
+        av_log(c->fc, AV_LOG_WARNING, "Unknown uncC version %d\n", version);
+        return AVERROR_INVALIDDATA;
+    }
+
+    return 0;
+}
+
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('A','C','L','R'), mov_read_aclr },
 { MKTAG('A','P','R','G'), mov_read_avid },
@@ -10329,6 +10369,7 @@ static const MOVParseTableEntry 
mov_default_parse_table[] = {
 { MKTAG('S','M','I',' '), mov_read_svq3 },
 { MKTAG('a','l','a','c'), mov_read_alac }, /* alac specific atom */
 { MKTAG('a','v','c','C'), mov_read_glbl },
+{ MKTAG('u','n','c','C'), mov_read_uncc },
 { MKTAG('p','a','s','p'), mov_read_pasp },
 { MKTAG('c','l','a','p'), mov_read_clap },
 { MKTAG('c','d','s','c'), mov_read_cdsc_rndr },
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index e467acdafbd..d5c5a160bdc 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -47,6 +47,9 @@ FATE_MOV_FFPROBE-$(call DEMDEC, MOV, HEVC) += 
fate-mov-dovi-hvce-mp4-read
 
 FATE_MOV_FFPROBE-$(call DEMDEC, MOV, H264) += fate-mov-vfr-bframes-duration
 
+FATE_MOV-$(call DEMDEC, MOV, RAWVIDEO) += fate-mov-uncv-rgb24
+fate-mov-uncv-rgb24: CMD = framecrc -i $(TARGET_SAMPLES)/mov/uncv-rgb24.mp4
+
 FATE_MOV_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-ffprobe-stream-entries-tmcd \
                                        fate-ffprobe-group-stream-entries-tmcd \
                                        fate-ffprobe-show-groups-tmcd
diff --git a/tests/ref/fate/mov-uncv-rgb24 b/tests/ref/fate/mov-uncv-rgb24
new file mode 100644
index 00000000000..e70b7315d0f
--- /dev/null
+++ b/tests/ref/fate/mov-uncv-rgb24
@@ -0,0 +1,65 @@
+#tb 0: 1/1
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 64x64
+#sar 0: 0/1
+0,          0,          0,        1,    12288, 0x670d211d
+0,          1,          1,        1,    12288, 0x57fd211d
+0,          2,          2,        1,    12288, 0xa64a211d
+0,          3,          3,        1,    12288, 0x670d211d
+0,          4,          4,        1,    12288, 0x57fd211d
+0,          5,          5,        1,    12288, 0xa64a211d
+0,          6,          6,        1,    12288, 0x670d211d
+0,          7,          7,        1,    12288, 0x57fd211d
+0,          8,          8,        1,    12288, 0xa64a211d
+0,          9,          9,        1,    12288, 0x670d211d
+0,         10,         10,        1,    12288, 0x57fd211d
+0,         11,         11,        1,    12288, 0xa64a211d
+0,         12,         12,        1,    12288, 0x670d211d
+0,         13,         13,        1,    12288, 0x57fd211d
+0,         14,         14,        1,    12288, 0xa64a211d
+0,         15,         15,        1,    12288, 0x670d211d
+0,         16,         16,        1,    12288, 0x57fd211d
+0,         17,         17,        1,    12288, 0xa64a211d
+0,         18,         18,        1,    12288, 0x670d211d
+0,         19,         19,        1,    12288, 0x57fd211d
+0,         20,         20,        1,    12288, 0xa64a211d
+0,         21,         21,        1,    12288, 0x670d211d
+0,         22,         22,        1,    12288, 0x57fd211d
+0,         23,         23,        1,    12288, 0xa64a211d
+0,         24,         24,        1,    12288, 0x670d211d
+0,         25,         25,        1,    12288, 0x57fd211d
+0,         26,         26,        1,    12288, 0xa64a211d
+0,         27,         27,        1,    12288, 0x670d211d
+0,         28,         28,        1,    12288, 0x57fd211d
+0,         29,         29,        1,    12288, 0xa64a211d
+0,         30,         30,        1,    12288, 0x670d211d
+0,         31,         31,        1,    12288, 0x57fd211d
+0,         32,         32,        1,    12288, 0xa64a211d
+0,         33,         33,        1,    12288, 0x670d211d
+0,         34,         34,        1,    12288, 0x57fd211d
+0,         35,         35,        1,    12288, 0xa64a211d
+0,         36,         36,        1,    12288, 0x670d211d
+0,         37,         37,        1,    12288, 0x57fd211d
+0,         38,         38,        1,    12288, 0xa64a211d
+0,         39,         39,        1,    12288, 0x670d211d
+0,         40,         40,        1,    12288, 0x57fd211d
+0,         41,         41,        1,    12288, 0xa64a211d
+0,         42,         42,        1,    12288, 0x670d211d
+0,         43,         43,        1,    12288, 0x57fd211d
+0,         44,         44,        1,    12288, 0xa64a211d
+0,         45,         45,        1,    12288, 0x670d211d
+0,         46,         46,        1,    12288, 0x57fd211d
+0,         47,         47,        1,    12288, 0xa64a211d
+0,         48,         48,        1,    12288, 0x670d211d
+0,         49,         49,        1,    12288, 0x57fd211d
+0,         50,         50,        1,    12288, 0xa64a211d
+0,         51,         51,        1,    12288, 0x670d211d
+0,         52,         52,        1,    12288, 0x57fd211d
+0,         53,         53,        1,    12288, 0xa64a211d
+0,         54,         54,        1,    12288, 0x670d211d
+0,         55,         55,        1,    12288, 0x57fd211d
+0,         56,         56,        1,    12288, 0xa64a211d
+0,         57,         57,        1,    12288, 0x670d211d
+0,         58,         58,        1,    12288, 0x57fd211d
+0,         59,         59,        1,    12288, 0xa64a211d
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to