From patchwork Tue Jul 6 09:19:49 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: 28794 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp4919511ios; Tue, 6 Jul 2021 02:21:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfTF713ayURbLTUUs1ygl7iclcS3nqZlOSPA/M2z6YvEnMH6rNmOak6qCbibIrBOydyPzE X-Received: by 2002:a17:906:5d07:: with SMTP id g7mr16365493ejt.537.1625563301209; Tue, 06 Jul 2021 02:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625563301; cv=none; d=google.com; s=arc-20160816; b=tWUgLJnT1A/ISbOW9exyCXXpBiXDq1SzmzDqViDjLWz3dH0rBExIfs60rVWRgY2qC8 sRiwubMhveC1U/xGRFRj5INaOdaZ8eYSjKGIJ8rAj3xNfwvnPi4bfdyRoy+JUFgvwza+ uG1SHcMMj8o6zNwsKOW/wu795XnqpoGUyVaVcAHMY16w8m0qYNMS7vNNwdYmcM6uWl1r r4hJml2CMlJjBkry5db1UxWTHRFjfElMfGrDsGRipJR9wvsqMxdSp1+ewFeD/mr5moqE h/evGjHLLms4BOBehPWwxpn4A7ig8r0NiyqxNy82S13rttuEfMn5yiWuQ0NeV91DfyF3 IZ9Q== 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=pa/7AoG/Tn1IKWdkErCmAui2uj/lRNPvOKfWL9u3LsY=; b=1DPTwf1rdyXPi8VhKC2cAAXka8V6i0njh6PX7dFu+oW5zLfpgDqR4mVf887IxdjV8i BFSDESh5lsxhRkn03zVXS1BcYKSHdffYYv0xK9WwnkofY8m2TdhebiacSN6tPHyk4UZT kq692TF8QmUZO2UGYD+ahgAfc9ss2TkbGzrRwxrTlQP0AUCF1NJcFIguS6cb53fpezwW ojeM8pXGOlvlb2mgsQz1BLYWEJfPBlRdn/8t4Yo41vab9S3o2hFwIO/YlGCFSGsmIo3/ wM+vUuUA8jFRDISLO7A9qpe3holz0Zn/IFJ576DlZGF3dWyzZXbEIQ36TwvDbZbubuoQ JHjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=bylRRlSd; 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 p18si13672345edr.268.2021.07.06.02.21.40; Tue, 06 Jul 2021 02:21:41 -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=bylRRlSd; 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 3948F68A6D6; Tue, 6 Jul 2021 12:21:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB15E68A6B0 for ; Tue, 6 Jul 2021 12:21:29 +0300 (EEST) Received: by mail-lf1-f43.google.com with SMTP id r26so19650971lfp.2 for ; Tue, 06 Jul 2021 02:21:29 -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=tLBGkU73btm2UY8VXqRWlX4bo6pvicPCF5lFX+SbDcM=; b=bylRRlSdgCrhz2zow4kQNyXiFckp0LEA3vBtIua1bDjdobY6I2mmpP9dMFMat2xpF1 S3dyaUTnAuYXZ6qlKYmKGxSsJO7seAOcjDvOFMm5sbGLNs1qCkPPrPHZv1l8NrqG2hh8 4CxJnc+MMe9NsJ97IYQuKDu/itYNExd75v+1RXPZhhyZgxUgp7mlyenjVcCdekA6DT5f 9q04+S2G33VzfB6m7LfAnld+gyUxh60VwzBK8xxlrR/xFB5lhg7WY/tzCDj40NP9tIZ0 u/zbTKhpcA1qj9ueXdEqPyPti3cn+yX7H9q99i/89HKX4TT2MHfsD03phf44DTwIMpbv wAeA== 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=tLBGkU73btm2UY8VXqRWlX4bo6pvicPCF5lFX+SbDcM=; b=MzEwAfwQ1ANLNfllS9wjclBJ+VwgldyNNP7jaLDAiPzAavogen7Jrp64CD5UYIjRJY 5t1oGM2Tficv+SAlmR/J7TAYEtlDJCIlSRc+fTe7c0mdoOukE4sFUjT2E+5MKFvNEscM r7Wv/SXZK1s0Dd4HY0E0hK+jLyGZ5qMDbrt0OkLDxbqUNKMRZ2n2sr+tx0ewir6ojRzB AsxNCpc/EuwvmpPj/3II+BOwQCctBmy7i/r+eV+0bXB9Bt8jRON2TgDlG25w7hZaWqCL 2sRZAJAz2H1NmU5GbqgCuIM/LfhxVEITwuMz5ekNC5ur+DpNUGjqKVyYW4OogvNx83wj zSNA== X-Gm-Message-State: AOAM5339H4lLVLhrZ6//qJbdFCgbGVdrPe0VwUYnelPaf40dCz5v34UM 7zqMHWnIox1r6qgunMpVpwjWkpTKXlA= X-Received: by 2002:a05:6512:e93:: with SMTP id bi19mr7319082lfb.129.1625563289084; Tue, 06 Jul 2021 02:21:29 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id b13sm1344510lfo.104.2021.07.06.02.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 02:21:28 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Jul 2021 11:19:49 +0200 Message-Id: <20210706092020.1057-4-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 03/34] avdevice/dshow: query graph and sample time only once 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: 2OI8qudT+C3M No need to query twice, use value we've already unconditionally got. Improve variable names Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 8e56dccbfe..1d0e880480 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,9 +295,10 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; - int64_t curtime; - int64_t orig_curtime; + int64_t chosentime; + int64_t sampletime; int64_t graphtime; + int use_sample_time = 1; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; @@ -313,24 +314,27 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) s = priv_data; ctx = s->priv_data; - IMediaSample_GetTime(sample, &orig_curtime, &dummy); - orig_curtime += pin->filter->start_time; + IMediaSample_GetTime(sample, &sampletime, &dummy); IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { /* PTS from video devices is unreliable. */ - IReferenceClock_GetTime(clock, &curtime); + chosentime = graphtime; + use_sample_time = 0; } else { - IMediaSample_GetTime(sample, &curtime, &dummy); - if(curtime > 400000000000000000LL) { + if (sampletime > 400000000000000000LL) { /* initial frames sometimes start < 0 (shown as a very large number here, - like 437650244077016960 which FFmpeg doesn't like. + 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", curtime); + "dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime); return S_OK; } - curtime += pin->filter->start_time; + chosentime = sampletime; } + // media sample time is relative to graph start time + sampletime += pin->filter->start_time; + if (use_sample_time) + chosentime += pin->filter->start_time; buf_size = IMediaSample_GetActualDataLength(sample); IMediaSample_GetPointer(sample, &buf); @@ -338,8 +342,8 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " "timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n", - devtypename, buf_size, curtime, orig_curtime, graphtime, graphtime - orig_curtime, ctx->device_name[devtype]); - pin->filter->callback(priv_data, index, buf, buf_size, curtime, devtype); + devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime, ctx->device_name[devtype]); + pin->filter->callback(priv_data, index, buf, buf_size, chosentime, devtype); return S_OK; }