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 5DB1F46987 for ; Thu, 29 Jun 2023 21:58:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A66E68C2E0; Fri, 30 Jun 2023 00:58:45 +0300 (EEST) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 83D7D689D6F for ; Fri, 30 Jun 2023 00:58:39 +0300 (EEST) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3a36b30aa7bso855841b6e.3 for ; Thu, 29 Jun 2023 14:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688075917; x=1690667917; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+7kuv6Eencpp02f3ku+v7rN1QWXgwnICWZPFW2L4wvk=; b=piLTUKvHgXMml23egUq0K27KBdTPoJBuzVkHAw3RdCSyOyHJpG2R+pAcIgLh1kvblr PzjoKVv3qvWHLrd2nV3DHKMuApRA7SLqyrMI8mzlb5JQljhlqJoCkSbZcOQU9dy/OQe2 dT1EVFp0flrtrAqyAZdlP4TEyFqQKT6rw7JW/PQPKvafPHr6boVl2ccWsieC98yXn5Dq Bwv+N8BkrmpAVt6Gi0py6wxW5hGS4zOkbL8jX0PxwMsVtCKonXz4a1uH4uKvRIZuscrQ nmoRgw66rUK0nVMyg2uVl2cYGYiYHzjoVDCjDduKVnMaqVzGzmBmhgNn4bD3Go/NHCew eMZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688075917; x=1690667917; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+7kuv6Eencpp02f3ku+v7rN1QWXgwnICWZPFW2L4wvk=; b=I2HF51/flejRWD2CrU8y17Ws/ViSpuqkyzHpUuPqx6dpkNg219qVwLZSOBrmyuejgX OGPZi00J6LeESwLQKgKSVOat3+FVMOt70YsAmdM0SyekO8VU9HXDzTEZ4nF9e2ETQRXO juxBafYvJCHGElp+brE/KbaVpNuXZUqIBGmMZefT3/RakWIS1MO0LGMPjz3Mou4lk8BA JvyvM4optz3hK+t3yvTR7TF7F7I3zseiYyxuGlfL+GJ05ocoA39r8pmslfrM60ZVzYJj S5hCl8uOKLjkxNg9pgTlSKBQfwFstnpITtKn2B0VA/tOXpWkcZin5IHj4+yr92lmnVSA FWIA== X-Gm-Message-State: AC+VfDwfcrC0POnMxHctKvnmHi/J6eRIbLWxH/MymzUbMwLn9ydn8q2r d12utZ0OoEBUWrDs4TBshbWoDXnPBk8= X-Google-Smtp-Source: ACHHUZ4vidvXzzfsHMhhIISnddLPlbTfw9FMhHGxmSIgF9E63CCNIbUn67oV5JXze6KF8elS84Irvg== X-Received: by 2002:a05:6808:d51:b0:3a0:384b:25f0 with SMTP id w17-20020a0568080d5100b003a0384b25f0mr789834oik.27.1688075917434; Thu, 29 Jun 2023 14:58:37 -0700 (PDT) Received: from [192.168.0.12] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id f9-20020a05680814c900b003a37fd2be45sm348653oiw.31.2023.06.29.14.58.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 14:58:37 -0700 (PDT) Message-ID: <6418a52e-b808-0395-34c4-7a01c254abfa@gmail.com> Date: Thu, 29 Jun 2023 18:58:41 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avcodec/vvc_parser: Don't store state unnecessarily 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 6/29/2023 6:53 PM, Andreas Rheinhardt wrote: > VVCParserContext.au_info is only used once (and in a read-only manner); > but this happens immediately after au_info has been completely > overwritten. Therefore one can just the src structure used to overwrite > au_info directly and remove au_info. > > This also means that the whole referencing and unreferncing of au_info > (which duplicates AVBufferRefs CodedBitstreamH266Context and is > therefore of dubious gain) can be removed, as can the AVBufferRef* > contained in PuInfo; this also removes a certain uglyness: Sometimes > these AVBufferRef* were ownership pointers and sometimes not. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/vvc_parser.c | 63 +---------------------------------------- > 1 file changed, 1 insertion(+), 62 deletions(-) > > diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c > index efea833565..69696eef57 100644 > --- a/libavcodec/vvc_parser.c > +++ b/libavcodec/vvc_parser.c > @@ -29,11 +29,6 @@ > #define IS_H266_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= VVC_GDR_NUT)) > > typedef struct PuInfo { > - AVBufferRef *sps_ref; > - AVBufferRef *pps_ref; > - AVBufferRef *slice_ref; > - AVBufferRef *ph_ref; > - > const H266RawPPS *pps; > const H266RawSPS *sps; > const H266RawPH *ph; > @@ -53,7 +48,6 @@ typedef struct VVCParserContext { > > CodedBitstreamFragment picture_unit; > > - PuInfo au_info; > AVPacket au; > AVPacket last_au; > > @@ -150,41 +144,6 @@ static int get_pict_type(const CodedBitstreamFragment *pu) > return has_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; > } > > -static void pu_info_unref(PuInfo *info) > -{ > - av_buffer_unref(&info->slice_ref); > - av_buffer_unref(&info->ph_ref); > - av_buffer_unref(&info->pps_ref); > - av_buffer_unref(&info->sps_ref); > - info->slice = NULL; > - info->ph = NULL; > - info->pps = NULL; > - info->sps = NULL; > - info->pic_type = AV_PICTURE_TYPE_NONE; > -} > - > -static int pu_info_ref(PuInfo *dest, const PuInfo *src) > -{ > - pu_info_unref(dest); > - dest->sps_ref = av_buffer_ref(src->sps_ref); > - dest->pps_ref = av_buffer_ref(src->pps_ref); > - if (src->ph_ref) > - dest->ph_ref = av_buffer_ref(src->ph_ref); > - dest->slice_ref = av_buffer_ref(src->slice_ref); > - if (!dest->sps_ref || !dest->pps_ref || (src->ph_ref && !dest->ph_ref) > - || !dest->slice_ref) { > - pu_info_unref(dest); > - return AVERROR(ENOMEM); > - } > - > - dest->sps = src->sps; > - dest->pps = src->pps; > - dest->ph = src->ph; > - dest->slice = src->slice; > - dest->pic_type = src->pic_type; > - return 0; > -} > - > static void set_parser_ctx(AVCodecParserContext *s, AVCodecContext *avctx, > const PuInfo *pu) > { > @@ -241,20 +200,6 @@ static void set_parser_ctx(AVCodecParserContext *s, AVCodecContext *avctx, > } > } > > -static int set_ctx(AVCodecParserContext *s, AVCodecContext *avctx, > - const PuInfo *next_pu) > -{ > - VVCParserContext *ctx = s->priv_data; > - > - int ret = pu_info_ref(&ctx->au_info, next_pu); > - if (ret < 0) > - return ret; > - > - set_parser_ctx(s, avctx, &ctx->au_info); > - > - return 0; > -} > - > //8.3.1 Decoding process for picture order count. > //VTM did not follow the spec, and it's much simpler than spec. > //We follow the VTM. > @@ -338,10 +283,8 @@ static int get_pu_info(PuInfo *info, const CodedBitstreamH266Context *h266, > continue; > if ( nal->nal_unit_type == VVC_PH_NUT ) { > info->ph = pu->units[i].content; > - info->ph_ref = pu->units[i].content_ref; > } else if (IS_H266_SLICE(nal->nal_unit_type)) { > info->slice = pu->units[i].content; > - info->slice_ref = pu->units[i].content_ref; > if (info->slice->header.sh_picture_header_in_slice_header_flag) > info->ph = &info->slice->header.sh_picture_header; > if (!info->ph) { > @@ -365,7 +308,6 @@ static int get_pu_info(PuInfo *info, const CodedBitstreamH266Context *h266, > ret = AVERROR_INVALIDDATA; > goto error; > } > - info->pps_ref = h266->pps_ref[info->ph->ph_pic_parameter_set_id]; > info->sps = h266->sps[info->pps->pps_seq_parameter_set_id]; > if (!info->sps) { > av_log(logctx, AV_LOG_ERROR, "SPS id %d is not avaliable.\n", > @@ -373,7 +315,6 @@ static int get_pu_info(PuInfo *info, const CodedBitstreamH266Context *h266, > ret = AVERROR_INVALIDDATA; > goto error; > } > - info->sps_ref = h266->sps_ref[info->pps->pps_seq_parameter_set_id]; > info->pic_type = get_pict_type(pu); > return 0; > error: > @@ -430,8 +371,7 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, > goto end; > } > if (is_au_start(ctx, &info, avctx)) { > - if ((ret = set_ctx(s, avctx, &info)) < 0) > - goto end; > + set_parser_ctx(s, avctx, &info); > av_packet_move_ref(&ctx->last_au, &ctx->au); > } else { > ret = 1; //not a completed au > @@ -560,7 +500,6 @@ static void vvc_parser_close(AVCodecParserContext *s) > { > VVCParserContext *ctx = s->priv_data; > > - pu_info_unref(&ctx->au_info); > av_packet_unref(&ctx->au); > av_packet_unref(&ctx->last_au); > ff_cbs_fragment_free(&ctx->picture_unit); Should be ok. _______________________________________________ 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".