[FFmpeg-devel] [PATCH 5/5] libavcodec/ffv1: Support storing LSB raw

Michael Niedermayer michael at niedermayer.cc
Wed Oct 16 16:54:04 EEST 2024


On Wed, Oct 16, 2024 at 03:26:39PM +0200, Michael Niedermayer wrote:
> This makes a 16bit RGB raw sample 25% faster at a 2% loss of compression with rawlsb=4
> 
> Please test and comment
> 
> This stores the LSB through non binary range coding, this is simpler than using a
> separate coder
> For cases where range coding is not wanted its probably best to use golomb rice
> for everything.
> 
> We also pass the LSB through the decorrelation and context stages (which is basically free)
> this leads to slightly better compression than separating them earlier.
> 
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavcodec/ffv1.h             |  2 ++
>  libavcodec/ffv1_template.c    | 19 ++++++++++---------
>  libavcodec/ffv1dec.c          |  2 ++
>  libavcodec/ffv1dec_template.c | 16 +++++++++++++---
>  libavcodec/ffv1enc.c          | 15 ++++++++++++++-
>  libavcodec/ffv1enc_template.c | 17 +++++++++++++++--
>  6 files changed, 56 insertions(+), 15 deletions(-)

3rd implemantation :)
you might ask why i implement this 4?! times
Heres why: (tests done with 4 rawlsb bits, 16bit per sample input)

The original (no decompression supported, bits riped out before context model and decorrelation, seperate buffer)
-rw-r----- 1 michael michael   91403202 Oct 15 22:48 film4st.nut

I dont remember
-rw-r----- 1 michael michael   91253765 Oct 15 23:14 film4st-new.nut

bits extracted after decorrelation and context model, interleaved range coder, simple but not efficient rangecoder implemantation
-rw-r----- 1 michael michael   91080109 Oct 16 00:14 film4st-new2.nut

This current, bits extracted after decorrelation and context model, simplest and most efficient range coder implemantation
-rw-r----- 1 michael michael   90996813 Oct 16 15:14 film4st-new3.nut
same but with quantization table 1
-rw-r----- 1 michael michael   89883371 Oct 16 15:50 film4st-new3q1.nut

Heres the reference without rawlsb:
-rw-r----- 1 michael michael   88090676 Oct 15 22:49 film0st.nut
-rw-r----- 1 michael michael   88168254 Oct 16 15:50 film0st-q1.nut

So this implemantation so far performs best and is also very simple

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241016/ee9073e9/attachment.sig>


More information about the ffmpeg-devel mailing list