mirror of
https://github.com/videolan/vlc.git
synced 2024-11-23 18:03:48 +08:00
modules: use vlc_tick_from_samples()
This commit is contained in:
parent
cc09e6abf8
commit
cc79f1f98f
@ -222,12 +222,12 @@ static void *Thread (void *data)
|
||||
if (snd_pcm_delay (pcm, &delay))
|
||||
delay = 0;
|
||||
delay += frames;
|
||||
pts -= (CLOCK_FREQ * delay) / sys->rate;
|
||||
pts -= vlc_tick_from_samples(delay, sys->rate);
|
||||
|
||||
block->i_buffer = snd_pcm_frames_to_bytes (pcm, frames);
|
||||
block->i_nb_samples = frames;
|
||||
block->i_pts = pts;
|
||||
block->i_length = (CLOCK_FREQ * frames) / sys->rate;
|
||||
block->i_length = vlc_tick_from_samples(frames, sys->rate);
|
||||
|
||||
es_out_SetPCR(demux->out, block->i_pts);
|
||||
es_out_Send (demux->out, sys->es, block);
|
||||
|
@ -703,8 +703,8 @@ static int Demux( demux_t *p_demux )
|
||||
goto error;
|
||||
}
|
||||
|
||||
p_video_frame->i_length = CLOCK_FREQ * p_sys->frame_rate_denom / p_sys->frame_rate_num;
|
||||
p_video_frame->i_pts = CLOCK_FREQ * p_sys->frame_no * p_sys->frame_rate_denom / p_sys->frame_rate_num;
|
||||
p_video_frame->i_length = vlc_tick_from_samples(p_sys->frame_rate_denom, p_sys->frame_rate_num);
|
||||
p_video_frame->i_pts = vlc_tick_from_samples(p_sys->frame_no * p_sys->frame_rate_denom, p_sys->frame_rate_num);
|
||||
|
||||
if( !p_sys->p_dcp->audio_reels.empty() )
|
||||
{
|
||||
@ -741,8 +741,8 @@ static int Demux( demux_t *p_demux )
|
||||
p_sys->pi_chan_table, VLC_CODEC_S24L );
|
||||
|
||||
p_audio_frame->i_buffer = AudioFrameBuff.Size();
|
||||
p_audio_frame->i_length = CLOCK_FREQ * p_sys->frame_rate_denom / p_sys->frame_rate_num;
|
||||
p_audio_frame->i_pts = CLOCK_FREQ * p_sys->frame_no * p_sys->frame_rate_denom / p_sys->frame_rate_num;
|
||||
p_audio_frame->i_length = vlc_tick_from_samples(p_sys->frame_rate_denom, p_sys->frame_rate_num);
|
||||
p_audio_frame->i_pts = vlc_tick_from_samples(p_sys->frame_no * p_sys->frame_rate_denom, p_sys->frame_rate_num);
|
||||
/* Video is the main pts */
|
||||
if ( p_audio_frame->i_pts != p_video_frame->i_pts ) {
|
||||
msg_Err( p_demux, "Audio and video frame pts are not in sync" );
|
||||
|
@ -494,7 +494,7 @@ static int InitVideo( demux_t *p_demux )
|
||||
}
|
||||
|
||||
p_sys->i_next_vdate = START_DATE;
|
||||
p_sys->i_incr = CLOCK_FREQ * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
|
||||
p_sys->i_incr = vlc_tick_from_samples(p_sys->i_frame_rate_base, p_sys->i_frame_rate);
|
||||
p_sys->i_vblock_size = p_sys->i_width * p_sys->i_height * 3 / 2
|
||||
+ sizeof(struct block_extension_t);
|
||||
|
||||
@ -543,7 +543,7 @@ static int InitAudio( demux_t *p_demux )
|
||||
|
||||
p_sys->i_next_adate = START_DATE;
|
||||
p_sys->i_ablock_size = p_sys->i_sample_rate * 4 * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
|
||||
p_sys->i_aincr = CLOCK_FREQ * p_sys->i_ablock_size / (p_sys->i_sample_rate * 4);
|
||||
p_sys->i_aincr = vlc_tick_from_samples(p_sys->i_ablock_size, p_sys->i_sample_rate * 4);
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ static int StartDecode( demux_t *p_demux )
|
||||
char *psz_parser;
|
||||
|
||||
p_sys->i_next_date = START_DATE;
|
||||
p_sys->i_incr = CLOCK_FREQ * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
|
||||
p_sys->i_incr = vlc_tick_from_samples(p_sys->i_frame_rate_base, p_sys->i_frame_rate);
|
||||
p_sys->i_block_size = p_sys->i_width * p_sys->i_height * 3 / 2
|
||||
+ sizeof(struct block_extension_t);
|
||||
if( NewFrame( p_demux ) != VLC_SUCCESS )
|
||||
@ -929,7 +929,7 @@ static int DecodeAudio( demux_t *p_demux, sdi_audio_t *p_audio )
|
||||
if( unlikely( !p_block ) )
|
||||
return VLC_ENOMEM;
|
||||
p_block->i_dts = p_block->i_pts = p_sys->i_next_date
|
||||
+ (vlc_tick_t)p_audio->i_delay * CLOCK_FREQ / p_audio->i_rate;
|
||||
+ vlc_tick_from_samples(p_audio->i_delay, p_audio->i_rate);
|
||||
p_output = (int16_t *)p_block->p_buffer;
|
||||
|
||||
if ( p_audio->i_left_samples == p_audio->i_nb_samples &&
|
||||
|
@ -317,8 +317,8 @@ static block_t* GrabAudio( demux_t *p_demux )
|
||||
|
||||
/* Timestamp */
|
||||
p_block->i_pts = p_block->i_dts =
|
||||
vlc_tick_now() - CLOCK_FREQ * (vlc_tick_t)i_correct /
|
||||
2 / ( p_sys->b_stereo ? 2 : 1) / p_sys->i_sample_rate;
|
||||
vlc_tick_now() - vlc_tick_from_samples(i_correct,
|
||||
2 * ( p_sys->b_stereo ? 2 : 1) * p_sys->i_sample_rate);
|
||||
|
||||
return p_block;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
|
||||
vlc_tick_t deadline;
|
||||
const rtp_pt_t *pt = rtp_find_ptype (session, src, block, NULL);
|
||||
if (pt)
|
||||
deadline = CLOCK_FREQ * 3 * src->jitter / pt->frequency;
|
||||
deadline = vlc_tick_from_samples(3 * src->jitter, pt->frequency);
|
||||
else
|
||||
deadline = 0; /* no jitter estimate with no frequency :( */
|
||||
|
||||
@ -523,7 +523,7 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
|
||||
* Otherwise it would be impossible to compute consistent timestamps. */
|
||||
const uint32_t timestamp = rtp_timestamp (block);
|
||||
block->i_pts = src->ref_ntp
|
||||
+ CLOCK_FREQ * (int32_t)(timestamp - src->ref_rtp) / pt->frequency;
|
||||
+ vlc_tick_from_samples(timestamp - src->ref_rtp, pt->frequency);
|
||||
/* TODO: proper inter-medias/sessions sync (using RTCP-SR) */
|
||||
src->ref_ntp = block->i_pts;
|
||||
src->ref_rtp = timestamp;
|
||||
|
@ -196,7 +196,7 @@ static block_t *Mix( filter_t *p_filter, block_t *p_buf )
|
||||
else
|
||||
p_out_buf->i_pts = p_sys->i_inputPTS;
|
||||
p_out_buf->i_dts = p_out_buf->i_pts;
|
||||
p_out_buf->i_length = p_out_buf->i_nb_samples * CLOCK_FREQ / p_filter->fmt_in.audio.i_rate;
|
||||
p_out_buf->i_length = vlc_tick_from_samples(p_out_buf->i_nb_samples, p_filter->fmt_in.audio.i_rate);
|
||||
|
||||
float *p_dest = (float *)p_out_buf->p_buffer;
|
||||
const float *p_src = (float *)p_sys->inputSamples.data();
|
||||
|
@ -257,7 +257,7 @@ SoXR_Resample( filter_t *p_filter, soxr_t soxr, block_t *p_in, size_t i_olen )
|
||||
|
||||
p_out->i_buffer = i_odone * i_oframesize;
|
||||
p_out->i_nb_samples = i_odone;
|
||||
p_out->i_length = i_odone * CLOCK_FREQ / p_filter->fmt_out.audio.i_rate;
|
||||
p_out->i_length = vlc_tick_from_samples(i_odone, p_filter->fmt_out.audio.i_rate);
|
||||
|
||||
if( p_in )
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ static block_t *Resample (filter_t *filter, block_t *in)
|
||||
out->i_buffer = olen * framesize;
|
||||
out->i_nb_samples = olen;
|
||||
out->i_pts = in->i_pts;
|
||||
out->i_length = olen * CLOCK_FREQ / filter->fmt_out.audio.i_rate;
|
||||
out->i_length = vlc_tick_from_samples(olen, filter->fmt_out.audio.i_rate);
|
||||
error:
|
||||
block_Release (in);
|
||||
return out;
|
||||
|
@ -162,8 +162,7 @@ static block_t *Resample (filter_t *filter, block_t *in)
|
||||
out->i_buffer = src.output_frames_gen * framesize;
|
||||
out->i_nb_samples = src.output_frames_gen;
|
||||
out->i_pts = in->i_pts;
|
||||
out->i_length = src.output_frames_gen * CLOCK_FREQ
|
||||
/ filter->fmt_out.audio.i_rate;
|
||||
out->i_length = vlc_tick_from_samples(src.output_frames_gen, filter->fmt_out.audio.i_rate);
|
||||
error:
|
||||
block_Release (in);
|
||||
return out;
|
||||
|
@ -111,8 +111,7 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
|
||||
p_out_buf->i_nb_samples = i_out_nb;
|
||||
p_out_buf->i_buffer = i_out_nb * framesize;
|
||||
p_out_buf->i_pts = p_in_buf->i_pts;
|
||||
p_out_buf->i_length = p_out_buf->i_nb_samples *
|
||||
CLOCK_FREQ / p_filter->fmt_out.audio.i_rate;
|
||||
p_out_buf->i_length = vlc_tick_from_samples(p_out_buf->i_nb_samples, p_filter->fmt_out.audio.i_rate);
|
||||
|
||||
while( i_out_nb )
|
||||
{
|
||||
|
@ -640,7 +640,7 @@ static int TimeGet (audio_output_t *aout, vlc_tick_t *restrict delay)
|
||||
msg_Err (aout, "cannot estimate delay: %s", snd_strerror (val));
|
||||
return -1;
|
||||
}
|
||||
*delay = frames * CLOCK_FREQ / sys->rate;
|
||||
*delay = vlc_tick_from_samples(frames, sys->rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ check_exception( JNIEnv *env, audio_output_t *p_aout,
|
||||
static inline vlc_tick_t
|
||||
frames_to_us( aout_sys_t *p_sys, uint64_t i_nb_frames )
|
||||
{
|
||||
return i_nb_frames * CLOCK_FREQ / p_sys->fmt.i_rate;
|
||||
return vlc_tick_from_samples(i_nb_frames, p_sys->fmt.i_rate);
|
||||
}
|
||||
#define FRAMES_TO_US(x) frames_to_us( p_sys, (x) )
|
||||
|
||||
|
@ -1609,7 +1609,7 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
|
||||
UInt32 i_latency_samples;
|
||||
AO_GET1PROP(p_sys->i_selected_dev, UInt32, &i_latency_samples,
|
||||
kAudioDevicePropertyLatency, kAudioObjectPropertyScopeOutput);
|
||||
vlc_tick_t i_latency_us = i_latency_samples * CLOCK_FREQ / fmt->i_rate;
|
||||
vlc_tick_t i_latency_us = vlc_tick_from_samples(i_latency_samples, fmt->i_rate);
|
||||
|
||||
/* Check for Digital mode or Analog output mode */
|
||||
if (do_spdif)
|
||||
|
@ -45,7 +45,7 @@ BytesToFrames(struct aout_sys_common *p_sys, size_t i_bytes)
|
||||
static inline vlc_tick_t
|
||||
FramesToUs(struct aout_sys_common *p_sys, uint64_t i_nb_frames)
|
||||
{
|
||||
return i_nb_frames * CLOCK_FREQ / p_sys->i_rate;
|
||||
return vlc_tick_from_samples(i_nb_frames, p_sys->i_rate);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -261,8 +261,8 @@ static int TimeGet (audio_output_t *aout, vlc_tick_t *restrict pts)
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pts = (delay * CLOCK_FREQ * sys->format.i_frame_length)
|
||||
/ (sys->format.i_rate * sys->format.i_bytes_per_frame);
|
||||
*pts = vlc_tick_from_samples(delay * sys->format.i_frame_length,
|
||||
sys->format.i_rate * sys->format.i_bytes_per_frame);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ static int TimeGet (audio_output_t *aout, vlc_tick_t *restrict delay)
|
||||
|
||||
if (!sys->started)
|
||||
return -1;
|
||||
*delay = (vlc_tick_t)sys->delay * CLOCK_FREQ / sys->rate;
|
||||
*delay = vlc_tick_from_samples(sys->delay, sys->rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -865,7 +865,7 @@ static int WaveOutTimeGet(audio_output_t * p_aout, vlc_tick_t *delay)
|
||||
return -1;
|
||||
}
|
||||
|
||||
vlc_tick_t i_pos = (vlc_tick_t) mmtime.u.sample * CLOCK_FREQ / sys->i_rate;
|
||||
vlc_tick_t i_pos = vlc_tick_from_samples(mmtime.u.sample, sys->i_rate);
|
||||
*delay = sys->i_played_length - i_pos;
|
||||
return 0;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ static void Convert( decoder_t *p_dec, vlc_tick_t i_pts,
|
||||
{
|
||||
if( (p_buffer[0] & 0x04) /* Valid bit */ )
|
||||
{
|
||||
const vlc_tick_t i_spupts = i_pts + i_ticks * CLOCK_FREQ / (1200/3);
|
||||
const vlc_tick_t i_spupts = i_pts + vlc_tick_from_samples(i_ticks, 1200/3);
|
||||
/* Mask off the specific i_field bit, else some sequences can be lost. */
|
||||
if ( p_sys->p_eia608 &&
|
||||
(p_buffer[0] & 0x03) == p_sys->i_field )
|
||||
|
@ -1660,7 +1660,7 @@ static void CEA708_Decode_ServiceBuffer( cea708_t *h )
|
||||
/* Update internal clock */
|
||||
const uint8_t i_consumed = i_in - cea708_input_buffer_size( &h->input_buffer );
|
||||
if( i_consumed )
|
||||
h->i_clock += CLOCK_FREQ / 9600 * i_consumed;
|
||||
h->i_clock += vlc_tick_from_samples(1, 9600) * i_consumed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1692,7 +1692,7 @@ void CEA708_Decoder_Push( cea708_t *h, vlc_tick_t i_time,
|
||||
{
|
||||
/* Increase internal clock */
|
||||
if( i_push )
|
||||
h->i_clock += CLOCK_FREQ / 1200 * i_push;
|
||||
h->i_clock += vlc_tick_from_samples(1, 1200) * i_push;
|
||||
continue;
|
||||
}
|
||||
h->suspended_deadline = VLC_TICK_INVALID;
|
||||
|
@ -451,7 +451,7 @@ static void *ProcessPacket( decoder_t *p_dec, daala_packet *p_dpacket,
|
||||
}
|
||||
|
||||
/* Date management */
|
||||
p_sys->i_pts += ( CLOCK_FREQ * p_sys->di.timebase_denominator /
|
||||
p_sys->i_pts += vlc_tick_from_samples( p_sys->di.timebase_denominator,
|
||||
p_sys->di.timebase_numerator ); /* 1 frame per packet */
|
||||
|
||||
return p_buf;
|
||||
|
@ -328,13 +328,11 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf)
|
||||
if (likely(p_aout_buf)) {
|
||||
p_buffer = (int16_t *)p_aout_buf->p_buffer;
|
||||
i_samples = p_aout_buf->i_nb_samples;
|
||||
i_pts_out = p_aout_buf->i_pts - (vlc_tick_t)((double)CLOCK_FREQ *
|
||||
(double)p_sys->i_encoderdelay /
|
||||
(double)p_enc->fmt_out.audio.i_rate);
|
||||
i_pts_out = p_aout_buf->i_pts - vlc_tick_from_samples(p_sys->i_encoderdelay,
|
||||
p_enc->fmt_out.audio.i_rate);
|
||||
if (p_sys->i_pts_last == 0)
|
||||
p_sys->i_pts_last = i_pts_out - (vlc_tick_t)((double)CLOCK_FREQ *
|
||||
(double)(p_sys->i_frame_size) /
|
||||
(double)p_enc->fmt_out.audio.i_rate);
|
||||
p_sys->i_pts_last = i_pts_out - vlc_tick_from_samples(p_sys->i_frame_size,
|
||||
p_enc->fmt_out.audio.i_rate);
|
||||
} else {
|
||||
i_samples = 0;
|
||||
i_pts_out = p_sys->i_pts_last;
|
||||
@ -407,10 +405,10 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf)
|
||||
// in the library buffer from the prior block
|
||||
double d_samples_delay = (double)p_sys->i_frame_size - (double)out_args.numInSamples /
|
||||
(double)p_enc->fmt_in.audio.i_channels;
|
||||
i_pts_out -= (vlc_tick_t)((double)CLOCK_FREQ * d_samples_delay /
|
||||
(double)p_enc->fmt_out.audio.i_rate);
|
||||
p_block->i_length = (vlc_tick_t)((double)CLOCK_FREQ * (double)p_sys->i_frame_size /
|
||||
(double)p_enc->fmt_out.audio.i_rate);
|
||||
i_pts_out -= vlc_tick_from_samples( d_samples_delay,
|
||||
p_enc->fmt_out.audio.i_rate);
|
||||
p_block->i_length = vlc_tick_from_samples(p_sys->i_frame_size,
|
||||
p_enc->fmt_out.audio.i_rate);
|
||||
p_block->i_nb_samples = d_samples_delay;
|
||||
//p_block->i_length = i_pts_out - p_sys->i_pts_last;
|
||||
} else {
|
||||
|
@ -770,8 +770,7 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
|
||||
|
||||
p_sys->i_samples_delay -= samples;
|
||||
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)samples / (vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
p_block->i_length = vlc_tick_from_samples(samples, p_enc->fmt_in.audio.i_rate);
|
||||
|
||||
/* Update pts */
|
||||
p_sys->i_pts += p_block->i_length;
|
||||
@ -880,8 +879,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
if( unlikely( !p_aout_buf ) ) return NULL;
|
||||
|
||||
p_sys->i_pts = p_aout_buf->i_pts -
|
||||
CLOCK_FREQ * (vlc_tick_t)p_sys->i_samples_delay /
|
||||
(vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
vlc_tick_from_samples( p_sys->i_samples_delay,
|
||||
p_enc->fmt_in.audio.i_rate );
|
||||
|
||||
p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
|
||||
|
||||
|
@ -1080,8 +1080,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
|
||||
}
|
||||
|
||||
p_spu->i_start = p_block->i_pts;
|
||||
p_spu->i_stop = p_block->i_pts + CLOCK_FREQ *
|
||||
ev->duration * p_sys->ki.gps_denominator / p_sys->ki.gps_numerator;
|
||||
p_spu->i_stop = p_block->i_pts + vlc_tick_from_samples(ev->duration * p_sys->ki.gps_denominator, p_sys->ki.gps_numerator);
|
||||
p_spu->b_ephemer = false;
|
||||
p_spu->b_absolute = false;
|
||||
|
||||
|
@ -482,7 +482,7 @@ static block_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
|
||||
|
||||
int i_end_trim = 0;
|
||||
if( i_duration > 0 && spp > 0 &&
|
||||
i_duration < i_nb_samples * CLOCK_FREQ / 48000 )
|
||||
i_duration < vlc_tick_from_samples(i_nb_samples, 48000) )
|
||||
{
|
||||
i_end_trim = spp - VLC_CLIP(samples_from_vlc_tick(i_duration, 48000), 0, spp);
|
||||
}
|
||||
@ -580,8 +580,8 @@ static block_t *Encode(encoder_t *enc, block_t *buf)
|
||||
return NULL;
|
||||
|
||||
vlc_tick_t i_pts = buf->i_pts -
|
||||
(vlc_tick_t) CLOCK_FREQ * (vlc_tick_t) sys->i_samples_delay /
|
||||
(vlc_tick_t) enc->fmt_in.audio.i_rate;
|
||||
vlc_tick_from_samples( sys->i_samples_delay,
|
||||
enc->fmt_in.audio.i_rate );
|
||||
|
||||
sys->i_samples_delay += buf->i_nb_samples;
|
||||
|
||||
@ -626,8 +626,8 @@ static block_t *Encode(encoder_t *enc, block_t *buf)
|
||||
}
|
||||
else
|
||||
{
|
||||
out_block->i_length = (vlc_tick_t) CLOCK_FREQ *
|
||||
(vlc_tick_t) OPUS_FRAME_SIZE / (vlc_tick_t) enc->fmt_in.audio.i_rate;
|
||||
out_block->i_length = vlc_tick_from_samples( OPUS_FRAME_SIZE,
|
||||
enc->fmt_in.audio.i_rate );
|
||||
|
||||
out_block->i_dts = out_block->i_pts = i_pts;
|
||||
|
||||
|
@ -720,9 +720,8 @@ static block_t *qsv_synchronize_block(encoder_t *enc, async_task_t *task)
|
||||
/* task->bs.FrameType, task->bs.TimeStamp, block->i_pts, task->bs.DecodeTimeStamp, *task->syncp); */
|
||||
|
||||
/* Copied from x264.c: This isn't really valid for streams with B-frames */
|
||||
block->i_length = CLOCK_FREQ *
|
||||
enc->fmt_in.video.i_frame_rate_base /
|
||||
enc->fmt_in.video.i_frame_rate;
|
||||
block->i_length = vlc_tick_from_samples( enc->fmt_in.video.i_frame_rate_base,
|
||||
enc->fmt_in.video.i_frame_rate );
|
||||
|
||||
// Buggy DTS (value comes from experiments)
|
||||
if (task->bs.DecodeTimeStamp < -10000)
|
||||
|
@ -1095,8 +1095,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
int i_samples_delay = p_sys->i_samples_delay;
|
||||
|
||||
vlc_tick_t i_pts = p_aout_buf->i_pts -
|
||||
CLOCK_FREQ * (vlc_tick_t)p_sys->i_samples_delay /
|
||||
(vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
vlc_tick_from_samples( p_sys->i_samples_delay,
|
||||
p_enc->fmt_in.audio.i_rate );
|
||||
|
||||
p_sys->i_samples_delay += i_samples;
|
||||
|
||||
@ -1154,9 +1154,9 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
p_block = block_Alloc( i_out );
|
||||
memcpy( p_block->p_buffer, p_sys->p_buffer_out, i_out );
|
||||
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)p_sys->i_frame_length * p_sys->header.frames_per_packet /
|
||||
(vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
p_block->i_length = vlc_tick_from_samples(
|
||||
p_sys->i_frame_length * p_sys->header.frames_per_packet,
|
||||
p_enc->fmt_in.audio.i_rate );
|
||||
|
||||
p_block->i_dts = p_block->i_pts = i_pts;
|
||||
|
||||
|
@ -225,7 +225,7 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,
|
||||
i_current_rate = decoder_GetDisplayRate( p_synchro->p_dec );
|
||||
|
||||
now = vlc_tick_now();
|
||||
period = CLOCK_FREQ * 1001 / p_synchro->i_frame_rate * i_current_rate;
|
||||
period = vlc_tick_from_samples(1001, p_synchro->i_frame_rate) * i_current_rate;
|
||||
|
||||
p_synchro->i_render_time = i_render_time;
|
||||
|
||||
@ -406,7 +406,7 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type
|
||||
int i_repeat_field, vlc_tick_t next_pts,
|
||||
vlc_tick_t next_dts, bool b_low_delay )
|
||||
{
|
||||
vlc_tick_t period = CLOCK_FREQ * 1001 / p_synchro->i_frame_rate;
|
||||
vlc_tick_t period = vlc_tick_from_samples(1001, p_synchro->i_frame_rate);
|
||||
#if 0
|
||||
vlc_tick_t now = vlc_tick_now();
|
||||
#endif
|
||||
|
@ -487,7 +487,7 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
|
||||
}
|
||||
|
||||
/* Date management */
|
||||
p_sys->i_pts += ( CLOCK_FREQ * p_sys->ti.fps_denominator /
|
||||
p_sys->i_pts += vlc_tick_from_samples( p_sys->ti.fps_denominator,
|
||||
p_sys->ti.fps_numerator ); /* 1 frame per packet */
|
||||
|
||||
return p_buf;
|
||||
|
@ -98,7 +98,7 @@ static tt_time_t tt_ParseTime( const char *s )
|
||||
unsigned i_den = 1;
|
||||
for( const char *p = strchr( s, '.' ) + 1; *p && (i_den < UINT_MAX / 10); p++ )
|
||||
i_den *= 10;
|
||||
t.base += vlc_tick_from_sec(d1) / i_den;
|
||||
t.base += vlc_tick_from_samples(d1, i_den);
|
||||
}
|
||||
else if( c == ':' )
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ static inline vlc_tick_t tt_time_Convert( const tt_time_t *t )
|
||||
if( !tt_time_Valid( t ) )
|
||||
return VLC_TICK_INVALID;
|
||||
else
|
||||
return t->base + CLOCK_FREQ * t->frames / TT_FRAME_RATE;
|
||||
return t->base + vlc_tick_from_samples( t->frames, TT_FRAME_RATE);
|
||||
}
|
||||
|
||||
static inline int tt_time_Compare( const tt_time_t *t1, const tt_time_t *t2 )
|
||||
@ -140,7 +140,7 @@ static inline tt_time_t tt_time_Add( tt_time_t t1, tt_time_t t2 )
|
||||
{
|
||||
t1.base += t2.base;
|
||||
t1.frames += t2.frames;
|
||||
t1.base += CLOCK_FREQ * ( t1.frames / TT_FRAME_RATE );
|
||||
t1.base += vlc_tick_from_samples( t1.frames, TT_FRAME_RATE );
|
||||
t1.frames = t1.frames % TT_FRAME_RATE;
|
||||
return t1;
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
if( !p_block )
|
||||
return NULL;
|
||||
memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used );
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)MPEG_FRAME_SIZE / (vlc_tick_t)p_enc->fmt_out.audio.i_rate;
|
||||
p_block->i_length = vlc_tick_from_samples( MPEG_FRAME_SIZE,
|
||||
p_enc->fmt_out.audio.i_rate );
|
||||
p_block->i_dts = p_block->i_pts = p_sys->i_pts;
|
||||
p_sys->i_pts += p_block->i_length;
|
||||
|
||||
@ -301,8 +301,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
int i_nb_samples = p_aout_buf->i_nb_samples;
|
||||
|
||||
p_sys->i_pts = p_aout_buf->i_pts -
|
||||
CLOCK_FREQ * (vlc_tick_t)p_sys->i_nb_samples /
|
||||
(vlc_tick_t)p_enc->fmt_out.audio.i_rate;
|
||||
vlc_tick_from_samples( p_sys->i_nb_samples,
|
||||
p_enc->fmt_out.audio.i_rate );
|
||||
|
||||
while ( p_sys->i_nb_samples + i_nb_samples >= MPEG_FRAME_SIZE )
|
||||
{
|
||||
@ -332,8 +332,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
return NULL;
|
||||
}
|
||||
memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used );
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)MPEG_FRAME_SIZE / (vlc_tick_t)p_enc->fmt_out.audio.i_rate;
|
||||
p_block->i_length = vlc_tick_from_samples( MPEG_FRAME_SIZE,
|
||||
p_enc->fmt_out.audio.i_rate );
|
||||
p_block->i_dts = p_block->i_pts = p_sys->i_pts;
|
||||
p_sys->i_pts += p_block->i_length;
|
||||
block_ChainAppend( &p_chain, p_block );
|
||||
|
@ -902,8 +902,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
if( unlikely( !p_aout_buf ) ) return NULL;
|
||||
|
||||
vlc_tick_t i_pts = p_aout_buf->i_pts -
|
||||
CLOCK_FREQ * (vlc_tick_t)p_sys->i_samples_delay /
|
||||
(vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
vlc_tick_from_samples( p_sys->i_samples_delay,
|
||||
p_enc->fmt_in.audio.i_rate );
|
||||
|
||||
p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
|
||||
|
||||
@ -941,8 +941,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
|
||||
i_samples = ( p_sys->i_last_block_size + i_block_size ) >> 2;
|
||||
p_sys->i_last_block_size = i_block_size;
|
||||
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)i_samples / (vlc_tick_t)p_enc->fmt_in.audio.i_rate;
|
||||
p_block->i_length = vlc_tick_from_samples(i_samples,
|
||||
p_enc->fmt_in.audio.i_rate);
|
||||
|
||||
p_block->i_dts = p_block->i_pts = i_pts;
|
||||
|
||||
|
@ -1542,9 +1542,9 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
|
||||
if( !p_sys->param.b_vfr_input )
|
||||
{
|
||||
/* This isn't really valid for streams with B-frames */
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
p_enc->fmt_in.video.i_frame_rate_base /
|
||||
p_enc->fmt_in.video.i_frame_rate;
|
||||
p_block->i_length = vlc_tick_from_samples(
|
||||
p_enc->fmt_in.video.i_frame_rate_base,
|
||||
p_enc->fmt_in.video.i_frame_rate );
|
||||
}
|
||||
|
||||
/* scale pts-values back*/
|
||||
|
@ -104,9 +104,9 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
|
||||
memcpy(p_block->p_buffer, nal[0].payload, i_out);
|
||||
|
||||
/* This isn't really valid for streams with B-frames */
|
||||
p_block->i_length = CLOCK_FREQ *
|
||||
p_enc->fmt_in.video.i_frame_rate_base /
|
||||
p_enc->fmt_in.video.i_frame_rate;
|
||||
p_block->i_length = vlc_tick_from_samples(
|
||||
p_enc->fmt_in.video.i_frame_rate_base,
|
||||
p_enc->fmt_in.video.i_frame_rate );
|
||||
|
||||
p_block->i_pts = p_sys->initial_date + pic.poc * p_block->i_length;
|
||||
p_block->i_dts = p_sys->initial_date + p_sys->frame_count++ * p_block->i_length;
|
||||
|
@ -251,9 +251,8 @@ static int Demux( demux_t *p_demux )
|
||||
p_block->i_dts =
|
||||
p_block->i_pts = VLC_TICK_0 + p_sys->i_time;
|
||||
|
||||
p_sys->i_time += CLOCK_FREQ *
|
||||
p_block->i_buffer /
|
||||
p_sys->i_ssnd_fsize /
|
||||
p_sys->i_time += vlc_tick_from_samples(p_block->i_buffer,
|
||||
p_sys->i_ssnd_fsize) /
|
||||
p_sys->fmt.audio.i_rate;
|
||||
|
||||
/* */
|
||||
@ -306,7 +305,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
{
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
p_sys->i_time = CLOCK_FREQ * i_frame / p_sys->fmt.audio.i_rate;
|
||||
p_sys->i_time = vlc_tick_from_samples( i_frame, p_sys->fmt.audio.i_rate );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
return VLC_EGENERIC;
|
||||
@ -323,7 +322,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
if( p_sys->i_ssnd_start < i_end )
|
||||
{
|
||||
*va_arg( args, vlc_tick_t * ) =
|
||||
CLOCK_FREQ * ( i_end - p_sys->i_ssnd_start ) / p_sys->i_ssnd_fsize / p_sys->fmt.audio.i_rate;
|
||||
vlc_tick_from_samples( i_end - p_sys->i_ssnd_start, p_sys->i_ssnd_fsize) / p_sys->fmt.audio.i_rate;
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
return VLC_EGENERIC;
|
||||
|
@ -288,9 +288,8 @@ static int Open( vlc_object_t *p_this )
|
||||
p_sys->i_frame_size += p_sys->fmt.audio.i_blockalign - mod;
|
||||
}
|
||||
}
|
||||
p_sys->i_frame_length = CLOCK_FREQ *
|
||||
(vlc_tick_t)i_samples /
|
||||
(vlc_tick_t)p_sys->fmt.audio.i_rate;
|
||||
p_sys->i_frame_length = vlc_tick_from_samples( i_samples,
|
||||
p_sys->fmt.audio.i_rate );
|
||||
|
||||
p_demux->p_sys = p_sys;
|
||||
p_demux->pf_demux = Demux;
|
||||
|
@ -702,9 +702,9 @@ int avformat_OpenDemux( vlc_object_t *p_this )
|
||||
EnsureUTF8( s->psz_name );
|
||||
msg_Dbg( p_demux, " - chapter %d: %s", i, s->psz_name );
|
||||
}
|
||||
s->i_time_offset = p_sys->ic->chapters[i]->start * CLOCK_FREQ *
|
||||
p_sys->ic->chapters[i]->time_base.num /
|
||||
p_sys->ic->chapters[i]->time_base.den -
|
||||
s->i_time_offset = vlc_tick_from_samples( p_sys->ic->chapters[i]->start *
|
||||
p_sys->ic->chapters[i]->time_base.num,
|
||||
p_sys->ic->chapters[i]->time_base.den ) -
|
||||
(i_start_time != VLC_TICK_INVALID ? i_start_time : 0 );
|
||||
TAB_APPEND( p_sys->p_title->i_seekpoint, p_sys->p_title->seekpoint, s );
|
||||
}
|
||||
@ -842,9 +842,9 @@ static int Demux( demux_t *p_demux )
|
||||
p_stream->time_base.den - i_start_time + VLC_TICK_0;
|
||||
}
|
||||
if( pkt.duration > 0 && p_frame->i_length <= 0 )
|
||||
p_frame->i_length = pkt.duration * CLOCK_FREQ *
|
||||
p_stream->time_base.num /
|
||||
p_stream->time_base.den;
|
||||
p_frame->i_length = vlc_tick_from_samples(pkt.duration *
|
||||
p_stream->time_base.num,
|
||||
p_stream->time_base.den );
|
||||
|
||||
/* Add here notoriously bugged file formats/samples */
|
||||
if( !strcmp( p_sys->fmt->name, "flv" ) )
|
||||
|
@ -1017,12 +1017,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
|
||||
case DEMUX_GET_LENGTH:
|
||||
*va_arg( args, vlc_tick_t * ) =
|
||||
CLOCK_FREQ * ( i_num_samples / p_sys->fmt.audio.i_rate );
|
||||
vlc_tick_from_samples( i_num_samples, p_sys->fmt.audio.i_rate );
|
||||
return VLC_SUCCESS;
|
||||
|
||||
case DEMUX_GET_TIME:
|
||||
*va_arg( args, vlc_tick_t * ) =
|
||||
CLOCK_FREQ * ( p_sys->position.i_samples / p_sys->fmt.audio.i_rate );
|
||||
vlc_tick_from_samples( p_sys->position.i_samples, p_sys->fmt.audio.i_rate );
|
||||
return VLC_SUCCESS;
|
||||
|
||||
case DEMUX_GET_POSITION:
|
||||
|
@ -52,8 +52,8 @@ bool IndexReader::parseIndex(block_t *p_block, BaseRepresentation *rep, uint64_t
|
||||
{
|
||||
splitlist.push_back(point);
|
||||
point.offset += sidx->p_items[i].i_referenced_size;
|
||||
point.duration = CLOCK_FREQ * sidx->p_items[i].i_subsegment_duration /
|
||||
sidx->i_timescale;
|
||||
point.duration = vlc_tick_from_samples( sidx->p_items[i].i_subsegment_duration,
|
||||
sidx->i_timescale );
|
||||
point.time += point.duration;
|
||||
}
|
||||
rep->SplitUsingIndex(splitlist);
|
||||
|
@ -784,7 +784,7 @@ static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, size_t i_da
|
||||
break;
|
||||
|
||||
s = xmalloc( sizeof (*s) );
|
||||
s->i_time_offset = i_sample * CLOCK_FREQ / i_sample_rate;
|
||||
s->i_time_offset = vlc_tick_from_samples(i_sample, i_sample_rate);
|
||||
s->i_byte_offset = GetQWBE( &p_data[4+18*i+8] );
|
||||
|
||||
/* Check for duplicate entry */
|
||||
|
@ -241,7 +241,7 @@ static int Demux( demux_t *p_demux )
|
||||
/* */
|
||||
p_data->i_buffer = i_ret * sizeof(MPC_SAMPLE_FORMAT) * p_sys->info.channels;
|
||||
p_data->i_dts = p_data->i_pts =
|
||||
VLC_TICK_0 + CLOCK_FREQ * p_sys->i_position / p_sys->info.sample_freq;
|
||||
VLC_TICK_0 + vlc_tick_from_samples(p_sys->i_position, p_sys->info.sample_freq);
|
||||
|
||||
es_out_SetPCR( p_demux->out, p_data->i_dts );
|
||||
|
||||
@ -276,7 +276,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
|
||||
case DEMUX_GET_LENGTH:
|
||||
*va_arg( args, vlc_tick_t * ) =
|
||||
CLOCK_FREQ * p_sys->info.pcm_samples / p_sys->info.sample_freq;
|
||||
vlc_tick_from_samples(p_sys->info.pcm_samples, p_sys->info.sample_freq);
|
||||
return VLC_SUCCESS;
|
||||
|
||||
case DEMUX_GET_POSITION:
|
||||
@ -290,7 +290,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
|
||||
case DEMUX_GET_TIME:
|
||||
*va_arg( args, vlc_tick_t * ) =
|
||||
CLOCK_FREQ * p_sys->i_position / p_sys->info.sample_freq;
|
||||
vlc_tick_from_samples(p_sys->i_position, p_sys->info.sample_freq);
|
||||
return VLC_SUCCESS;
|
||||
|
||||
case DEMUX_SET_POSITION:
|
||||
|
@ -602,7 +602,8 @@ sl_header_data DecodeSLHeader( unsigned i_data, const uint8_t *p_data,
|
||||
i_read |= bs_read( &s, i_bits );
|
||||
}
|
||||
if( sl->i_timestamp_resolution )
|
||||
*(timestamps[i].p_t) = VLC_TICK_0 + CLOCK_FREQ * i_read / sl->i_timestamp_resolution;
|
||||
*(timestamps[i].p_t) = VLC_TICK_0 +
|
||||
vlc_tick_from_samples(i_read, sl->i_timestamp_resolution);
|
||||
}
|
||||
|
||||
bs_read( &s, sl->i_AU_length );
|
||||
|
@ -157,7 +157,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
|
||||
msg_Info( p_demux, "Detected PSMF-PS header");
|
||||
i_mux_rate = GetDWBE( &p_peek[96] );
|
||||
if( GetDWBE( &p_peek[86] ) > 0 )
|
||||
i_length = CLOCK_FREQ * GetDWBE( &p_peek[92] ) / GetDWBE( &p_peek[86] );
|
||||
i_length = vlc_tick_from_samples( GetDWBE( &p_peek[92] ), GetDWBE( &p_peek[86] ));
|
||||
}
|
||||
else if( !memcmp( p_peek, "RIFF", 4 ) && !memcmp( &p_peek[8], "CDXA", 4 ) )
|
||||
{
|
||||
@ -741,7 +741,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
if( p_sys->i_mux_rate > 0 && p_sys->b_have_pack )
|
||||
{
|
||||
uint64_t i_offset = vlc_stream_Tell( p_demux->s ) - p_sys->i_lastpack_byte;
|
||||
i_time += CLOCK_FREQ * i_offset / (p_sys->i_mux_rate * 50);
|
||||
i_time += vlc_tick_from_samples(i_offset, p_sys->i_mux_rate * 50);
|
||||
}
|
||||
*va_arg( args, vlc_tick_t * ) = i_time;
|
||||
return VLC_SUCCESS;
|
||||
@ -757,8 +757,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
}
|
||||
else if( p_sys->i_mux_rate > 0 )
|
||||
{
|
||||
*va_arg( args, vlc_tick_t * ) = CLOCK_FREQ * ( stream_Size( p_demux->s ) - p_sys->i_start_byte / 50 ) /
|
||||
p_sys->i_mux_rate;
|
||||
*va_arg( args, vlc_tick_t * ) = vlc_tick_from_samples( stream_Size( p_demux->s ) - p_sys->i_start_byte / 50,
|
||||
p_sys->i_mux_rate );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
*va_arg( args, vlc_tick_t * ) = 0;
|
||||
|
@ -1310,7 +1310,7 @@ static block_t *J2K_Parse( demux_t *p_demux, block_t *p_block, bool b_interlaced
|
||||
uint16_t i_num = GetWBE( &p_buf[10] );
|
||||
if( i_den == 0 )
|
||||
goto invalid;
|
||||
p_block->i_length = CLOCK_FREQ * i_den / i_num;
|
||||
p_block->i_length = vlc_tick_from_samples( i_den, i_num );
|
||||
|
||||
p_block->p_buffer += (b_interlaced) ? 48 : 38;
|
||||
p_block->i_buffer -= (b_interlaced) ? 48 : 38;
|
||||
|
@ -392,7 +392,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
case DEMUX_GET_LENGTH:
|
||||
if( p_sys->i_mux_rate > 0 )
|
||||
{
|
||||
*va_arg( args, vlc_tick_t * ) = CLOCK_FREQ * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
|
||||
*va_arg( args, vlc_tick_t * ) = vlc_tick_from_samples( stream_Size( p_demux->s ) / 50, p_sys->i_mux_rate);
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
*va_arg( args, vlc_tick_t * ) = 0;
|
||||
|
@ -335,7 +335,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
pi64 = va_arg( args, vlc_tick_t * );
|
||||
if( p_sys->i_mux_rate > 0 )
|
||||
{
|
||||
*pi64 = CLOCK_FREQ * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
|
||||
*pi64 = vlc_tick_from_samples( stream_Size( p_demux->s ) / 50, p_sys->i_mux_rate);
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
*pi64 = 0;
|
||||
|
@ -180,9 +180,9 @@ static int Demux( demux_t *p_demux)
|
||||
|
||||
if( p_sys->p_packetizer->fmt_out.video.i_frame_rate > 0 &&
|
||||
p_sys->p_packetizer->fmt_out.video.i_frame_rate_base > 0 )
|
||||
p_sys->i_dts += CLOCK_FREQ *
|
||||
p_sys->p_packetizer->fmt_out.video.i_frame_rate_base /
|
||||
p_sys->p_packetizer->fmt_out.video.i_frame_rate;
|
||||
p_sys->i_dts += vlc_tick_from_samples(
|
||||
p_sys->p_packetizer->fmt_out.video.i_frame_rate_base,
|
||||
p_sys->p_packetizer->fmt_out.video.i_frame_rate );
|
||||
else if( p_sys->f_fps > 0.001f )
|
||||
p_sys->i_dts += (int64_t)((float) CLOCK_FREQ / p_sys->f_fps);
|
||||
else
|
||||
|
@ -88,8 +88,8 @@ static void flush(filter_t *filter);
|
||||
static int Open(filter_t *filter)
|
||||
{
|
||||
int32_t frame_duration = filter->fmt_in.video.i_frame_rate != 0 ?
|
||||
CLOCK_FREQ * filter->fmt_in.video.i_frame_rate_base /
|
||||
filter->fmt_in.video.i_frame_rate : 0;
|
||||
vlc_tick_from_samples( filter->fmt_in.video.i_frame_rate_base,
|
||||
filter->fmt_in.video.i_frame_rate ) : 0;
|
||||
bool use_qpu = var_InheritBool(filter, MMAL_DEINTERLACE_QPU);
|
||||
|
||||
MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imfx_param = {
|
||||
|
@ -924,7 +924,7 @@ DeinterlaceX2(filter_t * filter, picture_t * src)
|
||||
i_field_dur = (src->date - p_deint_data->meta[i].date) / i_fields_total;
|
||||
}
|
||||
else if (fmt->i_frame_rate_base)
|
||||
i_field_dur = CLOCK_FREQ * fmt->i_frame_rate_base / fmt->i_frame_rate;
|
||||
i_field_dur = vlc_tick_from_samples(fmt->i_frame_rate_base, fmt->i_frame_rate);
|
||||
|
||||
picture_t *dest[2] = {NULL, NULL};
|
||||
for (i = 0; i < 2; ++i)
|
||||
|
@ -652,9 +652,9 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
|
||||
{ /* we have no way to know real length except by decoding */
|
||||
if ( p_stream->mux.fmt.i_cat == VIDEO_ES )
|
||||
{
|
||||
p_data->i_length = CLOCK_FREQ *
|
||||
p_stream->mux.fmt.video.i_frame_rate_base /
|
||||
p_stream->mux.fmt.video.i_frame_rate;
|
||||
p_data->i_length = vlc_tick_from_samples(
|
||||
p_stream->mux.fmt.video.i_frame_rate_base,
|
||||
p_stream->mux.fmt.video.i_frame_rate );
|
||||
if( p_data->i_flags & BLOCK_FLAG_SINGLE_FIELD )
|
||||
p_data->i_length >>= 1;
|
||||
msg_Dbg( p_mux, "video track %u fixup to %"PRId64" for sample %u",
|
||||
@ -664,8 +664,8 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
|
||||
p_stream->mux.fmt.audio.i_rate &&
|
||||
p_data->i_nb_samples )
|
||||
{
|
||||
p_data->i_length = CLOCK_FREQ * p_data->i_nb_samples /
|
||||
p_stream->mux.fmt.audio.i_rate;
|
||||
p_data->i_length = vlc_tick_from_samples(p_data->i_nb_samples,
|
||||
p_stream->mux.fmt.audio.i_rate);
|
||||
msg_Dbg( p_mux, "audio track %u fixup to %"PRId64" for sample %u",
|
||||
p_stream->mux.i_track_id, p_data->i_length, p_stream->mux.i_entry_count );
|
||||
}
|
||||
@ -1315,9 +1315,9 @@ static void LengthLocalFixup(sout_mux_t *p_mux, const mp4_stream_t *p_stream, bl
|
||||
{
|
||||
if ( p_stream->mux.fmt.i_cat == VIDEO_ES && p_stream->mux.fmt.video.i_frame_rate )
|
||||
{
|
||||
p_entrydata->i_length = CLOCK_FREQ *
|
||||
p_stream->mux.fmt.video.i_frame_rate_base /
|
||||
p_stream->mux.fmt.video.i_frame_rate;
|
||||
p_entrydata->i_length = vlc_tick_from_samples(
|
||||
p_stream->mux.fmt.video.i_frame_rate_base,
|
||||
p_stream->mux.fmt.video.i_frame_rate);
|
||||
msg_Dbg(p_mux, "video track %d fixup to %"PRId64" for sample %u",
|
||||
p_stream->mux.i_track_id, p_entrydata->i_length, p_stream->mux.i_entry_count - 1);
|
||||
}
|
||||
@ -1325,8 +1325,8 @@ static void LengthLocalFixup(sout_mux_t *p_mux, const mp4_stream_t *p_stream, bl
|
||||
p_stream->mux.fmt.audio.i_rate &&
|
||||
p_entrydata->i_nb_samples && p_stream->mux.fmt.audio.i_rate)
|
||||
{
|
||||
p_entrydata->i_length = CLOCK_FREQ * p_entrydata->i_nb_samples /
|
||||
p_stream->mux.fmt.audio.i_rate;
|
||||
p_entrydata->i_length = vlc_tick_from_samples(p_entrydata->i_nb_samples,
|
||||
p_stream->mux.fmt.audio.i_rate);
|
||||
msg_Dbg(p_mux, "audio track %d fixup to %"PRId64" for sample %u",
|
||||
p_stream->mux.i_track_id, p_entrydata->i_length, p_stream->mux.i_entry_count - 1);
|
||||
}
|
||||
|
@ -1090,9 +1090,9 @@ static void SetBlockDuration( sout_input_t *p_input, block_t *p_data )
|
||||
p_input->p_fmt->video.i_frame_rate &&
|
||||
p_input->p_fmt->video.i_frame_rate_base )
|
||||
{
|
||||
p_data->i_length = CLOCK_FREQ *
|
||||
p_input->p_fmt->video.i_frame_rate /
|
||||
p_input->p_fmt->video.i_frame_rate_base;
|
||||
p_data->i_length = vlc_tick_from_samples(
|
||||
p_input->p_fmt->video.i_frame_rate,
|
||||
p_input->p_fmt->video.i_frame_rate_base);
|
||||
}
|
||||
else if( p_input->p_fmt->i_cat == AUDIO_ES &&
|
||||
p_input->p_fmt->audio.i_bytes_per_frame &&
|
||||
|
@ -1643,9 +1643,9 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
|
||||
p_stream->i_last_keyframe = p_stream->i_num_frames;
|
||||
|
||||
/* presentation time */
|
||||
i_time = CLOCK_FREQ * ( p_stream->i_num_frames - 1 ) *
|
||||
p_stream->fmt.video.i_frame_rate_base /
|
||||
p_stream->fmt.video.i_frame_rate;
|
||||
i_time = vlc_tick_from_samples( (p_stream->i_num_frames - 1 ) *
|
||||
p_stream->fmt.video.i_frame_rate_base,
|
||||
p_stream->fmt.video.i_frame_rate );
|
||||
AddIndexEntry( p_mux, i_time, p_input );
|
||||
}
|
||||
|
||||
@ -1713,8 +1713,8 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
|
||||
p_stream->i_last_keyframe = p_stream->i_num_frames;
|
||||
|
||||
/* presentation time */
|
||||
i_time = CLOCK_FREQ * ( p_stream->i_num_frames - 1 ) *
|
||||
p_stream->fmt.video.i_frame_rate_base / p_stream->fmt.video.i_frame_rate;
|
||||
i_time = vlc_tick_from_samples( ( p_stream->i_num_frames - 1 ) *
|
||||
p_stream->fmt.video.i_frame_rate_base, p_stream->fmt.video.i_frame_rate );
|
||||
AddIndexEntry( p_mux, i_time, p_input );
|
||||
}
|
||||
op.granulepos = ( ((int64_t)p_stream->i_num_frames) << 32 ) |
|
||||
|
@ -260,9 +260,9 @@ static inline int FLAC_ParseSyncInfo(const uint8_t *p_buf,
|
||||
|
||||
/* Compute from frame absolute time */
|
||||
if ( (p_buf[1] & 0x01) == 0 ) /* Fixed blocksize stream / Frames */
|
||||
h->i_pts = VLC_TICK_0 + CLOCK_FREQ * blocksize * i_fsnumber / samplerate;
|
||||
h->i_pts = VLC_TICK_0 + vlc_tick_from_samples(blocksize * i_fsnumber, samplerate);
|
||||
else /* Variable blocksize stream / Samples */
|
||||
h->i_pts = VLC_TICK_0 + CLOCK_FREQ * i_fsnumber / samplerate;
|
||||
h->i_pts = VLC_TICK_0 + vlc_tick_from_samples(i_fsnumber, samplerate);
|
||||
|
||||
h->i_bits_per_sample = bits_per_sample;
|
||||
h->i_rate = samplerate;
|
||||
|
@ -971,8 +971,8 @@ static block_t *OutputPicture( decoder_t *p_dec )
|
||||
{
|
||||
if( p_sps->vui.i_time_scale )
|
||||
{
|
||||
p_pic->i_length = CLOCK_FREQ * i_num_clock_ts *
|
||||
p_sps->vui.i_num_units_in_tick / p_sps->vui.i_time_scale;
|
||||
p_pic->i_length = vlc_tick_from_samples(i_num_clock_ts *
|
||||
p_sps->vui.i_num_units_in_tick, p_sps->vui.i_time_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -544,14 +544,14 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
|
||||
p_dec->fmt_in.video.i_frame_rate > 0 &&
|
||||
p_dec->fmt_in.video.i_frame_rate_base > 0 )
|
||||
{
|
||||
p_sys->i_interpolated_pts += CLOCK_FREQ *
|
||||
p_dec->fmt_in.video.i_frame_rate_base /
|
||||
p_dec->fmt_in.video.i_frame_rate;
|
||||
p_sys->i_interpolated_pts += vlc_tick_from_samples(
|
||||
p_dec->fmt_in.video.i_frame_rate_base,
|
||||
p_dec->fmt_in.video.i_frame_rate);
|
||||
}
|
||||
else if( p_sys->i_fps_num )
|
||||
{
|
||||
i_time_diff = (i_time_ref + i_time_increment) - (p_sys->i_last_time + p_sys->i_last_timeincr);
|
||||
p_sys->i_interpolated_pts += ( CLOCK_FREQ * i_time_diff / p_sys->i_fps_num );
|
||||
p_sys->i_interpolated_pts += vlc_tick_from_samples( i_time_diff, p_sys->i_fps_num );
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -389,9 +389,9 @@ static block_t *ParseIDU( decoder_t *p_dec, bool *pb_ts_used, block_t *p_frag )
|
||||
if( p_dec->fmt_out.video.i_frame_rate != 0 && p_dec->fmt_out.video.i_frame_rate_base != 0 )
|
||||
{
|
||||
if( p_sys->i_interpolated_dts != VLC_TICK_INVALID )
|
||||
p_sys->i_interpolated_dts += CLOCK_FREQ *
|
||||
p_dec->fmt_out.video.i_frame_rate_base /
|
||||
p_dec->fmt_out.video.i_frame_rate;
|
||||
p_sys->i_interpolated_dts += vlc_tick_from_samples(
|
||||
p_dec->fmt_out.video.i_frame_rate_base,
|
||||
p_dec->fmt_out.video.i_frame_rate);
|
||||
|
||||
//msg_Dbg( p_dec, "-------------- XXX0 dts=%"PRId64" pts=%"PRId64" interpolated=%"PRId64,
|
||||
// p_pic->i_dts, p_pic->i_pts, p_sys->i_interpolated_dts );
|
||||
|
@ -1167,7 +1167,9 @@ static void* live_thread( void* p )
|
||||
vlc_stream_Delete( download_stream );
|
||||
}
|
||||
|
||||
vlc_tick_wait( last_dl_start_time + (CLOCK_FREQ * hds_stream->fragment_runs[hds_stream->fragment_run_count-1].fragment_duration) / hds_stream->afrt_timescale);
|
||||
vlc_tick_wait( last_dl_start_time +
|
||||
vlc_tick_from_samples(hds_stream->fragment_runs[hds_stream->fragment_run_count-1].fragment_duration,
|
||||
hds_stream->afrt_timescale) );
|
||||
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ size_t AES3AudioBuffer::FramesToBytes(unsigned f) const
|
||||
|
||||
vlc_tick_t AES3AudioBuffer::FramesToDuration(unsigned f) const
|
||||
{
|
||||
return CLOCK_FREQ * f / 48000;
|
||||
return vlc_tick_from_samples(f, 48000);
|
||||
}
|
||||
|
||||
unsigned AES3AudioBuffer::BytesToFrames(size_t s) const
|
||||
|
@ -94,7 +94,7 @@ vlc_tick_t GetFieldDuration(const struct deinterlace_ctx *p_context,
|
||||
i_field_dur = (p_pic->date - p_context->meta[i].pi_date) / i_fields_total;
|
||||
}
|
||||
else if (fmt->i_frame_rate_base)
|
||||
i_field_dur = CLOCK_FREQ * fmt->i_frame_rate_base / fmt->i_frame_rate;
|
||||
i_field_dur = vlc_tick_from_samples( fmt->i_frame_rate_base, fmt->i_frame_rate);
|
||||
|
||||
/* Note that we default to field duration 0 if it could not be
|
||||
determined. This behaves the same as the old code - leaving the
|
||||
|
@ -1097,7 +1097,7 @@ static void Flush (audio_output_t *aout, bool drain)
|
||||
if (drain) {
|
||||
uint32_t samples;
|
||||
sys->p_output->GetBufferedAudioSampleFrameCount(&samples);
|
||||
vlc_tick_sleep(CLOCK_FREQ * samples / sys->i_rate);
|
||||
vlc_tick_sleep(vlc_tick_from_samples(samples, sys->i_rate));
|
||||
} else if (sys->p_output->FlushBufferedAudioSamples() == E_FAIL)
|
||||
msg_Err(aout, "Flush failed");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user