From patchwork Mon Dec 13 07:21:35 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: 32407 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5072804iog; Sun, 12 Dec 2021 23:23:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiTBjW9XBIWYLWyZhYj9ic9pru2w0o6NTp4dmxhpRf7TxlPSC2WpyX+6lOfGS7PGd7XTnU X-Received: by 2002:aa7:df9a:: with SMTP id b26mr60619311edy.107.1639380181449; Sun, 12 Dec 2021 23:23:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639380181; cv=none; d=google.com; s=arc-20160816; b=Uu7tH0VSTa48AQtveAoL/VNddjVwUeeu7cZkqImY0DAoFlpGetOKpMWPvxKgXGeHjm NCbrs8sW8MsuVEM8Movz+Xj+xpW3nmu+uKWeV6QvwDBki7+wdqLAwR1os0TEnR8RwpKO Kfp7UFlaH77kWIZtcTH1W61z2nB5407PvL1B8YplnlKj6ZJIA08vzv/dkJJDH0NXjEtB InTbwYuwwYc8vu9v5rQQ9d/e3gVi3osCvmflc3jkq3GFa5QXeixNvnH7KtRn+8aEolJ6 A390Rz+imU9vwILqsgBCIy0nPWuC9VU2SGi8xBYdsQrSbcvyK4ZEoxQM8rRdBaefgRux d+Ag== 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=mZJbOBmGSFOr9JX/7zDhDe36Orp4Wxh8hCu6zihnxWPNi+/e5jRHGvHFzDKzrZAKhs fLBU6fgOlt2qSx/6OVn1DpAEhvtZ+ldDrDCP61YEmNJ5/3vt3yOjYTpqK1phPx/qYYqm VHvo5ymco4bmdUBuw/GaTO5pZU81+vDHnB7NF4wfWGwZJIshKm8rGibKR8qcFSxa6570 /wFfnVD5tTwvBpLb3+ZR7VqfFp2l76fR+L099poif3sHiyunyM1x2I6ljb319y1qxIKX j9YDmbp2ObP9a0WtXcm4vfAvgEZSru58gLERfD3MdhJOxYxGwJMTY2n2TElAcBSp+YsR iycA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PDvXF3b+; 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 hd43si18255466ejc.484.2021.12.12.23.23.01; Sun, 12 Dec 2021 23:23:01 -0800 (PST) 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=20210112 header.b=PDvXF3b+; 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 AFEFA68AF32; Mon, 13 Dec 2021 09:22:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D442368AF19 for ; Mon, 13 Dec 2021 09:22:36 +0200 (EET) Received: by mail-lj1-f169.google.com with SMTP id 207so22305974ljf.10 for ; Sun, 12 Dec 2021 23:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=adnbYYXt3y1rSvkqYNUbMSM3zzoFE+m4ORetAFLtEoA=; b=PDvXF3b+h8Nm5pZ+2F1JivXLErBXRjV7FoTEE7MH3N9PEt1KCjnjvo2eMklmR9seld lL3IaPJJDynuAQMYKF7oBMCpGhjGrJVXlGwA8CjekIut/c1Qdqe35wJLLviLOtgBGRhy 9E6FcfRDn7Yxv/AihqOFfzUBIDz7B4QZrDyX0d2NR2FKFvH3Oy9hFEyujyblr30oQAbp wExzKWEAHehCY5xnGSa8cNlZVOrj3eQgUZNw99WLAVV+ZqM+U7Z2GZAP9+SX5DmqjK0s mDelW2TkOusKSFT+H7OurbTWr6hSbk1HGj3/MtF2aGcPanHj+m9ISFnZjXDuUIxDFsLv e+Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=l6xcmW2GW9TnvcTefkjIkaL6QqyA+xAs/usJs+HXds/qlYwQQUkHWSU/F58i3FGgoJ PZcwjjrE87R+GS30ARPRvBbzNe8bo7b7CQ/hYdmYABkbu0n6XK2XHq+50mMWOfgTXNt/ J3OklCMpHk+Y90GsCT4gBCjVMUGQvtqf7LxHNDPW4hfog7qAMMmQTKGgsgfOgGPwFKWR foS/jvRebOYkwpcq8brRz+choPiSfaCrlF+/ncaYna/8FqX3OwnAciXhPVECXRp3EbLw Y/pS+g7uQFUY/BxN5hO32EBp6rdlgFwdQuBLqMX95BlkeFYKkO2FsosbBcuCHPRaSadC RnJw== X-Gm-Message-State: AOAM533uugk7ZJatWW9q3cuCN2EveWRJgyePiVT84KdWPJmNNVslcBQO 7vAAbUQPJm+us8Bpr3lp2VwVZJoVWnQiHw== X-Received: by 2002:a2e:b8d0:: with SMTP id s16mr27827416ljp.496.1639380155128; Sun, 12 Dec 2021 23:22:35 -0800 (PST) Received: from localhost.localdomain (84-217-56-54.customers.ownit.se. [84.217.56.54]) by smtp.gmail.com with ESMTPSA id bj11sm1318383ljb.62.2021.12.12.23.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 23:22:34 -0800 (PST) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Dec 2021 08:21:35 +0100 Message-Id: <20211213072143.993-6-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20211213072143.993-1-dcnieho@gmail.com> References: <20211213072143.993-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 05/13] 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: ksqr+E05RpGy 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;