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
f2c5927d
Commit
f2c5927d
authored
May 06, 2002
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*ALL : ameliorations ( i hope ;)
parent
86614936
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
112 deletions
+112
-112
plugins/avi/avi.c
plugins/avi/avi.c
+60
-61
plugins/ffmpeg/ffmpeg.c
plugins/ffmpeg/ffmpeg.c
+52
-51
No files found.
plugins/avi/avi.c
View file @
f2c5927d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.1
2 2002/05/05 17:20:49
fenrir Exp $
* $Id: avi.c,v 1.1
3 2002/05/06 22:02:32
fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -286,7 +286,8 @@ static void __AVI_GetIndex( input_thread_t *p_input )
...
@@ -286,7 +286,8 @@ static void __AVI_GetIndex( input_thread_t *p_input )
intf_WarnMsg
(
1
,
"input init: loading index"
);
intf_WarnMsg
(
1
,
"input init: loading index"
);
for
(;;)
for
(;;)
{
{
if
(
((
i_read
=
input_Peek
(
p_input
,
&
p_buff
,
16
*
1024
))
<
16
)
i_read
=
__MIN
(
16
*
1024
,
p_idx1
->
i_size
-
i_totalentry
*
16
);
if
(
((
i_read
=
input_Peek
(
p_input
,
&
p_buff
,
i_read
))
<
16
)
||
(
i_totalentry
*
16
>=
p_idx1
->
i_size
)
)
||
(
i_totalentry
*
16
>=
p_idx1
->
i_size
)
)
{
{
intf_WarnMsg
(
1
,
"input info: read %d idx chunk"
,
i_totalentry
);
intf_WarnMsg
(
1
,
"input info: read %d idx chunk"
,
i_totalentry
);
...
@@ -321,7 +322,7 @@ static int __AVI_SeekToChunk( input_thread_t *p_input, AVIStreamInfo_t *p_info )
...
@@ -321,7 +322,7 @@ static int __AVI_SeekToChunk( input_thread_t *p_input, AVIStreamInfo_t *p_info )
demux_data_avi_file_t
*
p_avi_demux
;
demux_data_avi_file_t
*
p_avi_demux
;
p_avi_demux
=
(
demux_data_avi_file_t
*
)
p_input
->
p_demux_data
;
p_avi_demux
=
(
demux_data_avi_file_t
*
)
p_input
->
p_demux_data
;
if
(
(
p_info
->
p_index
!=
NULL
)
&&
(
p_info
->
i_idxposc
<
p_info
->
i_idxnb
)
)
if
(
(
p_info
->
p_index
)
&&
(
p_info
->
i_idxposc
<
p_info
->
i_idxnb
)
)
{
{
off_t
i_pos
;
off_t
i_pos
;
i_pos
=
(
off_t
)
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_offset
+
i_pos
=
(
off_t
)
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_offset
+
...
@@ -818,7 +819,6 @@ static int AVIInit( input_thread_t *p_input )
...
@@ -818,7 +819,6 @@ static int AVIInit( input_thread_t *p_input )
p_input
->
stream
.
p_selected_program
->
b_is_ok
=
1
;
p_input
->
stream
.
p_selected_program
->
b_is_ok
=
1
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
return
(
0
);
return
(
0
);
}
}
...
@@ -843,8 +843,9 @@ static mtime_t AVI_GetPTS( AVIStreamInfo_t *p_info )
...
@@ -843,8 +843,9 @@ static mtime_t AVI_GetPTS( AVIStreamInfo_t *p_info )
if
(
p_info
->
header
.
i_samplesize
!=
0
)
if
(
p_info
->
header
.
i_samplesize
!=
0
)
{
{
i_pts
=
(
mtime_t
)(
(
double
)
1000000
.
0
*
i_pts
=
(
mtime_t
)(
(
double
)
1000000
.
0
*
((
double
)
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_lengthtotal
+
(
double
)(
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_lengthtotal
+
(
double
)
p_info
->
i_idxposb
)
*
p_info
->
i_idxposb
-
p_info
->
p_index
[
p_info
->
header
.
i_initialframes
].
i_lengthtotal
)
*
(
double
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_rate
/
(
double
)
p_info
->
header
.
i_rate
/
(
double
)
p_info
->
header
.
i_samplesize
);
(
double
)
p_info
->
header
.
i_samplesize
);
...
@@ -852,7 +853,8 @@ static mtime_t AVI_GetPTS( AVIStreamInfo_t *p_info )
...
@@ -852,7 +853,8 @@ static mtime_t AVI_GetPTS( AVIStreamInfo_t *p_info )
else
else
{
{
i_pts
=
(
mtime_t
)(
(
double
)
1000000
.
0
*
i_pts
=
(
mtime_t
)(
(
double
)
1000000
.
0
*
(
double
)
p_info
->
i_idxposc
*
(
double
)(
p_info
->
i_idxposc
-
p_info
->
header
.
i_initialframes
)
*
(
double
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_rate
);
(
double
)
p_info
->
header
.
i_rate
);
}
}
...
@@ -890,6 +892,7 @@ static int __AVI_NextIndexEntry( input_thread_t *p_input,
...
@@ -890,6 +892,7 @@ static int __AVI_NextIndexEntry( input_thread_t *p_input,
the same things two time */
the same things two time */
/* search for the less advance stream and parse from it for all streams*/
/* search for the less advance stream and parse from it for all streams*/
p_info_tmp
=
p_info
;
p_info_tmp
=
p_info
;
/* XXX XXX XXX change to take the stream the more advanced */
for
(
i
=
0
;
i
<
p_avi_demux
->
i_streams
;
i
++
)
for
(
i
=
0
;
i
<
p_avi_demux
->
i_streams
;
i
++
)
{
{
...
@@ -1050,16 +1053,11 @@ static int __AVI_GoToStreamBytes( input_thread_t *p_input,
...
@@ -1050,16 +1053,11 @@ static int __AVI_GoToStreamBytes( input_thread_t *p_input,
while
(
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_lengthtotal
+
while
(
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_lengthtotal
+
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_length
<=
i_byte
)
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_length
<=
i_byte
)
{
{
intf_WarnMsg
(
1
,
"read 0"
);
if
(
__AVI_NextIndexEntry
(
p_input
,
p_info
)
!=
0
)
if
(
__AVI_NextIndexEntry
(
p_input
,
p_info
)
!=
0
)
{
{
return
(
-
1
);
return
(
-
1
);
}
}
intf_WarnMsg
(
1
,
"read 1"
);
}
}
}
}
else
else
{
{
...
@@ -1210,25 +1208,25 @@ static pes_packet_t *__AVI_ReadStreamBytesInPES( input_thread_t *p_input,
...
@@ -1210,25 +1208,25 @@ static pes_packet_t *__AVI_ReadStreamBytesInPES( input_thread_t *p_input,
static
__inline__
mtime_t
__AVI_PTSToChunk
(
AVIStreamInfo_t
*
p_info
,
static
__inline__
mtime_t
__AVI_PTSToChunk
(
AVIStreamInfo_t
*
p_info
,
mtime_t
i_pts
)
mtime_t
i_pts
)
{
{
return
(
(
mtime_t
)((
mtime_t
)
i_pts
*
return
(
(
mtime_t
)((
double
)
i_pts
*
(
mtime_t
)
p_info
->
header
.
i_rate
/
(
double
)
p_info
->
header
.
i_rate
/
(
mtime_t
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_scale
/
(
mtime_t
)
1000000
.
0
)
);
(
double
)
1000000
.
0
)
);
}
}
static
__inline__
mtime_t
__AVI_PTSToByte
(
AVIStreamInfo_t
*
p_info
,
static
__inline__
mtime_t
__AVI_PTSToByte
(
AVIStreamInfo_t
*
p_info
,
mtime_t
i_pts
)
mtime_t
i_pts
)
{
{
return
(
(
mtime_t
)((
mtime_t
)
i_pts
*
return
(
(
mtime_t
)((
double
)
i_pts
*
(
mtime_t
)
p_info
->
header
.
i_samplesize
*
(
double
)
p_info
->
header
.
i_samplesize
*
(
mtime_t
)
p_info
->
header
.
i_rate
/
(
double
)
p_info
->
header
.
i_rate
/
(
mtime_t
)
p_info
->
header
.
i_scale
/
(
double
)
p_info
->
header
.
i_scale
/
(
mtime_t
)
1000000
.
0
)
);
(
double
)
1000000
.
0
)
);
}
}
/* try to realign after a seek */
/* try to realign after a seek */
static
int
__
AVI_ReAlign
(
input_thread_t
*
p_input
)
static
int
AVI_ReAlign
(
input_thread_t
*
p_input
)
{
{
u32
u32_pos
;
u32
u32_pos
;
off_t
i_pos
;
off_t
i_pos
;
...
@@ -1245,16 +1243,24 @@ static int __AVI_ReAlign( input_thread_t *p_input )
...
@@ -1245,16 +1243,24 @@ static int __AVI_ReAlign( input_thread_t *p_input )
i_pos
=
(
off_t
)
u32_pos
-
(
off_t
)
p_info
->
i_idxoffset
;
i_pos
=
(
off_t
)
u32_pos
-
(
off_t
)
p_info
->
i_idxoffset
;
if
(
i_pos
<=
p_info
->
p_index
[
0
].
i_offset
)
if
(
i_pos
<=
p_info
->
p_index
[
p_info
->
header
.
i_initialframes
].
i_offset
)
{
{
/* before beginning of stream */
/* before beginning of stream */
if
(
!
p_info
->
header
.
i_samplesize
)
if
(
!
p_info
->
header
.
i_samplesize
)
{
{
__AVI_GoToStreamChunk
(
p_input
,
p_info
,
0
);
__AVI_GoToStreamChunk
(
p_input
,
p_info
,
p_info
->
header
.
i_initialframes
);
}
}
else
else
{
{
__AVI_GoToStreamBytes
(
p_input
,
p_info
,
0
);
__AVI_GoToStreamChunk
(
p_input
,
p_info
,
p_info
->
header
.
i_initialframes
);
__AVI_GoToStreamBytes
(
p_input
,
p_info
,
p_info
->
p_index
[
p_info
->
header
.
i_initialframes
].
i_lengthtotal
);
}
}
return
(
0
);
return
(
0
);
}
}
...
@@ -1276,7 +1282,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
...
@@ -1276,7 +1282,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
}
}
/* now find in what chunk we are */
/* now find in what chunk we are */
while
(
(
i_pos
<
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_offset
)
while
(
(
i_pos
<
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_offset
)
&&
(
p_info
->
i_idxposc
>
0
)
)
&&
(
p_info
->
i_idxposc
>
p_info
->
header
.
i_initialframes
)
)
{
{
/* search before i_idxposc */
/* search before i_idxposc */
p_info
->
i_idxposc
--
;
p_info
->
i_idxposc
--
;
...
@@ -1307,7 +1313,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
...
@@ -1307,7 +1313,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
}
}
else
else
{
{
while
(
(
p_info
->
i_idxposc
>
0
)
&&
while
(
(
p_info
->
i_idxposc
>
p_info
->
header
.
i_initialframes
)
&&
(
!
(
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_flags
&
AVIIF_KEYFRAME
))
)
(
!
(
p_info
->
p_index
[
p_info
->
i_idxposc
].
i_flags
&
AVIIF_KEYFRAME
))
)
{
{
p_info
->
i_idxposc
--
;
p_info
->
i_idxposc
--
;
...
@@ -1321,7 +1327,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
...
@@ -1321,7 +1327,7 @@ static int __AVI_ReAlign( input_thread_t *p_input )
/* update i_date and */
/* update i_date and */
/* make difference between audio and video pts as little as possible */
/* make difference between audio and video pts as little as possible */
static
void
__
AVI_SynchroReInit
(
input_thread_t
*
p_input
)
static
void
AVI_SynchroReInit
(
input_thread_t
*
p_input
)
{
{
demux_data_avi_file_t
*
p_avi_demux
;
demux_data_avi_file_t
*
p_avi_demux
;
...
@@ -1345,11 +1351,8 @@ static void __AVI_SynchroReInit( input_thread_t *p_input )
...
@@ -1345,11 +1351,8 @@ static void __AVI_SynchroReInit( input_thread_t *p_input )
if
(
p_avi_demux
->
p_info_audio
->
header
.
i_samplesize
==
0
)
if
(
p_avi_demux
->
p_info_audio
->
header
.
i_samplesize
==
0
)
{
{
int
i_chunk
=
__AVI_PTSToChunk
(
p_avi_demux
->
p_info_audio
,
int
i_chunk
=
__AVI_PTSToChunk
(
p_avi_demux
->
p_info_audio
,
AVI_GetPTS
(
p_avi_demux
->
p_info_video
));
AVI_GetPTS
(
p_avi_demux
->
p_info_video
))
+
if
(
i_chunk
<
0
)
p_avi_demux
->
p_info_audio
->
header
.
i_initialframes
;
{
i_chunk
=
0
;
}
__AVI_GoToStreamChunk
(
p_input
,
__AVI_GoToStreamChunk
(
p_input
,
p_avi_demux
->
p_info_audio
,
p_avi_demux
->
p_info_audio
,
i_chunk
);
i_chunk
);
...
@@ -1357,18 +1360,15 @@ static void __AVI_SynchroReInit( input_thread_t *p_input )
...
@@ -1357,18 +1360,15 @@ static void __AVI_SynchroReInit( input_thread_t *p_input )
else
else
{
{
int
i_byte
=
__AVI_PTSToByte
(
p_avi_demux
->
p_info_audio
,
int
i_byte
=
__AVI_PTSToByte
(
p_avi_demux
->
p_info_audio
,
AVI_GetPTS
(
p_avi_demux
->
p_info_video
)
);
AVI_GetPTS
(
p_avi_demux
->
p_info_video
)
)
+
if
(
i_byte
<
0
)
p_avi_demux
->
p_info_audio
->
p_index
[
p_avi_demux
->
p_info_audio
->
header
.
i_initialframes
].
i_lengthtotal
;
{
i_byte
=
0
;
}
__AVI_GoToStreamBytes
(
p_input
,
__AVI_GoToStreamBytes
(
p_input
,
p_avi_demux
->
p_info_audio
,
p_avi_demux
->
p_info_audio
,
i_byte
);
i_byte
);
}
}
}
}
}
}
}
}
static
pes_packet_t
*
AVI_GetFrameInPES
(
input_thread_t
*
p_input
,
static
pes_packet_t
*
AVI_GetFrameInPES
(
input_thread_t
*
p_input
,
...
@@ -1384,22 +1384,17 @@ static pes_packet_t *AVI_GetFrameInPES( input_thread_t *p_input,
...
@@ -1384,22 +1384,17 @@ static pes_packet_t *AVI_GetFrameInPES( input_thread_t *p_input,
p_avi_demux
=
(
demux_data_avi_file_t
*
)
p_input
->
p_demux_data
;
p_avi_demux
=
(
demux_data_avi_file_t
*
)
p_input
->
p_demux_data
;
if
(
(
!
p_info
)
||
(
i_dpts
<
0
)
)
if
(
(
!
p_info
)
||
(
i_dpts
<
100
0
)
)
{
{
return
(
NULL
)
;
return
(
NULL
)
;
}
}
/* if i_pts is too small use 50 ms */
if
(
i_dpts
<=
50000
)
{
i_dpts
=
50000
;
/* 50 ms by default */
}
if
(
!
p_info
->
header
.
i_samplesize
)
if
(
!
p_info
->
header
.
i_samplesize
)
{
{
/* stream is chunk based , easy */
/* stream is chunk based , easy */
int
i_chunk
=
__
MAX
(
__AVI_PTSToChunk
(
p_info
,
i_dpts
)
,
1
);
int
i_chunk
=
__
AVI_PTSToChunk
(
p_info
,
i_dpts
);
/* at least one frame */
/* at least one frame */
i_chunk
=
__MIN
(
20
,
i_chunk
);
/* but no more than 20 */
/* i_chunk = __MIN( 50, i_chunk ); */
/* but no more than 20 */
/* read them */
/* read them */
p_pes_first
=
NULL
;
p_pes_first
=
NULL
;
for
(
i
=
0
;
i
<
i_chunk
;
i
++
)
for
(
i
=
0
;
i
<
i_chunk
;
i
++
)
...
@@ -1427,9 +1422,13 @@ static pes_packet_t *AVI_GetFrameInPES( input_thread_t *p_input,
...
@@ -1427,9 +1422,13 @@ static pes_packet_t *AVI_GetFrameInPES( input_thread_t *p_input,
else
else
{
{
/* stream is byte based */
/* stream is byte based */
int
i_byte
=
__MAX
(
__AVI_PTSToByte
(
p_info
,
i_dpts
),
1024
);
int
i_byte
=
__AVI_PTSToByte
(
p_info
,
i_dpts
);
if
(
!
i_byte
)
{
return
(
NULL
);
}
/* at least one Kbyte */
/* at least one Kbyte */
i_byte
=
__MIN
(
1024
*
1000
,
i_byte
);
/* but no more than 1000ko */
/*i_byte = __MIN( 1024*1000, i_byte ); */
/* but no more than 1000ko */
i_pts
=
AVI_GetPTS
(
p_info
);
i_pts
=
AVI_GetPTS
(
p_info
);
p_pes
=
__AVI_ReadStreamBytesInPES
(
p_input
,
p_info
,
i_byte
);
p_pes
=
__AVI_ReadStreamBytesInPES
(
p_input
,
p_info
,
i_byte
);
...
@@ -1469,7 +1468,7 @@ static void AVI_DecodePES( AVIStreamInfo_t *p_info,
...
@@ -1469,7 +1468,7 @@ static void AVI_DecodePES( AVIStreamInfo_t *p_info,
(
mtime_t
)
DEFAULT_RATE
;
(
mtime_t
)
DEFAULT_RATE
;
input_DecodePES
(
p_info
->
p_es
->
p_decoder_fifo
,
p_pes
);
input_DecodePES
(
p_info
->
p_es
->
p_decoder_fifo
,
p_pes
);
p_pes
=
p_pes_next
;
p_pes
=
p_pes_next
;
}
while
(
p_pes
!=
NULL
);
}
while
(
p_pes
);
}
}
...
@@ -1540,7 +1539,7 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1540,7 +1539,7 @@ static int AVIDemux( input_thread_t *p_input )
if
(
!
p_info_master
)
if
(
!
p_info_master
)
{
{
intf_ErrMsg
(
"input error: stream selected"
);
intf_ErrMsg
(
"input error:
no
stream selected"
);
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -1548,7 +1547,7 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1548,7 +1547,7 @@ static int AVIDemux( input_thread_t *p_input )
if
(
(
input_ClockManageControl
(
p_input
,
p_input
->
stream
.
p_selected_program
,
if
(
(
input_ClockManageControl
(
p_input
,
p_input
->
stream
.
p_selected_program
,
(
mtime_t
)
0
)
==
PAUSE_S
)
)
(
mtime_t
)
0
)
==
PAUSE_S
)
)
{
{
__
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
and video egual */
and video egual */
p_avi_demux
->
i_rate
=
DEFAULT_RATE
;
p_avi_demux
->
i_rate
=
DEFAULT_RATE
;
}
}
...
@@ -1556,13 +1555,13 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1556,13 +1555,13 @@ static int AVIDemux( input_thread_t *p_input )
if
(
p_input
->
stream
.
p_selected_program
->
i_synchro_state
==
SYNCHRO_REINIT
)
if
(
p_input
->
stream
.
p_selected_program
->
i_synchro_state
==
SYNCHRO_REINIT
)
{
{
/* wait until buffer is empty */
/* wait until buffer is empty */
msleep
(
2
*
DEFAULT_PTS_DELAY
);
msleep
(
3
*
DEFAULT_PTS_DELAY
);
/*realign audio and video stream to the good pts*/
/*realign audio and video stream to the good pts*/
if
(
__
AVI_ReAlign
(
p_input
)
!=
0
)
if
(
AVI_ReAlign
(
p_input
)
!=
0
)
{
{
return
(
0
);
/* assume EOF */
return
(
0
);
/* assume EOF */
}
}
__
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
and video egual */
and video egual */
p_avi_demux
->
i_rate
=
DEFAULT_RATE
;
p_avi_demux
->
i_rate
=
DEFAULT_RATE
;
}
}
...
@@ -1571,7 +1570,7 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1571,7 +1570,7 @@ static int AVIDemux( input_thread_t *p_input )
if
(
(
p_input
->
stream
.
control
.
i_rate
!=
p_avi_demux
->
i_rate
)
if
(
(
p_input
->
stream
.
control
.
i_rate
!=
p_avi_demux
->
i_rate
)
&&
(
p_info_master
->
i_cat
==
VIDEO_ES
)
)
&&
(
p_info_master
->
i_cat
==
VIDEO_ES
)
)
{
{
msleep
(
2
*
DEFAULT_PTS_DELAY
);
msleep
(
3
*
DEFAULT_PTS_DELAY
);
p_avi_demux
->
i_rate
=
p_input
->
stream
.
control
.
i_rate
;
p_avi_demux
->
i_rate
=
p_input
->
stream
.
control
.
i_rate
;
p_avi_demux
->
i_date
=
mdate
()
+
DEFAULT_PTS_DELAY
p_avi_demux
->
i_date
=
mdate
()
+
DEFAULT_PTS_DELAY
-
AVI_GetPTS
(
p_info_master
)
*
-
AVI_GetPTS
(
p_info_master
)
*
...
@@ -1595,13 +1594,13 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1595,13 +1594,13 @@ static int AVIDemux( input_thread_t *p_input )
if
(
p_info_master
->
b_selected
)
if
(
p_info_master
->
b_selected
)
{
{
p_info_master
->
b_selected
=
0
;
p_info_master
->
b_selected
=
0
;
__
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
AVI_SynchroReInit
(
p_input
);
/* resynchro, and make pts audio
and video equal */
and video equal */
}
}
if
(
(
p_info_slave
)
&&
(
p_info_slave
->
b_selected
)
)
if
(
(
p_info_slave
)
&&
(
p_info_slave
->
b_selected
)
)
{
{
p_info_slave
->
b_selected
=
0
;
p_info_slave
->
b_selected
=
0
;
__
AVI_SynchroReInit
(
p_input
);
AVI_SynchroReInit
(
p_input
);
}
}
/* get audio and video frame */
/* get audio and video frame */
...
@@ -1613,7 +1612,7 @@ static int AVIDemux( input_thread_t *p_input )
...
@@ -1613,7 +1612,7 @@ static int AVIDemux( input_thread_t *p_input )
p_pes_slave
=
AVI_GetFrameInPES
(
p_input
,
p_pes_slave
=
AVI_GetFrameInPES
(
p_input
,
p_info_slave
,
p_info_slave
,
AVI_GetPTS
(
p_info_master
)
-
AVI_GetPTS
(
p_info_master
)
-
AVI_GetPTS
(
p_info_slave
)
+
10000
);
AVI_GetPTS
(
p_info_slave
));
/* decode it first because video will make us wait */
/* decode it first because video will make us wait */
AVI_DecodePES
(
p_info_slave
,
AVI_DecodePES
(
p_info_slave
,
p_pes_slave
,
p_pes_slave
,
...
...
plugins/ffmpeg/ffmpeg.c
View file @
f2c5927d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library
* ffmpeg.c: video decoder using ffmpeg library
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.
4 2002/05/05 17:20:49
fenrir Exp $
* $Id: ffmpeg.c,v 1.
5 2002/05/06 22:02:32
fenrir Exp $
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
...
@@ -156,7 +156,7 @@ static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
...
@@ -156,7 +156,7 @@ static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
vlc_mutex_lock
(
&
p_fifo
->
data_lock
);
vlc_mutex_lock
(
&
p_fifo
->
data_lock
);
/* if fifo is emty wait */
/* if fifo is emty wait */
while
(
p_fifo
->
p_first
==
NULL
)
while
(
!
p_fifo
->
p_first
)
{
{
if
(
p_fifo
->
b_die
)
if
(
p_fifo
->
b_die
)
{
{
...
@@ -184,12 +184,12 @@ static void __PES_NEXT( decoder_fifo_t *p_fifo )
...
@@ -184,12 +184,12 @@ static void __PES_NEXT( decoder_fifo_t *p_fifo )
p_fifo
->
p_first
=
p_next
;
p_fifo
->
p_first
=
p_next
;
p_fifo
->
i_depth
--
;
p_fifo
->
i_depth
--
;
if
(
p_fifo
->
p_first
==
NULL
)
if
(
!
p_fifo
->
p_first
)
{
{
/* No PES in the fifo */
/* No PES in the fifo */
/* pp_last no longer valid */
/* pp_last no longer valid */
p_fifo
->
pp_last
=
&
p_fifo
->
p_first
;
p_fifo
->
pp_last
=
&
p_fifo
->
p_first
;
while
(
p_fifo
->
p_first
==
NULL
)
while
(
!
p_fifo
->
p_first
)
{
{
vlc_cond_signal
(
&
p_fifo
->
data_wait
);
vlc_cond_signal
(
&
p_fifo
->
data_wait
);
vlc_cond_wait
(
&
p_fifo
->
data_wait
,
&
p_fifo
->
data_lock
);
vlc_cond_wait
(
&
p_fifo
->
data_wait
,
&
p_fifo
->
data_lock
);
...
@@ -218,7 +218,7 @@ static void __PACKET_NEXT( videodec_thread_t *p_vdec )
...
@@ -218,7 +218,7 @@ static void __PACKET_NEXT( videodec_thread_t *p_vdec )
do
do
{
{
p_vdec
->
p_data
=
p_vdec
->
p_data
->
p_next
;
p_vdec
->
p_data
=
p_vdec
->
p_data
->
p_next
;
if
(
p_vdec
->
p_data
==
NULL
)
if
(
!
p_vdec
->
p_data
)
{
{
__PES_NEXT
(
p_vdec
->
p_fifo
);
__PES_NEXT
(
p_vdec
->
p_fifo
);
if
(
p_vdec
->
p_fifo
->
b_die
)
if
(
p_vdec
->
p_fifo
->
b_die
)
...
@@ -249,20 +249,24 @@ static void __PACKET_FILL( videodec_thread_t *p_vdec )
...
@@ -249,20 +249,24 @@ static void __PACKET_FILL( videodec_thread_t *p_vdec )
static
__inline__
void
__ConvertAVPictureToPicture
(
AVPicture
*
p_avpicture
,
static
__inline__
void
__ConvertAVPictureToPicture
(
AVPicture
*
p_avpicture
,
picture_t
*
p_picture
)
picture_t
*
p_picture
)
{
{
int
i_plane
,
i_line
;
int
i_plane
,
i_line
,
i_inc
;
u8
*
p_dest
,
*
p_src
;
u8
*
p_dest
,
*
p_src
;
for
(
i_plane
=
0
;
i_plane
<
p_picture
->
i_planes
;
i_plane
++
)
for
(
i_plane
=
0
;
i_plane
<
__MIN
(
p_picture
->
i_planes
,
3
)
;
i_plane
++
)
{
{
p_dest
=
p_picture
->
p
[
i_plane
].
p_pixels
;
p_dest
=
p_picture
->
p
[
i_plane
].
p_pixels
;
p_src
=
p_avpicture
->
data
[
i_plane
];
p_src
=
p_avpicture
->
data
[
i_plane
];
if
(
(
p_dest
==
NULL
)
||
(
p_src
==
NULL
)
||
(
i_plane
>=
3
)
)
{
return
;
}
if
(
(
!
p_dest
)
||
(
!
p_src
))
{
return
;
}
i_inc
=
__MIN
(
p_picture
->
p
[
i_plane
].
i_pitch
,
p_avpicture
->
linesize
[
i_plane
]
);
for
(
i_line
=
0
;
i_line
<
p_picture
->
p
[
i_plane
].
i_lines
;
i_line
++
)
for
(
i_line
=
0
;
i_line
<
p_picture
->
p
[
i_plane
].
i_lines
;
i_line
++
)
{
{
FAST_MEMCPY
(
p_dest
,
FAST_MEMCPY
(
p_dest
,
p_src
,
p_src
,
__MIN
(
p_picture
->
p
[
i_plane
].
i_pitch
,
i_inc
);
p_avpicture
->
linesize
[
i_plane
]
)
);
p_dest
+=
p_picture
->
p
[
i_plane
].
i_pitch
;
p_dest
+=
p_picture
->
p
[
i_plane
].
i_pitch
;
p_src
+=
p_avpicture
->
linesize
[
i_plane
];
p_src
+=
p_avpicture
->
linesize
[
i_plane
];
}
}
...
@@ -278,14 +282,12 @@ static __inline__ u32 __FfmpegChromaToFourCC( int i_ffmpegchroma )
...
@@ -278,14 +282,12 @@ static __inline__ u32 __FfmpegChromaToFourCC( int i_ffmpegchroma )
return
FOURCC_I420
;
return
FOURCC_I420
;
case
(
PIX_FMT_RGB24
):
case
(
PIX_FMT_RGB24
):
return
FOURCC_RV24
;
return
FOURCC_RV24
;
case
(
PIX_FMT_BGR24
):
return
0
;
/* FIXME pas trouv ds video.h */
case
(
PIX_FMT_YUV422P
):
case
(
PIX_FMT_YUV422P
):
return
FOURCC_Y422
;
return
FOURCC_Y422
;
case
(
PIX_FMT_YUV444P
):
case
(
PIX_FMT_YUV444P
):
return
0
;
/* FIXME pas trouv FOURCC_IYU2; */
case
(
PIX_FMT_BGR24
):
default:
default:
return
0
;
return
(
0
)
;
}
}
}
}
...
@@ -383,11 +385,11 @@ static int InitThread( videodec_thread_t *p_vdec )
...
@@ -383,11 +385,11 @@ static int InitThread( videodec_thread_t *p_vdec )
break
;
break
;
case
(
MSMPEG4_VIDEO_ES
):
case
(
MSMPEG4_VIDEO_ES
):
p_vdec
->
p_codec
=
avcodec_find_decoder
(
CODEC_ID_MSMPEG4
);
p_vdec
->
p_codec
=
avcodec_find_decoder
(
CODEC_ID_MSMPEG4
);
p_vdec
->
psz_namecodec
=
"MS MPEG-4"
;
p_vdec
->
psz_namecodec
=
"MS MPEG-4
/divx
"
;
break
;
break
;
case
(
MPEG4_VIDEO_ES
):
case
(
MPEG4_VIDEO_ES
):
p_vdec
->
p_codec
=
avcodec_find_decoder
(
CODEC_ID_MPEG4
);
p_vdec
->
p_codec
=
avcodec_find_decoder
(
CODEC_ID_MPEG4
);
p_vdec
->
psz_namecodec
=
"MPEG-4"
;
p_vdec
->
psz_namecodec
=
"MPEG-4
/opendivx
"
;
break
;
break
;
default:
default:
p_vdec
->
p_codec
=
NULL
;
p_vdec
->
p_codec
=
NULL
;
...
@@ -419,7 +421,17 @@ static int InitThread( videodec_thread_t *p_vdec )
...
@@ -419,7 +421,17 @@ static int InitThread( videodec_thread_t *p_vdec )
intf_WarnMsg
(
1
,
"vdec info: ffmpeg codec (%s) started"
,
intf_WarnMsg
(
1
,
"vdec info: ffmpeg codec (%s) started"
,
p_vdec
->
psz_namecodec
);
p_vdec
->
psz_namecodec
);
}
}
/* destroy each p_vout */
vlc_mutex_lock
(
&
p_vout_bank
->
lock
);
if
(
p_vout_bank
->
i_count
!=
0
)
{
vlc_mutex_unlock
(
&
p_vout_bank
->
lock
);
vout_DestroyThread
(
p_vout_bank
->
pp_vout
[
0
],
NULL
);
p_vout_bank
->
i_count
--
;
p_vout_bank
->
pp_vout
[
0
]
=
NULL
;
vlc_mutex_lock
(
&
p_vout_bank
->
lock
);
}
vlc_mutex_unlock
(
&
p_vout_bank
->
lock
);
__PACKET_REINIT
(
p_vdec
);
__PACKET_REINIT
(
p_vdec
);
return
(
0
);
return
(
0
);
}
}
...
@@ -445,10 +457,15 @@ static void EndThread( videodec_thread_t *p_vdec )
...
@@ -445,10 +457,15 @@ static void EndThread( videodec_thread_t *p_vdec )
p_vdec
->
psz_namecodec
);
p_vdec
->
psz_namecodec
);
}
}
if
(
p_v
dec
->
p_vout
!=
NULL
)
if
(
p_v
out_bank
->
i_count
!=
0
)
{
{
vout_DestroyThread
(
p_vdec
->
p_vout
,
NULL
);
vlc_mutex_unlock
(
&
p_vout_bank
->
lock
);
vout_DestroyThread
(
p_vout_bank
->
pp_vout
[
0
],
NULL
);
p_vout_bank
->
i_count
--
;
p_vout_bank
->
pp_vout
[
0
]
=
NULL
;
vlc_mutex_lock
(
&
p_vout_bank
->
lock
);
}
}
vlc_mutex_unlock
(
&
p_vout_bank
->
lock
);
free
(
p_vdec
);
free
(
p_vdec
);
}
}
...
@@ -459,7 +476,6 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -459,7 +476,6 @@ static void DecodeThread( videodec_thread_t *p_vdec )
int
b_gotpicture
;
int
b_gotpicture
;
int
b_convert
;
int
b_convert
;
mtime_t
i_pts
;
mtime_t
i_pts
;
pes_packet_t
*
p_pes
;
AVPicture
avpicture
;
/* ffmpeg picture */
AVPicture
avpicture
;
/* ffmpeg picture */
u32
i_chroma
;
u32
i_chroma
;
picture_t
*
p_picture
;
/* videolan picture */
picture_t
*
p_picture
;
/* videolan picture */
...
@@ -467,16 +483,8 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -467,16 +483,8 @@ static void DecodeThread( videodec_thread_t *p_vdec )
give it to ffmpeg decoder
give it to ffmpeg decoder
and send the image to the output */
and send the image to the output */
/* when we have the first image we create the video output */
/* when we have the first image we create the video output */
/* int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
int *got_picture_ptr,
i_pts
=
0
;
UINT8 *buf, int buf_size);
typedef struct AVPicture
{
UINT8 *data[3];
int linesize[3];
} AVPicture;
*/
i_pts
=
-
1
;
do
do
{
{
__PACKET_FILL
(
p_vdec
);
__PACKET_FILL
(
p_vdec
);
...
@@ -485,7 +493,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -485,7 +493,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
return
;
return
;
}
}
/* save pts */
/* save pts */
if
(
i_pts
<
0
)
{
i_pts
=
__PES_GET
(
p_vdec
->
p_fifo
)
->
i_pts
;}
if
(
!
i_pts
)
{
i_pts
=
__PES_GET
(
p_vdec
->
p_fifo
)
->
i_pts
;}
i_len
=
avcodec_decode_video
(
p_vdec
->
p_context
,
i_len
=
avcodec_decode_video
(
p_vdec
->
p_context
,
&
avpicture
,
&
avpicture
,
...
@@ -495,7 +503,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -495,7 +503,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
if
(
i_len
<
0
)
if
(
i_len
<
0
)
{
{
intf_WarnMsg
(
1
,
"vdec error: cannot decode one frame (%d bytes)"
,
intf_WarnMsg
(
3
,
"vdec error: cannot decode one frame (%d bytes)"
,
p_vdec
->
i_data_size
);
p_vdec
->
i_data_size
);
__PES_NEXT
(
p_vdec
->
p_fifo
);
__PES_NEXT
(
p_vdec
->
p_fifo
);
__PACKET_REINIT
(
p_vdec
);
__PACKET_REINIT
(
p_vdec
);
...
@@ -505,8 +513,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -505,8 +513,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
p_vdec
->
p_buff
+=
i_len
;
p_vdec
->
p_buff
+=
i_len
;
}
while
(
!
b_gotpicture
);
}
while
(
!
b_gotpicture
);
i_chroma
=
__FfmpegChromaToFourCC
(
p_vdec
->
p_context
->
pix_fmt
);
if
(
!
(
i_chroma
=
__FfmpegChromaToFourCC
(
p_vdec
->
p_context
->
pix_fmt
)
)
)
if
(
i_chroma
==
0
)
{
{
b_convert
=
1
;
b_convert
=
1
;
i_chroma
=
FOURCC_I420
;
i_chroma
=
FOURCC_I420
;
...
@@ -517,17 +524,12 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -517,17 +524,12 @@ static void DecodeThread( videodec_thread_t *p_vdec )
}
}
/* Send decoded frame to vout */
/* Send decoded frame to vout */
if
(
p_vdec
->
p_vout
==
NULL
)
if
(
!
p_vdec
->
p_vout
)
{
{
/* FIXME FIXME faire ca comme il faut avec :
* pp_vout_bank
* bon aspect, ds avi pas definie mais pour le reste a voir ...
*/
/* create vout */
/* create vout */
/* ffmpeg set it for our with some codec */
/* ffmpeg set it for our with some codec */
if
(
(
p_vdec
->
format
.
i_width
==
0
)
||
(
p_vdec
->
format
.
i_height
==
0
)
)
if
(
(
!
p_vdec
->
format
.
i_width
)
||
(
!
p_vdec
->
format
.
i_height
)
)
{
{
p_vdec
->
format
.
i_width
=
p_vdec
->
p_context
->
width
;
p_vdec
->
format
.
i_width
=
p_vdec
->
p_context
->
width
;
p_vdec
->
format
.
i_height
=
p_vdec
->
p_context
->
height
;
p_vdec
->
format
.
i_height
=
p_vdec
->
p_context
->
height
;
...
@@ -537,12 +539,6 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -537,12 +539,6 @@ static void DecodeThread( videodec_thread_t *p_vdec )
p_vdec
->
format
.
i_height
;
p_vdec
->
format
.
i_height
;
p_vdec
->
i_chroma
=
i_chroma
;
p_vdec
->
i_chroma
=
i_chroma
;
intf_WarnMsg
(
1
,
"vdec info: creating vout %dx%d chroma %4.4s %s"
,
p_vdec
->
format
.
i_width
,
p_vdec
->
format
.
i_height
,
(
char
*
)
&
p_vdec
->
i_chroma
,
b_convert
?
"(with convertion)"
:
""
);
p_vdec
->
p_vout
=
vout_CreateThread
(
p_vdec
->
p_vout
=
vout_CreateThread
(
NULL
,
NULL
,
p_vdec
->
format
.
i_width
,
p_vdec
->
format
.
i_width
,
...
@@ -550,12 +546,17 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -550,12 +546,17 @@ static void DecodeThread( videodec_thread_t *p_vdec )
p_vdec
->
i_chroma
,
p_vdec
->
i_chroma
,
p_vdec
->
i_aspect
);
p_vdec
->
i_aspect
);
if
(
p_vdec
->
p_vout
==
NULL
)
if
(
!
p_vdec
->
p_vout
)
{
{
intf_ErrMsg
(
"vdec error: can't open vout, aborting"
);
intf_ErrMsg
(
"vdec error: can't open vout, aborting"
);
p_vdec
->
p_fifo
->
b_error
=
1
;
p_vdec
->
p_fifo
->
b_error
=
1
;
return
;
return
;
}
}
vlc_mutex_lock
(
&
p_vout_bank
->
lock
);
p_vout_bank
->
pp_vout
[
0
]
=
p_vdec
->
p_vout
;
p_vout_bank
->
i_count
++
;
vlc_mutex_unlock
(
&
p_vout_bank
->
lock
);
}
}
while
(
(
p_picture
=
vout_CreatePicture
(
p_vdec
->
p_vout
,
while
(
(
p_picture
=
vout_CreatePicture
(
p_vdec
->
p_vout
,
...
@@ -571,7 +572,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
...
@@ -571,7 +572,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
msleep
(
VOUT_OUTMEM_SLEEP
);
msleep
(
VOUT_OUTMEM_SLEEP
);
}
}
if
(
b_convert
==
1
)
if
(
b_convert
)
{
{
/* we convert in a supported format */
/* we convert in a supported format */
int
i_status
;
int
i_status
;
...
...
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