From patchwork Tue May 23 13:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41807 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp602532pzb; Tue, 23 May 2023 07:01:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KsV94O57c5JU/fdQH6kGRNFE5ptI9HTM5VXnaGdqGfUfJCvwkkDdkutMpWbZUE7e4MvfP X-Received: by 2002:a17:907:9807:b0:96f:e7cf:501b with SMTP id ji7-20020a170907980700b0096fe7cf501bmr6886354ejc.33.1684850514120; Tue, 23 May 2023 07:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850514; cv=none; d=google.com; s=arc-20160816; b=wcMFNoarjEzBLNL08tyyvEcG9r627aQa2ZER3iOUros5XPfO11s5+oqchfztrwEh1/ lPJbQZNBUWkH9PVtmxPgsYy15wSZ1dUWvqeLRjWY750RhukPs10gx8iHp8NKvvWU3ecr CthKUKLFP7e9vihbwXT7TEedUVMAMdS71QORp5JMgIkzfxh0l0wH8AbqJxovkRDkA1TI iHcyLQeKgByFoVh55r7StlkRftJ4rF4RjzO9cibDX9by0uZwnLVLsxREA5vqMTccAmWo gIkmQtJ8PqhOsehAwMR0QhUlxBc5UobZGHdRSe/jpYbkmb3a59svhEeSTUstofCK0XZB YSiA== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=bA2J/kwTw6KC4SqshPwkqfxWClvEuXznzpuyP/FmiXQ=; b=OMJB92brWPKGOjTdR6xVxwit/lgFMwsRz6n8qJGymeyEpTIfLtn4cnbB4dY5HDQeTw HDqlvYEvTswT6Wn8woHqDBCypRYRFVh7tARcWliZT75CqBgGjCKBxi2ASLbGLDrYzIGZ +1Vg1xAR9nriVvnaqKJleVCv11AIQpLbLPqsdh0Cn47gZOdcS05XlCyc6RHb/NYuHubQ TBJbZySKYD8vrt7UN0ThSJtA6I7ZPWQJsJ4yGsqrMfheFdKHeZZCJhasz3qNCQpi84sN 3ukDAHwfrPGo7JekXL2aJ9h7f9QayhxNQwS9E9nti8d8MIXX8pPL0RBy2P97GEylGLjX rLOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s8-20020a1709067b8800b00965a20908edsi103255ejo.422.2023.05.23.07.01.48; Tue, 23 May 2023 07:01:54 -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; 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 156D568C179; Tue, 23 May 2023 16:59:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 195FE68C11B for ; Tue, 23 May 2023 16:59:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7EA1B2406CE for ; Tue, 23 May 2023 15:59:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MD9mX2UQUW1u for ; Tue, 23 May 2023 15:59:02 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CB0AA2406CF for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BD6743A031B for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 May 2023 15:58:42 +0200 Message-Id: <20230523135842.20388-15-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523135842.20388-1-anton@khirnov.net> References: <20230523135842.20388-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/15] fftools/sync_queue: make sure non-limiting streams are not used as queue head 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: 486NIMIumoPT A non-limiting stream could mistakenly end up being the queue head, which would then produce incorrect synchronization, seen e.g. in fate-matroska-flac-extradata-update for certain number of frame threads (e.g. 5). Found-By: James Almer --- fftools/sync_queue.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fftools/sync_queue.c b/fftools/sync_queue.c index c0f33e9235..bc107ba4fe 100644 --- a/fftools/sync_queue.c +++ b/fftools/sync_queue.c @@ -217,17 +217,26 @@ static void finish_stream(SyncQueue *sq, unsigned int stream_idx) static void queue_head_update(SyncQueue *sq) { + av_assert0(sq->have_limiting); + if (sq->head_stream < 0) { + unsigned first_limiting = UINT_MAX; + /* wait for one timestamp in each stream before determining * the queue head */ for (unsigned int i = 0; i < sq->nb_streams; i++) { SyncQueueStream *st = &sq->streams[i]; - if (st->limiting && st->head_ts == AV_NOPTS_VALUE) + if (!st->limiting) + continue; + if (st->head_ts == AV_NOPTS_VALUE) return; + if (first_limiting == UINT_MAX) + first_limiting = i; } // placeholder value, correct one will be found below - sq->head_stream = 0; + av_assert0(first_limiting < UINT_MAX); + sq->head_stream = first_limiting; } for (unsigned int i = 0; i < sq->nb_streams; i++) {