From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id AA8CF401CA for ; Sun, 19 Dec 2021 19:22:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C76FC68AF57; Sun, 19 Dec 2021 21:22:21 +0200 (EET) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11C3268AF36 for ; Sun, 19 Dec 2021 21:22:19 +0200 (EET) Received: by mail-lf1-f52.google.com with SMTP id b22so16914189lfb.9 for ; Sun, 19 Dec 2021 11:22:19 -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=tLBGkU73btm2UY8VXqRWlX4bo6pvicPCF5lFX+SbDcM=; b=CPt1VvIM24uHqOYlXm0Yv9XFq/jnvhTFH15qvjHIP2hrwBz3Fs62kmG3r2zQTGkI0s malzBd7oGBaER0EzhLEbdY6nrE/o3XLoi9gwbmkG7YOqNGnfm2PE4shsd+l15pl/mWoL IZzBSP4hIMICoFVR0VTTELc+rigSCPCwQ1SjY2es7/ZQqRT8j9h88zbwijPg9x5l+vdA pDPlFyjFhDszBNcqWbqT8Y5WXURMgto3S0lPVJhb/bxpoI9qc/4TQ/yZlKV7NDpF+rwr QXkopAmgWtWdSCh8ie4PnbidEKtM54XvDnn8swC0yDabZkECUvgWf2nw1LV5rVQmvtPw zP2A== 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=tLBGkU73btm2UY8VXqRWlX4bo6pvicPCF5lFX+SbDcM=; b=XTlEN6Ecd25ypis6V0FS0NcSG5BRJem9eSE6KALw0JkopDmKAuFpsjtfF7qLAIKUPV O9v8ajlGo33x1AbUiJxuWEb25JqnFy4iYzThs2v/octpeVpmayyuN5+bO+c94wOgjYD3 NtKpSBnV87RQUfBZ9OEXNHCg7YnTXK3Ay/VeR9Pr6M0lWxZCWmkBeDr55Pg3I4fOlxqZ 6TumJtGD0uMn9BnMMtLUuW/DjXncU8JnYQR4/IDUyKd72ZmnAKDDTiPFVsoeI0DxczNb 6tKoB9HQ8gFlN0B7jNAlQmKTu9eKtH/hxC1Zb/rt6poPWQA+dXvBpUHOijy1Z2Ze+yFD WFDA== X-Gm-Message-State: AOAM531JGGT1yGCcl5K7M6vZnFiXAhCz03fHwKHceOCxA/8YN68IAL8J HjzQyKJSCuO80BdxNqTUwRSWZbZA52X0H5Lg X-Google-Smtp-Source: ABdhPJzuTDPEZY09JfLV+7eAzq75ZyuP5+2UmwIDFTWO4J9uV91/VS+X0538MJ7EC1eXc5GiKRAsyA== X-Received: by 2002:a05:6512:ac9:: with SMTP id n9mr5772183lfu.460.1639941738829; Sun, 19 Dec 2021 11:22:18 -0800 (PST) Received: from localhost.localdomain (84-217-56-54.customers.ownit.se. [84.217.56.54]) by smtp.gmail.com with ESMTPSA id z24sm2127812lfh.289.2021.12.19.11.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 11:22:18 -0800 (PST) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Dec 2021 20:21:25 +0100 Message-Id: <20211219192134.1296-5-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20211219192134.1296-1-dcnieho@gmail.com> References: <20211219192134.1296-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 04/13] 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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; } -- 2.28.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".