aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ffv1enc.c
Commit message (Collapse)AuthorAgeFilesLines
* all: fix typos found by codespellTimo Rothenpieler5 days1-1/+1
|
* avcodec/ffv1enc: Use dummies to avoid UB pointer arithmeticAndreas Rheinhardt2025-07-031-0/+5
| | | | | | | | | Fixes the following FATE-tests when run under Clang-UBSan: ffmpeg-loopback-decoding, lavf-mxf_ffv1, vsynth{1,2,3,_lena}-ffv1-v{0,2}, vsynth1-ffv{1,2,3,_lena}, vsynth{1,2,3,_lena}-ffv1-v3-yuv{420p,422p10,444p16} Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1enc: Fix explicitly set -slicecrc 2Andreas Rheinhardt2025-05-271-2/+3
| | | | | | | | | crcref needs to be set properly iff ec is two, regardless of whether it has been explicitly set by the user or set by default based on level/version. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ffv1enc_vulkan: support 8 and 16-bit 2-plane YUV formatsLynne2025-05-011-0/+6
| | | | | This adds support for all 8-bit and 16-bit 2-plane formats. P010 and others require more work as the data's LSB-padded.
* avcodec/ffv1enc: Eliminate fabs()Michael Niedermayer2025-04-271-1/+1
| | | | | | | | | Fixes: warning: using floating point absolute value function 'fabs' when argument is of integer type No change in output Changing variables to float worsens compression significantly Found-by: ePirat Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Use version 3 by default (CRCs by default)Michael Niedermayer2025-04-161-1/+2
| | | | | | Version 3 is since 2013 (FFmpeg 2.1) non experimental so should be widely supported Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: avoid repeating the same warning foreverJerome Martinez2025-04-161-1/+5
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: permit 1024 slicesJerome Martinez2025-04-101-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Fix remap > 0 with gbrp12, that is non floatMichael Niedermayer2025-04-071-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: avoid slices larger than 360x288 if no value is specifiedMichael Niedermayer2025-04-071-1/+5
| | | | | | This improves speed by providing more independent things for more CPUs Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Remove 65536 pixel per slice limit for remapMichael Niedermayer2025-04-071-6/+0
| | | | | | About 1% better compression with large slices Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Store slices*planes with the minimum bits needed after remapMichael Niedermayer2025-04-071-5/+10
| | | | | | | | | | This also means that if a plane*slice has only 1 color nothing is stored after the remap table This also corrects the RCT offset to the exact value after remap not a fixed 65536 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Consider 2s x s slice configurationsMichael Niedermayer2025-04-041-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Only allocate fltmap* and bitmap when neededMichael Niedermayer2025-04-041-6/+17
| | | | | | This reduces memory requirements Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Allocate unit only when needed and only as large as neededMichael Niedermayer2025-04-041-0/+17
| | | | | | | | | | | | That is instead of a fixed 65536, we now allocate only as many as there are pixels. We also allocate only for the encoder and only when remapping is enabled and only for 32bit per sample This should reduce memory consumption, the 2nd array will be dealt with in a future commit Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: run1start variables should fit in 32bitMichael Niedermayer2025-04-041-2/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: replace the remaining log2() by magicMichael Niedermayer2025-04-031-2/+8
| | | | | | | | | | | | | | | | | | | | big secret, reading a float as the corresponding integer is a good approximation of log2() for numbers not too close to 1.0. At the same time it maintains strict monotonicity this reduces run time from 19sec to 17sec for the slowest of my testcases (with default remap_optimizer 3) Compression is about the same: -rw-r----- 1 michael michael 497603370 Mar 30 15:23 float-303503-fixed-40-optim-3-1log2F.nut -rw-r----- 1 michael michael 497603374 Mar 28 11:27 float-303503-fixed-40-optim-3b.nut -rw-r----- 1 michael michael 549938852 Mar 28 11:27 float-303503-float16-40-optim-3b.nut -rw-r----- 1 michael michael 549938857 Mar 30 15:23 float-303503-float16-40-optim-3-1log2F.nut -rw-r----- 1 michael michael 1150827841 Mar 28 11:28 float-303503-float-40-optim-3b.nut -rw-r----- 1 michael michael 1150832913 Mar 30 15:22 float-303503-float-40-optim-3ref-log2F2.nut Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: replace 3 double precision log2() by 1 single precision log2()Michael Niedermayer2025-04-031-5/+11
| | | | | | This makes the remap finding heuristic much faster Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Add -remap_optimizer optionMichael Niedermayer2025-03-311-15/+37
| | | | | | | This allows tuning how much effort (time) the encoder spends on optimizing the remap table Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Eliminate RemapEncoderStateMichael Niedermayer2025-03-311-84/+67
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Eliminate copy_stateMichael Niedermayer2025-03-311-52/+25
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Better heuristic for selecting mul values.Michael Niedermayer2025-03-311-38/+51
| | | | | | | | | | | | This increases the search space from the hardcoded 17 tables to ~ 23^512 tables The mul_count choice is chosen by bruteforce All testcases tried, improve Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Store run1start_mul_index instead of computingMichael Niedermayer2025-03-271-3/+4
| | | | | | | There is a special case I missed, its simpler to just store Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Fix off by 1 in assertMichael Niedermayer2025-03-271-1/+1
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Fix end handlingMichael Niedermayer2025-03-271-1/+4
| | | | | | | This also produces smaller files Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Eliminate encode_mul()Michael Niedermayer2025-03-271-10/+5
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Eliminate index_stack and delta_stackMichael Niedermayer2025-03-251-22/+36
| | | | | | | This reduces stack space requirements my 1.5 mb and should fix fate Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Heuristic to select fixed in float multipliersMichael Niedermayer2025-03-251-6/+24
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Factorize s.last_val update outMichael Niedermayer2025-03-251-2/+1
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Simplify last_val updateMichael Niedermayer2025-03-251-5/+4
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: introduce step to simplify codeMichael Niedermayer2025-03-251-9/+7
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: eliminate if()Michael Niedermayer2025-03-251-9/+7
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: remap table size is 1<<bits_per_raw_sample not fixed 65536Michael Niedermayer2025-03-251-1/+2
| | | | | | | not a bugfix as this path was only used for float16 but it makes sense to allow using this for integers too Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: remap mode 2 is for floats onlyMichael Niedermayer2025-03-251-0/+5
| | | | | | (you could use it for others but it makes no sense) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: remove mixed declarations and codeJames Almer2025-03-241-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ffv1enc: update missing Unit accesses inside av_assert2James Almer2025-03-241-2/+2
| | | | | | Fixes compilation with assert-level=2. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ffv1enc: reduce stack usageJames Almer2025-03-241-29/+22
| | | | | | | Fixes failures in some systems since 171060d5dc54d1526abde736a711ce234df632f2. This can be further improved by only allocating the arrays when needed. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ffv1: Implement 2D RLE for remapMichael Niedermayer2025-03-241-41/+173
| | | | | | | | | | | | | | | | | | ATM this performs as well or better as any other algorithm tried. Its simple for the decoder. On the encoder side complexity depends on how parameters are chosen. But with a fixed mul_count of 1 and basic heuristic it performs as well as any more complex choice i tried so far. The encoder code here is flexible and allows mul_count > 1 and also can easily be used to exactly test various parameters. With mul_count=512 we can gain another 6% in remap table size for fixed point in float data. (this is not implemented in this patch though) Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: remap allows using rice golomb with more bitsMichael Niedermayer2025-03-241-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: 32-bit float sample supportMichael Niedermayer2025-03-241-3/+197
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Fix remap orderingMichael Niedermayer2025-03-241-1/+1
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Add GRAYF16 supportMichael Niedermayer2025-03-171-0/+2
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Add YAF16 supportMichael Niedermayer2025-03-171-16/+17
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: fix remap without chroma planesMichael Niedermayer2025-03-171-2/+1
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: implement remap for encode/decode_plane()Michael Niedermayer2025-03-171-11/+60
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Mark init and close functions as av_coldAndreas Rheinhardt2025-03-171-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ffv1: Implement jeromes idea of making remap flip optionalMichael Niedermayer2025-03-141-3/+17
| | | | | | | | | | | | | | This also makes remap optional (which is a good idea even if we decide to keep flip fixed) Effect on compression (using 2 rawlsb, golomb rice, large context model with ACES_OT_VWG_SampleFrames -rw-r----- 1 michael michael 499101306 Mär 11 14:58 float-303503-try3d-m2.nut -rw-r----- 1 michael michael 503700199 Mär 11 14:57 float-303503-try3d-m1.nut -rw-r----- 1 michael michael 518150578 Mär 11 14:57 float-303503-try3d-m0.nut (the test above used the rawlsb patch, which is not applied yet) Reviewed-by: Jerome Martinez <jerome@mediaarea.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: add space for the remap table to max_sizeMichael Niedermayer2025-03-141-0/+2
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1enc: Factor set_micro_version() out of ff_ffv1_write_extradata()Michael Niedermayer2025-03-141-8/+19
| | | | | | | | | and call it from ff_ffv1_encode_init() setting micro version from code writing the extradata is messy, this should be cleaner Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/ffv1: Fix remap and float with golomb riceMichael Niedermayer2025-03-111-0/+42
| | | | | | Sponsored-by: Sovereign Tech Fund Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>