Add simple ACLR atom reading to set the color range of the incomming
 track for codec's like DNxHD that utilise AVID's proprietary atom.

Note: for this to work with ffmpeg generated DNxHD QuickTime files you
need to also use my other patch to prevent ffmpeg generating 'corrupt'
files.
From 561db6b347bed1f60131c3eb2bebe890a402ad63 Mon Sep 17 00:00:00 2001
From: Kevin Wheatley <kevin.j.wheat...@gmail.com>
Date: Tue, 17 Feb 2015 09:15:06 +0000
Subject: [PATCH] Add simple ACLR atom reading to set the color range of the incomming
 track for codec's like DNxHD that utilise AVID's proprietary atom.


Signed-off-by: Kevin Wheatley <kevin.j.wheat...@gmail.com>
---
 libavformat/mov.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6d2262a..0d4b0cf 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1178,6 +1178,36 @@ static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return mov_read_avid(c, pb, atom);
 }
 
+static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+    int ret = mov_read_avid(c, pb, atom);
+
+    if (!ret && c->fc->nb_streams >= 1) {
+        if (atom.size == 16) {
+            AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
+            
+            /* This assumes the atom will be at the end of the extradata */
+            const uint8_t range_value = codec->extradata[codec->extradata_size - 5];
+            switch (range_value) {
+            case 1:
+                codec->color_range = AVCOL_RANGE_MPEG;
+                break;
+            case 2:
+                codec->color_range = AVCOL_RANGE_JPEG;
+                break;
+            default:
+                av_log(c, AV_LOG_WARNING, "unknown aclr value (%d)\n", range_value);
+                break;
+            }
+            av_dlog(c, "color_range: %"PRIu8"\n", codec->color_range);
+        } else {
+            av_log(c, AV_LOG_WARNING, "aclr not decoded - unexpected size %ld\n", atom.size);
+        }
+    }
+
+    return ret;
+}
+
 static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     return mov_read_extradata(c, pb, atom, AV_CODEC_ID_SVQ3);
@@ -3390,7 +3420,7 @@ static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 }
 
 static const MOVParseTableEntry mov_default_parse_table[] = {
-{ MKTAG('A','C','L','R'), mov_read_avid },
+{ MKTAG('A','C','L','R'), mov_read_aclr },
 { MKTAG('A','P','R','G'), mov_read_avid },
 { MKTAG('A','A','L','P'), mov_read_avid },
 { MKTAG('A','R','E','S'), mov_read_ares },
-- 
1.7.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to