summaryrefslogtreecommitdiff
path: root/libavfilter/vf_nlmeans.c
Commit message (Collapse)AuthorAge
* avfilter/vf_nlmeans: Move ff_nlmeans_init into a headerAndreas Rheinhardt2022-05-06
| | | | | | | | This removes a dependency of checkasm on lavfi/vf_nlmeans.o and also allows to inline ff_nlmeans_init() irrespectively of interposing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/vf_nlmeans: add x86 SIMDPaul B Mahol2021-11-11
|
* avfilter/vf_nlmeans: split wa structPaul B Mahol2021-10-29
| | | | This will make x86 SIMD simpler and faster.
* avfilter/vf_nlmeans: refactor line processing in preparation for x86 SIMD ↵Paul B Mahol2021-10-29
| | | | assembly
* avfilter/vf_nlmeans: avoid if () to help paralellizationPaul B Mahol2021-10-29
|
* avfilter/vf_nlmeans: no need to print filter options at info levelPaul B Mahol2021-10-29
|
* avfilter/vf_nlmeans: make access to pointer to lut fasterPaul B Mahol2021-10-29
|
* avfilter/vf_nlmeans: reduce scope of some variablesPaul B Mahol2021-10-29
|
* avfilter: Reindentation after query_formats changesAndreas Rheinhardt2021-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/vf_nlmeans: Use formats list instead of query functionAndreas Rheinhardt2021-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Replace query_formats callback with union of list and callbackAndreas Rheinhardt2021-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If one looks at the many query_formats callbacks in existence, one will immediately recognize that there is one type of default callback for video and a slightly different default callback for audio: It is "return ff_set_common_formats_from_list(ctx, pix_fmts);" for video with a filter-specific pix_fmts list. For audio, it is the same with a filter-specific sample_fmts list together with ff_set_common_all_samplerates() and ff_set_common_all_channel_counts(). This commit allows to remove the boilerplate query_formats callbacks by replacing said callback with a union consisting the old callback and pointers for pixel and sample format arrays. For the not uncommon case in which these lists only contain a single entry (besides the sentinel) enum AVPixelFormat and enum AVSampleFormat fields are also added to the union to store them directly in the AVFilter, thereby avoiding a relocation. The state of said union will be contained in a new, dedicated AVFilter field (the nb_inputs and nb_outputs fields have been shrunk to uint8_t in order to create a hole for this new field; this is no problem, as the maximum of all the nb_inputs is four; for nb_outputs it is only two). The state's default value coincides with the earlier default of query_formats being unset, namely that the filter accepts all formats (and also sample rates and channel counts/layouts for audio) provided that these properties agree coincide for all inputs and outputs. By using different union members for audio and video filters the type-unsafety of using the same functions for audio and video lists will furthermore be more confined to formats.c than before. When the new fields are used, they will also avoid allocations: Currently something nearly equivalent to ff_default_query_formats() is called after every successful call to a query_formats callback; yet in the common case that the newly allocated AVFilterFormats are not used at all (namely if there are no free links) these newly allocated AVFilterFormats are freed again without ever being used. Filters no longer using the callback will not exhibit this any more. Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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/internal: Factor out executing a filter's execute_funcAndreas Rheinhardt2021-08-15
| | | | | | | The current way of doing it involves writing the ctx parameter twice. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/formats: Factor common function combinations outAndreas Rheinhardt2021-08-13
| | | | | | | | | | | Several combinations of functions happen quite often in query_format functions; e.g. ff_set_common_formats(ctx, ff_make_format_list(sample_fmts)) is very common. This commit therefore adds functions that are equivalent to commonly used function combinations in order to reduce code duplication. Reviewed-by: Nicolas George <george@nsup.org> 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_nlmeans: round values toward nearest integerPaul B Mahol2019-10-21
| | | | | Instead of rounding toward zero and thus producing darker output.
* lavfi/nlmeans: use a dynamic size for the weight LUTClément Bœsch2019-02-01
|
* lavfi/nlmeans: simplify log() callClément Bœsch2019-02-01
|
* lavfi/nlmeans: improve the performanceJun Zhao2019-02-01
| | | | | | | | | | | | | | | | | | | | | | | | Remove the pdiff_lut_scale in nlmeans and increase weight_lut table size from 2^9 to 500000, this change will avoid using pdiff_lut_scale in nlmeans_slice() for weight_lut table search, improving the performance by about 12%. (in 1080P size picture case). Use the profiling command like: perf stat -a -d -r 5 ./ffmpeg -i input -an -vf nlmeans=s=30 -vframes 10 \ -f null /dev/null without this change: when s=1.0(default value) 63s s=30.0 72s after this change: s=1.0(default value) 56s s=30.0 63s Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> Signed-off-by: Jun Zhao <mypopydev@gmail.com> Signed-off-by: Clément Bœsch <u@pkh.me>
* lavfi/nlmeans: use AV_CEIL_RSHIFT instead of deprecated FF_CEIL_RSHIFTClément Bœsch2018-05-08
|
* lavfi/nlmeans: inline integral patch value functionClément Bœsch2018-05-08
| | | | | This prevents redundant position computation and make the code faster (1.1x faster overall).
* lavfi/nlmeans: use unsigned for the integral patch valueClément Bœsch2018-05-08
| | | | This value can not be negative.
* lavfi/nlmeans: reorder memory accesses in get_integral_patch_valueClément Bœsch2018-05-08
| | | | This doesn't seem to make much of a difference but it can't hurt.
* lavfi/nlmeans: move final weighted averaging out of nlmeans_planeClément Bœsch2018-05-08
| | | | | | | | | | | | | | | | This helps figuring out where the filter is slow: 70.53% ffmpeg_g ffmpeg_g [.] nlmeans_slice 25.73% ffmpeg_g ffmpeg_g [.] compute_safe_ssd_integral_image_c 1.74% ffmpeg_g ffmpeg_g [.] compute_unsafe_ssd_integral_image 0.82% ffmpeg_g ffmpeg_g [.] ff_mjpeg_decode_sos 0.51% ffmpeg_g [unknown] [k] 0xffffffff91800a80 0.24% ffmpeg_g ffmpeg_g [.] weight_averages (Tested with a large image that takes several seconds to process) Since this function is irrelevant speed wise, the file's TODO is updated.
* lavfi/nlmeans: switch from double to floatClément Bœsch2018-05-08
| | | | | Overall speed appears to be 1.1x faster with no noticeable quality impact.
* lavfi/nlmeans: make compute_safe_ssd_integral_image_c fasterClément Bœsch2018-05-08
| | | | | | | | | | | before: ssd_integral_image_c: 49204.6 after: ssd_integral_image_c: 44272.8 Unrolling by 4 made the biggest difference on odroid-c2 (aarch64); unrolling by 2 or 8 both raised 46k cycles vs 44k for 4. Additionally, this is a much better reference when writing SIMD (SIMD vectorization will just target 16 instead of 4).
* lavfi/nlmeans: add AArch64 SIMD for compute_safe_ssd_integral_imageClément Bœsch2018-05-08
| | | | | ssd_integral_image_c: 49204.6 ssd_integral_image_neon: 28346.8
* lavfi/nlmeans: use ptrdiff_t for linesizesClément Bœsch2018-05-08
| | | | | Similarly to previous commit, this will help writing SIMD code by not having manual zero-extension in SIMD code
* lavfi/nlmeans: add SIMD-friendly assumptions for compute_safe_ssd_integral_imageClément Bœsch2018-05-08
| | | | | | | | | SIMD code will not have to deal with padding itself. Overwriting in that function may have been possible but involve large overreading of the sources. Instead, we simply make sure the width to process is always a multiple of 16. Additionally, there must be some actual area to process so the SIMD code can have its boundary checks after processing the first pixels.
* lavfi/nlmeans: random code shuffling to help compilerClément Bœsch2018-05-08
| | | | This makes nlmeans_slice() slightly faster at least on GCC 7.3.
* avfilter: don't anonymously typedef structsPaul B Mahol2017-05-13
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* lavfi: add nlmeans filterClément Bœsch2016-09-24
Fixes Ticket #4910