From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 577C64B7E6 for ; Fri, 14 Jun 2024 09:39:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2706A68D618; Fri, 14 Jun 2024 12:39:16 +0300 (EEST) 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 39B0668C79B for ; Fri, 14 Jun 2024 12:39:09 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; t=1718357946; cv=none; d=zohomail.eu; s=zohoarc; b=UVxG3ODjuiHK4lXKAbxlQPNdpn6oKEJBQjd5Rchda4Xbewp9GlR61GXB8R2jK82eSo/nVmEm/b6kDbd9DxISX4TNrQtyzhOWCgHzDdhcGlir3PhYVczueBe2DShonjN7gAy9VDSnc7o/FFpwj0Hhqs0qbrABQcjeEsjI6UffUHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1718357946; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=Von15Vmpj4dFLPsfOwfusg1KPLhW4XT/a5siCaw1OIU=; b=cN0LpYhzmIxAOwUzBLU6S5tPzSzWsqDqujrNuaq+afbYooGnmYLrMiJQo0yWj58nxKYQeL4Mu4oc13riowuBw91X0G4/6/MqYcydkBOLzT1luOeHeVLV2JctEUfIBe0UfhtsZJlCB86BAILT180o8mXaESvSNnvzHbplKYMJsnE= 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=1718357946; 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=Von15Vmpj4dFLPsfOwfusg1KPLhW4XT/a5siCaw1OIU=; b=IM7Hi1y5SwnF9rkogMsmA6ndsANDa5gmWxAu8+hN3qWTdMPRJHpupTwYXs52nSJ0 UknP28tdADkKOYE1Qs3d7hOCJS+Kb9gvcqk2wLAPAczBKMlCY4/BrqRzl0K2YQahsyG Dx6u+pkwT7VZYsg30hknMigInqbCQrSzN0nWwS88= Received: by mx.zoho.eu with SMTPS id 1718357945863933.8331087821938; Fri, 14 Jun 2024 11:39:05 +0200 (CEST) From: Frank Plowman To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jun 2024 10:37:17 +0100 Message-ID: <20240614093903.98716-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: Invalidate PPSs which refer to a changed SPS 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: When the SPS associated with a particular SPS ID changes, invalidate all the PPSs which use that SPS ID. Fixes crashes with illegal bitstreams. This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS ID reuse validation, as parts of the CBS parsing process for PPSs depend on the SPS being referred to. Signed-off-by: Frank Plowman --- libavcodec/cbs_h2645.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index c5f167334d..e2389f124e 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -789,9 +789,28 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ } cbs_h266_replace_ps(6, VPS, vps, vps_video_parameter_set_id) -cbs_h266_replace_ps(6, SPS, sps, sps_seq_parameter_set_id) cbs_h266_replace_ps(6, PPS, pps, pps_pic_parameter_set_id) +static int cbs_h266_replace_sps(CodedBitstreamContext *ctx, + CodedBitstreamUnit *unit) +{ + CodedBitstreamH266Context *priv = ctx->priv_data; + H266RawSPS *sps = unit->content; + unsigned int id = sps->sps_seq_parameter_set_id; + int err = ff_cbs_make_unit_refcounted(ctx, unit); + if (err < 0) + return err; + av_assert0(unit->content_ref); + if (priv->sps[id] && memcmp(priv->sps[id], unit->content_ref, sizeof(*priv->sps[id]))) { + for (unsigned int i = 0; i < VVC_MAX_PPS_COUNT; i++) { + if (priv->pps[i] && priv->pps[i]->pps_seq_parameter_set_id == id) + ff_refstruct_unref(&priv->pps[i]); + } + } + ff_refstruct_replace(&priv->sps[id], unit->content_ref); + return 0; +} + static int cbs_h266_replace_ph(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, H266RawPictureHeader *ph) -- 2.45.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".