summaryrefslogtreecommitdiffstats
path: root/libhb/nlmeans.c
Commit message (Collapse)AuthorAgeFilesLines
* libhb: propagate color matrix info through the pipelineJohn Stebbins2019-04-081-3/+20
| | | | | | | | | Propagates pix_fmt, range, primaries, transfer, and matrix everywhere. Everything that passes or creates video frames tags the frames with their color matrix info. All filters know the expected color matrix info of input frames.
* Libhb: Some minor logging cleanupsr552019-03-301-1/+1
|
* libhb: Remove some NLMeans TODO comments.Bradley Sepos2019-01-191-2/+0
| | | | NLMeans has used frame threading for years, so SIMD aside, these areas are sufficiently parallelized overall.
* libhb: Reduce the number of threads NLMeans uses with many logical cores.Bradley Sepos2019-01-191-2/+14
| | | | Too many threads increases CPU cache pressure, reducing performance.
* Update copyright dates to 2019.Bradley Sepos2019-01-011-1/+1
|
* libhb: Allow NLMeans prefilter passthru when strength is 0 (zero).Bradley Sepos2018-01-101-6/+6
|
* libhb: Make NLMeans prefilter order consistent.Bradley Sepos2018-01-101-6/+6
|
* libhb: Make prefiltered check in NLMeans more explicit.Bradley Sepos2018-01-101-1/+1
|
* libhb: Reorder some code in nlmeans_prefilter for clarity.Bradley Sepos2018-01-101-11/+7
|
* libhb: Plug memory leak in NLMeans.Bradley Sepos2018-01-101-2/+10
| | | | This reverts 0e072aa42e3affd6280447317375460753f9284b and implements a proper fix for some frames not being prefiltered correctly. Turns out it was an issue with an uninitialized variable.
* libhb: Better prioritize NLMeans prefilter order.Bradley Sepos2018-01-091-11/+11
|
* libhb: Add CSM prefilter to NLMeans.Bradley Sepos2018-01-091-3/+108
| | | | | | | | | | | | | | | | CSM is a Conservative Smoothing filter with Median-like tendencies. Conservative Smoothing is a basic noise reduction method that ensures a given pixel is within the values of those around it. A value higher than all the others is clamped to the maximum value in the neighborhood. Likewise, a value lower than all the others is clamped to the minimum value in the neighborhood. Basically, pixel values that seem to "fit in" are left alone, and extreme values are brought in line. CSM takes this a step further. A pixel not affected by the previous part of the algorithm is subjected to additional thresholding. If the pixel value is closer to the minimum or maximum neighborhood value than the median, it is clamped to the half-way point. Finally, a pixel still not affected is subjected to a third level of thresholding, clamping to the half-way point between the median and the previous half-way point. Any other pixel value is deemed close enough to its peers and left alone. In effect, this creates a "soft" median-like filter, where relatively similar values are left alone and increasingly disparate values are nudged closer together. Practically, CSM is the best prefilter to date for improving weight decisions with sources containing a type or amount of noise proving difficult for NLMeans to uniformly dampen or completely remove on its own. Additionally, it does not significantly alter the strength metric in most cases, so it can simply be enabled wherever desired. From what I can tell in my limited testing, the algorithm respects proper detail and edges well enough that it seems to be safe with nearly any source. Perhaps it should be the default if I ever get around to creating NLMeans 2. Unlike the mean and median prefilters where a larger neighborhood increases the strength of the prefilter, a larger CSM neighborhood merely takes more pixels into account, theoretically decreasing the strength of the filter. In practice, the provided 3x3 and 5x5 neighborhoods typically do not produce significantly differing results. Basic usage: Add y-prefilter=16 to your desired parameters and NLMeans will use CSM for weighting decisions. Use y-prefilter=2064 if you want to see the output of the prefilter itself—the visual effect is mild. Adjust these values to 32 and 2080 for a 5x5 neighborhood; 3x3 works well in all cases I've tried.
* Update copyright dates to 2018.Bradley Sepos2018-01-011-1/+1
|
* libhb: Fix nlmeans prefilter passthru only outputting some frames.Bradley Sepos2017-12-301-7/+0
| | | | Closes #1088.
* libhb: Output result of nlmeans prefilter when passthru enabled.Chris Darroch2017-12-301-2/+11
| | | | | | | | | | | When the prefilter passthru flag is enabled, write the nlmeans prefilter result into the "main" memory buffer (mem) instead of the prefilter one (mem_pre) so that the prefilter result will be output as if it was the result of the nlmeans filter itself. Otherwise, when the passthru flag is enabled, the prefilter result is lost and the filter effectively just outputs its source input without any changes.
* libhb: Fix nlmeans prefilter passthru frame addressing.Chris Darroch2017-12-301-1/+1
| | | | | | In commit 29a49a8, the nlmeans_prefilter() call in nlmeans_filter_thread() was fixed, but a corresponding change was not made to the similar call site in nlmeans_filter_flush().
* libhb: Add threads parameter to NLMeans.Bradley Sepos2017-07-241-16/+22
| | | | Allows setting number of frames to process in parallel. For testing and experts wanting to fine tune the pipeline; e.g., fewer NLMeans threads may make x265 run slightly faster. Realistically, the defaults are the best choice for most everyone.
* nlmeans: fix prefilter passthruJohn Stebbins2017-05-311-1/+1
| | | | This is an error that crept in when making nlmeans multithreaded
* Update copyright dates to 2017.Bradley Sepos2017-01-011-1/+1
|
* filters: make job filter settings an hb_dict_tJohn Stebbins2016-03-091-11/+40
| | | | | | This simplifies accessing and changing filter parameters programatically. It also changes the custom filter string format to a ':' separated list of key/value pairs.
* Update copyright dates to 2016.Bradley Sepos2016-01-011-1/+1
|
* libhb: add hb_buffer_listJohn Stebbins2015-09-241-35/+17
| | | | | This brings together several independent implementations of a simple buffer list manager.
* nlmeans: fix the default valuesjstebbins2015-08-171-2/+2
| | | | | | | Make the nlmeans default (when no string supplied) match "medium" preset. And make the CLI default the medium preset. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7402 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Use a buffer flat to indicate EOFjstebbins2015-05-011-1/+1
| | | | | | | | | | | | ... instead of a 0 length buffer. This fixes this issue: https://forum.handbrake.fr/viewtopic.php?f=12&t=31959 Theora can create 0 length output. These 0 length frames indicate duplicate frames. So we can't use 0 length buffers to indicate the end of the stream. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7143 b64f7644-9d1e-0410-96f1-a4d463321fa5
* nlmeans: fix build on non-x86 architecturesjstebbins2015-02-261-4/+3
| | | | git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6945 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Fix memory alignment issue in nlmeans.bradleys2015-02-161-1/+1
| | | | | | | | Solves crash in accelerated code when source dimensions are not mod 16. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6915 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Fix compiler warnings and more const correctness in nlmeans.bradleys2015-02-161-32/+33
| | | | git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6910 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Additional minor optimizations to nlmeans.bradleys2015-02-111-45/+47
| | | | | | | | | | | Assume buffered planes are equal size in nlmeans. Make nlmeans scalar counters read like accelerated counters (more readable and saves ~2 cycles). Yet more const correctness. Clarify some variable names for readability. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6896 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Minor nlmeans optimizations.bradleys2015-02-061-58/+77
| | | | | | | | | | | | | | Use calloc for nlmeans integral instead of memsets in-loop zeroing. Replace superfluous const with literal in SSE implementation. Move exponential table calculation out of the main loop. More const correctness. Add some braces. Overall, slightly more readable/maintainable and (very) slightly faster. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6874 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: NLMeans x86 SSE acceleration/optimizations.bradleys2015-01-291-36/+80
| | | | | | | | Speed improvements of 1-6% seem typical. Most benefit seems to be for older hardware and/or hardware with fewer threads. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6826 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: thread nlmeans filterjstebbins2014-09-091-184/+410
| | | | | | | Scales well with number of CPUs, so is 4x faster on quad cores. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6397 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Improve nlmeans edgeboost prefilter.bradleys2014-06-281-11/+53
| | | | | | | | | Fixes a typo (1/27 instead of 1/127) that caused edgeboost to match on nearly everything, and tweaks this number slightly. Adds a post-processing step to handle marked pixels having too few marked neighboring pixels as false positives. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6224 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: Add median prefilter to nlmeans.bradleys2014-06-271-5/+118
| | | | git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6223 b64f7644-9d1e-0410-96f1-a4d463321fa5
* libhb: New denoiser, nlmeans.bradleys2014-06-191-0/+742
Non-local means averages multiple patches of similar pixels together, preserving similarities and attenuating variance (usually noise). This is typically more effective than lowpass and more faithfully restores the appearance of structure and detail found in the original source, especially in the high frequency range. Parameters for origin patch weight tuning and pre-filtering further improve on the original algorithm. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6216 b64f7644-9d1e-0410-96f1-a4d463321fa5