Srestore

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(2.7f -> 2.7f+ (as in g))
(Parameters)
Line 20: Line 20:
 
*[http://forum.doom9.org/showthread.php?t=139337 GRunT] Version 1.0.1 or higher (only for v2.7f+)
 
*[http://forum.doom9.org/showthread.php?t=139337 GRunT] Version 1.0.1 or higher (only for v2.7f+)
  
==Parameters==
+
==Syntax and Parameters==
{{Par|frate|float|optional}}
+
:{{Template:FuncDef|srestore(clip source, float "frate", "omode", float "blocks", int "mthresh", int "bthresh", bool "chroma", int "cache", float "rr", clip "dclip")}}
You don't need to set the decimation parameters for the norm conversions restoring Pal_to_NTSC (50->23.976 or 25->11.988) and NTSC_to_Pal (59.94->25 or 29.97->12.5), but for some seldom other blend conversion (for example 29.97 back to 23.976 or 50 to 25 - DEFT). Use frate to set the wanted output-framerate. If source-framerate/frate >5 or <1 the output-framerate will be the same as the input-framerate. This can be useful if you want to have only the dup functionality of srestore.
+
<br>
 +
::{{Par|frate|float|optional}}
 +
:::You don't need to set the decimation parameters for the norm conversions restoring Pal_to_NTSC (50->23.976 or 25->11.988) and NTSC_to_Pal (59.94->25 or 29.97->12.5),  
 +
:::but for some seldom other blend conversion (for example 29.97 back to 23.976 or 50 to 25 - DEFT). Use frate to set the wanted output-framerate.  
 +
:::If source-framerate/frate >5 or <1 the output-framerate will be the same as the input-framerate. This can be useful if you want to have only the dup functionality of srestore.
 +
<br>
 +
::{{ParR|omode|string|6|0-6 or mode}}
 +
:::Srestore can be used as blend-decimation-function, as simple deblend-function and for double-blend-removal
 +
:::: 1  - deblend-mode 1        -> detected blends will be replaced with the previous frame
 +
:::: 2  - deblend-mode 2        -> next frame is used instead of the detected blend
 +
:::: 3  - deblend-mode 3        -> detected blends will be replaced with the neighbour that has the smaller difference
 +
:::: 4  - deblend-mode 4        -> use the neighbour with the smaller blend-possibility
 +
:::: 5  - deblend-special      -> outputs the one of four frames with the smallest blend-possibility
 +
:::: >5  - blend-decimation      -> for all decimation operations
  
{{ParR|omode|string|6|0-6 or mode}}
+
:::The output-modes 1-5 are simple deblending modes, so the framerate will not change.
Srestore can be used as blend-decimation-function, as simple deblend-function and for double-blend-removal
+
       
: 1  - deblend-mode 1        -> detected blends will be replaced with the previous frame
+
:::To enable the double-blend-removal you have to set a string for omode. This string decides about the postprocessing mode that is used on the restored frames:
: 2  - deblend-mode 2        -> next frame is used instead of the detected blend
+
:::: pp0 -> the fastest mode, no postprocessing
: 3  - deblend-mode 3        -> detected blends will be replaced with the neighbour that has the smaller difference
+
:::: pp1 -> use difference masking, higher quality and still good speed
: 4  - deblend-mode 4        -> use the neighbour with the smaller blend-possibility
+
:::: pp2 ->  use a special blurring mask on luma and chroma that reduces artefacts
: 5  - deblend-special       -> outputs the one of four frames with the smallest blend-possibility
+
:::: pp3 -combines postprocessing 1 and 2  -> slowest
: >5 - blend-decimation      -> for all decimation operations
+
  
The output-modes 1-5 are simple deblending modes, so the framerate will not change.
 
           
 
To enable the double-blend-removal you have to set a string for omode. This string decides about the postprocessing mode that is used on the restored frames:
 
: pp0 ->  the fastest mode, no postprocessing
 
: pp1 ->  use difference masking, higher quality and still good speed
 
: pp2 ->  use a special blurring mask on luma and chroma that reduces artefacts
 
: pp3 ->  combines postprocessing 1 and 2  -> slowest
 
  
You can add also your own postprocessing to these modes. Just add your function like this:
+
:::You can add also your own postprocessing to these modes. Just add your function like this:
 +
::::<pre>omode="pp3.blur(1)"   -> pp3 + blurring</pre>
  
omode="pp3.blur(1)"   -> pp3 + blurring
+
:::If you want to add a function with its own inputstrings use three quotation marks:
If you want to add a function with its own inputstrings use three quotation marks:
+
::::<pre>omode="""pp2.deen("a2d")"""</pre>
omode="""pp2.deen("a2d")"""
+
  
Important Note: Also the double-blend-removal does no decimation. It's created only for double-blends caused by blend deinterlacing of telecined sources. You have to add an decimation function for full restoring:
+
<blockquote><blockquote>
 
+
Important Note:<br>
  source                          #progressive
+
::Also the double-blend-removal does no decimation. It's created only for double-blends caused by blend deinterlacing of telecined sources.<br>
srestore(dmode=-4,omode="pp0")
+
::You have to add an decimation function for full restoring:
decimate(cycle=5,quality=0)    #recommed decimating
+
  <blockquote>
 
+
  <pre>
{{ParR|speed|int|9|-25-25}}
+
  source                          #progressive
With the speed parameter you can set a speed-vs-detail-detection value. If you set speed=25, only one of 25 pixels (5*5) is used for the detection. Higher values result in a lower possibility of low-detail detection. Set a negative speed value for high quality and hd sources. This can improve the detection of small details.
+
  srestore(dmode=-4,omode="pp0")
 
+
  decimate(cycle=5,quality=0)    #recommed decimating
{{ParR|mode|int|2|1-3}}
+
  </pre>
With the mode parameter you can decide if chroma should be used for detection and if srestore have to merge neighboured frames or look for dups to improve output quality:
+
</blockquote>
: 1  - simple output mode, decimation is not touched
+
</blockquote>
: 2  - duping feature, if a frame has a dup-neighbour, that seems to have a higher quality, this one will be outputed
+
<br>
: 3  - like 2 but the duplicates will be merged
+
:{{ParR|speed|int|9|-25-25}}
: >3  - mode 2 and 3 combined
+
::With the speed parameter you can set a speed-vs-detail-detection value. If you set speed=25, only one of 25 pixels (5*5) is used for the detection.  
By setting the compatible negative values, the chroma values will be also used for the detection.
+
::Higher values result in a lower possibility of low-detail detection. Set a negative speed value for high quality and hd sources. This can improve the detection of small details.
Note: The double-blend-removal does not use this parameter (-> only mode 1 or -1).
+
<br>
 
+
:{{ParR|mode|int|2|1-3}}
{{ParR|thresh|int|22|12-44}}
+
::With the mode parameter you can decide if chroma should be used for detection and if srestore have to merge neighboured frames or look for dups to improve output quality:
The detection of srestore is pretty stable, but the threshold is still important to weight the detection influence. Use small values for sources with little temporal artefacts (bobbing effect, aliasing, blocks, noise, ...) and higher values for the opposite case.
+
::: 1  - simple output mode, decimation is not touched
 
+
::: 2  - duping feature, if a frame has a dup-neighbour, that seems to have a higher quality, this one will be outputed
{{ParR|cache|int|-1|-1-10}}
+
::: 3  - like 2 but the duplicates will be merged
With cache>=0 srestore use the RequestLinear function (TIVTC) to be more compatible with non-linear requesting (codec or other functions). Best way to use srestore is to do a lossless first pass right after calling srestore and do all other filtering and the final encoding in a second pass. If you do not have enough space to do a lossless pass and you cannot avoid non-linear frame requesting and the pattern of the source is pretty unstable set cache around 5-10, but keep in mind that this can increase memory usage.
+
::: >3  - mode 2 and 3 combined
   
+
:::By setting the compatible negative values, the chroma values will be also used for the detection.
{{Par|dclip|clip|input}}
+
::Note: The double-blend-removal does not use this parameter (-> only mode 1 or -1).
The '''d'''etection '''clip''' can be used to improve (deblock, smooth, ...) and speed-up blend and motion detection. The selected clip is only used for detection and not for output, so it does not affect the output quality.  
+
<br>
If you use a high quality deinterlacing on the source you can speed up the detection by using a faster deinterlacing function (third code example) for the detection clip.
+
:{{ParR|thresh|int|22|12-44}}
It's recommended to crop the bobbed source (deinterlace BEFORE cropping!) to avoid the detection influence of the bobbing borders (second code example).
+
::The detection of srestore is pretty stable, but the threshold is still important to weight the detection influence.
 +
::Use small values for sources with little temporal artefacts (bobbing effect, aliasing, blocks, noise, ...) and higher values for the opposite case.
 +
<br>
 +
:{{ParR|cache|int|-1|-1-10}}
 +
::With cache>=0 srestore use the RequestLinear function (TIVTC) to be more compatible with non-linear requesting (codec or other functions).
 +
::Best way to use srestore is to do a lossless first pass right after calling srestore and do all other filtering and the final encoding in a second pass.  
 +
::If you do not have enough space to do a lossless pass and you cannot avoid non-linear frame requesting and the pattern of the source is pretty unstable set cache around 5-10,  
 +
::but keep in mind that this can increase memory usage.
 +
<br>
 +
:{{Par|dclip|clip|input}}
 +
::The '''d'''etection '''clip''' can be used to improve (deblock, smooth, ...) and speed-up blend and motion detection.  
 +
::The selected clip is only used for detection and not for output, so it does not affect the output quality.  
 +
::If you use a high quality deinterlacing on the source you can speed up the detection by using a faster deinterlacing function (third code example) for the detection clip.
 +
::It's recommended to crop the bobbed source (deinterlace BEFORE cropping!) to avoid the detection influence of the bobbing borders (second code example).
 +
<br>
  
 
== Examples==  
 
== Examples==  

Revision as of 20:31, 24 December 2013

Abstract
Author MOmonster
Version 2.7e, 2.7g
Download 2.7e: srestore.avsi

2.7g: srestore_27g.avsi

Category Deblenders
Requirements
  • YV12
License
Discussion

srestore(clip source, float frate, int dmode, omode, float blocks, int mthresh, int bthresh, bool chroma, int cache, float rr, clip dclip)


Contents

Abstract

Srestore is the replacement function for mrestore, Cdeblend, FixBlendIVTC and DupHq from the R_pack. It is an AviSynth script function that uses conditional frame evaluation for the output calculation. Generally it was written to undo norm-conversions with blends, but the last version can be useful for decimation ratios between 5 and 1 using the frate parameter.

Important note: Srestore 2.7e can only be called one time in any script due to its use of global variables. Srestore 2.7f+ can be called as many times as you like. This is hopefully the only functional difference.

Requires Filters

  • MaskTools2
  • TIVTC Version 1.04 or higher (only for cache>0, not default)
  • RemoveGrain (only for double-blend-removal, not default)
  • Average (only for double-blend-removal, not default)
  • GRunT Version 1.0.1 or higher (only for v2.7f+)

Syntax and Parameters

srestore(clip source, float "frate", "omode", float "blocks", int "mthresh", int "bthresh", bool "chroma", int "cache", float "rr", clip "dclip")


frate float = optional
You don't need to set the decimation parameters for the norm conversions restoring Pal_to_NTSC (50->23.976 or 25->11.988) and NTSC_to_Pal (59.94->25 or 29.97->12.5),
but for some seldom other blend conversion (for example 29.97 back to 23.976 or 50 to 25 - DEFT). Use frate to set the wanted output-framerate.
If source-framerate/frate >5 or <1 the output-framerate will be the same as the input-framerate. This can be useful if you want to have only the dup functionality of srestore.


omode string (0-6 or mode, default 6)
Srestore can be used as blend-decimation-function, as simple deblend-function and for double-blend-removal
1 - deblend-mode 1 -> detected blends will be replaced with the previous frame
2 - deblend-mode 2 -> next frame is used instead of the detected blend
3 - deblend-mode 3 -> detected blends will be replaced with the neighbour that has the smaller difference
4 - deblend-mode 4 -> use the neighbour with the smaller blend-possibility
5 - deblend-special -> outputs the one of four frames with the smallest blend-possibility
>5 - blend-decimation -> for all decimation operations
The output-modes 1-5 are simple deblending modes, so the framerate will not change.
To enable the double-blend-removal you have to set a string for omode. This string decides about the postprocessing mode that is used on the restored frames:
pp0 -> the fastest mode, no postprocessing
pp1 -> use difference masking, higher quality and still good speed
pp2 -> use a special blurring mask on luma and chroma that reduces artefacts
pp3 -> combines postprocessing 1 and 2 -> slowest


You can add also your own postprocessing to these modes. Just add your function like this:
omode="pp3.blur(1)"		   -> pp3 + blurring
If you want to add a function with its own inputstrings use three quotation marks:
omode="""pp2.deen("a2d")"""
Important Note:
Also the double-blend-removal does no decimation. It's created only for double-blends caused by blend deinterlacing of telecined sources.
You have to add an decimation function for full restoring:
   source                          #progressive
   srestore(dmode=-4,omode="pp0")
   decimate(cycle=5,quality=0)     #recommed decimating
  


speed int (-25-25, default 9)
With the speed parameter you can set a speed-vs-detail-detection value. If you set speed=25, only one of 25 pixels (5*5) is used for the detection.
Higher values result in a lower possibility of low-detail detection. Set a negative speed value for high quality and hd sources. This can improve the detection of small details.


mode int (1-3, default 2)
With the mode parameter you can decide if chroma should be used for detection and if srestore have to merge neighboured frames or look for dups to improve output quality:
1 - simple output mode, decimation is not touched
2 - duping feature, if a frame has a dup-neighbour, that seems to have a higher quality, this one will be outputed
3 - like 2 but the duplicates will be merged
>3 - mode 2 and 3 combined
By setting the compatible negative values, the chroma values will be also used for the detection.
Note: The double-blend-removal does not use this parameter (-> only mode 1 or -1).


thresh int (12-44, default 22)
The detection of srestore is pretty stable, but the threshold is still important to weight the detection influence.
Use small values for sources with little temporal artefacts (bobbing effect, aliasing, blocks, noise, ...) and higher values for the opposite case.


cache int (-1-10, default -1)
With cache>=0 srestore use the RequestLinear function (TIVTC) to be more compatible with non-linear requesting (codec or other functions).
Best way to use srestore is to do a lossless first pass right after calling srestore and do all other filtering and the final encoding in a second pass.
If you do not have enough space to do a lossless pass and you cannot avoid non-linear frame requesting and the pattern of the source is pretty unstable set cache around 5-10,
but keep in mind that this can increase memory usage.


dclip clip = input
The detection clip can be used to improve (deblock, smooth, ...) and speed-up blend and motion detection.
The selected clip is only used for detection and not for output, so it does not affect the output quality.
If you use a high quality deinterlacing on the source you can speed up the detection by using a faster deinterlacing function (third code example) for the detection clip.
It's recommended to crop the bobbed source (deinterlace BEFORE cropping!) to avoid the detection influence of the bobbing borders (second code example).


Examples

bobbed (or progressive) source

srestore()

or:

ord = last.getparity() ? 1 : 0
leakkernelbob(ord,4,true,true)
srestore(dclip=last.crop(8,16,-8,-24))

or:

d = last.bob(-0.2,0.6).reduceflicker(strength=1)
tdeint(mode=1)   #or for example yadif(mode=1)
srestore(mode=4,dclip=d)

External Links

Personal tools