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) ...@@ -156,11 +156,11 @@ static int Demux(demux_t *demux)
sys->position += count; sys->position += count;
block->i_nb_samples = block->i_buffer / 4; 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); date_Increment(&sys->pts, block->i_nb_samples);
es_out_Send(demux->out, sys->es, block); 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; return VLC_DEMUXER_SUCCESS;
} }
...@@ -254,6 +254,7 @@ static int DemuxOpen(vlc_object_t *obj, vcddev_t *dev, unsigned track) ...@@ -254,6 +254,7 @@ static int DemuxOpen(vlc_object_t *obj, vcddev_t *dev, unsigned track)
sys->es = es_out_Add(demux->out, &fmt); sys->es = es_out_Add(demux->out, &fmt);
date_Init(&sys->pts, 44100, 1); date_Init(&sys->pts, 44100, 1);
date_Set(&sys->pts, VLC_TS_0);
sys->position = 0; sys->position = 0;
demux->pf_demux = Demux; demux->pf_demux = Demux;
......
...@@ -290,6 +290,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -290,6 +290,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt ); p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt );
date_Init( &p_sys->pts, fmt.audio.i_rate, 1 ); date_Init( &p_sys->pts, fmt.audio.i_rate, 1 );
date_Set( &p_sys->pts, 0 );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -463,7 +464,7 @@ static block_t *GrabJack( demux_t *p_demux ) ...@@ -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 ); 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) ); i_read/(p_sys->i_channels * p_sys->jack_sample_size) );
p_sys->p_block_audio = p_block; p_sys->p_block_audio = p_block;
......
...@@ -97,6 +97,7 @@ vlc_module_end () ...@@ -97,6 +97,7 @@ vlc_module_end ()
p_qtsound = p_demux; p_qtsound = p_demux;
currentAudioBuffer = nil; currentAudioBuffer = nil;
date_Init(&date, 44100, 1); date_Init(&date, 44100, 1);
date_Set(&date, 0);
currentPts = 0; currentPts = 0;
previousPts = 0; previousPts = 0;
} }
...@@ -116,7 +117,7 @@ vlc_module_end () ...@@ -116,7 +117,7 @@ vlc_module_end ()
@synchronized (self) { @synchronized (self) {
numberOfSamples = [sampleBuffer numberOfSamples]; numberOfSamples = [sampleBuffer numberOfSamples];
date_Increment(&date,numberOfSamples); date_Increment(&date,numberOfSamples);
currentPts = VLC_TS_0 + date_Get(&date); currentPts = date_Get(&date);
tempAudioBufferList = [sampleBuffer audioBufferListWithOptions:0]; tempAudioBufferList = [sampleBuffer audioBufferListWithOptions:0];
if (tempAudioBufferList->mNumberBuffers == 2) { if (tempAudioBufferList->mNumberBuffers == 2) {
......
...@@ -65,7 +65,7 @@ static int DemuxOnce (demux_t *demux, bool master) ...@@ -65,7 +65,7 @@ static int DemuxOnce (demux_t *demux, bool master)
lldiv_t d; lldiv_t d;
unsigned h, m, s, f; 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; f = d.rem * sys->date.i_divider_num / sys->date.i_divider_den / CLOCK_FREQ;
d = lldiv (d.quot, 60); d = lldiv (d.quot, 60);
s = d.rem; s = d.rem;
......
...@@ -270,7 +270,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -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]; 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_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_decode = DecodeAudio;
p_dec->pf_flush = Flush; p_dec->pf_flush = Flush;
......
...@@ -279,7 +279,6 @@ static int Open( decoder_t *p_dec, bool b_packetizer ) ...@@ -279,7 +279,6 @@ static int Open( decoder_t *p_dec, bool b_packetizer )
/* Misc init */ /* Misc init */
date_Init( &p_sys->end_date, 48000, 1 ); date_Init( &p_sys->end_date, 48000, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
/* Set output properties */ /* Set output properties */
p_dec->fmt_out.audio.i_rate = 48000; p_dec->fmt_out.audio.i_rate = 48000;
......
...@@ -289,7 +289,6 @@ static int DecoderOpen( vlc_object_t *p_this ) ...@@ -289,7 +289,6 @@ static int DecoderOpen( vlc_object_t *p_this )
assert( p_sys->framebits ); assert( p_sys->framebits );
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 ); 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_decode = DecodeBlock;
p_dec->pf_flush = Flush; p_dec->pf_flush = Flush;
......
...@@ -278,7 +278,6 @@ static int Open(vlc_object_t *p_this) ...@@ -278,7 +278,6 @@ static int Open(vlc_object_t *p_this)
// Initialize date (for PTS) // Initialize date (for PTS)
date_Init(&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1); 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->p_sys = p_sys;
p_dec->pf_decode = DecodeBlock; p_dec->pf_decode = DecodeBlock;
......
...@@ -251,7 +251,6 @@ int InitAudioDec( vlc_object_t *obj ) ...@@ -251,7 +251,6 @@ int InitAudioDec( vlc_object_t *obj )
/* Try to set as much information as possible but do not trust it */ /* Try to set as much information as possible but do not trust it */
SetupOutputFormat( p_dec, false ); SetupOutputFormat( p_dec, false );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
if( !p_dec->fmt_out.audio.i_rate ) if( !p_dec->fmt_out.audio.i_rate )
p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.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 ) if( p_dec->fmt_out.audio.i_rate )
......
...@@ -727,7 +727,6 @@ int InitVideoEnc( vlc_object_t *p_this ) ...@@ -727,7 +727,6 @@ int InitVideoEnc( vlc_object_t *p_this )
p_context->sample_rate = p_enc->fmt_out.audio.i_rate; 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_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.num = 1;
p_context->time_base.den = p_context->sample_rate; p_context->time_base.den = p_context->sample_rate;
p_context->channels = p_enc->fmt_out.audio.i_channels; 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 ...@@ -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->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay; 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 / if( likely( date_Get( &p_sys->buffer_date ) != VLC_TS_INVALID) )
CLOCK_FREQ / p_sys->p_context->time_base.num; {
/* Convert to AV timing */
if( likely( p_sys->frame->pts != AV_NOPTS_VALUE) ) 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 ); date_Increment( &p_sys->buffer_date, p_sys->frame->nb_samples );
}
else p_sys->frame->pts = AV_NOPTS_VALUE;
if( likely( p_aout_buf ) ) 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 ...@@ -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->p_buffer += leftover;
p_aout_buf->i_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 ) && 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 ) ...@@ -1391,8 +1393,14 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
else else
p_sys->frame->nb_samples = p_sys->i_frame_size; p_sys->frame->nb_samples = p_sys->i_frame_size;
p_sys->frame->format = p_sys->p_context->sample_fmt; 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 / if( likely(date_Get( &p_sys->buffer_date ) != VLC_TS_INVALID) )
CLOCK_FREQ / p_sys->p_context->time_base.num; {
/* 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 * const int in_bytes = p_sys->frame->nb_samples *
p_sys->p_context->channels * p_sys->i_sample_bytes; 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 ) ...@@ -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->p_buffer += in_bytes;
p_aout_buf->i_buffer -= in_bytes; p_aout_buf->i_buffer -= in_bytes;
p_aout_buf->i_nb_samples -= p_sys->frame->nb_samples; 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 ); date_Increment( &p_sys->buffer_date, p_sys->frame->nb_samples );
p_block = encode_avframe( p_enc, p_sys, p_sys->frame ); p_block = encode_avframe( p_enc, p_sys, p_sys->frame );
......
...@@ -614,7 +614,6 @@ int InitVideoDec( vlc_object_t *obj ) ...@@ -614,7 +614,6 @@ int InitVideoDec( vlc_object_t *obj )
/* ***** misc init ***** */ /* ***** misc init ***** */
date_Init(&p_sys->pts, 1, 30001); date_Init(&p_sys->pts, 1, 30001);
date_Set(&p_sys->pts, VLC_TS_INVALID);
p_sys->b_first_frame = true; p_sys->b_first_frame = true;
p_sys->i_late_frames = 0; p_sys->i_late_frames = 0;
p_sys->b_from_preroll = false; p_sys->b_from_preroll = false;
......
...@@ -597,6 +597,7 @@ static int DecOpen( decoder_t *p_dec ) ...@@ -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 ); date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
else else
date_Init( &p_sys->end_date, 25 /* FIXME */, 1 ); date_Init( &p_sys->end_date, 25 /* FIXME */, 1 );
date_Set( &p_sys->end_date, VLC_TS_0 );
free( p_vih ); free( p_vih );
free( p_wf ); free( p_wf );
......
...@@ -128,8 +128,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -128,8 +128,6 @@ static int Open( vlc_object_t *p_this )
} }
/* Misc init */ /* Misc init */
date_Set( &p_sys->date, 0 );
p_dec->fmt_out.audio.channel_type = p_dec->fmt_in.audio.channel_type; p_dec->fmt_out.audio.channel_type = p_dec->fmt_in.audio.channel_type;
if( p_dec->fmt_in.i_extra > 0 ) if( p_dec->fmt_in.i_extra > 0 )
...@@ -160,6 +158,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -160,6 +158,7 @@ static int Open( vlc_object_t *p_this )
/* Will be initalised from first frame */ /* Will be initalised from first frame */
p_dec->fmt_out.audio.i_rate = 0; p_dec->fmt_out.audio.i_rate = 0;
p_dec->fmt_out.audio.i_channels = 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; 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 ) ...@@ -321,7 +320,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
{ {
date_Set( &p_sys->date, i_pts ); 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. */ /* We've just started the stream, wait for the first PTS. */
FlushBuffer( p_sys, SIZE_MAX ); FlushBuffer( p_sys, SIZE_MAX );
......
...@@ -326,7 +326,6 @@ static void DecoderMetadataCallback( const FLAC__StreamDecoder *decoder, ...@@ -326,7 +326,6 @@ static void DecoderMetadataCallback( const FLAC__StreamDecoder *decoder,
p_sys->stream_info = metadata->data.stream_info; p_sys->stream_info = metadata->data.stream_info;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 ); date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
break; break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT: case FLAC__METADATA_TYPE_VORBIS_COMMENT:
...@@ -628,7 +627,7 @@ static void Flush( decoder_t *p_dec ) ...@@ -628,7 +627,7 @@ static void Flush( decoder_t *p_dec )
if( p_sys->b_stream_info ) if( p_sys->b_stream_info )
FLAC__stream_decoder_flush( p_sys->p_flac ); 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) ...@@ -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.i_codec = VLC_CODEC_FL32;
p_dec->fmt_out.audio.i_bitspersample = 32; p_dec->fmt_out.audio.i_bitspersample = 32;
date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1); 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->p_sys = p_sys;
p_dec->pf_decode = DecodeBlock; p_dec->pf_decode = DecodeBlock;
......
...@@ -202,7 +202,6 @@ static int DecoderOpen( vlc_object_t *p_this ) ...@@ -202,7 +202,6 @@ static int DecoderOpen( vlc_object_t *p_this )
p_sys->table = table; p_sys->table = table;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 ); 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; return VLC_SUCCESS;
} }
......
...@@ -252,7 +252,7 @@ static int OpenCommon( decoder_t *p_dec, bool b_packetizer ) ...@@ -252,7 +252,7 @@ static int OpenCommon( decoder_t *p_dec, bool b_packetizer )
/* Misc init */ /* Misc init */
p_sys->b_packetizer = b_packetizer; 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_type = i_type;
p_sys->i_header_size = i_header_size; p_sys->i_header_size = i_header_size;
p_sys->i_chans_to_reorder = 0; p_sys->i_chans_to_reorder = 0;
...@@ -317,7 +317,7 @@ static void Flush( decoder_t *p_dec ) ...@@ -317,7 +317,7 @@ static void Flush( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; 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 ) ...@@ -190,7 +190,6 @@ static int UpdateAudioFormat( decoder_t *p_dec )
{ {
p_dec->fmt_out.audio.i_rate = (unsigned int)frame_info.rate; 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_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 ); return decoder_UpdateAudioFormat( p_dec );
......
...@@ -1471,7 +1471,7 @@ int DecodeAudio ( decoder_t *p_dec, block_t *p_block ) ...@@ -1471,7 +1471,7 @@ int DecodeAudio ( decoder_t *p_dec, block_t *p_block )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{ {
block_Release( p_block ); 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) if(!p_sys->in.b_flushed)
{ {
msg_Dbg(p_dec, "flushing"); msg_Dbg(p_dec, "flushing");
......
...@@ -179,7 +179,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -179,7 +179,7 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->b_has_headers = false; 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 */ /* Set output properties */
p_dec->fmt_out.i_codec = VLC_CODEC_FL32; p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
...@@ -386,7 +386,7 @@ static void Flush( decoder_t *p_dec ) ...@@ -386,7 +386,7 @@ static void Flush( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; 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 ...@@ -907,8 +907,8 @@ typedef struct
block_t *p_chain; block_t *p_chain;
struct picture_pts_t pts_tlb[SCHRO_PTS_TLB_SIZE]; struct picture_pts_t pts_tlb[SCHRO_PTS_TLB_SIZE];
mtime_t i_pts_offset; unsigned i_pts_offset;
mtime_t i_field_time; unsigned i_field_duration;
bool b_eos_signalled; bool b_eos_signalled;
bool b_eos_pulled; bool b_eos_pulled;
...@@ -1455,16 +1455,17 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pic ) ...@@ -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. /* FIXME - Unlike dirac-research codec Schro doesn't have a function that returns the delay in pics yet.
* Use a default of 1 * Use a default of 1
*/ */
date_Increment( &date, 1 ); date_Increment( &date, 2 /* 2 fields, 1 frame */ );
p_sys->i_pts_offset = date_Get( &date ); 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 ) { if( schro_encoder_setting_get_double( p_sys->p_schro, "interlaced_coding" ) > 0.0 ) {
date_Set( &date, 0 ); date_Set( &date, VLC_TS_0 );
date_Increment( &date, 1); date_Increment( &date, 1 /* field */ );
p_sys->i_field_time = date_Get( &date ) / 2; 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 ); 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 ) ...@@ -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 * pts lookaside buffer and dts queue, offset to correspond
* to a one field delay. */ * to a one field delay. */
if( schro_encoder_setting_get_double( p_sys->p_schro, "interlaced_coding" ) > 0.0 ) { 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_sys->i_input_picnum++;
p_block = block_Alloc( 1 ); p_block = block_Alloc( 1 );
if( !p_block ) if( !p_block )
return NULL; 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 ); block_FifoPut( p_sys->p_dts_fifo, p_block );
p_block = NULL; p_block = NULL;
} }
......
...@@ -210,7 +210,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -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->rtp_rate = p_dec->fmt_in.audio.i_rate;
p_sys->b_has_headers = false; 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 */ /* Set output properties */
p_dec->fmt_out.i_codec = VLC_CODEC_S16N; p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
...@@ -554,7 +554,7 @@ static void Flush( decoder_t *p_dec ) ...@@ -554,7 +554,7 @@ static void Flush( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; 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) ...@@ -58,7 +58,7 @@ static void Flush(decoder_t *dec)
{ {
decoder_sys_t *sys = dec->p_sys; 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) static block_t *DecodeBlock(decoder_t *dec, block_t **block_ptr)
...@@ -155,7 +155,6 @@ static int Open(vlc_object_t *object) ...@@ -155,7 +155,6 @@ static int Open(vlc_object_t *object)
sys->is_12bit = dec->fmt_in.audio.i_bitspersample == 12; sys->is_12bit = dec->fmt_in.audio.i_bitspersample == 12;
date_Init(&sys->end_date, dec->fmt_in.audio.i_rate, 1); 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++) { for (unsigned i = 0; i < sizeof(sys->shuffle) / sizeof(*sys->shuffle); i++) {
const unsigned a = sys->is_pal ? 18 : 15; const unsigned a = sys->is_pal ? 18 : 15;
......
...@@ -244,7 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -244,7 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
/* Misc init */ /* 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->i_last_block_size = 0;
p_sys->b_packetizer = false; p_sys->b_packetizer = false;
p_sys->b_has_headers = false; p_sys->b_has_headers = false;
...@@ -455,7 +455,7 @@ static void Flush( decoder_t *p_dec ) ...@@ -455,7 +455,7 @@ static void Flush( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; 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 );
}