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 24F9848645 for ; Tue, 12 Dec 2023 08:16:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 991D868D1AB; Tue, 12 Dec 2023 10:16:10 +0200 (EET) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 89AB868D0F1 for ; Tue, 12 Dec 2023 10:16:04 +0200 (EET) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3333224c7b9so4754591f8f.1 for ; Tue, 12 Dec 2023 00:16:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702368963; x=1702973763; darn=ffmpeg.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=FWGcu1CIvfmyYsTeDjU/Cgcp2NfHYDsILIx6aspHLuw=; b=Voko0qRGOEYGsQAk60q0p1aKYMDWtzwIxG5AflJiLdTaAXg/Rxm0E5iFY2KmjOnmPi wohopKzh/aGbuq0Urm/zmL7u7rc5InZMcLKoQfWNPGien1iYnh11y+D9LfaCDnafsc2W 6RoHiAPc8HEVg+tRO+sPdG/ygLNxF0ImM6JtqCfJgwLLO6FunQ+PWyizG/1SVbVX2qGA 0h1Eq3hQa9exb7tfZdVWwhOgrgLAsUOYDgmKSDTvBdvti6bf5ZYl/3a8/CEdT7gpr1j3 r4WU3/XmfcGTaSbQl8E6UPMticKqMBANQHKVZye8Fu+H++SlYiBNcYvppRRu79aAqAWR v/YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702368963; x=1702973763; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWGcu1CIvfmyYsTeDjU/Cgcp2NfHYDsILIx6aspHLuw=; b=K4IKTd91KA6J5uyaFkzrd9MUKKameBeNjtksSFe6Jl1FEek9KlAUf/7sqHDHjJNuRo 7ODbQd6GQBV+m/er3I65Uj961T+LyfJzdxCnXWW/gpk0cVU/W1fdMTC2js5pElA3h6xN bJnWqHXI2wvaSOc3SS5V/FzPhha9p1OS7Xal4bwgGr/KMtXfO/3aFvQNO5hoGXGMQf/H 8yCiCLsPU/5HGEUiL1knM3X8sIDT+hG2+nQW3vtOfFCIAJNw/k483Np8MUmZWgLfk/yy XMihwh+32rzjO87ao5dY3EjFmK0v7z8ccUrW/8R812EoMKeeSmS3plM6EPOEBuJd8t3g wQFg== X-Gm-Message-State: AOJu0YwetDAB88QNgNcxhvR8K7dtG+UogEG9THdYfZM6Hiq2YXxoGqO/ AJy6h21JBmad7HgoYewzHeEQmsuY8X4= X-Google-Smtp-Source: AGHT+IGyqihVBu2GfAixcRTfICNJ6I6vH+NsdUqjYvkkg1FLt2T9wmBhSbA2kKgXpWRAOnTSJopUPQ== X-Received: by 2002:a05:6000:cd1:b0:332:e2b0:c217 with SMTP id dq17-20020a0560000cd100b00332e2b0c217mr3001847wrb.62.1702368962825; Tue, 12 Dec 2023 00:16:02 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id p13-20020a5d48cd000000b0033609750752sm9879326wrs.8.2023.12.12.00.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:16:02 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id D6305BFCDA; Tue, 12 Dec 2023 09:16:00 +0100 (CET) Date: Tue, 12 Dec 2023 09:16:00 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , =?iso-8859-15?Q?Cl=E9ment_B=BDsch?= References: <20231211014429.1841681-1-u@pkh.me> <20231211014429.1841681-6-u@pkh.me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231211014429.1841681-6-u@pkh.me> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 05/35] avcodec/proresenc_kostya: remove one LUT indirection for run/level to codebook mapping 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 Cc: =?iso-8859-15?Q?Cl=E9ment_B=BDsch?= Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Monday 2023-12-11 02:35:06 +0100, Cl=E9ment B=BDsch wrote: > This is following the same logic as proresenc_anatoliy. > --- > libavcodec/proresenc_kostya.c | 47 +++++++++++------------------------ > 1 file changed, 14 insertions(+), 33 deletions(-) > = > diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c > index 6e1d5a0cef..f883ab550b 100644 > --- a/libavcodec/proresenc_kostya.c > +++ b/libavcodec/proresenc_kostya.c > @@ -142,25 +142,6 @@ static const uint8_t prores_dc_codebook[4] =3D { > 0x70 // rice_order =3D 3, exp_golomb_order =3D 4, switch_bits =3D 0 > }; > = > -static const uint8_t prores_ac_codebook[7] =3D { > - 0x04, // rice_order =3D 0, exp_golomb_order =3D 1, switch_bits =3D 0 > - 0x28, // rice_order =3D 1, exp_golomb_order =3D 2, switch_bits =3D 0 > - 0x4C, // rice_order =3D 2, exp_golomb_order =3D 3, switch_bits =3D 0 > - 0x05, // rice_order =3D 0, exp_golomb_order =3D 1, switch_bits =3D 1 > - 0x29, // rice_order =3D 1, exp_golomb_order =3D 2, switch_bits =3D 1 > - 0x06, // rice_order =3D 0, exp_golomb_order =3D 1, switch_bits =3D 2 > - 0x0A, // rice_order =3D 0, exp_golomb_order =3D 2, switch_bits =3D 2 > -}; > - > -/** > - * Lookup tables for adaptive switching between codebooks > - * according with previous run/level value. > - */ > -static const uint8_t prores_run_to_cb_index[16] =3D > - { 5, 5, 3, 3, 0, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 2 }; > - > -static const uint8_t prores_lev_to_cb_index[10] =3D { 0, 6, 3, 5, 0, 1, = 1, 1, 1, 2 }; > - > #define NUM_MB_LIMITS 4 > static const int prores_mb_limits[NUM_MB_LIMITS] =3D { > 1620, // up to 720x576 > @@ -461,12 +442,12 @@ static void encode_acs(PutBitContext *pb, int16_t *= blocks, > const uint8_t *scan, const int16_t *qmat) > { > int idx, i; > - int run, level, run_cb, lev_cb; > + int prev_run =3D 4; > + int prev_level =3D 2; > + int run, level; > int max_coeffs, abs_level; > = > max_coeffs =3D blocks_per_slice << 6; > - run_cb =3D prores_run_to_cb_index[4]; > - lev_cb =3D prores_lev_to_cb_index[2]; > run =3D 0; > = > for (i =3D 1; i < 64; i++) { > @@ -474,13 +455,13 @@ static void encode_acs(PutBitContext *pb, int16_t *= blocks, > level =3D blocks[idx] / qmat[scan[i]]; > if (level) { > abs_level =3D FFABS(level); > - encode_vlc_codeword(pb, prores_ac_codebook[run_cb], run); > - encode_vlc_codeword(pb, prores_ac_codebook[lev_cb], > + encode_vlc_codeword(pb, ff_prores_run_to_cb[prev_run], r= un); > + encode_vlc_codeword(pb, ff_prores_lev_to_cb[prev_level], > abs_level - 1); > put_sbits(pb, 1, GET_SIGN(level)); > = > - run_cb =3D prores_run_to_cb_index[FFMIN(run, 15)]; > - lev_cb =3D prores_lev_to_cb_index[FFMIN(abs_level, 9)]; > + prev_run =3D FFMIN(run, 15); > + prev_level =3D FFMIN(abs_level, 9); > run =3D 0; > } else { > run++; > @@ -699,13 +680,13 @@ static int estimate_acs(int *error, int16_t *blocks= , int blocks_per_slice, > const uint8_t *scan, const int16_t *qmat) > { > int idx, i; > - int run, level, run_cb, lev_cb; > + int prev_run =3D 4; > + int prev_level =3D 2; > + int run, level; > int max_coeffs, abs_level; > int bits =3D 0; > = > max_coeffs =3D blocks_per_slice << 6; > - run_cb =3D prores_run_to_cb_index[4]; > - lev_cb =3D prores_lev_to_cb_index[2]; > run =3D 0; > = > for (i =3D 1; i < 64; i++) { > @@ -714,12 +695,12 @@ static int estimate_acs(int *error, int16_t *blocks= , int blocks_per_slice, > *error +=3D FFABS(blocks[idx]) % qmat[scan[i]]; > if (level) { > abs_level =3D FFABS(level); > - bits +=3D estimate_vlc(prores_ac_codebook[run_cb], run); > - bits +=3D estimate_vlc(prores_ac_codebook[lev_cb], > + bits +=3D estimate_vlc(ff_prores_run_to_cb[prev_run], ru= n); > + bits +=3D estimate_vlc(ff_prores_lev_to_cb[prev_level], > abs_level - 1) + 1; > = > - run_cb =3D prores_run_to_cb_index[FFMIN(run, 15)]; > - lev_cb =3D prores_lev_to_cb_index[FFMIN(abs_level, 9)]; > + prev_run =3D FFMIN(run, 15); > + prev_level =3D FFMIN(abs_level, 9); > run =3D 0; > } else { > run++; LGTM. _______________________________________________ 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".