summaryrefslogtreecommitdiff
path: root/libavfilter/vf_paletteuse.c
Commit message (Collapse)AuthorAge
* avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilterAndreas Rheinhardt2021-08-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, an AVFilter's lists of input and output AVFilterPads were terminated by a sentinel and the only way to get the length of these lists was by using avfilter_pad_count(). This has two drawbacks: first, sizeof(AVFilterPad) is not negligible (i.e. 64B on 64bit systems); second, getting the size involves a function call instead of just reading the data. This commit therefore changes this. The sentinels are removed and new private fields nb_inputs and nb_outputs are added to AVFilter that contain the number of elements of the respective AVFilterPad array. Given that AVFilter.(in|out)puts are the only arrays of zero-terminated AVFilterPads an API user has access to (AVFilterContext.(in|out)put_pads are not zero-terminated and they already have a size field) the argument to avfilter_pad_count() is always one of these lists, so it just has to find the filter the list belongs to and read said number. This is slower than before, but a replacement function that just reads the internal numbers that users are expected to switch to will be added soon; and furthermore, avfilter_pad_count() is probably never called in hot loops anyway. This saves about 49KiB from the binary; notice that these sentinels are not in .bss despite being zeroed: they are in .data.rel.ro due to the non-sentinels. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/vf_paletteuse: do not use in dithering transparent palettePaul B Mahol2021-08-19
|
* avfilter/vf_paletteuse: fix some integer overflowsPaul B Mahol2021-08-19
|
* avfilter/vf_paletteuse: do not sort transparency colorPaul B Mahol2021-08-19
| | | | | Make last palette entry always transparent color. Fixes wrong filtered output with new=1 option set.
* avfilter/vf_paletteuse: Remove redundant freeing codeAndreas Rheinhardt2021-08-15
| | | | | | AVFilter.uninit is called automatically if init fails. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Constify all AVFiltersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/vf_paletteuse: Fix left shift outside of range of intAndreas Rheinhardt2021-03-28
| | | | | | | by keeping the variable uint32_t which in this situation is the natural type anyway. This affected the FATE-test filter-paletteuse-sierra2_4a. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavfi: regroup formats lists in a single structure.Nicolas George2020-09-08
| | | | | | | | | | | | | | | It will allow to refernce it as a whole without clunky macros. Most of the changes have been automatically made with sed: sed -i ' s/-> *in_formats/->incfg.formats/g; s/-> *out_formats/->outcfg.formats/g; s/-> *in_channel_layouts/->incfg.channel_layouts/g; s/-> *out_channel_layouts/->outcfg.channel_layouts/g; s/-> *in_samplerates/->incfg.samplerates/g; s/-> *out_samplerates/->outcfg.samplerates/g; ' src/libavfilter/*(.)
* avfilter/vf_paletteuse: Fix leaks of AVFilterFormats on errorAndreas Rheinhardt2020-08-23
| | | | | | | | | | | | | | | | | | | | | | The paletteuse's query_formats function allocated three AVFilterFormats before storing them permanently. If allocating one of them failed, the three AVFilterFormats structures would be freed with av_freep() which does not free separately allocated subelements (namely the formats array) which leak. Furthermore, if storing one of the first two fails, the function simply returns and the ones not yet stored leak. These leaks have been fixed by only creating a new AVFilterFormats after the last one has already been permanently stored. Furthermore, it is enough to check whether the elements have been properly stored as ff_formats_ref() by design returns AVERROR(ENOMEM) if it is provided a NULL AVFilterFormats *. Fixes Coverity issues #1270818 and #1270819. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avfilter/vf_paletteuse: Forward error codesAndreas Rheinhardt2020-03-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* remove CHAR_MIN/CHAR_MAX usagePaul B Mahol2020-03-17
| | | | It is not needed at all.
* avfilter/vf_paletteuse: Fix potential double-free of AVFrameAndreas Rheinhardt2020-02-08
| | | | | | | | | | | | | | | | | | apply_palette() would free an AVFrame given to it only via an AVFrame * (and not via AVFrame **) in three of its four exists (namely in the normal path and in two error paths). So upon error the caller has no way to know whether the frame has already been freed or not; load_apply_palette(), the only caller, opted to free the frame in this scenario. This commit changes this by making apply_palette not freeing the frame at all, which is left to load_apply_palette(). Fixes Coverity issue #1452434. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/vf_paletteuse: don't constantly free and realloc internal framesJames Almer2019-01-17
| | | | | Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/vf_paletteuse: fix flags for alpha_threshold optionPaul B Mahol2018-12-11
|
* vf_paletteuse: Don't free the second frame from ↵Derek Buitenhuis2018-01-03
| | | | | | | | ff_framesync_dualinput_get_writable on error This fixes a double free in he error case. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* vf_paletteuse: Add error checking to apply_paletteDerek Buitenhuis2018-01-03
| | | | | | | This fixes a segfault caused by passing NULL to ff_filter_frame when an error occurs. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* lavfi/paletteuse: check get_color return valueTimo Rothenpieler2017-11-13
| | | | Fixes CID #1420396
* lavfi/paletteuse: fix debug_kdtree after aba926e7dClément Bœsch2017-10-28
|
* lavfi/paletteuse: fix debug_mean_error after aba926e7dClément Bœsch2017-10-28
|
* lavfi/paletteuse: fix debug_accuracy after aba926e7dClément Bœsch2017-10-28
|
* lavfi/paletteuse: simplify color get function prototypesClément Bœsch2017-10-28
|
* lavfi/paletteuse: move "new" option before debugging optionsClément Bœsch2017-10-28
|
* lavfi/paletteuse: fix to support transparencyBjorn Roche2017-10-28
| | | | | | | | | | | | | | | | | | This patch enables paletteuse to identify the transparency in incoming video and tag transparent pixels on outgoing video with the correct index from the palette. This requires tracking the transparency index in the palette, establishing an alpha threshold below which a pixel is considered transparent and above which the pixel is considered opaque, and additional changes to track the alpha value throughout the conversion process. This change is a partial fix for https://trac.ffmpeg.org/ticket/4443 However, animated GIFs are still output incorrectly due to a bug in gif optimization which does not correctly handle transparency. Signed-off-by: Clément Bœsch <u@pkh.me>
* lavfi: Rename local variables "main" as "master".Carl Eugen Hoyos2017-10-07
| | | | | Silences several warnings: main is usually a function
* lavfi: rename framesync2 to framesync.Nicolas George2017-09-12
|
* lavfi/vf_paletteuse: convert to framesync2.Nicolas George2017-08-29
|
* avfilter/vf_paletteuse: silence warning about misaligned indentationPaul B Mahol2017-04-10
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* Fix all -Wformat warnings raised by DJGPPClément Bœsch2017-03-29
|
* lavfi: split frame_count between input and output.Nicolas George2016-11-13
| | | | | | | | | | | | AVFilterLink.frame_count is supposed to count the number of frames that were passed on the link, but with min_samples, that number is not always the same for the source and destination filters. With the addition of a FIFO on the link, the difference will become more significant. Split the variable in two: frame_count_in counts the number of frames that entered the link, frame_count_out counts the number of frames that were sent to the destination filter.
* avfilter/vf_paletteuse: add option to use new palette for each output framePaul B Mahol2016-09-07
|
* avfilter/vf_paletteuse: enable skip_initial_unpairedMichael Niedermayer2016-06-26
| | | | | | | | | Fixes crash due to unprocessed input being passed through This fixes the last segfault caused by mixing 3.0 and 3.1 libs and applications Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/all: propagate errors of functions from avfilter/formatsGanesh Ajjanagadde2015-10-14
| | | | | | | | | | | | | | | | | | Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM). This propagates the return values. All of these were found by using av_warn_unused_result, demonstrating its utility. Tested with FATE. I am least sure of the changes to avfilter/filtergraph, since I don't know what/how reduce_format is intended to behave and how it should react to errors. Fixes: CID 1325680, 1325679, 1325678. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Previous version Reviewed-by: Nicolas George <george@nsup.org> Previous version Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avfilter/paletteuse: use AV_OPT_TYPE_BOOL for mean_err and debug_accuracy optionClément Bœsch2015-09-09
|
* Replace av_dlog with ff_dlog.Ronald S. Bultje2015-08-18
| | | | | ff_dlog checks compilability, and is non-public. av_dlog is deprecated and no longer exists if FF_API_DLOG=0.
* avfilter/vf_paletteuse: indent fix after 7ccc5848Clément Bœsch2015-03-05
|
* avfilter/vf_paletteuse: Use int where AVERROR can be returnedMichael Niedermayer2015-03-05
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avfilter/paletteuse: use AV_QSORT()Clément Bœsch2015-02-26
| | | | See previous commit for a rationale.
* avfilter/palette{gen,use}: add CopyrightClément Bœsch2015-02-23
|
* avfilter/paletteuse: add diff_modeClément Bœsch2015-02-23
|
* avfilter/paletteuse: fix error dithering accuracyClément Bœsch2015-02-23
|
* avfilter/paletteuse: fix leak in case of errorClément Bœsch2015-02-18
| | | | Fixes CID1270819
* avfilter/paletteuse: raise cache size from 64k to 512kClément Bœsch2015-02-17
| | | | (or 32k to 256k in 32-bit)
* avfilter: add paletteuse filterClément Bœsch2015-02-14