Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
2a0c82e4
Commit
2a0c82e4
authored
Apr 03, 2004
by
Laurent Aimar
Browse files
* mp4*: demux -> demux2.
parent
c0b276ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/demux/mp4/libmp4.c
View file @
2a0c82e4
...
...
@@ -104,7 +104,7 @@
free( p_buff ); \
if( i_read < 0 ) \
{ \
msg_Warn( p_stream->
p_input
, "Not enough data" ); \
msg_Warn( p_stream->
s
, "Not enough data" ); \
} \
return( i_code )
...
...
@@ -161,7 +161,7 @@ static void MP4_ConvertDate2Str( char *psz, uint64_t i_date )
static
MP4_Box_t
*
MP4_ReadBox
(
MP4_Stream_t
*
p_stream
,
MP4_Box_t
*
p_father
);
/*****************************************************************************
* Some basic functions to manipulate MP4_Stream_t, an abstraction o
p_inpu
t
* Some basic functions to manipulate MP4_Stream_t, an abstraction o
f stream_
t
* in the way that you can read from a memory buffer or from an input
*
*****************************************************************************/
...
...
@@ -172,7 +172,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father );
* MP4_InputStream create an stram with an input
*
****************************************************************************/
MP4_Stream_t
*
MP4_InputStream
(
input_th
rea
d
_t
*
p_input
)
MP4_Stream_t
*
MP4_InputStream
(
st
rea
m
_t
*
s
)
{
MP4_Stream_t
*
p_stream
;
...
...
@@ -181,7 +181,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
return
(
NULL
);
}
p_stream
->
b_memory
=
0
;
p_stream
->
p_input
=
p_input
;
p_stream
->
s
=
s
;
p_stream
->
i_start
=
0
;
p_stream
->
i_stop
=
0
;
p_stream
->
p_buffer
=
NULL
;
...
...
@@ -195,7 +195,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
* it uses p_buffer XXX you have to unallocate it yourself !
*
****************************************************************************/
MP4_Stream_t
*
MP4_MemoryStream
(
input_th
rea
d
_t
*
p_input
,
MP4_Stream_t
*
MP4_MemoryStream
(
st
rea
m
_t
*
s
,
int
i_size
,
uint8_t
*
p_buffer
)
{
MP4_Stream_t
*
p_stream
;
...
...
@@ -205,7 +205,7 @@ MP4_Stream_t *MP4_MemoryStream( input_thread_t *p_input,
return
(
NULL
);
}
p_stream
->
b_memory
=
1
;
p_stream
->
p_input
=
p_input
;
p_stream
->
s
=
s
;
p_stream
->
i_start
=
0
;
p_stream
->
i_stop
=
i_size
;
if
(
!
p_buffer
)
...
...
@@ -243,7 +243,7 @@ int MP4_ReadStream( MP4_Stream_t *p_stream, uint8_t *p_buff, int i_size )
}
else
{
return
(
stream_Read
(
p_stream
->
p_input
->
s
,
p_buff
,
i_size
)
<
i_size
?
VLC_EGENERIC
:
VLC_SUCCESS
);
return
(
stream_Read
(
p_stream
->
s
,
p_buff
,
i_size
)
<
i_size
?
VLC_EGENERIC
:
VLC_SUCCESS
);
}
}
...
...
@@ -262,16 +262,15 @@ int MP4_PeekStream( MP4_Stream_t *p_stream, uint8_t **pp_peek, int i_size )
else
{
if
(
p_
stream
->
p_input
->
stream
.
p_selected_a
rea
->
i_size
>
0
)
if
(
stream
_Size
(
p_st
rea
m
->
s
)
>
0
)
{
int64_t
i_max
=
p_stream
->
p_input
->
stream
.
p_selected_area
->
i_size
-
stream_Tell
(
p_stream
->
p_input
->
s
);
int64_t
i_max
=
stream_Size
(
p_stream
->
s
)
-
stream_Tell
(
p_stream
->
s
);
if
(
i_size
>
i_max
)
{
i_size
=
i_max
;
}
}
return
(
stream_Peek
(
p_stream
->
p_input
->
s
,
pp_peek
,
i_size
)
);
return
(
stream_Peek
(
p_stream
->
s
,
pp_peek
,
i_size
)
);
}
}
...
...
@@ -287,7 +286,7 @@ off_t MP4_TellStream( MP4_Stream_t *p_stream )
}
else
{
return
(
stream_Tell
(
p_stream
->
p_input
->
s
)
);
return
(
stream_Tell
(
p_stream
->
s
)
);
}
}
...
...
@@ -311,7 +310,7 @@ int MP4_SeekStream( MP4_Stream_t *p_stream, off_t i_pos)
}
else
{
return
(
stream_Seek
(
p_stream
->
p_input
->
s
,
(
int64_t
)
i_pos
)
);
return
(
stream_Seek
(
p_stream
->
s
,
(
int64_t
)
i_pos
)
);
}
}
...
...
@@ -371,7 +370,7 @@ static int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
#ifdef MP4_VERBOSE
if
(
p_box
->
i_size
)
{
msg_Dbg
(
p_stream
->
p_input
,
"found Box: %4.4s size "
I64Fd
,
msg_Dbg
(
p_stream
->
s
,
"found Box: %4.4s size "
I64Fd
,
(
char
*
)
&
p_box
->
i_type
,
p_box
->
i_size
);
}
...
...
@@ -492,7 +491,7 @@ static int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
i_fcc
==
FOURCC_cmov
||
i_fcc
==
FOURCC_mvhd
)
{
msg_Warn
(
p_stream
->
p_input
,
"detected moov hidden in a free box ..."
);
msg_Warn
(
p_stream
->
s
,
"detected moov hidden in a free box ..."
);
p_box
->
i_type
=
FOURCC_foov
;
return
MP4_ReadBoxContainer
(
p_stream
,
p_box
);
...
...
@@ -501,7 +500,7 @@ static int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
/* Nothing to do */
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"skip box:
\"
%4.4s
\"
"
,
msg_Dbg
(
p_stream
->
s
,
"skip box:
\"
%4.4s
\"
"
,
(
char
*
)
&
p_box
->
i_type
);
#endif
return
(
1
);
...
...
@@ -599,7 +598,7 @@ static int MP4_ReadBox_mvhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
s_duration
[
0
]
=
0
;
}
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
mvhd
\"
creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
mvhd
\"
creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d"
,
s_creation_time
,
s_modification_time
,
(
uint32_t
)
p_box
->
data
.
p_mvhd
->
i_timescale
,
...
...
@@ -661,7 +660,7 @@ static int MP4_ReadBox_tkhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_ConvertDate2Str
(
s_modification_time
,
p_box
->
data
.
p_mvhd
->
i_modification_time
);
MP4_ConvertDate2Str
(
s_duration
,
p_box
->
data
.
p_mvhd
->
i_duration
);
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
tkhd
\"
creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
tkhd
\"
creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f"
,
s_creation_time
,
s_modification_time
,
s_duration
,
...
...
@@ -715,7 +714,7 @@ static int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_ConvertDate2Str
(
s_creation_time
,
p_box
->
data
.
p_mdhd
->
i_creation_time
);
MP4_ConvertDate2Str
(
s_modification_time
,
p_box
->
data
.
p_mdhd
->
i_modification_time
);
MP4_ConvertDate2Str
(
s_duration
,
p_box
->
data
.
p_mdhd
->
i_duration
);
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
mdhd
\"
creation %s modification %s time scale %d duration %s language %c%c%c"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
mdhd
\"
creation %s modification %s time scale %d duration %s language %c%c%c"
,
s_creation_time
,
s_modification_time
,
(
uint32_t
)
p_box
->
data
.
p_mdhd
->
i_timescale
,
...
...
@@ -741,7 +740,7 @@ static int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
memcpy
(
p_box
->
data
.
p_hdlr
->
psz_name
,
p_peek
,
i_read
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
hdlr
\"
hanler type %4.4s name %s"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
hdlr
\"
hanler type %4.4s name %s"
,
(
char
*
)
&
p_box
->
data
.
p_hdlr
->
i_handler_type
,
p_box
->
data
.
p_hdlr
->
psz_name
);
...
...
@@ -769,7 +768,7 @@ static int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
vmhd
\"
graphics-mode %d opcolor (%d, %d, %d)"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
vmhd
\"
graphics-mode %d opcolor (%d, %d, %d)"
,
p_box
->
data
.
p_vmhd
->
i_graphics_mode
,
p_box
->
data
.
p_vmhd
->
i_opcolor
[
0
],
p_box
->
data
.
p_vmhd
->
i_opcolor
[
1
],
...
...
@@ -791,7 +790,7 @@ static int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES
(
p_box
->
data
.
p_smhd
->
i_reserved
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
smhd
\"
balance %f"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
smhd
\"
balance %f"
,
(
float
)
p_box
->
data
.
p_smhd
->
i_balance
/
256
);
#endif
MP4_READBOX_EXIT
(
1
);
...
...
@@ -813,7 +812,7 @@ static int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES
(
p_box
->
data
.
p_hmhd
->
i_reserved
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
hmhd
\"
maxPDU-size %d avgPDU-size %d max-bitrate %d avg-bitrate %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
hmhd
\"
maxPDU-size %d avgPDU-size %d max-bitrate %d avg-bitrate %d"
,
p_box
->
data
.
p_hmhd
->
i_max_PDU_size
,
p_box
->
data
.
p_hmhd
->
i_avg_PDU_size
,
p_box
->
data
.
p_hmhd
->
i_max_bitrate
,
...
...
@@ -830,7 +829,7 @@ static int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETSTRINGZ
(
p_box
->
data
.
p_url
->
psz_location
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
url
\"
url: %s"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
url
\"
url: %s"
,
p_box
->
data
.
p_url
->
psz_location
);
#endif
...
...
@@ -853,7 +852,7 @@ static int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETSTRINGZ
(
p_box
->
data
.
p_urn
->
psz_location
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
urn
\"
name %s location %s"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
urn
\"
name %s location %s"
,
p_box
->
data
.
p_urn
->
psz_name
,
p_box
->
data
.
p_urn
->
psz_location
);
#endif
...
...
@@ -878,7 +877,7 @@ static int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_ReadBoxContainerRaw
(
p_stream
,
p_box
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
dref
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
dref
\"
entry-count %d"
,
p_box
->
data
.
p_dref
->
i_entry_count
);
#endif
...
...
@@ -906,7 +905,7 @@ static int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stts
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stts
\"
entry-count %d"
,
p_box
->
data
.
p_stts
->
i_entry_count
);
#endif
...
...
@@ -940,7 +939,7 @@ static int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
ctts
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
ctts
\"
entry-count %d"
,
p_box
->
data
.
p_ctts
->
i_entry_count
);
#endif
...
...
@@ -986,7 +985,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_len
=
MP4_ReadLengthDescriptor
(
&
p_peek
,
&
i_read
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"found esds MPEG4ESDescr (%dBytes)"
,
msg_Dbg
(
p_stream
->
s
,
"found esds MPEG4ESDescr (%dBytes)"
,
i_len
);
#endif
...
...
@@ -1032,7 +1031,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_len
=
MP4_ReadLengthDescriptor
(
&
p_peek
,
&
i_read
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"found esds MP4DecConfigDescr (%dBytes)"
,
msg_Dbg
(
p_stream
->
s
,
"found esds MP4DecConfigDescr (%dBytes)"
,
i_len
);
#endif
...
...
@@ -1057,7 +1056,7 @@ static int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_len
=
MP4_ReadLengthDescriptor
(
&
p_peek
,
&
i_read
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"found esds MP4DecSpecificDescr (%dBytes)"
,
msg_Dbg
(
p_stream
->
s
,
"found esds MP4DecSpecificDescr (%dBytes)"
,
i_len
);
#endif
...
...
@@ -1138,7 +1137,7 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES
(
p_box
->
data
.
p_sample_soun
->
i_bytes_per_sample
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
soun
\"
qt3+ sample/packet=%d bytes/packet=%d bytes/frame=%d bytes/sample=%d"
,
p_box
->
data
.
p_sample_soun
->
i_sample_per_packet
,
p_box
->
data
.
p_sample_soun
->
i_bytes_per_packet
,
p_box
->
data
.
p_sample_soun
->
i_bytes_per_frame
,
p_box
->
data
.
p_sample_soun
->
i_bytes_per_sample
);
...
...
@@ -1152,25 +1151,25 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box
->
data
.
p_sample_soun
->
i_bytes_per_frame
=
0
;
p_box
->
data
.
p_sample_soun
->
i_bytes_per_sample
=
0
;
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
soun
\"
mp4 or qt1/2 (rest="
I64Fd
")"
,
i_read
);
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
soun
\"
mp4 or qt1/2 (rest="
I64Fd
")"
,
i_read
);
MP4_SeekStream
(
p_stream
,
p_box
->
i_pos
+
MP4_BOX_HEADERSIZE
(
p_box
)
+
28
);
}
if
(
p_box
->
i_type
==
FOURCC_drms
)
{
p_box
->
data
.
p_sample_soun
->
p_drms
=
drms_alloc
(
p_stream
->
p_input
->
p_vlc
->
psz_homedir
);
drms_alloc
(
p_stream
->
s
->
p_vlc
->
psz_homedir
);
if
(
p_box
->
data
.
p_sample_soun
->
p_drms
==
NULL
)
{
msg_Err
(
p_stream
->
p_input
,
"drms_alloc() failed"
);
msg_Err
(
p_stream
->
s
,
"drms_alloc() failed"
);
}
}
MP4_ReadBoxContainerRaw
(
p_stream
,
p_box
);
/* esds */
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
soun
\"
in stsd channel %d sample size %d sampl rate %f"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
soun
\"
in stsd channel %d sample size %d sampl rate %f"
,
p_box
->
data
.
p_sample_soun
->
i_channelcount
,
p_box
->
data
.
p_sample_soun
->
i_samplesize
,
(
float
)
p_box
->
data
.
p_sample_soun
->
i_sampleratehi
+
...
...
@@ -1250,7 +1249,7 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_ReadBoxContainerRaw
(
p_stream
,
p_box
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
vide
\"
in stsd %dx%d depth %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
vide
\"
in stsd %dx%d depth %d"
,
p_box
->
data
.
p_sample_vide
->
i_width
,
p_box
->
data
.
p_sample_vide
->
i_height
,
p_box
->
data
.
p_sample_vide
->
i_depth
);
...
...
@@ -1280,7 +1279,7 @@ static int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_ReadBoxContainerRaw
(
p_stream
,
p_box
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stsd
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stsd
\"
entry-count %d"
,
p_box
->
data
.
p_stsd
->
i_entry_count
);
#endif
...
...
@@ -1312,7 +1311,7 @@ static int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stsz
\"
sample-size %d sample-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stsz
\"
sample-size %d sample-count %d"
,
p_box
->
data
.
p_stsz
->
i_sample_size
,
p_box
->
data
.
p_stsz
->
i_sample_count
);
...
...
@@ -1350,7 +1349,7 @@ static int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stsc
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stsc
\"
entry-count %d"
,
p_box
->
data
.
p_stsc
->
i_entry_count
);
#endif
...
...
@@ -1398,7 +1397,7 @@ static int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
co64
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
co64
\"
entry-count %d"
,
p_box
->
data
.
p_co64
->
i_entry_count
);
#endif
...
...
@@ -1432,7 +1431,7 @@ static int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stss
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stss
\"
entry-count %d"
,
p_box
->
data
.
p_stss
->
i_entry_count
);
#endif
...
...
@@ -1470,7 +1469,7 @@ static int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stsh
\"
entry-count %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stsh
\"
entry-count %d"
,
p_box
->
data
.
p_stsh
->
i_entry_count
);
#endif
MP4_READBOX_EXIT
(
1
);
...
...
@@ -1501,7 +1500,7 @@ static int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stdp
\"
entry-count "
I64Fd
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stdp
\"
entry-count "
I64Fd
,
i_read
/
2
);
#endif
...
...
@@ -1545,7 +1544,7 @@ static int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
stdp
\"
entry-count "
I64Fd
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
stdp
\"
entry-count "
I64Fd
,
i_read
/
2
);
#endif
...
...
@@ -1604,7 +1603,7 @@ static int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
elst
\"
entry-count "
I64Fd
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
elst
\"
entry-count "
I64Fd
,
i_read
/
2
);
#endif
...
...
@@ -1638,7 +1637,7 @@ static int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETSTRINGZ
(
p_box
->
data
.
p_cprt
->
psz_notice
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
cprt
\"
language %c%c%c notice %s"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cprt
\"
language %c%c%c notice %s"
,
p_box
->
data
.
p_cprt
->
i_language
[
0
],
p_box
->
data
.
p_cprt
->
i_language
[
1
],
p_box
->
data
.
p_cprt
->
i_language
[
2
],
...
...
@@ -1660,7 +1659,7 @@ static int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETFOURCC
(
p_box
->
data
.
p_dcom
->
i_algorithm
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
dcom
\"
compression algorithm : %4.4s"
,
(
char
*
)
&
p_box
->
data
.
p_dcom
->
i_algorithm
);
#endif
...
...
@@ -1677,7 +1676,7 @@ static int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
!
(
p_box
->
data
.
p_cmvd
->
p_data
=
malloc
(
i_read
)
)
)
{
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
cmvd
\"
not enough memory to load data"
);
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmvd
\"
not enough memory to load data"
);
return
(
1
);
}
...
...
@@ -1689,7 +1688,7 @@ static int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box
->
data
.
p_cmvd
->
b_compressed
=
1
;
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
cmvd
\"
compressed data size %d"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmvd
\"
compressed data size %d"
,
p_box
->
data
.
p_cmvd
->
i_compressed_size
);
#endif
...
...
@@ -1716,7 +1715,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
!
(
p_box
->
data
.
p_cmov
=
malloc
(
sizeof
(
MP4_Box_data_cmov_t
)
)
)
)
{
msg_Err
(
p_stream
->
p_input
,
"out of memory"
);
msg_Err
(
p_stream
->
s
,
"out of memory"
);
return
(
0
);
}
memset
(
p_box
->
data
.
p_cmov
,
0
,
sizeof
(
MP4_Box_data_cmov_t
)
);
...
...
@@ -1724,7 +1723,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
!
p_box
->
p_father
||
(
p_box
->
p_father
->
i_type
!=
FOURCC_moov
&&
p_box
->
p_father
->
i_type
!=
FOURCC_foov
)
)
{
msg_Warn
(
p_stream
->
p_input
,
"Read box:
\"
cmov
\"
box alone"
);
msg_Warn
(
p_stream
->
s
,
"Read box:
\"
cmov
\"
box alone"
);
return
(
1
);
}
...
...
@@ -1737,19 +1736,19 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
(
p_cmvd
=
MP4_BoxGet
(
p_box
,
"cmvd"
)
)
==
NULL
||
p_cmvd
->
data
.
p_cmvd
->
p_data
==
NULL
)
{
msg_Warn
(
p_stream
->
p_input
,
"read box:
\"
cmov
\"
incomplete"
);
msg_Warn
(
p_stream
->
s
,
"read box:
\"
cmov
\"
incomplete"
);
return
(
1
);
}
if
(
p_dcom
->
data
.
p_dcom
->
i_algorithm
!=
FOURCC_zlib
)
{
msg_Dbg
(
p_stream
->
p_input
,
"read box:
\"
cmov
\"
compression algorithm : %4.4s not supported"
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmov
\"
compression algorithm : %4.4s not supported"
,
(
char
*
)
&
p_dcom
->
data
.
p_dcom
->
i_algorithm
);
return
(
1
);
}
#ifndef HAVE_ZLIB_H
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmov
\"
zlib unsupported"
);
return
(
1
);
#else
...
...
@@ -1757,7 +1756,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* allocate a new buffer */
if
(
!
(
p_data
=
malloc
(
p_cmvd
->
data
.
p_cmvd
->
i_uncompressed_size
)
)
)
{
msg_Err
(
p_stream
->
p_input
,
msg_Err
(
p_stream
->
s
,
"read box:
\"
cmov
\"
not enough memory to uncompress data"
);
return
(
1
);
}
...
...
@@ -1773,7 +1772,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* init zlib */
if
(
(
i_result
=
inflateInit
(
&
z_data
)
)
!=
Z_OK
)
{
msg_Err
(
p_stream
->
p_input
,
msg_Err
(
p_stream
->
s
,
"read box:
\"
cmov
\"
error while uncompressing data"
);
free
(
p_data
);
return
(
1
);
...
...
@@ -1783,7 +1782,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_result
=
inflate
(
&
z_data
,
Z_NO_FLUSH
);
if
(
(
i_result
!=
Z_OK
)
&&
(
i_result
!=
Z_STREAM_END
)
)
{
msg_Err
(
p_stream
->
p_input
,
msg_Err
(
p_stream
->
s
,
"read box:
\"
cmov
\"
error while uncompressing data"
);
free
(
p_data
);
return
(
1
);
...
...
@@ -1791,7 +1790,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
p_cmvd
->
data
.
p_cmvd
->
i_uncompressed_size
!=
z_data
.
total_out
)
{
msg_Warn
(
p_stream
->
p_input
,
msg_Warn
(
p_stream
->
s
,
"read box:
\"
cmov
\"
uncompressing data size mismatch"
);
}
p_cmvd
->
data
.
p_cmvd
->
i_uncompressed_size
=
z_data
.
total_out
;
...
...
@@ -1800,7 +1799,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_result
=
inflateEnd
(
&
z_data
);
if
(
i_result
!=
Z_OK
)
{
msg_Warn
(
p_stream
->
p_input
,
msg_Warn
(
p_stream
->
s
,
"read box:
\"
cmov
\"
error while uncompressing data (ignored)"
);
}
...
...
@@ -1809,11 +1808,11 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_cmvd
->
data
.
p_cmvd
->
p_data
=
p_data
;
p_cmvd
->
data
.
p_cmvd
->
b_compressed
=
0
;
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmov
\"
box succesfully uncompressed"
);
/* now create a memory stream */
p_stream_memory
=
MP4_MemoryStream
(
p_stream
->
p_input
,
p_stream_memory
=
MP4_MemoryStream
(
p_stream
->
s
,
p_cmvd
->
data
.
p_cmvd
->
i_uncompressed_size
,
p_cmvd
->
data
.
p_cmvd
->
p_data
);
...
...
@@ -1823,7 +1822,7 @@ static int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
free
(
p_stream_memory
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
cmov
\"
compressed movie header completed"
);
#endif
return
(
p_box
->
data
.
p_cmov
->
p_moov
?
1
:
0
);
...
...
@@ -1854,7 +1853,7 @@ static int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
rdrf
\"
type:%4.4s ref %s"
,
(
char
*
)
&
p_box
->
data
.
p_rdrf
->
i_ref_type
,
p_box
->
data
.
p_rdrf
->
psz_ref
);
...
...
@@ -1878,7 +1877,7 @@ static int MP4_ReadBox_rmdr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES
(
p_box
->
data
.
p_rmdr
->
i_rate
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
rmdr
\"
rate:%d"
,
p_box
->
data
.
p_rmdr
->
i_rate
);
#endif
...
...
@@ -1892,7 +1891,7 @@ static int MP4_ReadBox_rmqu( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES
(
p_box
->
data
.
p_rmqu
->
i_quality
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
rmqu
\"
quality:%d"
,
p_box
->
data
.
p_rmqu
->
i_quality
);
#endif
...
...
@@ -1910,7 +1909,7 @@ static int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES
(
p_box
->
data
.
p_rmvc
->
i_checkType
);
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
rmvc
\"
gestaltType:%4.4s val1:0x%x val2:0x%x checkType:0x%x"
,
(
char
*
)
&
p_box
->
data
.
p_rmvc
->
i_gestaltType
,
p_box
->
data
.
p_rmvc
->
i_val1
,
p_box
->
data
.
p_rmvc
->
i_val2
,
...
...
@@ -1936,7 +1935,7 @@ static int MP4_ReadBox_drms( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if
(
drms_init
(
p_drms_box
->
data
.
p_sample_soun
->
p_drms
,
p_box
->
i_type
,
p_peek
,
i_read
)
)
{
msg_Err
(
p_stream
->
p_input
,
"drms_init( %4.4s ) failed"
,
msg_Err
(
p_stream
->
s
,
"drms_init( %4.4s ) failed"
,
(
char
*
)
&
p_box
->
i_type
);
drms_free
(
p_drms_box
->
data
.
p_sample_soun
->
p_drms
);
...
...
@@ -1969,7 +1968,7 @@ static int MP4_ReadBox_0xa9xxx( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box
->
data
.
p_0xa9xxx
->
psz_text
[
i_length
]
=
'\0'
;
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
->
p_input
,
msg_Dbg
(
p_stream
->
s
,
"read box:
\"
%4.4s
\"
text=`%s'"
,
(
char
*
)
&
p_box
->
i_type
,
p_box
->
data
.
p_0xa9xxx
->
psz_text
);
...
...
@@ -2162,13 +2161,13 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
if
(
!
MP4_ReadBoxCommon
(
p_stream
,
p_box
)
)
{
msg_Warn
(
p_stream
->
p_input
,
"cannot read one box"
);
msg_Warn
(
p_stream
->
s
,
"cannot read one box"
);
free
(
p_box
);
return
NULL
;
}
if
(
!
p_box
->
i_size
)
{
msg_Dbg
(
p_stream
->
p_input
,
"found an empty box (null size)"
);
msg_Dbg
(
p_stream
->
s
,
"found an empty box (null size)"
);
free
(
p_box
);
return
NULL
;
}
...
...
@@ -2185,7 +2184,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
}
if
(
MP4_Box_Function
[
i_index
].
MP4_ReadBox_function
==
NULL
)
{
msg_Warn
(
p_stream
->
p_input
,
msg_Warn
(
p_stream
->
s
,
"unknown box type %4.4s (uncompletetly loaded)"
,
(
char
*
)
&
p_box
->
i_type
);
}
...
...
@@ -2202,7 +2201,7 @@ static MP4_Box_t *MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_father )
* MP4_FreeBox : free memory after read with MP4_ReadBox and all
* the children
*****************************************************************************/
void
MP4_BoxFree
(
input_th
rea
d
_t
*
p_input
,
MP4_Box_t
*
p_box
)
void
MP4_BoxFree
(
st
rea
m
_t
*
s
,
MP4_Box_t
*
p_box
)
{
unsigned
int
i_index
;
MP4_Box_t
*
p_child
;
...
...
@@ -2217,7 +2216,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
MP4_Box_t
*
p_next
;
p_next
=
p_child
->
p_next
;
MP4_BoxFree
(
p_input
,
p_child
);
MP4_BoxFree
(
s
,
p_child
);
p_child
=
p_next
;
}
...
...
@@ -2235,7 +2234,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
if
(
MP4_Box_Function
[
i_index
].
MP4_FreeBox_function
==
NULL
)
{
/* Should not happen */
msg_Warn
(
p_input
,
msg_Warn
(
s
,
"cannot free box %4.4s, type unknown"
,
(
char
*
)
&
p_box
->
i_type
);
}
...
...
@@ -2256,7 +2255,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
* The first box is a virtual box "root" and is the father for all first
* level boxes for the file, a sort of virtual contener
*****************************************************************************/
MP4_Box_t
*
MP4_BoxGetRoot
(
input_th
rea
d
_t
*
p_input
)
MP4_Box_t
*
MP4_BoxGetRoot
(
st
rea
m
_t
*
s
)
{
MP4_Box_t
*
p_root
;
MP4_Stream_t
*
p_stream
;
...
...
@@ -2266,7 +2265,7 @@ MP4_Box_t *MP4_BoxGetRoot( input_thread_t *p_input )
p_root
->
i_pos
=
0
;