From patchwork Thu Apr 27 19:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 41389 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp767597pzb; Thu, 27 Apr 2023 12:22:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Kt4Y8pP3VYghlwZP6YwMMwcymENteUKZ4Ox0K+mlzj+Yu0U1DSUAeFAMFKJ/F7Z5yB3Rx X-Received: by 2002:a05:6402:1215:b0:4fb:4fc2:e600 with SMTP id c21-20020a056402121500b004fb4fc2e600mr2280393edw.42.1682623355403; Thu, 27 Apr 2023 12:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682623355; cv=none; d=google.com; s=arc-20160816; b=R0o4zXOm0Bq4sdAjJXdjfwSSZXKlRSTgQrNuoFqFydcAzA8Wblk1hb95FLLHQrG6Wf 2sJ68DX5SoXT5N8KAkZ0a89YVwYEqBldaZ1hfRNhQFEd6VL0wqiMOWVimZdemC3xWXES DnSR1UIuDdcUHdX6zsZ8fCiQqrf/5uAqReDJloxos2QM+XdEUboIag0VYOboZdlUF412 pDHKmU/+ddFy7LrUPY/bebWqoeQoraPqGE1s6yLrmtasVGffhRYudN+8OiywRIsmb9GD NqHKg2SNb18hiE6vLKLBkMUuOqWTU8MSEMUEn309jZXY7l63zY+lv11uhM+BfFDmdamP 3Teg== 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=8RyyhSC2yMPpLznFnk6JIdpPZhqYwKdqw/xpldALlkM=; b=KWrpABepxbMfZHPCN5qaTCHDtrA2g7Yymohn8Pm8KFmsxqjBKVfVj4Fsjz5/pPUvHb KboMWU+g3ZibA08UwDN5Yq/J8vUlyrNRlDo3jvAX+DxVfwRdOAkAmc2JOUgkGnzxb8zJ 4RQGFoMiEQQvPV1I9CzLyu8GhKH2stK70fABzRh1YY2xxOrVc2l/BzQSNfHNBV5f+F8G foxKzPn6WR3TbOjrW4MUKoGp1pbmpIp8ZUI7Z/2eZp9xssAoQmKg030FqCJEO8h3C++c TAyrdkZLtS9Ddqh+I5g+1I+aW0JPb/ykpXNGzsFmNdV8AvnEq5LjXac32plKcEFShuFr +8Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=i0UrQhhN; 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 a15-20020aa7d90f000000b005083b0f55efsi12688000edr.351.2023.04.27.12.22.34; Thu, 27 Apr 2023 12:22:35 -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=i0UrQhhN; 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 13C49689D6F; Thu, 27 Apr 2023 22:22:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51DAC6807D9 for ; Thu, 27 Apr 2023 22:22:23 +0300 (EEST) Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-18f16a2c329so6466588fac.0 for ; Thu, 27 Apr 2023 12:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682623341; x=1685215341; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZxfpniIZGpPzG2RMDUhHsLVGvNmkvd+YggepZs95VyM=; b=i0UrQhhNAhP6TXVwFFTCuqDvF0snwItr1l8TW2am9pTXKsECRdhxrl9oNwJJjKyz/w MmeHPr/KI5o5e6W02xp8uEB4ckbA63kG8G7kLSAxvXb2mzelgdKig3nMM/8eu8v3rTc1 S93C2azy1HJLt9NGHSBkpyDbZL0JjwD02x9ckwdcQn5LZi++gmWcVdTJhgvk/LMXrwA/ lcecLKq0k6q3P/DdDCvxEF5VTI2u4ExPGJA1xl4LF+r3JKh7msSC7ACmif5xb/8sE0L2 NUWDh9MSw4DoEUCRci2EQ8h3asJlis7EFosMWNJGyVj5WpD1NyzhFTgK78ZSZ/fglJEz +IWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682623341; x=1685215341; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZxfpniIZGpPzG2RMDUhHsLVGvNmkvd+YggepZs95VyM=; b=jJ9250RxOLZPjn+2gBAsp0NzVaZjDYUu+a273SaYw8jt8gvhVIb/cDJO5BOBIiKQx2 TnNRru7b1BBt4BjF1JqQEXwy6Vj1dqz+/ot/7vKzJYs3HX9h1pz040h0XI77hw9XIfrO uFO7qNky94vAcptspzKpR66XDf9Ftb2nOElg7jLVlCakbl+AaAeB4bSznLAWFjzfCUP+ majOZtguMKZcymkgPnwXA0ON0VjXonWLdrD2Yl3kBxRtG6S/eEcc3mKAi/GKmoCYmiGG UjhzW2baPpAEgOvXINLEESAf2/WSZdKfmcpKLAbzMr+3+gmswhs6yQp911EkN078QEeT 4gcQ== X-Gm-Message-State: AC+VfDx+c34lWPh+VhtonxByf0nXFiYrgDDKTekS8jatr9t0FCgYNRjs K3OZxFYemCPYkm/lwCHH4Zc7Yz9abjU= X-Received: by 2002:a05:6830:6707:b0:6a4:3b0a:eef6 with SMTP id cr7-20020a056830670700b006a43b0aeef6mr3415775otb.0.1682623341238; Thu, 27 Apr 2023 12:22:21 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id h9-20020a056830164900b006a61bef7968sm8231647otr.53.2023.04.27.12.22.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 12:22:20 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Apr 2023 16:22:06 -0300 Message-Id: <20230427192206.50108-1-jamrial@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/hevc_ps: use get_ue_golomb() for some PPS Screen Content Coding 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: kQ8NOS8B1G8K Also remove the _minus8 part of the name to be in line with the rest of the decoder, and fix the storage type for pps_palette_predictor_initializer, to support hbd values. Signed-off-by: James Almer --- libavcodec/hevc_ps.c | 21 ++++++++++++++------- libavcodec/hevc_ps.h | 6 +++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index f29f783f77..289b8f7d95 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -1538,17 +1538,24 @@ static int pps_scc_extension(GetBitContext *gb, AVCodecContext *avctx, } if (pps->pps_palette_predictor_initializers_present_flag = get_bits1(gb)) { - if ((pps->pps_num_palette_predictor_initializers = get_ue_golomb_long(gb)) > 0) { + pps->pps_num_palette_predictor_initializers = get_ue_golomb(gb); + if (pps->pps_num_palette_predictor_initializers > 0) { + if (pps->pps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) { + av_log(avctx, AV_LOG_ERROR, + "pps_num_palette_predictor_initializers out of range: %u\n", + pps->pps_num_palette_predictor_initializers); + return AVERROR_INVALIDDATA; + } pps->monochrome_palette_flag = get_bits1(gb); - pps->luma_bit_depth_entry_minus8 = get_ue_golomb_long(gb); + pps->luma_bit_depth_entry = get_ue_golomb_31(gb) + 8; if (!pps->monochrome_palette_flag) - pps->chroma_bit_depth_entry_minus8 = get_ue_golomb_long(gb); + pps->chroma_bit_depth_entry = get_ue_golomb_31(gb) + 8; num_comps = pps->monochrome_palette_flag ? 1 : 3; - for (int comp = 0; comp < num_comps; comp++) + for (int comp = 0; comp < num_comps; comp++) { + int bit_depth = !comp ? pps->luma_bit_depth_entry : pps->chroma_bit_depth_entry; for (int i = 0; i < pps->pps_num_palette_predictor_initializers; i++) - pps->pps_palette_predictor_initializer[comp][i] = - get_bits(gb, 8 + (!comp ? pps->luma_bit_depth_entry_minus8 : - pps->chroma_bit_depth_entry_minus8)); + pps->pps_palette_predictor_initializer[comp][i] = get_bits(gb, bit_depth); + } } } diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 0c9c278662..8cd99bb161 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -358,9 +358,9 @@ typedef struct HEVCPPS { uint8_t pps_palette_predictor_initializers_present_flag; uint8_t pps_num_palette_predictor_initializers; uint8_t monochrome_palette_flag; - uint8_t luma_bit_depth_entry_minus8; - uint8_t chroma_bit_depth_entry_minus8; - uint8_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; + uint8_t luma_bit_depth_entry; + uint8_t chroma_bit_depth_entry; + uint16_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; // Inferred parameters unsigned int *column_width; ///< ColumnWidth