From patchwork Sat Feb 17 14:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Plowman X-Patchwork-Id: 46304 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp334570pzb; Sat, 17 Feb 2024 06:48:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUgV5X6zLxdHFEu4atmdevC/XaK+gJLyqkCo1yaluR2OV/gsCul2mOv7o84tzXuSwBkM0y+qzZqRseAT21pZwejqzRMtWKWskPJwQ== X-Google-Smtp-Source: AGHT+IEPDds/Fmy0zkCG+au9bdMXV1q2kW42WpSq8sa2qg+HnoLoXqchO2yJxSGypJsGCk811/p2 X-Received: by 2002:ac2:446e:0:b0:512:9e54:da7a with SMTP id y14-20020ac2446e000000b005129e54da7amr1710934lfl.9.1708181310630; Sat, 17 Feb 2024 06:48:30 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o10-20020a056402038a00b005643f11223dsi87519edv.435.2024.02.17.06.48.30; Sat, 17 Feb 2024 06:48:30 -0800 (PST) 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=E1gaUDb8; 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 6588868D2B0; Sat, 17 Feb 2024 16:48:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender-op-o14.zoho.eu (sender-op-o14.zoho.eu [136.143.169.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF4FF68D21A for ; Sat, 17 Feb 2024 16:48:19 +0200 (EET) Delivered-To: post@frankplowman.com ARC-Seal: i=1; a=rsa-sha256; t=1708181296; cv=none; d=zohomail.eu; s=zohoarc; b=OWoAB4GKzqJxhe5EqFNVzqed+8vRHUdYD1frL3hWzIdGClxpoOoueIMgOykQ5VT9VHjwMwf7x+gir7bTRI1YtNCkXP5bu66JzKkmzJ5iBzYSY6BMmrVyO86eYilLO2RuiIcj/QWs1XOVdr5oVQD+jXEPlOJ1GjObIBrcW63Zn4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1708181296; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=lSn2hGEC+wPMpWVXsxPIjqX2I5/tgMI0qEfMifkoaOY=; b=hm5dFVi3QNZBgUglN9IfDId9/eRgdoPYK86lz8iygHcdwCnBYCi0+V6mMtW5iFTLvntj6AzM92176oV9h8c/jiOGgDWp6cDeY0wDwc4iLLzuKEoxTiThl/uGZAvqvUYFO2Q4EbSszRMOU4HlW5a1q+85jkEOBN+fXpEZK7Yj63I= 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=1708181296; 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=lSn2hGEC+wPMpWVXsxPIjqX2I5/tgMI0qEfMifkoaOY=; b=E1gaUDb8h+gBqQ1bsAgqrz3K7omvD2GdbPuFy328Xz0DXcKRvxwbHN2bRYEda1ej 8RkdNTdrP7kpOCeKVm823EJkVf8To9frX4vqStIU0BO/IZoBMkK50ZRfER0VO2bNlva bK3oXCofgHZ1LJ4/wL7WTs/EYkA1uhFBDvc3q6M0= Received: from localhost.localdomain (frankplowman.com [51.89.148.29]) by mx.zoho.eu with SMTPS id 1708181295555805.3050330299664; Sat, 17 Feb 2024 15:48:15 +0100 (CET) From: Frank Plowman To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Feb 2024 14:48:10 +0000 Message-ID: <20240217144810.10604-1-post@frankplowman.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-ZohoMailClient: External Subject: [FFmpeg-devel] [PATCH] lavc/vvc: Fail inter prediction if using IBC 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: qncErOMklrb6 IBC is not yet implemented. Fail the inter prediction process with AVERROR_PATCHWELCOME if the bitstream uses IBC. Fixes crashes due to out-of-bounds reads when attempting to decode IBC bitstreams. Signed-off-by: Frank Plowman --- libavcodec/vvc/vvc_inter.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libavcodec/vvc/vvc_inter.c b/libavcodec/vvc/vvc_inter.c index e05f3db93e..cb5e8d4ef6 100644 --- a/libavcodec/vvc/vvc_inter.c +++ b/libavcodec/vvc/vvc_inter.c @@ -779,7 +779,7 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int } } -static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) +static int pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) { const VVCFrameContext *fc = lc->fc; const CodingUnit *cu = lc->cu; @@ -789,7 +789,7 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) int sbw, sbh, sb_bdof_flag = 0; if (cu->ciip_flag && skip_ciip) - return; + return 0; sbw = cu->cb_width / mi->num_sb_x; sbh = cu->cb_height / mi->num_sb_y; @@ -803,11 +803,17 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh); derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh); + if (mv.pred_flag == PF_INTRA) { + avpriv_report_missing_feature(fc->log_ctx, "Intra Block Copy"); + return AVERROR_PATCHWELCOME; + } pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, &mv, x0, y0, sbw, sbh, &orig_mv, sb_bdof_flag); if (fc->ps.sps->r->sps_chroma_format_idc) pred_regular_chroma(lc, &mv, x0, y0, sbw, sbh, &orig_mv, pu->dmvr_flag); } } + + return 0; } static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv, @@ -872,23 +878,29 @@ static void pred_affine_blk(VVCLocalContext *lc) } } -static void predict_inter(VVCLocalContext *lc) +static int predict_inter(VVCLocalContext *lc) { const VVCFrameContext *fc = lc->fc; const CodingUnit *cu = lc->cu; const PredictionUnit *pu = &cu->pu; + int ret; if (pu->merge_gpm_flag) pred_gpm_blk(lc); else if (pu->inter_affine_flag) pred_affine_blk(lc); - else - pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip + else { + ret = pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip + if (ret < 0) + return ret; + } if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) { uint8_t* dst0 = POS(0, cu->x0, cu->y0); fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, fc->ps.lmcs.fwd_lut); } + + return 0; } static int has_inter_luma(const CodingUnit *cu) @@ -901,11 +913,15 @@ int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs) const VVCFrameContext *fc = lc->fc; const CTU *ctu = fc->tab.ctus + rs; CodingUnit *cu = ctu->cus; + int ret; while (cu) { lc->cu = cu; - if (has_inter_luma(cu)) - predict_inter(lc); + if (has_inter_luma(cu)) { + ret = predict_inter(lc); + if (ret < 0) + return ret; + } cu = cu->next; }