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 4493C4B4BB for ; Fri, 7 Jun 2024 13:09:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F5BB68D85F; Fri, 7 Jun 2024 16:04:33 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DECC068D7E2 for ; Fri, 7 Jun 2024 16:03:49 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=O0mgI8cE; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id BBE314DAA for ; Fri, 7 Jun 2024 15:03:45 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id HAXoNJfs79Dc for ; Fri, 7 Jun 2024 15:03:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765421; bh=qpsYBqlRIp9agn2cP9qXR2JAoQowBdtzVvtmW+N3V/s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O0mgI8cEkWTi+rXyZKKCxBDlUeRWHQ4Cg1kk7vHzybJbFaGBtEr7wLvLJkwqKYq8M /fg3cfApVp7Nt4x4Au/r3RKcT18joB41MDYuRwvkRcLxdNxf7bt/9w7xzp1XDIJCw4 WJgiYU4Wdg2rJhFyLuapOT7MBSk183XoZmsRRyxiQQH6mIi9YJKD4r0teWtplnjZAI +MGzUHvxrE5Gr8H+aDtI7m5s/UFog8Glsmu5zE5Y10hXCrTUFuNWzOn4qmjgOfutsI 3e5miszZqT+ViM2BgyysZbh/7llDyNqn5CQvgqprBT6kItA48S4tR+gCj/AWiyeE/i PvRBWk1B4IeTw== 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 mail1.khirnov.net (Postfix) with ESMTPS id 9C4AA4DE3 for ; Fri, 7 Jun 2024 15:03:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7EA0A3A071E for ; Fri, 07 Jun 2024 15:03:34 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 15:01:01 +0200 Message-ID: <20240607130135.9088-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607130135.9088-1-anton@khirnov.net> References: <20240607130135.9088-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/39] lavc/hevc_ps: make SPS hold a reference to its VPS 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 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: SPS and its dependent PPSes depend on, and are parsed for, specific VPS data. This will be useful in following commits. --- libavcodec/hevc/hevcdec.c | 5 ++--- libavcodec/hevc/parser.c | 2 +- libavcodec/hevc/ps.c | 13 +++++++++---- libavcodec/hevc/ps.h | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index ae4a5888e5..16c46997a8 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -319,8 +319,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) static void export_stream_params(HEVCContext *s, const HEVCSPS *sps) { AVCodecContext *avctx = s->avctx; - const HEVCParamSets *ps = &s->ps; - const HEVCVPS *vps = ps->vps_list[sps->vps_id]; + const HEVCVPS *vps = sps->vps; const HEVCWindow *ow = &sps->output_window; unsigned int num = 0, den = 0; @@ -575,7 +574,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, } s->ps.sps = sps; - s->ps.vps = s->ps.vps_list[s->ps.sps->vps_id]; + s->ps.vps = sps->vps; return 0; diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c index d0d5e7fbc2..49f7bccdfa 100644 --- a/libavcodec/hevc/parser.c +++ b/libavcodec/hevc/parser.c @@ -82,7 +82,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, if (ps->sps != ps->pps->sps) { ps->sps = ps->pps->sps; - ps->vps = ps->vps_list[ps->sps->vps_id]; + ps->vps = ps->sps->vps; } ow = &ps->sps->output_window; diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c index 98217e337b..eabed69b94 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -889,10 +889,13 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->vps_id = get_bits(gb, 4); - if (vps_list && !vps_list[sps->vps_id]) { - av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n", - sps->vps_id); - return AVERROR_INVALIDDATA; + if (vps_list) { + if (!vps_list[sps->vps_id]) { + av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n", + sps->vps_id); + return AVERROR_INVALIDDATA; + } + sps->vps = ff_refstruct_ref_c(vps_list[sps->vps_id]); } sps->max_sub_layers = get_bits(gb, 3) + 1; @@ -1298,6 +1301,8 @@ static void hevc_sps_free(FFRefStructOpaque opaque, void *obj) { HEVCSPS *sps = obj; + ff_refstruct_unref(&sps->vps); + av_freep(&sps->data); } diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h index 7c9aacf057..fc10876756 100644 --- a/libavcodec/hevc/ps.h +++ b/libavcodec/hevc/ps.h @@ -302,6 +302,8 @@ typedef struct HEVCSPS { uint8_t *data; int data_size; + + const HEVCVPS *vps; ///< RefStruct reference } HEVCSPS; typedef struct HEVCPPS { -- 2.43.0 _______________________________________________ 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".