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 ESMTPS id 8538A42112 for ; Sat, 18 Jan 2025 23:02:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2EA268B137; Sun, 19 Jan 2025 01:02:28 +0200 (EET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8EEB968A15D for ; Sun, 19 Jan 2025 01:02:21 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id D031BE0002 for ; Sat, 18 Jan 2025 23:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1737241341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=21Fm3O4Zz/m/0Q9i5xhNXBHMhMtnijPi8IHSA3XcW8g=; b=O/jtL/u+u0pO87ZN7WlbHlsxN4Uy+KTONG7hpiagknjZWcJZJlSwYEq3WBzGuA9J5ctiRG isM56NW8JC8GZUA0R3bHuWGhh7oIQu0iRhUoiAQQg070oq4b5/03J4v8mYr4d49GdUfqr8 UUDje21gRXDpBgEOvisA6b497geWyr9Qk2usA4uxse5z46jCND4qeTEfYm9wOKOaCji0Yr Q4clcNCP2OaCU9St3BSU6eBtn/XI3Xr1f05xfJhzky4xWY8UhJLoadpCbTNoYkbRz4LThC abi0dx8X5aBTxeZszNb2xOBznSlX2Oi3FnVAGexz9DAtFRiHniIl/BW7cwAS3w== Date: Sun, 19 Jan 2025 00:02:19 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250118230219.GT4991@pb2> References: <20250118050001.1809058-1-michael@niedermayer.cc> <20250118050001.1809058-4-michael@niedermayer.cc> <435215b6-196f-4947-92ee-a96129cbba89@lynne.ee> MIME-Version: 1.0 In-Reply-To: <435215b6-196f-4947-92ee-a96129cbba89@lynne.ee> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1: NOT FOR GIT, experiment about float decorrelation 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="===============8810341039151197220==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8810341039151197220== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Z5dln0PkzQdJE97M" Content-Disposition: inline --Z5dln0PkzQdJE97M Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 18, 2025 at 05:33:19PM +0900, Lynne wrote: > On 18/01/2025 14:00, Michael Niedermayer wrote: > > This performs a tiny bit better than not using it but it is incompatible > > with the RCT which gives a bigger gain > >=20 > > Sponsored-by: Sovereign Tech Fund > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/ffv1.h | 20 ++++++++++++++++++++ > > libavcodec/ffv1enc_template.c | 33 ++++++++++++++++++++++++--------- > > 2 files changed, 44 insertions(+), 9 deletions(-) > >=20 > > diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h > > index 2c2df154037..84a443613df 100644 > > --- a/libavcodec/ffv1.h > > +++ b/libavcodec/ffv1.h > > @@ -196,6 +196,26 @@ static av_always_inline int fold(int diff, int bit= s) > > return diff; > > } > > +// We treat infinite as a big number, 0 as a small non 0 number, this = is close enough, we ignore denormal numbers > > +static av_always_inline int64_t f2i(uint16_t f) > > +{ > > + int s =3D -(f>>15); > > + int64_t v =3D (1024L + (f & 1023)) << ((f & 0x7C00) >> 10); > > + return (v + s) ^ s; > > +} > > + > > +//undo above > > +static av_always_inline uint16_t i2f(int64_t v) > > +{ > > + int s =3D v>>63; > > + int e; > > + v =3D (v + s) ^ s; > > + > > + e =3D av_log2(v>>10); > > + > > + return (s&32768) + (e<<10) + ((v + (1U<> e) - 1024; > > +} > > + > > static inline void update_vlc_state(VlcState *const state, const int = v) > > { > > int drift =3D state->drift; > > diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_templat= e.c > > index bc14926ab95..12d519320c0 100644 > > --- a/libavcodec/ffv1enc_template.c > > +++ b/libavcodec/ffv1enc_template.c > > @@ -64,7 +64,13 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext= *sc, > > context =3D RENAME(get_context)(f->quant_tables[p->quant_tabl= e_index], > > sample[0] + x, sample[1] + x, s= ample[2] + x); > > - diff =3D sample[0][x] - RENAME(predict)(sample[0] + x, samp= le[1] + x); > > + > > + int64_t L =3D f2i(sample[0][x-1]); > > + int64_t T =3D f2i(sample[1][x]); > > + int64_t LT =3D f2i(sample[1][x-1]); > > + > > + diff =3D sample[0][x] - mid_pred(i2f(L), i2f(L + T - LT), i= 2f(T)); > > +// diff =3D sample[0][x] - RENAME(predict)(sample[0] + x, s= ample[1] + x); > > if (context < 0) { > > context =3D -context; > > @@ -147,7 +153,16 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f= , FFV1SliceContext *sc, > > memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * > > (w + 6) * sizeof(*RENAME(sc->sample_buffer))); > > - > > + if(0){ > > + int v; > > + for (v =3D 0; v<65536; v++) { > > + int64_t i =3D f2i(v); > > + int v2 =3D i2f(i); > > + if (v !=3D v2) > > + av_log(0,0, "D %X %X %LX\n", v, v2, i); > > + av_assert0(v2 =3D=3D v); > > + } > > + } > > for (y =3D 0; y < h; y++) { > > for (i =3D 0; i < ring_size; i++) > > for (p =3D 0; p < MAX_PLANES; p++) > > @@ -180,13 +195,13 @@ static int RENAME(encode_rgb_frame)(FFV1Context *= f, FFV1SliceContext *sc, > > r =3D *((const uint16_t *)(src[2] + x*2 + stride[2]*y= )); > > } > > - if (sc->slice_coding_mode !=3D 1) { > > - b -=3D g; > > - r -=3D g; > > - g +=3D (b * sc->slice_rct_by_coef + r * sc->slice_rct_= ry_coef) >> 2; > > - b +=3D offset; > > - r +=3D offset; > > - } > > +// if (sc->slice_coding_mode !=3D 1) { > > +// b -=3D g; > > +// r -=3D g; > > +// g +=3D (b * sc->slice_rct_by_coef + r * sc->slice_r= ct_ry_coef) >> 2; > > +// b +=3D offset; > > +// r +=3D offset; > > +// } > > sample[0][0][x] =3D g; > > sample[1][0][x] =3D b; >=20 > I think using prediction independently on both exponent and mantissa, and > coding the two via different contexts would be better, not to mention it > would avoid the f2i hacks. i thought so too but so far i dont have a piece of code that stores them seperately and does perform better thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answe= r. --Z5dln0PkzQdJE97M Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ4wy9wAKCRBhHseHBAsP q+2QAJ9KZs6cm3uOWNnNXO8MtjEfMLY/IgCgkOL7xZXSzOo9DAoWPkB7S0UVIx0= =K6TR -----END PGP SIGNATURE----- --Z5dln0PkzQdJE97M-- --===============8810341039151197220== 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". --===============8810341039151197220==--