Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
c0b276ae
Commit
c0b276ae
authored
Apr 03, 2004
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* avi: demux -> demux2.
parent
fcfa54ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
227 additions
and
256 deletions
+227
-256
modules/demux/avi/avi.c
modules/demux/avi/avi.c
+227
-256
No files found.
modules/demux/avi/avi.c
View file @
c0b276ae
...
...
@@ -49,7 +49,7 @@ static void Close( vlc_object_t * );
vlc_module_begin
();
set_description
(
_
(
"AVI demuxer"
)
);
set_capability
(
"demux"
,
212
);
set_capability
(
"demux
2
"
,
212
);
add_bool
(
"avi-interleaved"
,
0
,
NULL
,
INTERLEAVE_TEXT
,
INTERLEAVE_LONGTEXT
,
VLC_TRUE
);
...
...
@@ -62,10 +62,10 @@ vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Control
(
input_thread
_t
*
,
int
,
va_list
);
static
int
Seek
(
input_thread
_t
*
,
mtime_t
,
int
);
static
int
Demux_Seekable
(
input_thread
_t
*
);
static
int
Demux_UnSeekable
(
input_thread
_t
*
);
static
int
Control
(
demux
_t
*
,
int
,
va_list
);
static
int
Seek
(
demux
_t
*
,
mtime_t
,
int
);
static
int
Demux_Seekable
(
demux
_t
*
);
static
int
Demux_UnSeekable
(
demux
_t
*
);
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
#define __ABS( x ) ( (x) < 0 ? (-(x)) : (x) )
...
...
@@ -151,31 +151,31 @@ static mtime_t AVI_GetDPTS ( avi_track_t *, int64_t i_count );
static
mtime_t
AVI_GetPTS
(
avi_track_t
*
);
static
int
AVI_StreamChunkFind
(
input_thread
_t
*
,
unsigned
int
i_stream
);
static
int
AVI_StreamChunkSet
(
input_thread
_t
*
,
static
int
AVI_StreamChunkFind
(
demux
_t
*
,
unsigned
int
i_stream
);
static
int
AVI_StreamChunkSet
(
demux
_t
*
,
unsigned
int
i_stream
,
unsigned
int
i_ck
);
static
int
AVI_StreamBytesSet
(
input_thread
_t
*
,
static
int
AVI_StreamBytesSet
(
demux
_t
*
,
unsigned
int
i_stream
,
off_t
i_byte
);
vlc_fourcc_t
AVI_FourccGetCodec
(
unsigned
int
i_cat
,
vlc_fourcc_t
);
static
int
AVI_GetKeyFlag
(
vlc_fourcc_t
,
uint8_t
*
);
static
int
AVI_PacketGetHeader
(
input_thread
_t
*
,
avi_packet_t
*
p_pk
);
static
int
AVI_PacketNext
(
input_thread
_t
*
);
static
int
AVI_PacketRead
(
input_thread
_t
*
,
avi_packet_t
*
,
block_t
**
);
static
int
AVI_PacketSearch
(
input_thread
_t
*
);
static
int
AVI_PacketGetHeader
(
demux
_t
*
,
avi_packet_t
*
p_pk
);
static
int
AVI_PacketNext
(
demux
_t
*
);
static
int
AVI_PacketRead
(
demux
_t
*
,
avi_packet_t
*
,
block_t
**
);
static
int
AVI_PacketSearch
(
demux
_t
*
);
static
void
AVI_IndexLoad
(
input_thread
_t
*
);
static
void
AVI_IndexCreate
(
input_thread
_t
*
);
static
void
AVI_IndexLoad
(
demux
_t
*
);
static
void
AVI_IndexCreate
(
demux
_t
*
);
static
void
AVI_IndexAddEntry
(
demux_sys_t
*
,
int
,
avi_entry_t
*
);
static
mtime_t
AVI_MovieGetLength
(
input_thread
_t
*
);
static
mtime_t
AVI_MovieGetLength
(
demux
_t
*
);
/*****************************************************************************
* Stream management
*****************************************************************************/
static
int
AVI_TrackSeek
(
input_thread
_t
*
,
int
,
mtime_t
);
static
int
AVI_TrackStopFinishedStreams
(
input_thread
_t
*
);
static
int
AVI_TrackSeek
(
demux
_t
*
,
int
,
mtime_t
);
static
int
AVI_TrackStopFinishedStreams
(
demux
_t
*
);
/* Remarks:
- For VBR mp3 stream:
...
...
@@ -191,7 +191,7 @@ static int AVI_TrackStopFinishedStreams( input_thread_t *);
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
avi_chunk_t
ck_riff
;
...
...
@@ -206,19 +206,19 @@ static int Open( vlc_object_t * p_this )
/* Is it an avi file ? */
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
12
)
<
12
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
12
)
<
12
)
{
msg_Err
(
p_
input
,
"cannot peek()"
);
msg_Err
(
p_
demux
,
"cannot peek()"
);
return
VLC_EGENERIC
;
}
if
(
strncmp
(
&
p_peek
[
0
],
"RIFF"
,
4
)
||
strncmp
(
&
p_peek
[
8
],
"AVI "
,
4
)
)
{
msg_Warn
(
p_
input
,
"avi module discarded (invalid header)"
);
msg_Warn
(
p_
demux
,
"avi module discarded (invalid header)"
);
return
VLC_EGENERIC
;
}
/* Initialize input structures. */
p_sys
=
p_
input
->
p_demux_data
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
=
p_
demux
->
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
memset
(
p_sys
,
0
,
sizeof
(
demux_sys_t
)
);
p_sys
->
i_time
=
0
;
p_sys
->
i_length
=
0
;
...
...
@@ -228,19 +228,19 @@ static int Open( vlc_object_t * p_this )
p_sys
->
track
=
NULL
;
p_sys
->
meta
=
NULL
;
stream_Control
(
p_
input
->
s
,
STREAM_CAN_FASTSEEK
,
&
p_sys
->
b_seekable
);
stream_Control
(
p_
demux
->
s
,
STREAM_CAN_FASTSEEK
,
&
p_sys
->
b_seekable
);
p_
input
->
pf_demux
_control
=
Control
;
p_
input
->
pf_demux
=
Demux_Seekable
;
p_
demux
->
pf
_control
=
Control
;
p_
demux
->
pf_demux
=
Demux_Seekable
;
/* For unseekable stream, automaticaly use Demux_UnSeekable */
if
(
!
p_sys
->
b_seekable
||
config_GetInt
(
p_
input
,
"avi-interleaved"
)
)
if
(
!
p_sys
->
b_seekable
||
config_GetInt
(
p_
demux
,
"avi-interleaved"
)
)
{
p_
input
->
pf_demux
=
Demux_UnSeekable
;
p_
demux
->
pf_demux
=
Demux_UnSeekable
;
}
if
(
AVI_ChunkReadRoot
(
p_
input
->
s
,
&
p_sys
->
ck_root
)
)
if
(
AVI_ChunkReadRoot
(
p_
demux
->
s
,
&
p_sys
->
ck_root
)
)
{
msg_Err
(
p_
input
,
"avi module discarded (invalid file)"
);
msg_Err
(
p_
demux
,
"avi module discarded (invalid file)"
);
return
VLC_EGENERIC
;
}
...
...
@@ -249,7 +249,7 @@ static int Open( vlc_object_t * p_this )
unsigned
int
i_count
=
AVI_ChunkCount
(
&
p_sys
->
ck_root
,
AVIFOURCC_RIFF
);
msg_Warn
(
p_
input
,
"multiple riff -> OpenDML ?"
);
msg_Warn
(
p_
demux
,
"multiple riff -> OpenDML ?"
);
for
(
i
=
1
;
i
<
i_count
;
i
++
)
{
avi_chunk_list_t
*
p_sysx
;
...
...
@@ -257,7 +257,7 @@ static int Open( vlc_object_t * p_this )
p_sysx
=
AVI_ChunkFind
(
&
p_sys
->
ck_root
,
AVIFOURCC_RIFF
,
i
);
if
(
p_sysx
->
i_type
==
AVIFOURCC_AVIX
)
{
msg_Warn
(
p_
input
,
"detected OpenDML file"
);
msg_Warn
(
p_
demux
,
"detected OpenDML file"
);
p_sys
->
b_odml
=
VLC_TRUE
;
break
;
}
...
...
@@ -270,41 +270,30 @@ static int Open( vlc_object_t * p_this )
if
(
!
p_hdrl
||
!
p_movi
)
{
msg_Err
(
p_
input
,
"avi module discarded (invalid file)"
);
msg_Err
(
p_
demux
,
"avi module discarded (invalid file)"
);
goto
error
;
}
if
(
!
(
p_avih
=
AVI_ChunkFind
(
p_hdrl
,
AVIFOURCC_avih
,
0
)
)
)
{
msg_Err
(
p_
input
,
"cannot find avih chunk"
);
msg_Err
(
p_
demux
,
"cannot find avih chunk"
);
goto
error
;
}
i_track
=
AVI_ChunkCount
(
p_hdrl
,
AVIFOURCC_strl
);
if
(
p_avih
->
i_streams
!=
i_track
)
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"found %d stream but %d are declared"
,
i_track
,
p_avih
->
i_streams
);
}
if
(
i_track
==
0
)
{
msg_Err
(
p_
input
,
"no stream defined!"
);
msg_Err
(
p_
demux
,
"no stream defined!"
);
goto
error
;
}
/* create one program */
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
if
(
input_InitStream
(
p_input
,
0
)
==
-
1
)
{
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
msg_Err
(
p_input
,
"cannot init stream"
);
goto
error
;
}
p_input
->
stream
.
i_mux_rate
=
0
;
/* Fixed later */
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
/* print informations on streams */
msg_Dbg
(
p_
input
,
"AVIH: %d stream, flags %s%s%s%s "
,
msg_Dbg
(
p_
demux
,
"AVIH: %d stream, flags %s%s%s%s "
,
i_track
,
p_avih
->
i_flags
&
AVIF_HASINDEX
?
" HAS_INDEX"
:
""
,
p_avih
->
i_flags
&
AVIF_MUSTUSEINDEX
?
" MUST_USE_INDEX"
:
""
,
...
...
@@ -346,14 +335,14 @@ static int Open( vlc_object_t * p_this )
if
(
p_strl
==
NULL
||
p_strh
==
NULL
||
p_auds
==
NULL
||
p_vids
==
NULL
)
{
msg_Warn
(
p_
input
,
"stream[%d] incomplete"
,
i
);
msg_Warn
(
p_
demux
,
"stream[%d] incomplete"
,
i
);
continue
;
}
tk
->
i_rate
=
p_strh
->
i_rate
;
tk
->
i_scale
=
p_strh
->
i_scale
;
tk
->
i_samplesize
=
p_strh
->
i_samplesize
;
msg_Dbg
(
p_
input
,
"stream[%d] rate:%d scale:%d samplesize:%d"
,
msg_Dbg
(
p_
demux
,
"stream[%d] rate:%d scale:%d samplesize:%d"
,
i
,
tk
->
i_rate
,
tk
->
i_scale
,
tk
->
i_samplesize
);
switch
(
p_strh
->
i_type
)
...
...
@@ -383,7 +372,7 @@ static int Open( vlc_object_t * p_this )
fmt
.
i_extra
=
__MIN
(
p_auds
->
p_wf
->
cbSize
,
p_auds
->
i_chunk_size
-
sizeof
(
WAVEFORMATEX
)
);
fmt
.
p_extra
=
&
p_auds
->
p_wf
[
1
];
msg_Dbg
(
p_
input
,
"stream[%d] audio(0x%x) %d channels %dHz %dbits"
,
msg_Dbg
(
p_
demux
,
"stream[%d] audio(0x%x) %d channels %dHz %dbits"
,
i
,
p_auds
->
p_wf
->
wFormatTag
,
p_auds
->
p_wf
->
nChannels
,
p_auds
->
p_wf
->
nSamplesPerSec
,
p_auds
->
p_wf
->
wBitsPerSample
);
break
;
...
...
@@ -426,7 +415,7 @@ static int Open( vlc_object_t * p_this )
__MIN
(
p_vids
->
p_bih
->
biSize
-
sizeof
(
BITMAPINFOHEADER
),
p_vids
->
i_chunk_size
-
sizeof
(
BITMAPINFOHEADER
)
);
fmt
.
p_extra
=
&
p_vids
->
p_bih
[
1
];
msg_Dbg
(
p_
input
,
"stream[%d] video(%4.4s) %dx%d %dbpp %ffps"
,
msg_Dbg
(
p_
demux
,
"stream[%d] video(%4.4s) %dx%d %dbpp %ffps"
,
i
,
(
char
*
)
&
p_vids
->
p_bih
->
biCompression
,
p_vids
->
p_bih
->
biWidth
,
...
...
@@ -435,44 +424,44 @@ static int Open( vlc_object_t * p_this )
(
float
)
tk
->
i_rate
/
(
float
)
tk
->
i_scale
);
break
;
default:
msg_Warn
(
p_
input
,
"stream[%d] unknown type"
,
i
);
msg_Warn
(
p_
demux
,
"stream[%d] unknown type"
,
i
);
free
(
tk
);
continue
;
}
tk
->
p_es
=
es_out_Add
(
p_
input
->
p_es_
out
,
&
fmt
);
tk
->
p_es
=
es_out_Add
(
p_
demux
->
out
,
&
fmt
);
TAB_APPEND
(
p_sys
->
i_track
,
p_sys
->
track
,
tk
);
}
if
(
p_sys
->
i_track
<=
0
)
{
msg_Err
(
p_
input
,
"no valid track"
);
msg_Err
(
p_
demux
,
"no valid track"
);
goto
error
;
}
if
(
config_GetInt
(
p_
input
,
"avi-index"
)
)
if
(
config_GetInt
(
p_
demux
,
"avi-index"
)
)
{
if
(
p_sys
->
b_seekable
)
{
AVI_IndexCreate
(
p_
input
);
AVI_IndexCreate
(
p_
demux
);
}
else
{
msg_Warn
(
p_
input
,
"cannot create index (unseekable stream)"
);
AVI_IndexLoad
(
p_
input
);
msg_Warn
(
p_
demux
,
"cannot create index (unseekable stream)"
);
AVI_IndexLoad
(
p_
demux
);
}
}
else
{
AVI_IndexLoad
(
p_
input
);
AVI_IndexLoad
(
p_
demux
);
}
/* *** movie length in sec *** */
p_sys
->
i_length
=
AVI_MovieGetLength
(
p_
input
);
p_sys
->
i_length
=
AVI_MovieGetLength
(
p_
demux
);
if
(
p_sys
->
i_length
<
(
mtime_t
)
p_avih
->
i_totalframes
*
(
mtime_t
)
p_avih
->
i_microsecperframe
/
(
mtime_t
)
1000000
)
{
msg_Warn
(
p_
input
,
"broken or missing index, 'seek' will be axproximative or will have strange behavour"
);
msg_Warn
(
p_
demux
,
"broken or missing index, 'seek' will be axproximative or will have strange behavour"
);
}
/* fix some BeOS MediaKit generated file */
for
(
i
=
0
;
i
<
p_sys
->
i_track
;
i
++
)
...
...
@@ -507,28 +496,22 @@ static int Open( vlc_object_t * p_this )
if
(
i_length
==
0
)
{
msg_Warn
(
p_
input
,
"track[%d] cannot be fixed (BeOS MediaKit generated)"
,
i
);
msg_Warn
(
p_
demux
,
"track[%d] cannot be fixed (BeOS MediaKit generated)"
,
i
);
continue
;
}
tk
->
i_samplesize
=
1
;
tk
->
i_rate
=
i_track_length
*
(
int64_t
)
1000000
/
i_length
;
msg_Warn
(
p_input
,
"track[%d] fixed with rate=%d scale=%d (BeOS MediaKit generated)"
,
i
,
tk
->
i_rate
,
tk
->
i_scale
);
}
msg_Warn
(
p_demux
,
"track[%d] fixed with rate=%d scale=%d (BeOS MediaKit generated)"
,
i
,
tk
->
i_rate
,
tk
->
i_scale
);
}
if
(
p_sys
->
i_length
)
{
p_input
->
stream
.
i_mux_rate
=
stream_Size
(
p_input
->
s
)
/
50
/
p_sys
->
i_length
;
}
if
(
p_sys
->
b_seekable
)
{
/* we have read all chunk so go back to movi */
stream_Seek
(
p_
input
->
s
,
p_movi
->
i_chunk_pos
);
stream_Seek
(
p_
demux
->
s
,
p_movi
->
i_chunk_pos
);
}
/* Skip movi header */
stream_Read
(
p_
input
->
s
,
NULL
,
12
);
stream_Read
(
p_
demux
->
s
,
NULL
,
12
);
p_sys
->
i_movi_begin
=
p_movi
->
i_chunk_pos
;
return
VLC_SUCCESS
;
...
...
@@ -538,7 +521,7 @@ error:
{
vlc_meta_Delete
(
p_sys
->
meta
);
}
AVI_ChunkFreeRoot
(
p_
input
->
s
,
&
p_sys
->
ck_root
);
AVI_ChunkFreeRoot
(
p_
demux
->
s
,
&
p_sys
->
ck_root
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
...
...
@@ -548,9 +531,9 @@ error:
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
unsigned
int
i
;
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
for
(
i
=
0
;
i
<
p_sys
->
i_track
;
i
++
)
{
...
...
@@ -561,7 +544,7 @@ static void Close ( vlc_object_t * p_this )
}
}
FREE
(
p_sys
->
track
);
AVI_ChunkFreeRoot
(
p_
input
->
s
,
&
p_sys
->
ck_root
);
AVI_ChunkFreeRoot
(
p_
demux
->
s
,
&
p_sys
->
ck_root
);
vlc_meta_Delete
(
p_sys
->
meta
);
free
(
p_sys
);
...
...
@@ -585,9 +568,9 @@ typedef struct
else : point on data directly */
}
avi_track_toread_t
;
static
int
Demux_Seekable
(
input_thread_t
*
p_input
)
static
int
Demux_Seekable
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
unsigned
int
i_track_count
=
0
;
unsigned
int
i_track
;
...
...
@@ -602,12 +585,12 @@ static int Demux_Seekable( input_thread_t *p_input )
avi_track_t
*
tk
=
p_sys
->
track
[
i_track
];
vlc_bool_t
b
;
es_out_Control
(
p_
input
->
p_es_
out
,
ES_OUT_GET_ES_STATE
,
tk
->
p_es
,
&
b
);
es_out_Control
(
p_
demux
->
out
,
ES_OUT_GET_ES_STATE
,
tk
->
p_es
,
&
b
);
if
(
b
&&
!
tk
->
b_activated
)
{
if
(
p_sys
->
b_seekable
)
{
AVI_TrackSeek
(
p_
input
,
i_track
,
p_sys
->
i_time
);
AVI_TrackSeek
(
p_
demux
,
i_track
,
p_sys
->
i_time
);
}
tk
->
b_activated
=
VLC_TRUE
;
}
...
...
@@ -623,12 +606,12 @@ static int Demux_Seekable( input_thread_t *p_input )
if
(
i_track_count
<=
0
)
{
msg_Warn
(
p_
input
,
"no track selected, exiting..."
);
msg_Warn
(
p_
demux
,
"no track selected, exiting..."
);
return
(
0
);
}
/* wait for the good time */
es_out_Control
(
p_
input
->
p_es_
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
es_out_Control
(
p_
demux
->
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
p_sys
->
i_time
+=
25
*
1000
;
/* read 25ms */
/* init toread */
...
...
@@ -714,35 +697,35 @@ static int Demux_Seekable( input_thread_t *p_input )
* in case we fail we will disable all finished stream */
if
(
p_sys
->
i_movi_lastchunk_pos
>=
p_sys
->
i_movi_begin
+
12
)
{
stream_Seek
(
p_
input
->
s
,
p_sys
->
i_movi_lastchunk_pos
);
if
(
AVI_PacketNext
(
p_
input
)
)
stream_Seek
(
p_
demux
->
s
,
p_sys
->
i_movi_lastchunk_pos
);
if
(
AVI_PacketNext
(
p_
demux
)
)
{
return
(
AVI_TrackStopFinishedStreams
(
p_
input
)
?
0
:
1
);
return
(
AVI_TrackStopFinishedStreams
(
p_
demux
)
?
0
:
1
);
}
}
else
{
stream_Seek
(
p_
input
->
s
,
p_sys
->
i_movi_begin
+
12
);
stream_Seek
(
p_
demux
->
s
,
p_sys
->
i_movi_begin
+
12
);
}
for
(
;;
)
{
avi_packet_t
avi_pk
;
if
(
AVI_PacketGetHeader
(
p_
input
,
&
avi_pk
)
)
if
(
AVI_PacketGetHeader
(
p_
demux
,
&
avi_pk
)
)
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"cannot get packet header, track disabled"
);
return
(
AVI_TrackStopFinishedStreams
(
p_
input
)
?
0
:
1
);
return
(
AVI_TrackStopFinishedStreams
(
p_
demux
)
?
0
:
1
);
}
if
(
avi_pk
.
i_stream
>=
p_sys
->
i_track
||
(
avi_pk
.
i_cat
!=
AUDIO_ES
&&
avi_pk
.
i_cat
!=
VIDEO_ES
)
)
{
if
(
AVI_PacketNext
(
p_
input
)
)
if
(
AVI_PacketNext
(
p_
demux
)
)
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"cannot skip packet, track disabled"
);
return
(
AVI_TrackStopFinishedStreams
(
p_
input
)
?
0
:
1
);
return
(
AVI_TrackStopFinishedStreams
(
p_
demux
)
?
0
:
1
);
}
continue
;
}
...
...
@@ -768,11 +751,11 @@ static int Demux_Seekable( input_thread_t *p_input )
}
else
{
if
(
AVI_PacketNext
(
p_
input
)
)
if
(
AVI_PacketNext
(
p_
demux
)
)
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"cannot skip packet, track disabled"
);
return
(
AVI_TrackStopFinishedStreams
(
p_
input
)
?
0
:
1
);
return
(
AVI_TrackStopFinishedStreams
(
p_
demux
)
?
0
:
1
);
}
}
}
...
...
@@ -781,7 +764,7 @@ static int Demux_Seekable( input_thread_t *p_input )
}
else
{
stream_Seek
(
p_
input
->
s
,
i_pos
);
stream_Seek
(
p_
demux
->
s
,
i_pos
);
}
/* Set the track to use */
...
...
@@ -817,9 +800,9 @@ static int Demux_Seekable( input_thread_t *p_input )
i_size
+=
8
;
/* need to read and skip header */
}
if
(
(
p_frame
=
stream_Block
(
p_
input
->
s
,
__EVEN
(
i_size
)
)
)
==
NULL
)
if
(
(
p_frame
=
stream_Block
(
p_
demux
->
s
,
__EVEN
(
i_size
)
)
)
==
NULL
)
{
msg_Warn
(
p_
input
,
"failled reading data"
);
msg_Warn
(
p_
demux
,
"failled reading data"
);
tk
->
b_activated
=
VLC_FALSE
;
toread
[
i_track
].
b_ok
=
VLC_FALSE
;
continue
;
...
...
@@ -897,8 +880,8 @@ static int Demux_Seekable( input_thread_t *p_input )
p_frame
->
i_pts
=
0
;
}
//p_pes->i_rate = p_
input
->stream.control.i_rate;
es_out_Send
(
p_
input
->
p_es_
out
,
tk
->
p_es
,
p_frame
);
//p_pes->i_rate = p_
demux
->stream.control.i_rate;
es_out_Send
(
p_
demux
->
out
,
tk
->
p_es
,
p_frame
);
}
}
...
...
@@ -908,18 +891,14 @@ static int Demux_Seekable( input_thread_t *p_input )
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux_UnSeekable
(
input_thread_t
*
p_input
)
static
int
Demux_UnSeekable
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_track_t
*
p_stream_master
=
NULL
;
vlc_bool_t
b_audio
;
unsigned
int
i_stream
;
unsigned
int
i_packet
;
/* Check if we need to send the audio data to decoder */
b_audio
=
!
p_input
->
stream
.
control
.
b_mute
;
es_out_Control
(
p_input
->
p_es_out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
/* *** find master stream for data packet skipping algo *** */
/* *** -> first video, if any, or first audio ES *** */
...
...
@@ -928,7 +907,7 @@ static int Demux_UnSeekable( input_thread_t *p_input )
avi_track_t
*
tk
=
p_sys
->
track
[
i_stream
];
vlc_bool_t
b
;
es_out_Control
(
p_
input
->
p_es_
out
,
ES_OUT_GET_ES_STATE
,
tk
->
p_es
,
&
b
);
es_out_Control
(
p_
demux
->
out
,
ES_OUT_GET_ES_STATE
,
tk
->
p_es
,
&
b
);
if
(
b
&&
tk
->
i_cat
==
VIDEO_ES
)
{
...
...
@@ -942,7 +921,7 @@ static int Demux_UnSeekable( input_thread_t *p_input )
if
(
!
p_stream_master
)
{
msg_Warn
(
p_
input
,
"no more stream selected"
);
msg_Warn
(
p_
demux
,
"no more stream selected"
);
return
(
0
);
}
...
...
@@ -954,7 +933,7 @@ static int Demux_UnSeekable( input_thread_t *p_input )
avi_packet_t
avi_pk
;
if
(
AVI_PacketGetHeader
(
p_
input
,
&
avi_pk
)
)
if
(
AVI_PacketGetHeader
(
p_
demux
,
&
avi_pk
)
)
{
return
(
0
);
}
...
...
@@ -971,42 +950,32 @@ static int Demux_UnSeekable( input_thread_t *p_input )
case
AVIFOURCC_JUNK
:
case
AVIFOURCC_LIST
:
case
AVIFOURCC_RIFF
:
return
(
!
AVI_PacketNext
(
p_
input
)
?
1
:
0
);
return
(
!
AVI_PacketNext
(
p_
demux
)
?
1
:
0
);
case
AVIFOURCC_idx1
:
if
(
p_sys
->
b_odml
)
{
return
(
!
AVI_PacketNext
(
p_
input
)
?
1
:
0
);
return
(
!
AVI_PacketNext
(
p_
demux
)
?
1
:
0
);
}
return
(
0
);
/* eof */
default:
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"seems to have lost position, resync"
);
if
(
AVI_PacketSearch
(
p_
input
)
)
if
(
AVI_PacketSearch
(
p_
demux
)
)
{
msg_Err
(
p_
input
,
"resync failed"
);
msg_Err
(
p_
demux
,
"resync failed"
);
return
(
-
1
);
}
}
}
else
{
/* do will send this packet to decoder ? */
if
(
!
b_audio
&&
avi_pk
.
i_cat
==
AUDIO_ES
)
{
if
(
AVI_PacketNext
(
p_input
)
)
{
return
(
0
);
}
}
else
{
/* it's a selected stream, check for time */
/* check for time */
if
(
__ABS
(
AVI_GetPTS
(
p_stream
)
-
AVI_GetPTS
(
p_stream_master
)
)
<
600
*
1000
)
{
/* load it and send to decoder */
block_t
*
p_frame
;
if
(
AVI_PacketRead
(
p_input
,
&
avi_pk
,
&
p_frame
)
||
p_frame
==
NULL
)
if
(
AVI_PacketRead
(
p_demux
,
&
avi_pk
,
&
p_frame
)
||
p_frame
==
NULL
)
{
return
(
-
1
);
}
...
...
@@ -1020,17 +989,16 @@ static int Demux_UnSeekable( input_thread_t *p_input )
p_frame
->
i_pts
=
0
;
}
//p_pes->i_rate = p_input
->stream.control.i_rate;
es_out_Send
(
p_input
->
p_es_
out
,
p_stream
->
p_es
,
p_frame
);
//p_pes->i_rate = p_demux
->stream.control.i_rate;
es_out_Send
(
p_demux
->
out
,
p_stream
->
p_es
,
p_frame
);
}
else
{
if
(
AVI_PacketNext
(
p_input
)
)
if
(
AVI_PacketNext
(
p_demux
)
)
{
return
(
0
);
}
}
}
/* *** update stream time position *** */
if
(
p_stream
->
i_samplesize
)
...
...
@@ -1058,12 +1026,12 @@ static int Demux_UnSeekable( input_thread_t *p_input )
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Seek
(
input_thread_t
*
p_input
,
mtime_t
i_date
,
int
i_percent
)
static
int
Seek
(
demux_t
*
p_demux
,
mtime_t
i_date
,
int
i_percent
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
unsigned
int
i_stream
;
msg_Dbg
(
p_
input
,
msg_Dbg
(
p_
demux
,
"seek requested: "
I64Fd
" secondes %d%%"
,
i_date
/
1000000
,
i_percent
);
...
...
@@ -1076,19 +1044,19 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
int64_t
i_pos
;
/* use i_percent to create a true i_date */
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"mmh, seeking without index at %d%%"
" work only for interleaved file"
,
i_percent
);
if
(
i_percent
>=
100
)
{
msg_Warn
(
p_
input
,
"cannot seek so far !"
);
msg_Warn
(
p_
demux
,
"cannot seek so far !"
);
return
(
-
1
);
}
i_percent
=
__MAX
(
i_percent
,
0
);
/* try to find chunk that is at i_percent or the file */
i_pos
=
__MAX
(
i_percent
*
stream_Size
(
p_
input
->
s
)
/
100
,
stream_Size
(
p_
demux
->
s
)
/
100
,
p_sys
->
i_movi_begin
);
/* search first selected stream */
for
(
i_stream
=
0
,
p_stream
=
NULL
;
...
...
@@ -1102,16 +1070,16 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
}
if
(
!
p_stream
||
!
p_stream
->
b_activated
)
{
msg_Warn
(
p_
input
,
"cannot find any selected stream"
);
msg_Warn
(
p_
demux
,
"cannot find any selected stream"
);
return
(
-
1
);
}
/* be sure that the index exist */
if
(
AVI_StreamChunkSet
(
p_
input
,
if
(
AVI_StreamChunkSet
(
p_
demux
,
i_stream
,
0
)
)
{
msg_Warn
(
p_
input
,
"cannot seek"
);
msg_Warn
(
p_
demux
,
"cannot seek"
);
return
(
-
1
);
}
...
...
@@ -1119,16 +1087,16 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
p_stream
->
p_index
[
p_stream
->
i_idxposc
].
i_length
+
8
)
{
/* search after i_idxposc */
if
(
AVI_StreamChunkSet
(
p_
input
,
if
(
AVI_StreamChunkSet
(
p_
demux
,
i_stream
,
p_stream
->
i_idxposc
+
1
)
)
{
msg_Warn
(
p_
input
,
"cannot seek"
);
msg_Warn
(
p_
demux
,
"cannot seek"
);
return
(
-
1
);
}
}
i_date
=
AVI_GetPTS
(
p_stream
);
/* TODO better support for i_samplesize != 0 */
msg_Dbg
(
p_
input
,
"estimate date "
I64Fd
,
i_date
);
msg_Dbg
(
p_
demux
,
"estimate date "
I64Fd
,
i_date
);
}
#define p_stream p_sys->track[i_stream]
...
...
@@ -1139,7 +1107,7 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
if
(
p_stream
->
b_activated
&&
!
p_stream
->
i_samplesize
)
/* if( p_stream->b_activated ) */
{
AVI_TrackSeek
(
p_
input
,
i_stream
,
i_date
);
AVI_TrackSeek
(
p_
demux
,
i_stream
,
i_date
);
p_sys
->
i_time
=
__MAX
(
AVI_GetPTS
(
p_stream
),
p_sys
->
i_time
);
}
...
...
@@ -1154,11 +1122,11 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
{
if
(
p_stream
->
b_activated
&&
p_stream
->
i_samplesize
)
{
AVI_TrackSeek
(
p_
input
,
i_stream
,
i_date
);
AVI_TrackSeek
(
p_
demux
,
i_stream
,
i_date
);
/* p_sys->i_time = __MAX( AVI_GetPTS( p_stream ), p_sys->i_time );*/
}
}
msg_Dbg
(
p_
input
,
"seek: "
I64Fd
" seconds"
,
p_sys
->
i_time
/
1000000
);
msg_Dbg
(
p_
demux
,
"seek: "
I64Fd
" seconds"
,
p_sys
->
i_time
/
1000000
);
/* set true movie time */
#endif
if
(
!
p_sys
->
i_time
)
...
...
@@ -1170,7 +1138,7 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
}
else
{
msg_Err
(
p_
input
,
"shouldn't yet be executed"
);
msg_Err
(
p_
demux
,
"shouldn't yet be executed"
);
return
(
-
1
);
}
}
...
...
@@ -1180,15 +1148,15 @@ static int Seek( input_thread_t *p_input, mtime_t i_date, int i_percent )
*****************************************************************************
*
*****************************************************************************/
static
double
ControlGetPosition
(
input_thread_t
*
p_input
)
static
double
ControlGetPosition
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
if
(
p_sys
->
i_length
>
0
)
{
return
(
double
)
p_sys
->
i_time
/
(
double
)(
p_sys
->
i_length
*
(
mtime_t
)
1000000
);
}
else
if
(
stream_Size
(
p_
input
->
s
)
>
0
)
else
if
(
stream_Size
(
p_
demux
->
s
)
>
0
)
{
unsigned
int
i
;
int64_t
i_tmp
;
...
...
@@ -1208,14 +1176,14 @@ static double ControlGetPosition( input_thread_t *p_input )
}
}
}
return
(
double
)
i64
/
(
double
)
stream_Size
(
p_
input
->
s
);
return
(
double
)
i64
/
(
double
)
stream_Size
(
p_
demux
->
s
);
}
return
0
.
0
;
}
static
int
Control
(
input_thread_t
*
p_input
,
int
i_query
,
va_list
args
)
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int
i
;
double
f
,
*
pf
;
int64_t
i64
,
*
pi64
;
...
...
@@ -1225,16 +1193,20 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
{
case
DEMUX_GET_POSITION
:
pf
=
(
double
*
)
va_arg
(
args
,
double
*
);
*
pf
=
ControlGetPosition
(
p_
input
);
*
pf
=
ControlGetPosition
(
p_
demux
);
return
VLC_SUCCESS
;
case
DEMUX_SET_POSITION
:
f
=
(
double
)
va_arg
(
args
,
double
);
if
(
p_sys
->
b_seekable
)
{
f
=
(
double
)
va_arg
(
args
,
double
);
i64
=
(
mtime_t
)(
1000000
.
0
*
p_sys
->
i_length
*
f
);
return
Seek
(
p_input
,
i64
,
(
int
)(
f
*
100
)
)
<
0
?
VLC_EGENERIC
:
VLC_SUCCESS
;
return
Seek
(
p_demux
,
i64
,
(
int
)(
f
*
100
)
)
<
0
?
VLC_EGENERIC
:
VLC_SUCCESS
;
}
else
{
int64_t
i_pos
=
stream_Size
(
p_demux
->
s
)
*
f
;
return
stream_Seek
(
p_demux
->
s
,
i_pos
);
}
return
demux_vaControlDefault
(
p_input
,
i_query
,
args
);
case
DEMUX_GET_TIME
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
...
...
@@ -1252,10 +1224,10 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
}
else
if
(
p_sys
->
i_time
>
0
)
{
i_percent
=
(
int
)(
100
.
0
*
ControlGetPosition
(
p_
input
)
*
i_percent
=
(
int
)(
100
.
0
*
ControlGetPosition
(
p_
demux
)
*
(
double
)
i64
/
(
double
)
p_sys
->
i_time
);
}
return
Seek
(
p_
input
,
i64
,
i_percent
);
return
Seek
(
p_
demux
,
i64
,
i_percent
);
}
case
DEMUX_GET_LENGTH
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
...
...
@@ -1281,9 +1253,8 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
return
VLC_SUCCESS
;
default:
return
demux_vaControlDefault
(
p_input
,
i_query
,
args
);
}
return
VLC_EGENERIC
;
}
}
/*****************************************************************************
...
...
@@ -1357,43 +1328,43 @@ static mtime_t AVI_GetPTS( avi_track_t *tk )
}
}
static
int
AVI_StreamChunkFind
(
input_thread_t
*
p_input
,
static
int
AVI_StreamChunkFind
(
demux_t
*
p_demux
,
unsigned
int
i_stream
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_packet_t
avi_pk
;
/* find first chunk of i_stream that isn't in index */
if
(
p_sys
->
i_movi_lastchunk_pos
>=
p_sys
->
i_movi_begin
+
12
)
{
stream_Seek
(
p_
input
->
s
,
p_sys
->
i_movi_lastchunk_pos
);
if
(
AVI_PacketNext
(
p_
input
)
)
stream_Seek
(
p_
demux
->
s
,
p_sys
->
i_movi_lastchunk_pos
);
if
(
AVI_PacketNext
(
p_
demux
)
)
{
return
VLC_EGENERIC
;
}
}
else
{
stream_Seek
(
p_
input
->
s
,
p_sys
->
i_movi_begin
+
12
);
stream_Seek
(
p_
demux
->
s
,
p_sys
->
i_movi_begin
+
12
);
}
for
(
;;
)
{
if
(
p_
input
->
b_die
)
if
(
p_
demux
->
b_die
)
{
return
VLC_EGENERIC
;
}
if
(
AVI_PacketGetHeader
(
p_
input
,
&
avi_pk
)
)
if
(
AVI_PacketGetHeader
(
p_
demux
,
&
avi_pk
)
)
{
msg_Warn
(
p_
input
,
"cannot get packet header"
);
msg_Warn
(
p_
demux
,
"cannot get packet header"
);
return
VLC_EGENERIC
;
}
if
(
avi_pk
.
i_stream
>=
p_sys
->
i_track
||
(
avi_pk
.
i_cat
!=
AUDIO_ES
&&
avi_pk
.
i_cat
!=
VIDEO_ES
)
)
{
if
(
AVI_PacketNext
(
p_
input
)
)
if
(
AVI_PacketNext
(
p_
demux
)
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1416,7 +1387,7 @@ static int AVI_StreamChunkFind( input_thread_t *p_input,
return
VLC_SUCCESS
;
}
if
(
AVI_PacketNext
(
p_
input
)
)
if
(
AVI_PacketNext
(
p_
demux
)
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1426,11 +1397,11 @@ static int AVI_StreamChunkFind( input_thread_t *p_input,
/* be sure that i_ck will be a valid index entry */
static
int
AVI_StreamChunkSet
(
input_thread_t
*
p_input
,
static
int
AVI_StreamChunkSet
(
demux_t
*
p_demux
,
unsigned
int
i_stream
,
unsigned
int
i_ck
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_track_t
*
p_stream
=
p_sys
->
track
[
i_stream
];
p_stream
->
i_idxposc
=
i_ck
;
...
...
@@ -1442,7 +1413,7 @@ static int AVI_StreamChunkSet( input_thread_t *p_input,
do
{
p_stream
->
i_idxposc
++
;
if
(
AVI_StreamChunkFind
(
p_
input
,
i_stream
)
)
if
(
AVI_StreamChunkFind
(
p_
demux
,
i_stream
)
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1455,11 +1426,11 @@ static int AVI_StreamChunkSet( input_thread_t *p_input,
/* XXX FIXME up to now, we assume that all chunk are one after one */
static
int
AVI_StreamBytesSet
(
input_thread_t
*
p_input
,
static
int
AVI_StreamBytesSet
(
demux_t
*
p_demux
,
unsigned
int
i_stream
,
off_t
i_byte
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_track_t
*
p_stream
=
p_sys
->
track
[
i_stream
];
if
(
(
p_stream
->
i_idxnb
>
0
)
...
...
@@ -1504,7 +1475,7 @@ static int AVI_StreamBytesSet( input_thread_t *p_input,
do
{
p_stream
->
i_idxposc
++
;
if
(
AVI_StreamChunkFind
(
p_
input
,
i_stream
)
)
if
(
AVI_StreamChunkFind
(
p_
demux
,
i_stream
)
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1518,11 +1489,11 @@ static int AVI_StreamBytesSet( input_thread_t *p_input,
}
}
static
int
AVI_TrackSeek
(
input_thread_t
*
p_input
,
static
int
AVI_TrackSeek
(
demux_t
*
p_demux
,
int
i_stream
,
mtime_t
i_date
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_track_t
*
tk
=
p_sys
->
track
[
i_stream
];
#define p_stream p_sys->track[i_stream]
...
...
@@ -1532,7 +1503,7 @@ static int AVI_TrackSeek( input_thread_t *p_input,
if
(
!
p_stream
->
i_samplesize
)
{
if
(
AVI_StreamChunkSet
(
p_
input
,
if
(
AVI_StreamChunkSet
(
p_
demux
,
i_stream
,
AVI_PTSToChunk
(
p_stream
,
i_date
)
)
)
{
...
...
@@ -1556,7 +1527,7 @@ static int AVI_TrackSeek( input_thread_t *p_input,
}
}
msg_Dbg
(
p_
input
,
msg_Dbg
(
p_
demux
,
"old:"
I64Fd
" %s new "
I64Fd
,
i_oldpts
,
i_oldpts
>
i_date
?
">"
:
"<"
,
...
...
@@ -1571,7 +1542,7 @@ static int AVI_TrackSeek( input_thread_t *p_input,
!
(
p_stream
->
p_index
[
p_stream
->
i_idxposc
].
i_flags
&
AVIIF_KEYFRAME
)
)
{
if
(
AVI_StreamChunkSet
(
p_
input
,
if
(
AVI_StreamChunkSet
(
p_
demux
,
i_stream
,
p_stream
->
i_idxposc
-
1
)
)
{
...
...
@@ -1585,7 +1556,7 @@ static int AVI_TrackSeek( input_thread_t *p_input,
!
(
p_stream
->
p_index
[
p_stream
->
i_idxposc
].
i_flags
&
AVIIF_KEYFRAME
)
)
{
if
(
AVI_StreamChunkSet
(
p_
input
,
if
(
AVI_StreamChunkSet
(
p_
demux
,
i_stream
,
p_stream
->
i_idxposc
+
1
)
)
{
...
...
@@ -1597,7 +1568,7 @@ static int AVI_TrackSeek( input_thread_t *p_input,
}
else
{
if
(
AVI_StreamBytesSet
(
p_
input
,
if
(
AVI_StreamBytesSet
(
p_
demux
,
i_stream
,
AVI_PTSToByte
(
p_stream
,
i_date
)
)
)
{
...
...
@@ -1758,17 +1729,17 @@ static void AVI_ParseStreamHeader( vlc_fourcc_t i_id,
/****************************************************************************
*
****************************************************************************/
static
int
AVI_PacketGetHeader
(
input_thread_t
*
p_input
,
avi_packet_t
*
p_pk
)
static
int
AVI_PacketGetHeader
(
demux_t
*
p_demux
,
avi_packet_t
*
p_pk
)
{
uint8_t
*
p_peek
;
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
16
)
<
16
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
16
)
<
16
)
{
return
VLC_EGENERIC
;
}
p_pk
->
i_fourcc
=
VLC_FOURCC
(
p_peek
[
0
],
p_peek
[
1
],
p_peek
[
2
],
p_peek
[
3
]
);
p_pk
->
i_size
=
GetDWLE
(
p_peek
+
4
);
p_pk
->
i_pos
=
stream_Tell
(
p_
input
->
s
);
p_pk
->
i_pos
=
stream_Tell
(
p_
demux
->
s
);
if
(
p_pk
->
i_fourcc
==
AVIFOURCC_LIST
||
p_pk
->
i_fourcc
==
AVIFOURCC_RIFF
)
{
p_pk
->
i_type
=
VLC_FOURCC
(
p_peek
[
8
],
p_peek
[
9
],
...
...
@@ -1785,12 +1756,12 @@ static int AVI_PacketGetHeader( input_thread_t *p_input, avi_packet_t *p_pk )
return
VLC_SUCCESS
;
}
static
int
AVI_PacketNext
(
input_thread_t
*
p_input
)
static
int
AVI_PacketNext
(
demux_t
*
p_demux
)
{
avi_packet_t
avi_ck
;
int
i_skip
=
0
;
if
(
AVI_PacketGetHeader
(
p_
input
,
&
avi_ck
)
)
if
(
AVI_PacketGetHeader
(
p_
demux
,
&
avi_ck
)
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1810,13 +1781,13 @@ static int AVI_PacketNext( input_thread_t *p_input )
i_skip
=
__EVEN
(
avi_ck
.
i_size
)
+
8
;
}
if
(
stream_Read
(
p_
input
->
s
,
NULL
,
i_skip
)
!=
i_skip
)
if
(
stream_Read
(
p_
demux
->
s
,
NULL
,
i_skip
)
!=
i_skip
)
{
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
static
int
AVI_PacketRead
(
input_thread_t
*
p_input
,
static
int
AVI_PacketRead
(
demux_t
*
p_demux
,
avi_packet_t
*
p_pk
,
block_t
**
pp_frame
)
{
...
...
@@ -1824,7 +1795,7 @@ static int AVI_PacketRead( input_thread_t *p_input,
i_size
=
__EVEN
(
p_pk
->
i_size
+
8
);
if
(
(
*
pp_frame
=
stream_Block
(
p_
input
->
s
,
i_size
)
)
==
NULL
)
if
(
(
*
pp_frame
=
stream_Block
(
p_
demux
->
s
,
i_size
)
)
==
NULL
)
{
return
VLC_EGENERIC
;
}
...
...
@@ -1839,19 +1810,19 @@ static int AVI_PacketRead( input_thread_t *p_input,
return
VLC_SUCCESS
;
}
static
int
AVI_PacketSearch
(
input_thread_t
*
p_input
)
static
int
AVI_PacketSearch
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_packet_t
avi_pk
;
int
i_count
=
0
;
for
(
;;
)
{
if
(
stream_Read
(
p_
input
->
s
,
NULL
,
1
)
!=
1
)
if
(
stream_Read
(
p_
demux
->
s
,
NULL
,
1
)
!=
1
)
{
return
VLC_EGENERIC
;
}
AVI_PacketGetHeader
(
p_
input
,
&
avi_pk
);
AVI_PacketGetHeader
(
p_
demux
,
&
avi_pk
);
if
(
avi_pk
.
i_stream
<
p_sys
->
i_track
&&
(
avi_pk
.
i_cat
==
AUDIO_ES
||
avi_pk
.
i_cat
==
VIDEO_ES
)
)
{
...
...
@@ -1872,11 +1843,11 @@ static int AVI_PacketSearch( input_thread_t *p_input )
* this code is called only on broken files). */
if
(
!
(
++
i_count
%
1024
)
)
{
if
(
p_
input
->
b_die
)
return
VLC_EGENERIC
;
if
(
p_
demux
->
b_die
)
return
VLC_EGENERIC
;
msleep
(
10000
);
if
(
!
(
i_count
%
(
1024
*
10
))
)
msg_Warn
(
p_
input
,
"trying to resync..."
);
msg_Warn
(
p_
demux
,
"trying to resync..."
);
}
}
}
...
...
@@ -1922,9 +1893,9 @@ static void AVI_IndexAddEntry( demux_sys_t *p_sys,
tk
->
p_index
[
tk
->
i_idxnb
++
]
=
*
p_index
;
}
static
int
AVI_IndexLoad_idx1
(
input_thread_t
*
p_input
)
static
int
AVI_IndexLoad_idx1
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_chunk_list_t
*
p_riff
;
avi_chunk_list_t
*
p_movi
;
...
...
@@ -1941,7 +1912,7 @@ static int AVI_IndexLoad_idx1( input_thread_t *p_input )
if
(
!
p_idx1
)
{
msg_Warn
(
p_
input
,
"cannot find idx1 chunk, no index defined"
);
msg_Warn
(
p_
demux
,
"cannot find idx1 chunk, no index defined"
);
return
VLC_EGENERIC
;
}
...
...
@@ -1980,15 +1951,15 @@ static int AVI_IndexLoad_idx1( input_thread_t *p_input )
return
VLC_SUCCESS
;
}
static
void
__Parse_indx
(
input_thread_t
*
p_input
,
static
void
__Parse_indx
(
demux_t
*
p_demux
,
int
i_stream
,
avi_chunk_indx_t
*
p_indx
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_entry_t
index
;
int32_t
i
;
msg_Dbg
(
p_
input
,
"loading subindex(0x%x) %d entries"
,
p_indx
->
i_indextype
,
p_indx
->
i_entriesinuse
);
msg_Dbg
(
p_
demux
,
"loading subindex(0x%x) %d entries"
,
p_indx
->
i_indextype
,
p_indx
->
i_entriesinuse
);
if
(
p_indx
->
i_indexsubtype
==
0
)
{
for
(
i
=
0
;
i
<
p_indx
->
i_entriesinuse
;
i
++
)
...
...
@@ -2015,13 +1986,13 @@ static void __Parse_indx( input_thread_t *p_input,
}
else
{
msg_Warn
(
p_
input
,
"unknow subtype index(0x%x)"
,
p_indx
->
i_indexsubtype
);
msg_Warn
(
p_
demux
,
"unknow subtype index(0x%x)"
,
p_indx
->
i_indexsubtype
);
}
}
static
void
AVI_IndexLoad_indx
(
input_thread_t
*
p_input
)
static
void
AVI_IndexLoad_indx
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
unsigned
int
i_stream
;
int32_t
i
;
...
...
@@ -2042,38 +2013,38 @@ static void AVI_IndexLoad_indx( input_thread_t *p_input )
if
(
!
p_indx
)
{
msg_Warn
(
p_
input
,
"cannot find indx (misdetect/broken OpenDML file?)"
);
msg_Warn
(
p_
demux
,
"cannot find indx (misdetect/broken OpenDML file?)"
);
continue
;
}
if
(
p_indx
->
i_indextype
==
AVI_INDEX_OF_CHUNKS
)
{
__Parse_indx
(
p_
input
,
i_stream
,
p_indx
);
__Parse_indx
(
p_
demux
,
i_stream
,
p_indx
);
}
else
if
(
p_indx
->
i_indextype
==
AVI_INDEX_OF_INDEXES
)
{
avi_chunk_indx_t
ck_sub
;
for
(
i
=
0
;
i
<
p_indx
->
i_entriesinuse
;
i
++
)
{
if
(
stream_Seek
(
p_
input
->
s
,
p_indx
->
idx
.
super
[
i
].
i_offset
)
||
AVI_ChunkRead
(
p_
input
->
s
,
&
ck_sub
,
NULL
)
)
if
(
stream_Seek
(
p_
demux
->
s
,
p_indx
->
idx
.
super
[
i
].
i_offset
)
||
AVI_ChunkRead
(
p_
demux
->
s
,
&
ck_sub
,
NULL
)
)
{
break
;
}
__Parse_indx
(
p_
input
,
i_stream
,
&
ck_sub
);
__Parse_indx
(
p_
demux
,
i_stream
,
&
ck_sub
);
}
}
else
{
msg_Warn
(
p_
input
,
"unknow type index(0x%x)"
,
p_indx
->
i_indextype
);
msg_Warn
(
p_
demux
,
"unknow type index(0x%x)"
,
p_indx
->
i_indextype
);
}
#undef p_stream
}
}
static
void
AVI_IndexLoad
(
input_thread_t
*
p_input
)
static
void
AVI_IndexLoad
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
unsigned
int
i_stream
;
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_track
;
i_stream
++
)
...
...
@@ -2085,24 +2056,24 @@ static void AVI_IndexLoad( input_thread_t *p_input )
if
(
p_sys
->
b_odml
)
{
AVI_IndexLoad_indx
(
p_
input
);
AVI_IndexLoad_indx
(
p_
demux
);
}
else
if
(
AVI_IndexLoad_idx1
(
p_
input
)
)
else
if
(
AVI_IndexLoad_idx1
(
p_
demux
)
)
{
/* try indx if idx1 failed as some "normal" file have indx too */
AVI_IndexLoad_indx
(
p_
input
);
AVI_IndexLoad_indx
(
p_
demux
);
}
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_track
;
i_stream
++
)
{
msg_Dbg
(
p_
input
,
"stream[%d] created %d index entries"
,
msg_Dbg
(
p_
demux
,
"stream[%d] created %d index entries"
,
i_stream
,
p_sys
->
track
[
i_stream
]
->
i_idxnb
);
}
}
static
void
AVI_IndexCreate
(
input_thread_t
*
p_input
)
static
void
AVI_IndexCreate
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
avi_chunk_list_t
*
p_riff
;
avi_chunk_list_t
*
p_movi
;
...
...
@@ -2115,7 +2086,7 @@ static void AVI_IndexCreate( input_thread_t *p_input )
if
(
!
p_movi
)
{
msg_Err
(
p_
input
,
"cannot find p_movi"
);
msg_Err
(
p_
demux
,
"cannot find p_movi"
);
return
;
}
...
...
@@ -2126,20 +2097,20 @@ static void AVI_IndexCreate( input_thread_t *p_input )
p_sys
->
track
[
i_stream
]
->
p_index
=
NULL
;
}
i_movi_end
=
__MIN
(
(
off_t
)(
p_movi
->
i_chunk_pos
+
p_movi
->
i_chunk_size
),
stream_Size
(
p_
input
->
s
)
);
stream_Size
(
p_
demux
->
s
)
);
stream_Seek
(
p_
input
->
s
,
p_movi
->
i_chunk_pos
+
12
);
msg_Warn
(
p_
input
,
"creating index from LIST-movi, will take time !"
);
stream_Seek
(
p_
demux
->
s
,
p_movi
->
i_chunk_pos
+
12
);
msg_Warn
(
p_
demux
,
"creating index from LIST-movi, will take time !"
);
for
(
;;
)
{
avi_packet_t
pk
;
if
(
p_
input
->
b_die
)
if
(
p_
demux
->
b_die
)
{
return
;
}
if
(
AVI_PacketGetHeader
(
p_
input
,
&
pk
)
)
if
(
AVI_PacketGetHeader
(
p_
demux
,
&
pk
)
)
{
break
;
}
...
...
@@ -2165,8 +2136,8 @@ static void AVI_IndexCreate( input_thread_t *p_input )
p_sysx
=
AVI_ChunkFind
(
&
p_sys
->
ck_root
,
AVIFOURCC_RIFF
,
1
);
msg_Dbg
(
p_
input
,
"looking for new RIFF chunk"
);
if
(
stream_Seek
(
p_
input
->
s
,
p_sysx
->
i_chunk_pos
+
24
))
msg_Dbg
(
p_
demux
,
"looking for new RIFF chunk"
);
if
(
stream_Seek
(
p_
demux
->
s
,
p_sysx
->
i_chunk_pos
+
24
))
{
goto
print_stat
;
}
...
...
@@ -2174,22 +2145,22 @@ static void AVI_IndexCreate( input_thread_t *p_input )
}
goto
print_stat
;
case
AVIFOURCC_RIFF
:
msg_Dbg
(
p_
input
,
"new RIFF chunk found"
);
msg_Dbg
(
p_
demux
,
"new RIFF chunk found"
);
case
AVIFOURCC_rec
:
case
AVIFOURCC_JUNK
:
break
;
default:
msg_Warn
(
p_
input
,
"need resync, probably broken avi"
);
if
(
AVI_PacketSearch
(
p_
input
)
)
msg_Warn
(
p_
demux
,
"need resync, probably broken avi"
);
if
(
AVI_PacketSearch
(
p_
demux
)
)
{
msg_Warn
(
p_
input
,
"lost sync, abord index creation"
);
msg_Warn
(
p_
demux
,
"lost sync, abord index creation"
);
goto
print_stat
;
}
}
}
if
(
(
!
p_sys
->
b_odml
&&
pk
.
i_pos
+
pk
.
i_size
>=
i_movi_end
)
||
AVI_PacketNext
(
p_
input
)
)
AVI_PacketNext
(
p_
demux
)
)
{
break
;
}
...
...
@@ -2198,7 +2169,7 @@ static void AVI_IndexCreate( input_thread_t *p_input )
print_stat:
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_track
;
i_stream
++
)
{
msg_Dbg
(
p_
input
,
msg_Dbg
(
p_
demux
,
"stream[%d] creating %d index entries"
,
i_stream
,
p_sys
->
track
[
i_stream
]
->
i_idxnb
);
...
...
@@ -2208,9 +2179,9 @@ print_stat:
/*****************************************************************************
* Stream management
*****************************************************************************/
static
int
AVI_TrackStopFinishedStreams
(
input_thread_t
*
p_input
)
static
int
AVI_TrackStopFinishedStreams
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
unsigned
int
i
;
int
b_end
=
VLC_TRUE
;
...
...
@@ -2220,7 +2191,7 @@ static int AVI_TrackStopFinishedStreams( input_thread_t *p_input )
if
(
tk
->
i_idxposc
>=
tk
->
i_idxnb
)
{
tk
->
b_activated
=
VLC_FALSE
;
es_out_Control
(
p_
input
->
p_es_
out
,
ES_OUT_SET_ES_STATE
,
tk
->
p_es
,
VLC_FALSE
);
es_out_Control
(
p_
demux
->
out
,
ES_OUT_SET_ES_STATE
,
tk
->
p_es
,
VLC_FALSE
);
}
else
{
...
...
@@ -2233,9 +2204,9 @@ static int AVI_TrackStopFinishedStreams( input_thread_t *p_input )
/****************************************************************************
* AVI_MovieGetLength give max streams length in second
****************************************************************************/
static
mtime_t
AVI_MovieGetLength
(
input_thread_t
*
p_input
)
static
mtime_t
AVI_MovieGetLength
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
mtime_t
i_maxlength
=
0
;
unsigned
int
i
;
...
...
@@ -2262,7 +2233,7 @@ static mtime_t AVI_MovieGetLength( input_thread_t *p_input )
}
i_length
/=
(
mtime_t
)
1000000
;
/* in seconds */
msg_Dbg
(
p_
input
,
msg_Dbg
(
p_
demux
,
"stream[%d] length:"
I64Fd
" (based on index)"
,
i
,
i_length
);
...
...
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