Limiter

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:FuncDef|Limiter(clip ''clip'' [, int ''min_luma''] [, int ''max_luma''] [, int ''min_chroma''] [, int ''max_chroma'']  [, string show])}}
+
The standard known as Rec.601 or [[Wikipedia:Rec._601|CCIR-601]] (''Studio Encoding Parameters of Digital Television...'') defines standard quantization levels: for luminance, black is '''16''' and peak white is '''235'''. For chrominance, the range is '''16''' to '''240''', with the center (grey) at 128. "The signal may occasionally excurse beyond" this range according to Rec.601.
  
This filter is present in v2.5. The standard known as CCIR-601 defines the range of pixel values considered legal for presenting on a TV. These ranges are 16-235 for the luma component and 16-240 for the chroma component.
+
Luminance or chrominance values outside this range are [http://forum.doom9.org/showthread.php?p=1108323#post1108323 known to cause problems with some TV sets], so '''Limiter''' was created to ''clip'' them (or [[Talk:Levels#Clamping_vs._Clipping|''clamp'']] them - both terms are used) to the ranges [{{FuncArg|min_luma}}''', '''{{FuncArg|max_luma}}] and [{{FuncArg|min_chroma}}''', '''{{FuncArg|max_chroma}}], which you may specify, but by default are the Rec.601 values listed above.  
  
Pixels outside this range are known to cause problems with some TV sets, and thus it is best to remove them before encoding if that is your intended display device. By default this filter clips (or "clamps") pixels under 16 to 16 and over 235 (or 240) to 235 (or 240).
 
  
Prior to v2.53 the (incorrect) default value was 236. Use Limiter(16, 235, 16, 240) for CCIR-601 compliant digital video.
+
== Syntax and Parameters ==
 +
{{Template:FuncDef
 +
|Limiter(clip ''clip'' [, int ''min_luma'', int ''max_luma'', int ''min_chroma'', int ''max_chroma'', string show ] )
 +
}}
  
In  v2.56, an option ''show'' is added (works only for YUY2, YV12 and since v2.60 for YV24). If set, it colors the pixels outside the specified [min_luma,max_luma] or [min_chroma,max_chroma] range. ''show'' can be "luma" (shows out of bound luma), "luma_grey" (shows out of bound luma and makes the remaining pixels grey), "chroma" (shows out of bound chroma), "chroma_grey" (shows out of bound chroma and makes the remaining pixels grey). The coloring is done as follows:
+
:{{Par2|clip|clip|(required)}}
 +
::Source clip. [[YUV]] only.
  
YUY2 (chroma shared between two horizontal pixels p1 and p2: Y1UY2V): j,k=1,2 <br>
+
:{{Par2|min_luma|int|16}}
YV24 (no chroma shared): j,k=1 <br>
+
::''Y'' (luma) lower clamping limit.
YV12 (chroma shared between 2x2 pixels Y11UY12V; Y21UY22V): j,k=11,12,21,22
+
  
{| border="1"
+
:{{Par2|max_luma|int|235}}
|-  
+
::''Y'' (luma) upper clamping limit.
|  
+
 
| "luma" / "chroma"
+
:{{Par2|min_chroma|int|16}}
| "luma_grey" / "chroma_grey"
+
::''U'' & ''V'' (chroma) lower clamping limit.
 +
 
 +
:{{Par2|max_chroma|int|240}}
 +
::''U'' & ''V'' (chroma) upper clamping limit.
 +
 
 +
:{{Par2|show|string|(empty)}}
 +
::Colorizes the pixels outside the specified [{{FuncArg|min_}}''X'', {{FuncArg|max_}}''X''] range.
 +
::If set, {{FuncArg|show}} must take one of the following values:
 +
::{| class="wikitable" style="width:40em;"
 +
!style="text-align:left;"| {{FuncArg|show}}
 +
!style="text-align:left;"| Effect
 +
|-
 +
|"luma"
 +
|''colorizes out of bound luma''
 +
|-
 +
|"luma_grey"
 +
|''colorizes out of bound luma, and makes the remaining pixels grey''
 +
|-
 +
|"chroma"
 +
|''colorizes out of bound chroma''
 +
|-
 +
|"chroma_grey"
 +
|''colorizes out of bound chroma, and makes the remaining pixels grey''
 +
|}
 +
::The colorizing is done as follows:
 +
::*[[YUY2]]: {{Serif|j}},{{Serif|k}}=1,2 (chroma shared between two horizontal pixels p1 and p2: Y1UY2V)
 +
::*[[YV24]]: {{Serif|j}},{{Serif|k}}=1 (no chroma shared)
 +
::*[[YV12]]: {{Serif|j}},{{Serif|k}}=11,12,21,22 (chroma shared between 2x2 pixels Y11UY12V: Y21UY22V)
 +
 
 +
::{| class="wikitable"
 +
! style="text-align:left;vertical-align:top;width:12em;"| Pixel Condition
 +
! style="text-align:left;vertical-align:top;width:12em;"| Colorization
 +
{{FuncArg|show}}="luma"
 +
{{FuncArg|show}}="chroma"
 +
! style="text-align:left;vertical-align:top;width:12em;"| Colorization
 +
{{FuncArg|show}}="luma_grey"
 +
{{FuncArg|show}}="chroma_grey"
 
|-  
 
|-  
| Yj < min_luma
+
| ''Y''j < {{FuncArg|min_luma}}
 
| red (pj)
 
| red (pj)
 
| red (pj)
 
| red (pj)
 
|-  
 
|-  
| Yj > max_luma
+
| ''Y''j > {{FuncArg|max_luma}}
 
| green (pj)
 
| green (pj)
 
| green (pj)
 
| green (pj)
 
|-  
 
|-  
| Yj < min_luma and Yk > max_luma
+
| ''Y''j < {{FuncArg|min_luma}}&nbsp;and ''Y''k&nbsp;>&nbsp;{{FuncArg|max_luma}}
 
| yellow (pj and pk)
 
| yellow (pj and pk)
 
| puke (pj), olive (pk)
 
| puke (pj), olive (pk)
 
|-  
 
|-  
|
+
| ''U'' < {{FuncArg|min_chroma}}
|
+
|
+
|-
+
| U < min_chroma
+
 
| yellow
 
| yellow
 
| yellow
 
| yellow
 
|-  
 
|-  
| U > max_chroma
+
| ''U'' > {{FuncArg|max_chroma}}
 
| yellow
 
| yellow
 
| blue
 
| blue
 
|-  
 
|-  
| V < min_chroma
+
| ''V'' < {{FuncArg|min_chroma}}
 
| yellow
 
| yellow
 
| cyan
 
| cyan
 
|-  
 
|-  
| V > max_chroma
+
| ''V'' > {{FuncArg|max_chroma}}
 
| yellow
 
| yellow
 
| red
 
| red
 
|-  
 
|-  
| U < min_chroma and V < min_chroma
+
| ''U'' < {{FuncArg|min_chroma}}&nbsp;and ''V''&nbsp;<&nbsp;{{FuncArg|min_chroma}}
 
| yellow
 
| yellow
 
| green
 
| green
 
|-  
 
|-  
| U > max_chroma and V < min_chroma
+
| ''U'' > {{FuncArg|max_chroma}}&nbsp;and ''V''&nbsp;<&nbsp;{{FuncArg|min_chroma}}
 
| yellow
 
| yellow
 
| teal
 
| teal
 
|-  
 
|-  
| U < min_chroma and V > max_chroma
+
| ''U'' < {{FuncArg|min_chroma}}&nbsp;and ''V''&nbsp;>&nbsp;{{FuncArg|max_chroma}}
 
| yellow
 
| yellow
 
| orange
 
| orange
 
|-  
 
|-  
| U > max_chroma and V > max_chroma
+
| ''U'' > {{FuncArg|max_chroma}}&nbsp;and ''V''&nbsp;>&nbsp;{{FuncArg|max_chroma}}
 
| yellow
 
| yellow
 
| magenta
 
| magenta
 
|}
 
|}
  
'''Changes'''
+
 
 +
== Changes ==
 
{| border="1"
 
{| border="1"
 
|-  
 
|-  
 
| v2.60
 
| v2.60
| Added show for YV24.
+
| Added support for YV24.
 
|-  
 
|-  
 
| v2.56
 
| v2.56
| Added show to show out of bound luma/chroma.
+
| Added ''show'' to show out of bound luma/chroma.
 
|}
 
|}
  

Revision as of 03:19, 23 January 2016

The standard known as Rec.601 or CCIR-601 (Studio Encoding Parameters of Digital Television...) defines standard quantization levels: for luminance, black is 16 and peak white is 235. For chrominance, the range is 16 to 240, with the center (grey) at 128. "The signal may occasionally excurse beyond" this range according to Rec.601.

Luminance or chrominance values outside this range are known to cause problems with some TV sets, so Limiter was created to clip them (or clamp them - both terms are used) to the ranges [min_luma, max_luma] and [min_chroma, max_chroma], which you may specify, but by default are the Rec.601 values listed above.


Syntax and Parameters

Limiter(clip clip [, int min_luma, int max_luma, int min_chroma, int max_chroma, string show ] )

clip  clip = (required)
Source clip. YUV only.
int  min_luma = 16
Y (luma) lower clamping limit.
int  max_luma = 235
Y (luma) upper clamping limit.
int  min_chroma = 16
U & V (chroma) lower clamping limit.
int  max_chroma = 240
U & V (chroma) upper clamping limit.
string  show = (empty)
Colorizes the pixels outside the specified [min_X, max_X] range.
If set, show must take one of the following values:
show Effect
"luma" colorizes out of bound luma
"luma_grey" colorizes out of bound luma, and makes the remaining pixels grey
"chroma" colorizes out of bound chroma
"chroma_grey" colorizes out of bound chroma, and makes the remaining pixels grey
The colorizing is done as follows:
  • YUY2: j,k=1,2 (chroma shared between two horizontal pixels p1 and p2: Y1UY2V)
  • YV24: j,k=1 (no chroma shared)
  • YV12: j,k=11,12,21,22 (chroma shared between 2x2 pixels Y11UY12V: Y21UY22V)
Pixel Condition Colorization

show="luma" show="chroma"

Colorization

show="luma_grey" show="chroma_grey"

Yj < min_luma red (pj) red (pj)
Yj > max_luma green (pj) green (pj)
Yj < min_luma and Yk > max_luma yellow (pj and pk) puke (pj), olive (pk)
U < min_chroma yellow yellow
U > max_chroma yellow blue
V < min_chroma yellow cyan
V > max_chroma yellow red
U < min_chroma and V < min_chroma yellow green
U > max_chroma and V < min_chroma yellow teal
U < min_chroma and V > max_chroma yellow orange
U > max_chroma and V > max_chroma yellow magenta


Changes

v2.60 Added support for YV24.
v2.56 Added show to show out of bound luma/chroma.
Personal tools