[FFmpeg-devel] [PATCH 4/4] avformat/mov: support parsing auxl iref type

James Almer jamrial at gmail.com
Thu Sep 26 17:34:36 EEST 2024


Use the reference information present in iref boxes of type auxl to include the
relevant streams into a Tile Grid stream group. These streams are "auxiliar",
which can be things like separate alpha planes and HDR gain maps.
This does not yet export the relation of a said auxiliary streams and an
independent stream (not a grid). For this, a new Stream group type would
probably be needed.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/mov.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8a257ba535..f1274392f3 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8844,8 +8844,8 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
     return 0;
 }
 
-static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version,
-                               HEIFItem *from_item)
+static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, uint32_t type,
+                               int version, HEIFItem *from_item)
 {
     HEIFItem **ref_item_list, *to_item = NULL;
     int to_item_id = version ? avio_rb32(pb) : avio_rb16(pb);
@@ -8856,7 +8856,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version,
         to_item = &c->heif_item[j];
     }
     if (!to_item) {
-        av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n");
+        av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n",
+               av_fourcc2str(type));
         return AVERROR_INVALIDDATA;
     }
 
@@ -8870,7 +8871,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version,
     return 0;
 }
 
-static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version)
+static int mov_read_iref_generic(MOVContext *c, AVIOContext *pb, uint32_t type,
+                                 int version)
 {
     HEIFItem *from_item = NULL;
     int entries;
@@ -8882,20 +8884,21 @@ static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version)
         from_item = &c->heif_item[i];
     }
     if (!from_item) {
-        av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n");
+        av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n",
+               av_fourcc2str(type));
         return AVERROR_INVALIDDATA;
     }
 
     entries = avio_rb16(pb);
     /* 'to' item ids */
     for (int i = 0; i < entries; i++) {
-        int ret = mov_add_ref_to_item(c, pb, version, from_item);
+        int ret = mov_add_ref_to_item(c, pb, type, version, from_item);
         if (ret < 0)
             return ret;
     }
 
-    av_log(c->fc, AV_LOG_TRACE, "thmb: from_item_id %d, entries %d\n",
-           from_item_id, entries);
+    av_log(c->fc, AV_LOG_TRACE, "%s: from_item_id %d, entries %d\n",
+           av_fourcc2str(type), from_item_id, entries);
 
     return 0;
 }
@@ -8924,8 +8927,9 @@ static int mov_read_iref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         case MKTAG('d','i','m','g'):
             mov_read_iref_dimg(c, pb, version);
             break;
+        case MKTAG('a','u','x','l'):
         case MKTAG('t','h','m','b'):
-            mov_read_iref_thmb(c, pb, version);
+            mov_read_iref_generic(c, pb, type, version);
             break;
         default:
             av_log(c->fc, AV_LOG_DEBUG, "Unknown iref type %s size %"PRIu32"\n",
-- 
2.46.0



More information about the ffmpeg-devel mailing list