From patchwork Mon Apr 17 14:16:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 41225 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp2394410pzb; Mon, 17 Apr 2023 07:17:38 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4Ms93YPYILUuDiXGZL6NbJIj2BXHj2wls7D6x7IB19kVGEiKaj6b1Ek7IaeMaIb8BKp+u X-Received: by 2002:a17:906:395:b0:94a:96c4:135c with SMTP id b21-20020a170906039500b0094a96c4135cmr6488211eja.73.1681741057878; Mon, 17 Apr 2023 07:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681741057; cv=none; d=google.com; s=arc-20160816; b=VbjhuOO0uvL6nUAQ8Wgn7I8oUY171LPLqIDiqlj+LBWP1u5ezQlw0yCG/yscJ8UIOo MkxxwXv6adcrwLRgRLWVT6FOIkJ4mbpA1qmGFJHFEiIkS0svimSB/+0Ad4Hjq+2q7V/o bnvhVzuK3aO9NP7iKhwQk1gBUX4JlfrQKLybleEu8/kwEaHfD9zB7l8N6EYTRKl/QdD4 YSTvlGykF98RCyJR1v2prmLycdp9sNCiljn0Z+sBZEBdcJfGyVrSiDvUMi6SBv7Hk3ys O6hmUsfYDyHmc4LSNks1pIny04Xrl6D7+FqCDmJy4j3vyR+rKtfjgmFITdyHHEFqZsmo pjwQ== 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=sC6us6ZksI7VVmYcypw87tejb/lFM9NXdCQh5x7yjQM=; b=0iwc2lNTFo3ZTmo8evDf3lO//pIT8xJzDiehbGJCkcF+DrfE2I5zugl7+VNUHOIT8h bYUR+ySD9e4gsYYDsSmgRyW7drKZyNE7FfS5hNzE9Yp4eTfhzeRDwdEiCgMS20JYi8BD MLK5jRibWOz2AXf6tEncZ2dqAI5aAU509CKpNoIqvj9bxoYx0IIET3wycaQexA6OayX/ Oi7abb5IQMUfC0yy6dLa/7B/b6/R7LgbtUD2kqqp2jPyX/507maiGdBSTf7lAE557Qqv YUUUNLkvzdhJGemlBQ/qQR9YWk68nBdU2rgvl/tjTaRrIBr5L7B+2+PZjbM52E5TgGII aBCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=PBjO0pYo; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id we23-20020a170907235700b0094f6c4b556esi2254186ejb.518.2023.04.17.07.17.37; Mon, 17 Apr 2023 07:17: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=@gmail.com header.s=20221208 header.b=PBjO0pYo; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C6BF68BE41; Mon, 17 Apr 2023 17:17:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E837068B630 for ; Mon, 17 Apr 2023 17:17:07 +0300 (EEST) Received: by mail-oi1-f180.google.com with SMTP id bh10so16814309oib.1 for ; Mon, 17 Apr 2023 07:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681741026; x=1684333026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yHvWGagDbTyJ0IBXLOz+GImih3PwNmT5lhwx6WSGTlA=; b=PBjO0pYonnpBsiJMRhDzVxZYb5UZsS+hDnJVXPZHXXy2H0A1c7gwjKT6Jc5iP6GslH T+yAPlphB4m5agLYvjyNundOK6iYN6mc8pV2Nc18e+ogrRXQtt4x5UxmrOuRepy6i2Ke spfm4OUtBRIwoUPTbWn5bqDXZiWze2dHm9NmYd8R0/5d0qZzKbSRE6HrNpLEUJQnQd8/ l/A3F4pLTceXY1fvQZgqd9BtPgXQK3mNE0CWbcBuO23MJDOyTrvkn3z8EFG9LOgD1xMa bAyab4pcVLXebjXolimLbav0zFQM52S/APFzsq3Ia2NPvIHaEnxiuEzK50tMs5dBV91/ N49w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681741026; x=1684333026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHvWGagDbTyJ0IBXLOz+GImih3PwNmT5lhwx6WSGTlA=; b=k1uvIShrX2F/YzNLS3cVnoSenQn24ELJqxqxrLLFpH9J2hcOMGIlS5ffQBJFCqFJ/4 lOGcNF9PBkIpG6sTSchvhsird4bwRYZ4sK/sijW6iDGPkcCFmO5TOL41ahHVdj5x++fG sO4CK6bSg4hPm5AGmd81ZyAtjyC0JkIqp62Cn58jywarn0f0Jl/SyK7N8k6J+anaIGUT 2AyVJVgng/HfHKwxMnWr+1ZKXL3sRDm+KxE8jlVW9n7CvimIuAKfEkrLxuknin6jH61f 07CCOlNKTXYWSD8/SbpNeq9iHlaaDxpqeVPr5j+GnTROALvZA0nnYZ4EmLCjeQVqCs34 A5ew== X-Gm-Message-State: AAQBX9d1b8AJ+xe7fJQtwZs7Xx730k3i682iKrH5nGZtWX1aznHVXESL 2yDSr1ME2gOHgYDCR+NKry2QJCjrptA= X-Received: by 2002:a05:6808:1283:b0:38c:570f:8c83 with SMTP id a3-20020a056808128300b0038c570f8c83mr4566254oiw.15.1681741026002; Mon, 17 Apr 2023 07:17:06 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id q15-20020a9d4b0f000000b006a5edce01f4sm572123otf.26.2023.04.17.07.17.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 07:17:05 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Apr 2023 11:16:47 -0300 Message-Id: <20230417141647.1129-3-jamrial@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230417141647.1129-1-jamrial@gmail.com> References: <20230417141647.1129-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: use get_ue_golomb() for some PPS multilayer extension fields 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: 5RJtv4DALrFT Also remove the _plus* and _minus* parts of some of these to be in line with other similar fields in the decoder. Signed-off-by: James Almer --- libavcodec/hevc_ps.c | 27 +++++++++++++-------------- libavcodec/hevc_ps.h | 18 +++++++++--------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 69d5504ce1..7401ea23f5 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -1324,7 +1324,7 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept int idx_y, int idx_cb, int idx_cr, int inp_length) { unsigned int split_octant_flag, part_num_y, coded_res_flag, res_coeff_q, res_coeff_r; - int bit_depth_cm_input_y, bit_depth_cm_output_y, cm_res_bits; + int cm_res_bits; part_num_y = 1 << pps->cm_y_part_num_log2; @@ -1346,10 +1346,9 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept if (coded_res_flag) for (int c = 0; c < 3; c++) { res_coeff_q = get_ue_golomb_long(gb); - bit_depth_cm_input_y = 8 + pps->luma_bit_depth_cm_input_minus8; - bit_depth_cm_output_y = 8 + pps->luma_bit_depth_cm_output_minus8; - cm_res_bits = FFMAX(0, 10 + bit_depth_cm_input_y - bit_depth_cm_output_y - - pps->cm_res_quant_bits - (pps->cm_delta_flc_bits_minus1 + 1)); + cm_res_bits = FFMAX(0, 10 + pps->luma_bit_depth_cm_input - + pps->luma_bit_depth_cm_output - + pps->cm_res_quant_bits - pps->cm_delta_flc_bits); res_coeff_r = cm_res_bits ? get_bits(gb, cm_res_bits) : 0; if (res_coeff_q || res_coeff_r) skip_bits1(gb); @@ -1367,13 +1366,13 @@ static void colour_mapping_table(GetBitContext *gb, HEVCPPS *pps) pps->cm_octant_depth = get_bits(gb, 2); pps->cm_y_part_num_log2 = get_bits(gb, 2); - pps->luma_bit_depth_cm_input_minus8 = get_ue_golomb_long(gb); - pps->chroma_bit_depth_cm_input_minus8 = get_ue_golomb_long(gb); - pps->luma_bit_depth_cm_output_minus8 = get_ue_golomb_long(gb); - pps->chroma_bit_depth_cm_output_minus8 = get_ue_golomb_long(gb); + pps->luma_bit_depth_cm_input = get_ue_golomb(gb) + 8; + pps->chroma_bit_depth_cm_input = get_ue_golomb(gb) + 8; + pps->luma_bit_depth_cm_output = get_ue_golomb(gb) + 8; + pps->chroma_bit_depth_cm_output = get_ue_golomb(gb) + 8; pps->cm_res_quant_bits = get_bits(gb, 2); - pps->cm_delta_flc_bits_minus1 = get_bits(gb, 2); + pps->cm_delta_flc_bits = get_bits(gb, 2) + 1; if (pps->cm_octant_depth == 1) { pps->cm_adapt_threshold_u_delta = get_se_golomb_long(gb); @@ -1415,10 +1414,10 @@ static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx, pps->resample_phase_set_present_flag[i] = get_bits1(gb); if (pps->resample_phase_set_present_flag[i]) { - pps->phase_hor_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb); - pps->phase_ver_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb); - pps->phase_hor_chroma_plus8[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb); - pps->phase_ver_chroma_plus8[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb); + pps->phase_hor_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_31(gb); + pps->phase_ver_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_31(gb); + pps->phase_hor_chroma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb(gb) - 8; + pps->phase_ver_chroma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb(gb) - 8; } } diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 5a80cf5d80..0c9c278662 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -327,21 +327,21 @@ typedef struct HEVCPPS { int16_t ref_region_right_offset[64]; int16_t ref_region_bottom_offset[64]; uint8_t resample_phase_set_present_flag[64]; - uint16_t phase_hor_luma[64]; - uint16_t phase_ver_luma[64]; - uint16_t phase_hor_chroma_plus8[64]; - uint16_t phase_ver_chroma_plus8[64]; + uint8_t phase_hor_luma[64]; + uint8_t phase_ver_luma[64]; + int8_t phase_hor_chroma[64]; + int8_t phase_ver_chroma[64]; uint8_t colour_mapping_enabled_flag; uint16_t num_cm_ref_layers_minus1; uint8_t cm_ref_layer_id[63]; uint8_t cm_octant_depth; uint8_t cm_y_part_num_log2; - uint16_t luma_bit_depth_cm_input_minus8; - uint16_t chroma_bit_depth_cm_input_minus8; - uint16_t luma_bit_depth_cm_output_minus8; - uint16_t chroma_bit_depth_cm_output_minus8; + uint8_t luma_bit_depth_cm_input; + uint8_t chroma_bit_depth_cm_input; + uint8_t luma_bit_depth_cm_output; + uint8_t chroma_bit_depth_cm_output; uint8_t cm_res_quant_bits; - uint8_t cm_delta_flc_bits_minus1; + uint8_t cm_delta_flc_bits; int8_t cm_adapt_threshold_u_delta; int8_t cm_adapt_threshold_v_delta;