From patchwork Mon Jun 24 15:30:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Plowman X-Patchwork-Id: 50129 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp2087570vqz; Mon, 24 Jun 2024 08:30:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2OoHfxMiv63ZKmsoFQ5yVYs+nbSYOFtQtkZK88pJfDNJth3CF9M2M33Evsio96egadzY5hTFEmjoJ3T2i1AlPEAy/rmctzwsHAA== X-Google-Smtp-Source: AGHT+IHz8cr2jsnig8k+kI6CwY7USRiJnwNN/o3Kp6ewQZ6JmguoUvWGboR2I5vghlvgs1WQB8lE X-Received: by 2002:a50:9f8d:0:b0:57d:1627:93ed with SMTP id 4fb4d7f45d1cf-57d457a1540mr3881058a12.22.1719243037808; Mon, 24 Jun 2024 08:30:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57d30af4857si3779624a12.518.2024.06.24.08.30.37; Mon, 24 Jun 2024 08:30:37 -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=@frankplowman.com header.s=zmail header.b=HQMUZeir; arc=fail (body hash mismatch); 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 1E42968D5B7; Mon, 24 Jun 2024 18:30:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender-op-o11.zoho.eu (sender-op-o11.zoho.eu [136.143.169.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D195468D4EF for ; Mon, 24 Jun 2024 18:30:27 +0300 (EEST) Delivered-To: post@frankplowman.com ARC-Seal: i=1; a=rsa-sha256; t=1719243025; cv=none; d=zohomail.eu; s=zohoarc; b=UerkiEDP/oKVztM8rbWaouNoaZtqH0YizCnXgQxIKVK/78ZW0lCeAGKj25FyD+GVzrvBrnCc+/QmLdwbD2AXALp8m1QztEsnBiI0lKYWScbaqMQi4BluE0xVpS9xMgXOFvD5yFayK4Gyv+Wp6AvCDFf6B4z/qQBNWA72Ip9deh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1719243025; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=T+AP2LcqghnU4x0Rg/2vydZXqtBOMDr12eNniQUM/UQ=; b=kNqVK/aGp42E0DhygPcDnepJpWoD1Nx8mSgiGhghXGLPfiZIau/GdvT5x7hWjUqIGpmN2V6PUovYSaC+Ie8NbDpI4fuhKwq5rRgWud+jEhzyA91CvOIKyGSIIIB2sKktz9ul0xJo3xXvvOrtCg8eRKxMygQUajFNzRryHW9Fjeg= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=frankplowman.com; spf=pass smtp.mailfrom=post@frankplowman.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1719243025; s=zmail; d=frankplowman.com; i=post@frankplowman.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=T+AP2LcqghnU4x0Rg/2vydZXqtBOMDr12eNniQUM/UQ=; b=HQMUZeir0uSb9KQavvzUC3q0iTvkWx+enpg86VpnxGCZuhvjDU4E0wBjGr0JdOuQ N24p7zTZp8/zgUwRNOZbfazograDyhfS3zQA3SEPFyYB4LWq1OlRx3QPihKrjlGgPkT GafDvQN/6FjiaaSE9tQNRnt6koplHRIAJNGJzJ0c= Received: by mx.zoho.eu with SMTPS id 1719243023794540.8217121766146; Mon, 24 Jun 2024 17:30:23 +0200 (CEST) From: Frank Plowman To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jun 2024 16:30:17 +0100 Message-ID: <20240624153021.16399-1-post@frankplowman.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-ZohoMailClient: External Subject: [FFmpeg-devel] [PATCH] lavc/vvc: Always set flags for the current picture 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: Frank Plowman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: HSl4mSo9KXcj ff_vvc_frame_rpl uses the flags to detect whether a frame is in use. Therefore, in the case of a CVSS AU (RASL/GDR with NoOutputBeforeRecoveryFlag) with ph_non_ref_pic_flag = 1, the frame would be freed before it is used. Fix this by always marking the current frame with VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC decoder. Additionally, add an assert0 to mitigate the effects of a frame being freed before it is used. Signed-off-by: Frank Plowman --- libavcodec/vvc/refs.c | 2 +- libavcodec/vvc/thread.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c index 8b7ba639a3..26a5b0b34c 100644 --- a/libavcodec/vvc/refs.c +++ b/libavcodec/vvc/refs.c @@ -191,7 +191,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame) fc->ref = ref; if (s->no_output_before_recovery_flag && (IS_RASL(s) || !GDR_IS_RECOVERED(s))) - ref->flags = 0; + ref->flags = VVC_FRAME_FLAG_SHORT_REF; else if (ph->r->ph_pic_output_flag) ref->flags = VVC_FRAME_FLAG_OUTPUT; diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c index 5b01dd2d20..e87ed5b676 100644 --- a/libavcodec/vvc/thread.c +++ b/libavcodec/vvc/thread.c @@ -801,6 +801,8 @@ int ff_vvc_frame_wait(VVCContext *s, VVCFrameContext *fc) { VVCFrameThread *ft = fc->ft; + av_assert0(fc->ref->progress); + ff_mutex_lock(&ft->lock); while (atomic_load(&ft->nb_scheduled_tasks) || atomic_load(&ft->nb_scheduled_listeners))