[vlc-devel] [PATCH][RFC] mp4: prhd, equi, cbmp and st3d boxes have a header size of 10 bytes

Adrien Maglo magsoft at videolan.org
Fri Dec 2 13:20:48 CET 2016


According to the Google spatial video specification v2
https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md
these boxes inherit from "FullBox" which has a header size of 10 bytes.

This commit fixes the reading of parameters contained in these boxes.
---
 modules/demux/mp4/libmp4.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 9b0fa18..b404a3e 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1749,9 +1749,24 @@ struct MP4_Box_s
 
 static inline size_t mp4_box_headersize( MP4_Box_t *p_box )
 {
-    return 8
-        + ( p_box->i_shortsize == 1 ? 8 : 0 )
-        + ( p_box->i_type == ATOM_uuid ? 16 : 0 );
+    size_t i_ret =  8 + ( p_box->i_shortsize == 1 ? 8 : 0 );
+
+    switch (p_box->i_type)
+    {
+    case ATOM_uuid:
+        i_ret += 16;
+        break;
+    case ATOM_prhd:
+    case ATOM_equi:
+    case ATOM_cbmp:
+    case ATOM_st3d:
+        i_ret += 4;
+        break;
+    default:
+        break;
+    }
+
+    return i_ret;
 }
 
 #define MP4_GETX_PRIVATE(dst, code, size) do { \
-- 
2.9.3



More information about the vlc-devel mailing list