[vlc-commits] mp4: privatize remaining file read helpers
Rémi Denis-Courmont
git at videolan.org
Thu Nov 30 20:16:33 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov 30 18:39:15 2017 +0200| [c8e259ae0661bbacbe80ab4d9a3e01db44f7f20d] | committer: Rémi Denis-Courmont
mp4: privatize remaining file read helpers
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8e259ae0661bbacbe80ab4d9a3e01db44f7f20d
---
modules/demux/mp4/libmp4.c | 37 +++++++++++++++++++++++++++++++++++--
modules/demux/mp4/libmp4.h | 35 -----------------------------------
modules/demux/mp4/meta.c | 8 ++++----
3 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index a4a0d4f821..3f2d3afbce 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -69,16 +69,32 @@ static void MP4_ConvertDate2Str( char *psz, uint64_t i_date, bool b_relative )
}
#endif
+#define MP4_GETX_PRIVATE(dst, code, size) \
+ do \
+ { \
+ if( (i_read) >= (size) ) \
+ { \
+ dst = (code); \
+ p_peek += (size); \
+ i_read -= (size); \
+ } \
+ else \
+ { \
+ dst = 0; \
+ i_read = 0; \
+ } \
+ } while(0)
+
#define MP4_GET1BYTE( dst ) MP4_GETX_PRIVATE( dst, *p_peek, 1 )
+#define MP4_GET2BYTES( dst ) MP4_GETX_PRIVATE( dst, GetWBE(p_peek), 2 )
#define MP4_GET3BYTES( dst ) MP4_GETX_PRIVATE( dst, Get24bBE(p_peek), 3 )
#define MP4_GET4BYTES( dst ) MP4_GETX_PRIVATE( dst, GetDWBE(p_peek), 4 )
#define MP4_GET8BYTES( dst ) MP4_GETX_PRIVATE( dst, GetQWBE(p_peek), 8 )
-#define MP4_GETFOURCC( dst ) MP4_GETX_PRIVATE( dst, \
- VLC_FOURCC(p_peek[0],p_peek[1],p_peek[2],p_peek[3]), 4)
#define MP4_GET2BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetWLE(p_peek), 2 )
#define MP4_GET4BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetDWLE(p_peek), 4 )
#define MP4_GET8BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetQWLE(p_peek), 8 )
+#define MP4_GETFOURCC( dst ) MP4_GET4BYTESLE( dst )
#define MP4_GETVERSIONFLAGS( p_void ) \
MP4_GET1BYTE( p_void->i_version ); \
@@ -109,6 +125,23 @@ static char *mp4_getstringz( uint8_t **restrict in, uint64_t *restrict size )
(p_str) = mp4_getstringz( &p_peek, &i_read ); \
while(0)
+/* This macro is used when we want to printf the box type
+ * APPLE annotation box is :
+ * either 0xA9 + 24-bit ASCII text string (and 0xA9 isn't printable)
+ * either 32-bit ASCII text string
+ */
+#define MP4_BOX_TYPE_ASCII() ( ((char*)&p_box->i_type)[0] != (char)0xA9 )
+
+static inline uint32_t Get24bBE( const uint8_t *p )
+{
+ return( ( p[0] <<16 ) + ( p[1] <<8 ) + p[2] );
+}
+
+static inline void GetUUID( UUID_t *p_uuid, const uint8_t *p_buff )
+{
+ memcpy( p_uuid, p_buff, 16 );
+}
+
static uint8_t *mp4_readbox_enter_common( stream_t *s, MP4_Box_t *box,
size_t typesize,
void (*release)( MP4_Box_t * ),
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index b8fcb682a0..6f1cc325d6 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1786,41 +1786,6 @@ static inline size_t mp4_box_headersize( MP4_Box_t *p_box )
+ ( p_box->i_type == ATOM_uuid ? 16 : 0 );
}
-#define MP4_GETX_PRIVATE(dst, code, size) \
- do \
- { \
- if( (i_read) >= (size) ) \
- { \
- dst = (code); \
- p_peek += (size); \
- i_read -= (size); \
- } \
- else \
- { \
- dst = 0; \
- i_read = 0; \
- } \
- } while(0)
-
-#define MP4_GET2BYTES( dst ) MP4_GETX_PRIVATE( dst, GetWBE(p_peek), 2 )
-
-/* This macro is used when we want to printf the box type
- * APPLE annotation box is :
- * either 0xA9 + 24-bit ASCII text string (and 0xA9 isn't printable)
- * either 32-bit ASCII text string
- */
-#define MP4_BOX_TYPE_ASCII() ( ((char*)&p_box->i_type)[0] != (char)0xA9 )
-
-static inline uint32_t Get24bBE( const uint8_t *p )
-{
- return( ( p[0] <<16 ) + ( p[1] <<8 ) + p[2] );
-}
-
-static inline void GetUUID( UUID_t *p_uuid, const uint8_t *p_buff )
-{
- memcpy( p_uuid, p_buff, 16 );
-}
-
static inline int CmpUUID( const UUID_t *u1, const UUID_t *u2 )
{
return memcmp( u1, u2, 16 );
diff --git a/modules/demux/mp4/meta.c b/modules/demux/mp4/meta.c
index 9464c842de..4a88c106d4 100644
--- a/modules/demux/mp4/meta.c
+++ b/modules/demux/mp4/meta.c
@@ -272,10 +272,10 @@ static int ExtractIntlStrings( vlc_meta_t *p_meta, MP4_Box_t *p_box )
while( i_read >= 4 )
{
- uint16_t i_len, i_lang;
-
- MP4_GET2BYTES( i_len );
- MP4_GET2BYTES( i_lang );
+ uint16_t i_len = GetWBE( p_peek );
+ uint16_t i_lang = GetWBE( p_peek + 2 );
+ p_peek += 4;
+ i_read -= 4;
if( i_len > i_read )
break;
More information about the vlc-commits
mailing list