[FFmpeg-devel] [RFC][PATCH] movenc: write clap tag

Dave Rice dave at dericed.com
Fri Jul 7 04:20:09 EEST 2017


Hi all,
I’m looking for some assistance on this patch which is intended to resolve https://trac.ffmpeg.org/ticket/6145 <https://trac.ffmpeg.org/ticket/6145>.

In https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html <https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html>, regarding the clap atom, it states "This is a mandatory extension for all uncompressed Y´CbCr data formats”. This patch is intended to write the clap atom in those cases as a coincident with the stored image (not supported a cropped aperature yet), but I’m having trouble associating it with the correct conditional formats. 

Currently this patch writes the clap atom under this condition "track->par->codec_id == AV_CODEC_ID_RAWVIDEO & track->mode == MODE_MOV”; however, AV_CODEC_ID_RAWVIDEO isn’t quite what the spec asks for. Any advice on how to write this condition for “uncompressed Y´CbCr data formats”; for instance v210 is considered uncompress Y´CbCr in QuickTime but is not a AV_CODEC_ID_RAWVIDEO. I haven’t found a concise way to add a condition for uncompressed YUV.

Other comments welcome. Thanks.

From a5e399c6eeaa64aef52dc498cc62114428f42941 Mon Sep 17 00:00:00 2001
From: Dave Rice <dave at dericed.com>
Date: Thu, 6 Jul 2017 21:12:38 -0400
Subject: [PATCH] movenc: write clap tag

---
 libavformat/movenc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 88f2f2c819..033e8550b2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1669,6 +1669,21 @@ static int mov_write_sv3d_tag(AVFormatContext *s, AVIOContext *pb, AVSphericalMa
     return update_size(pb, sv3d_pos);
 }
 
+static int mov_write_clap_tag(AVIOContext *pb, MOVTrack *track)
+{
+    avio_wb32(pb, 64);
+    ffio_wfourcc(pb, "clap");
+    avio_wb32(pb, track->par->width); /* aperatureWidth numerator */
+    avio_wb32(pb, 1); /* aperatureWidth denominator (= 1) */
+    avio_wb32(pb, track->height); /* aperatureHeight numerator */
+    avio_wb32(pb, 1); /* aperatureHeight denominator (= 1) */
+    avio_wb32(pb, 0); /* horizontal offset numerator (= 0) */
+    avio_wb32(pb, 1); /* horizontal offset denominator (= 1) */
+    avio_wb32(pb, 0); /* vertical offset numerator (= 0) */
+    avio_wb32(pb, 1); /* vertical offset denominator (= 1) */
+    return 64;
+}
+
 static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
 {
     AVRational sar;
@@ -1939,6 +1954,10 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
             av_log(mov->fc, AV_LOG_WARNING, "Not writing 'colr' atom. Format is not MOV or MP4.\n");
     }
 
+    if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO & track->mode == MODE_MOV) {
+        mov_write_clap_tag(pb, track);
+    }
+
     if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
         AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL);
         AVSphericalMapping* spherical_mapping = (AVSphericalMapping*)av_stream_get_side_data(track->st, AV_PKT_DATA_SPHERICAL, NULL);
-- 
2.13.0

Best Regards,
Dave Rice



More information about the ffmpeg-devel mailing list