SkewRows

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
 
(add link to avs+ documentation)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<div {{BlueBox2|40|0|3px solid purple}} >
 +
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/skewrows.html https://avisynthplus.readthedocs.io]
 +
</div>
 +
 +
 
{{Template:FuncDef|SkewRows(clip ''clip'', int ''skew'')}}
 
{{Template:FuncDef|SkewRows(clip ''clip'', int ''skew'')}}
  
SkewRows (added in v2.60) skews the rows of a clip by an amount of ''skew''. The skewing is memory layout based, so RGB images are skewed from the bottom up, YUV images are skewed from the top down.
+
''Skews'' the rows of a clip. It can be used to correct (''deskew'') problem clips such as the [[MessageClip|error message]] shown below.  
  
It can be used to read those skewed error messages that some media player users are submitting.
+
The amount, {{FuncArg|skew}}, can be positive or negative. For [[YUY2]] sources, {{FuncArg|skew}} should be even (divisible by 2).  
  
The effect of the algorithm is to paste all of the input rows together as one single very long row, then slice them up based on the new width (= input width + skew). Skew can also be negative in which case the last skew pixels of each line are added to the beginning of the next line and you get some extra lines at the end. The last line is padded with grey pixels when required.
+
All [[Interleaved|interleaved]] pixel formats are supported, including [[Y8]]. [[RGB]] images are skewed from the bottom up, while [[YUV]] images are skewed from the top down.
  
The geometry of the output is calculated as follows:
+
All of the input rows are joined together as one very long row, then sliced up based on the new width (= input width + {{FuncArg|skew}}).
* OutWidth = InWidth + skew // signed skew values acceptable
+
* OutHeight = (InHeight*InWidth + OutWidth-1) / OutWidth // rounded up to nearest integer
+
  
All interleaved pixel formats are supported (including Y8), though ''skew'' should be even for YUY2.
+
The '''width and height of the output clip are therefore altered slightly''', as follows:
 +
* <tt>OutWidth = InWidth + {{FuncArg|skew}}&nbsp;&nbsp;</tt> (signed skew values acceptable)
 +
* <tt>OutHeight=(InHeight*InWidth+OutWidth-1)/OutWidth&nbsp;</tt> (rounded up to nearest integer)
 +
The last line is padded with grey pixels when required.
  
'''examples:'''
+
==== Examples ====
  
{|border=1 cellspacing=1 cellpadding=4
+
{|border="0"
 
| [[Image:Skewrows_before.png]]
 
| [[Image:Skewrows_before.png]]
 +
|-
 +
|align="center"| (original with skew problem)
 +
|-
 +
|&nbsp;
 +
|-
 
| [[Image:Skewrows_after.png]]
 
| [[Image:Skewrows_after.png]]
 
|-
 
|-
| Original
+
|align="center"| <tt>SkewRows(1)</tt>
| SkewRows(1)
+
 
|}
 
|}
  
'''changelog:'''
+
==== See also ====
 +
[[AviSource]] and [[DirectShowSource]] {{FuncArg|pixel_type}}
 +
<div {{NotaBeneWidthIndent|56|2|2px solid gray}} >
 +
''For planar color formats, adding a '+' prefix, e.g. DirectShowSource(..., pixel_type="+YV12"), tells AviSynth the video rows are DWORD aligned in memory instead of packed. '''This can fix skew or tearing of the decoded video''' with bad codecs when the width of the picture is not divisible by 4. ''
 +
</div>
 +
 
 +
==== Changelog ====
  
 
{| border="1"
 
{| border="1"
Line 32: Line 49:
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Transformation]]

Latest revision as of 07:12, 18 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io


SkewRows(clip clip, int skew)

Skews the rows of a clip. It can be used to correct (deskew) problem clips such as the error message shown below.

The amount, skew, can be positive or negative. For YUY2 sources, skew should be even (divisible by 2).

All interleaved pixel formats are supported, including Y8. RGB images are skewed from the bottom up, while YUV images are skewed from the top down.

All of the input rows are joined together as one very long row, then sliced up based on the new width (= input width + skew).

The width and height of the output clip are therefore altered slightly, as follows:

  • OutWidth = InWidth + skew   (signed skew values acceptable)
  • OutHeight=(InHeight*InWidth+OutWidth-1)/OutWidth  (rounded up to nearest integer)

The last line is padded with grey pixels when required.

[edit] Examples

Skewrows before.png
(original with skew problem)
 
Skewrows after.png
SkewRows(1)

[edit] See also

AviSource and DirectShowSource pixel_type

For planar color formats, adding a '+' prefix, e.g. DirectShowSource(..., pixel_type="+YV12"), tells AviSynth the video rows are DWORD aligned in memory instead of packed. This can fix skew or tearing of the decoded video with bad codecs when the width of the picture is not divisible by 4.

[edit] Changelog

v2.60 Initial release
Personal tools