Thierry Foucu
efbe84eb1b
avcodec/mpeg12dec: use init_get_bits8 and check the return value
...
Signed-off-by: James Almer <jamrial@gmail.com>
2 years ago
Paul B Mahol
99bd2dbc91
swresample/swresample_frame: fix regression in detecting changes
...
Do not overwrite return variable values, instead use different
one for checking results.
2 years ago
Anton Khirnov
a0b5aaceca
lavc/libx265: restructure handling reordered_opaque
...
Current code stores a pointer to allocated data in libx265 and frees it
when the encoded packet is retrieved. This will leak if the packet is
never retrieved, e.g. if the encoder is closed without being flushed.
Restructure the code such that only indices to an array stored in our
private data are given to libx265. This ensures no allocated memory can
be lost.
2 years ago
Anton Khirnov
7399e5305c
lavc/libx264: do not leave an invalid array size on alloc error
2 years ago
Anton Khirnov
a4a81be1a8
lavc/libx264: zero reordered opaque on alloc
...
This is safer.
2 years ago
Anton Khirnov
141303f323
lavc/libx264: print an error on invalid opaque pointer
2 years ago
Anton Khirnov
89761c2122
lavc/libx264: use a local variable to shorten code
2 years ago
Anton Khirnov
4469ce10a6
lavc/libx264: reindent after previous commit
2 years ago
Anton Khirnov
9ed5b0ac3b
lavc/libx264: reorder control flow in setup_roi() to reduce nesting depth
2 years ago
Anton Khirnov
ce5b2d34b4
lavc/libx264: reindent after previous commit
2 years ago
Anton Khirnov
e17b609fc6
lavc/libx264: do not ignore memory allocation errors
2 years ago
Anton Khirnov
cccd2c2179
lavc/libx264: unify cleanup in setup_frame()
2 years ago
Anton Khirnov
87eb362693
lavc/libx264: reindent after previous commit
2 years ago
Anton Khirnov
b1a184283b
lavc/libx264: factor out setting up ROI
2 years ago
Anton Khirnov
c7a8a6939b
lavc/libx264: use a local variable for input frame in setup_frame()
2 years ago
Anton Khirnov
9f8f980165
lavc/libx264: reindent after previous commit
2 years ago
Anton Khirnov
33cbba165c
lavc/libx264: factor out setting up the input frame
...
X264_frame() is currently too large and complex.
2 years ago
James Almer
a781279871
avformat/oggenc: don't flush twice when the last packet is side data only
...
Commit 18f24527eb
accidentally made side data only packets be handled like a
flush request. Fix this regression by effectively ignoring them as was the
original intention.
Signed-off-by: James Almer <jamrial@gmail.com>
2 years ago
James Almer
99e3d26f20
avformat/mux: use only valid timestamps when calculating packet distance
...
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long int'
Fixes: fate-cover-art-aiff-id3v2-remux, fate-cover-art-mp3-id3v2-remux and fate-mov-cover-image
under ubsan.
Signed-off-by: James Almer <jamrial@gmail.com>
2 years ago
Clément Bœsch
6e05622216
avfilter/paletteuse: use explicit key indexes in set_frame_lut
2 years ago
Clément Bœsch
68275043a0
avfilter/paletteuse: add atkinson dithering
...
Atkinson according to
https://bisqwit.iki.fi/jutut/kuvat/ordered_dither/error_diffusion.txt :
* 1 1 / 8
1 1 1
1
2 years ago
Clément Bœsch
c973e8ae79
avfilter/paletteuse: add burkes dithering
...
Burkes according to
https://bisqwit.iki.fi/jutut/kuvat/ordered_dither/error_diffusion.txt :
* 8 4
2 4 8 4 2 / 32
2 years ago
Clément Bœsch
9973343bf9
avfilter/paletteuse: add sierra3 dithering
...
Sierra3 according to
https://bisqwit.iki.fi/jutut/kuvat/ordered_dither/error_diffusion.txt :
* 5 3
2 4 5 4 2
2 3 2 / 32
2 years ago
Clément Bœsch
11926c4bd4
avfilter/palette{gen,use}: misc for-loop cosmetics
2 years ago
Clément Bœsch
1340fe7caf
avfilter/paletteuse: move r,g,b computation in a more local scope
2 years ago
Clément Bœsch
1ae1b707e2
avfilter/paletteuse: remove mean error tool
...
This belongs in another filter.
2 years ago
Clément Bœsch
8789a9e05b
avfilter/paletteuse: remove alternative search methods
...
This is a maintenance pain more than anything. It appears to make the
code slightly faster as a side effect.
2 years ago
Clément Bœsch
0f7942afa6
avfilter/paletteuse: switch to recursive method
...
It appears faster than the iterative method on my machine (1.06x
faster), so I'm guessing compilers improved over time (the iterative
version was slightly faster in the past).
2 years ago
Clément Bœsch
6c7b54e962
avfilter/paletteuse: use lowbias32 for color hashing
...
Impact is more negligible than previous commit but still faster (1.02x).
2 years ago
Clément Bœsch
c9084cd0e2
avfilter/palettegen: use lowbias32 for color hashing
...
1.12x faster overall in palettegen on my machine.
2 years ago
Clément Bœsch
3cafbdc083
avfilter/palette: add lowbias32 hashing
2 years ago
Clément Bœsch
051926868c
avfilter/palette{gen,use}: update Copyright after recent changes
2 years ago
Clément Bœsch
3a4a6c7815
avfilter/palettegen: use libc qsort
...
Now that the sort function is deterministic, we can rely on the libc
sorting function.
2 years ago
Clément Bœsch
8057e1a618
avfilter/palettegen: make refs order deterministic
...
Currently, in case of equality on the first color channel, the order of
the ref colors is defined by the hashing function. This commit makes the
sorting deterministic and improve the hierarchical ordering.
2 years ago
Clément Bœsch
2441e53c0a
avfilter/palettegen: add a warning about supporting only sRGB
2 years ago
Clément Bœsch
9026d92c13
avfilter/palettegen: base box split decision on a perceptual model
...
Similar to the change in paletteuse, we rely on a perceptual model to
decide how and where to split the box.
2 years ago
Clément Bœsch
724f52b906
avfilter/palettegen: switch to signed arithmetic
...
This prevents mixed sign arithmetic (typically because we have signed
color channel differences), which has nasty side effects in C.
2 years ago
Clément Bœsch
67ce6ad9a2
avfilter/palettegen: rename local variable box_weight to weight
...
This variable is used only for the running weight (used to reach the
target median). The places where we actually need the box weight are
changed to use box->weight.
2 years ago
Clément Bœsch
61d334d8c3
avfilter/palettegen: misc cosmetics
2 years ago
Clément Bœsch
efb0a6f6ce
avfilter/palettegen: compute average color within compute_box_stats()
2 years ago
Clément Bœsch
dafd43b78d
avfilter/palettegen: change cut score from ∑e² to max e²
...
This is following the results from personal research¹.
¹: https://github.com/ubitux/research/tree/main/color-quantization#results
2 years ago
Clément Bœsch
187f5e7f90
avfilter/palettegen: rename variance to cut_score
...
"Variance" wasn't exactly the correct word; "cut score" is more
agnostic, which will be useful when changing the algorithm in the next
commit.
2 years ago
Clément Bœsch
e49fc1a6ef
avfilter/palettegen: always compute the box variance
...
The variance computation is simple enough now (since we can use the axis
squared errors) that it doesn't need to have a complex lazy computation
logic.
2 years ago
Clément Bœsch
9e5f494d26
avfilter/palettegen: use box->major_axis without intermediate variable
2 years ago
Clément Bœsch
86bced7c65
avfilter/palettegen: define the best axis to cut using the squared error
...
This is following the results from personal research¹.
¹: https://github.com/ubitux/research/tree/main/color-quantization#results
2 years ago
Clément Bœsch
21f7814238
avfilter/palettegen: move box stats computation to a dedicated function
2 years ago
Clément Bœsch
a0587c0219
avfilter/paletteuse: switch to a perceptual model
...
Now the selection of the color is based on a distance built around human
perception of color instead of the unreliable sRGB triplet one.
2 years ago
Clément Bœsch
1159c36d6d
avfilter/paletteuse: remove redundant alpha condition
...
This is redundant with a != 0xff below.
2 years ago
Clément Bœsch
4c061bc837
avfilter/paletteuse: remove unused alpha split dimension
...
The equalities in the w{r,g,b} range checks make sure longest is never
0. Even if the alpha ended up being selected in get_next_color() it
would cause underread memory accesses in its caller (colormap_insert).
2 years ago
Clément Bœsch
71ed92e9c4
avfilter/paletteuse: name target color arg consistently in colormap functions
2 years ago