Commit d75d16cb authored by Jean-Paul Saman's avatar Jean-Paul Saman

debian: patches: add splice point generation fixes.

Add patches for generating proper splice points in the adaptation field for
AUDIO and VIDEO elementary streams.
parent 5b2cfac6
From 8613243ee5271d502bc97605c353dfdb4ccdd6f4 Mon Sep 17 00:00:00 2001
From: Jean-Paul Saman <jean-paul.saman@m2x.nl>
Date: Thu, 9 Sep 2010 13:04:51 +0200
Subject: [PATCH] mux/mpeg/ts.c: Generate splice points
Index: vlc.git/modules/mux/mpeg/ts.c
===================================================================
--- vlc.git.orig/modules/mux/mpeg/ts.c 2010-10-21 11:43:35.499061780 +0200
+++ vlc.git/modules/mux/mpeg/ts.c 2010-10-21 11:44:06.231566263 +0200
@@ -346,6 +346,10 @@
int i_continuity_counter;
bool b_discontinuity;
ISO/IEC 13818-1:2007 page 25
Generate splicing_point_flag and splice_countdown for every AUDIO and VIDEO pid
in the stream at the beginning of the file. Since it is easier to generate a
negative countdown from 0 to -127, then to forcast when to start counting down.
When -127 is reached the splicing_point_flag is no longer set.
+ /* splice points */
+ bool b_splicing_point;
+ int8_t i_splice_countdown;
+
/* to be used for carriege of DIV3 */
vlc_fourcc_t i_bih_codec;
int i_bih_width, i_bih_height;
@@ -975,6 +979,8 @@
p_stream->i_codec = p_input->p_fmt->i_codec;
p_stream->i_continuity_counter = 0;
p_stream->b_discontinuity = false;
+ p_stream->b_splicing_point = true;
+ p_stream->i_splice_countdown = 0;
p_stream->i_decoder_specific_info = 0;
p_stream->p_decoder_specific_info = NULL;
The simplistic method is good enough for now.
---
mux_ts_splice_points.patch | 114 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 114 insertions(+), 0 deletions(-)
create mode 100644 mux_ts_splice_points.patch
@@ -1621,7 +1627,7 @@
i_max_pes_size = INT_MAX;
}
diff --git a/mux_ts_splice_points.patch b/mux_ts_splice_points.patch
new file mode 100644
index 0000000..6eb1747
--- /dev/null
+++ b/mux_ts_splice_points.patch
@@ -0,0 +1,114 @@
+diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
+index eb0ce12..7e349e1 100644
+--- a/modules/mux/mpeg/ts.c
++++ b/modules/mux/mpeg/ts.c
+@@ -346,6 +346,10 @@ typedef struct ts_stream_t
+ int i_continuity_counter;
+ bool b_discontinuity;
+
++ /* splice points */
++ bool b_splicing_point;
++ int8_t i_splice_countdown;
++
+ /* to be used for carriege of DIV3 */
+ vlc_fourcc_t i_bih_codec;
+ int i_bih_width, i_bih_height;
+@@ -975,6 +979,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
+ p_stream->i_codec = p_input->p_fmt->i_codec;
+ p_stream->i_continuity_counter = 0;
+ p_stream->b_discontinuity = false;
++ p_stream->b_splicing_point = true;
++ p_stream->i_splice_countdown = 0;
+ p_stream->i_decoder_specific_info = 0;
+ p_stream->p_decoder_specific_info = NULL;
+
+@@ -1621,7 +1627,7 @@ static int Mux( sout_mux_t *p_mux )
+ i_max_pes_size = INT_MAX;
+ }
+
+- EStoPES ( p_mux->p_sout, &p_data, 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 );
+@@ -2002,8 +2008,11 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
+
+ bool b_new_pes = false;
+ bool b_adaptation_field = false;
++ bool b_splicing_point = p_stream->b_splicing_point;
+
+- int i_payload_max = 184 - ( b_pcr ? 8 : 0 );
++ int i_payload_max = 184 - ( b_pcr ?
++ ( b_splicing_point ? 9 : 8 ) :
++ ( b_splicing_point ? 3 : 0 ) );
+ int i_payload;
+
+ if( p_stream->i_pes_used <= 0 )
+@@ -2013,7 +2022,7 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
+ i_payload = __MIN( (int)p_pes->i_buffer - p_stream->i_pes_used,
+ i_payload_max );
+
+- if( b_pcr || i_payload < i_payload_max )
++ if( b_pcr || b_splicing_point || i_payload < i_payload_max )
+ {
+ b_adaptation_field = true;
- EStoPES ( p_mux->p_sout, &p_data, 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 );
@@ -2002,8 +2008,11 @@
bool b_new_pes = false;
bool b_adaptation_field = false;
+ bool b_splicing_point = p_stream->b_splicing_point;
- int i_payload_max = 184 - ( b_pcr ? 8 : 0 );
+ int i_payload_max = 184 - ( b_pcr ?
+ ( b_splicing_point ? 9 : 8 ) :
+ ( b_splicing_point ? 3 : 0 ) );
int i_payload;
if( p_stream->i_pes_used <= 0 )
@@ -2013,7 +2022,7 @@
i_payload = __MIN( (int)p_pes->i_buffer - p_stream->i_pes_used,
i_payload_max );
- if( b_pcr || i_payload < i_payload_max )
+ if( b_pcr || b_splicing_point || i_payload < i_payload_max )
{
b_adaptation_field = true;
}
@@ -2044,10 +2053,11 @@
if( b_pcr )
{
int i_stuffing = i_payload_max - i_payload;
+ int i_stuffing_start = b_splicing_point ? 13 : 12;
p_ts->i_flags |= BLOCK_FLAG_CLOCK;
- p_ts->p_buffer[4] = 7 + i_stuffing;
+ p_ts->p_buffer[4] = (b_splicing_point ? 8 : 7) + i_stuffing;
p_ts->p_buffer[5] = 0x10; /* flags */
if( p_stream->b_discontinuity )
{
@@ -2061,20 +2071,41 @@
p_ts->p_buffer[10]= ( ( 0 )&0x80 ) | 0x7e;
p_ts->p_buffer[11]= 0;
- for( i = 12; i < 12 + i_stuffing; i++ )
+ if( b_splicing_point )
{
- p_ts->p_buffer[i] = 0xff;
+ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
+ /* in (+) or out (-) point */
+ p_ts->p_buffer[12] = p_stream->i_splice_countdown > 0 ?
+ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
+ p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
+ p_stream->i_splice_countdown++;
+ }
+@@ -2044,10 +2053,11 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
+ if( b_pcr )
+ {
+ int i_stuffing = i_payload_max - i_payload;
++ int i_stuffing_start = b_splicing_point ? 13 : 12;
+
+ p_ts->i_flags |= BLOCK_FLAG_CLOCK;
+
+- p_ts->p_buffer[4] = 7 + i_stuffing;
++ p_ts->p_buffer[4] = (b_splicing_point ? 8 : 7) + i_stuffing;
+ p_ts->p_buffer[5] = 0x10; /* flags */
+ if( p_stream->b_discontinuity )
+ for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
+ {
+@@ -2061,20 +2071,41 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
+ p_ts->p_buffer[10]= ( ( 0 )&0x80 ) | 0x7e;
+ p_ts->p_buffer[11]= 0;
+
+- for( i = 12; i < 12 + i_stuffing; i++ )
++ if( b_splicing_point )
+ p_ts->p_buffer[i] = 0xff;
}
}
else
{
int i_stuffing = i_payload_max - i_payload;
+ int i_stuffing_start = b_splicing_point ? 7 : 6;
- p_ts->p_buffer[4] = i_stuffing - 1;
+ p_ts->p_buffer[4] = i_stuffing + (b_splicing_point ? 2 : -1);
if( i_stuffing > 1 )
{
p_ts->p_buffer[5] = 0x00;
- for( i = 6; i < 6 + i_stuffing - 2; i++ )
+ if( b_splicing_point )
+ {
+- p_ts->p_buffer[i] = 0xff;
++ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
++ /* in (+) or out (-) point */
++ p_ts->p_buffer[12] = p_stream->i_splice_countdown > 0 ?
++ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
++ p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
++ p_stream->i_splice_countdown++;
++ }
++
++ for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
++ {
++ p_ts->p_buffer[i] = 0xff;
+ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
+ /* in (+) or out (-) point */
+ p_ts->p_buffer[6] = p_stream->i_splice_countdown > 0 ?
+ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
+ p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
+ p_stream->i_splice_countdown++;
+ }
+ }
+ else
+ {
+ int i_stuffing = i_payload_max - i_payload;
++ int i_stuffing_start = b_splicing_point ? 7 : 6;
+
+- p_ts->p_buffer[4] = i_stuffing - 1;
++ p_ts->p_buffer[4] = i_stuffing + (b_splicing_point ? 2 : -1);
+ if( i_stuffing > 1 )
+ {
+ p_ts->p_buffer[5] = 0x00;
+- for( i = 6; i < 6 + i_stuffing - 2; i++ )
++ if( b_splicing_point )
++ {
++ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
++ /* in (+) or out (-) point */
++ p_ts->p_buffer[6] = p_stream->i_splice_countdown > 0 ?
++ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
++ p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
++ p_stream->i_splice_countdown++;
++ }
++
++ for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
+ {
+ p_ts->p_buffer[i] = 0xff;
+ }
--
1.7.2.2
+ for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
{
p_ts->p_buffer[i] = 0xff;
}
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 7e349e1..dc95ecd 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -979,7 +979,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_stream->i_codec = p_input->p_fmt->i_codec;
p_stream->i_continuity_counter = 0;
p_stream->b_discontinuity = false;
- p_stream->b_splicing_point = true;
+ p_stream->b_splicing_point = false;
p_stream->i_splice_countdown = 0;
p_stream->i_decoder_specific_info = 0;
p_stream->p_decoder_specific_info = NULL;
@@ -1034,6 +1034,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
free( p_stream );
return VLC_EGENERIC;
}
+ p_stream->b_splicing_point = true;
p_sys->i_video_bound++;
break;
@@ -1074,6 +1075,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
free( p_stream );
return VLC_EGENERIC;
}
+ p_stream->b_splicing_point = true;
p_sys->i_audio_bound++;
break;
@@ -1173,7 +1175,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_stream->lang[i*3+0] = pl->psz_iso639_2T[0];
p_stream->lang[i*3+1] = pl->psz_iso639_2T[1];
p_stream->lang[i*3+2] = pl->psz_iso639_2T[2];
-
+
msg_Dbg( p_mux, " - lang=%c%c%c",
p_stream->lang[i*3+0], p_stream->lang[i*3+1],
p_stream->lang[i*3+2] );
@@ -2077,8 +2079,8 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
/* in (+) or out (-) point */
p_ts->p_buffer[12] = p_stream->i_splice_countdown > 0 ?
(0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
- p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
p_stream->i_splice_countdown++;
+ p_stream->b_splicing_point = (p_stream->i_splice_countdown >= 127) ? false : true;
}
for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
@@ -2101,7 +2103,7 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
/* in (+) or out (-) point */
p_ts->p_buffer[6] = p_stream->i_splice_countdown > 0 ?
(0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
- p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
+ p_stream->b_splicing_point = (p_stream->i_splice_countdown >= 127) ? false : true;
p_stream->i_splice_countdown++;
}
--
1.7.2.3
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index dc95ecd..e3b8c04 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -2094,19 +2094,19 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
int i_stuffing_start = b_splicing_point ? 7 : 6;
p_ts->p_buffer[4] = i_stuffing + (b_splicing_point ? 2 : -1);
- if( i_stuffing > 1 )
+ p_ts->p_buffer[5] = 0x00;
+ if( b_splicing_point )
{
- p_ts->p_buffer[5] = 0x00;
- if( b_splicing_point )
- {
- p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
- /* in (+) or out (-) point */
- p_ts->p_buffer[6] = p_stream->i_splice_countdown > 0 ?
- (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
- p_stream->b_splicing_point = (p_stream->i_splice_countdown >= 127) ? false : true;
- p_stream->i_splice_countdown++;
- }
+ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
+ /* in (+) or out (-) point */
+ p_ts->p_buffer[6] = p_stream->i_splice_countdown > 0 ?
+ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
+ p_stream->b_splicing_point = (p_stream->i_splice_countdown >= 127) ? false : true;
+ p_stream->i_splice_countdown++;
+ }
+ if( i_stuffing > 1 )
+ {
for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
{
p_ts->p_buffer[i] = 0xff;
--
1.7.2.3
......@@ -18,3 +18,5 @@
#CVE-2010-2937.patch
901-modules-codec-x264.c-relax-requirement-to-X264_BUILD.patch
0001-mux-mpeg-ts.c-Generate-splice-points.patch
0002-mux-mpeg-ts.c-splice_point-generation-fixes.patch
0003-mux-mpeg-ts.c-write-splice_countdown-field-when-no-p.patch
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment