From patchwork Fri Sep 13 06:34:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 51564 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2986:b0:48e:c0f8:d0de with SMTP id ih6csp101074vqb; Thu, 12 Sep 2024 23:44:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHodNaBHqKd6ws6+a4R1Y/t44+sj5ymVNUEwtMcj8LEtuLGbIJlPPOf5cI3RYsv54yO4YxWduI70o/klf6CYQw@gmail.com X-Google-Smtp-Source: AGHT+IHP0juZaZ54TiLnZd6E6F9cH5q7Acg06O5+QadPl0i9uZPou/fYK8Ki4NDacfUmRdONBB8a X-Received: by 2002:a17:906:c104:b0:a8d:1545:f48a with SMTP id a640c23a62f3a-a90480d1ad7mr114541466b.61.1726209850608; Thu, 12 Sep 2024 23:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726209850; cv=none; d=google.com; s=arc-20240605; b=YV9uYFE/EVxzUxZIUF/48+vzSZ7oMGWErtT3I5chek1PgsKEI1C8iegrU4mXOMDoOU uI9WQ/9GzVCcGvbpwz3MrFaPgFirHMNcUjOPPR6VcUZyoINwHt2ESAB5m6/7SQSjbUGk aUlK2NcU5IrT21K/N464BNnMzGOpE8QYO0UpLqP1kQJ6rFMVeLCdGAkUHFTJ2OFhTx4w bnBcL/dVprr3XKNjJYbuxOrJHravLbTIKUT5gkdWRLXZ4C5ekq3F1cENjptjNACFars1 ZZNbCuIwVBtWonbzSFcqiyR/oNM1MBCSQUz3F9/8MH2yqCAVK8kO4UhOdj7Mqb6EVNMC rFhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:date :to:from:message-id:dkim-signature:delivered-to; bh=gQWU5EheUdQKVFwZXGLuvhZ8S6os6UkO/Ogsg84S+Nw=; fh=HnHYuZ9XgUo86ZRXTLWWmQxhslYEI9B9taZ5X1DLFfc=; b=TsFLtWHm+zMUsNPDGIv0fpSMKpJYA06UVRMmaytNsSxHB9dkCVVwuJdXd2klPewS8V jFoTWCy81A/z1/aK/CgfbWD+eOygIrQmB4trA8JT2ld8u9km+k2GQXzOoMMi4SSYYtrV /aCG8fwd1J8lQJlyxuDDF6FvZP+1UMeeO3frnqheZAjbrAO4zDms7pKQEH0OF6MpWCEy bKwGh7XJe9kP2f5EfP3rmWDn9NC6C9XkLTWfZUhN1+WWYFIAQBypEYWDiyyoBSuObSKd VwgdOB89cSOuGQX9hMCQKK36OVC0lus/T0uA6iG5gvykbHwB1lEHYOHGIQ3iYj8wLtTk iGbA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b="f3y/hSDs"; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a8d25d5d36esi987102966b.798.2024.09.12.23.44.10; Thu, 12 Sep 2024 23:44:10 -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=@foxmail.com header.s=s201512 header.b="f3y/hSDs"; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3081868DD1C; Fri, 13 Sep 2024 09:35:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-58-216.mail.qq.com (out162-62-58-216.mail.qq.com [162.62.58.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F7DC68DCCE for ; Fri, 13 Sep 2024 09:34:51 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1726209282; bh=Ae0Fj6ioQd5kvHt0eG5qDvUl/fii7fGbQ2c2ht4vhB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f3y/hSDsCBovn94lTbGEJen/APquhdynNJytVMa+x3x+ehvZA0J05LBacvLMsUQZX vflRp0q5DvCiLZJ0BLfN1/yRbTlzaWwCYYfWxG7MZ+3byFqt2VEI0e4/v9vBn6wcps BQLaUlPg1kuhHQsbALhOZuGvt8OAMENnAZhcRXWA= Received: from ZHILIZHAO-MB1.tencent.com ([119.147.10.185]) by newxmesmtplogicsvrszc13-0.qq.com (NewEsmtp) with SMTP id 8A98841D; Fri, 13 Sep 2024 14:34:41 +0800 X-QQ-mid: xmsmtpt1726209281tuo50lq4f Message-ID: X-QQ-XMAILINFO: NuBH63TBO+hCDWPm/G8+miwUX4qj5C9ip19zHsYaeY9JG05CKVNNCzTpDgWR6o fg1v4Y7oHVLxlzVFskger6Fz+Qqet6qsl4bNNKF7YqAT90bdBCmynXxeZgLbxNc9lj/+0fTkFd17 90mK1xJqNQYLY0huOOpX5Hf8LBrimDB6s+Geu7EJtuvnVPZDNTQykAPU4xKhMRqxHZopSKq3eivN yKVZnTeCBqjU8ry3t3l1FyPrLZK8kq3J9gCze4Wh8vU8OwDihfVu/8bkZzRQRjAirfJD/gTqjtQ+ zrWKXQ/8Lq8z27KzOYdcAbJLkJVJX2JoD4sG2OfjBk4T+C22UgoLK0NTV0wL3bff9fAiqmCjl/Mx 3pAjmWevD2EQjMMwAEeVAF21e36H/RB728tHj3N9PoXfZdtB9894YtjPbKG7tEhsFPS9I2p5WzT8 53RaUMmKC8AWXRAa4K9wQC70VByVylMDuxezSgLeojNBZx4vEyzVNSNCGT8BrjnZQC8vgLQYxki+ 8YacoY39ZCsAa5plHdRp5fhnwKJL/m0mzrq1UeBqxqhCZUDfm3p/dRHKATTgxtQjfiUs2Z07cUAi veRPIpW3Z62oLTt6N634JjK/H/SgQFlOcZCjD49NKVy4nOpfz2s+U4uKWffXRzme7ObdR2553Quj EUb8PhTAQ6bHs1Lo05oBkpNptlNxR7bmDwVCGczlHAYOf5ekG4TGwkhVR2UwZLxO28c/Hrldl+JL kIvMEiGRfnbWv09o1nNIe4hcJoZAJnVuqXrMAJNC8kmy+VgppYfNEAXGH/WgsB+3pR10pSe3E4VP /LyshnZOgNyXZTOR2waz6DNWC0/ykEIfDIibUuYXalL/NJTcgkpUupY/g2NE2lfcj/yawoGTVypZ 4F7vr/3J48oWFFigIRSlYFmD4+v27qRsb8fY43xoUaVgAwz+U5LhLVJGQVqahVCNx3H4+XdW2mzw mUFUc8sIz0KK2E79G4CNTibrb/LtDebWNu7rNloshZL7EKqUgM+Huckm7GdvHXy2x1KiZPi9xvYW kFPE6XLy3l2KaGhZnynAHGORj5rAoisGc4fxr0P/lk8UMYf6JCvXcjq+dF5KcXJ9UHA/tu5Ca7JR u5kvYiE33paKCSSy4= X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 13 Sep 2024 14:34:39 +0800 X-OQ-MSGID: <20240913063439.94116-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/vvc: Fix output and unref a frame which isn't decoding yet 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gTq9MWiVSc8G From: Zhao Zhili ff_vvc_output_frame is called before actually decoding. It's possible for ff_vvc_output_frame to select current frame to output. If current frame is nonref frame, it will be released by ff_vvc_unref_frame. Fix this by always marking the current frame with VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC decoder. --- fate sample: https://drive.google.com/file/d/1U5WGWeSsMFiEkhsl_vL4NiMma-LLh02t/view?usp=drive_link md5sum: 8054b4b8e62c0171476b40206d044590 Hierarchical.bit libavcodec/vvc/refs.c | 5 +-- tests/fate/vvc.mak | 1 + tests/ref/fate/vvc-conformance-Hierarchical | 35 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/ref/fate/vvc-conformance-Hierarchical diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c index bebcef7fd6..d5aa2ff28d 100644 --- a/libavcodec/vvc/refs.c +++ b/libavcodec/vvc/refs.c @@ -193,10 +193,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame) if (s->no_output_before_recovery_flag && (IS_RASL(s) || !GDR_IS_RECOVERED(s))) ref->flags = VVC_FRAME_FLAG_SHORT_REF; else if (ph->r->ph_pic_output_flag) - ref->flags = VVC_FRAME_FLAG_OUTPUT; - - if (!ph->r->ph_non_ref_pic_flag) - ref->flags |= VVC_FRAME_FLAG_SHORT_REF; + ref->flags = VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_SHORT_REF; ref->poc = poc; ref->sequence = s->seq_decode; diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak index 5335460263..7fd0a47214 100644 --- a/tests/fate/vvc.mak +++ b/tests/fate/vvc.mak @@ -1,5 +1,6 @@ VVC_SAMPLES_8BIT = \ CodingToolsSets_A_2 \ + Hierarchical \ VVC_SAMPLES_10BIT = \ APSALF_A_2 \ diff --git a/tests/ref/fate/vvc-conformance-Hierarchical b/tests/ref/fate/vvc-conformance-Hierarchical new file mode 100644 index 0000000000..0797305b9a --- /dev/null +++ b/tests/ref/fate/vvc-conformance-Hierarchical @@ -0,0 +1,35 @@ +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 480x320 +#sar 0: 0/1 +0, 0, 0, 1, 230400, 0x3293f7f1 +0, 1, 1, 1, 230400, 0xe2570fa4 +0, 2, 2, 1, 230400, 0xecd608fb +0, 3, 3, 1, 230400, 0xea46f9f4 +0, 4, 4, 1, 230400, 0xb715d24a +0, 5, 5, 1, 230400, 0x69faaf46 +0, 6, 6, 1, 230400, 0xf9a362db +0, 7, 7, 1, 230400, 0x2dcd19ca +0, 8, 8, 1, 230400, 0xf8fda185 +0, 9, 9, 1, 230400, 0x48a35bfd +0, 10, 10, 1, 230400, 0x27efe832 +0, 11, 11, 1, 230400, 0x74279617 +0, 12, 12, 1, 230400, 0x91935248 +0, 13, 13, 1, 230400, 0x29b621e6 +0, 14, 14, 1, 230400, 0x89b1ec0b +0, 15, 15, 1, 230400, 0x898fdba1 +0, 16, 16, 1, 230400, 0xc6d18e6f +0, 17, 17, 1, 230400, 0xedff651b +0, 18, 18, 1, 230400, 0x677e2260 +0, 19, 19, 1, 230400, 0x930918ef +0, 20, 20, 1, 230400, 0x70da2c30 +0, 21, 21, 1, 230400, 0x699a3b9d +0, 22, 22, 1, 230400, 0xff3b1b3a +0, 23, 23, 1, 230400, 0xca11d9a5 +0, 24, 24, 1, 230400, 0x904394e0 +0, 25, 25, 1, 230400, 0x392e5445 +0, 26, 26, 1, 230400, 0x6191f4d8 +0, 27, 27, 1, 230400, 0xa7d7be12 +0, 28, 28, 1, 230400, 0xbb29752c +0, 29, 29, 1, 230400, 0x14ff297e