PR #26171 opened by dukesook URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26171 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26171.patch
# Summary of changes Implements the `uncC` box version 0 to demux uncompressed gray8 MP4s ### FATE Sample: ```fate-samples mov/uncv-gray8.mp4 ``` The `uncC` box is defined in [ISO/IEC 23001-17:2024](https://www.iso.org/standard/82528.html) Section 5.2.2: ```C aligned(8) class UncompressedFrameConfigBox extends FullBox('uncC', version, 0) { unsigned int(32) profile; if (version == 1) { } else if (version == 0) { unsigned int(32) component_count; { unsigned int(16) component_index; unsigned int(8) component_bit_depth_minus_one; unsigned int(8) component_format; unsigned int(8) component_align_size; } [component_count]; unsigned int(8) sampling_type; unsigned int(8) interleave_type; unsigned int(8) block_size; bit(1) components_little_endian; bit(1) block_pad_lsb; bit(1) block_little_endian; bit(1) block_reversed; bit(1) pad_unknown; bit(3) reserved = 0; unsigned int(32) pixel_size; unsigned int(32) row_align_size; unsigned int(32) tile_align_size; unsigned int(32) num_tile_cols_minus_one; unsigned int(32) num_tile_rows_minus_one; } } ``` <!-- 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 00a2d6315a30d417fe093ebf66b4bc6501c86b0f Mon Sep 17 00:00:00 2001 From: Devon Sookhoo <[email protected]> Date: Wed, 18 Nov 2026 07:58:45 -0700 Subject: [PATCH] avformat/mov demux uncC gray8 --- libavformat/mov.c | 172 +++++++++++++++++++++++++++++++++- tests/fate/mov.mak | 4 +- tests/ref/fate/mov-uncv-gray8 | 8 ++ 3 files changed, 179 insertions(+), 5 deletions(-) create mode 100644 tests/ref/fate/mov-uncv-gray8 diff --git a/libavformat/mov.c b/libavformat/mov.c index 97f26cf28ba..0d1113c5684 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -10393,7 +10393,12 @@ static int mov_read_uncc(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; int version; - uint32_t profile; + uint32_t profile, component_count; + uint8_t component_bit_depth, component_format, align_size; + uint8_t sampling_type, interleave_type, block_size, block_flags; + uint32_t pixel_size, row_align_size, tile_align_size, num_tile_cols_minus_one, num_tile_rows_minus_one; + uint8_t block_pad_lsb, block_little_endian, block_reversed, pad_unknown; + int64_t expected_size; if (c->fc->nb_streams < 1) return 0; @@ -10419,10 +10424,169 @@ static int mov_read_uncc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; } } else if (version == 0) { - avpriv_request_sample(c->fc, "uncC version 0 not yet implemented"); - return AVERROR_PATCHWELCOME; + + if (atom.size < 12) + return AVERROR_INVALIDDATA; + + component_count = avio_rb32(pb); + + if (component_count == 0) { + av_log(c->fc, AV_LOG_ERROR, "uncC: component_count is zero\n"); + return AVERROR_INVALIDDATA; + } + + expected_size = 36 + (int64_t)component_count * 5; + if (atom.size != expected_size) { + av_log(c->fc, AV_LOG_ERROR, "uncC: expected size: %"PRId64", actual size: %"PRId64"\n", expected_size, atom.size); + return AVERROR_INVALIDDATA; + } + + for (uint32_t i = 0; i < component_count; i++) { + avio_rb16(pb); /* component index */ + component_bit_depth = avio_r8(pb) + 1; /* component_bit_depth_minus_one */ + component_format = avio_r8(pb); + align_size = avio_r8(pb); + + if (component_bit_depth != 8) { + avpriv_request_sample(c->fc, "uncC: component bit depth %u", component_bit_depth); + return AVERROR_PATCHWELCOME; + } + + if (component_format == 0) { + /* unsigned integer */ + } else if (component_format == 1) { + avpriv_request_sample(c->fc, "uncC: floating point component"); + return AVERROR_PATCHWELCOME; + } else if (component_format == 2) { + avpriv_request_sample(c->fc, "uncC: complex floating point component"); + return AVERROR_PATCHWELCOME; + } else if (component_format == 3) { + avpriv_request_sample(c->fc, "uncC: signed integer component"); + return AVERROR_PATCHWELCOME; + } else { + av_log(c->fc, AV_LOG_ERROR, "uncC: Unknown component format %u\n", component_format); + return AVERROR_INVALIDDATA; + } + + if (align_size) { + /* If 0, the component value is coded on bit_depth bits exactly */ + avpriv_request_sample(c->fc, "uncC: align_size %u", align_size); + return AVERROR_PATCHWELCOME; + } + } + + sampling_type = avio_r8(pb); + interleave_type = avio_r8(pb); + block_size = avio_r8(pb); + block_flags = avio_r8(pb); + pixel_size = avio_rb32(pb); + row_align_size = avio_rb32(pb); + tile_align_size = avio_rb32(pb); + num_tile_cols_minus_one = avio_rb32(pb); + num_tile_rows_minus_one = avio_rb32(pb); + + switch (sampling_type) { + case 0: + /* 444 (No subsampling) */ + break; + case 1: + avpriv_request_sample(c->fc, "uncC: 422 sampling"); + return AVERROR_PATCHWELCOME; + case 2: + avpriv_request_sample(c->fc, "uncC: 420 sampling"); + return AVERROR_PATCHWELCOME; + case 3: + avpriv_request_sample(c->fc, "uncC: 411 sampling"); + return AVERROR_PATCHWELCOME; + default: + av_log(c->fc, AV_LOG_ERROR, "uncC: Unknown sampling type %u\n", sampling_type); + return AVERROR_INVALIDDATA; + } + + switch (interleave_type) { + case 0: + /* Component Interleaving (planar) */ + break; + case 1: + /* Pixel Interleaving (packed) */ + break; + case 2: + /* Mixed Interleaving */ + avpriv_request_sample(c->fc, "uncC: Mixed Interleaving"); + return AVERROR_PATCHWELCOME; + case 3: + /* Row Interleaving */ + avpriv_request_sample(c->fc, "uncC: Row Interleaving"); + return AVERROR_PATCHWELCOME; + case 4: + /* Tile-component Interleaving */ + avpriv_request_sample(c->fc, "uncC: Tile-component Interleaving"); + return AVERROR_PATCHWELCOME; + case 5: + /* Multi-Y pixel Interleaving */ + avpriv_request_sample(c->fc, "uncC: Multi-Y pixel Interleaving"); + return AVERROR_PATCHWELCOME; + default: + av_log(c->fc, AV_LOG_ERROR, "uncC: Unknown interleave type %u\n", interleave_type); + return AVERROR_INVALIDDATA; + } + + if (block_size) { + /* If block_size is 0, then blocking is not used */ + avpriv_request_sample(c->fc, "uncC: Block size handling"); + return AVERROR_PATCHWELCOME; + } + + /* bit 7: components_little_endian (unused) */ + block_pad_lsb = (block_flags >> 6) & 1; + block_little_endian = (block_flags >> 5) & 1; + block_reversed = (block_flags >> 4) & 1; + pad_unknown = (block_flags >> 3) & 1; + + if (block_pad_lsb) { + avpriv_request_sample(c->fc, "uncC: Block pad LSB"); + return AVERROR_PATCHWELCOME; + } + if (block_little_endian) { + avpriv_request_sample(c->fc, "uncC: Block little endian"); + return AVERROR_PATCHWELCOME; + } + if (block_reversed) { + avpriv_request_sample(c->fc, "uncC: Block reversed"); + return AVERROR_PATCHWELCOME; + } + if (pad_unknown) { + avpriv_request_sample(c->fc, "uncC: Pad unknown"); + return AVERROR_PATCHWELCOME; + } + if (pixel_size) { + /* If 0, then no additional padding is present after each pixel. */ + avpriv_request_sample(c->fc, "uncC: Pixel size handling"); + return AVERROR_PATCHWELCOME; + } + if (row_align_size) { + /* Indicates the padding between rows */ + avpriv_request_sample(c->fc, "uncC: Row alignment handling"); + return AVERROR_PATCHWELCOME; + } + if (tile_align_size) { + /* Indicates the padding between tiles */ + avpriv_request_sample(c->fc, "uncC: Tile alignment handling"); + return AVERROR_PATCHWELCOME; + } + if (num_tile_cols_minus_one || num_tile_rows_minus_one) { + avpriv_request_sample(c->fc, "uncC: tiling"); + return AVERROR_PATCHWELCOME; + } + + if (component_count == 1) { + st->codecpar->format = AV_PIX_FMT_GRAY8; + } else { + avpriv_request_sample(c->fc, "uncC: %u components", component_count); + return AVERROR_PATCHWELCOME; + } } else { - av_log(c->fc, AV_LOG_WARNING, "Unknown uncC version %d\n", version); + av_log(c->fc, AV_LOG_ERROR, "Unknown uncC version %d\n", version); return AVERROR_INVALIDDATA; } diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index be39d60d210..c850d797699 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -53,8 +53,10 @@ fate-mov-vpcc-reserved-color-tags: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -v erro -show_entries stream=color_primaries,color_transfer,color_space -of default=nw=1 \ $(TARGET_SAMPLES)/mov/vpcc-reserved-color-tags.mp4 -FATE_MOV-$(call DEMDEC, MOV, RAWVIDEO) += fate-mov-uncv-rgb24 +FATE_MOV-$(call DEMDEC, MOV, RAWVIDEO) += fate-mov-uncv-rgb24 \ + fate-mov-uncv-gray8 fate-mov-uncv-rgb24: CMD = framecrc -i $(TARGET_SAMPLES)/mov/uncv-rgb24.mp4 +fate-mov-uncv-gray8: CMD = framecrc -i $(TARGET_SAMPLES)/mov/uncv-gray8.mp4 FATE_MOV_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-ffprobe-stream-entries-tmcd \ fate-ffprobe-group-stream-entries-tmcd \ diff --git a/tests/ref/fate/mov-uncv-gray8 b/tests/ref/fate/mov-uncv-gray8 new file mode 100644 index 00000000000..cd47d766e1e --- /dev/null +++ b/tests/ref/fate/mov-uncv-gray8 @@ -0,0 +1,8 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 128x64 +#sar 0: 0/1 +0, 0, 0, 1, 8192, 0x38b48078 +0, 1, 1, 1, 8192, 0x716800ff +0, 2, 2, 1, 8192, 0xaa1c8177 -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
