Commit 10318107 authored by François Cartegnie's avatar François Cartegnie 🤞

date_t: always init to TS_INVALID

parent c0f850f8
......@@ -156,11 +156,11 @@ static int Demux(demux_t *demux)
sys->position += count;
block->i_nb_samples = block->i_buffer / 4;
block->i_dts = block->i_pts = VLC_TS_0 + date_Get(&sys->pts);
block->i_dts = block->i_pts = date_Get(&sys->pts);
date_Increment(&sys->pts, block->i_nb_samples);
es_out_Send(demux->out, sys->es, block);
es_out_SetPCR(demux->out, VLC_TS_0 + date_Get(&sys->pts));
es_out_SetPCR(demux->out, date_Get(&sys->pts));
return VLC_DEMUXER_SUCCESS;
}
......@@ -254,6 +254,7 @@ static int DemuxOpen(vlc_object_t *obj, vcddev_t *dev, unsigned track)
sys->es = es_out_Add(demux->out, &fmt);
date_Init(&sys->pts, 44100, 1);
date_Set(&sys->pts, VLC_TS_0);
sys->position = 0;
demux->pf_demux = Demux;
......
......@@ -290,6 +290,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt );
date_Init( &p_sys->pts, fmt.audio.i_rate, 1 );
date_Set( &p_sys->pts, 0 );
return VLC_SUCCESS;
}
......@@ -463,7 +464,7 @@ static block_t *GrabJack( demux_t *p_demux )
i_read = jack_ringbuffer_read( p_sys->p_jack_ringbuffer, ( char * ) p_block->p_buffer, i_read );
p_block->i_dts = p_block->i_pts = VLC_TS_0 + date_Increment( &p_sys->pts,
p_block->i_dts = p_block->i_pts = date_Increment( &p_sys->pts,
i_read/(p_sys->i_channels * p_sys->jack_sample_size) );
p_sys->p_block_audio = p_block;
......
......@@ -97,6 +97,7 @@ vlc_module_end ()
p_qtsound = p_demux;
currentAudioBuffer = nil;
date_Init(&date, 44100, 1);
date_Set(&date, 0);
currentPts = 0;
previousPts = 0;
}
......@@ -116,7 +117,7 @@ vlc_module_end ()
@synchronized (self) {
numberOfSamples = [sampleBuffer numberOfSamples];
date_Increment(&date,numberOfSamples);
currentPts = VLC_TS_0 + date_Get(&date);
currentPts = date_Get(&date);
tempAudioBufferList = [sampleBuffer audioBufferListWithOptions:0];
if (tempAudioBufferList->mNumberBuffers == 2) {
......
......@@ -65,7 +65,7 @@ static int DemuxOnce (demux_t *demux, bool master)
lldiv_t d;
unsigned h, m, s, f;
d = lldiv (pts, CLOCK_FREQ);
d = lldiv (pts - VLC_TS_0, CLOCK_FREQ);
f = d.rem * sys->date.i_divider_num / sys->date.i_divider_den / CLOCK_FREQ;
d = lldiv (d.quot, 60);
s = d.rem;
......
......@@ -270,7 +270,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->fmt_out.audio.i_physical_channels = vlc_chan_maps[i_channels];
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
p_dec->pf_decode = DecodeAudio;
p_dec->pf_flush = Flush;
......
......@@ -279,7 +279,6 @@ static int Open( decoder_t *p_dec, bool b_packetizer )
/* Misc init */
date_Init( &p_sys->end_date, 48000, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
/* Set output properties */
p_dec->fmt_out.audio.i_rate = 48000;
......
......@@ -289,7 +289,6 @@ static int DecoderOpen( vlc_object_t *p_this )
assert( p_sys->framebits );
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
p_dec->pf_decode = DecodeBlock;
p_dec->pf_flush = Flush;
......
......@@ -278,7 +278,6 @@ static int Open(vlc_object_t *p_this)
// Initialize date (for PTS)
date_Init(&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1);
date_Set(&p_sys->end_date, VLC_TS_INVALID);
p_dec->p_sys = p_sys;
p_dec->pf_decode = DecodeBlock;
......
......@@ -251,7 +251,6 @@ int InitAudioDec( vlc_object_t *obj )
/* Try to set as much information as possible but do not trust it */
SetupOutputFormat( p_dec, false );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
if( !p_dec->fmt_out.audio.i_rate )
p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
if( p_dec->fmt_out.audio.i_rate )
......
......@@ -727,7 +727,6 @@ int InitVideoEnc( vlc_object_t *p_this )
p_context->sample_rate = p_enc->fmt_out.audio.i_rate;
date_Init( &p_sys->buffer_date, p_enc->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->buffer_date, AV_NOPTS_VALUE );
p_context->time_base.num = 1;
p_context->time_base.den = p_context->sample_rate;
p_context->channels = p_enc->fmt_out.audio.i_channels;
......@@ -1266,11 +1265,15 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
if( likely( p_sys->frame->pts != AV_NOPTS_VALUE) )
if( likely( date_Get( &p_sys->buffer_date ) != VLC_TS_INVALID) )
{
/* Convert to AV timing */
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) - VLC_TS_0;
p_sys->frame->pts = p_sys->frame->pts * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
date_Increment( &p_sys->buffer_date, p_sys->frame->nb_samples );
}
else p_sys->frame->pts = AV_NOPTS_VALUE;
if( likely( p_aout_buf ) )
{
......@@ -1287,8 +1290,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
p_aout_buf->p_buffer += leftover;
p_aout_buf->i_buffer -= leftover;
if( likely( p_sys->frame->pts != AV_NOPTS_VALUE) )
p_aout_buf->i_pts = date_Get( &p_sys->buffer_date );
p_aout_buf->i_pts = date_Get( &p_sys->buffer_date );
}
if(unlikely( ( (leftover + buffer_delay) < p_sys->i_buffer_out ) &&
......@@ -1391,8 +1393,14 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
else
p_sys->frame->nb_samples = p_sys->i_frame_size;
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
if( likely(date_Get( &p_sys->buffer_date ) != VLC_TS_INVALID) )
{
/* Convert to AV timing */
p_sys->frame->pts = date_Get( &p_sys->buffer_date ) - VLC_TS_0;
p_sys->frame->pts = p_sys->frame->pts * p_sys->p_context->time_base.den /
CLOCK_FREQ / p_sys->p_context->time_base.num;
}
else p_sys->frame->pts = AV_NOPTS_VALUE;
const int in_bytes = p_sys->frame->nb_samples *
p_sys->p_context->channels * p_sys->i_sample_bytes;
......@@ -1421,7 +1429,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
p_aout_buf->p_buffer += in_bytes;
p_aout_buf->i_buffer -= in_bytes;
p_aout_buf->i_nb_samples -= p_sys->frame->nb_samples;
if( likely( p_sys->frame->pts != AV_NOPTS_VALUE) )
if( likely(date_Get( &p_sys->buffer_date ) != VLC_TS_INVALID) )
date_Increment( &p_sys->buffer_date, p_sys->frame->nb_samples );
p_block = encode_avframe( p_enc, p_sys, p_sys->frame );
......
......@@ -614,7 +614,6 @@ int InitVideoDec( vlc_object_t *obj )
/* ***** misc init ***** */
date_Init(&p_sys->pts, 1, 30001);
date_Set(&p_sys->pts, VLC_TS_INVALID);
p_sys->b_first_frame = true;
p_sys->i_late_frames = 0;
p_sys->b_from_preroll = false;
......
......@@ -597,6 +597,7 @@ static int DecOpen( decoder_t *p_dec )
date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
else
date_Init( &p_sys->end_date, 25 /* FIXME */, 1 );
date_Set( &p_sys->end_date, VLC_TS_0 );
free( p_vih );
free( p_wf );
......
......@@ -128,8 +128,6 @@ static int Open( vlc_object_t *p_this )
}
/* Misc init */
date_Set( &p_sys->date, 0 );
p_dec->fmt_out.audio.channel_type = p_dec->fmt_in.audio.channel_type;
if( p_dec->fmt_in.i_extra > 0 )
......@@ -160,6 +158,7 @@ static int Open( vlc_object_t *p_this )
/* Will be initalised from first frame */
p_dec->fmt_out.audio.i_rate = 0;
p_dec->fmt_out.audio.i_channels = 0;
date_Set( &p_sys->date, VLC_TS_INVALID );
}
p_dec->fmt_out.i_codec = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N;
......@@ -321,7 +320,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
{
date_Set( &p_sys->date, i_pts );
}
else if( !date_Get( &p_sys->date ) )
else if( date_Get( &p_sys->date ) == VLC_TS_INVALID )
{
/* We've just started the stream, wait for the first PTS. */
FlushBuffer( p_sys, SIZE_MAX );
......
......@@ -326,7 +326,6 @@ static void DecoderMetadataCallback( const FLAC__StreamDecoder *decoder,
p_sys->stream_info = metadata->data.stream_info;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
......@@ -628,7 +627,7 @@ static void Flush( decoder_t *p_dec )
if( p_sys->b_stream_info )
FLAC__stream_decoder_flush( p_sys->p_flac );
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/****************************************************************************
......
......@@ -174,7 +174,6 @@ static int Open (vlc_object_t *p_this)
p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
p_dec->fmt_out.audio.i_bitspersample = 32;
date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1);
date_Set(&p_sys->end_date, VLC_TS_INVALID);
p_dec->p_sys = p_sys;
p_dec->pf_decode = DecodeBlock;
......
......@@ -202,7 +202,6 @@ static int DecoderOpen( vlc_object_t *p_this )
p_sys->table = table;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
return VLC_SUCCESS;
}
......
......@@ -252,7 +252,7 @@ static int OpenCommon( decoder_t *p_dec, bool b_packetizer )
/* Misc init */
p_sys->b_packetizer = b_packetizer;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
p_sys->i_type = i_type;
p_sys->i_header_size = i_header_size;
p_sys->i_chans_to_reorder = 0;
......@@ -317,7 +317,7 @@ static void Flush( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/*****************************************************************************
......
......@@ -190,7 +190,6 @@ static int UpdateAudioFormat( decoder_t *p_dec )
{
p_dec->fmt_out.audio.i_rate = (unsigned int)frame_info.rate;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
return decoder_UpdateAudioFormat( p_dec );
......
......@@ -1471,7 +1471,7 @@ int DecodeAudio ( decoder_t *p_dec, block_t *p_block )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release( p_block );
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
if(!p_sys->in.b_flushed)
{
msg_Dbg(p_dec, "flushing");
......
......@@ -179,7 +179,7 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_ENOMEM;
p_sys->b_has_headers = false;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
/* Set output properties */
p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
......@@ -386,7 +386,7 @@ static void Flush( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/*****************************************************************************
......
......@@ -907,8 +907,8 @@ typedef struct
block_t *p_chain;
struct picture_pts_t pts_tlb[SCHRO_PTS_TLB_SIZE];
mtime_t i_pts_offset;
mtime_t i_field_time;
unsigned i_pts_offset;
unsigned i_field_duration;
bool b_eos_signalled;
bool b_eos_pulled;
......@@ -1455,16 +1455,17 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pic )
}
}
date_Init( &date, p_enc->fmt_in.video.i_frame_rate, p_enc->fmt_in.video.i_frame_rate_base );
date_Init( &date, p_enc->fmt_in.video.i_frame_rate * 2, p_enc->fmt_in.video.i_frame_rate_base );
date_Set( &date, VLC_TS_0 );
/* FIXME - Unlike dirac-research codec Schro doesn't have a function that returns the delay in pics yet.
* Use a default of 1
*/
date_Increment( &date, 1 );
p_sys->i_pts_offset = date_Get( &date );
date_Increment( &date, 2 /* 2 fields, 1 frame */ );
p_sys->i_pts_offset = date_Get( &date ) - VLC_TS_0;
if( schro_encoder_setting_get_double( p_sys->p_schro, "interlaced_coding" ) > 0.0 ) {
date_Set( &date, 0 );
date_Increment( &date, 1);
p_sys->i_field_time = date_Get( &date ) / 2;
date_Set( &date, VLC_TS_0 );
date_Increment( &date, 1 /* field */ );
p_sys->i_field_duration = date_Get( &date ) - VLC_TS_0;
}
schro_video_format_set_std_signal_range( p_sys->p_format, SCHRO_SIGNAL_RANGE_8BIT_VIDEO );
......@@ -1503,13 +1504,13 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pic )
* pts lookaside buffer and dts queue, offset to correspond
* to a one field delay. */
if( schro_encoder_setting_get_double( p_sys->p_schro, "interlaced_coding" ) > 0.0 ) {
StorePicturePTS( p_enc, p_sys->i_input_picnum, p_pic->date + p_sys->i_field_time );
StorePicturePTS( p_enc, p_sys->i_input_picnum, p_pic->date + p_sys->i_field_duration );
p_sys->i_input_picnum++;
p_block = block_Alloc( 1 );
if( !p_block )
return NULL;
p_block->i_dts = p_pic->date - p_sys->i_pts_offset + p_sys->i_field_time;
p_block->i_dts = p_pic->date - p_sys->i_pts_offset + p_sys->i_field_duration;
block_FifoPut( p_sys->p_dts_fifo, p_block );
p_block = NULL;
}
......
......@@ -210,7 +210,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->rtp_rate = p_dec->fmt_in.audio.i_rate;
p_sys->b_has_headers = false;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
/* Set output properties */
p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
......@@ -554,7 +554,7 @@ static void Flush( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/*****************************************************************************
......
......@@ -58,7 +58,7 @@ static void Flush(decoder_t *dec)
{
decoder_sys_t *sys = dec->p_sys;
date_Set(&sys->end_date, 0);
date_Set(&sys->end_date, VLC_TS_INVALID);
}
static block_t *DecodeBlock(decoder_t *dec, block_t **block_ptr)
......@@ -155,7 +155,6 @@ static int Open(vlc_object_t *object)
sys->is_12bit = dec->fmt_in.audio.i_bitspersample == 12;
date_Init(&sys->end_date, dec->fmt_in.audio.i_rate, 1);
date_Set(&sys->end_date, 0);
for (unsigned i = 0; i < sizeof(sys->shuffle) / sizeof(*sys->shuffle); i++) {
const unsigned a = sys->is_pal ? 18 : 15;
......
......@@ -244,7 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_ENOMEM;
/* Misc init */
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
p_sys->i_last_block_size = 0;
p_sys->b_packetizer = false;
p_sys->b_has_headers = false;
......@@ -455,7 +455,7 @@ static void Flush( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
date_Set( &p_sys->end_date, 0 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/*****************************************************************************
......
......@@ -100,6 +100,7 @@ static int Open( vlc_object_t * p_this )
/* There is CDG_FRAME_RATE frames per second */
date_Init( &p_sys->pts, CDG_FRAME_RATE, 1 );
date_Set( &p_sys->pts, VLC_TS_0 );
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
......@@ -132,12 +133,12 @@ static int Demux( demux_t *p_demux )
if( i_date >= date_Get( &p_sys->pts ) + i_delta )
{
p_block->i_dts = p_block->i_pts = VLC_TS_0 + i_date;
date_Set( &p_sys->pts, i_date );
date_Set( &p_sys->pts, VLC_TS_0 + i_date );
}
else
{
p_block->i_dts = VLC_TS_0 + i_date;
p_block->i_pts = VLC_TS_0 + date_Get( &p_sys->pts );
p_block->i_pts = date_Get( &p_sys->pts );
}
es_out_SetPCR( p_demux->out, p_block->i_pts );
......
......@@ -130,6 +130,7 @@ static int Open (vlc_object_t *obj)
sys->es = es_out_Add (demux->out, &fmt);
date_Init (&sys->pts, RATE, 1);
date_Set(&sys->pts, VLC_TS_0);
/* Titles */
unsigned n = gme_track_count (sys->emu);
......@@ -228,7 +229,7 @@ static int Demux (demux_t *demux)
return VLC_DEMUXER_EOF;
}
block->i_pts = block->i_dts = VLC_TS_0 + date_Get (&sys->pts);
block->i_pts = block->i_dts = date_Get (&sys->pts);
es_out_SetPCR (demux->out, block->i_pts);
es_out_Send (demux->out, sys->es, block);
date_Increment (&sys->pts, SAMPLES);
......
......@@ -104,7 +104,7 @@ typedef struct
es_out_id_t *es;
mtime_t duration;
bool is_realtime;
mtime_t pts_origin;
int64_t pts_offset;
mtime_t pts_next;
date_t pts;
} demux_sys_t;
......@@ -191,7 +191,7 @@ static int Demux(demux_t *demux)
return VLC_DEMUXER_EOF;
mtime_t deadline;
const mtime_t pts_first = sys->pts_origin + date_Get(&sys->pts);
const mtime_t pts_first = sys->pts_offset + date_Get(&sys->pts);
if (sys->pts_next != VLC_TS_INVALID) {
deadline = sys->pts_next;
} else if (sys->is_realtime) {
......@@ -208,8 +208,8 @@ static int Demux(demux_t *demux)
}
for (;;) {
const mtime_t pts = sys->pts_origin + date_Get(&sys->pts);
if (sys->duration >= 0 && pts >= sys->pts_origin + sys->duration)
const mtime_t pts = sys->pts_offset + date_Get(&sys->pts);
if (sys->duration >= 0 && pts >= VLC_TS_0 + sys->pts_offset + sys->duration)
return VLC_DEMUXER_EOF;
if (pts >= deadline)
......@@ -256,20 +256,20 @@ static int Control(demux_t *demux, int query, va_list args)
}
case DEMUX_GET_TIME: {
int64_t *time = va_arg(args, int64_t *);
*time = sys->pts_origin + date_Get(&sys->pts);
*time = sys->pts_offset + date_Get(&sys->pts);
return VLC_SUCCESS;
}
case DEMUX_SET_TIME: {
if (sys->duration < 0 || sys->is_realtime)
return VLC_EGENERIC;
int64_t time = va_arg(args, int64_t);
date_Set(&sys->pts, VLC_CLIP(time - sys->pts_origin, 0, sys->duration));
date_Set(&sys->pts, VLC_CLIP(time - sys->pts_offset, VLC_TS_0, sys->duration));
return VLC_SUCCESS;
}
case DEMUX_SET_NEXT_DEMUX_TIME: {
mtime_t pts_next = VLC_TS_0 + va_arg(args, mtime_t);
if (sys->pts_next == VLC_TS_INVALID)
sys->pts_origin = pts_next;
sys->pts_offset = pts_next - VLC_TS_0;
sys->pts_next = pts_next;
return VLC_SUCCESS;
}
......@@ -733,10 +733,10 @@ static int Open(vlc_object_t *object)
sys->es = es_out_Add(demux->out, &fmt);
sys->duration = CLOCK_FREQ * var_InheritFloat(demux, "image-duration");
sys->is_realtime = var_InheritBool(demux, "image-realtime");
sys->pts_origin = sys->is_realtime ? mdate() : 0;
sys->pts_offset = sys->is_realtime ? mdate() : 0;
sys->pts_next = VLC_TS_INVALID;
date_Init(&sys->pts, fmt.video.i_frame_rate, fmt.video.i_frame_rate_base);
date_Set(&sys->pts, 0);
date_Set(&sys->pts, VLC_TS_0);
es_format_Clean(&fmt);
......
......@@ -217,7 +217,7 @@ static int Open( vlc_object_t *p_this )
/* init time */
date_Init( &p_sys->pts, settings.mFrequency, 1 );
date_Set( &p_sys->pts, 0 );
date_Set( &p_sys->pts, VLC_TS_0 );
p_sys->i_length = ModPlug_GetLength( p_sys->f ) * INT64_C(1000);
msg_Dbg( p_demux, "MOD loaded name=%s length=%"PRId64"ms",
......@@ -277,7 +277,7 @@ static int Demux( demux_t *p_demux )
}
p_frame->i_buffer = i_read;
p_frame->i_dts =
p_frame->i_pts = VLC_TS_0 + date_Get( &p_sys->pts );
p_frame->i_pts = date_Get( &p_sys->pts );
es_out_SetPCR( p_demux->out, p_frame->i_pts );
es_out_Send( p_demux->out, p_sys->es, p_frame );
......@@ -304,7 +304,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
pf = va_arg( args, double* );
if( p_sys->i_length > 0 )
{
double current = date_Get( &p_sys->pts );
double current = date_Get( &p_sys->pts ) - VLC_TS_0;
double length = p_sys->i_length;
*pf = current / length;
return VLC_SUCCESS;
......@@ -318,7 +318,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( i64 >= 0 && i64 <= p_sys->i_length )
{
ModPlug_Seek( p_sys->f, i64 / 1000 );
date_Set( &p_sys->pts, i64 );
date_Set( &p_sys->pts, VLC_TS_0 + i64 );
return VLC_SUCCESS;
}
......@@ -340,7 +340,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( i64 >= 0 && i64 <= p_sys->i_length )
{
ModPlug_Seek( p_sys->f, i64 / 1000 );
date_Set( &p_sys->pts, i64 );
date_Set( &p_sys->pts, VLC_TS_0 + i64 );
return VLC_SUCCESS;
}
......
......@@ -208,6 +208,7 @@ static int Open( vlc_object_t * p_this )
/* initialize timing */
date_Init( &p_sys->pts, p_sys->fmt.audio.i_rate, 1 );
date_Set( &p_sys->pts, VLC_TS_0 );
/* calculate 50ms frame size/time */
p_sys->i_frame_samples = __MAX( p_sys->fmt.audio.i_rate / 20, 1 );
......@@ -247,7 +248,7 @@ static int Demux( demux_t *p_demux )
if( p_block == NULL )
return VLC_DEMUXER_EOF;
p_block->i_dts = p_block->i_pts = VLC_TS_0 + date_Get( &p_sys->pts );
p_block->i_dts = p_block->i_pts = date_Get( &p_sys->pts );
es_out_SetPCR( p_demux->out, p_block->i_pts );
es_out_Send( p_demux->out, p_sys->p_es, p_block );
......
......@@ -341,6 +341,7 @@ valid:
u_fps_num, u_fps_den, 0);
date_Init( &p_sys->pcr, p_sys->fmt_video.video.i_frame_rate,
p_sys->fmt_video.video.i_frame_rate_base );
date_Set( &p_sys->pcr, VLC_TS_0 );
if( !p_sys->fmt_video.video.i_bits_per_pixel )
{
......@@ -394,7 +395,7 @@ static int Demux( demux_t *p_demux )
mtime_t i_pcr = date_Get( &p_sys->pcr );
/* Call the pace control */
es_out_SetPCR( p_demux->out, VLC_TS_0 + i_pcr );
es_out_SetPCR( p_demux->out, i_pcr );
if( p_sys->b_y4m )
{
......@@ -417,7 +418,7 @@ static int Demux( demux_t *p_demux )
if( p_block == NULL )
return VLC_DEMUXER_EOF;
p_block->i_dts = p_block->i_pts = VLC_TS_0 + i_pcr;
p_block->i_dts = p_block->i_pts = i_pcr;
es_out_Send( p_demux->out, p_sys->p_es_video, p_block );
date_Increment( &p_sys->pcr, 1 );
......
......@@ -166,6 +166,7 @@ static int Open (vlc_object_t *obj)
sys->es = es_out_Add (demux->out, &fmt);
date_Init (&sys->pts, fmt.audio.i_rate, 1);
date_Set(&sys->pts, VLC_TS_0);
sys->tune->selectSong (0);
result = (sys->player->load (sys->tune) >=0 );
......@@ -220,7 +221,7 @@ static int Demux (demux_t *demux)
return VLC_DEMUXER_EOF;
}
block->i_buffer = i_read;
block->i_pts = block->i_dts = VLC_TS_0 + date_Get (&sys->pts);
block->i_pts = block->i_dts = date_Get (&sys->pts);
es_out_SetPCR (demux->out, block->i_pts);
......