From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0D0204B4BB for ; Fri, 7 Jun 2024 13:05:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF86C68D7ED; Fri, 7 Jun 2024 16:03:58 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2157068D76E for ; Fri, 7 Jun 2024 16:03:50 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=T7ysK0u6; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 80A6B4DE6 for ; Fri, 7 Jun 2024 15:03:47 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 0f_vR2CQ1prL for ; Fri, 7 Jun 2024 15:03:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=tBb/a32JZxRSzIW3a02v3Jj5s+4yhB/yzl3JmkhNac8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T7ysK0u6ty02vo9r/1KMBxoPHcIgDat5yKurBlHq2XrgX/6rYfh3ChsyyhOuOkQQK GC05GDl/AWGQt/4Z9iTond3WGzGzxsbA7zxoVHjvu8uhz0Fmmrf1Dk/RyO8huF8Wdz qUb6ycVhklU/9PytkZ9+b8i1AIFGiDnwSCQkZsMnViaialJx/9YV/7/+396mdW93R9 Kn8Wtwh+3nJYJjUm1oULDz4FUJpeLUs7PKoWhfe4esxiRG1QCnmod+gzmP/owi+a1s QqIPB+NwO3Wn2pL/l3yurEu4nzCdNO/Gur/giR64D1xJ47pHyHyTy6/RNLtNFIlagW sy0nkTJdex1ag== 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 063514DF2 for ; Fri, 7 Jun 2024 15:03:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 086F83A0DB2 for ; Fri, 07 Jun 2024 15:03:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 15:01:11 +0200 Message-ID: <20240607130135.9088-15-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607130135.9088-1-anton@khirnov.net> References: <20240607130135.9088-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/39] lavc/hevcdec: pass SliceHeader explicitly to pred_weight_table() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: And replace the HEVCContext* parameter by void *logctx. Makes it clear that only SliceHeader is modified by this function. --- libavcodec/hevc/hevcdec.c | 75 ++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 2c26d397df..6a9de79dcd 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -143,7 +143,8 @@ fail: return AVERROR(ENOMEM); } -static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *gb) +static int pred_weight_table(SliceHeader *sh, void *logctx, + const HEVCSPS *sps, GetBitContext *gb) { int i = 0; int j = 0; @@ -155,40 +156,40 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext * luma_log2_weight_denom = get_ue_golomb_long(gb); if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) { - av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); + av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); return AVERROR_INVALIDDATA; } - s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); + sh->luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); if (sps->chroma_format_idc != 0) { int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb); if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) { - av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); + av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); return AVERROR_INVALIDDATA; } - s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom; + sh->chroma_log2_weight_denom = chroma_log2_weight_denom; } - for (i = 0; i < s->sh.nb_refs[L0]; i++) { + for (i = 0; i < sh->nb_refs[L0]; i++) { luma_weight_l0_flag[i] = get_bits1(gb); if (!luma_weight_l0_flag[i]) { - s->sh.luma_weight_l0[i] = 1 << s->sh.luma_log2_weight_denom; - s->sh.luma_offset_l0[i] = 0; + sh->luma_weight_l0[i] = 1 << sh->luma_log2_weight_denom; + sh->luma_offset_l0[i] = 0; } } if (sps->chroma_format_idc != 0) { - for (i = 0; i < s->sh.nb_refs[L0]; i++) + for (i = 0; i < sh->nb_refs[L0]; i++) chroma_weight_l0_flag[i] = get_bits1(gb); } else { - for (i = 0; i < s->sh.nb_refs[L0]; i++) + for (i = 0; i < sh->nb_refs[L0]; i++) chroma_weight_l0_flag[i] = 0; } - for (i = 0; i < s->sh.nb_refs[L0]; i++) { + for (i = 0; i < sh->nb_refs[L0]; i++) { if (luma_weight_l0_flag[i]) { int delta_luma_weight_l0 = get_se_golomb(gb); if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0) return AVERROR_INVALIDDATA; - s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l0; - s->sh.luma_offset_l0[i] = get_se_golomb(gb); + sh->luma_weight_l0[i] = (1 << sh->luma_log2_weight_denom) + delta_luma_weight_l0; + sh->luma_offset_l0[i] = get_se_golomb(gb); } if (chroma_weight_l0_flag[i]) { for (j = 0; j < 2; j++) { @@ -200,39 +201,39 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext * return AVERROR_INVALIDDATA; } - s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0; - s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j]) - >> s->sh.chroma_log2_weight_denom) + 128), -128, 127); + sh->chroma_weight_l0[i][j] = (1 << sh->chroma_log2_weight_denom) + delta_chroma_weight_l0; + sh->chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * sh->chroma_weight_l0[i][j]) + >> sh->chroma_log2_weight_denom) + 128), -128, 127); } } else { - s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom; - s->sh.chroma_offset_l0[i][0] = 0; - s->sh.chroma_weight_l0[i][1] = 1 << s->sh.chroma_log2_weight_denom; - s->sh.chroma_offset_l0[i][1] = 0; + sh->chroma_weight_l0[i][0] = 1 << sh->chroma_log2_weight_denom; + sh->chroma_offset_l0[i][0] = 0; + sh->chroma_weight_l0[i][1] = 1 << sh->chroma_log2_weight_denom; + sh->chroma_offset_l0[i][1] = 0; } } - if (s->sh.slice_type == HEVC_SLICE_B) { - for (i = 0; i < s->sh.nb_refs[L1]; i++) { + if (sh->slice_type == HEVC_SLICE_B) { + for (i = 0; i < sh->nb_refs[L1]; i++) { luma_weight_l1_flag[i] = get_bits1(gb); if (!luma_weight_l1_flag[i]) { - s->sh.luma_weight_l1[i] = 1 << s->sh.luma_log2_weight_denom; - s->sh.luma_offset_l1[i] = 0; + sh->luma_weight_l1[i] = 1 << sh->luma_log2_weight_denom; + sh->luma_offset_l1[i] = 0; } } if (sps->chroma_format_idc != 0) { - for (i = 0; i < s->sh.nb_refs[L1]; i++) + for (i = 0; i < sh->nb_refs[L1]; i++) chroma_weight_l1_flag[i] = get_bits1(gb); } else { - for (i = 0; i < s->sh.nb_refs[L1]; i++) + for (i = 0; i < sh->nb_refs[L1]; i++) chroma_weight_l1_flag[i] = 0; } - for (i = 0; i < s->sh.nb_refs[L1]; i++) { + for (i = 0; i < sh->nb_refs[L1]; i++) { if (luma_weight_l1_flag[i]) { int delta_luma_weight_l1 = get_se_golomb(gb); if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1) return AVERROR_INVALIDDATA; - s->sh.luma_weight_l1[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l1; - s->sh.luma_offset_l1[i] = get_se_golomb(gb); + sh->luma_weight_l1[i] = (1 << sh->luma_log2_weight_denom) + delta_luma_weight_l1; + sh->luma_offset_l1[i] = get_se_golomb(gb); } if (chroma_weight_l1_flag[i]) { for (j = 0; j < 2; j++) { @@ -244,15 +245,15 @@ static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext * return AVERROR_INVALIDDATA; } - s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1; - s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j]) - >> s->sh.chroma_log2_weight_denom) + 128), -128, 127); + sh->chroma_weight_l1[i][j] = (1 << sh->chroma_log2_weight_denom) + delta_chroma_weight_l1; + sh->chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * sh->chroma_weight_l1[i][j]) + >> sh->chroma_log2_weight_denom) + 128), -128, 127); } } else { - s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom; - s->sh.chroma_offset_l1[i][0] = 0; - s->sh.chroma_weight_l1[i][1] = 1 << s->sh.chroma_log2_weight_denom; - s->sh.chroma_offset_l1[i][1] = 0; + sh->chroma_weight_l1[i][0] = 1 << sh->chroma_log2_weight_denom; + sh->chroma_offset_l1[i][0] = 0; + sh->chroma_weight_l1[i][1] = 1 << sh->chroma_log2_weight_denom; + sh->chroma_offset_l1[i][1] = 0; } } } @@ -857,7 +858,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) if ((pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) || (pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) { - int ret = pred_weight_table(s, sps, gb); + int ret = pred_weight_table(sh, s->avctx, sps, gb); if (ret < 0) return ret; } -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".