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 59268422F0 for ; Fri, 17 Dec 2021 11:43:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD38768AEBA; Fri, 17 Dec 2021 13:43:38 +0200 (EET) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D96E68AD15 for ; Fri, 17 Dec 2021 13:43:31 +0200 (EET) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 5298B24000B for ; Fri, 17 Dec 2021 11:43:31 +0000 (UTC) Date: Fri, 17 Dec 2021 12:43:30 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20211217114330.GI2829255@pb2> References: <20211216194321.18669-1-mvanb1@gmail.com> MIME-Version: 1.0 In-Reply-To: <20211216194321.18669-1-mvanb1@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] Add 32 bit-per-sample capability to FLAC 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 Content-Type: multipart/mixed; boundary="===============8917871618602830532==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8917871618602830532== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TbeRhL8/k55gxNER" Content-Disposition: inline --TbeRhL8/k55gxNER Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 16, 2021 at 08:43:21PM +0100, Martijn van Beurden wrote: [...] > @@ -972,7 +1007,25 @@ static int encode_residual_ch(FlacEncodeContext *s,= int ch) > for (i =3D 0; i < sub->order; i++) > sub->coefs[i] =3D coefs[sub->order-1][i]; > =20 > - if (s->bps_code * 4 + s->options.lpc_coeff_precision + av_log2(opt_o= rder) <=3D 32) { > + if (s->avctx->bits_per_raw_sample > 24) { > + if (!ff_flacdsp_lpc_encode_c_32_overflow_detect(res, smp, n, sub= ->order, > + sub->coefs, sub->= shift)) { > + /* The found LPC coefficients produce predictions that overf= low > + * 32-bit signed integer or produce residuals that do not fa= ll > + * between -2^30 and 2^30. First try again with slightly sma= ller > + * coefficients so that the prediction undershoots, if that > + * doesn't help return a verbatim subframe instead */ > + for (i =3D 0; i < sub->order; i++) { > + sub->coefs[i] =3D sub->coefs[i]*0.98; ^^^^ This is ugly, the amount of actual overflow should be known at this point so no arbitrary downscale should be needed here =20 =20 > + if (!ff_flacdsp_lpc_encode_c_32_overflow_detect(res, smp= , n, sub->order, > + sub->coe= fs, sub->shift)) { > + sub->type =3D sub->type_code =3D FLAC_SUBFRAME_VERBA= TIM; > + memcpy(res, smp, n * sizeof(int32_t)); > + return subframe_count_exact(s, sub, 0); How often does this occur ? thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato --TbeRhL8/k55gxNER Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYbx34gAKCRBhHseHBAsP q4ZHAJ9cyvZ9snRy4UrzTr+TvPK96k+BzwCgm9zeAQQoxkLYPRh6i1YaLa8xjXg= =VeSw -----END PGP SIGNATURE----- --TbeRhL8/k55gxNER-- --===============8917871618602830532== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============8917871618602830532==--