View Single Post
Old 2nd January 2011, 00:25   #141  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
A Happy New Year, to all our Avisynth friends and family.

Quote:
Originally Posted by Wilbert View Post
I'm updating the documentation again Regarding SkewRows. I noticed that for RGB it skews from the bottom and for YUY2/Y8 from the top. It's perhaps nice to add this as an option where it starts to skew.
Yes as noted above the skewing is memory layout based, so RGB images are skew from the bottom up, YUV images are skew from the top down. I threw it together to read those skewed error messages that some media player users were submitting a short while ago, so no great amount of thought went into the design.

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.

The geometry of the output is calculated thus :-
. OutWidth = InWidth + Skew // signed skew values acceptable
. OutHeight = (InHeight*InWidth + OutWidth-1) / OutWidth // Ceiling

Quote:
Also, when do you know when to use "Add "Global OPT_AVIPadScanlines=True" option for DWORD aligned planar padding."? Is it sometimes set to false by some input filters?
OPT_AVIPadScanlines controls the memory alignment used in the AVIFile output emulation, class CAVIFileSynth::, Avisynth input filters should have nothing to do with this output option. Programs that use direct Avisynth API input, e.g x264, will be unaffected by this option, but may choose to support it if appropriate.

Microsoft specify 4 byte, DWORD, alignment for the simple DIB compatible formats, RGB24, RGB32, YUY2 and Y8. They make no specification for other formats, i.e. it is format specific.

Avery Lee in VirtualDub assumes all planar YUV formats are packed, i.e. pitch = rowsize, and all DIB compatible formats are DWORD aligned, i.e. pitch = (rowsize+3)/4 * 4.

By default Avisynth conforms to VirtualDub's alignment and packing expectations. For other software using AVIFile input that may assume DWORD alignment of a planar format the user can set OPT_AVIPadScanlines=True. With VirtualDub's direct stream copy mode the Avisynth AVIFile emulation packing is copied through, so DWORD aligned planar AVI files can be created by this method.

Both DirectShowSource (257) and AviSource (260b3) test for and support both packed and DWORD aligned planar memory layouts.

For image widths such that the chroma rowsize is mod4 there is never an issue, i.e YV24 is mod4, YV16 and YV12 are mod8, YV411 is mod16. But for other widths the assumptions made by the software in use becomes relevant.

If the result of processing a planar output Avisynth script, via the AVIFile interface, shows row skewing then OPT_AVIPadScanlines=True may help.
IanB is offline   Reply With Quote