Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
4605535b
Commit
4605535b
authored
Mar 29, 2012
by
Frédéric Yhuel
Committed by
Jean-Baptiste Kempf
Mar 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libmp4: move some stuff into the header file
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
54e435ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
122 deletions
+116
-122
modules/demux/mp4/libmp4.c
modules/demux/mp4/libmp4.c
+0
-122
modules/demux/mp4/libmp4.h
modules/demux/mp4/libmp4.h
+116
-0
No files found.
modules/demux/mp4/libmp4.c
View file @
4605535b
...
...
@@ -34,132 +34,10 @@
#include "libmp4.h"
#include <math.h>
/*****************************************************************************
* Here are defined some macro to make life simpler but before using it
* *look* at the code.
*
*****************************************************************************/
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
);
}
#define MP4_GETX_PRIVATE(dst, code, size) do { \
if( (i_read) >= (size) ) { dst = (code); p_peek += (size); } \
else { dst = 0; } \
i_read -= (size); \
} 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_GETVERSIONFLAGS( p_void ) \
MP4_GET1BYTE( p_void->i_version ); \
MP4_GET3BYTES( p_void->i_flags )
#define MP4_GETSTRINGZ( p_str ) \
if( (i_read > 0) && (p_peek[0]) ) \
{ \
const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 ); \
p_str = malloc( __i_copy__+1 ); \
if( p_str ) \
{ \
memcpy( p_str, p_peek, __i_copy__ ); \
p_str[__i_copy__] = 0; \
} \
p_peek += __i_copy__ + 1; \
i_read -= __i_copy__ + 1; \
} \
else \
{ \
p_str = NULL; \
}
#define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t ) \
int64_t i_read = p_box->i_size; \
uint8_t *p_peek, *p_buff; \
int i_actually_read; \
if( !( p_peek = p_buff = malloc( i_read ) ) ) \
{ \
return( 0 ); \
} \
i_actually_read = stream_Read( p_stream, p_peek, i_read ); \
if( i_actually_read < 0 || (int64_t)i_actually_read < i_read )\
{ \
msg_Warn( p_stream, "MP4_READBOX_ENTER: I got %i bytes, "\
"but I requested %"PRId64"", i_actually_read, i_read );\
free( p_buff ); \
return( 0 ); \
} \
p_peek += mp4_box_headersize( p_box ); \
i_read -= mp4_box_headersize( p_box ); \
if( !( p_box->data.p_data = calloc( 1, sizeof( MP4_Box_data_TYPE_t ) ) ) ) \
{ \
free( p_buff ); \
return( 0 ); \
}
#define MP4_READBOX_EXIT( i_code ) \
do \
{ \
free( p_buff ); \
if( i_read < 0 ) \
msg_Warn( p_stream, "Not enough data" ); \
return( i_code ); \
} while (0)
/* Some assumptions:
* The input method HAS to be seekable
*/
/* 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
);
}
static
void
CreateUUID
(
UUID_t
*
p_uuid
,
uint32_t
i_fourcc
)
{
/* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
where XXXXXXXX is the fourcc */
/* FIXME implement this */
(
void
)
p_uuid
;
(
void
)
i_fourcc
;
}
const
UUID_t
TfrfBoxUUID
=
{
.
b
=
{
0xd4
,
0x80
,
0x7e
,
0xf2
,
0xca
,
0x39
,
0x46
,
0x95
,
0x8e
,
0x54
,
0x26
,
0xcb
,
0x9e
,
0x46
,
0xa7
,
0x9f
}
};
const
UUID_t
TfxdBoxUUID
=
{
.
b
=
{
0x6d
,
0x1d
,
0x9b
,
0x05
,
0x42
,
0xd5
,
0x44
,
0xe6
,
0x80
,
0xe2
,
0x14
,
0x1b
,
0xaf
,
0xf7
,
0x57
,
0xb2
}
};
/* convert 16.16 fixed point to floating point */
static
double
conv_fx
(
int32_t
fx
)
{
double
fp
=
fx
;
...
...
modules/demux/mp4/libmp4.h
View file @
4605535b
...
...
@@ -1213,6 +1213,122 @@ typedef struct MP4_Box_s
}
MP4_Box_t
;
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
);
}
#define MP4_GETX_PRIVATE(dst, code, size) do { \
if( (i_read) >= (size) ) { dst = (code); p_peek += (size); } \
else { dst = 0; } \
i_read -= (size); \
} 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_GETVERSIONFLAGS( p_void ) \
MP4_GET1BYTE( p_void->i_version ); \
MP4_GET3BYTES( p_void->i_flags )
#define MP4_GETSTRINGZ( p_str ) \
if( (i_read > 0) && (p_peek[0]) ) \
{ \
const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 ); \
p_str = malloc( __i_copy__+1 ); \
if( p_str ) \
{ \
memcpy( p_str, p_peek, __i_copy__ ); \
p_str[__i_copy__] = 0; \
} \
p_peek += __i_copy__ + 1; \
i_read -= __i_copy__ + 1; \
} \
else \
{ \
p_str = NULL; \
}
#define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t ) \
int64_t i_read = p_box->i_size; \
uint8_t *p_peek, *p_buff; \
int i_actually_read; \
if( !( p_peek = p_buff = malloc( i_read ) ) ) \
{ \
return( 0 ); \
} \
i_actually_read = stream_Read( p_stream, p_peek, i_read ); \
if( i_actually_read < 0 || (int64_t)i_actually_read < i_read )\
{ \
msg_Warn( p_stream, "MP4_READBOX_ENTER: I got %i bytes, "\
"but I requested %"PRId64"", i_actually_read, i_read );\
free( p_buff ); \
return( 0 ); \
} \
p_peek += mp4_box_headersize( p_box ); \
i_read -= mp4_box_headersize( p_box ); \
if( !( p_box->data.p_data = calloc( 1, sizeof( MP4_Box_data_TYPE_t ) ) ) ) \
{ \
free( p_buff ); \
return( 0 ); \
}
#define MP4_READBOX_EXIT( i_code ) \
do \
{ \
free( p_buff ); \
if( i_read < 0 ) \
msg_Warn( p_stream, "Not enough data" ); \
return( i_code ); \
} 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
inline
int
CmpUUID
(
const
UUID_t
*
u1
,
const
UUID_t
*
u2
)
{
return
memcmp
(
u1
,
u2
,
16
);
}
static
inline
void
CreateUUID
(
UUID_t
*
p_uuid
,
uint32_t
i_fourcc
)
{
/* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
where XXXXXXXX is the fourcc */
/* FIXME implement this */
(
void
)
p_uuid
;
(
void
)
i_fourcc
;
}
static
const
UUID_t
TfrfBoxUUID
=
{
{
0xd4
,
0x80
,
0x7e
,
0xf2
,
0xca
,
0x39
,
0x46
,
0x95
,
0x8e
,
0x54
,
0x26
,
0xcb
,
0x9e
,
0x46
,
0xa7
,
0x9f
}
};
static
const
UUID_t
TfxdBoxUUID
=
{
{
0x6d
,
0x1d
,
0x9b
,
0x05
,
0x42
,
0xd5
,
0x44
,
0xe6
,
0x80
,
0xe2
,
0x14
,
0x1b
,
0xaf
,
0xf7
,
0x57
,
0xb2
}
};
/*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment