You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-09-16 08:36:51 +02:00
avplay: Use av_gettime_relative
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
24
avplay.c
24
avplay.c
@@ -101,7 +101,7 @@ typedef struct PacketQueue {
|
|||||||
|
|
||||||
typedef struct VideoPicture {
|
typedef struct VideoPicture {
|
||||||
double pts; // presentation timestamp for this picture
|
double pts; // presentation timestamp for this picture
|
||||||
double target_clock; // av_gettime() time at which this should be displayed ideally
|
double target_clock; // av_gettime_relative() time at which this should be displayed ideally
|
||||||
int64_t pos; // byte position in file
|
int64_t pos; // byte position in file
|
||||||
SDL_Overlay *bmp;
|
SDL_Overlay *bmp;
|
||||||
int width, height; /* source height & width */
|
int width, height; /* source height & width */
|
||||||
@@ -197,7 +197,7 @@ typedef struct VideoState {
|
|||||||
AVStream *video_st;
|
AVStream *video_st;
|
||||||
PacketQueue videoq;
|
PacketQueue videoq;
|
||||||
double video_current_pts; // current displayed pts (different from video_clock if frame fifos are used)
|
double video_current_pts; // current displayed pts (different from video_clock if frame fifos are used)
|
||||||
double video_current_pts_drift; // video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
|
double video_current_pts_drift; // video_current_pts - time (av_gettime_relative) at which we updated video_current_pts - used to have running video pts
|
||||||
int64_t video_current_pos; // current displayed file pos
|
int64_t video_current_pos; // current displayed file pos
|
||||||
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
|
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
|
||||||
int pictq_size, pictq_rindex, pictq_windex;
|
int pictq_size, pictq_rindex, pictq_windex;
|
||||||
@@ -754,7 +754,7 @@ static void video_audio_display(VideoState *s)
|
|||||||
/* to be more precise, we take into account the time spent since
|
/* to be more precise, we take into account the time spent since
|
||||||
the last buffer computation */
|
the last buffer computation */
|
||||||
if (audio_callback_time) {
|
if (audio_callback_time) {
|
||||||
time_diff = av_gettime() - audio_callback_time;
|
time_diff = av_gettime_relative() - audio_callback_time;
|
||||||
delay -= (time_diff * s->sdl_sample_rate) / 1000000;
|
delay -= (time_diff * s->sdl_sample_rate) / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,7 +972,7 @@ static double get_video_clock(VideoState *is)
|
|||||||
if (is->paused) {
|
if (is->paused) {
|
||||||
return is->video_current_pts;
|
return is->video_current_pts;
|
||||||
} else {
|
} else {
|
||||||
return is->video_current_pts_drift + av_gettime() / 1000000.0;
|
return is->video_current_pts_drift + av_gettime_relative() / 1000000.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,7 +980,7 @@ static double get_video_clock(VideoState *is)
|
|||||||
static double get_external_clock(VideoState *is)
|
static double get_external_clock(VideoState *is)
|
||||||
{
|
{
|
||||||
int64_t ti;
|
int64_t ti;
|
||||||
ti = av_gettime();
|
ti = av_gettime_relative();
|
||||||
return is->external_clock + ((ti - is->external_clock_time) * 1e-6);
|
return is->external_clock + ((ti - is->external_clock_time) * 1e-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1022,11 +1022,11 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by
|
|||||||
static void stream_pause(VideoState *is)
|
static void stream_pause(VideoState *is)
|
||||||
{
|
{
|
||||||
if (is->paused) {
|
if (is->paused) {
|
||||||
is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
|
is->frame_timer += av_gettime_relative() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
|
||||||
if (is->read_pause_return != AVERROR(ENOSYS)) {
|
if (is->read_pause_return != AVERROR(ENOSYS)) {
|
||||||
is->video_current_pts = is->video_current_pts_drift + av_gettime() / 1000000.0;
|
is->video_current_pts = is->video_current_pts_drift + av_gettime_relative() / 1000000.0;
|
||||||
}
|
}
|
||||||
is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
|
is->video_current_pts_drift = is->video_current_pts - av_gettime_relative() / 1000000.0;
|
||||||
}
|
}
|
||||||
is->paused = !is->paused;
|
is->paused = !is->paused;
|
||||||
}
|
}
|
||||||
@@ -1084,7 +1084,7 @@ retry:
|
|||||||
if (is->pictq_size == 0) {
|
if (is->pictq_size == 0) {
|
||||||
// nothing to do, no picture to display in the que
|
// nothing to do, no picture to display in the que
|
||||||
} else {
|
} else {
|
||||||
double time = av_gettime() / 1000000.0;
|
double time = av_gettime_relative() / 1000000.0;
|
||||||
double next_target;
|
double next_target;
|
||||||
/* dequeue the picture */
|
/* dequeue the picture */
|
||||||
vp = &is->pictq[is->pictq_rindex];
|
vp = &is->pictq[is->pictq_rindex];
|
||||||
@@ -1190,7 +1190,7 @@ retry:
|
|||||||
int aqsize, vqsize, sqsize;
|
int aqsize, vqsize, sqsize;
|
||||||
double av_diff;
|
double av_diff;
|
||||||
|
|
||||||
cur_time = av_gettime();
|
cur_time = av_gettime_relative();
|
||||||
if (!last_time || (cur_time - last_time) >= 30000) {
|
if (!last_time || (cur_time - last_time) >= 30000) {
|
||||||
aqsize = 0;
|
aqsize = 0;
|
||||||
vqsize = 0;
|
vqsize = 0;
|
||||||
@@ -1464,7 +1464,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
|
|||||||
init_pts_correction(&is->pts_ctx);
|
init_pts_correction(&is->pts_ctx);
|
||||||
is->frame_last_pts = AV_NOPTS_VALUE;
|
is->frame_last_pts = AV_NOPTS_VALUE;
|
||||||
is->frame_last_delay = 0;
|
is->frame_last_delay = 0;
|
||||||
is->frame_timer = (double)av_gettime() / 1000000.0;
|
is->frame_timer = (double)av_gettime_relative() / 1000000.0;
|
||||||
is->skip_frames = 1;
|
is->skip_frames = 1;
|
||||||
is->skip_frames_index = 0;
|
is->skip_frames_index = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1993,7 +1993,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
|
|||||||
int audio_size, len1;
|
int audio_size, len1;
|
||||||
double pts;
|
double pts;
|
||||||
|
|
||||||
audio_callback_time = av_gettime();
|
audio_callback_time = av_gettime_relative();
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
if (is->audio_buf_index >= is->audio_buf_size) {
|
if (is->audio_buf_index >= is->audio_buf_size) {
|
||||||
|
Reference in New Issue
Block a user