diff mbox

[FFmpeg-devel] #7496: Access to the reference track (dolby vision) of a stream

Message ID AEB6F99C59AFC04FB890F68057924E510114BB9E@CQEX10.loewe.de
State New
Headers show

Commit Message

Dmitrij.Gresserman@loewe.de Oct. 18, 2018, 12:39 p.m. UTC
Here is my new approach with side data.
________________________________
Visit our website: https://www.loewe.tv/int

[Facebook]<https://www.facebook.com/LoeweDeutschland>  [Instagram] <https://www.instagram.com/loewe.international/>   [Pinterest] <https://www.pinterest.com/loewetv/>   [YouTube] <http://www.youtube.com/user/loewe>

Loewe Technologies GmbH, Industriestraße 11, 96317 Kronach
Tel. +49 9261 99-500 • Fax +49 9261 99-515
ccc@loewe.de<mailto:ccc@loewe.de> • www.loewe.tv<https://www.loewe.tv>

Executive Management: Mark Hüsges, Hans-Henning Doerr, Peter Nortmann, Dr. Ralf Vogt • Registered Office: Kronach • Commercial Register: Amtsgericht Coburg HRB 5443
diff mbox

Patch

From ec14915807d79a9e2c4bbf082d07080fdc86a37b Mon Sep 17 00:00:00 2001
From: gressermdm <Dmitrij.Gresserman@loewe.de>
Date: Thu, 18 Oct 2018 14:19:53 +0200
Subject: [PATCH] Access to the reference track (dolby vision) of a stream

---
 libavcodec/avcodec.h |  6 ++++++
 libavformat/dump.c   | 22 ++++++++++++++++++++++
 libavformat/mov.c    | 23 +++++++++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 705a3ce..81b30dc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1372,6 +1372,12 @@  enum AVPacketSideDataType {
     AV_PKT_DATA_AFD,
 
     /**
+     * This side data contains an integer value representing the
+     * reference to another dolby track.
+     */
+    AV_PKT_DATA_REFERENCE_TRACK,
+
+    /**
      * The number of side data types.
      * This is not part of the public API/ABI in the sense that it may
      * change when new side data types are added.
diff --git a/libavformat/dump.c b/libavformat/dump.c
index bc0f401..ef20070 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -380,6 +380,24 @@  static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData *
     }
 }
 
+static void dump_reference_track(void *ctx, AVPacketSideData *sd)
+{
+    uint32_t *track_id;
+
+    if (sd->size < sizeof(uint32_t)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
+
+    track_id = (uint32_t *)sd->data;
+
+    if (!track_id) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
+    av_log(ctx, AV_LOG_INFO, "%"PRIu32"", *track_id);
+}
+
 static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
 {
     int i;
@@ -439,6 +457,10 @@  static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
         case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
             dump_content_light_metadata(ctx, &sd);
             break;
+        case AV_PKT_DATA_REFERENCE_TRACK:
+            av_log(ctx, AV_LOG_INFO, "reference track: ");
+            dump_reference_track(ctx, &sd);
+            break;
         default:
             av_log(ctx, AV_LOG_INFO,
                    "unknown side data type %d (%d bytes)", sd.type, sd.size);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index ec57a05..922776e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6658,6 +6658,28 @@  static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return 0;
 }
 
+static int mov_read_vdep(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+    uint32_t *track_id;
+    AVStream *st;
+    int ret;
+
+    track_id = av_mallocz(sizeof(uint32_t));
+    if (!track_id)
+        return AVERROR(ENOMEM);
+    *track_id = (uint32_t)avio_rb32(pb);
+
+    st = c->fc->streams[c->fc->nb_streams-1];
+    ret = av_stream_add_side_data(st, AV_PKT_DATA_REFERENCE_TRACK,
+                                  (uint8_t *)track_id, sizeof(uint32_t));
+    if (ret < 0) {
+        av_freep(&track_id);
+        return ret;
+    }
+
+    return 0;
+}
+
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('A','C','L','R'), mov_read_aclr },
 { MKTAG('A','P','R','G'), mov_read_avid },
@@ -6751,6 +6773,7 @@  static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('v','p','c','C'), mov_read_vpcc },
 { MKTAG('m','d','c','v'), mov_read_mdcv },
 { MKTAG('c','l','l','i'), mov_read_clli },
+{ MKTAG('v','d','e','p'), mov_read_vdep },
 { 0, NULL }
 };
 
-- 
2.7.4