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
3d94c37e
Commit
3d94c37e
authored
Mar 09, 2005
by
Gildas Bazin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* modules/mux/mpeg/ps.c: Write a PSM + support for mp4v/mp4a/h264.
parent
0afb33e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
168 additions
and
4 deletions
+168
-4
modules/mux/mpeg/ps.c
modules/mux/mpeg/ps.c
+168
-4
No files found.
modules/mux/mpeg/ps.c
View file @
3d94c37e
...
@@ -37,6 +37,8 @@
...
@@ -37,6 +37,8 @@
#include "bits.h"
#include "bits.h"
#include "pes.h"
#include "pes.h"
#include "iso_lang.h"
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
...
@@ -81,6 +83,7 @@ static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
...
@@ -81,6 +83,7 @@ static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
static
void
MuxWritePackHeader
(
sout_mux_t
*
,
block_t
**
,
mtime_t
);
static
void
MuxWritePackHeader
(
sout_mux_t
*
,
block_t
**
,
mtime_t
);
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
,
block_t
**
,
mtime_t
);
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
,
block_t
**
,
mtime_t
);
static
void
MuxWritePSM
(
sout_mux_t
*
,
block_t
**
,
mtime_t
);
static
void
StreamIdInit
(
vlc_bool_t
*
id
,
int
i_range
);
static
void
StreamIdInit
(
vlc_bool_t
*
id
,
int
i_range
);
static
int
StreamIdGet
(
vlc_bool_t
*
id
,
int
i_id_min
,
int
i_id_max
);
static
int
StreamIdGet
(
vlc_bool_t
*
id
,
int
i_id_min
,
int
i_id_max
);
...
@@ -89,6 +92,10 @@ static void StreamIdRelease ( vlc_bool_t *id, int i_id_min, int i_id );
...
@@ -89,6 +92,10 @@ static void StreamIdRelease ( vlc_bool_t *id, int i_id_min, int i_id );
typedef
struct
ps_stream_s
typedef
struct
ps_stream_s
{
{
int
i_stream_id
;
int
i_stream_id
;
int
i_stream_type
;
/* Language is iso639-2T */
uint8_t
lang
[
3
];
}
ps_stream_t
;
}
ps_stream_t
;
...
@@ -113,6 +120,9 @@ struct sout_mux_sys_t
...
@@ -113,6 +120,9 @@ struct sout_mux_sys_t
int64_t
i_instant_dts
;
int64_t
i_instant_dts
;
vlc_bool_t
b_mpeg2
;
vlc_bool_t
b_mpeg2
;
int
i_psm_version
;
uint32_t
crc32_table
[
256
];
};
};
static
const
char
*
ppsz_sout_options
[]
=
{
static
const
char
*
ppsz_sout_options
[]
=
{
...
@@ -150,6 +160,8 @@ static int Open( vlc_object_t *p_this )
...
@@ -150,6 +160,8 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_system_header
=
0
;
p_sys
->
i_system_header
=
0
;
p_sys
->
i_pes_count
=
0
;
p_sys
->
i_pes_count
=
0
;
p_sys
->
i_psm_version
=
0
;
p_sys
->
i_instant_bitrate
=
0
;
p_sys
->
i_instant_bitrate
=
0
;
p_sys
->
i_instant_size
=
0
;
p_sys
->
i_instant_size
=
0
;
p_sys
->
i_instant_dts
=
0
;
p_sys
->
i_instant_dts
=
0
;
...
@@ -159,6 +171,21 @@ static int Open( vlc_object_t *p_this )
...
@@ -159,6 +171,21 @@ static int Open( vlc_object_t *p_this )
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"dts-delay"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"dts-delay"
,
&
val
);
p_sys
->
i_dts_delay
=
(
int64_t
)
val
.
i_int
*
1000
;
p_sys
->
i_dts_delay
=
(
int64_t
)
val
.
i_int
*
1000
;
/* Initialise CRC32 table */
if
(
p_sys
->
b_mpeg2
)
{
uint32_t
i
,
j
,
k
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
k
=
0
;
for
(
j
=
(
i
<<
24
)
|
0x800000
;
j
!=
0x80000000
;
j
<<=
1
)
k
=
(
k
<<
1
)
^
(((
k
^
j
)
&
0x80000000
)
?
0x04c11db7
:
0
);
p_sys
->
crc32_table
[
i
]
=
k
;
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -225,13 +252,31 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -225,13 +252,31 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
(
char
*
)
&
p_input
->
p_fmt
->
i_codec
);
(
char
*
)
&
p_input
->
p_fmt
->
i_codec
);
p_input
->
p_sys
=
p_stream
=
malloc
(
sizeof
(
ps_stream_t
)
);
p_input
->
p_sys
=
p_stream
=
malloc
(
sizeof
(
ps_stream_t
)
);
p_stream
->
i_stream_type
=
0x81
;
/* Init this new stream */
/* Init this new stream */
switch
(
p_input
->
p_fmt
->
i_codec
)
switch
(
p_input
->
p_fmt
->
i_codec
)
{
{
case
VLC_FOURCC
(
'm'
,
'p'
,
'1'
,
'v'
):
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpgv
,
0xe0
,
0xef
);
p_stream
->
i_stream_type
=
0x01
;
/* ISO/IEC 11172 Video */
break
;
case
VLC_FOURCC
(
'm'
,
'p'
,
'2'
,
'v'
):
case
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'v'
):
case
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'v'
):
p_stream
->
i_stream_id
=
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpgv
,
0xe0
,
0xef
);
StreamIdGet
(
p_sys
->
stream_id_mpgv
,
0xe0
,
0xef
);
p_stream
->
i_stream_type
=
0x02
;
/* ISO/IEC 13818 Video */
break
;
case
VLC_FOURCC
(
'm'
,
'p'
,
'4'
,
'v'
):
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpgv
,
0xe0
,
0xef
);
p_stream
->
i_stream_type
=
0x10
;
break
;
case
VLC_FOURCC
(
'h'
,
'2'
,
'6'
,
'4'
):
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpgv
,
0xe0
,
0xef
);
p_stream
->
i_stream_type
=
0x1b
;
break
;
break
;
case
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'm'
):
case
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'm'
):
p_stream
->
i_stream_id
=
p_stream
->
i_stream_id
=
...
@@ -248,6 +293,12 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -248,6 +293,12 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
case
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'a'
):
case
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'a'
):
p_stream
->
i_stream_id
=
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpga
,
0xc0
,
0xcf
);
StreamIdGet
(
p_sys
->
stream_id_mpga
,
0xc0
,
0xcf
);
p_stream
->
i_stream_type
=
0x03
;
/* ISO/IEC 11172 Audio */
break
;
case
VLC_FOURCC
(
'm'
,
'p'
,
'4'
,
'a'
):
p_stream
->
i_stream_id
=
StreamIdGet
(
p_sys
->
stream_id_mpga
,
0xc0
,
0xcf
);
p_stream
->
i_stream_type
=
0x0f
;
break
;
break
;
case
VLC_FOURCC
(
's'
,
'p'
,
'u'
,
' '
):
case
VLC_FOURCC
(
's'
,
'p'
,
'u'
,
' '
):
p_stream
->
i_stream_id
=
p_stream
->
i_stream_id
=
...
@@ -257,10 +308,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -257,10 +308,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
goto
error
;
goto
error
;
}
}
if
(
p_stream
->
i_stream_id
<
0
)
if
(
p_stream
->
i_stream_id
<
0
)
goto
error
;
{
goto
error
;
}
if
(
p_input
->
p_fmt
->
i_cat
==
AUDIO_ES
)
if
(
p_input
->
p_fmt
->
i_cat
==
AUDIO_ES
)
{
{
...
@@ -274,6 +322,37 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -274,6 +322,37 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
/* Try to set a sensible default value for the instant bitrate */
/* Try to set a sensible default value for the instant bitrate */
p_sys
->
i_instant_bitrate
+=
p_input
->
p_fmt
->
i_bitrate
+
1000
/* overhead */
;
p_sys
->
i_instant_bitrate
+=
p_input
->
p_fmt
->
i_bitrate
+
1000
/* overhead */
;
p_sys
->
i_psm_version
++
;
p_stream
->
lang
[
0
]
=
p_stream
->
lang
[
1
]
=
p_stream
->
lang
[
2
]
=
0
;
if
(
p_input
->
p_fmt
->
psz_language
)
{
char
*
psz
=
p_input
->
p_fmt
->
psz_language
;
const
iso639_lang_t
*
pl
=
NULL
;
if
(
strlen
(
psz
)
==
2
)
{
pl
=
GetLang_1
(
psz
);
}
else
if
(
strlen
(
psz
)
==
3
)
{
pl
=
GetLang_2B
(
psz
);
if
(
!
strcmp
(
pl
->
psz_iso639_1
,
"??"
)
)
{
pl
=
GetLang_2T
(
psz
);
}
}
if
(
pl
&&
strcmp
(
pl
->
psz_iso639_1
,
"??"
)
)
{
p_stream
->
lang
[
0
]
=
pl
->
psz_iso639_2T
[
0
];
p_stream
->
lang
[
1
]
=
pl
->
psz_iso639_2T
[
1
];
p_stream
->
lang
[
2
]
=
pl
->
psz_iso639_2T
[
2
];
msg_Dbg
(
p_mux
,
" - lang=%c%c%c"
,
p_stream
->
lang
[
0
],
p_stream
->
lang
[
1
],
p_stream
->
lang
[
2
]
);
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
...
@@ -330,6 +409,11 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -330,6 +409,11 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_sys
->
i_video_bound
--
;
p_sys
->
i_video_bound
--
;
}
}
/* Try to set a sensible default value for the instant bitrate */
p_sys
->
i_instant_bitrate
-=
(
p_input
->
p_fmt
->
i_bitrate
+
1000
);
p_sys
->
i_psm_version
++
;
free
(
p_stream
);
free
(
p_stream
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -399,6 +483,12 @@ static int Mux( sout_mux_t *p_mux )
...
@@ -399,6 +483,12 @@ static int Mux( sout_mux_t *p_mux )
}
}
}
}
/* Write regulary ProgramStreamMap */
if
(
p_sys
->
b_mpeg2
&&
p_sys
->
i_pes_count
%
300
==
0
)
{
MuxWritePSM
(
p_mux
,
&
p_ps
,
i_dts
);
}
/* Get and mux a packet */
/* Get and mux a packet */
p_data
=
block_FifoGet
(
p_input
->
p_fifo
);
p_data
=
block_FifoGet
(
p_input
->
p_fifo
);
E_
(
EStoPES
)(
p_mux
->
p_sout
,
&
p_data
,
p_data
,
E_
(
EStoPES
)(
p_mux
->
p_sout
,
&
p_data
,
p_data
,
...
@@ -610,6 +700,80 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, block_t **p_buf,
...
@@ -610,6 +700,80 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, block_t **p_buf,
block_ChainAppend
(
p_buf
,
p_hdr
);
block_ChainAppend
(
p_buf
,
p_hdr
);
}
}
static
void
MuxWritePSM
(
sout_mux_t
*
p_mux
,
block_t
**
p_buf
,
mtime_t
i_dts
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
block_t
*
p_hdr
;
bits_buffer_t
bits
;
int
i
,
i_psm_size
=
16
,
i_es_map_size
=
0
;
for
(
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout_input_t
*
p_input
=
p_mux
->
pp_inputs
[
i
];
ps_stream_t
*
p_stream
=
p_input
->
p_sys
;
i_es_map_size
+=
4
;
if
(
p_stream
->
lang
[
0
]
!=
0
)
i_es_map_size
+=
6
;
}
i_psm_size
+=
i_es_map_size
;
p_hdr
=
block_New
(
p_mux
,
i_psm_size
);
p_hdr
->
i_dts
=
p_hdr
->
i_pts
=
i_dts
;
bits_initwrite
(
&
bits
,
i_psm_size
,
p_hdr
->
p_buffer
);
bits_write
(
&
bits
,
32
,
0x01bc
);
bits_write
(
&
bits
,
16
,
i_psm_size
-
3
);
bits_write
(
&
bits
,
1
,
1
);
/* current_next_indicator */
bits_write
(
&
bits
,
2
,
0xF
);
/* reserved */
bits_write
(
&
bits
,
5
,
p_sys
->
i_psm_version
);
bits_write
(
&
bits
,
7
,
0xFF
);
/* reserved */
bits_write
(
&
bits
,
1
,
1
);
/* marker */
bits_write
(
&
bits
,
16
,
0
);
/* program_stream_info_length */
/* empty */
bits_write
(
&
bits
,
16
,
i_es_map_size
);
/* elementary_stream_map_length */
for
(
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout_input_t
*
p_input
=
p_mux
->
pp_inputs
[
i
];
ps_stream_t
*
p_stream
=
p_input
->
p_sys
;
bits_write
(
&
bits
,
8
,
p_stream
->
i_stream_type
);
/* stream_type */
bits_write
(
&
bits
,
8
,
p_stream
->
i_stream_id
);
/* elementary_stream_id */
/* ISO639 language descriptor */
if
(
p_stream
->
lang
[
0
]
!=
0
)
{
bits_write
(
&
bits
,
16
,
6
);
/* elementary_stream_info_length */
bits_write
(
&
bits
,
8
,
0x0a
);
/* descriptor_tag */
bits_write
(
&
bits
,
8
,
4
);
/* descriptor_length */
bits_write
(
&
bits
,
8
,
p_stream
->
lang
[
0
]
);
bits_write
(
&
bits
,
8
,
p_stream
->
lang
[
1
]
);
bits_write
(
&
bits
,
8
,
p_stream
->
lang
[
2
]
);
bits_write
(
&
bits
,
8
,
0
);
/* audio type: 0x00 undefined */
}
else
{
bits_write
(
&
bits
,
16
,
0
);
/* elementary_stream_info_length */
}
}
/* CRC32 */
{
uint32_t
i_crc
=
0xffffffff
;
for
(
i
=
0
;
i
<
p_hdr
->
i_buffer
;
i
++
)
i_crc
=
(
i_crc
<<
8
)
^
p_sys
->
crc32_table
[((
i_crc
>>
24
)
^
p_hdr
->
p_buffer
[
i
])
&
0xff
];
bits_write
(
&
bits
,
32
,
i_crc
);
}
block_ChainAppend
(
p_buf
,
p_hdr
);
}
/*
/*
* Find stream to be muxed.
* Find stream to be muxed.
*/
*/
...
...
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