[FFmpeg-devel] [Uncompressed MP4] Write uncC Tag
Devon Sookhoo
devonsookhoo14 at gmail.com
Tue Sep 24 23:51:30 EEST 2024
>From 5767e173414432d6079b1b581121622e874a26cd Mon Sep 17 00:00:00 2001
From: dukesook <devonsookhoo14 at gmail.com>
Date: Tue, 24 Sep 2024 12:27:31 -0600
Subject: [PATCH] mov_write_uncC_tag()
Initial function for writing the uncC, or uncopmressed codec box
---
libavformat/movenc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d20e45cf81..da40442726 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2602,6 +2602,58 @@ static int mov_write_aux_tag(AVIOContext *pb, const
char *aux_type)
return update_size(pb, pos);
}
+static int mov_write_uncC_component(AVIOContext *pb, uint16_t index,
uint8_t bit_depth_minus_one, uint8_t format, uint8_t align_size) {
+ avio_wb16(pb, index);
+ avio_w8(pb, bit_depth_minus_one);
+ avio_w8(pb, format);
+ avio_w8(pb, align_size);
+ return 0;
+}
+
+static int mov_write_uncC_tag(AVFormatContext *s, AVIOContext *pb,
MOVMuxContext *mov, MOVTrack *track) {
+ int64_t pos = avio_tell(pb);
+ uint8_t version = 0x0;
+
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "uncC");
+
+ //FULL BOX
+ avio_w8(pb, 0x00); // Flags
+ avio_wb24(pb, 0x000000); // Version
+
+ avio_wb32(pb, 0x00000000); // profile
+
+ if (version == 1) {
+ return update_size(pb, pos);
+ }
+ else if (version == 0) {
+ avio_wb32(pb, 0x03); // component_count
+ mov_write_uncC_component(pb, 0x0000, 0x07, 0x00, 0x00); //Red
+ mov_write_uncC_component(pb, 0x0001, 0x07, 0x00, 0x00); //Green
+ mov_write_uncC_component(pb, 0x0002, 0x07, 0x00, 0x00); //Blue
+
+ avio_w8(pb, 0x00); //sampling_type. 0 = No subsampling
+ avio_w8(pb, 0x00); //interleave_type. 0 = Planar, 1 = interleaved
+ avio_w8(pb, 0x00); //block_size;
+
+ // Pixel Layout Flags
+ // bit(1) components_little_endian;
+ // bit(1) block_pad_last;
+ // bit(1) block_little_endian;
+ // bit(1) block_reversed;
+ // bit(1) pad_unknown;
+ // bit(3) reserved = 0;
+ avio_w8(pb, 0X00);
+
+ avio_wb32(pb, 0x00000000); // pixel_size;
+ avio_wb32(pb, 0x00000000); // row_align_size;
+ avio_wb32(pb, 0x00000000); // tile_align_size;
+ avio_wb32(pb, 0x00000000); // num_tile_cols_minus_one;
+ avio_wb32(pb, 0x00000000); // num_tile_rows_minus_one;
+ }
+ return update_size(pb, pos);
+}
+
static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb,
MOVMuxContext *mov, MOVTrack *track)
{
int ret = AVERROR_BUG;
--
2.34.1
*ISO/IEC 23001-17:2024 Section 5.2.2 Syntax*
aligned(8) class UncompressedFrameConfigBox extends FullBox('uncC', 0, 0)
{
unsigned int(32) profile;
unsigned int(16) 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(8) 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;
}
More information about the ffmpeg-devel
mailing list