mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-07 23:32:33 +00:00
Merge remote-tracking branch 'cus/stable'
* cus/stable: ffplay: assume 0 stream start time if start time is unset in duration check ffplay: do not update audio clock with old audio pts if current frame is AV_NOPTS_VALUE Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
9e214900ad
17
ffplay.c
17
ffplay.c
@ -2297,10 +2297,11 @@ static int audio_decode_frame(VideoState *is)
|
|||||||
|
|
||||||
audio_clock0 = is->audio_clock;
|
audio_clock0 = is->audio_clock;
|
||||||
/* update the audio clock with the pts */
|
/* update the audio clock with the pts */
|
||||||
if (is->frame->pts != AV_NOPTS_VALUE) {
|
if (is->frame->pts != AV_NOPTS_VALUE)
|
||||||
is->audio_clock = is->frame->pts * av_q2d(tb) + (double) is->frame->nb_samples / is->frame->sample_rate;
|
is->audio_clock = is->frame->pts * av_q2d(tb) + (double) is->frame->nb_samples / is->frame->sample_rate;
|
||||||
is->audio_clock_serial = is->audio_pkt_temp_serial;
|
else
|
||||||
}
|
is->audio_clock = NAN;
|
||||||
|
is->audio_clock_serial = is->audio_pkt_temp_serial;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
static double last_clock;
|
static double last_clock;
|
||||||
@ -2374,8 +2375,10 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
|
|||||||
bytes_per_sec = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);
|
bytes_per_sec = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);
|
||||||
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
|
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
|
||||||
/* Let's assume the audio driver that is used by SDL has two periods. */
|
/* Let's assume the audio driver that is used by SDL has two periods. */
|
||||||
set_clock_at(&is->audclk, is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / bytes_per_sec, is->audio_clock_serial, audio_callback_time / 1000000.0);
|
if (!isnan(is->audio_clock)) {
|
||||||
sync_clock_to_slave(&is->extclk, &is->audclk);
|
set_clock_at(&is->audclk, is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / bytes_per_sec, is->audio_clock_serial, audio_callback_time / 1000000.0);
|
||||||
|
sync_clock_to_slave(&is->extclk, &is->audclk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb_channels, int wanted_sample_rate, struct AudioParams *audio_hw_params)
|
static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb_channels, int wanted_sample_rate, struct AudioParams *audio_hw_params)
|
||||||
@ -2682,6 +2685,7 @@ static int read_thread(void *arg)
|
|||||||
int st_index[AVMEDIA_TYPE_NB];
|
int st_index[AVMEDIA_TYPE_NB];
|
||||||
AVPacket pkt1, *pkt = &pkt1;
|
AVPacket pkt1, *pkt = &pkt1;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
|
int64_t stream_start_time;
|
||||||
int pkt_in_play_range = 0;
|
int pkt_in_play_range = 0;
|
||||||
AVDictionaryEntry *t;
|
AVDictionaryEntry *t;
|
||||||
AVDictionary **opts;
|
AVDictionary **opts;
|
||||||
@ -2923,8 +2927,9 @@ static int read_thread(void *arg)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* check if packet is in play range specified by user, then queue, otherwise discard */
|
/* check if packet is in play range specified by user, then queue, otherwise discard */
|
||||||
|
stream_start_time = ic->streams[pkt->stream_index]->start_time;
|
||||||
pkt_in_play_range = duration == AV_NOPTS_VALUE ||
|
pkt_in_play_range = duration == AV_NOPTS_VALUE ||
|
||||||
(pkt->pts - ic->streams[pkt->stream_index]->start_time) *
|
(pkt->pts - (stream_start_time != AV_NOPTS_VALUE ? stream_start_time : 0)) *
|
||||||
av_q2d(ic->streams[pkt->stream_index]->time_base) -
|
av_q2d(ic->streams[pkt->stream_index]->time_base) -
|
||||||
(double)(start_time != AV_NOPTS_VALUE ? start_time : 0) / 1000000
|
(double)(start_time != AV_NOPTS_VALUE ? start_time : 0) / 1000000
|
||||||
<= ((double)duration / 1000000);
|
<= ((double)duration / 1000000);
|
||||||
|
Loading…
Reference in New Issue
Block a user