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
9fcc258c
Commit
9fcc258c
authored
12 years ago
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TS mux: cosmetics, reduce indentation
parent
1e8a2b5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
104 deletions
+90
-104
modules/mux/mpeg/ts.c
modules/mux/mpeg/ts.c
+90
-104
No files found.
modules/mux/mpeg/ts.c
View file @
9fcc258c
...
...
@@ -1271,8 +1271,6 @@ static bool MuxStreams(sout_mux_t *p_mux )
i
=
-
1
;
}
sout_input_t
*
p_input
;
ts_stream_t
*
p_stream
;
int64_t
i_spu_delay
=
0
;
if
(
i
==
-
1
)
p_input
=
p_sys
->
p_pcr_input
;
...
...
@@ -1280,7 +1278,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
continue
;
else
p_input
=
p_mux
->
pp_inputs
[
i
];
p_stream
=
(
ts_stream_t
*
)
p_input
->
p_sys
;
ts_stream_t
*
p_stream
=
(
ts_stream_t
*
)
p_input
->
p_sys
;
if
(
(
p_stream
!=
p_pcr_stream
||
p_stream
->
i_pes_length
>=
i_shaping_delay
)
&&
...
...
@@ -1307,9 +1305,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
/* Don't mux the SPU yet if it is too early */
block_t
*
p_spu
=
block_FifoShow
(
p_input
->
p_fifo
);
i_spu_delay
=
p_spu
->
i_dts
-
p_pcr_stream
->
i_pes_dts
;
int64_t
i_spu_delay
=
p_spu
->
i_dts
-
p_pcr_stream
->
i_pes_dts
;
if
(
(
i_spu_delay
>
i_shaping_delay
)
&&
(
i_spu_delay
<
INT64_C
(
100000000
)
)
)
continue
;
...
...
@@ -1378,119 +1374,111 @@ static bool MuxStreams(sout_mux_t *p_mux )
p_pcr_stream
->
i_pes_used
=
0
;
p_pcr_stream
->
i_pes_length
=
0
;
}
continue
;
}
else
int
i_header_size
=
0
;
int
i_max_pes_size
=
0
;
int
b_data_alignment
=
0
;
if
(
p_input
->
p_fmt
->
i_cat
==
SPU_ES
)
{
int
i_header_size
=
0
;
int
i_max_pes_size
=
0
;
int
b_data_alignment
=
0
;
if
(
p_input
->
p_fmt
->
i_cat
==
SPU_ES
)
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_SUBT
)
{
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_SUBT
)
/* Prepend header */
p_data
=
block_Realloc
(
p_data
,
2
,
p_data
->
i_buffer
);
p_data
->
p_buffer
[
0
]
=
(
(
p_data
->
i_buffer
-
2
)
>>
8
)
&
0xff
;
p_data
->
p_buffer
[
1
]
=
(
(
p_data
->
i_buffer
-
2
)
)
&
0xff
;
/* remove trailling \0 if any */
if
(
p_data
->
i_buffer
>
2
&&
p_data
->
p_buffer
[
p_data
->
i_buffer
-
1
]
==
'\0'
)
p_data
->
i_buffer
--
;
/* Append a empty sub (sub text only) */
if
(
p_data
->
i_length
>
0
&&
(
p_data
->
i_buffer
!=
1
||
*
p_data
->
p_buffer
!=
' '
)
)
{
/* Prepend header */
p_data
=
block_Realloc
(
p_data
,
2
,
p_data
->
i_buffer
);
p_data
->
p_buffer
[
0
]
=
(
(
p_data
->
i_buffer
-
2
)
>>
8
)
&
0xff
;
p_data
->
p_buffer
[
1
]
=
(
(
p_data
->
i_buffer
-
2
)
)
&
0xff
;
/* remove trailling \0 if any */
if
(
p_data
->
i_buffer
>
2
&&
p_data
->
p_buffer
[
p_data
->
i_buffer
-
1
]
==
'\0'
)
p_data
->
i_buffer
--
;
/* Append a empty sub (sub text only) */
if
(
p_data
->
i_length
>
0
&&
!
(
p_data
->
i_buffer
==
1
&&
*
p_data
->
p_buffer
==
' '
)
)
{
block_t
*
p_spu
=
block_New
(
p_mux
,
3
);
block_t
*
p_spu
=
block_New
(
p_mux
,
3
);
p_spu
->
i_dts
=
p_spu
->
i_pts
=
p_data
->
i_dts
+
p_data
->
i_length
;
p_spu
->
i_length
=
1000
;
p_spu
->
i_dts
=
p_data
->
i_dts
+
p_data
->
i_length
;
p_spu
->
i_pts
=
p_spu
->
i_dts
;
p_spu
->
i_length
=
1000
;
p_spu
->
p_buffer
[
0
]
=
0
;
p_spu
->
p_buffer
[
1
]
=
1
;
p_spu
->
p_buffer
[
2
]
=
' '
;
p_spu
->
p_buffer
[
0
]
=
0
;
p_spu
->
p_buffer
[
1
]
=
1
;
p_spu
->
p_buffer
[
2
]
=
' '
;
EStoPES
(
p_mux
->
p_sout
,
&
p_spu
,
p_spu
,
p_input
->
p_fmt
,
p_stream
->
i_stream_id
,
1
,
0
,
0
,
0
);
p_data
->
p_next
=
p_spu
;
}
}
else
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_TELETEXT
)
{
/* EN 300 472 */
i_header_size
=
0x24
;
b_data_alignment
=
1
;
}
else
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_DVBS
)
{
/* EN 300 743 */
b_data_alignment
=
1
;
EStoPES
(
p_mux
->
p_sout
,
&
p_spu
,
p_spu
,
p_input
->
p_fmt
,
p_stream
->
i_stream_id
,
1
,
0
,
0
,
0
);
p_data
->
p_next
=
p_spu
;
}
}
else
if
(
p_data
->
i_length
<
0
||
p_data
->
i_length
>
2000000
)
else
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_TELETEXT
)
{
/*
FIXME choose a better value, but anyway we
* should never have to do that */
p_data
->
i_length
=
1000
;
/*
EN 300 472 */
i_header_size
=
0x24
;
b_data_alignment
=
1
;
}
p_stream
->
i_pes_length
+=
p_data
->
i_length
;
if
(
p_stream
->
i_pes_dts
==
0
)
else
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_DVBS
)
{
p_stream
->
i_pes_dts
=
p_data
->
i_dts
;
/* EN 300 743 */
b_data_alignment
=
1
;
}
}
else
if
(
p_data
->
i_length
<
0
||
p_data
->
i_length
>
2000000
)
{
/* FIXME choose a better value, but anyway we
* should never have to do that */
p_data
->
i_length
=
1000
;
}
/* Convert to pes */
if
(
p_stream
->
i_stream_id
==
0xa0
&&
p_data
->
i_pts
<=
0
)
{
/* XXX yes I know, it's awful, but it's needed,
* so don't remove it ... */
p_data
->
i_pts
=
p_data
->
i_dts
;
}
p_stream
->
i_pes_length
+=
p_data
->
i_length
;
if
(
p_stream
->
i_pes_dts
==
0
)
{
p_stream
->
i_pes_dts
=
p_data
->
i_dts
;
}
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_DIRAC
)
{
b_data_alignment
=
1
;
/* dirac pes packets should be unbounded in
* length, specify a suitibly large max size */
i_max_pes_size
=
INT_MAX
;
}
/* Convert to pes */
if
(
p_stream
->
i_stream_id
==
0xa0
&&
p_data
->
i_pts
<=
0
)
{
/* XXX yes I know, it's awful, but it's needed,
* so don't remove it ... */
p_data
->
i_pts
=
p_data
->
i_dts
;
}
EStoPES
(
p_mux
->
p_sout
,
&
p_data
,
p_data
,
p_input
->
p_fmt
,
p_stream
->
i_stream_id
,
1
,
b_data_alignment
,
i_header_size
,
i_max_pes_size
);
if
(
p_input
->
p_fmt
->
i_codec
==
VLC_CODEC_DIRAC
)
{
b_data_alignment
=
1
;
/* dirac pes packets should be unbounded in
* length, specify a suitibly large max size */
i_max_pes_size
=
INT_MAX
;
}
BufferChainAppend
(
&
p_stream
->
chain_pes
,
p_data
);
EStoPES
(
p_mux
->
p_sout
,
&
p_data
,
p_data
,
p_input
->
p_fmt
,
p_stream
->
i_stream_id
,
1
,
b_data_alignment
,
i_header_size
,
i_max_pes_size
);
if
(
p_sys
->
b_use_key_frames
&&
p_stream
==
p_pcr_stream
&&
(
p_data
->
i_flags
&
BLOCK_FLAG_TYPE_I
)
&&
!
(
p_data
->
i_flags
&
BLOCK_FLAG_NO_KEYFRAME
)
&&
(
p_stream
->
i_pes_length
>
400000
)
)
{
i_shaping_delay
=
p_stream
->
i_pes_length
;
p_stream
->
b_key_frame
=
1
;
}
BufferChainAppend
(
&
p_stream
->
chain_pes
,
p_data
);
if
(
p_sys
->
b_use_key_frames
&&
p_stream
==
p_pcr_stream
&&
(
p_data
->
i_flags
&
BLOCK_FLAG_TYPE_I
)
&&
!
(
p_data
->
i_flags
&
BLOCK_FLAG_NO_KEYFRAME
)
&&
(
p_stream
->
i_pes_length
>
400000
)
)
{
i_shaping_delay
=
p_stream
->
i_pes_length
;
p_stream
->
b_key_frame
=
1
;
}
}
/* save */
const
mtime_t
i_pcr_dts
=
p_pcr_stream
->
i_pes_dts
;
const
mtime_t
i_pcr_length
=
p_pcr_stream
->
i_pes_length
;
p_pcr_stream
->
b_key_frame
=
0
;
...
...
@@ -1533,14 +1521,12 @@ static bool MuxStreams(sout_mux_t *p_mux )
i_packet_count
+=
chain_ts
.
i_depth
;
/* msg_Dbg( p_mux, "estimated pck=%d", i_packet_count ); */
for
(;;
)
const
mtime_t
i_pcr_dts
=
p_pcr_stream
->
i_pes_dts
;
for
(;;)
{
int
i_stream
=
-
1
;
mtime_t
i_dts
=
0
;
ts_stream_t
*
p_stream
;
sout_input_t
*
p_input
;
block_t
*
p_ts
;
bool
b_pcr
;
/* Select stream (lowest dts) */
for
(
int
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
...
...
@@ -1564,10 +1550,10 @@ static bool MuxStreams(sout_mux_t *p_mux )
break
;
}
p_stream
=
(
ts_stream_t
*
)
p_mux
->
pp_inputs
[
i_stream
]
->
p_sys
;
p_input
=
p_mux
->
pp_inputs
[
i_stream
];
sout_input_t
*
p_input
=
p_mux
->
pp_inputs
[
i_stream
];
/* do we need to issue pcr */
b_pcr
=
false
;
b
ool
b
_pcr
=
false
;
if
(
p_stream
==
p_pcr_stream
&&
i_pcr_dts
+
i_packet_pos
*
i_pcr_length
/
i_packet_count
>=
p_sys
->
i_pcr
+
p_sys
->
i_pcr_delay
)
...
...
@@ -1578,7 +1564,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
}
/* Build the TS packet */
p_ts
=
TSNew
(
p_mux
,
p_stream
,
b_pcr
);
block_t
*
p_ts
=
TSNew
(
p_mux
,
p_stream
,
b_pcr
);
if
(
p_sys
->
csa
!=
NULL
&&
(
p_input
->
p_fmt
->
i_cat
!=
AUDIO_ES
||
p_sys
->
b_crypt_audio
)
&&
(
p_input
->
p_fmt
->
i_cat
!=
VIDEO_ES
||
p_sys
->
b_crypt_video
)
)
...
...
This diff is collapsed.
Click to expand it.
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