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
08ece243
Commit
08ece243
authored
Mar 03, 2004
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* a52.c aac.c au.c dts.c flac.c wav.c: Converted all audio only demuxers
to demux2.
parent
ae60413f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
390 additions
and
569 deletions
+390
-569
modules/demux/a52.c
modules/demux/a52.c
+82
-121
modules/demux/aac.c
modules/demux/aac.c
+62
-67
modules/demux/au.c
modules/demux/au.c
+4
-70
modules/demux/dts.c
modules/demux/dts.c
+90
-134
modules/demux/flac.c
modules/demux/flac.c
+62
-68
modules/demux/wav.c
modules/demux/wav.c
+90
-109
No files found.
modules/demux/a52.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* a52.c : raw A/52 stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52.c,v 1.
6 2004/02/25 17:48:52
fenrir Exp $
* $Id: a52.c,v 1.
7 2004/03/03 11:40:19
fenrir Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
...
...
@@ -32,18 +32,24 @@
# include <unistd.h>
#endif
#define PCM_FRAME_SIZE (1536 * 4)
#define A52_PACKET_SIZE (4 * PCM_FRAME_SIZE)
#define A52_MAX_HEADER_SIZE 10
/*****************************************************************************
*
Local prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
int
Demux
(
input_thread_t
*
);
static
int
Control
(
input_thread_t
*
,
int
,
va_list
);
vlc_module_begin
();
set_description
(
_
(
"Raw A/52 demuxer"
)
);
set_capability
(
"demux2"
,
145
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"a52"
);
vlc_module_end
();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
struct
demux_sys_t
{
...
...
@@ -57,63 +63,33 @@ struct demux_sys_t
vlc_bool_t
b_big_endian
;
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Raw A/52 demuxer"
)
);
set_capability
(
"demux"
,
145
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"a52"
);
vlc_module_end
();
static
int
CheckSync
(
uint8_t
*
p_peek
,
vlc_bool_t
*
p_big_endian
);
/*****************************************************************************
* CheckSync: Check if buffer starts with an A52 sync code
*****************************************************************************/
static
int
CheckSync
(
uint8_t
*
p_peek
,
vlc_bool_t
*
p_big_endian
)
{
/* Little endian version of the bitstream */
if
(
p_peek
[
0
]
==
0x77
&&
p_peek
[
1
]
==
0x0b
&&
p_peek
[
4
]
<
0x60
/* bsid < 12 */
)
{
*
p_big_endian
=
VLC_FALSE
;
return
VLC_SUCCESS
;
}
/* Big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x0b
&&
p_peek
[
1
]
==
0x77
&&
p_peek
[
5
]
<
0x60
/* bsid < 12 */
)
{
*
p_big_endian
=
VLC_TRUE
;
return
VLC_SUCCESS
;
}
#define PCM_FRAME_SIZE (1536 * 4)
#define A52_PACKET_SIZE (4 * PCM_FRAME_SIZE)
#define A52_MAX_HEADER_SIZE 10
return
VLC_EGENERIC
;
}
/*****************************************************************************
* Open: initializes ES structures
*****************************************************************************/
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
;
byte_t
*
p_peek
;
byte_t
*
p_peek
;
int
i_peek
=
0
;
vlc_bool_t
b_big_endian
;
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux_control
=
Control
;
p_input
->
pf_rewind
=
NULL
;
/* Check if we are dealing with a WAV file */
if
(
input_Peek
(
p_input
,
&
p_peek
,
12
)
==
12
&&
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
12
)
==
12
&&
!
strncmp
(
p_peek
,
"RIFF"
,
4
)
&&
!
strncmp
(
&
p_peek
[
8
],
"WAVE"
,
4
)
)
{
int
i_size
;
/* Skip the wave header */
i_peek
=
12
+
8
;
while
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
)
==
i_peek
&&
while
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
)
==
i_peek
&&
strncmp
(
p_peek
+
i_peek
-
8
,
"data"
,
4
)
)
{
i_peek
+=
GetDWLE
(
p_peek
+
i_peek
-
4
)
+
8
;
...
...
@@ -123,7 +99,7 @@ static int Open( vlc_object_t * p_this )
/* Some A52 wav files don't begin with a sync code so we do a more
* extensive search */
i_size
=
input_Peek
(
p_input
,
&
p_peek
,
i_peek
+
A52_PACKET_SIZE
*
2
);
i_size
=
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
+
A52_PACKET_SIZE
*
2
);
i_size
-=
(
PCM_FRAME_SIZE
+
A52_MAX_HEADER_SIZE
);
while
(
i_peek
<
i_size
)
...
...
@@ -147,29 +123,30 @@ static int Open( vlc_object_t * p_this )
}
/* Have a peep at the show. */
if
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
+
A52_MAX_HEADER_SIZE
*
2
)
<
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
+
A52_MAX_HEADER_SIZE
*
2
)
<
i_peek
+
A52_MAX_HEADER_SIZE
*
2
)
{
/* Stream too short */
msg_Warn
(
p_
input
,
"cannot peek()"
);
msg_Warn
(
p_
demux
,
"cannot peek()"
);
return
VLC_EGENERIC
;
}
if
(
CheckSync
(
p_peek
+
i_peek
,
&
b_big_endian
)
!=
VLC_SUCCESS
)
{
if
(
p_input
->
psz_demux
&&
!
strncmp
(
p_input
->
psz_demux
,
"a52"
,
3
)
)
{
/* User forced */
msg_Err
(
p_input
,
"this doesn't look like a A52 audio stream, "
"continuing anyway"
);
}
else
if
(
strncmp
(
p_demux
->
psz_demux
,
"a52"
,
3
)
)
{
return
VLC_EGENERIC
;
}
/* User forced */
msg_Err
(
p_demux
,
"this doesn't look like a A52 audio stream, "
"continuing anyway"
);
}
p_input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
/* Fill p_demux fields */
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
->
b_start
=
VLC_TRUE
;
p_sys
->
i_mux_rate
=
0
;
p_sys
->
b_big_endian
=
b_big_endian
;
...
...
@@ -177,7 +154,7 @@ static int Open( vlc_object_t * p_this )
/*
* Load the A52 packetizer
*/
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
input
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
demux
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
->
pf_decode_audio
=
0
;
p_sys
->
p_packetizer
->
pf_decode_video
=
0
;
p_sys
->
p_packetizer
->
pf_decode_sub
=
0
;
...
...
@@ -191,23 +168,12 @@ static int Open( vlc_object_t * p_this )
module_Need
(
p_sys
->
p_packetizer
,
"packetizer"
,
NULL
);
if
(
!
p_sys
->
p_packetizer
->
p_module
)
{
msg_Err
(
p_
input
,
"cannot find A52 packetizer"
);
msg_Err
(
p_
demux
,
"cannot find A52 packetizer"
);
return
VLC_EGENERIC
;
}
/* 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"
);
return
VLC_EGENERIC
;
}
p_input
->
stream
.
i_mux_rate
=
0
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
p_sys
->
p_es
=
es_out_Add
(
p_input
->
p_es_out
,
&
p_sys
->
p_packetizer
->
fmt_in
);
p_sys
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
p_sys
->
p_packetizer
->
fmt_in
);
return
VLC_SUCCESS
;
}
...
...
@@ -217,8 +183,8 @@ static int Open( vlc_object_t * p_this )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
/* Unneed module */
module_Unneed
(
p_sys
->
p_packetizer
,
p_sys
->
p_packetizer
->
p_module
);
...
...
@@ -234,16 +200,16 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block_in
,
*
p_block_out
;
/* Align stream */
int64_t
i_pos
=
stream_Tell
(
p_
input
->
s
);
if
(
i_pos
%
2
)
stream_Read
(
p_
input
->
s
,
NULL
,
1
);
int64_t
i_pos
=
stream_Tell
(
p_
demux
->
s
);
if
(
i_pos
%
2
)
stream_Read
(
p_
demux
->
s
,
NULL
,
1
);
if
(
!
(
p_block_in
=
stream_Block
(
p_
input
->
s
,
A52_PACKET_SIZE
)
)
)
if
(
!
(
p_block_in
=
stream_Block
(
p_
demux
->
s
,
A52_PACKET_SIZE
)
)
)
{
return
0
;
}
...
...
@@ -285,19 +251,15 @@ static int Demux( input_thread_t * p_input )
/* We assume a constant bitrate */
if
(
p_block_out
->
i_length
)
{
p_sys
->
i_mux_rate
=
p_block_out
->
i_buffer
*
I64C
(
1000000
)
/
p_block_out
->
i_length
;
p_input
->
stream
.
i_mux_rate
=
p_sys
->
i_mux_rate
/
50
;
input_ClockManageRef
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
p_block_out
->
i_buffer
*
I64C
(
1000000
)
/
p_block_out
->
i_length
;
}
p_block_out
->
i_dts
=
p_block_out
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
/* set PCR */
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_block_out
->
i_dts
);
es_out_Send
(
p_
input
->
p_es_
out
,
p_sys
->
p_es
,
p_block_out
);
es_out_Send
(
p_
demux
->
out
,
p_sys
->
p_es
,
p_block_out
);
p_block_out
=
p_next
;
}
...
...
@@ -309,36 +271,35 @@ static int Demux( input_thread_t * p_input )
/*****************************************************************************
* Control:
*****************************************************************************/
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
=
(
demux_sys_t
*
)
p_input
->
p_demux_data
;
int64_t
*
pi64
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
return
demux2_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
8
*
p_sys
->
i_mux_rate
,
1
,
i_query
,
args
);
}
switch
(
i_query
)
{
case
DEMUX_GET_TIME
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
if
(
p_sys
->
i_mux_rate
>
0
)
/*****************************************************************************
* CheckSync: Check if buffer starts with an A52 sync code
*****************************************************************************/
static
int
CheckSync
(
uint8_t
*
p_peek
,
vlc_bool_t
*
p_big_endian
)
{
/* Little endian version of the bitstream */
if
(
p_peek
[
0
]
==
0x77
&&
p_peek
[
1
]
==
0x0b
&&
p_peek
[
4
]
<
0x60
/* bsid < 12 */
)
{
*
pi64
=
I64C
(
1000000
)
*
stream_Tell
(
p_input
->
s
)
/
p_sys
->
i_mux_rate
;
*
p_big_endian
=
VLC_FALSE
;
return
VLC_SUCCESS
;
}
*
pi64
=
0
;
return
VLC_EGENERIC
;
case
DEMUX_GET_LENGTH
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
if
(
p_sys
->
i_mux_rate
>
0
)
/* Big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x0b
&&
p_peek
[
1
]
==
0x77
&&
p_peek
[
5
]
<
0x60
/* bsid < 12 */
)
{
*
pi64
=
I64C
(
1000000
)
*
stream_Size
(
p_input
->
s
)
/
p_sys
->
i_mux_rate
;
*
p_big_endian
=
VLC_TRUE
;
return
VLC_SUCCESS
;
}
*
pi64
=
0
;
return
VLC_EGENERIC
;
default:
return
demux_vaControlDefault
(
p_input
,
i_query
,
args
);
}
return
VLC_EGENERIC
;
}
modules/demux/aac.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: aac.c,v 1.
9 2004/01/25 20:05:28 hartman
Exp $
* $Id: aac.c,v 1.
10 2004/03/03 11:40:19 fenrir
Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -37,7 +37,7 @@ static void Close ( vlc_object_t * );
vlc_module_begin
();
set_description
(
_
(
"AAC demuxer"
)
);
set_capability
(
"demux
"
,
1
0
);
set_capability
(
"demux
2"
,
10
0
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"aac"
);
vlc_module_end
();
...
...
@@ -50,8 +50,6 @@ vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
);
struct
demux_sys_t
{
mtime_t
i_time
;
...
...
@@ -59,6 +57,9 @@ struct demux_sys_t
es_out_id_t
*
p_es
;
};
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
static
int
i_aac_samplerate
[
16
]
=
{
96000
,
88200
,
64000
,
48000
,
44100
,
32000
,
...
...
@@ -70,6 +71,7 @@ static int i_aac_samplerate[16] =
#define AAC_SAMPLE_RATE( p ) i_aac_samplerate[((p)[2]>>2)&0x0f]
#define AAC_CHANNELS( p ) ( (((p)[2]&0x01)<<2) | (((p)[3]>>6)&0x03) )
#define AAC_FRAME_SIZE( p ) ( (((p)[3]&0x03) << 11)|( (p)[4] << 3 )|( (((p)[5]) >>5)&0x7 ) )
/* FIXME it's plain wrong */
#define AAC_FRAME_SAMPLES( p ) 1024
...
...
@@ -86,33 +88,29 @@ static inline int HeaderCheck( uint8_t *p )
return
VLC_TRUE
;
}
/*****************************************************************************
* Open: initializes AAC demux structures
*****************************************************************************/
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
;
int
b_forced
=
VLC_FALSE
;
uint8_t
*
p_peek
;
module_t
*
p_id3
;
es_format_t
fmt
;
if
(
p_input
->
psz_demux
&&
!
strncmp
(
p_input
->
psz_demux
,
"aac"
,
3
)
)
if
(
!
strncmp
(
p_demux
->
psz_demux
,
"aac"
,
3
)
)
{
b_forced
=
VLC_TRUE
;
}
if
(
p_
input
->
psz_name
)
if
(
p_
demux
->
psz_path
)
{
int
i_len
=
strlen
(
p_
input
->
psz_name
);
int
i_len
=
strlen
(
p_
demux
->
psz_path
);
if
(
i_len
>
4
&&
!
strcasecmp
(
&
p_
input
->
psz_name
[
i_len
-
4
],
".aac"
)
)
if
(
i_len
>
4
&&
!
strcasecmp
(
&
p_
demux
->
psz_path
[
i_len
-
4
],
".aac"
)
)
{
b_forced
=
VLC_TRUE
;
}
...
...
@@ -123,33 +121,31 @@ static int Open( vlc_object_t * p_this )
/* I haven't find any sure working aac detection so only forced or
* extention check
*/
msg_Warn
(
p_
input
,
"AAC module discarded"
);
msg_Warn
(
p_
demux
,
"AAC module discarded"
);
return
VLC_EGENERIC
;
}
/* skip possible id3 header */
p_id3
=
module_Need
(
p_input
,
"id3"
,
NULL
);
if
(
p_id3
)
if
(
(
p_id3
=
module_Need
(
p_demux
,
"id3"
,
NULL
)
)
)
{
module_Unneed
(
p_
input
,
p_id3
);
module_Unneed
(
p_
demux
,
p_id3
);
}
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux_control
=
demux_vaControlDefault
;
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
->
i_time
=
0
;
/* peek the begining (10 is for adts header) */
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
10
)
<
10
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
10
)
<
10
)
{
msg_Err
(
p_
input
,
"cannot peek"
);
msg_Err
(
p_
demux
,
"cannot peek"
);
goto
error
;
}
if
(
!
strncmp
(
p_peek
,
"ADIF"
,
4
)
)
{
msg_Err
(
p_
input
,
"ADIF file. Not yet supported. (Please report)"
);
msg_Err
(
p_
demux
,
"ADIF file. Not yet supported. (Please report)"
);
goto
error
;
}
...
...
@@ -159,25 +155,14 @@ static int Open( vlc_object_t * p_this )
fmt
.
audio
.
i_channels
=
AAC_CHANNELS
(
p_peek
);
fmt
.
audio
.
i_rate
=
AAC_SAMPLE_RATE
(
p_peek
);
msg_Dbg
(
p_
input
,
msg_Dbg
(
p_
demux
,
"adts header: id=%d channels=%d sample_rate=%d"
,
AAC_ID
(
p_peek
),
AAC_CHANNELS
(
p_peek
),
AAC_SAMPLE_RATE
(
p_peek
)
);
}
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
/
50
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
p_sys
->
p_es
=
es_out_Add
(
p_input
->
p_es_out
,
&
fmt
);
p_sys
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
fmt
);
return
VLC_SUCCESS
;
error:
...
...
@@ -191,17 +176,17 @@ error:
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block
;
uint8_t
h
[
8
];
uint8_t
*
p_peek
;
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
8
)
<
8
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
8
)
<
8
)
{
msg_Warn
(
p_
input
,
"cannot peek"
);
msg_Warn
(
p_
demux
,
"cannot peek"
);
return
0
;
}
...
...
@@ -212,10 +197,10 @@ static int Demux( input_thread_t * p_input )
int
i_skip
=
0
;
int
i_peek
;
i_peek
=
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
8096
);
i_peek
=
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
8096
);
if
(
i_peek
<
8
)
{
msg_Warn
(
p_
input
,
"cannot peek"
);
msg_Warn
(
p_
demux
,
"cannot peek"
);
return
0
;
}
...
...
@@ -232,29 +217,27 @@ static int Demux( input_thread_t * p_input )
i_skip
++
;
}
msg_Warn
(
p_
input
,
"garbage=%d bytes"
,
i_skip
);
stream_Read
(
p_
input
->
s
,
NULL
,
i_skip
);
msg_Warn
(
p_
demux
,
"garbage=%d bytes"
,
i_skip
);
stream_Read
(
p_
demux
->
s
,
NULL
,
i_skip
);
return
1
;
}
memcpy
(
h
,
p_peek
,
8
);
/* can't use p_peek after stream_* */
input_ClockManageRef
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_sys
->
i_time
*
9
/
100
);
if
(
(
p_block
=
stream_Block
(
p_input
->
s
,
AAC_FRAME_SIZE
(
h
)
)
)
==
NULL
)
/* set PCR */
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
if
(
(
p_block
=
stream_Block
(
p_demux
->
s
,
AAC_FRAME_SIZE
(
h
)
)
)
==
NULL
)
{
msg_Warn
(
p_
input
,
"cannot read data"
);
msg_Warn
(
p_
demux
,
"cannot read data"
);
return
0
;
}
p_block
->
i_dts
=
p_block
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_sys
->
i_time
*
9
/
100
);
p_block
->
i_dts
=
p_block
->
i_pts
=
p_sys
->
i_time
;
es_out_Send
(
p_
input
->
p_es_
out
,
p_sys
->
p_es
,
p_block
);
es_out_Send
(
p_
demux
->
out
,
p_sys
->
p_es
,
p_block
);
p_sys
->
i_time
+=
(
mtime_t
)
1000000
*
(
mtime_t
)
AAC_FRAME_SAMPLES
(
h
)
/
...
...
@@ -267,9 +250,21 @@ static int Demux( input_thread_t * p_input )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
free
(
p_sys
);
}
/*****************************************************************************
* Control:
*****************************************************************************/
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
/* demux_sys_t *p_sys = p_demux->p_sys; */
/* FIXME calculate the bitrate */
return
demux2_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
8
*
0
,
1
,
i_query
,
args
);
}
modules/demux/au.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* au.c : au file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: au.c,v 1.1
3 2004/01/29 15:11:17
fenrir Exp $
* $Id: au.c,v 1.1
4 2004/03/03 11:40:19
fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -331,75 +331,9 @@ static void Close( vlc_object_t * p_this )
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
double
f
,
*
pf
;
int64_t
*
pi64
;
switch
(
i_query
)
{
case
DEMUX_GET_POSITION
:
{
int64_t
i_tell
=
stream_Tell
(
p_demux
->
s
);
int64_t
i_end
=
stream_Size
(
p_demux
->
s
);
pf
=
(
double
*
)
va_arg
(
args
,
double
*
);
if
(
p_sys
->
i_header_size
<
i_end
)
{
*
pf
=
(
double
)(
i_tell
-
p_sys
->
i_header_size
)
/
(
double
)(
i_end
-
p_sys
->
i_header_size
);
return
VLC_SUCCESS
;
}
return
VLC_EGENERIC
;
}
case
DEMUX_SET_POSITION
:
{
int64_t
i_end
=
stream_Size
(
p_demux
->
s
);
f
=
(
double
)
va_arg
(
args
,
double
);
if
(
p_sys
->
i_header_size
<
i_end
)
{
int64_t
i_frame
=
(
f
*
(
i_end
-
p_sys
->
i_header_size
))
/
p_sys
->
fmt
.
audio
.
i_blockalign
;
if
(
stream_Seek
(
p_demux
->
s
,
p_sys
->
i_header_size
+
i_frame
*
p_sys
->
fmt
.
audio
.
i_blockalign
)
)
{
return
VLC_EGENERIC
;
}
p_sys
->
i_time
=
1
+
(
i_frame
*
p_sys
->
fmt
.
audio
.
i_blockalign
/
p_sys
->
i_frame_size
)
*
p_sys
->
i_frame_length
;
return
VLC_SUCCESS
;
}
return
VLC_EGENERIC
;
}
case
DEMUX_GET_TIME
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
*
pi64
=
p_sys
->
i_time
;
return
VLC_SUCCESS
;
case
DEMUX_GET_LENGTH
:
{
int64_t
i_size
=
stream_Size
(
p_demux
->
s
)
-
p_sys
->
i_header_size
;
if
(
i_size
>
0
)
{
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
*
pi64
=
i_size
/
p_sys
->
i_frame_size
*
p_sys
->
i_frame_length
;
return
VLC_SUCCESS
;
}
return
VLC_EGENERIC
;
}
case
DEMUX_SET_TIME
:
case
DEMUX_GET_FPS
:
default:
return
VLC_EGENERIC
;
}
return
demux2_vaControlHelper
(
p_demux
->
s
,
p_sys
->
i_header_size
,
-
1
,
p_sys
->
fmt
.
i_bitrate
,
p_sys
->
fmt
.
audio
.
i_blockalign
,
i_query
,
args
);
}
modules/demux/dts.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* dts.c : raw DTS stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: dts.c,v 1.1
0 2004/02/25 17:48:52
fenrir Exp $
* $Id: dts.c,v 1.1
1 2004/03/03 11:40:19
fenrir Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
...
...
@@ -28,18 +28,24 @@
#include <vlc/input.h>
#include <vlc_codec.h>
#define DTS_PACKET_SIZE 16384
#define DTS_PROBE_SIZE (DTS_PACKET_SIZE * 4)
#define DTS_MAX_HEADER_SIZE 11
/*****************************************************************************
*
Local prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
int
Demux
(
input_thread_t
*
);
static
int
Control
(
input_thread_t
*
,
int
,
va_list
);
vlc_module_begin
();
set_description
(
_
(
"Raw DTS demuxer"
)
);
set_capability
(
"demux2"
,
155
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"dts"
);
vlc_module_end
();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
struct
demux_sys_t
{
...
...
@@ -52,67 +58,24 @@ struct demux_sys_t
int
i_mux_rate
;
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Raw DTS demuxer"
)
);
set_capability
(
"demux"
,
155
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"dts"
);
vlc_module_end
();
/*****************************************************************************
* CheckSync: Check if buffer starts with a DTS sync code
*****************************************************************************/
static
int
CheckSync
(
uint8_t
*
p_peek
)
{
/* 14 bits, little endian version of the bitstream */
if
(
p_peek
[
0
]
==
0xff
&&
p_peek
[
1
]
==
0x1f
&&
p_peek
[
2
]
==
0x00
&&
p_peek
[
3
]
==
0xe8
&&
(
p_peek
[
4
]
&
0xf0
)
==
0xf0
&&
p_peek
[
5
]
==
0x07
)
{
return
VLC_SUCCESS
;
}
/* 14 bits, big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x1f
&&
p_peek
[
1
]
==
0xff
&&
p_peek
[
2
]
==
0xe8
&&
p_peek
[
3
]
==
0x00
&&
p_peek
[
4
]
==
0x07
&&
(
p_peek
[
5
]
&
0xf0
)
==
0xf0
)
{
return
VLC_SUCCESS
;
}
/* 16 bits, big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x7f
&&
p_peek
[
1
]
==
0xfe
&&
p_peek
[
2
]
==
0x80
&&
p_peek
[
3
]
==
0x01
)
{
return
VLC_SUCCESS
;
}
/* 16 bits, little endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0xfe
&&
p_peek
[
1
]
==
0x7f
&&
p_peek
[
2
]
==
0x01
&&
p_peek
[
3
]
==
0x80
)
{
return
VLC_SUCCESS
;
}
static
int
CheckSync
(
uint8_t
*
p_peek
);
return
VLC_EGENERIC
;
}
#define DTS_PACKET_SIZE 16384
#define DTS_PROBE_SIZE (DTS_PACKET_SIZE * 4)
#define DTS_MAX_HEADER_SIZE 11
/*****************************************************************************
* Open: initializes ES structures
*****************************************************************************/
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
;
byte_t
*
p_peek
;
int
i_peek
=
0
;
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux_control
=
Control
;
p_input
->
pf_rewind
=
NULL
;
/* Check if we are dealing with a WAV file */
if
(
input_Peek
(
p_input
,
&
p_peek
,
20
)
==
20
&&
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
20
)
==
20
&&
!
strncmp
(
p_peek
,
"RIFF"
,
4
)
&&
!
strncmp
(
&
p_peek
[
8
],
"WAVE"
,
4
)
)
{
int
i_size
;
...
...
@@ -125,7 +88,7 @@ static int Open( vlc_object_t * p_this )
if
(
i_size
+
i_peek
>
DTS_PROBE_SIZE
)
return
VLC_EGENERIC
;
i_peek
+=
i_size
+
8
;
if
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
)
!=
i_peek
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
)
!=
i_peek
)
return
VLC_EGENERIC
;
}
...
...
@@ -133,7 +96,7 @@ static int Open( vlc_object_t * p_this )
i_size
=
GetDWLE
(
p_peek
+
i_peek
-
4
);
if
(
i_size
+
i_peek
>
DTS_PROBE_SIZE
)
return
VLC_EGENERIC
;
i_peek
+=
i_size
+
8
;
if
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
)
!=
i_peek
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
)
!=
i_peek
)
return
VLC_EGENERIC
;
if
(
GetWLE
(
p_peek
+
i_peek
-
i_size
-
8
/* wFormatTag */
)
!=
1
/* WAVE_FORMAT_PCM */
)
...
...
@@ -151,13 +114,13 @@ static int Open( vlc_object_t * p_this )
if
(
i_size
+
i_peek
>
DTS_PROBE_SIZE
)
return
VLC_EGENERIC
;
i_peek
+=
i_size
+
8
;
if
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
)
!=
i_peek
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
)
!=
i_peek
)
return
VLC_EGENERIC
;
}
/* Some DTS wav files don't begin with a sync code so we do a more
* extensive search */
i_size
=
input_Peek
(
p_input
,
&
p_peek
,
DTS_PROBE_SIZE
);
i_size
=
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
DTS_PROBE_SIZE
);
i_size
-=
DTS_MAX_HEADER_SIZE
;
while
(
i_peek
<
i_size
)
...
...
@@ -171,36 +134,35 @@ static int Open( vlc_object_t * p_this )
}
/* Have a peep at the show. */
if
(
input_Peek
(
p_input
,
&
p_peek
,
i_peek
+
DTS_MAX_HEADER_SIZE
*
2
)
<
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_peek
+
DTS_MAX_HEADER_SIZE
*
2
)
<
i_peek
+
DTS_MAX_HEADER_SIZE
*
2
)
{
/* Stream too short */
msg_Warn
(
p_
input
,
"cannot peek()"
);
msg_Warn
(
p_
demux
,
"cannot peek()"
);
return
VLC_EGENERIC
;
}
if
(
CheckSync
(
p_peek
+
i_peek
)
!=
VLC_SUCCESS
)
{
if
(
p_input
->
psz_demux
&&
!
strncmp
(
p_input
->
psz_demux
,
"dts"
,
3
)
)
{
/* User forced */
msg_Err
(
p_input
,
"this doesn't look like a DTS audio stream, "
"continuing anyway"
);
}
else
if
(
strncmp
(
p_demux
->
psz_demux
,
"dts"
,
3
)
)
{
return
VLC_EGENERIC
;
}
/* User forced */
msg_Err
(
p_demux
,
"this doesn't look like a DTS audio stream, "
"continuing anyway"
);
}
p_input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
->
b_start
=
VLC_TRUE
;
p_sys
->
i_mux_rate
=
0
;
/*
* Load the DTS packetizer
*/
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
input
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
demux
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
->
pf_decode_audio
=
0
;
p_sys
->
p_packetizer
->
pf_decode_video
=
0
;
p_sys
->
p_packetizer
->
pf_decode_sub
=
0
;
...
...
@@ -214,23 +176,11 @@ static int Open( vlc_object_t * p_this )
module_Need
(
p_sys
->
p_packetizer
,
"packetizer"
,
NULL
);
if
(
!
p_sys
->
p_packetizer
->
p_module
)
{
msg_Err
(
p_
input
,
"cannot find DTS packetizer"
);
msg_Err
(
p_
demux
,
"cannot find DTS packetizer"
);
return
VLC_EGENERIC
;
}
/* 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"
);
return
VLC_EGENERIC
;
}
p_input
->
stream
.
i_mux_rate
=
0
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
p_sys
->
p_es
=
es_out_Add
(
p_input
->
p_es_out
,
&
p_sys
->
p_packetizer
->
fmt_in
);
p_sys
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
p_sys
->
p_packetizer
->
fmt_in
);
return
VLC_SUCCESS
;
}
...
...
@@ -238,10 +188,10 @@ static int Open( vlc_object_t * p_this )
/*****************************************************************************
* Close: frees unused data
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
/* Unneed module */
module_Unneed
(
p_sys
->
p_packetizer
,
p_sys
->
p_packetizer
->
p_module
);
...
...
@@ -257,12 +207,12 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block_in
,
*
p_block_out
;
if
(
!
(
p_block_in
=
stream_Block
(
p_
input
->
s
,
DTS_PACKET_SIZE
)
)
)
if
(
!
(
p_block_in
=
stream_Block
(
p_
demux
->
s
,
DTS_PACKET_SIZE
)
)
)
{
return
0
;
}
...
...
@@ -283,19 +233,15 @@ static int Demux( input_thread_t * p_input )
/* We assume a constant bitrate */
if
(
p_block_out
->
i_length
)
{
p_sys
->
i_mux_rate
=
p_block_out
->
i_buffer
*
I64C
(
1000000
)
/
p_block_out
->
i_length
;
p_input
->
stream
.
i_mux_rate
=
p_sys
->
i_mux_rate
/
50
;
input_ClockManageRef
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
}
p_block_out
->
i_dts
=
p_block_out
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
/* set PCR */
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_block_out
->
i_dts
);
es_out_Send
(
p_
input
->
p_es_
out
,
p_sys
->
p_es
,
p_block_out
);
es_out_Send
(
p_
demux
->
out
,
p_sys
->
p_es
,
p_block_out
);
p_block_out
=
p_next
;
}
...
...
@@ -307,36 +253,46 @@ static int Demux( input_thread_t * p_input )
/*****************************************************************************
* Control:
*****************************************************************************/
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
=
(
demux_sys_t
*
)
p_input
->
p_demux_data
;
int64_t
*
pi64
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
return
demux2_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
8
*
p_sys
->
i_mux_rate
,
1
,
i_query
,
args
);
}
switch
(
i_query
)
/*****************************************************************************
* CheckSync: Check if buffer starts with a DTS sync code
*****************************************************************************/
static
int
CheckSync
(
uint8_t
*
p_peek
)
{
/* 14 bits, little endian version of the bitstream */
if
(
p_peek
[
0
]
==
0xff
&&
p_peek
[
1
]
==
0x1f
&&
p_peek
[
2
]
==
0x00
&&
p_peek
[
3
]
==
0xe8
&&
(
p_peek
[
4
]
&
0xf0
)
==
0xf0
&&
p_peek
[
5
]
==
0x07
)
{
case
DEMUX_GET_TIME
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
if
(
p_sys
->
i_mux_rate
>
0
)
return
VLC_SUCCESS
;
}
/* 14 bits, big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x1f
&&
p_peek
[
1
]
==
0xff
&&
p_peek
[
2
]
==
0xe8
&&
p_peek
[
3
]
==
0x00
&&
p_peek
[
4
]
==
0x07
&&
(
p_peek
[
5
]
&
0xf0
)
==
0xf0
)
{
*
pi64
=
I64C
(
1000000
)
*
stream_Tell
(
p_input
->
s
)
/
p_sys
->
i_mux_rate
;
return
VLC_SUCCESS
;
}
*
pi64
=
0
;
return
VLC_EGENERIC
;
case
DEMUX_GET_LENGTH
:
pi64
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
if
(
p_sys
->
i_mux_rate
>
0
)
/* 16 bits, big endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0x7f
&&
p_peek
[
1
]
==
0xfe
&&
p_peek
[
2
]
==
0x80
&&
p_peek
[
3
]
==
0x01
)
{
*
pi64
=
I64C
(
1000000
)
*
stream_Size
(
p_input
->
s
)
/
p_sys
->
i_mux_rate
;
return
VLC_SUCCESS
;
}
*
pi64
=
0
;
return
VLC_EGENERIC
;
default:
return
demux_vaControlDefault
(
p_input
,
i_query
,
args
)
;
/* 16 bits, little endian version of the bitstream */
else
if
(
p_peek
[
0
]
==
0xfe
&&
p_peek
[
1
]
==
0x7f
&&
p_peek
[
2
]
==
0x01
&&
p_peek
[
3
]
==
0x80
)
{
return
VLC_SUCCESS
;
}
return
VLC_EGENERIC
;
}
modules/demux/flac.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* flac.c : FLAC demux module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: flac.c,v 1.1
1 2004/02/25 17:48:52
fenrir Exp $
* $Id: flac.c,v 1.1
2 2004/03/03 11:40:19
fenrir Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
...
...
@@ -28,15 +28,24 @@
#include <vlc/input.h>
#include <vlc_codec.h>
#define STREAMINFO_SIZE 38
#define FLAC_PACKET_SIZE 16384
/*****************************************************************************
*
Local prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
int
Demux
(
input_thread_t
*
);
vlc_module_begin
();
set_description
(
_
(
"FLAC demuxer"
)
);
set_capability
(
"demux2"
,
155
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"flac"
);
vlc_module_end
();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
struct
demux_sys_t
{
...
...
@@ -47,76 +56,64 @@ struct demux_sys_t
decoder_t
*
p_packetizer
;
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"FLAC demuxer"
)
);
set_capability
(
"demux"
,
155
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"flac"
);
vlc_module_end
();
#define STREAMINFO_SIZE 38
#define FLAC_PACKET_SIZE 16384
/*****************************************************************************
* Open: initializes ES structures
*****************************************************************************/
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
;
int
i_peek
;
byte_t
*
p_peek
;
byte_t
*
p_peek
;
es_format_t
fmt
;
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux_control
=
demux_vaControlDefault
;
p_input
->
pf_rewind
=
NULL
;
/* Have a peep at the show. */
if
(
input_Peek
(
p_input
,
&
p_peek
,
4
)
<
4
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
4
)
<
4
)
{
/* Stream shorter than 4 bytes... */
msg_Err
(
p_
input
,
"cannot peek()"
);
msg_Err
(
p_
demux
,
"cannot peek()"
);
return
VLC_EGENERIC
;
}
if
(
p_peek
[
0
]
!=
'f'
||
p_peek
[
1
]
!=
'L'
||
p_peek
[
2
]
!=
'a'
||
p_peek
[
3
]
!=
'C'
)
{
if
(
p_input
->
psz_demux
&&
!
strncmp
(
p_input
->
psz_demux
,
"flac"
,
4
)
)
if
(
strncmp
(
p_demux
->
psz_demux
,
"flac"
,
4
)
)
{
/* User forced */
msg_Err
(
p_input
,
"this doesn't look like a flac stream, "
"continuing anyway"
);
}
else
{
msg_Warn
(
p_input
,
"flac module discarded (no startcode)"
);
msg_Warn
(
p_demux
,
"flac module discarded (no startcode)"
);
return
VLC_EGENERIC
;
}
/* User forced */
msg_Err
(
p_demux
,
"this doesn't look like a flac stream, "
"continuing anyway"
);
}
p_input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
es_format_Init
(
&
fmt
,
AUDIO_ES
,
VLC_FOURCC
(
'f'
,
'l'
,
'a'
,
'c'
)
);
p_sys
->
b_start
=
VLC_TRUE
;
/* We need to read and store the STREAMINFO metadata */
i_peek
=
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
8
);
i_peek
=
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
8
);
if
(
p_peek
[
4
]
&
0x7F
)
{
msg_Err
(
p_
input
,
"this isn't a STREAMINFO metadata block"
);
msg_Err
(
p_
demux
,
"this isn't a STREAMINFO metadata block"
);
return
VLC_EGENERIC
;
}
if
(
((
p_peek
[
5
]
<<
16
)
+
(
p_peek
[
6
]
<<
8
)
+
p_peek
[
7
])
!=
(
STREAMINFO_SIZE
-
4
)
)
{
msg_Err
(
p_
input
,
"invalid size for a STREAMINFO metadata block"
);
msg_Err
(
p_
demux
,
"invalid size for a STREAMINFO metadata block"
);
return
VLC_EGENERIC
;
}
/*
* Load the FLAC packetizer
*/
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
input
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
=
vlc_object_create
(
p_
demux
,
VLC_OBJECT_DECODER
);
p_sys
->
p_packetizer
->
pf_decode_audio
=
0
;
p_sys
->
p_packetizer
->
pf_decode_video
=
0
;
p_sys
->
p_packetizer
->
pf_decode_sub
=
0
;
...
...
@@ -129,7 +126,7 @@ static int Open( vlc_object_t * p_this )
/* Store STREAMINFO for the decoder and packetizer */
p_sys
->
p_packetizer
->
fmt_in
.
i_extra
=
fmt
.
i_extra
=
STREAMINFO_SIZE
+
4
;
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
=
malloc
(
STREAMINFO_SIZE
+
4
);
stream_Read
(
p_
input
->
s
,
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
,
stream_Read
(
p_
demux
->
s
,
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
,
STREAMINFO_SIZE
+
4
);
/* Fake this as the last metadata block */
...
...
@@ -146,22 +143,11 @@ static int Open( vlc_object_t * p_this )
free
(
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
);
vlc_object_destroy
(
p_sys
->
p_packetizer
);
msg_Err
(
p_
input
,
"cannot find flac packetizer"
);
msg_Err
(
p_
demux
,
"cannot find flac packetizer"
);
return
VLC_EGENERIC
;
}
/* 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"
);
return
VLC_EGENERIC
;
}
p_input
->
stream
.
i_mux_rate
=
0
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
p_sys
->
p_es
=
es_out_Add
(
p_input
->
p_es_out
,
&
fmt
);
p_sys
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
fmt
);
return
VLC_SUCCESS
;
}
...
...
@@ -171,8 +157,8 @@ static int Open( vlc_object_t * p_this )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
/* Unneed module */
module_Unneed
(
p_sys
->
p_packetizer
,
p_sys
->
p_packetizer
->
p_module
);
...
...
@@ -191,12 +177,12 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block_in
,
*
p_block_out
;
if
(
!
(
p_block_in
=
stream_Block
(
p_
input
->
s
,
FLAC_PACKET_SIZE
)
)
)
if
(
!
(
p_block_in
=
stream_Block
(
p_
demux
->
s
,
FLAC_PACKET_SIZE
)
)
)
{
return
0
;
}
...
...
@@ -218,15 +204,10 @@ static int Demux( input_thread_t * p_input )
{
block_t
*
p_next
=
p_block_out
->
p_next
;
input_ClockManageRef
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
p_block_out
->
i_dts
=
p_block_out
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_block_out
->
i_pts
*
9
/
100
);
/* set PCR */
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_block_out
->
i_dts
);
es_out_Send
(
p_
input
->
p_es_
out
,
p_sys
->
p_es
,
p_block_out
);
es_out_Send
(
p_
demux
->
out
,
p_sys
->
p_es
,
p_block_out
);
p_block_out
=
p_next
;
}
...
...
@@ -234,3 +215,16 @@ static int Demux( input_thread_t * p_input )
return
1
;
}
/*****************************************************************************
* Control:
*****************************************************************************/
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
/* demux_sys_t *p_sys = p_demux->p_sys; */
/* FIXME bitrate */
return
demux2_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
8
*
0
,
1
,
i_query
,
args
);
}
modules/demux/wav.c
View file @
08ece243
...
...
@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: wav.c,v 1.1
4 2004/02/23 23:01:05 gbazin
Exp $
* $Id: wav.c,v 1.1
5 2004/03/03 11:40:19 fenrir
Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -39,14 +39,15 @@ static void Close( vlc_object_t * );
vlc_module_begin
();
set_description
(
_
(
"WAV demuxer"
)
);
set_capability
(
"demux"
,
142
);
set_capability
(
"demux
2
"
,
142
);
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
);
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
i_query
,
va_list
args
);
struct
demux_sys_t
{
...
...
@@ -61,23 +62,20 @@ struct demux_sys_t
mtime_t
i_frame_length
;
};
/*****************************************************************************
* Declaration of local function
*****************************************************************************/
#define __EVEN( x ) ( ( (x)%2 != 0 ) ? ((x)+1) : (x) )
static
int
ChunkFind
(
input_thread
_t
*
,
char
*
,
unsigned
int
*
);
static
int
ChunkFind
(
demux
_t
*
,
char
*
,
unsigned
int
*
);
static
void
FrameInfo_IMA_ADPCM
(
input_thread
_t
*
,
unsigned
int
*
,
mtime_t
*
);
static
void
FrameInfo_MS_ADPCM
(
input_thread
_t
*
,
unsigned
int
*
,
mtime_t
*
);
static
void
FrameInfo_PCM
(
input_thread
_t
*
,
unsigned
int
*
,
mtime_t
*
);
static
void
FrameInfo_IMA_ADPCM
(
demux
_t
*
,
unsigned
int
*
,
mtime_t
*
);
static
void
FrameInfo_MS_ADPCM
(
demux
_t
*
,
unsigned
int
*
,
mtime_t
*
);
static
void
FrameInfo_PCM
(
demux
_t
*
,
unsigned
int
*
,
mtime_t
*
);
/*****************************************************************************
* Open: check file and initializes structures
*****************************************************************************/
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
;
uint8_t
*
p_peek
;
...
...
@@ -88,9 +86,9 @@ static int Open( vlc_object_t * p_this )
WAVEFORMATEX
*
p_wf
;
/* Is it a wav file ? */
if
(
input_Peek
(
p_input
,
&
p_peek
,
12
)
<
12
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
12
)
<
12
)
{
msg_Warn
(
p_
input
,
"WAV module discarded (cannot peek)"
);
msg_Warn
(
p_
demux
,
"WAV module discarded (cannot peek)"
);
return
VLC_EGENERIC
;
}
if
(
strncmp
(
p_peek
,
"RIFF"
,
4
)
||
strncmp
(
&
p_peek
[
8
],
"WAVE"
,
4
)
)
...
...
@@ -98,35 +96,35 @@ static int Open( vlc_object_t * p_this )
return
VLC_EGENERIC
;
}
p_
input
->
pf_demux
=
Demux
;
p_
input
->
pf_demux_control
=
demux_vaControlDefault
;
p_
input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_
demux
->
pf_demux
=
Demux
;
p_
demux
->
pf_control
=
Control
;
p_
demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
->
p_es
=
NULL
;
p_sys
->
i_time
=
0
;
/* skip riff header */
stream_Read
(
p_
input
->
s
,
NULL
,
12
);
/* cannot fail as peek succeed */
stream_Read
(
p_
demux
->
s
,
NULL
,
12
);
/* cannot fail as peek succeed */
/* search fmt chunk */
if
(
ChunkFind
(
p_
input
,
"fmt "
,
&
i_size
)
)
if
(
ChunkFind
(
p_
demux
,
"fmt "
,
&
i_size
)
)
{
msg_Err
(
p_
input
,
"cannot find 'fmt ' chunk"
);
msg_Err
(
p_
demux
,
"cannot find 'fmt ' chunk"
);
goto
error
;
}
if
(
i_size
<
sizeof
(
WAVEFORMATEX
)
-
2
)
/* XXX -2 isn't a typo */
{
msg_Err
(
p_
input
,
"invalid 'fmt ' chunk"
);
msg_Err
(
p_
demux
,
"invalid 'fmt ' chunk"
);
goto
error
;
}
stream_Read
(
p_
input
->
s
,
NULL
,
8
);
/* Cannot fail */
stream_Read
(
p_
demux
->
s
,
NULL
,
8
);
/* Cannot fail */
/* load waveformatex */
p_wf
=
(
WAVEFORMATEX
*
)
p_wf_ext
=
malloc
(
__EVEN
(
i_size
)
+
2
);
p_wf
->
cbSize
=
0
;
if
(
stream_Read
(
p_
input
->
s
,
if
(
stream_Read
(
p_
demux
->
s
,
p_wf
,
__EVEN
(
i_size
)
)
<
(
int
)
__EVEN
(
i_size
)
)
{
msg_Err
(
p_
input
,
"cannot load 'fmt ' chunk"
);
msg_Err
(
p_
demux
,
"cannot load 'fmt ' chunk"
);
goto
error
;
}
...
...
@@ -158,7 +156,7 @@ static int Open( vlc_object_t * p_this )
p_sys
->
fmt
.
i_extra
);
}
msg_Dbg
(
p_
input
,
"format: 0x%4.4x, fourcc: %4.4s, channels: %d, "
msg_Dbg
(
p_
demux
,
"format: 0x%4.4x, fourcc: %4.4s, channels: %d, "
"freq: %d Hz, bitrate: %dKo/s, blockalign: %d, bits/samples: %d, "
"extra size: %d"
,
GetWLE
(
&
p_wf
->
wFormatTag
),
(
char
*
)
&
p_sys
->
fmt
.
i_codec
,
...
...
@@ -174,20 +172,20 @@ static int Open( vlc_object_t * p_this )
case
VLC_FOURCC
(
'a'
,
'f'
,
'l'
,
't'
):
case
VLC_FOURCC
(
'u'
,
'l'
,
'a'
,
'w'
):
case
VLC_FOURCC
(
'a'
,
'l'
,
'a'
,
'w'
):
FrameInfo_PCM
(
p_
input
,
&
p_sys
->
i_frame_size
,
&
p_sys
->
i_frame_length
);
FrameInfo_PCM
(
p_
demux
,
&
p_sys
->
i_frame_size
,
&
p_sys
->
i_frame_length
);
break
;
case
VLC_FOURCC
(
'm'
,
's'
,
0x00
,
0x02
):
FrameInfo_MS_ADPCM
(
p_
input
,
&
p_sys
->
i_frame_size
,
FrameInfo_MS_ADPCM
(
p_
demux
,
&
p_sys
->
i_frame_size
,
&
p_sys
->
i_frame_length
);
break
;
case
VLC_FOURCC
(
'm'
,
's'
,
0x00
,
0x11
):
FrameInfo_IMA_ADPCM
(
p_
input
,
&
p_sys
->
i_frame_size
,
FrameInfo_IMA_ADPCM
(
p_
demux
,
&
p_sys
->
i_frame_size
,
&
p_sys
->
i_frame_length
);
break
;
case
VLC_FOURCC
(
'm'
,
's'
,
0x00
,
0x61
):
case
VLC_FOURCC
(
'm'
,
's'
,
0x00
,
0x62
):
/* FIXME not sure at all FIXME */
FrameInfo_MS_ADPCM
(
p_
input
,
&
p_sys
->
i_frame_size
,
FrameInfo_MS_ADPCM
(
p_
demux
,
&
p_sys
->
i_frame_size
,
&
p_sys
->
i_frame_length
);
break
;
case
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'a'
):
...
...
@@ -195,43 +193,28 @@ static int Open( vlc_object_t * p_this )
/* FIXME set end of area FIXME */
goto
relay
;
default:
msg_Err
(
p_
input
,
"unsupported codec (%4.4s)"
,
msg_Err
(
p_
demux
,
"unsupported codec (%4.4s)"
,
(
char
*
)
&
p_sys
->
fmt
.
i_codec
);
goto
error
;
}
msg_Dbg
(
p_
input
,
"found %s audio format"
,
psz_name
);
msg_Dbg
(
p_
demux
,
"found %s audio format"
,
psz_name
);
if
(
ChunkFind
(
p_
input
,
"data"
,
&
p_sys
->
i_data_size
)
)
if
(
ChunkFind
(
p_
demux
,
"data"
,
&
p_sys
->
i_data_size
)
)
{
msg_Err
(
p_
input
,
"cannot find 'data' chunk"
);
msg_Err
(
p_
demux
,
"cannot find 'data' chunk"
);
goto
error
;
}
stream_Read
(
p_
input
->
s
,
NULL
,
8
);
/* Cannot fail */
p_sys
->
i_data_pos
=
stream_Tell
(
p_
input
->
s
);
stream_Read
(
p_
demux
->
s
,
NULL
,
8
);
/* Cannot fail */
p_sys
->
i_data_pos
=
stream_Tell
(
p_
demux
->
s
);
/* 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
;
if
(
p_sys
->
fmt
.
i_bitrate
)
{
p_input
->
stream
.
i_mux_rate
=
p_sys
->
fmt
.
i_bitrate
/
50
/
8
;
}
else
if
(
p_sys
->
i_data_size
>
0
)
if
(
p_sys
->
fmt
.
i_bitrate
<=
0
)
{
p_
input
->
stream
.
i_mux_
rate
=
(
mtime_t
)
p_sys
->
i_frame_size
*
(
mtime_t
)
1000000
/
50
/
p_sys
->
i_frame_length
;
p_
sys
->
fmt
.
i_bit
rate
=
(
mtime_t
)
p_sys
->
i_frame_size
*
I64C
(
8000000
)
/
p_sys
->
i_frame_length
;
}
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
p_sys
->
p_es
=
es_out_Add
(
p_
input
->
p_es_
out
,
&
p_sys
->
fmt
);
p_sys
->
p_es
=
es_out_Add
(
p_
demux
->
out
,
&
p_sys
->
fmt
);
return
VLC_SUCCESS
;
error:
...
...
@@ -245,34 +228,13 @@ relay:
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int64_t
i_pos
;
block_t
*
p_block
;
if
(
p_input
->
stream
.
p_selected_program
->
i_synchro_state
==
SYNCHRO_REINIT
)
{
i_pos
=
stream_Tell
(
p_input
->
s
);
}
input_ClockManageRef
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_sys
->
i_time
*
9
/
100
);
i_pos
=
stream_Tell
(
p_input
->
s
);
/* Check alignment */
if
(
p_sys
->
fmt
.
audio
.
i_blockalign
!=
0
&&
i_pos
%
p_sys
->
fmt
.
audio
.
i_blockalign
)
{
int
i_skip
=
p_sys
->
fmt
.
audio
.
i_blockalign
-
i_pos
%
p_sys
->
fmt
.
audio
.
i_blockalign
;
if
(
stream_Read
(
p_input
->
s
,
NULL
,
i_skip
)
!=
i_skip
)
{
msg_Err
(
p_input
,
"failed to re-align stream"
);
}
}
i_pos
=
stream_Tell
(
p_demux
->
s
);
if
(
p_sys
->
i_data_size
>
0
&&
i_pos
>=
p_sys
->
i_data_pos
+
p_sys
->
i_data_size
)
...
...
@@ -281,17 +243,17 @@ static int Demux( input_thread_t *p_input )
return
0
;
}
if
(
(
p_block
=
stream_Block
(
p_
input
->
s
,
p_sys
->
i_frame_size
)
)
==
NULL
)
if
(
(
p_block
=
stream_Block
(
p_
demux
->
s
,
p_sys
->
i_frame_size
)
)
==
NULL
)
{
msg_Warn
(
p_
input
,
"cannot read data"
);
msg_Warn
(
p_
demux
,
"cannot read data"
);
return
0
;
}
p_block
->
i_dts
=
p_block
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_sys
->
i_time
*
9
/
100
);
p_block
->
i_dts
=
p_block
->
i_pts
=
p_sys
->
i_time
;
es_out_Send
(
p_input
->
p_es_out
,
p_sys
->
p_es
,
p_block
);
/* set PCR */
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
es_out_Send
(
p_demux
->
out
,
p_sys
->
p_es
,
p_block
);
p_sys
->
i_time
+=
p_sys
->
i_frame_length
;
...
...
@@ -303,16 +265,33 @@ static int Demux( input_thread_t *p_input )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
free
(
p_sys
);
}
/*****************************************************************************
* Control:
*****************************************************************************/
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int64_t
i_end
=
-
1
;
if
(
p_sys
->
i_data_size
>
0
)
{
i_end
=
p_sys
->
i_data_pos
+
p_sys
->
i_data_size
;
}
return
demux2_vaControlHelper
(
p_demux
->
s
,
p_sys
->
i_data_pos
,
i_end
,
p_sys
->
fmt
.
i_bitrate
,
p_sys
->
fmt
.
audio
.
i_blockalign
,
i_query
,
args
);
}
/*****************************************************************************
* Local functions
*****************************************************************************/
static
int
ChunkFind
(
input_thread_t
*
p_input
,
static
int
ChunkFind
(
demux_t
*
p_demux
,
char
*
fcc
,
unsigned
int
*
pi_size
)
{
uint8_t
*
p_peek
;
...
...
@@ -321,15 +300,15 @@ static int ChunkFind( input_thread_t *p_input,
{
int
i_size
;
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
8
)
<
8
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
8
)
<
8
)
{
msg_Err
(
p_
input
,
"cannot peek()"
);
msg_Err
(
p_
demux
,
"cannot peek()"
);
return
VLC_EGENERIC
;
}
i_size
=
GetDWLE
(
p_peek
+
4
);
msg_Dbg
(
p_
input
,
"Chunk: fcc=`%4.4s` size=%d"
,
p_peek
,
i_size
);
msg_Dbg
(
p_
demux
,
"Chunk: fcc=`%4.4s` size=%d"
,
p_peek
,
i_size
);
if
(
!
strncmp
(
p_peek
,
fcc
,
4
)
)
{
...
...
@@ -341,18 +320,18 @@ static int ChunkFind( input_thread_t *p_input,
}
i_size
=
__EVEN
(
i_size
)
+
8
;
if
(
stream_Read
(
p_
input
->
s
,
NULL
,
i_size
)
!=
i_size
)
if
(
stream_Read
(
p_
demux
->
s
,
NULL
,
i_size
)
!=
i_size
)
{
return
VLC_EGENERIC
;
}
}
}
static
void
FrameInfo_PCM
(
input_thread_t
*
p_input
,
static
void
FrameInfo_PCM
(
demux_t
*
p_demux
,
unsigned
int
*
pi_size
,
mtime_t
*
pi_length
)
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_samples
;
...
...
@@ -381,11 +360,11 @@ static void FrameInfo_PCM( input_thread_t *p_input,
*
pi_size
=
i_bytes
;
}
static
void
FrameInfo_MS_ADPCM
(
input_thread_t
*
p_input
,
static
void
FrameInfo_MS_ADPCM
(
demux_t
*
p_demux
,
unsigned
int
*
pi_size
,
mtime_t
*
pi_length
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int
i_samples
;
...
...
@@ -398,11 +377,11 @@ static void FrameInfo_MS_ADPCM( input_thread_t *p_input,
*
pi_size
=
p_sys
->
fmt
.
audio
.
i_blockalign
;
}
static
void
FrameInfo_IMA_ADPCM
(
input_thread_t
*
p_input
,
static
void
FrameInfo_IMA_ADPCM
(
demux_t
*
p_demux
,
unsigned
int
*
pi_size
,
mtime_t
*
pi_length
)
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int
i_samples
;
...
...
@@ -414,3 +393,5 @@ static void FrameInfo_IMA_ADPCM( input_thread_t *p_input,
*
pi_size
=
p_sys
->
fmt
.
audio
.
i_blockalign
;
}
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