From patchwork Fri Jun 7 13:01:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 49651 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1010130vqo; Fri, 7 Jun 2024 06:06:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDZAEOVDxkhJwAt5owiN+1D8tIst0K40QEmW+HNPwtL8TZRXPTapy0z7Ch6zwTK1Cii26mLHm55PdAOWLP3uFyO8/LkUH+HwE6GA== X-Google-Smtp-Source: AGHT+IEHJ6BnL1+lUxGW6ED1eYSheiosdfy02q8xWRL9xP6RYb5zMj5rb7uTspqipswdIok0ybsI X-Received: by 2002:a05:6512:2211:b0:52b:bf92:bcd with SMTP id 2adb3069b0e04-52bbf920ca9mr1539720e87.22.1717765582548; Fri, 07 Jun 2024 06:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717765582; cv=none; d=google.com; s=arc-20160816; b=qZnFsnGbFnU+qQf3NGquWi+9jbtDh9TTdYvL/uKFpSlBM5vQvu3hDHG/pXL5xwRPGi 5nNm8TXEbnLgJSKvF+4u0woRuvKXreVHLReEYtD6O4dv81hTK6+f5lOwk8V4e3ypQpK7 hnCPeiTdsPOxLrOS0Sr7uEcNxmGeGVZkZL0je2EbKQ89KtpW52JehNIv0n0OASMfpzOz CTa4QbsoBzjlXmUWotiBzUC0mPsBhrqPHz1xbz90h29wvok1xTJYQUTqNrNMYrdvIKMD Eoa+Jx/cfajR7V0L+incHRuDJP6Ki6KQ6wRudUvMbB4LAlKCOFNoms4adToKDKBonyOC mAMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=isfsAjID50987MnzjNKB0bRTwHxpukC/km8/yXC6iGM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PEfL+txmVmMe/3CMIvuTZYDRwXhBFuXz22ms9XS5f4I+YXneWmGXDNoK/suaZX0mB3 rOoCQ3+QpuKLXalBfyGvrw7uElTf8zfBf0e29FUnwbNngMK+5/JQITBnkKnKY3r11+ql XqdcD8SMedTjNdqbIscQon4X4Gk10HQrORnn6EoUp27c5b/NF7Hr8Zm2nWioPdiv/guv ooKBbeTRXEej7yFvb2kY+d4OgKVbfv1dGiLim3/fOpqLdq8eTflpm5LdpkI6Vo6v9sP/ jXfYjRDryT+6hI5vpUnjNYHrOKp5a9h96rAM1Twmhc+h64T5sxrIMuH41GHal0WUk2jI 1ing==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=grx3cuyu; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a6e448710ccsi52442866b.401.2024.06.07.06.06.21; Fri, 07 Jun 2024 06:06:22 -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=@khirnov.net header.s=mail header.b=grx3cuyu; 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 2850968D7AF; Fri, 7 Jun 2024 16:04:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 725CD68D782 for ; Fri, 7 Jun 2024 16:03:50 +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=grx3cuyu; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 3CA764DF2 for ; Fri, 7 Jun 2024 15:03:48 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Mk4BdSRIGllS for ; Fri, 7 Jun 2024 15:03:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=kXL7ou06MZalsHE5CvfLjYkQ4JYpQXT3hMUg3tJzhMI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=grx3cuyuE/NEesaX4645qkt9hOq0VbzkJrUGWnA/ueKVr06rJdI7xNKW621WCtuxF EQiypK3OTJ2KXvAe2li9wz+Xx5v/CY6B32oGMIMYohyHmiAHo6Lhw859hoMve5QSuH Z1GmCh8gL1qDIK2aGUxbzIiVNbXF/z3aGQvY1ynxTPvOKyZ9HPwYOYfvK7RuEjBWi+ 9lOJI9tyWp/xz0kv9ZvG3kRx1aAxszoHbl54sXkuwjsWpJGovijDgSZYfmxBfddY0k azQAhbDuD7Kfn0qBQtyCEXBBXFYjNYxhq9FM4vnBP9QMh4Zd+GFpN+w3HuG0L19kLH LMrgU06pDht8Q== 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 064364DF4 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 374873A1513 for ; Fri, 07 Jun 2024 15:03:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 15:01:15 +0200 Message-ID: <20240607130135.9088-19-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 19/39] lavc/hevcdec: do not pass HEVCContext to ff_hevc_frame_nb_refs() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dY74nrAsr7Co Pass the only things required from it - slice header and PPS - explicitly. Will be useful in the following commits to avoid mofiying HEVCContext in hls_slice_header(). --- libavcodec/hevc/hevcdec.c | 2 +- libavcodec/hevc/hevcdec.h | 2 +- libavcodec/hevc/refs.c | 8 ++++---- libavcodec/nvdec_hevc.c | 2 +- libavcodec/vdpau_hevc.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index bf6e93ba1b..585a066426 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -795,7 +795,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) sh->rpl_modification_flag[0] = 0; sh->rpl_modification_flag[1] = 0; - nb_refs = ff_hevc_frame_nb_refs(s); + nb_refs = ff_hevc_frame_nb_refs(sh, pps); if (!nb_refs) { av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n"); return AVERROR_INVALIDDATA; diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 4b28494366..5eaebd3584 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -614,7 +614,7 @@ int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx); /** * Get the number of candidate references for the current frame. */ -int ff_hevc_frame_nb_refs(const HEVCContext *s); +int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps); int ff_hevc_set_new_ref(HEVCContext *s, int poc); diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c index 31fcd49d69..5bd5eab9f1 100644 --- a/libavcodec/hevc/refs.c +++ b/libavcodec/hevc/refs.c @@ -526,12 +526,12 @@ fail: return ret; } -int ff_hevc_frame_nb_refs(const HEVCContext *s) +int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps) { int ret = 0; int i; - const ShortTermRPS *rps = s->sh.short_term_rps; - const LongTermRPS *long_rps = &s->sh.long_term_rps; + const ShortTermRPS *rps = sh->short_term_rps; + const LongTermRPS *long_rps = &sh->long_term_rps; if (rps) { for (i = 0; i < rps->num_negative_pics; i++) @@ -545,7 +545,7 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s) ret += !!long_rps->used[i]; } - if (s->pps->pps_curr_pic_ref_enabled_flag) + if (pps->pps_curr_pic_ref_enabled_flag) ret++; return ret; diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c index 0bebca7568..ce66ddcfb7 100644 --- a/libavcodec/nvdec_hevc.c +++ b/libavcodec/nvdec_hevc.c @@ -187,7 +187,7 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx, .NumBitsForShortTermRPSInSlice = s->sh.short_term_rps ? s->sh.short_term_ref_pic_set_size : 0, .NumDeltaPocsOfRefRpsIdx = s->sh.short_term_rps ? s->sh.short_term_rps->rps_idx_num_delta_pocs : 0, - .NumPocTotalCurr = ff_hevc_frame_nb_refs(s), + .NumPocTotalCurr = ff_hevc_frame_nb_refs(&s->sh, pps), .NumPocStCurrBefore = s->rps[ST_CURR_BEF].nb_refs, .NumPocStCurrAfter = s->rps[ST_CURR_AFT].nb_refs, .NumPocLtCurr = s->rps[LT_CURR].nb_refs, diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c index 3db7ec156a..b9e922ecfc 100644 --- a/libavcodec/vdpau_hevc.c +++ b/libavcodec/vdpau_hevc.c @@ -205,7 +205,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, } } /* See section 7.4.7.2 of the specification. */ - info->NumPocTotalCurr = ff_hevc_frame_nb_refs(h); + info->NumPocTotalCurr = ff_hevc_frame_nb_refs(&h->sh, pps); if (sh->short_term_ref_pic_set_sps_flag == 0 && sh->short_term_rps) { /* Corresponds to specification field, NumDeltaPocs[RefRpsIdx]. Only applicable when short_term_ref_pic_set_sps_flag == 0.