From patchwork Tue Jul 6 09:19:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28790 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp4919664ios; Tue, 6 Jul 2021 02:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3jZew6N//+V51yZ/OfdcuHWI0nfrVC6m0X/Ag+4EpPm53pIDDqd52axbanQVJ9McqeHQE X-Received: by 2002:a05:6402:1103:: with SMTP id u3mr21743789edv.342.1625563311820; Tue, 06 Jul 2021 02:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625563311; cv=none; d=google.com; s=arc-20160816; b=t5I5ci/kPzScXv/6UOazpxdSHW/DYSs0fEkR2Yx+X48x6mmKBdaKYQrUsjOALIPoMa kuiPiMu0TZqLfxgaA049eUE2modm/cQnBIHfruB51qt7AJTHdQAwbyaXM9Y1ANEFfwzM 8R4glnee4ul2cKk3OrDOOaVOTVxI6y55BTMaEt+ceKr3OKEgTA1LxDz6obyMzrFxQ/sM hmKs00EIvPbgdU5CSM8D0ajUfBFBxK1P9JJxrptQElRJbMnG/JTXx91JCHmHaLNF3GWl tvEbogZWtmW0k3iioAU/9Vj6aeV2XqDfStKqTyxLp5xfppmECaZXUtKFRm2KflyAd/06 7ktw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=1GNbKic4/hTLN8/M2EuCDzyPjx1FXZ2iUnm51nzwk7Y=; b=YSzztZUBjvjFF7n2d2I/S0MpZiQQIu4djy4QPv1NCIWWL53KrQDH1JtkEORS1myaxv RT1DDQDtXpYDDyzzJx46BxUHnDDdTqPAIOc03F/2pCN3ezmfGS+cobC9SUGjgnpPW16P ayaOEK1dsVgMZCCkd8cbmuoseATZaEyI3YotSfJqhVNu1S8DHMxz3S0NYR7UzTbXtqoR B/0nO914km8GgjSUz5xX6N8jSDiV8/zpFzlXZQBqN3JdT1Kn6eASOROv2a8zknOhhAjt SBzzbQL84yJhyTOmAT45dtrt9XHg9ge5RspxehAAsOZ2+hQ47Gsp0frbrwYelfC+ymL9 +qkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=hsnXMbTY; 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 hr19si10168470ejc.270.2021.07.06.02.21.51; Tue, 06 Jul 2021 02:21:51 -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=20161025 header.b=hsnXMbTY; 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 4F56768A4C5; Tue, 6 Jul 2021 12:21:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B8FE768A4C5 for ; Tue, 6 Jul 2021 12:21:41 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id y42so1885255lfa.3 for ; Tue, 06 Jul 2021 02:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=adnbYYXt3y1rSvkqYNUbMSM3zzoFE+m4ORetAFLtEoA=; b=hsnXMbTYQjJWQ9DpY4ESaOK3Fg6o/LKxN4rCAL/p5/LQQFcVx7JfRR9quxaCMJdo+w uxmLmMSEN/3omY3213aZsOhibezmhIQIaNJpi/EpOgkgCoRzCULqx+Cy9EArEPoITN+C VXee7/uRMXM31goD4Jx2zD2HgA1YJURyK8k8ys6/7zV2dAt57AAYzG43aP0IYI6lm8oE lSNz/kULh8vjkRcDjxHWWXF8kgkafZrB8FM+REzEEiZEBWa5iRgqVOH+RUygmFr+dkUm rZAgtsswzTx1Ch5lRltBdExEksmZIHFYIaCiuWS/vvNGsDbw8bpwjAMf6s/yOaLNk21U hOCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=adnbYYXt3y1rSvkqYNUbMSM3zzoFE+m4ORetAFLtEoA=; b=e8sNrn/FThwlAnkAUMqJInbH8/xZdKC1AgFUo5gLfjTeOdQIzEhYI4RqzA29+4vAsp W0Da6TiTv95KKLBGf7x9hGSLqY1/BnhT43rDTfhGX4x/qgtaQqEiHncQTcD/S4/d/jH6 pu+szReDcZ37DXCwCHVZuyFdrJ8d9FoJM1TWFneDBu9hpAPSnBWqPolRXY/DB+T3zpsj EJ3JLqSF0bqhquVssphdyPLOQL/8ZuWWEJJmX3uNHZIJffeGmtMZn7VNrYEut7jl2YMu g1d3m/+JWt0nvSxJrXwcwQCzcfgE/GjC7BqPoImvCjdgAZNv9iXSTzXEDyPoirfVMp8c cSfA== X-Gm-Message-State: AOAM532Hic2iHfpYjRAUbFsx3mTGoI/tm999z1Lv6y/LwdaLHwTmxWKG BGAPyfhTCJTTD4A9dO6LvDYbcxCKyl8= X-Received: by 2002:a05:6512:2343:: with SMTP id p3mr13786682lfu.83.1625563300547; Tue, 06 Jul 2021 02:21:40 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id n9sm1344828lfl.69.2021.07.06.02.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 02:21:40 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Jul 2021 11:19:50 +0200 Message-Id: <20210706092020.1057-5-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210706092020.1057-1-dcnieho@gmail.com> References: <20210706092020.1057-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 04/34] avdevice/dshow: handle unknown sample time 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: Diederick Niehorster Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: axxRPe2uSyEB GetTime may return an error indication that the sample has not timestamps, or may return a NULL start time. In those cases, fall back to graph time. Better debug message in case sample dropped: could now be audio or video frame Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 1d0e880480..310f48c85e 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,14 +295,15 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; - int64_t chosentime; - int64_t sampletime; - int64_t graphtime; + int64_t chosentime = 0; + int64_t sampletime = 0; + int64_t graphtime = 0; int use_sample_time = 1; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; struct dshow_ctx *ctx; + HRESULT hr; dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this); @@ -314,22 +315,26 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) s = priv_data; ctx = s->priv_data; - IMediaSample_GetTime(sample, &sampletime, &dummy); + hr = IMediaSample_GetTime(sample, &sampletime, &dummy); IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { /* PTS from video devices is unreliable. */ chosentime = graphtime; use_sample_time = 0; } else { - if (sampletime > 400000000000000000LL) { + if (hr == VFW_E_SAMPLE_TIME_NOT_SET || sampletime == 0) { + chosentime = graphtime; + use_sample_time = 0; + } + else if (sampletime > 400000000000000000LL) { /* initial frames sometimes start < 0 (shown as a very large number here, like 437650244077016960 which FFmpeg doesn't like). TODO figure out math. For now just drop them. */ av_log(NULL, AV_LOG_DEBUG, "dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime); return S_OK; - } - chosentime = sampletime; + } else + chosentime = sampletime; } // media sample time is relative to graph start time sampletime += pin->filter->start_time;