mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-16 11:47:04 +00:00
ffmpeg: Use av_gettime_relative()
Whenever av_gettime() is used to measure relative period of time, av_gettime_relative() is prefered as it guarantee monotonic time on supported platforms. Signed-off-by: Olivier Langlois <olivier@trillion01.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
e705d0ce1c
commit
76191c08f8
@ -181,12 +181,12 @@ static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env)
|
|||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
|
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
|
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
|
||||||
|
|
||||||
start = av_gettime();
|
start = av_gettime_relative();
|
||||||
for (i = 0; i < OPENCL_NB_ITER; i++)
|
for (i = 0; i < OPENCL_NB_ITER; i++)
|
||||||
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
|
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
|
||||||
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
|
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
|
||||||
clFinish(ext_opencl_env->command_queue);
|
clFinish(ext_opencl_env->command_queue);
|
||||||
ret = (av_gettime() - start)/OPENCL_NB_ITER;
|
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
|
||||||
end:
|
end:
|
||||||
if (kernel)
|
if (kernel)
|
||||||
clReleaseKernel(kernel);
|
clReleaseKernel(kernel);
|
||||||
|
10
ffmpeg.c
10
ffmpeg.c
@ -2430,7 +2430,7 @@ static int transcode_init(void)
|
|||||||
InputFile *ifile = input_files[i];
|
InputFile *ifile = input_files[i];
|
||||||
if (ifile->rate_emu)
|
if (ifile->rate_emu)
|
||||||
for (j = 0; j < ifile->nb_streams; j++)
|
for (j = 0; j < ifile->nb_streams; j++)
|
||||||
input_streams[j + ifile->ist_index]->start = av_gettime();
|
input_streams[j + ifile->ist_index]->start = av_gettime_relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* output stream init */
|
/* output stream init */
|
||||||
@ -3228,7 +3228,7 @@ static int get_input_packet(InputFile *f, AVPacket *pkt)
|
|||||||
for (i = 0; i < f->nb_streams; i++) {
|
for (i = 0; i < f->nb_streams; i++) {
|
||||||
InputStream *ist = input_streams[f->ist_index + i];
|
InputStream *ist = input_streams[f->ist_index + i];
|
||||||
int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
|
int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
|
||||||
int64_t now = av_gettime() - ist->start;
|
int64_t now = av_gettime_relative() - ist->start;
|
||||||
if (pts > now)
|
if (pts > now)
|
||||||
return AVERROR(EAGAIN);
|
return AVERROR(EAGAIN);
|
||||||
}
|
}
|
||||||
@ -3594,7 +3594,7 @@ static int transcode(void)
|
|||||||
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
|
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_start = av_gettime();
|
timer_start = av_gettime_relative();
|
||||||
|
|
||||||
#if HAVE_PTHREADS
|
#if HAVE_PTHREADS
|
||||||
if ((ret = init_input_threads()) < 0)
|
if ((ret = init_input_threads()) < 0)
|
||||||
@ -3602,7 +3602,7 @@ static int transcode(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (!received_sigterm) {
|
while (!received_sigterm) {
|
||||||
int64_t cur_time= av_gettime();
|
int64_t cur_time= av_gettime_relative();
|
||||||
|
|
||||||
/* if 'q' pressed, exits */
|
/* if 'q' pressed, exits */
|
||||||
if (stdin_interaction)
|
if (stdin_interaction)
|
||||||
@ -3649,7 +3649,7 @@ static int transcode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dump report by using the first video and audio streams */
|
/* dump report by using the first video and audio streams */
|
||||||
print_report(1, timer_start, av_gettime());
|
print_report(1, timer_start, av_gettime_relative());
|
||||||
|
|
||||||
/* close each encoder */
|
/* close each encoder */
|
||||||
for (i = 0; i < nb_output_streams; i++) {
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user