[FFmpeg-devel] What is the correct way to read Avid ACLR atom?

Kevin Wheatley kevin.j.wheatley at gmail.com
Thu Feb 5 16:20:41 CET 2015


Hi,

so I had a quick go at this but I'm still not sure on the preferred
way of reading this, should I read the atom directly and not put the
data in extradata?

Obviously this doesn't include fixing up the fate data

Thanks

Kevin

On Wed, Feb 4, 2015 at 11:51 AM, Kevin Wheatley
<kevin.j.wheatley at gmail.com> wrote:
> Hi,
>
> I've been looking at what the appropriate place and method to read in
> the ACLR atom placed in the Avid codecs so that we can automatically
> set the color_range.
>
> From my reading of the code the mov.c code the parse table shunts the
> reading of the atom to mov_read_avid(), which in turn calls
> mov_read_extradata() which leaves the data in the codec extradata
> buffer.
>
> The issue would be at which point is the preferred point to look into
> that buffer and set the colour_range, should it be done in the
> specific codec's file in libavcodec (I'm only interested in DNxHD but
> I assume the other Avid codecs might need it), or because of this
> duplication should the change be made in libavformat/mov.c somewhere
> like mov_read_avid() in a similar way to the mov_read_ares()
> functions?
>
> Thanks
>
> Kevin
-------------- next part --------------
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e5dd1bd..8710742 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1172,6 +1172,27 @@ 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); // should we do this or read the atom directly using avio_*() and not store it in extradata?
+    if (c->fc->nb_streams >= 1) {
+        AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
+        if (codec->extradata_size == 24)
+        {        
+            switch (codec->extradata[19]) {
+            case 1:
+                codec->color_range = AVCOL_RANGE_MPEG;
+                break;
+            case 2:
+                codec->color_range = AVCOL_RANGE_JPEG;
+                break;
+            }
+        }
+    }
+
+    return ret;
+}
+
 static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     return mov_read_extradata(c, pb, atom, AV_CODEC_ID_SVQ3);
@@ -3372,7 +3393,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 },


More information about the ffmpeg-devel mailing list