From patchwork Wed Oct 25 11:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 44355 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4999:b0:15d:8365:d4b8 with SMTP id fs25csp343257pzb; Wed, 25 Oct 2023 04:43:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmtrwXvjjTEzJH/QOXAalCj5Gmr9rzepjxFU+YGWajR6y16c3n63+OuKNdxp9onkNHVRO2 X-Received: by 2002:a05:6402:2813:b0:53f:8493:5b0b with SMTP id h19-20020a056402281300b0053f84935b0bmr12537617ede.35.1698234182839; Wed, 25 Oct 2023 04:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698234182; cv=none; d=google.com; s=arc-20160816; b=0Uw7Dh6mZqh3p8kXJqYX+pmzkL2xmLck7ZsJxvBKCbb0XISACbnxJZp6Fw5N0ZQM1n lMD21QVqwy7ksfheQDj22l775KuN1yiCfWkP9qYJUMOwDTvg1ai8+TFCB9iq91uzQUgf KcLmPKsfxWdmpQUSwbvags6dv9ZRVol6e+X4la9mIYihR7ny5/lDmnN2r6e/iBhEjPpl WoEyAgLKNXlfKHgQRHsCvz7wZprgvwiId5XMceK9oTf2rjH4ZXGFDmNbKempklbRhwMz 7/87QJVd07/7TYEVuDo7CR0MhdaSPnvATG67XYuPRDzfvEZ61zq1Gm/hKtPNEwREM+3R /RcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=zDkfFb++1NtLs2wE6HquvQE8skTgJ2Z6LZx1RfuTalc=; fh=t7y2C+eTeDTjU/IXcwx7KgHV+pYAZ1n9wIrNqt3BZNM=; b=l6r2rOzC4pDo0YcWzpqKK6URqWzzGDEY14NtjQCxsc6yQxCdSHLwWdZyTxx3pALOFB TzsUp9nvByNxFTOhCWBmhvH1olLHLzLtgDwhPoin/VF7OCteTyZ/IzbDodsUoWQHeiO8 xrnc9gmdZkrH5FQJ64OD211sozB8H/lvIkIdcCMjnERxJ8N1qhToc5NuT7q0rtg18fS0 v3TSo2CqpuEX+ysc5uQy1Qm6j7nyiY+7UZm0aK6mjZvMwTszts/CAY7Q1itG3L5e+ftc rFGJWD0vyufnUdlRcXI1h9y3En3lqsPZVdZhIlegR/xIMJ+lUFVfSNfvdllbTIKwoTCw ZD4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=RXelUtQb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k22-20020a056402049600b005376fa4cfabsi5474829edv.675.2023.10.25.04.43.01; Wed, 25 Oct 2023 04:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=RXelUtQb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB79468CACB; Wed, 25 Oct 2023 14:42:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0FFB68C9F8 for ; Wed, 25 Oct 2023 14:42:51 +0300 (EEST) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-32db8f8441eso4239023f8f.0 for ; Wed, 25 Oct 2023 04:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698234170; x=1698838970; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9Y5sRMCN77m+K8GdiXKQtYvSaED+LwDgz2hcnkWYkUA=; b=RXelUtQb2R8i9oas+GmHqznICCnAEZas0Un4EYpMO2ld0pzu9WTzl+reJYb2stcTsM ImigeX8ixxC7NEycV2TVqRcQinCpKv4yoI5U0ChSI+sW4QwCMmbGWHW9EAwlcSQXkwpp jRLf6epiOgfVtebapSo0fDUODQJh2mAc8oveRAp2dC2eUd1tc2rHLUm9hH8KYh092KSv YkQqERDGQd8VirgmdC0diTbmw/ebnulpwU5E+DBQQ3hiVcbwvSRGaOmQ6F9DUPlRuaEk XxQA0VdJ1xb0J9eIzBzvPt3F//u4LohHsY9y6Hku0JKX4Tz9dFSzPObSWVanqg/Faz1j FV0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698234170; x=1698838970; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9Y5sRMCN77m+K8GdiXKQtYvSaED+LwDgz2hcnkWYkUA=; b=QWlJYYAGL1tqaJ6OIx8sL7ue1Oo5fW9vMtUJqhebYiYlLp84nwCBVSsAqowCtTRRUV UBa2JqaCebi7HYkoRPgA6iMsOsbaOtMkWBgLcEOjP8xUtYC2uMEQxFUsN3zTrZxGD34X gzw3rtapsEz/dzvvIKcOnPc03omjd6pr8aUw80qQ5Gvcb/Ms78Xr/wFEJCxuG53XME1X i3813QcaVyv8DBUpKUxZg0CeiI8JO7CfnyGFVRf/3FmDMVYRcBuBDOxE5Eh4EeLhgjJT 4eCLT31EOmFxqz5EZ8q26r/YXQVhSUIqJgcbwe4SoDVGkkrUOYfje/x59TeBHdTLaXF4 Abew== X-Gm-Message-State: AOJu0Yxj0K7tRVPpEQI8MLOzk4Th+SICk+7tTNVGVFTZEAD+Xg3heKsN 543PYCK/Z0WMkRDF8YXYFjp4qKTbb90= X-Received: by 2002:a05:6000:10c1:b0:32d:a466:c471 with SMTP id b1-20020a05600010c100b0032da466c471mr9580198wrx.19.1698234169988; Wed, 25 Oct 2023 04:42:49 -0700 (PDT) Received: from Clement-Blade14.outsight.local (lputeaux-656-1-11-33.w82-127.abo.wanadoo.fr. [82.127.142.33]) by smtp.gmail.com with ESMTPSA id n15-20020adfe78f000000b003197869bcd7sm11966271wrm.13.2023.10.25.04.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 04:42:49 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Oct 2023 13:42:45 +0200 Message-ID: <20231025114245.170846-1-peron.clem@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/demux: use producer timestamp as wallclock when available X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pjc0lXaBt2g9 When use_wallclock_as_timestamps option is enabled the demux rely on the time of the system even when a producer wallclock is available. If a Producer Reference Timestamp is available use it instead of the system timestamp. Signed-off-by: Clément Péron --- libavformat/demux.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 6decb08698..94a622e0cc 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -635,8 +635,17 @@ FF_ENABLE_DEPRECATION_WARNINGS force_codec_ids(s, st); /* TODO: audio: time filter; video: frame reordering (pts != dts) */ - if (s->use_wallclock_as_timestamps) - pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); + if (s->use_wallclock_as_timestamps) { + AVProducerReferenceTime *prft; + size_t side_data_size; + + // User Producer Reference time as wallclock when available + prft = (AVProducerReferenceTime *)av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size); + if (prft && side_data_size == sizeof(AVProducerReferenceTime) && prft->flags == 24) + pkt->dts = pkt->pts = av_rescale_q(prft->wallclock, AV_TIME_BASE_Q, st->time_base); + else + pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); + } if (!pktl && sti->request_probe <= 0) return 0;