From patchwork Fri Mar 24 21:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 40810 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp928716pzb; Fri, 24 Mar 2023 14:10:02 -0700 (PDT) X-Google-Smtp-Source: AKy350YlXGah4lnK4l11Xcf3SSK0rrv7TF7iId4TXF84xJzXbAsSV7mP8P9ElhaBeVQ9rzBMfD11 X-Received: by 2002:a17:906:a15a:b0:933:1967:a98a with SMTP id bu26-20020a170906a15a00b009331967a98amr4096288ejb.17.1679692202630; Fri, 24 Mar 2023 14:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679692202; cv=none; d=google.com; s=arc-20160816; b=x8KFFc9fYqCIvmWYdjOLilhR4b/FXWrAIpgUDlCHNH7w60FrjUNu3NyU8IbO872dS6 z+D5TkZP/aga102utPH0mdhe6fDIopDeAQsTehIL3BqNz73CXviihnyN02ho+KMJlm1A wkKENLhcYRQVgDqknbgBzFrLa2Dwf6X5VtBrmC8M2QX3BDF08CDpUhlsGeiYv+66E37M BCR6hsHfGIA8j6u9PxkupM7nBPZxK29wKB0yZM8Ymq5w/M3MGladYIVjmaiqh/oC4gEk pZvrpAJSVh0suGfmX02tvzPUAicpdUxwjqGVz4vyVpbdTLBPKvMw4THR1ct7WPyc39wD sgaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=OcIbBYcACtYbsZn2yxUC8aNXGJlFk9hQMocEl0Zwuo8=; b=ju2LgxJh1otV8dkznrSWnJyMqwlhmQ/ruWCx29Q2r7juuqL1Oun2kGnHZi6IZHg1oW FhOQElnnHLQ1hpcPWi92TiY7C/p5Od6BJtgY+FBBWsOzFRJDmx/dIuJxQwiQVedoZ1fu +CXR7nHQ12UVk/Yue7T9FvL3LkmCtDIMI7Ceovk2DhXEvt1URoc/y3JmRfVCENl3WG9S 1WWmurw/Pc/PQ3ILQkRK61e0RhO6/u6Vrl3VXgquqlEb1AofKQwdZNpHYgSn6FQoGJHA oM4WyfB8ZUQSdoBAqCr1rKmlKJruvLaTJ02rPIQ/Ywl+sThpSriz1gYImJX6qEQvn1AW s2Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=C54rwK3Z; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o22-20020a1709062e9600b009316b784857si21870181eji.352.2023.03.24.14.10.02; Fri, 24 Mar 2023 14:10:02 -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=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=C54rwK3Z; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E619C68C840; Fri, 24 Mar 2023 23:09:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E3D468BED5 for ; Fri, 24 Mar 2023 23:09:53 +0200 (EET) Received: by mail-lf1-f51.google.com with SMTP id t11so3860993lfr.1 for ; Fri, 24 Mar 2023 14:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; t=1679692192; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=VR8RhshDCed0TA27KJDGVob/y99IfOhWmfpEH5gIPqc=; b=C54rwK3ZJUAecbVLw/6QZZdx8djb5AQ//u3ObeAyjlnCuz20T2Nc71mEP+iqdJycWX /YNdRFAGWVolU9/aZzYoYjqYmzSnR2507lAjm5Tuktegwsf9QbygWj8GX2d3fQoAlQYU 8GM1V4LUFgS1F6rEZbXTGfwkAFERMs/tvDHtKAwsQzFBaix6+q81WNPh8kV1WIcNCRFI oq3xlZox82PHzU4Z74dUbxpZDjLpZO7MXrBMFRPE+DrmBEXkH84l5hg6dlV3W157bI/v n88cQWw0orKqrD1PpB8qgEF0BEEM0UnDQJ/cV5Avtt2HV/aM832SSUDmoe7q09dENLGK DtrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679692192; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VR8RhshDCed0TA27KJDGVob/y99IfOhWmfpEH5gIPqc=; b=g6/wXBY6wye1roaoXuf7blIbdH4Oh/jxYvrZZMDbWwiRNqMrWLcrgg4CGUc8QTDoBE EYe3N5wbjDov5IenZmEZl4W8ld03wLVNcvrNEXJYBeF/AWpQcj7jgEQqYhPG4qgLpHUY UtqjkPpZuNKPGUihmxDc/v+D/UgP2MQWpsnn221+T3tqrxKVoPSqKNjafzPZeG+Zn6Qp SHoagw5vCjQqiMEzVBLN84cXm83oZHcsMlj9YUTG+KrToI8d1fxnkiQ5UJwYYsWKBajs ZhtNcLoIJvcLKCTue4ikFdy3tzO7tt8qFOJF5KbRAqQzYMTZh44Ehb6p9uahkh0a1ced P/iw== X-Gm-Message-State: AAQBX9fRLeso9SwxDMVY4o6RqB11rmGF4MNnFTMGK+5sghA0Se27Q8qF TT7CvRgxPmnGnSJG89V7q+RIRIHRN1Mm0mw9lBVhkA== X-Received: by 2002:ac2:5699:0:b0:4e8:3bac:4e32 with SMTP id 25-20020ac25699000000b004e83bac4e32mr1105657lfr.53.1679692192303; Fri, 24 Mar 2023 14:09:52 -0700 (PDT) Received: from localhost (host-97-187.parnet.fi. [77.234.97.187]) by smtp.gmail.com with ESMTPSA id d23-20020ac24c97000000b004d61af6771dsm3524004lfl.41.2023.03.24.14.09.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 24 Mar 2023 14:09:51 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 24 Mar 2023 23:09:51 +0200 Message-Id: <20230324210951.47779-1-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: huZgmr4TdGOU When scanning through the index, account for the fact that the compared samples may be located in an unexpected order in the file; this function is mainly interested in the absolute difference between file locations. Signed-off-by: Martin Storsjö --- libavformat/seek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/seek.c b/libavformat/seek.c index 818549dfef..62a26d6b5f 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -210,7 +210,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q); if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance) continue; - pos_delta = FFMAX(pos_delta, e1->pos - e2->pos); + pos_delta = FFMAX(pos_delta, llabs(e1->pos - e2->pos)); break; } }