+
+static mtime_t DecoderTeletextFixTs( mtime_t i_ts, mtime_t i_ts_delay )
+{
+ mtime_t current_date = mdate();
+
+ /* FIXME I don't really like that, es_out SHOULD do it using the video pts */
+ if( !i_ts || i_ts > current_date + 10000000 || i_ts < current_date )
+ {
+ /* ETSI EN 300 472 Annex A : do not take into account the PTS
+ * for teletext streams. */
+ return current_date + 400000 + i_ts_delay;
+ }
+ return i_ts;
+}
+
+static void DecoderSoutBufferFixTs( block_t *p_block,
+ input_clock_t *p_clock, mtime_t i_ts_delay,
+ bool b_teletext )
+{
+ assert( p_clock );
+
+ p_block->i_rate = input_clock_GetRate( p_clock );
+
+ if( p_block->i_dts > 0 )
+ p_block->i_dts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_dts );
+
+ if( p_block->i_pts > 0 )
+ p_block->i_pts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_pts );
+
+ if( p_block->i_length > 0 )
+ p_block->i_length = ( p_block->i_length * p_block->i_rate +
+ INPUT_RATE_DEFAULT-1 ) / INPUT_RATE_DEFAULT;
+
+ if( b_teletext )
+ p_block->i_pts = DecoderTeletextFixTs( p_block->i_pts, i_ts_delay );
+}
+static void DecoderAoutBufferFixTs( aout_buffer_t *p_buffer,
+ input_clock_t *p_clock, mtime_t i_ts_delay )
+{
+ /* sout display module does not set clock */
+ if( !p_clock )
+ return;
+
+ if( p_buffer->start_date )
+ p_buffer->start_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->start_date );
+
+ if( p_buffer->end_date )
+ p_buffer->end_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->end_date );
+}
+static void DecoderVoutBufferFixTs( picture_t *p_picture,
+ input_clock_t *p_clock, mtime_t i_ts_delay )
+{
+ /* sout display module does not set clock */
+ if( !p_clock )
+ return;
+
+ if( p_picture->date )
+ p_picture->date = input_clock_GetTS( p_clock, i_ts_delay, p_picture->date );
+}
+static void DecoderSpuBufferFixTs( subpicture_t *p_subpic,
+ input_clock_t *p_clock, mtime_t i_ts_delay,
+ bool b_teletext )
+{
+ bool b_ephemere = p_subpic->i_start == p_subpic->i_stop;
+
+ /* sout display module does not set clock */
+ if( !p_clock )
+ return;
+
+ if( p_subpic->i_start )
+ p_subpic->i_start = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_start );
+
+ if( p_subpic->i_stop )
+ p_subpic->i_stop = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_stop );
+
+ /* Do not create ephemere picture because of rounding errors */
+ if( !b_ephemere && p_subpic->i_start == p_subpic->i_stop )
+ p_subpic->i_stop++;
+
+ if( b_teletext )
+ p_subpic->i_start = DecoderTeletextFixTs( p_subpic->i_start, i_ts_delay );
+}
+