Log in

View Full Version : AlignPlanar filter


Leak
11th August 2005, 13:10
While I'm in the process of revamping LeakKernelDeint to make use of SoftWire and finally add SSE2 support, I've come to the conclusion that instead of special-casing the heck around oddly aligned frames I'll use AlignPlanar instead.

But after taking a closer look at it, I'm wondering - does "planar alignment" only mean that the pitch is aligned to FRAME_ALIGN? Shouldn't it also mean that the frame data start address is aligned to FRAME_ALIGN?

If the latter is the case, not only the pitch has to be checked, but also the addresses of the planes themselves - if I do a Crop(2,0,-14,0,false) on an aligned frame (well, not neccessarily me, but maybe Joe Random User :D), AlignPlanar will assume that the frame is still aligned, but since the Y data will start 2 bytes beyond the original address doing things like reading 16 values at once into an XMM register using the faster MOVDQA instruction will cause an exception, which somehow defeats the purpose of making sure the frame is aligned... ;)

In case the filter works as planned, I'll have to align the frames myself, which isn't a big deal, but what's the use of AlignPlanar then? :confused:

And while I'm at it - when creating a new YV12 frame, are the chroma planes' start addresses and pitches guaranteed to also be aligned to a FRAME_ALIGN boundary?

np: Donnacha Costello - To Thee This Night (I Will No Requiem Raise) (Pop Ambient 2004)

kassandro
11th August 2005, 17:50
While I'm in the process of revamping LeakKernelDeint to make
And while I'm at it - when creating a new YV12 frame, are the chroma planes' start addresses and pitches guaranteed to also be aligned to a FRAME_ALIGN boundary?

No they are not. The chroma planes have only have the alignment of the luma planes. While maintainers of Avisynth urge filter writers not to use the formula

chroma pitch = (luma pitch)/2

they are using this formula all the time. It is virtually hardwired into Avisynth and is the reason why we have this alignment mess, which even costs time for non-SSE2 machines. I usually have one routine for aligned and one for unaligned access. Finally I check for each plane, the buffer address and the pitch, whether the aligned access routine can be used.