From patchwork Wed Apr 10 13:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47997 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp556577pzb; Wed, 10 Apr 2024 06:31:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLB7a6tf9rju51If58Tvx07jAbnv4F1U3aMCpEXaxyBThVtZN0dap3iZc7/134AzIS7SvoJdEAaNzc2Mxo2cT+epaPU1OMPhlmhA== X-Google-Smtp-Source: AGHT+IGp6L1zryivriWZzVKmTyAW+Kks2uSNLy48JF4roKrFnwqAn0PQF+wr+ZjpX9trSSXWSV4W X-Received: by 2002:a50:bb23:0:b0:56d:f246:bfa4 with SMTP id y32-20020a50bb23000000b0056df246bfa4mr2119548ede.23.1712755897101; Wed, 10 Apr 2024 06:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755897; cv=none; d=google.com; s=arc-20160816; b=MDvnTfDDmGpD1/R6OI46qMpVCF2KqqOun0Lfh5YQmAasQrFCvQ7ex46kN4NxEGFK4r o/9NxmZspT5YZzmYCAHmuYrGj5+42keTDAk2A9hY9/UJf87Makv934STGOm+dwt6NikZ p3xYEdafMkFQJyuNJDIqevnbBZ4NyIxclzBo0DQuoeajcijZSgAC5aa3E3hWx1xUEda2 8XJXbDtyirDYXZr2IszYzYGVPyPrIJB/TzjFygeIZ5tBK//HB6w40QyyUlBaU+KZtLP6 gqMdFtkXFBJjtGy/0gPnka4mxJLN9U3ejQQ3Kq2Lh677hhDZ+IVDXg1fSPulmyWMaXZp n3Ew== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=QBCogHuRPcIUvNZbkD0YjF1C5VluJH3Z6v5Px7y3Z5s=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=m4xSGCxP9UR9I0Xal+/2QYmZb8qaVTu7SlpgrvnxvJntf+g7Wwz0TYhrNB2bJ+vgrT u4m9Kth4O5vF/jxHdrzOKavEkGBjtV4TBKR+0kU6D/TwSF+ybm3a+qREx+u6xvxJYVbb EWuXhOT9cKKtn5ZB/tyu+H6FFni2bIgA/zWP89dnZYT5BNFDixMa5j+bsw/AF4PVI4j6 sVPf1r5N3//FGdaQwaciAbQOR26xdB0XvzL9CqKutcAiQZPdX3Z701Lrr2Zqpj2gj70Y IKNHZm+Ulg3GfN+GSlMJeoLluHPTlrEAhut5uEK1a4b/FgR7pERbW+xmMQccVUi2/QPT kmIA==; 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=WIbtQPQR; 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 f17-20020a0564021e9100b0056e6601fc9asi2765096edf.469.2024.04.10.06.31.36; Wed, 10 Apr 2024 06:31:37 -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=WIbtQPQR; 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 5178868D02A; Wed, 10 Apr 2024 16:31:34 +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 5582F68CB46 for ; Wed, 10 Apr 2024 16:31:27 +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=WIbtQPQR; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id AC8EF4D84 for ; Wed, 10 Apr 2024 15:31:25 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 8kRcOnyrKGud for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=9QLbPoV8xCNZpk7N8WodennmaDCJfH3EYkCu6A1LNrg=; h=From:To:Subject:Date:From; b=WIbtQPQRE8R+ljrmvX5RS/swS5ej5m/jRzCIfBes4kWJM2Iqa8glOPQIC2+2VVNxy 1QDb0baxwk+HcstbKcQ3twyDRKerolD2/4tj97d15yrD0oPTfX1CiHp3nD/xnuAhXq 2W9UFD3z+HxQve1LLB8433VOlIdxebuCBdpQ2FFgGSqHhrB6jkz6+AyHlTGPUh9tYd ecBVHbq0N+z2gdaU0p8ZfQYF/MQcj0y0kERyHbcKcPV84dzaxNb639upn6TJylSRqU 3gC7DQbhs3i58Zs/SQFJYvrCKJqt3+HRUY4no7a8WB/sPqQ0KtmpPkeRfEW64qgKIH hTzfrWVJhFj5g== 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 AB6184D6E for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 83D723A0357 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:09 +0200 Message-ID: <20240410133118.28144-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] lavc/hevcdec: rename HEVCContext.HEVClcList to local_ctx 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: EOl6vnURdDch It is more consistent with our naming conventions. --- libavcodec/hevcdec.c | 30 +++++++++++++++--------------- libavcodec/hevcdec.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index d3b668af00..c70937a756 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2697,14 +2697,14 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) } for (i = 1; i < s->threads_number; i++) { - if (s->HEVClcList[i]) + if (s->local_ctx[i]) continue; - s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext)); - if (!s->HEVClcList[i]) + s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext)); + if (!s->local_ctx[i]) return AVERROR(ENOMEM); - s->HEVClcList[i]->logctx = s->avctx; - s->HEVClcList[i]->parent = s; - s->HEVClcList[i]->common_cabac_state = &s->cabac; + s->local_ctx[i]->logctx = s->avctx; + s->local_ctx[i]->parent = s; + s->local_ctx[i]->common_cabac_state = &s->cabac; } offset = (lc->gb.index >> 3); @@ -2742,8 +2742,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) s->data = data; for (i = 1; i < s->threads_number; i++) { - s->HEVClcList[i]->first_qp_group = 1; - s->HEVClcList[i]->qp_y = s->HEVClc->qp_y; + s->local_ctx[i]->first_qp_group = 1; + s->local_ctx[i]->qp_y = s->HEVClc->qp_y; } atomic_store(&s->wpp_err, 0); @@ -2756,7 +2756,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) return AVERROR(ENOMEM); if (s->ps.pps->entropy_coding_sync_enabled_flag) - s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->HEVClcList, ret, s->sh.num_entry_point_offsets + 1); + s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->local_ctx, ret, s->sh.num_entry_point_offsets + 1); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) res += ret[i]; @@ -3474,13 +3474,13 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_freep(&s->sh.offset); av_freep(&s->sh.size); - if (s->HEVClcList) { + if (s->local_ctx) { for (i = 1; i < s->threads_number; i++) { - av_freep(&s->HEVClcList[i]); + av_freep(&s->local_ctx[i]); } } av_freep(&s->HEVClc); - av_freep(&s->HEVClcList); + av_freep(&s->local_ctx); ff_h2645_packet_uninit(&s->pkt); @@ -3497,13 +3497,13 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) s->avctx = avctx; s->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); - s->HEVClcList = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number); - if (!s->HEVClc || !s->HEVClcList) + s->local_ctx = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number); + if (!s->HEVClc || !s->local_ctx) return AVERROR(ENOMEM); s->HEVClc->parent = s; s->HEVClc->logctx = avctx; s->HEVClc->common_cabac_state = &s->cabac; - s->HEVClcList[0] = s->HEVClc; + s->local_ctx[0] = s->HEVClc; s->output_frame = av_frame_alloc(); if (!s->output_frame) diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index e65a6180ca..9e3e6a8cd7 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -441,7 +441,7 @@ typedef struct HEVCContext { const AVClass *c; // needed by private avoptions AVCodecContext *avctx; - HEVCLocalContext **HEVClcList; + HEVCLocalContext **local_ctx; HEVCLocalContext *HEVClc; uint8_t threads_type; From patchwork Wed Apr 10 13:31:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47998 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp556719pzb; Wed, 10 Apr 2024 06:31:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzcyJ32lHwarI5YEtkU/x4v0pqYdM52sWuaOFMw0g8esYfjp2evotkVZ0Y+f2ASm33KKrQLjOGceR/Y9svHVYGfJke6x762noK5w== X-Google-Smtp-Source: AGHT+IFM2ih5GLajNfg2tXmjuAt7SMIoGK2zELzeEzS/6HBkMzppvPHwWkSdEoBWPSZiv2QqnVhy X-Received: by 2002:a17:907:7e84:b0:a4e:24af:d8a4 with SMTP id qb4-20020a1709077e8400b00a4e24afd8a4mr291339ejc.28.1712755908859; Wed, 10 Apr 2024 06:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755908; cv=none; d=google.com; s=arc-20160816; b=YrDuHgGfazTQDag2TXAMajUCgEqWQ3LVU8m/Uaui/hguxrdnBR0NG5vmU8pFpbRAZF 7DurKrDbxitf7yODVp56Ww8fnNX5NJ3921CQW2IjJkG3KxEsN7pMLDA4ne45Fkvuslqs S85nEUDUm/Ixe/2uL9U67Jr9eO2blWnPhsJxyJly2ud+E5ckHIo1juiv1xH7KPn2zaGO 5zNS0yiIcv4EMI9P3FUnH1msPW5nbrm35OOwgcSebb2AZZoiIESaROPQ2OPEFTRtpJsF GJUxBPacqD5TMWXcli0kbS3CMeYf8Z7t/ZPj4lfe7odKkUrSBMzPpHEuOWrGsmIYxDsu G0Gw== 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=GF0RdkFIFI9lSm1hdAjadvC0+HZdGOV+st9lgSXa6Lg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PBnmldloeeu4M2wm2kkOpA4546xikd206a5r5wzYqBzGHwDdK0HiiCZMOrJl0M06jv uPktt058gVXPDjdKhGtWT4WoRGKSlXzkH5CDF7bDorjPQdDXBvGCOkRfyaI7V8QiMwQ1 F8XW52lsAbnu8F2j7X8rSwilwAAhsfSYNjiuvYMW0VYbnFwOmJ3hqVV9e4Lj9APgf5Iu YulvyZfV/ftqluaHH+ro4Pti4MPOeOfPl+KgtVE3BfYygwRdzo2zX29SgsYHITbmKGoK 7HqU9Oozjrwct/MHwPRf3LUNAZfTqlkYoAQgBi1KKpMuJDu95cscuiY+2/APB3NCm7cE Ckpg==; 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="W9s/F4+f"; 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 z18-20020a1709060ad200b00a51f5ac8bc8si1865798ejf.118.2024.04.10.06.31.47; Wed, 10 Apr 2024 06:31:48 -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="W9s/F4+f"; 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 59E0268D0B1; Wed, 10 Apr 2024 16:31:35 +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 4944168C788 for ; Wed, 10 Apr 2024 16:31:27 +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=W9s/F4+f; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 941DE4D72 for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id FJGD-vCcKE0h for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=SG5LCi6nAgTMVl6e13oL/zc9WyLc+RwCqLeAk80aGOM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W9s/F4+fXbKFiSn7Iv0YQetDbZ2EkIFJMz1S+QhguAJevAjTdw6f4uyUnwLfdWMlH mu2Mojow8S8TtDcmOuG8mK70DNRPWVpP0mbOkI7uKH2w5LT+ESgTMpbc8uuLFgLCA/ OGqJJFtGjqVS7AXVBte6NohLAZqCvJFvY2DvXeFpiDM9MWLWmVXiDRiCinoosiMJlc p9lUMQikVIJZwHO+78FUjl1tN6RE2XTahBlLzNfxyt6kdV60Kjxn6dwp1Mm0BN5dGs KorVNc6ko7gmGoI1ChSKSZ/VZOoK5q2Fk9TrO4XCBUcUmyYndJTLtTlbjf8o07wfdh 1knYr4QmKtbEQ== 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 A98281D2E for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 908D03A0379 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:10 +0200 Message-ID: <20240410133118.28144-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] lavc/hevcdec: track local context count separately from WPP thread count 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: cli15e49+KQs The latter can be lowered while decoding, which would lead to memleaks. --- libavcodec/hevcdec.c | 7 +++++-- libavcodec/hevcdec.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index c70937a756..55f72af972 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2697,11 +2697,13 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) } for (i = 1; i < s->threads_number; i++) { - if (s->local_ctx[i]) + if (i < s->nb_local_ctx) continue; s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext)); if (!s->local_ctx[i]) return AVERROR(ENOMEM); + s->nb_local_ctx++; + s->local_ctx[i]->logctx = s->avctx; s->local_ctx[i]->parent = s; s->local_ctx[i]->common_cabac_state = &s->cabac; @@ -3475,7 +3477,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_freep(&s->sh.size); if (s->local_ctx) { - for (i = 1; i < s->threads_number; i++) { + for (i = 1; i < s->nb_local_ctx; i++) { av_freep(&s->local_ctx[i]); } } @@ -3504,6 +3506,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) s->HEVClc->logctx = avctx; s->HEVClc->common_cabac_state = &s->cabac; s->local_ctx[0] = s->HEVClc; + s->nb_local_ctx = 1; s->output_frame = av_frame_alloc(); if (!s->output_frame) diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 9e3e6a8cd7..a881eb9981 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -442,6 +442,8 @@ typedef struct HEVCContext { AVCodecContext *avctx; HEVCLocalContext **local_ctx; + unsigned nb_local_ctx; + HEVCLocalContext *HEVClc; uint8_t threads_type; From patchwork Wed Apr 10 13:31:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48000 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp556907pzb; Wed, 10 Apr 2024 06:32:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVIfDJnxpRX2MXCUkFYSoyue+qRPmEpw+TKqjkBROHCgEGNLPk6KX657XqGqNm0ghuNQFStyKSrnLcmqPygTrlr4IvmW89jjlegg== X-Google-Smtp-Source: AGHT+IHkIWaclTOyd/AaB/AqTbggVHGiRxi2XnsWvAQgXMWArzsfxXBgrqChorpKbXt9LHKyqmiS X-Received: by 2002:a05:6512:371a:b0:513:aef5:b431 with SMTP id z26-20020a056512371a00b00513aef5b431mr1333731lfr.4.1712755926583; Wed, 10 Apr 2024 06:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755926; cv=none; d=google.com; s=arc-20160816; b=j/mejNQwY3Z0tOr88MNRWG8swnDdoCSh4phXhxYBkaHuVVCYKMZRcufhxiBDmliPPk Hbgbfqbu5EKhSwyoFhX15E0WaoNAkCtbsm3UwdxfhqnEuVTFVtu5A9rXdZfCgEfUzyyM 0+iGgQhz8yIxpp2/B6R7j/8CrKbG1U2tYNpF4veZJbxm78DpRBVjIUJAMlKPGNVvWmoq RQRz0XwwrG+hmyews6V6Eav0LYKEzjdeMH1JVEHMhDNPCSbPupR5s+5JqQxPHT2tW65o EAljFt1QCP7Nfn22FJZ6/VXTh98iwbOAq+8BprqStgEwtxUv+6pDa8+UbyjyA04l2+KB G0og== 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=Oc+ifo0mH44+JZfJb+qBCmK/re3Uw8g5saZPLg8AHJA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=IcJ5SoymmB6etuWmOaN3YLiwl0sa57QerbDkNqhIf95i/4roobmQ2kqCn9DW7JxG3Q 8ZDolzpZenIK1IBfwF23pzVEjALRwoXgX12nEsaGKR35MLMF1Eaf5NcL/AGm8+gyRDWu 5V9W/NZy0Or8m36mfZ7OdO9DYW3F4LHLmcyYmjpEoW/CoQf2kYBagRcFtmwe+4Z879CI 84TcPurzzF4FQEbbIWQ16Ozvpn/0WLqP6ihPfqSnshlWPkaaU1lqi35d8uf0AFSkozjH mgCIf7/RkwlFxPfo8ccU89XgiQGiBzoHHGg3D34hDqpu1PomFRoKkSHXpLxNcWqFlSyM qkDA==; 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=fRbYs34V; 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 w18-20020a17090652d200b00a51c4d610e5si4137633ejn.641.2024.04.10.06.32.06; Wed, 10 Apr 2024 06:32:06 -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=fRbYs34V; 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 5077868CF46; Wed, 10 Apr 2024 16:31:37 +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 60BEA68CEE6 for ; Wed, 10 Apr 2024 16:31:27 +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=fRbYs34V; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2B4824D6E for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id urJuahZlDkS3 for ; Wed, 10 Apr 2024 15:31:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=yD3xfZVzLgylUzG8gzFzdKJhWCsYUQ8tc8CCzHBUosQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fRbYs34VWZqPr9uakoNveOyTO0GrdhvylqoS1md7w2CP7e91Ak0PX/LwiiZig+DXv BWUx7O0sgQjMqTzKejKoB2JVqivY0hQeruE5ZI/MMxT2W8PKSqQ1Osd0qOMYob4CmF 7LlrJqvlOp7GdxlLJ2nLyg9ZNc81EZggPX/3+zTtdEjxwr5B5sFxNB7NvcvJslqY3u UN4RXbz+4vpJnG8oBecDlSmRILdNkA1YCY6MssxCrF1duw8g4+Biu9g0jOiyU5g8UL 3O2xY3/ciLCr8+R6ZrbpuSy6Bars3q27NPGdUWonQLFj1m/LtDQrHKnfzOI0x1yzPw o/wNjh0dY4MeA== 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 B1B654D72 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9B92D3A03BC for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:11 +0200 Message-ID: <20240410133118.28144-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/10] lavc/hevcdec: allocate local_ctx as array of structs rather than pointers 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: AP9i/EXk2hYh It is more efficient and easier to manage. --- libavcodec/hevcdec.c | 57 +++++++++++++++++++++++++------------------- libavcodec/hevcdec.h | 2 +- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 55f72af972..47226ef0ab 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2598,7 +2598,7 @@ static int hls_slice_data(HEVCContext *s) static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, int job, int self_id) { - HEVCLocalContext *lc = ((HEVCLocalContext**)hevc_lclist)[self_id]; + HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id]; const HEVCContext *const s = lc->parent; int ctb_size = 1 << s->ps.sps->log2_ctb_size; int more_data = 1; @@ -2682,7 +2682,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) { const uint8_t *data = nal->data; int length = nal->size; - HEVCLocalContext *lc = s->HEVClc; + HEVCLocalContext *lc; int *ret; int64_t offset; int64_t startheader, cmpt = 0; @@ -2696,19 +2696,31 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) return AVERROR_INVALIDDATA; } - for (i = 1; i < s->threads_number; i++) { - if (i < s->nb_local_ctx) - continue; - s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext)); - if (!s->local_ctx[i]) - return AVERROR(ENOMEM); - s->nb_local_ctx++; + if (s->threads_number > s->nb_local_ctx) { + HEVCLocalContext *tmp = av_malloc_array(s->threads_number, sizeof(*s->local_ctx)); - s->local_ctx[i]->logctx = s->avctx; - s->local_ctx[i]->parent = s; - s->local_ctx[i]->common_cabac_state = &s->cabac; + if (!tmp) + return AVERROR(ENOMEM); + + memcpy(tmp, s->local_ctx, sizeof(*s->local_ctx) * s->nb_local_ctx); + av_free(s->local_ctx); + s->local_ctx = tmp; + s->HEVClc = &s->local_ctx[0]; + + for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) { + tmp = &s->local_ctx[i]; + + memset(tmp, 0, sizeof(*tmp)); + + tmp->logctx = s->avctx; + tmp->parent = s; + tmp->common_cabac_state = &s->cabac; + } + + s->nb_local_ctx = s->threads_number; } + lc = &s->local_ctx[0]; offset = (lc->gb.index >> 3); for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { @@ -2744,8 +2756,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) s->data = data; for (i = 1; i < s->threads_number; i++) { - s->local_ctx[i]->first_qp_group = 1; - s->local_ctx[i]->qp_y = s->HEVClc->qp_y; + s->local_ctx[i].first_qp_group = 1; + s->local_ctx[i].qp_y = s->HEVClc->qp_y; } atomic_store(&s->wpp_err, 0); @@ -3476,12 +3488,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_freep(&s->sh.offset); av_freep(&s->sh.size); - if (s->local_ctx) { - for (i = 1; i < s->nb_local_ctx; i++) { - av_freep(&s->local_ctx[i]); - } - } - av_freep(&s->HEVClc); av_freep(&s->local_ctx); ff_h2645_packet_uninit(&s->pkt); @@ -3498,15 +3504,16 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) s->avctx = avctx; - s->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); - s->local_ctx = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number); - if (!s->HEVClc || !s->local_ctx) + s->local_ctx = av_mallocz(sizeof(*s->local_ctx)); + if (!s->local_ctx) return AVERROR(ENOMEM); + s->nb_local_ctx = 1; + + s->HEVClc = &s->local_ctx[0]; + s->HEVClc->parent = s; s->HEVClc->logctx = avctx; s->HEVClc->common_cabac_state = &s->cabac; - s->local_ctx[0] = s->HEVClc; - s->nb_local_ctx = 1; s->output_frame = av_frame_alloc(); if (!s->output_frame) diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index a881eb9981..5a4ed270e8 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -441,7 +441,7 @@ typedef struct HEVCContext { const AVClass *c; // needed by private avoptions AVCodecContext *avctx; - HEVCLocalContext **local_ctx; + HEVCLocalContext *local_ctx; unsigned nb_local_ctx; HEVCLocalContext *HEVClc; From patchwork Wed Apr 10 13:31:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47999 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp556818pzb; Wed, 10 Apr 2024 06:31:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuEl1BoeSKhazV0MpJGhSs9E1QHOFnERgeMM0eUU9j+oXnCL7OEyUU5p0u6PiLcQIVwZT02xrhhHtUl4DyKfCi5dwHKhKbdJaIAw== X-Google-Smtp-Source: AGHT+IHlGUSiHqXXEMJ3XxqEtWq/mE9eCfvQs5K/cfb82Lz4g60V06vNdBd5fKAowTkp5EvWsFfw X-Received: by 2002:a50:d795:0:b0:568:a9f3:b3fb with SMTP id w21-20020a50d795000000b00568a9f3b3fbmr1661641edi.8.1712755917337; Wed, 10 Apr 2024 06:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755917; cv=none; d=google.com; s=arc-20160816; b=lFE4GWB/kh/FJ/4pBZ/uIz9Qg4UYmMnMAVglPnaFvM4CL4UoBkYiHlxte6ZwoDhU/Z HhQOTDJ50DV5TxeGPSXy8xdE3HNj2tQfEN2FPUVGDdzz8ZP06O12H/6W66Dje5Bl2SO9 Yh103pYv8k4dUvvoV9/WmOrTmnsLSh9hcAalclvWbdGhYsDVGYjyjA/FI4CMRNh9VfUv PfS0IXFNXHY0uwfx5mTE1LmDP7Vb1rsQXCrj+HSkzHCwLNltjJUdDLJ/7ywFi/MQVxLc Dke8KZdkdEm7KLydAMCMNOVan5h9GozZLDoEaK6Vs+5f2Nioh2fJzjCThZYgiD84fWS5 PReg== 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=m6LEcwW60/6J+TfZHlwe7eVPuVOqmd1n5l6JKvSgFTU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=bJFrzKynAsmwfim2yIo9YIOq6lHZBn1cthc/XKfAZHSioXylbrtCNo5YOLdpq7w4NL T9T3h8otJYqfl2SZznVXPnLS8ffqlwLntFlPrwliD8k9Oa3DoRSbY7Ijn4G4Wu1JW3Uy lDM6cUJEPaQqXGe+z93/E6fSsEeo16/xwVvz9/l2bhq5wjrlNvMs4EYVdLH2f3o176gG 83mHMDsmyOyjg2g48WsR/yX87wNdqxeNuZwTirUIsUHDExmYBIEmU12YiVZwrfi2wf8i dDOkbO0vZGOWFGOVfL0o7W29QhkT/gK3bWiY9Hkfqx197984/TULvniyaoyns44AOD/E p0PA==; 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=OXjuAyqK; 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 w22-20020a50d796000000b0056e31aea633si5559964edi.367.2024.04.10.06.31.56; Wed, 10 Apr 2024 06:31:57 -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=OXjuAyqK; 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 4DCD668CB46; Wed, 10 Apr 2024 16:31:36 +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 58CA168CE33 for ; Wed, 10 Apr 2024 16:31:27 +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=OXjuAyqK; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id B54181D2E for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id CvLCEz-KW_E8 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=L4ldU7PiW1ElbEdxoyuPzkB/ulQbL6qSTONGs/hz95M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OXjuAyqKpS8jtB6vJXPbD+2xznBor54gvbTV2jqeB+BYcHOrVZvFCPWrxetFYTOCY jg2C3EkFxCNZdf5KQlhGpg55vne2i+MTNrIkdzCqO+SO/R0sFnTj6t3vRg475MiWg7 lyEIS83+ZRpRDfB/MfNWMPY6leJD/WqSWPT2mIYcghdNRv40Gw+Iw7+1JBpZWU5VV0 t/7nBAx7Z/Yv9YMSDzaOrwsl81HwAMb0HAb1x7s9BhuJIiXreivqWzOuwO4Eg+ePM+ DAT3axykaCP7o+K+HFI3V6Agw9nDrlFHst7493qVmSWh5c/QSOkDQidE2/IXj8G3WS 18XmyQzrFGs6A== 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 BCCC14D74 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A646D3A03CA for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:12 +0200 Message-ID: <20240410133118.28144-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/10] lavc/hevcdec: drop a useless execute() call with 1 job 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: zrP+4mTBr97t --- libavcodec/hevcdec.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 47226ef0ab..6b2c0b75ee 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2526,9 +2526,8 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb, lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); } -static int hls_decode_entry(AVCodecContext *avctxt, void *arg) +static int hls_decode_entry(HEVCContext *s) { - HEVCContext *s = avctxt->priv_data; HEVCLocalContext *const lc = s->HEVClc; int ctb_size = 1 << s->ps.sps->log2_ctb_size; int more_data = 1; @@ -2588,13 +2587,6 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *arg) return ctb_addr_ts; } -static int hls_slice_data(HEVCContext *s) -{ - int ret = 0; - - s->avctx->execute(s->avctx, hls_decode_entry, NULL, &ret , 1, 0); - return ret; -} static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, int job, int self_id) { @@ -3133,7 +3125,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0) ctb_addr_ts = hls_slice_data_wpp(s, nal); else - ctb_addr_ts = hls_slice_data(s); + ctb_addr_ts = hls_decode_entry(s); if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) { ret = hevc_frame_end(s); if (ret < 0) From patchwork Wed Apr 10 13:31:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48001 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557007pzb; Wed, 10 Apr 2024 06:32:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvY9tI1ChtRs+cJG4D9BZn/aUMZvozmbDFVFXciwSlrSdtJnapo5gGNGkRwma8aqhCe/3yiBx6rwT19Qipl2Yz9zyj/H68pq/DIA== X-Google-Smtp-Source: AGHT+IEt58i9h0K37Ue49cL4Rmc0sTSc8YcYT/MrY2TSLU8qYJMpWMXz1YwQBcDI1+Fkf3trj9NV X-Received: by 2002:a17:906:52d7:b0:a51:e476:803b with SMTP id w23-20020a17090652d700b00a51e476803bmr2271125ejn.40.1712755936970; Wed, 10 Apr 2024 06:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755936; cv=none; d=google.com; s=arc-20160816; b=RtTM74Al1npLk/OoUS0/Bvoz09VTUP9W9F6+sDtm61WRKjBJ1JKpI2ErUydwW52ZRN /B+l1V5vGK65e0pTddtN/HYJ4kjHhELWF1O82r5JqUQgqM1n8ylVfUSpl+nostwoJu3y x53y1EO3kQdLU4YbwbR+pj6TRyF6dAVFZwLqPcoZsHwWJQhrJCz2UpcwPVl5ikJXG3It /LQqhX7fyEhahUv65OFR4dVFY41+0ZLTLUNLp2X39+TamOOLcPiN/Qie8YeppmRcvcdC lAqhNxRZHPigpgi8FV1dHujRlkUb7rLfco1dNPRaCKYcbi1p4kOZ3mXHeL3459MwXwTt CmAg== 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=fS9EkGxWRoQ3hAnBVpERXXmfX9TlnkqqNUrB4De2FXM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OeoFvsP6u9QBmeCWlYQsX+oqoUlf9J08E4JDLWrI4Wf3MM9iGYnpk6oDWcVGhugvfb QxHSjNV88VDpDg27F2hgx/THH6gipLwGHhSThWgufpV3FAUr0VkuAQcCRzNGCjYjLxjX UFARkragEjt82k6zt5jQWslGgXAIkL+tVWCk20uUBP5XTqEPyDt3XkfUYCQKpJM8mH97 gqbMtTf1rBiUFNnhqGLOtE5Tgf9w+U+FEUfDzLCTJF6Nn9Pud+Ic1eeBqHRgRblrJtAP mHlzhzcvYno6dTL+L2ojkwm0LbHE38HV8ukuqgubLHcVK62BXmVMGjn3ATU9qRhVH8mE ya/w==; 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=dyi2GW6k; 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 c22-20020a170906341600b00a520a40633csi797649ejb.1007.2024.04.10.06.32.14; Wed, 10 Apr 2024 06:32:16 -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=dyi2GW6k; 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 3AB5A68D027; Wed, 10 Apr 2024 16:31:38 +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 60C6568CEEB for ; Wed, 10 Apr 2024 16:31:27 +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=dyi2GW6k; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E33264D74 for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id y9qmwuDZwxE6 for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=sxtOottlH9J1kq01Kz4A/wvtAoklP2WHN4B3IYkCYHU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dyi2GW6kLLQsY8wIzPshT3eovoglQjktoJyYoshmzxbMXA1OVmQi/iBupOo/62mvB HInKhb08VyTuq62n9pDD+Y/LbKTEtAv7oUV4YA2ivPSQPpez9JqEpdLpSpGLlH2Y10 ITLoyjx/WmiBBdHaahEEHJCl1PxUa4L0HY/3amERrG7Hr+ilUs6PDWYq2VOSMvPSX7 fdYyMkGr4o6lU1ABWimnGis5SFdZUpGPRmSHYJRYNuITerD31uxAm6lITWuj+zxSc0 oYEtwbR+c90z8THZ9c+afM7WWOaR16qOFo3YShbqXCfTDyVrWcPp8ZgY+LVEGB0bvF eW5BjU6yxaeFQ== 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 C6E454D76 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B10EF3A03CF for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:13 +0200 Message-ID: <20240410133118.28144-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10] lavc/hevc_ps: reduce the size of used_by_curr_pic_lt_sps_flag 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: vdgLNI9ZR/yC It is currently an array of 32 uint8_t, each storing a single flag. A single uint32_t is sufficient. --- libavcodec/hevc_ps.c | 4 +++- libavcodec/hevc_ps.h | 2 +- libavcodec/hevcdec.c | 2 +- libavcodec/vulkan_hevc.c | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 25f087ed75..8d5fc0d0ca 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -1094,9 +1094,11 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->num_long_term_ref_pics_sps); return AVERROR_INVALIDDATA; } + + sps->used_by_curr_pic_lt = 0; for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) { sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb); - sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb); + sps->used_by_curr_pic_lt |= get_bits1(gb) * (1 << i); } } diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 61a0fe2219..b2f3a8dbd1 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -230,7 +230,7 @@ typedef struct HEVCSPS { uint8_t long_term_ref_pics_present_flag; uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS]; - uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS]; + uint32_t used_by_curr_pic_lt; uint8_t num_long_term_ref_pics_sps; struct { diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 6b2c0b75ee..4a7046bdec 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -295,7 +295,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) lt_idx_sps = get_bits(gb, av_ceil_log2(sps->num_long_term_ref_pics_sps)); rps->poc[i] = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps]; - rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps]; + rps->used[i] = !!(sps->used_by_curr_pic_lt & (1 << lt_idx_sps)); } else { rps->poc[i] = get_bits(gb, sps->log2_max_poc_lsb); rps->used[i] = get_bits1(gb); diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index 2705a965b9..9b40f5ad58 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -386,11 +386,10 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, } *ltr = (StdVideoH265LongTermRefPicsSps) { - .used_by_curr_pic_lt_sps_flag = 0x0, + .used_by_curr_pic_lt_sps_flag = sps->used_by_curr_pic_lt, }; for (int i = 0; i < sps->num_long_term_ref_pics_sps; i++) { - ltr->used_by_curr_pic_lt_sps_flag |= sps->used_by_curr_pic_lt_sps_flag[i] << i; ltr->lt_ref_pic_poc_lsb_sps[i] = sps->lt_ref_pic_poc_lsb_sps[i]; } From patchwork Wed Apr 10 13:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557455pzb; Wed, 10 Apr 2024 06:32:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXiPa35G7hTZ/ya0Nqc5ilcQzJ8eJsG5UBAv5vn0HXo3+4Z5upUWsImSRhKjNepm0gOHTQlvpRMNSkzT4Iize8xqKusM7KXOtS2Qg== X-Google-Smtp-Source: AGHT+IGPaipSJXDVKmv8aRx0O75MQe4fffw6n0gmD8HUvqyBsLpa9ZsCLV4yKL+WfNBJqw8BCfva X-Received: by 2002:aa7:d39a:0:b0:56e:7ba6:e78a with SMTP id x26-20020aa7d39a000000b0056e7ba6e78amr1561665edq.2.1712755978695; Wed, 10 Apr 2024 06:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755978; cv=none; d=google.com; s=arc-20160816; b=o++M2FTDKd9jWXHR+WiigITjm7bvCtcskLaL6SxGECwYaeP7BjLw1tn///W59l2+p5 3ItliFidqDTd29QbIG0pj3rkFO7fbJnstCyKxyp/hWx9PhpdIT6Rvo99/e+cF6CZUJm5 jFqrZ+ogSyluPLpkkU+m9Q1nj1e4uhdzzt9aFnelwKoBEoI6ZkkPOAK7q/E70IyI4e0m UUK7QUFZK7mxXKaVznr7457vxH4ZSiVBr2dwGVMBRdlCIdh617ZsVBx1lv90xn3v3yKM 0Yy0/G+yy6LhMQsTS0or0cNtL6OkEjLHm019v39o66gFVA3sWaAtcpnAckf3t9abFaT9 5lpw== 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=GRSOAqMVSg3xMtunfF59EDh41SVTr6a9ISW1c1Ul80M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=wryV7BpvkifptJXTJzQDwfksV7hs8+1MyLV+WY23yRvF+lZHHMpTGfPtjQX3bDUIKL s87MXSsgBZMUkPTBhl16AehvMHyOGoBO0fmxdqxsiYo8dhEZSR89II5p2vkRGSIvLyCf NeQKW2cqmWB5hrs2GcOILSX9dtW1waLP7blOhUcPsv9tyM025Xox+cPk9jQqTX0SyVv6 1bRJz1Sh8A36kQXX5hJeH2jphs8ebLpQjrpJHfuqhjPQoZxY1ock2yPUnk0B4kLoH9Lp WYZgVsLk9aH95guDLspn/8/QT9C5E2hc9QQLRIEy4VZec7ohDzZTZpv+aC9F4vvAYuas cMYQ==; 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="nK/fXI1V"; 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 5-20020a508745000000b0056df5574b6dsi5603988edv.541.2024.04.10.06.32.58; Wed, 10 Apr 2024 06:32:58 -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="nK/fXI1V"; 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 7FB5F68D1DA; Wed, 10 Apr 2024 16:31:43 +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 4E1A768CF46 for ; Wed, 10 Apr 2024 16:31:33 +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=nK/fXI1V; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2C4914D81 for ; Wed, 10 Apr 2024 15:31:28 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 6uBg4-K26dyO for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=yNTw1f6kef8Q+dOq3cuG8PZkThOVolNsWZnsMI3n1PM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nK/fXI1V+A6nkp/abAeQBYSIW2pgRlnCWi7okuJzDqjWEd0spjT1EsHu94cTiLRr1 w30pZ/o+fjH5Dx3TCr1kgCh+7NtGFnnGwIrEykCdJJ5KZlTULFFu9mXSMoenSA+oY7 eFuncK0jhBc9t8xpQYrlzgRpGrHuQ4Jm7dZsTzrHrUvtDU1xJsmBW+DksaAOcyAgrq 2IzVB7P2SHkbXe0PJLVE5z++xyIvemlv8/YaXTZ3NzIgeRmn4Zp6PT6N1Qqhaw8aZY F3R+CQuuq0Ap5VqorkHRrwtQvAvGt8xRJNGrZWrYcswquLdT+A32URQN8asot/NFwj +y0zxlMyrQyRQ== 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 CA4264D78 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BC87B3A04E0 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:14 +0200 Message-ID: <20240410133118.28144-6-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/10] lavc/hevc_ps/HEVCSPS: change flags into size-1 bitfields 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: KPQFSefdiusO Reduces sizeof(HEVCSPS) by 96 bytes. Also improve flag names: drop redundant suffixes and prefixes, and consistently use disabled/enabled. --- libavcodec/dxva2_hevc.c | 24 ++++----- libavcodec/hevc_cabac.c | 36 ++++++------- libavcodec/hevc_filter.c | 8 +-- libavcodec/hevc_parser.c | 2 +- libavcodec/hevc_ps.c | 95 +++++++++++++++++----------------- libavcodec/hevc_ps.h | 62 +++++++++++----------- libavcodec/hevcdec.c | 10 ++-- libavcodec/hevcpred_template.c | 4 +- libavcodec/mips/hevcpred_msa.c | 6 +-- libavcodec/nvdec_hevc.c | 42 +++++++-------- libavcodec/qsvenc_hevc.c | 2 +- libavcodec/vaapi_hevc.c | 42 +++++++-------- libavcodec/vdpau_hevc.c | 36 ++++++------- libavcodec/vulkan_hevc.c | 56 ++++++++++---------- 14 files changed, 212 insertions(+), 213 deletions(-) diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 31d74a7164..b500d7917a 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -72,7 +72,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo pp->PicHeightInMinCbsY = sps->min_cb_height; pp->wFormatAndSequenceInfoFlags = (sps->chroma_format_idc << 0) | - (sps->separate_colour_plane_flag << 2) | + (sps->separate_colour_plane << 2) | ((sps->bit_depth - 8) << 3) | ((sps->bit_depth - 8) << 6) | ((sps->log2_max_poc_lsb - 4) << 9) | @@ -99,18 +99,18 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo pp->wNumBitsForShortTermRPSInSlice = h->sh.short_term_ref_pic_set_size; } - pp->dwCodingParamToolFlags = (sps->scaling_list_enable_flag << 0) | - (sps->amp_enabled_flag << 1) | + pp->dwCodingParamToolFlags = (sps->scaling_list_enabled << 0) | + (sps->amp_enabled << 1) | (sps->sao_enabled << 2) | - (sps->pcm_enabled_flag << 3) | - ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth - 1) : 0) << 4) | - ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth_chroma - 1) : 0) << 8) | - ((sps->pcm_enabled_flag ? (sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) | - ((sps->pcm_enabled_flag ? (sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) | - (sps->pcm.loop_filter_disable_flag << 16) | - (sps->long_term_ref_pics_present_flag << 17) | - (sps->sps_temporal_mvp_enabled_flag << 18) | - (sps->sps_strong_intra_smoothing_enable_flag << 19) | + (sps->pcm_enabled << 3) | + ((sps->pcm_enabled ? (sps->pcm.bit_depth - 1) : 0) << 4) | + ((sps->pcm_enabled ? (sps->pcm.bit_depth_chroma - 1) : 0) << 8) | + ((sps->pcm_enabled ? (sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) | + ((sps->pcm_enabled ? (sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) | + (sps->pcm_loop_filter_disabled << 16) | + (sps->long_term_ref_pics_present << 17) | + (sps->temporal_mvp_enabled << 18) | + (sps->strong_intra_smoothing_enabled << 19) | (pps->dependent_slice_segments_enabled_flag << 20) | (pps->output_flag_present_flag << 21) | (pps->num_extra_slice_header_bits << 22) | diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c index 63ffb3d37c..2e639a7e41 100644 --- a/libavcodec/hevc_cabac.c +++ b/libavcodec/hevc_cabac.c @@ -408,7 +408,7 @@ void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts) (s->ps.sps->ctb_width == 2 && ctb_addr_ts % s->ps.sps->ctb_width == 0))) { memcpy(lc->common_cabac_state->state, lc->cabac_state, HEVC_CONTEXTS); - if (s->ps.sps->persistent_rice_adaptation_enabled_flag) { + if (s->ps.sps->persistent_rice_adaptation_enabled) { memcpy(lc->common_cabac_state->stat_coeff, lc->stat_coeff, HEVC_STAT_COEFFS); } } @@ -417,7 +417,7 @@ void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts) static void load_states(HEVCLocalContext *lc, const HEVCContext *s) { memcpy(lc->cabac_state, lc->common_cabac_state->state, HEVC_CONTEXTS); - if (s->ps.sps->persistent_rice_adaptation_enabled_flag) { + if (s->ps.sps->persistent_rice_adaptation_enabled) { memcpy(lc->stat_coeff, lc->common_cabac_state->stat_coeff, HEVC_STAT_COEFFS); } } @@ -683,7 +683,7 @@ int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size) return PART_NxN; // 000 } - if (!lc->parent->ps.sps->amp_enabled_flag) { + if (!lc->parent->ps.sps->amp_enabled) { if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01 return PART_2NxN; return PART_Nx2N; @@ -1091,7 +1091,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, scale_m = 16; // default when no custom scaling lists. dc_scale = 16; - if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { + if (s->ps.sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) { const ScalingList *sl = s->ps.pps->scaling_list_data_present_flag ? &s->ps.pps->scaling_list : &s->ps.sps->scaling_list; int matrix_id = lc->cu.pred_mode != MODE_INTRA; @@ -1109,7 +1109,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, dc_scale = 0; } - if (lc->cu.pred_mode == MODE_INTER && s->ps.sps->explicit_rdpcm_enabled_flag && + if (lc->cu.pred_mode == MODE_INTER && s->ps.sps->explicit_rdpcm_enabled && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { explicit_rdpcm_flag = explicit_rdpcm_flag_decode(lc, c_idx); if (explicit_rdpcm_flag) { @@ -1240,7 +1240,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, }; const uint8_t *ctx_idx_map_p; int scf_offset = 0; - if (s->ps.sps->transform_skip_context_enabled_flag && + if (s->ps.sps->transform_skip_context_enabled && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { ctx_idx_map_p = &ctx_idx_map[4 * 16]; if (c_idx == 0) { @@ -1281,7 +1281,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, } } if (implicit_non_zero_coeff == 0) { - if (s->ps.sps->transform_skip_context_enabled_flag && + if (s->ps.sps->transform_skip_context_enabled && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { if (c_idx == 0) { scf_offset = 42; @@ -1326,7 +1326,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, // initialize first elem of coeff_bas_level_greater1_flag int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0; - if (s->ps.sps->persistent_rice_adaptation_enabled_flag) { + if (s->ps.sps->persistent_rice_adaptation_enabled) { if (!transform_skip_flag && !lc->cu.cu_transquant_bypass_flag) sb_type = 2 * (c_idx == 0 ? 1 : 0); else @@ -1355,7 +1355,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, if (lc->cu.cu_transquant_bypass_flag || (lc->cu.pred_mode == MODE_INTRA && - s->ps.sps->implicit_rdpcm_enabled_flag && transform_skip_flag && + s->ps.sps->implicit_rdpcm_enabled && transform_skip_flag && (pred_mode_intra == 10 || pred_mode_intra == 26 )) || explicit_rdpcm_flag) sign_hidden = 0; @@ -1381,8 +1381,8 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, trans_coeff_level += last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) - c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); - if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) { + c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); + if (s->ps.sps->persistent_rice_adaptation_enabled && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; @@ -1397,8 +1397,8 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, trans_coeff_level = 1 + last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) - c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); - if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) { + c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); + if (s->ps.sps->persistent_rice_adaptation_enabled && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; @@ -1417,7 +1417,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, trans_coeff_level = -trans_coeff_level; coeff_sign_flag <<= 1; if(!lc->cu.cu_transquant_bypass_flag) { - if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { + if (s->ps.sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) { if(y_c || x_c || log2_trafo_size < 4) { switch(log2_trafo_size) { case 3: pos = (y_c << 3) + x_c; break; @@ -1445,15 +1445,15 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, } if (lc->cu.cu_transquant_bypass_flag) { - if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag && + if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled && (pred_mode_intra == 10 || pred_mode_intra == 26))) { - int mode = s->ps.sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag; + int mode = s->ps.sps->implicit_rdpcm_enabled ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag; s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode); } } else { if (transform_skip_flag) { - int rot = s->ps.sps->transform_skip_rotation_enabled_flag && + int rot = s->ps.sps->transform_skip_rotation_enabled && log2_trafo_size == 2 && lc->cu.pred_mode == MODE_INTRA; if (rot) { @@ -1463,7 +1463,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0, s->hevcdsp.dequant(coeffs, log2_trafo_size); - if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag && + if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled && lc->cu.pred_mode == MODE_INTRA && (pred_mode_intra == 10 || pred_mode_intra == 26))) { int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26); diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c index 0c45310ea6..70d3ca588a 100644 --- a/libavcodec/hevc_filter.c +++ b/libavcodec/hevc_filter.c @@ -224,7 +224,7 @@ static void restore_tqb_pixels(const HEVCContext *s, int x0, int y0, int width, int height, int c_idx) { if ( s->ps.pps->transquant_bypass_enable_flag || - (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { + (s->ps.sps->pcm_loop_filter_disabled && s->ps.sps->pcm_enabled)) { int x, y; int min_pu_size = 1 << s->ps.sps->log2_min_pu_size; int hshift = s->ps.sps->hshift[c_idx]; @@ -330,7 +330,7 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, x_ctb, y_ctb); if (s->ps.pps->transquant_bypass_enable_flag || - (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { + (s->ps.sps->pcm_loop_filter_disabled && s->ps.sps->pcm_enabled)) { dst = lc->edge_emu_buffer; stride_dst = 2*MAX_PB_SIZE; copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src); @@ -500,8 +500,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0) int cur_beta_offset = s->deblock[ctb].beta_offset; int left_tc_offset, left_beta_offset; int tc_offset, beta_offset; - int pcmf = (s->ps.sps->pcm_enabled_flag && - s->ps.sps->pcm.loop_filter_disable_flag) || + int pcmf = (s->ps.sps->pcm_enabled && + s->ps.sps->pcm_loop_filter_disabled) || s->ps.pps->transquant_bypass_enable_flag; if (x0) { diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index f174d419e4..73fc5d6372 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -150,7 +150,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, if (ps->pps->output_flag_present_flag) skip_bits1(gb); // pic_output_flag - if (ps->sps->separate_colour_plane_flag) + if (ps->sps->separate_colour_plane) skip_bits(gb, 2); // colour_plane_id if (!IS_IDR_NAL(nal)) { diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 8d5fc0d0ca..1af691414e 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -895,7 +895,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return AVERROR_INVALIDDATA; } - sps->temporal_id_nesting_flag = get_bits(gb, 1); + sps->temporal_id_nesting = get_bits(gb, 1); if ((ret = parse_ptl(gb, avctx, &sps->ptl, sps->max_sub_layers)) < 0) return ret; @@ -913,9 +913,9 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } if (sps->chroma_format_idc == 3) - sps->separate_colour_plane_flag = get_bits1(gb); + sps->separate_colour_plane = get_bits1(gb); - if (sps->separate_colour_plane_flag) + if (sps->separate_colour_plane) sps->chroma_format_idc = 0; sps->width = get_ue_golomb_long(gb); @@ -924,8 +924,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->height, 0, avctx)) < 0) return ret; - sps->conformance_window_flag = get_bits1(gb); - if (sps->conformance_window_flag) { + sps->conformance_window = get_bits1(gb); + if (sps->conformance_window) { int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * horiz_mult; @@ -982,8 +982,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return AVERROR_INVALIDDATA; } - sps->sublayer_ordering_info_flag = get_bits1(gb); - start = sps->sublayer_ordering_info_flag ? 0 : sps->max_sub_layers - 1; + sps->sublayer_ordering_info = get_bits1(gb); + start = sps->sublayer_ordering_info ? 0 : sps->max_sub_layers - 1; for (i = start; i < sps->max_sub_layers; i++) { sps->temporal_layer[i].max_dec_pic_buffering = get_ue_golomb_long(gb) + 1; sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb); @@ -1004,7 +1004,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } } - if (!sps->sublayer_ordering_info_flag) { + if (!sps->sublayer_ordering_info) { for (i = 0; i < start; i++) { sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[start].max_dec_pic_buffering; sps->temporal_layer[i].num_reorder_pics = sps->temporal_layer[start].num_reorder_pics; @@ -1043,8 +1043,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb); sps->max_transform_hierarchy_depth_intra = get_ue_golomb_long(gb); - sps->scaling_list_enable_flag = get_bits1(gb); - if (sps->scaling_list_enable_flag) { + sps->scaling_list_enabled = get_bits1(gb); + if (sps->scaling_list_enabled) { set_default_scaling_list_data(&sps->scaling_list); if (get_bits1(gb)) { @@ -1054,11 +1054,11 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } } - sps->amp_enabled_flag = get_bits1(gb); - sps->sao_enabled = get_bits1(gb); + sps->amp_enabled = get_bits1(gb); + sps->sao_enabled = get_bits1(gb); - sps->pcm_enabled_flag = get_bits1(gb); - if (sps->pcm_enabled_flag) { + sps->pcm_enabled = get_bits1(gb); + if (sps->pcm_enabled) { sps->pcm.bit_depth = get_bits(gb, 4) + 1; sps->pcm.bit_depth_chroma = get_bits(gb, 4) + 1; sps->pcm.log2_min_pcm_cb_size = get_ue_golomb_long(gb) + 3; @@ -1071,7 +1071,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return AVERROR_INVALIDDATA; } - sps->pcm.loop_filter_disable_flag = get_bits1(gb); + sps->pcm_loop_filter_disabled = get_bits1(gb); } sps->nb_st_rps = get_ue_golomb_long(gb); @@ -1086,8 +1086,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return ret; } - sps->long_term_ref_pics_present_flag = get_bits1(gb); - if (sps->long_term_ref_pics_present_flag) { + sps->long_term_ref_pics_present = get_bits1(gb); + if (sps->long_term_ref_pics_present) { sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb); if (sps->num_long_term_ref_pics_sps > HEVC_MAX_LONG_TERM_REF_PICS) { av_log(avctx, AV_LOG_ERROR, "Too many long term ref pics: %d.\n", @@ -1102,54 +1102,53 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } } - sps->sps_temporal_mvp_enabled_flag = get_bits1(gb); - sps->sps_strong_intra_smoothing_enable_flag = get_bits1(gb); + sps->temporal_mvp_enabled = get_bits1(gb); + sps->strong_intra_smoothing_enabled = get_bits1(gb); sps->vui.common.sar = (AVRational){0, 1}; sps->vui_present = get_bits1(gb); if (sps->vui_present) decode_vui(gb, avctx, apply_defdispwin, sps); - sps->sps_extension_present_flag = get_bits1(gb); - if (sps->sps_extension_present_flag) { - sps->sps_range_extension_flag = get_bits1(gb); - sps->sps_multilayer_extension_flag = get_bits1(gb); - sps->sps_3d_extension_flag = get_bits1(gb); - sps->sps_scc_extension_flag = get_bits1(gb); + sps->extension_present = get_bits1(gb); + if (sps->extension_present) { + sps->range_extension = get_bits1(gb); + sps->multilayer_extension = get_bits1(gb); + sps->sps_3d_extension = get_bits1(gb); + sps->scc_extension = get_bits1(gb); skip_bits(gb, 4); // sps_extension_4bits - if (sps->sps_range_extension_flag) { - sps->transform_skip_rotation_enabled_flag = get_bits1(gb); - sps->transform_skip_context_enabled_flag = get_bits1(gb); - sps->implicit_rdpcm_enabled_flag = get_bits1(gb); + if (sps->range_extension) { + sps->transform_skip_rotation_enabled = get_bits1(gb); + sps->transform_skip_context_enabled = get_bits1(gb); + sps->implicit_rdpcm_enabled = get_bits1(gb); + sps->explicit_rdpcm_enabled = get_bits1(gb); - sps->explicit_rdpcm_enabled_flag = get_bits1(gb); - - sps->extended_precision_processing_flag = get_bits1(gb); - if (sps->extended_precision_processing_flag) + sps->extended_precision_processing = get_bits1(gb); + if (sps->extended_precision_processing) av_log(avctx, AV_LOG_WARNING, "extended_precision_processing_flag not yet implemented\n"); - sps->intra_smoothing_disabled_flag = get_bits1(gb); - sps->high_precision_offsets_enabled_flag = get_bits1(gb); - if (sps->high_precision_offsets_enabled_flag) + sps->intra_smoothing_disabled = get_bits1(gb); + sps->high_precision_offsets_enabled = get_bits1(gb); + if (sps->high_precision_offsets_enabled) av_log(avctx, AV_LOG_WARNING, "high_precision_offsets_enabled_flag not yet implemented\n"); - sps->persistent_rice_adaptation_enabled_flag = get_bits1(gb); + sps->persistent_rice_adaptation_enabled = get_bits1(gb); - sps->cabac_bypass_alignment_enabled_flag = get_bits1(gb); - if (sps->cabac_bypass_alignment_enabled_flag) + sps->cabac_bypass_alignment_enabled = get_bits1(gb); + if (sps->cabac_bypass_alignment_enabled) av_log(avctx, AV_LOG_WARNING, "cabac_bypass_alignment_enabled_flag not yet implemented\n"); } - if (sps->sps_multilayer_extension_flag) { + if (sps->multilayer_extension) { skip_bits1(gb); // inter_view_mv_vert_constraint_flag av_log(avctx, AV_LOG_WARNING, "sps_multilayer_extension_flag not yet implemented\n"); } - if (sps->sps_3d_extension_flag) { + if (sps->sps_3d_extension) { for (i = 0; i <= 1; i++) { skip_bits1(gb); // iv_di_mc_enabled_flag skip_bits1(gb); // iv_mv_scal_enabled_flag @@ -1173,15 +1172,15 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, "sps_3d_extension_flag not yet implemented\n"); } - if (sps->sps_scc_extension_flag) { - sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb); - sps->palette_mode_enabled_flag = get_bits1(gb); - if (sps->palette_mode_enabled_flag) { + if (sps->scc_extension) { + sps->curr_pic_ref_enabled = get_bits1(gb); + sps->palette_mode_enabled = get_bits1(gb); + if (sps->palette_mode_enabled) { sps->palette_max_size = get_ue_golomb(gb); sps->delta_palette_max_predictor_size = get_ue_golomb(gb); - sps->sps_palette_predictor_initializers_present_flag = get_bits1(gb); + sps->palette_predictor_initializers_present = get_bits1(gb); - if (sps->sps_palette_predictor_initializers_present_flag) { + if (sps->palette_predictor_initializers_present) { sps->sps_num_palette_predictor_initializers = get_ue_golomb(gb) + 1; if (sps->sps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) { av_log(avctx, AV_LOG_ERROR, @@ -1198,7 +1197,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } } sps->motion_vector_resolution_control_idc = get_bits(gb, 2); - sps->intra_boundary_filtering_disabled_flag = get_bits1(gb); + sps->intra_boundary_filtering_disabled = get_bits1(gb); } } if (apply_defdispwin) { diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index b2f3a8dbd1..9801b4347f 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -188,11 +188,9 @@ typedef struct ScalingList { typedef struct HEVCSPS { unsigned vps_id; int chroma_format_idc; - uint8_t separate_colour_plane_flag; HEVCWindow output_window; - uint8_t conformance_window_flag; HEVCWindow pic_conf_win; HEVCHdrParams hdr; @@ -203,32 +201,23 @@ typedef struct HEVCSPS { enum AVPixelFormat pix_fmt; unsigned int log2_max_poc_lsb; - int pcm_enabled_flag; - uint8_t sublayer_ordering_info_flag; int max_sub_layers; struct { int max_dec_pic_buffering; int num_reorder_pics; int max_latency_increase; } temporal_layer[HEVC_MAX_SUB_LAYERS]; - uint8_t temporal_id_nesting_flag; int vui_present; VUI vui; PTL ptl; - uint8_t sps_extension_present_flag; - uint8_t scaling_list_enable_flag; ScalingList scaling_list; unsigned int nb_st_rps; ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]; - uint8_t amp_enabled_flag; - uint8_t sao_enabled; - - uint8_t long_term_ref_pics_present_flag; uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS]; uint32_t used_by_curr_pic_lt; uint8_t num_long_term_ref_pics_sps; @@ -238,10 +227,7 @@ typedef struct HEVCSPS { uint8_t bit_depth_chroma; unsigned int log2_min_pcm_cb_size; unsigned int log2_max_pcm_cb_size; - uint8_t loop_filter_disable_flag; } pcm; - uint8_t sps_temporal_mvp_enabled_flag; - uint8_t sps_strong_intra_smoothing_enable_flag; unsigned int log2_min_cb_size; unsigned int log2_diff_max_min_coding_block_size; @@ -254,30 +240,44 @@ typedef struct HEVCSPS { int max_transform_hierarchy_depth_inter; int max_transform_hierarchy_depth_intra; - int sps_range_extension_flag; - int transform_skip_rotation_enabled_flag; - int transform_skip_context_enabled_flag; - int implicit_rdpcm_enabled_flag; - int explicit_rdpcm_enabled_flag; - int extended_precision_processing_flag; - int intra_smoothing_disabled_flag; - int high_precision_offsets_enabled_flag; - int persistent_rice_adaptation_enabled_flag; - int cabac_bypass_alignment_enabled_flag; + unsigned separate_colour_plane:1; + unsigned conformance_window:1; + unsigned pcm_enabled:1; + unsigned pcm_loop_filter_disabled:1; + unsigned sublayer_ordering_info:1; + unsigned temporal_id_nesting:1; + unsigned extension_present:1; + unsigned scaling_list_enabled:1; + unsigned amp_enabled:1; + unsigned sao_enabled:1; + unsigned long_term_ref_pics_present:1; + unsigned temporal_mvp_enabled:1; + unsigned strong_intra_smoothing_enabled:1; + unsigned range_extension:1; + unsigned transform_skip_rotation_enabled:1; + unsigned transform_skip_context_enabled:1; + unsigned implicit_rdpcm_enabled:1; + unsigned explicit_rdpcm_enabled:1; + unsigned extended_precision_processing:1; + unsigned intra_smoothing_disabled:1; + unsigned high_precision_offsets_enabled:1; + unsigned persistent_rice_adaptation_enabled:1; + unsigned cabac_bypass_alignment_enabled:1; - int sps_multilayer_extension_flag; - int sps_3d_extension_flag; + unsigned multilayer_extension:1; + unsigned sps_3d_extension:1; + + unsigned scc_extension:1; + unsigned curr_pic_ref_enabled:1; + unsigned palette_mode_enabled:1; + unsigned palette_predictor_initializers_present:1; + unsigned intra_boundary_filtering_disabled:1; - int sps_scc_extension_flag; - int sps_curr_pic_ref_enabled_flag; - int palette_mode_enabled_flag; int palette_max_size; int delta_palette_max_predictor_size; - int sps_palette_predictor_initializers_present_flag; int sps_num_palette_predictor_initializers; int sps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; int motion_vector_resolution_control_idc; - int intra_boundary_filtering_disabled_flag; ///< coded frame dimension in various units int width; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 4a7046bdec..eb03c45e8a 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -272,7 +272,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) int i; rps->nb_refs = 0; - if (!sps->long_term_ref_pics_present_flag) + if (!sps->long_term_ref_pics_present) return 0; if (sps->num_long_term_ref_pics_sps > 0) @@ -705,7 +705,7 @@ static int hls_slice_header(HEVCContext *s) if (s->ps.pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); - if (s->ps.sps->separate_colour_plane_flag) + if (s->ps.sps->separate_colour_plane) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(s)) { @@ -753,7 +753,7 @@ static int hls_slice_header(HEVCContext *s) } sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); - if (s->ps.sps->sps_temporal_mvp_enabled_flag) + if (s->ps.sps->temporal_mvp_enabled) sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); else sh->slice_temporal_mvp_enabled_flag = 0; @@ -2294,7 +2294,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i } if (lc->cu.pred_mode == MODE_INTRA) { - if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled_flag && + if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled && log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { pcm_flag = ff_hevc_pcm_flag_decode(lc); @@ -2302,7 +2302,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i if (pcm_flag) { intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size); ret = hls_pcm_sample(lc, x0, y0, log2_cb_size); - if (s->ps.sps->pcm.loop_filter_disable_flag) + if (s->ps.sps->pcm_loop_filter_disabled) set_deblocking_bypass(s, x0, y0, log2_cb_size); if (ret < 0) diff --git a/libavcodec/hevcpred_template.c b/libavcodec/hevcpred_template.c index 46bd806523..9082a816e0 100644 --- a/libavcodec/hevcpred_template.c +++ b/libavcodec/hevcpred_template.c @@ -285,14 +285,14 @@ do { \ top[-1] = left[-1]; // Filtering process - if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) { + if (!s->ps.sps->intra_smoothing_disabled && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) { if (mode != INTRA_DC && size != 4){ int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), FFABS((int)(mode - 10U))); if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { int threshold = 1 << (BIT_DEPTH - 5); - if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 && + if (s->ps.sps->strong_intra_smoothing_enabled && c_idx == 0 && log2_size == 5 && FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) { diff --git a/libavcodec/mips/hevcpred_msa.c b/libavcodec/mips/hevcpred_msa.c index b056ee986b..d9137519ad 100644 --- a/libavcodec/mips/hevcpred_msa.c +++ b/libavcodec/mips/hevcpred_msa.c @@ -2369,7 +2369,7 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx) top[-1] = left[-1]; - if (!s->ps.sps->intra_smoothing_disabled_flag + if (!s->ps.sps->intra_smoothing_disabled && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) { if (mode != INTRA_DC && 16 != 4) { int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; @@ -2886,7 +2886,7 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx) top[-1] = left[-1]; - if (!s->ps.sps->intra_smoothing_disabled_flag + if (!s->ps.sps->intra_smoothing_disabled && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) { if (mode != INTRA_DC && 32 != 4) { int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; @@ -2901,7 +2901,7 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx) 0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U)))))); if (min_dist_vert_hor > intra_hor_ver_dist_thresh[5 - 3]) { int threshold = 1 << (8 - 5); - if (s->ps.sps->sps_strong_intra_smoothing_enable_flag + if (s->ps.sps->strong_intra_smoothing_enabled && c_idx == 0 && ((top[-1] + top[63] - 2 * top[31]) >= 0 ? (top[-1] + top[63] - diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c index f26ced71ef..3d704666d0 100644 --- a/libavcodec/nvdec_hevc.c +++ b/libavcodec/nvdec_hevc.c @@ -105,44 +105,44 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx, .log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size, .log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2, .log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size, - .pcm_enabled_flag = sps->pcm_enabled_flag, - .log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm_enabled_flag ? sps->pcm.log2_min_pcm_cb_size - 3 : 0, + .pcm_enabled_flag = sps->pcm_enabled, + .log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm_enabled ? sps->pcm.log2_min_pcm_cb_size - 3 : 0, .log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size, - .pcm_sample_bit_depth_luma_minus1 = sps->pcm_enabled_flag ? sps->pcm.bit_depth - 1 : 0, - .pcm_sample_bit_depth_chroma_minus1 = sps->pcm_enabled_flag ? sps->pcm.bit_depth_chroma - 1 : 0, + .pcm_sample_bit_depth_luma_minus1 = sps->pcm_enabled ? sps->pcm.bit_depth - 1 : 0, + .pcm_sample_bit_depth_chroma_minus1 = sps->pcm_enabled ? sps->pcm.bit_depth_chroma - 1 : 0, #if NVDECAPI_CHECK_VERSION(8, 1) .log2_max_transform_skip_block_size_minus2 = pps->log2_max_transform_skip_block_size - 2, .log2_sao_offset_scale_luma = pps->log2_sao_offset_scale_luma, .log2_sao_offset_scale_chroma = pps->log2_sao_offset_scale_chroma, - .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled_flag, + .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled, #endif - .pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag, - .strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag, + .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled, + .strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled, .max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra, .max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter, - .amp_enabled_flag = sps->amp_enabled_flag, - .separate_colour_plane_flag = sps->separate_colour_plane_flag, + .amp_enabled_flag = sps->amp_enabled, + .separate_colour_plane_flag = sps->separate_colour_plane, .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4, .num_short_term_ref_pic_sets = sps->nb_st_rps, - .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag, + .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present, .num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps, - .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag, + .sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled, .sample_adaptive_offset_enabled_flag = sps->sao_enabled, - .scaling_list_enable_flag = sps->scaling_list_enable_flag, + .scaling_list_enable_flag = sps->scaling_list_enabled, .IrapPicFlag = IS_IRAP(s), .IdrPicFlag = IS_IDR(s), .bit_depth_luma_minus8 = sps->bit_depth - 8, .bit_depth_chroma_minus8 = sps->bit_depth - 8, #if NVDECAPI_CHECK_VERSION(9, 0) - .sps_range_extension_flag = sps->sps_range_extension_flag, - .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled_flag, - .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled_flag, - .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled_flag, - .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled_flag, - .extended_precision_processing_flag = sps->extended_precision_processing_flag, - .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled_flag, - .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled_flag, - .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled_flag, + .sps_range_extension_flag = sps->range_extension, + .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled, + .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled, + .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled, + .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled, + .extended_precision_processing_flag = sps->extended_precision_processing, + .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled, + .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled, + .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled, #endif .dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 2ccbe0464b..40cff6335a 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -108,7 +108,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) /* generate the VPS */ vps.vps_max_layers = 1; vps.vps_max_sub_layers = sps.max_sub_layers; - vps.vps_temporal_id_nesting_flag = sps.temporal_id_nesting_flag; + vps.vps_temporal_id_nesting_flag = sps.temporal_id_nesting; memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl)); vps.vps_sub_layer_ordering_info_present_flag = 1; for (i = 0; i < HEVC_MAX_SUB_LAYERS; i++) { diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index 3bdd2dd1b8..5af297c2af 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -171,12 +171,12 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, .pic_fields.bits = { .chroma_format_idc = sps->chroma_format_idc, .tiles_enabled_flag = pps->tiles_enabled_flag, - .separate_colour_plane_flag = sps->separate_colour_plane_flag, - .pcm_enabled_flag = sps->pcm_enabled_flag, - .scaling_list_enabled_flag = sps->scaling_list_enable_flag, + .separate_colour_plane_flag = sps->separate_colour_plane, + .pcm_enabled_flag = sps->pcm_enabled, + .scaling_list_enabled_flag = sps->scaling_list_enabled, .transform_skip_enabled_flag = pps->transform_skip_enabled_flag, - .amp_enabled_flag = sps->amp_enabled_flag, - .strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag, + .amp_enabled_flag = sps->amp_enabled, + .strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled, .sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag, .constrained_intra_pred_flag = pps->constrained_intra_pred_flag, .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag, @@ -186,12 +186,12 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag, .pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag, .loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag, - .pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag, + .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled, }, .slice_parsing_fields.bits = { .lists_modification_present_flag = pps->lists_modification_present_flag, - .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag, - .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag, + .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present, + .sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled, .cabac_init_present_flag = pps->cabac_init_present_flag, .output_flag_present_flag = pps->output_flag_present_flag, .dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag, @@ -231,15 +231,15 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, avctx->profile == AV_PROFILE_HEVC_SCC) { pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) { .range_extension_pic_fields.bits = { - .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled_flag, - .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled_flag, - .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled_flag, - .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled_flag, - .extended_precision_processing_flag = sps->extended_precision_processing_flag, - .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled_flag, - .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled_flag, - .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled_flag, - .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled_flag, + .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled, + .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled, + .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled, + .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled, + .extended_precision_processing_flag = sps->extended_precision_processing, + .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled, + .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled, + .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled, + .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled, .cross_component_prediction_enabled_flag = pps->cross_component_prediction_enabled_flag, .chroma_qp_offset_list_enabled_flag = pps->chroma_qp_offset_list_enabled_flag, }, @@ -258,7 +258,7 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ? pps->pps_num_palette_predictor_initializers : - (sps->sps_palette_predictor_initializers_present_flag ? + (sps->palette_predictor_initializers_present ? sps->sps_num_palette_predictor_initializers : 0); @@ -266,9 +266,9 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, pic->pic_param.scc = (VAPictureParameterBufferHEVCScc) { .screen_content_pic_fields.bits = { .pps_curr_pic_ref_enabled_flag = pps->pps_curr_pic_ref_enabled_flag, - .palette_mode_enabled_flag = sps->palette_mode_enabled_flag, + .palette_mode_enabled_flag = sps->palette_mode_enabled, .motion_vector_resolution_control_idc = sps->motion_vector_resolution_control_idc, - .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled_flag, + .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled, .residual_adaptive_colour_transform_enabled_flag = pps->residual_adaptive_colour_transform_enabled_flag, .pps_slice_act_qp_offsets_present_flag = pps->pps_slice_act_qp_offsets_present_flag, @@ -305,7 +305,7 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, if (pps->scaling_list_data_present_flag) scaling_list = &pps->scaling_list; - else if (sps->scaling_list_enable_flag) + else if (sps->scaling_list_enabled) scaling_list = &sps->scaling_list; if (scaling_list) { diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c index 4cd7ce5621..b029f9c42e 100644 --- a/libavcodec/vdpau_hevc.c +++ b/libavcodec/vdpau_hevc.c @@ -53,7 +53,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, /* SPS */ info->chroma_format_idc = sps->chroma_format_idc; - info->separate_colour_plane_flag = sps->separate_colour_plane_flag; + info->separate_colour_plane_flag = sps->separate_colour_plane; info->pic_width_in_luma_samples = sps->width; info->pic_height_in_luma_samples = sps->height; info->bit_depth_luma_minus8 = sps->bit_depth - 8; @@ -68,7 +68,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, info->log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size; info->max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter; info->max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra; - info->scaling_list_enabled_flag = sps->scaling_list_enable_flag; + info->scaling_list_enabled_flag = sps->scaling_list_enabled; /* Scaling lists, in diagonal order, to be used for this frame. */ for (size_t i = 0; i < 6; i++) { for (size_t j = 0; j < 16; j++) { @@ -100,9 +100,9 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, info->ScalingListDCCoeff32x32[i] = sl->sl_dc[1][i * 3]; } } - info->amp_enabled_flag = sps->amp_enabled_flag; + info->amp_enabled_flag = sps->amp_enabled; info->sample_adaptive_offset_enabled_flag = sps->sao_enabled; - info->pcm_enabled_flag = sps->pcm_enabled_flag; + info->pcm_enabled_flag = sps->pcm_enabled; if (info->pcm_enabled_flag) { /* Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ info->pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1; @@ -113,17 +113,17 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, /* Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ info->log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size; /* Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ - info->pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag; + info->pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled; } /* Per spec, when zero, assume short_term_ref_pic_set_sps_flag is also zero. */ info->num_short_term_ref_pic_sets = sps->nb_st_rps; - info->long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag; + info->long_term_ref_pics_present_flag = sps->long_term_ref_pics_present; /* Only needed if long_term_ref_pics_present_flag is set. Ignored otherwise. */ info->num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps; - info->sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag; - info->strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag; + info->sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled; + info->strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled; /* Copy the HEVC Picture Parameter Set bitstream fields. */ info->dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag; @@ -360,17 +360,17 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx, } #ifdef VDP_YCBCR_FORMAT_Y_U_V_444 - if (sps->sps_range_extension_flag) { + if (sps->range_extension) { info2->sps_range_extension_flag = 1; - info2->transformSkipRotationEnableFlag = sps->transform_skip_rotation_enabled_flag; - info2->transformSkipContextEnableFlag = sps->transform_skip_context_enabled_flag; - info2->implicitRdpcmEnableFlag = sps->implicit_rdpcm_enabled_flag; - info2->explicitRdpcmEnableFlag = sps->explicit_rdpcm_enabled_flag; - info2->extendedPrecisionProcessingFlag = sps->extended_precision_processing_flag; - info2->intraSmoothingDisabledFlag = sps->intra_smoothing_disabled_flag; - info2->highPrecisionOffsetsEnableFlag = sps->high_precision_offsets_enabled_flag; - info2->persistentRiceAdaptationEnableFlag = sps->persistent_rice_adaptation_enabled_flag; - info2->cabacBypassAlignmentEnableFlag = sps->cabac_bypass_alignment_enabled_flag; + info2->transformSkipRotationEnableFlag = sps->transform_skip_rotation_enabled; + info2->transformSkipContextEnableFlag = sps->transform_skip_context_enabled; + info2->implicitRdpcmEnableFlag = sps->implicit_rdpcm_enabled; + info2->explicitRdpcmEnableFlag = sps->explicit_rdpcm_enabled; + info2->extendedPrecisionProcessingFlag = sps->extended_precision_processing; + info2->intraSmoothingDisabledFlag = sps->intra_smoothing_disabled; + info2->highPrecisionOffsetsEnableFlag = sps->high_precision_offsets_enabled; + info2->persistentRiceAdaptationEnableFlag = sps->persistent_rice_adaptation_enabled; + info2->cabacBypassAlignmentEnableFlag = sps->cabac_bypass_alignment_enabled; } else { info2->sps_range_extension_flag = 0; } diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index 9b40f5ad58..df86049d22 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -395,36 +395,36 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, *vksps = (StdVideoH265SequenceParameterSet) { .flags = (StdVideoH265SpsFlags) { - .sps_temporal_id_nesting_flag = sps->temporal_id_nesting_flag, - .separate_colour_plane_flag = sps->separate_colour_plane_flag, - .conformance_window_flag = sps->conformance_window_flag, - .sps_sub_layer_ordering_info_present_flag = sps->sublayer_ordering_info_flag, - .scaling_list_enabled_flag = sps->scaling_list_enable_flag, - .sps_scaling_list_data_present_flag = sps->scaling_list_enable_flag, - .amp_enabled_flag = sps->amp_enabled_flag, + .sps_temporal_id_nesting_flag = sps->temporal_id_nesting, + .separate_colour_plane_flag = sps->separate_colour_plane, + .conformance_window_flag = sps->conformance_window, + .sps_sub_layer_ordering_info_present_flag = sps->sublayer_ordering_info, + .scaling_list_enabled_flag = sps->scaling_list_enabled, + .sps_scaling_list_data_present_flag = sps->scaling_list_enabled, + .amp_enabled_flag = sps->amp_enabled, .sample_adaptive_offset_enabled_flag = sps->sao_enabled, - .pcm_enabled_flag = sps->pcm_enabled_flag, - .pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag, - .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag, - .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag, - .strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag, + .pcm_enabled_flag = sps->pcm_enabled, + .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled, + .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present, + .sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled, + .strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled, .vui_parameters_present_flag = sps->vui_present, - .sps_extension_present_flag = sps->sps_extension_present_flag, - .sps_range_extension_flag = sps->sps_range_extension_flag, - .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled_flag, - .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled_flag, - .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled_flag, - .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled_flag, - .extended_precision_processing_flag = sps->extended_precision_processing_flag, - .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled_flag, - .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled_flag, - .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled_flag, - .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled_flag, - .sps_scc_extension_flag = sps->sps_scc_extension_flag, - .sps_curr_pic_ref_enabled_flag = sps->sps_curr_pic_ref_enabled_flag, - .palette_mode_enabled_flag = sps->palette_mode_enabled_flag, - .sps_palette_predictor_initializers_present_flag = sps->sps_palette_predictor_initializers_present_flag, - .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled_flag, + .sps_extension_present_flag = sps->extension_present, + .sps_range_extension_flag = sps->range_extension, + .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled, + .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled, + .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled, + .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled, + .extended_precision_processing_flag = sps->extended_precision_processing, + .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled, + .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled, + .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled, + .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled, + .sps_scc_extension_flag = sps->scc_extension, + .sps_curr_pic_ref_enabled_flag = sps->curr_pic_ref_enabled, + .palette_mode_enabled_flag = sps->palette_mode_enabled, + .sps_palette_predictor_initializers_present_flag = sps->palette_predictor_initializers_present, + .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled, }, .chroma_format_idc = sps->chroma_format_idc, .pic_width_in_luma_samples = sps->width, From patchwork Wed Apr 10 13:31: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: 48002 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557124pzb; Wed, 10 Apr 2024 06:32:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVv8XSDB+0wMAObX0Ij8EuP3dy+W8OrpIAjmROpD4bfyP17qMhZx9IdZ5UvvibqjhxACM0vd8OsvbKIlb8+L4UgfZhD0FjvBNvqCw== X-Google-Smtp-Source: AGHT+IGfzHcGrS7YQLU9nc7pytcoNVrPQox+b2zQsGP8DSRgpErIrI3yc/o5sk7GTq8P/Oy9heOR X-Received: by 2002:a2e:7808:0:b0:2d8:1b2a:6526 with SMTP id t8-20020a2e7808000000b002d81b2a6526mr1871865ljc.4.1712755945419; Wed, 10 Apr 2024 06:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755945; cv=none; d=google.com; s=arc-20160816; b=NNfTzQucEFrPyxgLnzvv2MUOtFOcdgMlsaORFt1B/DmHeSNl0Ju2uBy3ZxpzvNpPXq GxMbBD8hYDJy2NBqEChrvfJWAJXwEG2YaPudoCarc0WKzCjjgLVqpwXLjbGNR1avPMJe pYJU416LMstyxDy1FTU+/HKiNOCGq0qw76hLEtRWgWsgd9Gc/iOraA0EunvHSGkRA0Mh 7D9ZIDxB/Ja/9q2EEyqn6DYe1SuUkI9863ePv7lMlrji+lG9GR57Jju9hnGiobMGx90M /S6akzt8GUTmDvDiDZBahgEaZnMVzGYNlw/ySqMkfP0UmWegljZqnNoVEZhfxuyCiCyV fAqw== 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=n89kPwXCnmvL4n47CaM/EvPHqykFM7eGpG663JRRJqQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=as/hTmKwedXwmZcfDd9hDWSqZz+3N7WJfQ6mgEkiAnKgv672venkbn8D7z/veTkzrd UVM4PsSYjaNGjC5ZkQ4ArMfVQmQ9POMfVq/w/dB4sCVvBjXYclqc2niDObRMuOQwaEMu bNc+VbfLCwujJM/77S2R0Yp9XTIX+5sPxZ+tGSCAtxDdUDDMhrZXUkOMCmdVR+5I8/TU EqSOI5a7uue8aofhzICYXHRJkG6X9HBtE57ibzADzwi0bpd2dSs1DRMHdjy+uwgeTK8f /TXfHC6pmM1gWrL+6Li+yj0fWjvuBm4AcRlq44M5Mxgvn0OoWfL9Gf/L6uYHoEW0xhmK GBEA==; 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=XkhUYrHv; 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 2-20020a05651c00c200b002d6b3f5cdb5si330076ljr.192.2024.04.10.06.32.24; Wed, 10 Apr 2024 06:32:25 -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=XkhUYrHv; 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 3DF6D68D15D; Wed, 10 Apr 2024 16:31:39 +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 4D4D468CEE6 for ; Wed, 10 Apr 2024 16:31:32 +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=XkhUYrHv; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 341384D76 for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id JxKNfof3G_za for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=qA0AuMxYm78poykhZjKwFh+DOADjTReX+N8NqWCqBbk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XkhUYrHvmbdvVWelsQfDQNN21sxMciANGqLVRJjmcgkwFnvUnEwz4pvrLr3ySNSdy df/x5qvDqhfUNYQoHbDMakMNHWhHBx7y30hb+c8xLSLKyn8zD0wgDWPYRZTXahLlhI wHvCBHMq106enI59g1CFWwMukHoTfNObEH2rTXNQUoDZ63YaLTJweXY4SexHPskLS1 BZytw4SixnpSESUvl8SuqIMZQgIYDMmFz6Nshm5mDuDJOiFnR0icP5Y82FOw13mK+B jUtP7YJlhQXXlKMk8QXJPeaMYJ8Dj53pWety5cjTKC9HyWK4YWTmfmfIK4GmG+quM2 LJk/06GqgGCXQ== 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 E01664D79 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C98643A0379 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:15 +0200 Message-ID: <20240410133118.28144-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10] lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps() 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: cEn6qARusLlw It is actually supposed to go negative in the loop over num_negative pics, but underflow does not break anything as the result is then assigned to a signed int. --- libavcodec/hevc_ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 1af691414e..d90f172c46 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -197,7 +197,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } } } else { - unsigned int prev, nb_positive_pics; + unsigned int nb_positive_pics; + rps->num_negative_pics = get_ue_golomb_long(gb); nb_positive_pics = get_ue_golomb_long(gb); @@ -209,7 +210,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics; if (rps->num_delta_pocs) { - prev = 0; + int prev = 0; + for (i = 0; i < rps->num_negative_pics; i++) { delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) { From patchwork Wed Apr 10 13:31:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48003 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557198pzb; Wed, 10 Apr 2024 06:32:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/j9rhGYVjoN5uDj6LbrZd1aIFTWAoSXVY2qzuU5DG7KU2h6fPzF+ZuXRDKWU9vnqUfA+yUWQn2R41lbErkNX/5lEK7ZLqw2/YBw== X-Google-Smtp-Source: AGHT+IEPQsoZsPBdC6qYlvnnE8CGV/25qndWys54Ipzbzz6/WRAYHcKdV/s0WYw4jK4fyJLCfwIi X-Received: by 2002:a19:ad03:0:b0:513:e7ff:15b8 with SMTP id t3-20020a19ad03000000b00513e7ff15b8mr1862818lfc.51.1712755952671; Wed, 10 Apr 2024 06:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755952; cv=none; d=google.com; s=arc-20160816; b=lBlCF0McBso7QGCKP1kqHQGUa1rVudeFg154ITyi2vBmxoTkNQ9TW+S8DltkoB6t+a Mrc6l0BH1Xn6HrwloZOUNIXGBuEfGkgvWoI6miprEmhbU4yFebPj5cX2YL8zOD5xjIDf qEax5SncAovnpDh8MGZbbVVgouNevcBXBfndI8FHFg2rawKc9YD/PWJoXuW3ifOeYEdS LIN+VXEGxZvspw/bRgxgGP/d4WGKsjpg900PHVNPjC36JhdsnbZUZ/d1veV+KbajCrag pfpnUcdIhZPeRpkw7bgLXQfQwSgc7dN+6DV47dYNeeO9P+H/pIFWXcW3Ure/SU/h/Ele oiXg== 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=998qv2vyx3hzk6a0n0HVwOkcbhVQ2XlgtC72Y3q3/1M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=nzCDJuNJSZjT+cG+5g7BjDSDueCF4OJhhqsuk3YRMqXw+A6AjTn6LtVAs/ch5tQKl5 RzXpqXzUjESIlxkgNl7q9k954+v8fBoAR/XJN9k8wfku2xNhh2yELRMX7BhhgSAN+U0A +ogC1oLeMLz7i3p2FhsdYi6dd/ALDMPYJo55qJOmMe8XS8JKhJhBNCqIMRg+hVG+Fl+a 41Ihf6uQ9Z0QlEQ2GK/ykLHMRcYfA+XpX1XAllVT24oQfUlEG+Gw1Hja65/4x6l+xi6t 7HrxytvUlvZjdB1QxkUT3SV1K2aYbaWNVTEtmtYuVZMj0g7drYM7dSE0L5pOCLDgv/Tq xMpg==; 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=du2+zV99; 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 v9-20020a056402348900b00568cd675c8csi5747444edc.103.2024.04.10.06.32.32; Wed, 10 Apr 2024 06:32:32 -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=du2+zV99; 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 493E568D1A6; Wed, 10 Apr 2024 16:31:40 +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 4DDB168CEEB for ; Wed, 10 Apr 2024 16:31:32 +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=du2+zV99; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 854C04D79 for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id WentNKNXyHct for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=zG6oIdIbhuL8Lv4ZGLvcwvl8qVywMTPXpFABD2MHVcY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=du2+zV99K1xBwaDe9oZRbNo0n5pDWKYH7MdnTCIwgwO0bIClqtx+pOzkkOLlT5Wul omgYrRZs5bQb8v4wSTT5jGpkZDaSfpZEvXkRiCpekVfcZncb4aj/aZEYdtQFJtlDOA 1u1OqPB+9fZ8JXKfZi6OnFfcoZ0MdPticLligQ+oHIQVlgfJQv/GYo3GeFzxAKrbFf sDtpMSV/D7Yfj9SM4Mtng3O++7coBZ1qE4SbzLeWwdx9V6dS4Ym7IGfWkxT9TR7hOZ fTPXLwyvBVYO018phRFcOVvt45A/qqw8k30IwLSksMbOBX9SbD86N7ZpXjxKR9Oga5 99K/k+qT06e/Q== 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 E2F7E4D7E for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D52763A0552 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:16 +0200 Message-ID: <20240410133118.28144-8-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/10] lavc/hevc_ps: do not store delta_poc_s[01] in ShortTermRPS 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: IGojBRC7ijd2 They are only used in vulkan_hevc and are not actually needed, as they can be computed from delta_poc. Reduces sizeof(HEVCSPS) by 16kB. --- libavcodec/hevc_ps.c | 4 ++-- libavcodec/hevc_ps.h | 2 -- libavcodec/vulkan_hevc.c | 7 +++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index d90f172c46..a6b0021bc3 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -213,7 +213,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, int prev = 0; for (i = 0; i < rps->num_negative_pics; i++) { - delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1; + delta_poc = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) { av_log(avctx, AV_LOG_ERROR, "Invalid value of delta_poc: %d\n", @@ -226,7 +226,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } prev = 0; for (i = 0; i < nb_positive_pics; i++) { - delta_poc = rps->delta_poc_s1[i] = get_ue_golomb_long(gb) + 1; + delta_poc = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) { av_log(avctx, AV_LOG_ERROR, "Invalid value of delta_poc: %d\n", diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 9801b4347f..6ef29a8ea7 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -78,8 +78,6 @@ typedef struct ShortTermRPS { unsigned int num_negative_pics; int num_delta_pocs; int rps_idx_num_delta_pocs; - int32_t delta_poc_s0[32]; - int32_t delta_poc_s1[32]; int32_t delta_poc[32]; uint8_t used[32]; } ShortTermRPS; diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index df86049d22..5d7c6b1b64 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -351,6 +351,8 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, pal->PredictorPaletteEntries[i][j] = sps->sps_palette_predictor_initializer[i][j]; for (int i = 0; i < sps->nb_st_rps; i++) { + const ShortTermRPS *st_rps = &sps->st_rps[i]; + str[i] = (StdVideoH265ShortTermRefPicSet) { .flags = (StdVideoH265ShortTermRefPicSetFlags) { .inter_ref_pic_set_prediction_flag = sps->st_rps[i].rps_predict, @@ -375,12 +377,13 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j; for (int j = 0; j < str[i].num_negative_pics; j++) { - str[i].delta_poc_s0_minus1[j] = sps->st_rps[i].delta_poc_s0[j] - 1; + str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? st_rps->delta_poc[j - 1] : 0) - 1; str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j; } for (int j = 0; j < str[i].num_positive_pics; j++) { - str[i].delta_poc_s1_minus1[j] = sps->st_rps[i].delta_poc_s1[j] - 1; + str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[st_rps->num_negative_pics + j] - + (j ? st_rps->delta_poc[st_rps->num_negative_pics + j - 1] : 0) - 1; str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[str[i].num_negative_pics + j] << j; } } From patchwork Wed Apr 10 13:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47996 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557283pzb; Wed, 10 Apr 2024 06:32:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdSe76YaMisEGg/ngWZOXnlwMdr3z07M2lLlP/yWweJ4oHU+gwpARJWFqWH54k6JSRVQCM8G8KHF7gykzdxG+npuP51U62byZjnw== X-Google-Smtp-Source: AGHT+IGFGZuZjOER+as0qen6de7fDNeOu8Axk/224wcdy7vECrXkDh30SXlld6Y9ekeFbwBZjEkr X-Received: by 2002:ac2:5bc8:0:b0:513:a479:3ad9 with SMTP id u8-20020ac25bc8000000b00513a4793ad9mr1630979lfn.55.1712755961653; Wed, 10 Apr 2024 06:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755961; cv=none; d=google.com; s=arc-20160816; b=pgep8x95kADtXLG/0q4J+YDf46JFHY7z4sDx/+NccFRj/22jFqrO5mCeXnep6geBDc FUk+q/DdyPWJDUpip5+secBz+eMT46fi9hJ7R8HEr/+SH3exaClMkN3Cxm47Pt6MvZYc dP4VIBK+keHdtm8vNf/5sRX811EjyFDGsANV7GdImmFU4dOeQ5CjatkpWoVccLSKBex0 yjHemsLVvQpEtmDCe1apUdMEUSRIYUG7fVxOsjriYMfi2aPkYVpKKH00p2HQU5lCEWTG yqutRMTiRxuCpsYl44w36BUYI2TVV2WndoKgQvMeNQ67qzrSJMKiNbFvtNcH36FTyolK 2zpQ== 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=6MW1u7biWuo5J8daYi7vD/Aa9srQ7jIUgTDEs9hLvjE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BIQGWnbMk5GL6fki23qd0pb91IavedFCSEK+p3m8rv1n4Zwa9+XKiK2ZmbIDQbuwhS 0OlvTbHibFdpQRaerZjmBK3I2VxsjIzEdr1yVZzot3D/sT8lxR0ozOR2PV+rPH2Kbxe6 RErL9QGeSWDkWmMZY0WFdn37RPvZ4KtHSBGAtM/mmCRqi1n6CTbQnBgSFOw5bNqlnhvX zh1DYpoUMp2Dng6kvJfVqgAkeqNEsYRLEFsg8EaB4Zc6vyUsnmZ2SrF5DaR6xJlDR0mS L1LcBjJSce+tDPOHJeBFY9p3JcKwirV6lobpVRzPHsCxNxp3+17fPVgvFHGBZlB1V7cW GJxQ==; 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=pxmOUcHM; 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 c2-20020a056512104200b0051700381c4bsi2333763lfb.482.2024.04.10.06.32.41; Wed, 10 Apr 2024 06:32:41 -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=pxmOUcHM; 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 57B5968D1C4; Wed, 10 Apr 2024 16:31:41 +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 4E60568CF68 for ; Wed, 10 Apr 2024 16:31:33 +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=pxmOUcHM; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4BDA24D78 for ; Wed, 10 Apr 2024 15:31:28 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id tSQ1iLexh4Pu for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755885; bh=5vVEyirYXPopdj9r03tB8hgQ/4c1t6UUyaMMPR0DxRs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pxmOUcHM0xpzyvwkohgbZiw4xwOZF1RNOqF64g2gwzA4PqALYfDQtwNMrvbz/XGEA UJXcAfDG3UA06yGUnogq8PQJpz7+lDg9vnEFriSxwDBvgy8RsXdYaK0epz3vDlyswn e4/+76oq8tgkFcEwkOXVk9nepuHYZBn1s+JOVM+m+xwq+/Do/Z/rfC+ztNoY8goDkS qKSM7UfVHI+XVNWRU1LkDG7MVeWKKYztWqQ9CDftGSbeWyp4UfvqgDjML3SryIPfZ5 8Wf1TKBeh4xYv9uDUc3xtoCxfdaJUtqBybJOVmdX1mbdtSHMIM4HUAjWP7e8wr3e28 b7Q/IsOBg+CwA== 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 EBD0B4D82 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DFF163A059B for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:17 +0200 Message-ID: <20240410133118.28144-9-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/10] lavc/hevc_ps: reduce the size of ShortTermRPS.used 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: Cyb7DbHAi4B3 It is currently an array of 32 uint8_t, each storing a single flag. A single uint32_t is sufficient. Reduces sizeof(HEVCSPS) by 1792 bytes. --- libavcodec/hevc_ps.c | 33 +++++++++++++++++++-------------- libavcodec/hevc_ps.h | 2 +- libavcodec/hevc_refs.c | 6 +++--- libavcodec/vulkan_hevc.c | 8 ++++---- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index a6b0021bc3..76fe507e7b 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -107,6 +107,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, int k = 0; int i; + rps->used = 0; rps->rps_predict = 0; if (rps != sps->st_rps && sps->nb_st_rps) @@ -114,6 +115,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, if (rps->rps_predict) { const ShortTermRPS *rps_ridx; + uint8_t used[32] = { 0 }; int delta_rps; if (is_slice_header) { @@ -139,13 +141,13 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } delta_rps = (1 - (rps->delta_rps_sign << 1)) * rps->abs_delta_rps; for (i = 0; i <= rps_ridx->num_delta_pocs; i++) { - int used = rps->used[k] = get_bits1(gb); + used[k] = get_bits1(gb); rps->use_delta_flag = 0; - if (!used) + if (!used[k]) rps->use_delta_flag = get_bits1(gb); - if (used || rps->use_delta_flag) { + if (used[k] || rps->use_delta_flag) { if (i < rps_ridx->num_delta_pocs) delta_poc = delta_rps + rps_ridx->delta_poc[i]; else @@ -157,7 +159,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } } - if (k >= FF_ARRAY_ELEMS(rps->used)) { + if (k >= FF_ARRAY_ELEMS(used)) { av_log(avctx, AV_LOG_ERROR, "Invalid num_delta_pocs: %d\n", k); return AVERROR_INVALIDDATA; @@ -167,35 +169,38 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, rps->num_negative_pics = k0; // sort in increasing order (smallest first) if (rps->num_delta_pocs != 0) { - int used, tmp; + int u, tmp; for (i = 1; i < rps->num_delta_pocs; i++) { delta_poc = rps->delta_poc[i]; - used = rps->used[i]; + u = used[i]; for (k = i - 1; k >= 0; k--) { tmp = rps->delta_poc[k]; if (delta_poc < tmp) { rps->delta_poc[k + 1] = tmp; - rps->used[k + 1] = rps->used[k]; + used[k + 1] = used[k]; rps->delta_poc[k] = delta_poc; - rps->used[k] = used; + used[k] = u; } } } } if ((rps->num_negative_pics >> 1) != 0) { - int used; + int u; k = rps->num_negative_pics - 1; // flip the negative values to largest first for (i = 0; i < rps->num_negative_pics >> 1; i++) { delta_poc = rps->delta_poc[i]; - used = rps->used[i]; + u = used[i]; rps->delta_poc[i] = rps->delta_poc[k]; - rps->used[i] = rps->used[k]; + used[i] = used[k]; rps->delta_poc[k] = delta_poc; - rps->used[k] = used; + used[k] = u; k--; } } + + for (unsigned i = 0; i < FF_ARRAY_ELEMS(used); i++) + rps->used |= used[i] * (1 << i); } else { unsigned int nb_positive_pics; @@ -222,7 +227,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } prev -= delta_poc; rps->delta_poc[i] = prev; - rps->used[i] = get_bits1(gb); + rps->used |= get_bits1(gb) * (1 << i); } prev = 0; for (i = 0; i < nb_positive_pics; i++) { @@ -235,7 +240,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } prev += delta_poc; rps->delta_poc[rps->num_negative_pics + i] = prev; - rps->used[rps->num_negative_pics + i] = get_bits1(gb); + rps->used |= get_bits1(gb) * (1 << (rps->num_negative_pics + i)); } } } diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 6ef29a8ea7..92b85115f7 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -79,7 +79,7 @@ typedef struct ShortTermRPS { int num_delta_pocs; int rps_idx_num_delta_pocs; int32_t delta_poc[32]; - uint8_t used[32]; + uint32_t used; } ShortTermRPS; typedef struct HEVCWindow { diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index aed649933d..19f3fa81da 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -501,7 +501,7 @@ int ff_hevc_frame_rps(HEVCContext *s) int poc = s->poc + short_rps->delta_poc[i]; int list; - if (!short_rps->used[i]) + if (!(short_rps->used & (1 << i))) list = ST_FOLL; else if (i < short_rps->num_negative_pics) list = ST_CURR_BEF; @@ -540,9 +540,9 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s) if (rps) { for (i = 0; i < rps->num_negative_pics; i++) - ret += !!rps->used[i]; + ret += !!(rps->used & (1 << i)); for (; i < rps->num_delta_pocs; i++) - ret += !!rps->used[i]; + ret += !!(rps->used & (1 << i)); } if (long_rps) { diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index 5d7c6b1b64..c2b65fc201 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -374,17 +374,17 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, /* NOTE: This is the predicted, and *reordered* version. * Probably incorrect, but the spec doesn't say which version to use. */ for (int j = 0; j < sps->st_rps[i].num_delta_pocs; j++) - str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j; + str[i].used_by_curr_pic_flag |= st_rps->used; for (int j = 0; j < str[i].num_negative_pics; j++) { - str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? st_rps->delta_poc[j - 1] : 0) - 1; - str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j; + str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? st_rps->delta_poc[j - 1] : 0) - 1; + str[i].used_by_curr_pic_s0_flag |= st_rps->used & ((1 << str[i].num_negative_pics) - 1); } for (int j = 0; j < str[i].num_positive_pics; j++) { str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[st_rps->num_negative_pics + j] - (j ? st_rps->delta_poc[st_rps->num_negative_pics + j - 1] : 0) - 1; - str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[str[i].num_negative_pics + j] << j; + str[i].used_by_curr_pic_s0_flag |= st_rps->used >> str[i].num_negative_pics; } } From patchwork Wed Apr 10 13:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48004 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557341pzb; Wed, 10 Apr 2024 06:32:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVoUYpiK0b21Fweoz1AO2+ljJIQsbgnSlmC9NaguhnjTKrchTm1gge0j4PXyzNJqDpvM9ohR5mAjkaNXJRv+RLgKqRWhRdAFH+ycw== X-Google-Smtp-Source: AGHT+IFbfBoa6PvEzTVVo362pGOBneeBymWoncwtYDVLNFCqJ/6pOYO4/NX1fEcgbHcNMSrTKthp X-Received: by 2002:a17:906:18b2:b0:a51:b228:9282 with SMTP id c18-20020a17090618b200b00a51b2289282mr1527868ejf.44.1712755969382; Wed, 10 Apr 2024 06:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755969; cv=none; d=google.com; s=arc-20160816; b=k7BrliNYqXfg2NskcHJuWw3NrgbP/+0D+5hfjIYr5fE4QQvNkGWAhIDOgttuLBip8P 1ICT2WYQNMjaVKPqQgWpcEOL7CsDKdiPrEbVwXCltHsHWYdnF5SWh5fxZkeToRyAWPOb 6BvQZGAXm04Xqx4kbDGiZncO+rm4xYd3P1N1Uo6OliYwqFy3tdNJoDl6Qzk/r42spJrr zvrVA2Bohp0QcQ5SFZwHkJrwLZIfVjoXy3VXZtriDoVOa4vnU6Gy4GJmdq1xQvrrMU0C ADKW86aKIseOOH1hq4aktDQEBBIJuPa6DITGVjSv0sHxrCCYyzsQpoGRlCdv8v8S3FdG gNSA== 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=co99isVAMTiKuNFkBSzEyRDgTXI1KyFILH+R7m171/k=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eHUNyqYcWHTdcIR0teMDwGNvluGmrAUV6hH3/oqVwP8So1KUYdkjafWlB1ysupr7bS Di1eQ60tUUyKH3Q9M022jp9BPTC7VR25PJhfZD9fR+F4XBiNAS2f0ODW3nf7DOYZybsM cVQ0c0iGajoBo7Ve0TSBgzTsQRuRVpfWnSPL5nyPoqbTv8q2LJEM+FBcqBDiCNGMnBCw K5Q8nFvvg5fvXKuTKhCwKCRVAqN+2fG7PM1lwd2qWIuQ29seCJd6EtL4VQG8w7GgwJtH VrZESUw9Ip4fSdMd4/OCKTHAJ+l6OvgcX4BbAw6tF264x4t/LplZ+yN1NH9zvWO1wrSr ls3Q==; 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=A3lrZf20; 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 m4-20020a1709066d0400b00a519055c375si5887534ejr.152.2024.04.10.06.32.49; Wed, 10 Apr 2024 06:32:49 -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=A3lrZf20; 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 6C11868D1CF; Wed, 10 Apr 2024 16:31:42 +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 4E12E68CF45 for ; Wed, 10 Apr 2024 16:31:33 +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=A3lrZf20; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id CEF604D7D for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 3tqA2kaCusP0 for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755885; bh=Xl2JxrTNuYFfrvPscVVBjgtsAAWr+/ahWBAfuweX4yQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=A3lrZf206LGDD0VTbN99iS6WciGVQIEIKd4RHdCupSFrxNw+/7I+O5ss1IjYYU+dG enYMWrzfXNjFXvlQl+gcSReeusc0rCdueqqyttDa/32iXx3r3PTV2xDMrdI9sq3+5E BIwQJZCoqB/yY9kj/YXdwBqgL0XoWBKres3DYWZ89KbgQBzbsUuGfYq90gTGMyIHh9 dfzylmOTcqlmFmm/myHNuv3ZAlOqVyj3s5Jiztz8OyTA0RTbepjyUahHsGy+J6O5cA u9jruz6OxxXADRWGSGcA7lE/Ld2gaLvwV0ZVB51ilSLme8Y5pJYjAvuEjU5A/yJ6Fx AnriiVI+HXMdw== 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 021934D86 for ; Wed, 10 Apr 2024 15:31:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id EAA9C3A0357 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:18 +0200 Message-ID: <20240410133118.28144-10-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10] lavc/hevc_ps: compactify ShortTermRPS 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: hu3kmhfVgITD Do not use larger fields than needed, use size-1 bitfields for flags. Reduces sizeof(HEVCSPS) by 1280 bytes. --- libavcodec/hevc_ps.c | 6 +++--- libavcodec/hevc_ps.h | 19 +++++++++++-------- libavcodec/vulkan_hevc.c | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 76fe507e7b..7b486ce0af 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -143,11 +143,11 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, for (i = 0; i <= rps_ridx->num_delta_pocs; i++) { used[k] = get_bits1(gb); - rps->use_delta_flag = 0; + rps->use_delta = 0; if (!used[k]) - rps->use_delta_flag = get_bits1(gb); + rps->use_delta = get_bits1(gb); - if (used[k] || rps->use_delta_flag) { + if (used[k] || rps->use_delta) { if (i < rps_ridx->num_delta_pocs) delta_poc = delta_rps + rps_ridx->delta_poc[i]; else diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 92b85115f7..a8d07aa1b2 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -70,16 +70,19 @@ typedef struct HEVCHdrParams { } HEVCHdrParams; typedef struct ShortTermRPS { - uint8_t rps_predict; - unsigned int delta_idx; - uint8_t use_delta_flag; - uint8_t delta_rps_sign; - unsigned int abs_delta_rps; - unsigned int num_negative_pics; - int num_delta_pocs; - int rps_idx_num_delta_pocs; int32_t delta_poc[32]; uint32_t used; + + uint8_t delta_idx; + uint8_t num_negative_pics; + uint8_t num_delta_pocs; + uint8_t rps_idx_num_delta_pocs; + + uint16_t abs_delta_rps; + unsigned delta_rps_sign:1; + + unsigned rps_predict:1; + unsigned use_delta:1; } ShortTermRPS; typedef struct HEVCWindow { diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index c2b65fc201..b109475194 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -359,7 +359,7 @@ static void set_sps(const HEVCSPS *sps, int sps_idx, .delta_rps_sign = sps->st_rps[i].delta_rps_sign, }, .delta_idx_minus1 = sps->st_rps[i].delta_idx - 1, - .use_delta_flag = sps->st_rps[i].use_delta_flag, + .use_delta_flag = sps->st_rps[i].use_delta, .abs_delta_rps_minus1 = sps->st_rps[i].abs_delta_rps - 1, .used_by_curr_pic_flag = 0x0, .used_by_curr_pic_s0_flag = 0x0,