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 Index: vlc.git/modules/mux/mpeg/ts.c
From: Jean-Paul Saman <jean-paul.saman@m2x.nl> ===================================================================
Date: Thu, 9 Sep 2010 13:04:51 +0200 --- vlc.git.orig/modules/mux/mpeg/ts.c 2010-10-21 11:43:35.499061780 +0200
Subject: [PATCH] mux/mpeg/ts.c: Generate splice points +++ vlc.git/modules/mux/mpeg/ts.c 2010-10-21 11:44:06.231566263 +0200
@@ -346,6 +346,10 @@
ISO/IEC 13818-1:2007 page 25 int i_continuity_counter;
Generate splicing_point_flag and splice_countdown for every AUDIO and VIDEO pid bool b_discontinuity;
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. + /* splice points */
When -127 is reached the splicing_point_flag is no longer set. + bool b_splicing_point;
+ int8_t i_splice_countdown;
The simplistic method is good enough for now. +
--- /* to be used for carriege of DIV3 */
mux_ts_splice_points.patch | 114 ++++++++++++++++++++++++++++++++++++++++++++ vlc_fourcc_t i_bih_codec;
1 files changed, 114 insertions(+), 0 deletions(-) int i_bih_width, i_bih_height;
create mode 100644 mux_ts_splice_points.patch @@ -975,6 +979,8 @@
p_stream->i_codec = p_input->p_fmt->i_codec;
diff --git a/mux_ts_splice_points.patch b/mux_ts_splice_points.patch p_stream->i_continuity_counter = 0;
new file mode 100644 p_stream->b_discontinuity = false;
index 0000000..6eb1747 + p_stream->b_splicing_point = true;
--- /dev/null + p_stream->i_splice_countdown = 0;
+++ b/mux_ts_splice_points.patch p_stream->i_decoder_specific_info = 0;
@@ -0,0 +1,114 @@ p_stream->p_decoder_specific_info = NULL;
+diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
+index eb0ce12..7e349e1 100644 @@ -1621,7 +1627,7 @@
+--- a/modules/mux/mpeg/ts.c i_max_pes_size = INT_MAX;
++++ b/modules/mux/mpeg/ts.c }
+@@ -346,6 +346,10 @@ typedef struct ts_stream_t
+ int i_continuity_counter; - EStoPES ( p_mux->p_sout, &p_data, p_data,
+ bool b_discontinuity; + EStoPES ( p_mux->p_sout, &p_data, p_data,
+ p_input->p_fmt, p_stream->i_stream_id,
++ /* splice points */ 1, b_data_alignment, i_header_size,
++ bool b_splicing_point; i_max_pes_size );
++ int8_t i_splice_countdown; @@ -2002,8 +2008,11 @@
++
+ /* to be used for carriege of DIV3 */ bool b_new_pes = false;
+ vlc_fourcc_t i_bih_codec; bool b_adaptation_field = false;
+ int i_bih_width, i_bih_height; + bool b_splicing_point = p_stream->b_splicing_point;
+@@ -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; - int i_payload_max = 184 - ( b_pcr ? 8 : 0 );
+ p_stream->i_continuity_counter = 0; + int i_payload_max = 184 - ( b_pcr ?
+ p_stream->b_discontinuity = false; + ( b_splicing_point ? 9 : 8 ) :
++ p_stream->b_splicing_point = true; + ( b_splicing_point ? 3 : 0 ) );
++ p_stream->i_splice_countdown = 0; int i_payload;
+ p_stream->i_decoder_specific_info = 0;
+ p_stream->p_decoder_specific_info = NULL; if( p_stream->i_pes_used <= 0 )
+ @@ -2013,7 +2022,7 @@
+@@ -1621,7 +1627,7 @@ static int Mux( sout_mux_t *p_mux ) i_payload = __MIN( (int)p_pes->i_buffer - p_stream->i_pes_used,
+ i_max_pes_size = INT_MAX; i_payload_max );
+ }
+ - if( b_pcr || i_payload < i_payload_max )
+- EStoPES ( p_mux->p_sout, &p_data, p_data, + if( b_pcr || b_splicing_point || i_payload < i_payload_max )
++ EStoPES ( p_mux->p_sout, &p_data, p_data, {
+ p_input->p_fmt, p_stream->i_stream_id, b_adaptation_field = true;
+ 1, b_data_alignment, i_header_size, }
+ i_max_pes_size ); @@ -2044,10 +2053,11 @@
+@@ -2002,8 +2008,11 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, if( b_pcr )
+ {
+ bool b_new_pes = false; int i_stuffing = i_payload_max - i_payload;
+ bool b_adaptation_field = false; + int i_stuffing_start = b_splicing_point ? 13 : 12;
++ bool b_splicing_point = p_stream->b_splicing_point;
+ p_ts->i_flags |= BLOCK_FLAG_CLOCK;
+- int i_payload_max = 184 - ( b_pcr ? 8 : 0 );
++ int i_payload_max = 184 - ( b_pcr ? - p_ts->p_buffer[4] = 7 + i_stuffing;
++ ( b_splicing_point ? 9 : 8 ) : + p_ts->p_buffer[4] = (b_splicing_point ? 8 : 7) + i_stuffing;
++ ( b_splicing_point ? 3 : 0 ) ); p_ts->p_buffer[5] = 0x10; /* flags */
+ int i_payload; if( p_stream->b_discontinuity )
+ {
+ if( p_stream->i_pes_used <= 0 ) @@ -2061,20 +2071,41 @@
+@@ -2013,7 +2022,7 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, p_ts->p_buffer[10]= ( ( 0 )&0x80 ) | 0x7e;
+ i_payload = __MIN( (int)p_pes->i_buffer - p_stream->i_pes_used, p_ts->p_buffer[11]= 0;
+ i_payload_max );
+ - for( i = 12; i < 12 + i_stuffing; i++ )
+- if( b_pcr || i_payload < i_payload_max ) + if( b_splicing_point )
++ if( b_pcr || b_splicing_point || i_payload < i_payload_max ) {
+ { - p_ts->p_buffer[i] = 0xff;
+ b_adaptation_field = true; + p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
+ } + /* in (+) or out (-) point */
+@@ -2044,10 +2053,11 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, + p_ts->p_buffer[12] = p_stream->i_splice_countdown > 0 ?
+ if( b_pcr ) + (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0;
+ { + p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127);
+ int i_stuffing = i_payload_max - i_payload; + p_stream->i_splice_countdown++;
++ int i_stuffing_start = b_splicing_point ? 13 : 12; + }
+ +
+ p_ts->i_flags |= BLOCK_FLAG_CLOCK; + for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
+ + {
+- p_ts->p_buffer[4] = 7 + i_stuffing; + p_ts->p_buffer[i] = 0xff;
++ p_ts->p_buffer[4] = (b_splicing_point ? 8 : 7) + i_stuffing; }
+ p_ts->p_buffer[5] = 0x10; /* flags */ }
+ if( p_stream->b_discontinuity ) else
+ { {
+@@ -2061,20 +2071,41 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, int i_stuffing = i_payload_max - i_payload;
+ p_ts->p_buffer[10]= ( ( 0 )&0x80 ) | 0x7e; + int i_stuffing_start = b_splicing_point ? 7 : 6;
+ p_ts->p_buffer[11]= 0;
+ - p_ts->p_buffer[4] = i_stuffing - 1;
+- for( i = 12; i < 12 + i_stuffing; i++ ) + p_ts->p_buffer[4] = i_stuffing + (b_splicing_point ? 2 : -1);
++ if( b_splicing_point ) if( i_stuffing > 1 )
+ { {
+- p_ts->p_buffer[i] = 0xff; p_ts->p_buffer[5] = 0x00;
++ p_ts->p_buffer[5] |= 0x04; /* flag splicing point */ - for( i = 6; i < 6 + i_stuffing - 2; i++ )
++ /* in (+) or out (-) point */ + if( b_splicing_point )
++ p_ts->p_buffer[12] = p_stream->i_splice_countdown > 0 ? + {
++ (0x80 | (p_stream->i_splice_countdown & 0x7f)) : 0; + p_ts->p_buffer[5] |= 0x04; /* flag splicing point */
++ p_stream->b_splicing_point = !(p_stream->i_splice_countdown == 127); + /* in (+) or out (-) point */
++ p_stream->i_splice_countdown++; + 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);
++ for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ ) + p_stream->i_splice_countdown++;
++ { + }
++ p_ts->p_buffer[i] = 0xff; +
+ } + for( i = i_stuffing_start; i < i_stuffing_start + i_stuffing; i++ )
+ } {
+ else p_ts->p_buffer[i] = 0xff;
+ { }
+ 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
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 @@ ...@@ -18,3 +18,5 @@
#CVE-2010-2937.patch #CVE-2010-2937.patch
901-modules-codec-x264.c-relax-requirement-to-X264_BUILD.patch 901-modules-codec-x264.c-relax-requirement-to-X264_BUILD.patch
0001-mux-mpeg-ts.c-Generate-splice-points.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