## HybridFuPP version 0.92b

INTRODUCTION

This Avisynth script enables both resizing and filtering. Distinct filters can be applied on the different parts of a same picture (edges, static areas, motion, dark and bright areas) : HybridFuPP is a kind of adaptive processor, allowing picture cleaning and compressibility gain.

Main idea consists in filtering strongly the less visible parts of the picture, and very softly the more visible. HybridFuPP uses masks to detect areas to process.

Standard processings proposed are : resizing (5 possibilities), static areas denoising, motion denoising, dark and bright areas denoising, chroma denoising (U and V channels), edges sharpening or softening (distinct horizontal and vertical settings), edges brightness control, deringing (removing artefacts around edges) and deblocking (removing blocks effects generated by mpeg compression).

Though HybridFuPP has been designed first to process rather clean materials, filtering package used is flexible and powerful enough to use it with noisy materials too (depending on noise type) : increasing default settings could be though required.

HybridFuPP is provided with some presets allowing beginners to use the script easily and other people to use these presets as basis for their explorations. Moreover, HybridFuPP allow the user to define its own processing chains (as explained further). Lot of things are therefore possible !

#

# PREREQUISITES

Has been tested with avisynth 2.56 beta 1

Put HybridFuPP.avsi and the provided filters (these dll files have to be uncompressed) in your avisynth plug-ins directory (by default : C:\Program Files\AviSynth 2.5\plugins)

Be sure that UnFilter.dll (v1.5), msharpen.dll (v1.10b2), Deen.dll (v1.0 beta 1), MVTools.dll (0.9.9.1) and Masktools.dll (v1.5.6) are loaded in your main script.

# SYNTAX

HybridFuPP( clip, int width, int height, bool Fast, bool Dering, bool Deblock, int MP_Mode, int EM_Mode, int DB_Q, int DB_Off_a, int DB_Off_b, int M_Thr, int M_SCD, int E_Thr, int D_Thr, int B_Thr, int Resizer , int S_Str, int T_Str, int S_Radius, int S_Dist, int C_Str, int M_Str, int E_Str_X, int E_Str_Y, int E_Str_B, int LP_Str, int DR_Str, int DR_Radius, string show, int N1, int N2, int M, int E1, int E2, int LP, int DR, string Preset )

AVAILABLE PARAMETERS (all of them are optional)

General parameters

# Parameters

# Possible values

# Comments

Resizer

0..5

Resizing algorithm

0 : bilinear ( sharpness - - - / compressibility + + + )

1 : bicubic ( sharpness - - / compressibility + + )

2 : bicubic ( sharpness - / compressibility + )

3 : bicubic ( sharpness + / compressibility - )

4 : bicubic ( sharpness + + / compressibility - - )

5 : lanczos ( sharpness + + + / compressibility - - - )

Width |  | Destination Width. Final size has to be divisible by 4 ( by 8 if you want to use motion processing). It is though advised to use values divisible by 16 because of speed gain.
Height |  | Destination Height. Final size has to be divisible by 4 ( by 8 if you want to use motion processing). It is though advised to use values divisible by 16 because of speed gain.
Fast | True / false | When True, dark areas, lit areas and motion (only if MP_Mode = 2) masks are computed from an already denoised and resized picture (enables HybridFuPP to save time). If False, these masks are computed from a simply resized picture

Preset

Very low

Low

Medium

High

Very High

HybridQ

Anime1

Anime2

Presets allow anyone to use HybridFuPP very quickly and easily while all parameters remain tweakable

« Very Low » or « Very High » are quality related. For instance, « Very low » will deliver a rather strongly denoised picture and weak sharpness (compressibility will be therefore better)

HybridQ will use bilinear resizing while sharpening edges. It will then deliver a good visual impression while maintaining a good compressibility

Presets Anime1 and Anime2 have been designed for anime materials. Anime 2 is very useful for very noisy materials but can sometimes deliver a less detailed picture

Show

E, M, D, B, R, P

Displays masks and / or values used :

E : Edge mask

M : Motion mask

D : Dark areas mask

B : Bright areas mask

R : Deringing mask

P : displays values used ( «mod» will appear closed to the preset name if some default parameters have been modified )

Ex : HybridFuPP(448, 320, Show="MDB") displays motion, dark and bright areas

Static areas denoising

### S_Str

### 0..100

### Spatial filtering strength

### S_Radius

### 0..3

### Radius for spatial filtering

### S_Dist

### 0.0 ..1.0

### Parameter influencing spatial filtering threshold. The weaker, the more edges are preserved.

### T_Str

### 0..100

### Temporal filtering strength

C_Str | 0..100 | chroma filtering (UV)

Motion denoising

MP_Mode | 0..2 | Motion processing mode : 0 : no processing 1 : motion compensated temporal denoising 2 : spatial denoising (default)

###### M_Thr

###### 0..255

###### Motion detection threshold

M_SCD | 0..999 | Scene change detection threshold
M_Str | 0..300 | Spatial processing strength (only with MP_Mode = 2)

Edges processing (accentuation and deringing)

EM_Mode | 1..2 | Edge mask mode : 1 : rather for movie pictures 2 : rather for animes

### E_Thr

### 0..255

### Edges detection threshold

E_Str_X | -50..50 | Horizontal sharpening strength
E_Str_Y | -50..50 | Vertical sharpening strength
E_Str_B | -200..200 | Edges brightness
Dering | True / false | Enables to remove artefacts around edges on source materials. This setting is disactivated in all presets by default. It slows down precessing speed significantly.
DR_Radius | 0..10 | Deringing radius
DR_Str | 0..100 | Deringing strength

Dark and bright areas

D_Thr | 0..255 | Dark areas detection threshold
B_Thr | 0..255 | Bright areas detection. In all presets, this parameter is set to 0, disabling bright areas processing. To process or more simply to display the corresponding mask, you must specify a value. Something between 160 and 180 should be good
LP_Str | 0..30 | Dark and bright areas filtering strength

Deblocking

Deblock | True / false | Enable blocks smoothing. Be careful : if you need to crop your input, cropping must use mod 4 values
DB_Q | 0..51 | Deblocking strength
DB_Off_a | 0..51 | Edges sensitivity
DB_Off_b | 0..51 | Affects both detection threshold and processing strength

NB : parameters N1, N2, E1, E2, M, LP et DR are described in section ‘ADVANCED PARAMETERS’.

PRESETS (be careful, associated parameters could change as HybridFuPP is still in beta stage) :

preset names are generally related to the final quality (« High » means High Quality). The higher (i.e. better quality), the less compressible. You can temporarily change some parameters included in a preset.

ex : HybridFuPP(preset = "very high", E_Thr = 12, dering = true)

presets parameters | Very Low | Low | Medium | High (default) | Very High | HybridQ | Anime1 | Anime2
Resizer | 0 | 2 | 3 | 4 | 5 | 0 | 1 | 1
Fast | True | True | True | True | True | True | True | True
S_Str | 12 | 12 | 10 | 5 | 7 | 5 | 20 | 20
S_Radius | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2
S_Dist | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1
T_Str | 5 | 5 | 3 | 3 | 2 | 3 | 15 | 15
C_Str | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20
MP_Mode | 2 | 2 | 2 | 2 | 2 | 2 | 0 | 0
M_Thr | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10
M_SCD | 260 | 260 | 260 | 260 | 260 | 260 | 260 | 260
M_Str | 120 | 120 | 120 | 120 | 80 | 120 | 0 | 0
EM_Mode | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2
E_thr | 14 | 14 | 14 | 12 | 12 | 10 | 7 | 7
E_Str_X | 0 | 0 | 0 | 0 | 0 | 36 | 30 | 40
E_Str_Y | 0 | 0 | 0 | 0 | 0 | 36 | 30 | 40
E_Str_B | 0 | 0 | 0 | 0 | 0 | 0 | -3 | -3
dering | False | False | False | False | False | False | False | False
DR_Radius | 2 | 2 | 2 | 2 | 2 | 2 | 4 | 4
DR_Str | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30
D_Thr | 39 | 37 | 35 | 32 | 31 | 32 | 30 | 30
B_Thr | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
LP_Str | 30 | 30 | 30 | 30 | 30 | 30 | 40 | 40
Deblock | false | False | False | False | False | False | False | False
DB_Q | 25 | 25 | 25 | 25 | 25 | 25 | 25 | 25
DB_Off_a | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
DB_Off_b | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0

ADVANCED PARAMETERS

HybridFuPP enables to define your own filtering chains, after the resizer for motion, dark and lit areas processing, before or after the resizer for edges and static parts of each frame.

Resizing remains processed by the standard script (but can be defined using the Resizer parameter)

N1 | filtering chain for normal areas, before resizing
N2 | filtering chain for normal areas, after resizing
E1 | filtering chain for edges, before resizing
E2 | filtering chain for edges, after resizing
M | filtering chain for motion
LP | filtering chain for dark and lit areas
DR | filtering chain for deringing

##

## NB : filtering chains have to be defined using quotes

Ex : HybridFuPP(640, 480, preset = "medium", N2 = "deen()" )

if the filtering chain contains quotes, then it has to be defined using triple quotes

ex : HybridFuPP(640, 480, preset = "medium", N2 = "deen()" , Dering = true, DR = """BlindPP(quant= 2, cpu2 = "xxxxxx", moderate_h = 40, moderate_v = 80)""")

All advanced parameters which are not explicitly defined are then replaced by HybridFuPP default processing chains (see further).

It is therefore possible to define only a few advanced parameters (ex : you can define only N1, N2 et LP ; other advanced parameters, i.e. M, E1, E2 and DR, will use default HybridFuPP’s processing chains).

To cancel a default processing chain without defining a new one, you have to use double quotes, and write XX = "", where XX is an advanced parameter (ex : E2 = "" ).

NB : it is not possible to add a filter to a default chain ; the whole chain must be entirely redefined.

HybridFuPP’s default processing chains :

N1 | ""
N2 | """Deen("a3d", S_Radius, S_Str, 3*C_Str, T_Str, C_Str, S_Dist, 9)"""
E1 | "UnFilter(E_Str_X, E_Str_Y)"
E2 | “ColorYUV(off_Y = E_Str_L)”
M* | """Deen("a2d", 1, M_Str, 0, 0, 0, 0, 0)"""
LP | """Deen("a2d", 2, LP_Str, 0, 0, 0, 0, 0)"""
DR | """Deen("a2d", 2, DR_Str, 0, 0, 0, 0, 0)"""

* NB : processing chain M is only used if MP_Mode = 2

EXAMPLES

HybridFuPP( 448, 320 ) | 448x320, use default values. Is therefore equivalent to HybridFuPP(448, 320, preset = "high")
HybridFuPP( 448, 320, preset="low" ) | 448x320, use low quality preset
HybridFuPP( 448, 320, preset="medium", E_Str_X= 40, E_Str_Y = 10 ) | 448x320, preset medium, but applying oversharpening (using a stronger value on horizontal axis, in order to get better aspect for SVCDs for instance)
HybridFuPP(preset = "very high", S_Str = 8, T_Str = 5, C_Str = 0, D_Str = 0 ) | 448x320, using preset "very high", except for ST_Str (spatio-temporal filtering strength). Chroma channels and dark areas will not be processed
HybridFuPP( 448, 320, M_Str = 160, dering = true ) | 448x320, uses default values (see preset "high"), except for M_Str (motion filtering strength) and dering
HybridFuPP( 448, 320, M_Str = 160, dering = true, show = "M" ) | Same than the previous one, but motion mask is displayed
HybridFuPP( 448, 320, preset = "very high", LP = "" ) | 448x320, using preset “very high”. Dark and bright areas processing is though disactivated.
HybridFuPP( 448, 320, show = "MDB", B_Thr = 165 ) | 448x320, displays motion (M), dark areas (D) and bright areas (B). Bright areas detection threshold is set to 165
HybridFuPP( 448, 320, N2 = "temporalsoften(2,3,3,6,2)"", deblock = true) | 448x320. HybridFuPP's default N2 processing (static areas denoising) is replaced with temporalsoften. Deblocking has been activated.

script examples :

a classic one :

Mpeg2Source("c:\test\test.d2v", idct = 6)

Crop(24, 80, 672, 416, align = true)

HybridFuPP(448, 320, preset = "very high")

AddBorders(16,128,16,128)

For those who use GripFit(), you may want to use GripFit_resize_width and GripFit_resize_height variables to define width and height. These variables are initialized by GripCrop() :

Mpeg2Source("c:\test\test.d2v",idct=6)

GripCrop(480, 576, overscan = 2, source_anamorphic=true, dest_anamorphic=true)

HybridFuPP(preset = "very high", width = GripFit_resize_width, height = GripFit_resize_height)

GripBorders()

# THANKS TO

Manao (a lot)

Neuron2, MarcFD and trbarry (for their filters)

Beiji, CAS, ThomN2H, Cyberyeye, Didée, Bond, Jorel, Audioslave and Scharfis_brain (for tips, ideas and feedback)

And all other people who try or use this script...

- FuPP -

# HISTORY

0.92b | 2 modes are available for motion precessing : motion compensated temporal denoising, or spatial denoising. Spatial denoising (default) is faster, but quality is a bit lower.
| MM_Type parameter removed (motion mask type)
| Two edges mask modes (parameter EM_Mode) : 1 is rather for films, 2 for animes
| New deringing processing
| Deblocking mode added (parameters Deblock, DB_Q, DB_Off_a and DB_Off_b)
| Dark areas processing has been modified
| Bright areas processing has been inactivated by default in all presets
| New parameters S_Str et T_Str manage now distinctively spatial and temporal filtering strength (parameter ST_Str has been removed) for static areas
| In order to get better efficiency when denoising static areas, 2 new parameters have been added : S_Radius and S_Dist. The first one is related to filtering radius, and the second one influences spatial filtering threshold (The weaker, the more edges are preserved)
| New parameter E_Str_B : edges brightness
| New parameter Fast (true / false). When True, dark areas, lit areas and motion (only if MP_Mode = 2) masks are computed from an already denoised and resized picture (enabling HybridFuPP to save time). If False, these masks are computed from a simply resized picture
| 2 new presets : anime1 and anime2
| New preset HybridQ that allows sharp edges while maintaining good compressibility
| Parameter L_Thr has been renamed in B_Thr
| New parameters available for 'Show' : “R” (displays areas that will be deringed) and “P” (displays all the parameters used)
| Be careful : range of valid values have been modified for a few parameters. Please have a look on the documentation above.
0.9a à 0.917a | Non official alpha versions
0.89a à 0.897a | Non official alpha versions
0.882b | Bug fixed when width or height were lee than 256
0.881b | Deringing bug fixed
0.88b | No more multiple resizing
| Standard filtering chains have been changed a lot
| Like dark areas, bright areas are now processed too
| Chroma processing has been improved
| New and more efficient motion detection engine (thanks Manao). The old one, and an improved version of it, are though available too (use parameter MM_Type)
| New presets : “very low”, “low”, “medium”, “high” (default), “very high” and “anime”
| « Debug » mode is now called « Show ». As previously, it enables to display the masks. Using it is easier too.
| New parameters (C_Str = chroma filtering strength, L_Thr = lit areas threshold, LP_Str = dark and lit areas filtering strength). Some others are no more used (chroma, dark, D_Str, Eresizer, Nresizer, CH…)
| Dering no more returns an error when used with non mod 16 destination width and height. It will simply be disactivated if needed.
0.85a à 0.87a | Non official alpha versions
0.84b | It is now possible to create personal processing chains
| Advanced debug mode (displayed with colors, modes can be now combined)
| Added a strength parameter for dark areas processing
| More speed
| No more limits concerning final size for chroma and dark (called ‘special’ in 0.7x versions) modes
| Deringing (optional) is now done after resizing. Mod 16 size limit concerns now only final size.
| Be careful : some parameters have been renamed (ex : special -> dark).
| Parameters order has changed ! so be careful if you used unnamed parameters in previous releases. ex : HybridFuPP(448,320,12,7,10,30,9,32,17,1,5,true,true,true,30,0)
0.80a à 0.83a | Non official alpha versions
0.71b: | Added a threshold parameter for special mode (i.e. dark areas processing)
0.7b | Special processing of dark areas, i.e. soft resizing + strong filtering (optional). Compressibility : up to 12% more
| It is now possible to choose resizing algorithm for edges
| Motion spatial filtering has been re-introduced (because of users request)
| A little bit less speed if dark areas processing is used (activated by default), a little bit more than 0.6b if it is not used
0.6b | Resizing algorithm and settings can be now selected for picture parts displaying no motion nor edges
| Edge detection algorithm changed (uses Msharpen now)
| Default values have been changed
| Presets have been changed
| It is now possible to override parameters included in a preset
| Spatial filtering has been removed when processing motion (offered a very weak compressibility gain)
| General picture quality improvements
| Speed improvement
0.5b | Added presets
| Changed defaults for better quality
| Changed spatio-temporal filter position in the chain
0.4b | Added parameters for both spatio-temporal and spatial filtering
| Changed default value for Edge detection threshold from 15 to 10
| Chroma smoothing is now done after resizing. Dering is still done before. Will see later...
0.3b | Errors with non mod16 sources are better managed
0.2b | First downloadable version