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 290CA4877A for ; Mon, 18 Dec 2023 00:07:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 18B0368D18D; Mon, 18 Dec 2023 02:07:33 +0200 (EET) Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B67C068CF4C for ; Mon, 18 Dec 2023 02:07:26 +0200 (EET) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a235ea9f9b4so8746566b.0 for ; Sun, 17 Dec 2023 16:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702858045; x=1703462845; 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=sv1FEIbGNH3I+rnrEqqCAn/1iU85m71ulFwEHgdM85E=; b=SV10bGJC8p8Jmcxs4Izlj45R0zMAlOX5M4zxnG6WCCWuHtL4EzFL0UoBr0vPtgHerT V3vKGH4l7U79Lh0XaXOonTGzg0ncBOQPzKqwKXLefFZ/z678VhkNBcYAw8sGiafXD38o 5eD8oCSgwmfySEEcp7Fdx/a8dhbS4WU4cauGbtXNcVatxlizMn5g2z0Wp8hfWs53YmEz owTzUAT2AdgvvG7h5YMyBG5uZwxnNvnqtTotdVNyGnrL+JmRNjf6x0yWWsq7Ats+n7wq 8A74u73RQ7YoFFDSiJMde/XjKVhPvmbvtm0Ic3rmYrpweU2SDjl/ub0AoxTx2BUvSw+j k7Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702858045; x=1703462845; 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=sv1FEIbGNH3I+rnrEqqCAn/1iU85m71ulFwEHgdM85E=; b=u+JKpd9/Oeau42Y7uuPv7E/5DrnELOzfLB9JFtaBtM/6Zth4Ccrm1MeRfeFX36dRvh JO7z2d9sBntNJCjFdhN4nbi2YOZt7zuu3lHZcNVoUPwBzNx6Hj+Y59UXq0VxcavJLwk/ 4UA9hbIvBizB54K1VX0Y9CZSzrlOQFeEFj+ViG39AyY2Xm0dQvtzeBe5i5KZHenViAwC 2SN0oKL/T9IINNCALxx5OeWGgaPJ32T2rLvWKRWEAD95RxgWRipQbeAVOAI6lLm5vmzq uayqxKx1e9IZ70by2ghAZdZiGhhQs5wvUlvZRdzyUSp4+AVpe4bgXCioAgZvzEx99OnD vNpA== X-Gm-Message-State: AOJu0YxfrBy14nITfkH7FGcRbtX5JW2Kh5WJmr+kowyBfTa8Ar9seIRj ErWvdDVVXP7yvlQ4y1YOVfDSYxJn9Lw= X-Google-Smtp-Source: AGHT+IHwKrUfjTeUB0jT/zh7edVaw+whcpRCne/VGha4xJ31PRIKinTrqYc/sX95/SRQk7gDep+nEw== X-Received: by 2002:a17:906:78a:b0:a23:4524:e183 with SMTP id l10-20020a170906078a00b00a234524e183mr550601ejc.77.1702858044522; Sun, 17 Dec 2023 16:07:24 -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 wb2-20020a170907d50200b00a19084099a4sm13655340ejc.16.2023.12.17.16.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 16:07:24 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 029D3BFCDC; Mon, 18 Dec 2023 01:07:21 +0100 (CET) Date: Mon, 18 Dec 2023 01:07:21 +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-13-u@pkh.me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231211014429.1841681-13-u@pkh.me> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 12/35] avcodec/proresenc_anatoliy: shuffle encode_codeword() code to match Kostya encoder 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:13 +0100, Cl=E9ment B=BDsch wrote: > Code is functionally identical, it's just rename of variables, cosmetics > and branch logic shuffling. > --- > libavcodec/proresenc_anatoliy.c | 45 +++++++++++++++++---------------- > 1 file changed, 23 insertions(+), 22 deletions(-) > = > diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anato= liy.c > index 804ff6ddf7..c7e43fc88c 100644 > --- a/libavcodec/proresenc_anatoliy.c > +++ b/libavcodec/proresenc_anatoliy.c > @@ -226,31 +226,32 @@ static int int_from_list_or_default(void *ctx, cons= t char *val_name, int val, > return default_value; > } > = > -static void encode_codeword(PutBitContext *pb, int val, int codebook) > +static void encode_codeword(PutBitContext *pb, int val, unsigned codeboo= k) > { > - unsigned int rice_order, exp_order, switch_bits, first_exp, exp, zer= os; > - > - /* number of bits to switch between rice and exp golomb */ > - switch_bits =3D codebook & 3; > - rice_order =3D codebook >> 5; > - exp_order =3D (codebook >> 2) & 7; > - > - first_exp =3D ((switch_bits + 1) << rice_order); > - > - if (val >=3D first_exp) { /* exp golomb */ > - val -=3D first_exp; > - val +=3D (1 << exp_order); > - exp =3D av_log2(val); > - zeros =3D exp - exp_order + switch_bits + 1; > - put_bits(pb, zeros, 0); > - put_bits(pb, exp + 1, val); > - } else if (rice_order) { > - put_bits(pb, (val >> rice_order), 0); > - put_bits(pb, 1, 1); > - put_sbits(pb, rice_order, val); > + unsigned int rice_order, exp_order, switch_bits, switch_val; > + int exponent; > + > + /* number of prefix bits to switch between Rice and expGolomb */ > + switch_bits =3D (codebook & 3) + 1; > + rice_order =3D codebook >> 5; /* rice code order */ > + exp_order =3D (codebook >> 2) & 7; /* exp golomb code order */ > + > + switch_val =3D switch_bits << rice_order; > + > + if (val >=3D switch_val) { > + val -=3D switch_val - (1 << exp_order); > + exponent =3D av_log2(val); > + > + put_bits(pb, exponent - exp_order + switch_bits, 0); > + put_bits(pb, exponent + 1, val); > } else { > - put_bits(pb, val, 0); > + exponent =3D val >> rice_order; > + > + if (exponent) > + put_bits(pb, exponent, 0); > put_bits(pb, 1, 1); > + if (rice_order) > + put_sbits(pb, rice_order, val); > } > } > = > -- = > 2.43.0 Should be equivalent to the original code (and with some small optimizations), so it should be fine. _______________________________________________ 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".