MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_convert_timestamp

Function init_convert_timestamp

libavdevice/v4l2.c:479–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477#endif
478
479static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
480{
481 struct video_data *s = ctx->priv_data;
482 int64_t now;
483
484 now = av_gettime();
485 if (s->ts_mode == V4L_TS_ABS &&
486 ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE) {
487 av_log(ctx, AV_LOG_INFO, "Detected absolute timestamps\n");
488 s->ts_mode = V4L_TS_CONVERT_READY;
489 return 0;
490 }
491#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
492 if (ctx->streams[0]->avg_frame_rate.num) {
493 now = av_gettime_monotonic();
494 if (s->ts_mode == V4L_TS_MONO2ABS ||
495 (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) {
496 AVRational tb = {AV_TIME_BASE, 1};
497 int64_t period = av_rescale_q(1, tb, ctx->streams[0]->avg_frame_rate);
498 av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n");
499 /* microseconds instead of seconds, MHz instead of Hz */
500 s->timefilter = ff_timefilter_new(1, period, 1.0E-6);
501 if (!s->timefilter)
502 return AVERROR(ENOMEM);
503 s->ts_mode = V4L_TS_CONVERT_READY;
504 return 0;
505 }
506 }
507#endif
508 av_log(ctx, AV_LOG_ERROR, "Unknown timestamps\n");
509 return AVERROR(EIO);
510}
511
512static int convert_timestamp(AVFormatContext *ctx, int64_t *ts)
513{

Callers 1

convert_timestampFunction · 0.85

Calls 5

av_gettimeFunction · 0.85
av_logFunction · 0.85
av_gettime_monotonicFunction · 0.85
av_rescale_qFunction · 0.85
ff_timefilter_newFunction · 0.85

Tested by

no test coverage detected