From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 9DE5C4C532
	for <ffmpegdev@gitmailbox.com>; Sat,  5 Apr 2025 14:36:38 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D4FB687ABD;
	Sat,  5 Apr 2025 17:36:33 +0300 (EEST)
Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net
 [217.70.183.199])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 393F1687ABD
 for <ffmpeg-devel@ffmpeg.org>; Sat,  5 Apr 2025 17:36:27 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 8EDC24327F
 for <ffmpeg-devel@ffmpeg.org>; Sat,  5 Apr 2025 14:36:25 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1743863786;
 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=YAlQWJyNignoBrc784vU73zEKkzRyg8icxr/17af/4w=;
 b=aY9yZBFSuSLzoXH3nbAWfOoPQxjfkzW6cLZ4fH521Z20oG/rNEsIiOUTsa3wCwFBKefN/h
 hiuJX5qRlt9dOZUXMMhbKtxT5Vbal0Va7taZlPeaujZWM6eB1tSrD9LpnPBJVd141zp7K+
 M/K6PbN014wgRqCIpqtZcpdqUuL9Rvj2T7tqqxbj9tECJlGt+kPyDfkMghuc4FDiz1ZwLC
 IHS3I0NdCC05hDSgJz/C15A8lawFKLj5YeFNtMwkrTy+OMxu5lWe7jTH5S2l8yVcXvXYlR
 rmOXOffYgUzUzvBn6pm12RtFAoeGwED24UYjTtOnGHf8/GiNmbhHaEMVInrmVQ==
Date: Sat, 5 Apr 2025 16:36:25 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20250405143625.GE4991@pb2>
References: <DU0P250MB07476D6A89F0D691F04EB7F68FAE2@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM>
 <20250405073810.GC4991@pb2>
MIME-Version: 1.0
In-Reply-To: <20250405073810.GC4991@pb2>
X-GND-State: clean
X-GND-Score: -85
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduleegiedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdduhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH 01/23] avcodec/x86/vvc/dsp_init: Make put
 wrappers static
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: multipart/mixed; boundary="===============2606491887029239206=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250405143625.GE4991@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============2606491887029239206==
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="Iooj0VZY7WddXLXc"
Content-Disposition: inline


--Iooj0VZY7WddXLXc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Apr 05, 2025 at 09:38:10AM +0200, Michael Niedermayer wrote:
> On Thu, Apr 03, 2025 at 10:31:26PM +0200, Andreas Rheinhardt wrote:
> > Patches attached.
> >=20
> > - Andreas
>=20
> [...]
>=20
> >  libavcodec/mjpegenc_huffman.c                    |   33 ++++++--------=
----
> >  libavcodec/tests/mjpegenc_huffman.c              |    6 ++-
> >  tests/ref/fate/jpg-icc                           |    6 +--
> >  tests/ref/lavf/jpg                               |    4 +-
> >  tests/ref/lavf/smjpeg                            |    4 +-
> >  tests/ref/seek/vsynth_lena-mjpeg                 |   40 +++++++++++---=
---------
> >  tests/ref/vsynth/vsynth1-mjpeg                   |    4 +-
> >  tests/ref/vsynth/vsynth1-mjpeg-422               |    4 +-
> >  tests/ref/vsynth/vsynth1-mjpeg-444               |    4 +-
> >  tests/ref/vsynth/vsynth1-mjpeg-huffman           |    4 +-
> >  tests/ref/vsynth/vsynth1-mjpeg-trell             |    4 +-
> >  tests/ref/vsynth/vsynth1-mjpeg-trell-huffman     |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg                   |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg-422               |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg-444               |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg-huffman           |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg-trell             |    4 +-
> >  tests/ref/vsynth/vsynth2-mjpeg-trell-huffman     |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg                   |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg-422               |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg-444               |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg-huffman           |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg-trell             |    4 +-
> >  tests/ref/vsynth/vsynth3-mjpeg-trell-huffman     |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg               |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg-422           |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg-444           |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg-huffman       |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg-trell         |    4 +-
> >  tests/ref/vsynth/vsynth_lena-mjpeg-trell-huffman |    4 +-
> >  30 files changed, 91 insertions(+), 98 deletions(-)
> > 515cd8ef4364423e2e7ec04535f04b0580e97c78  0020-avcodec-mjpegenc_huffman=
-Avoid-AV_QSORT-to-sort-entr.patch
> > From a17db6215a1600021c9d4a7d6c7923ac5816ea70 Mon Sep 17 00:00:00 2001
> > From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > Date: Wed, 2 Apr 2025 15:06:43 +0200
> > Subject: [PATCH 20/23] avcodec/mjpegenc_huffman: Avoid AV_QSORT to sort
> >  entries by length
> >=20
> > It is unnecessary; all one needs to ensure that shorter codes
> > precede longer ones is to get the number of codes for each
> > length. Then the codes of length 1 occupy the first count[1]
> > positions, the codes of length 2 the next count[2]...
> > Doing so gives a 3.4% speedup of ff_mjpeg_encode_huffman_close()
> > here; it also saves about 340B.
> >=20
> > The new code sorts codes of the same length in order of
> > ascending symbol. The old code did not and therefore
> > the FATE checksums needed to be updated. Due to MJPEG's
> > 0xFF unescaping file sizes as well as file checksums
> > needed to be updated; the decoded picture hashes stayed
> > the same.
>=20
> so theres a difference in size because of escaping differences
> that implies the previous table was not optimal (by the definition
> of smallest filesize)
>=20
> have you considered to use this effect to reduce escaping overhead
> further and thus improve compression further ?
>=20
> for example one can build a variable length code that has no "all 1" code=
 with
> very little overhead. One also could maybe avoid codes that have
> long runs of 1 over some threshold
>=20
> The patch as is, is fine of course. Thats just an idea to improve
> compression by another 0.1-0.3% or so

or another way to see this, is that a huffman table assumes the cost
of each code of the same length is equal.
But due to the escaping thats not true, a code starting and ending in 0 and
not having 8 1 bits in  it is less costly than a code that is
more likely to create patterns that need escaping

the maximum compression gain from this is small, but it may be
an interresting problem. Within the bitstream syntax and adding
no cost on the decoder

thx

[...]

--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA

--Iooj0VZY7WddXLXc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ/E/3gAKCRBhHseHBAsP
q23vAJ9JDgR80YrVfih4DROxfesG5TLDBwCgjIDfLiQ/qXiTZ5ySfJNxHMlrGbA=
=Kquq
-----END PGP SIGNATURE-----

--Iooj0VZY7WddXLXc--

--===============2606491887029239206==
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".

--===============2606491887029239206==--