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 86E8F4B4BE for ; Fri, 7 Jun 2024 13:08:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A0BC68D84D; Fri, 7 Jun 2024 16:04:27 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F2E8468D782 for ; Fri, 7 Jun 2024 16:03:51 +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=Y7C/KJPa; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id CCA5E4D76 for ; Fri, 7 Jun 2024 15:03:51 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ct_L4abhBlu6 for ; Fri, 7 Jun 2024 15:03:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=VVdNgxCQ3m6IwaTmd04yjYhxwIVx1Dz54VHUeMSHkR0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Y7C/KJPacfgIn3HtGXjyaBc0TlQGMcT5wVV8XhMNB7HmQnB1bcKJNseWaq6AsHVAc Z5AdWax3iCVWCkZKUneMb8UIvNwTJ7GcNt0SVjnOOkXf7P1OgyZQK00QHLNjPs8dPB j2BNzOTqtqMbs2h1XOTT0OxabDiJ8kUJkU2JBLXxHP0kuKnqaz326XSv7e/uzDD7Sn 4Rv6u3ZYT/LEyqqLEU0NdODnaSnwwIRhV6Kx5pgqv/49UDj9MTFdp/3wYQP4myIHU2 LSPqAlXs6ddDnWVdbWCWfiCQk1CZNHNNGH6pQSpw5pdNG0azxUkql9eQGSsdyB/98l E+4PVcmPjDY4w== 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 D9ECB4E0F for ; Fri, 7 Jun 2024 15:03:42 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C2D4E3A1AA4 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:27 +0200 Message-ID: <20240607130135.9088-31-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 31/39] lavc/hevcdec: set active PPS/SPS in hevc_frame_start() 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: Not in hls_slice_header(), as it should only be done once per frame. --- libavcodec/hevc/hevcdec.c | 52 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 804cceac3e..9abae3260d 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -594,6 +594,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) SliceHeader *sh = &s->sh; const HEVCPPS *pps; const HEVCSPS *sps; + unsigned pps_id; int i, ret; // Coded parameters @@ -612,40 +613,23 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) if (IS_IRAP(s)) sh->no_output_of_prior_pics_flag = get_bits1(gb); - sh->pps_id = get_ue_golomb_long(gb); - if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { - av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); + pps_id = get_ue_golomb_long(gb); + if (pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[pps_id]) { + av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); return AVERROR_INVALIDDATA; } - if (!sh->first_slice_in_pic_flag && - s->pps != s->ps.pps_list[sh->pps_id]) { + if (!sh->first_slice_in_pic_flag && pps_id != sh->pps_id) { av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); return AVERROR_INVALIDDATA; } - ff_refstruct_replace(&s->pps, s->ps.pps_list[sh->pps_id]); - pps = s->pps; + sh->pps_id = pps_id; + + pps = s->ps.pps_list[pps_id]; sps = pps->sps; if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) sh->no_output_of_prior_pics_flag = 1; - if (s->ps.sps != sps) { - enum AVPixelFormat pix_fmt; - - ff_hevc_clear_refs(s); - - ret = set_sps(s, sps, sps->pix_fmt); - if (ret < 0) - return ret; - - pix_fmt = get_format(s, sps); - if (pix_fmt < 0) - return pix_fmt; - s->avctx->pix_fmt = pix_fmt; - - s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; - } - sh->dependent_slice_segment_flag = 0; if (!sh->first_slice_in_pic_flag) { int slice_address_length; @@ -2935,12 +2919,30 @@ static int set_side_data(HEVCContext *s) static int hevc_frame_start(HEVCContext *s) { - const HEVCPPS *const pps = s->pps; + const HEVCPPS *const pps = s->ps.pps_list[s->sh.pps_id]; const HEVCSPS *const sps = pps->sps; int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) * ((sps->height >> sps->log2_min_cb_size) + 1); int ret; + ff_refstruct_replace(&s->pps, pps); + if (s->ps.sps != sps) { + enum AVPixelFormat pix_fmt; + + ff_hevc_clear_refs(s); + + ret = set_sps(s, sps, sps->pix_fmt); + if (ret < 0) + return ret; + + pix_fmt = get_format(s, sps); + if (pix_fmt < 0) + return pix_fmt; + s->avctx->pix_fmt = pix_fmt; + + s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; + } + memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); memset(s->vertical_bs, 0, s->bs_width * s->bs_height); memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); -- 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".