From patchwork Mon Jun 7 23:03:43 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: 28161 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp3889792iof; Mon, 7 Jun 2021 16:10:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPWBmKZjem26BeOChreQW9eHYQQgNsMzoHBBPolELT5Nu9hcpZ6jqqdBQpvxZyKGurnMzs X-Received: by 2002:a17:906:394:: with SMTP id b20mr20099529eja.108.1623107435005; Mon, 07 Jun 2021 16:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623107435; cv=none; d=google.com; s=arc-20160816; b=G37nJEIdPS3VvfwsMYgE7E6ZimXohll7QWkaVAlq6MCQbgJ7HPJZS9h7vMZsufw5MB dTJef2qEf+Z4No2spO+ZXfgkY/lgyCrcZ/SFg1JBSRjR0PpbwQvZlwCBxFADFdMkiHY9 eAZ/98s9cORVHjPepQG3MfJLzFOS/v63yheIn7S36oxhWl57y8AIVgdklO8pvwrQ0q7S gc69TazresWZWu6WzjdsboN1lGGksbs/603ouK/aTd+osK86UBoXw7lo7fbZg6WHIoZo ZVQk83PFlCLyA2hBC919i6kQZCGHNZEtKAl501e2uhP00IuyygroLcL0FjnfDpobovhq S8zQ== 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=+ebHyRTijEqfyQAbEzNZ8SxGuXZab4wxBcIeLGIELv8=; b=x6kXN+l4J9Ny+932n8mcCmcaRoQCEcY5rMxhgBsGodO1lwmWmi8rw/Vjf63xmuFzcu QGT3AXKImYCkGl1j0DiCvoTS0+O07Tf6O+fWrmsOpTySUU3HS5Hguca5zIlY2mwyuehw ZMNPbKqRkadFm519HapKZD8vBCO/8Lhw3TVKRjsmUDZDSB4hwotZd8vc+aKjuNEJO3bS epajWuBlw1yZkzjxYj5lqd1nibrBw4cZu5DN3476D+ca5ziXb+CcEvSKYuX8YU1T2Yq3 hGWLEdUPaggjF0HRFxotQsLSv3asxh93z25B6nlZn0taXEGFYVLHDf+CPnru7v4oDXZc z+Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=jT7W2e1M; 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 r7si6829148edd.2.2021.06.07.16.10.34; Mon, 07 Jun 2021 16:10:34 -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=jT7W2e1M; 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 415AB687F3D; Tue, 8 Jun 2021 02:10:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E4366818DB for ; Tue, 8 Jun 2021 02:10:22 +0300 (EEST) Received: by mail-lj1-f182.google.com with SMTP id r16so5257278ljk.9 for ; Mon, 07 Jun 2021 16:10:22 -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=vM85fUiUmL5WPImQHPYnayxMXdiC3qAvMR9o+8z2els=; b=jT7W2e1MhvA1N1aMBH0IkhnpeqRgWNeHpgwP5lOwEi/Rg8XU80SPCxtrluuMYpyJio pXeYjdad5aP8pu6fp2y0IzAo3dhF/Nqfll0F663TZvyG3La3vZpeuqmnH2xeOYHzoyox f4kepzU+r+bQsZFFMtPsBv1iEtGF6UcA1dustqxC1A6HcX0W99p57r2/Z65qBTEnLRrg RdSb7CfZFvk2YDjaG4S1C7VxdU49rQw38gKA05Xe7uuzDqV8EmSkNkHwW89Lud+7EGHp 0gxJ5O0w0VnLs2Muf2SM/R1mevABU6ujAsZzj7wnfEU7pUi6ekMnTvhN659HlvYw8yIW 11rg== 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=vM85fUiUmL5WPImQHPYnayxMXdiC3qAvMR9o+8z2els=; b=NTkh3vaQEr8j+Vuko9MaACFX2RXDFt5eU3iZpfrcT4l8RvGr1ZjEJyXDL2iy5toMfn xmgZM+h6evrH3vEUwQ+r/X4Jrs1gaBh/isHiYcwUmbO1o48QhcKetwdxlz9ftrwN9dHt sYijpqY0Y94PLqVq1eFM9jLqxcW2Pcz27cH1vrWrmpUwc6aSTdGiLULC3KyVnfQsU+h9 9LfRpNecT1q8KWg4A5GS0WP3Aoxv+Je/NDy+V4w7AlBAb6Plrmrs4XrzK0GqgLAOb7+G SidqNQfbxUa6L1jsBgjRlvl4jR8CCPBN78MjO7m/DYa3qfZah0IJJuK0MEtJFFt61uXo HQHw== X-Gm-Message-State: AOAM533FnCYHN1cjYN/+WKd7Z50w4u7dumCvLeEh0nGQhT8le+LRn9i/ Z84c1cuSvjlCZEVMDWe5bzmld4kp0ncLsw== X-Received: by 2002:a05:6512:2397:: with SMTP id c23mr13391658lfv.114.1623107070393; Mon, 07 Jun 2021 16:04:30 -0700 (PDT) Received: from localhost.localdomain (84-217-56-54.customers.ownit.se. [84.217.56.54]) by smtp.gmail.com with ESMTPSA id v9sm1999563ljv.131.2021.06.07.16.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 16:04:30 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Jun 2021 01:03:43 +0200 Message-Id: <20210607230414.612-5-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210607230414.612-1-dcnieho@gmail.com> References: <20210607230414.612-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/35] 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: P0LKlNxF1w2C 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;