View Full Version : Question about crop(...,align=true)
squid_80
29th July 2006, 06:08
Am I missing something or has poor old crop been left behind when we changed the default alignment from 16/8 to 32/16?
From Crop::Crop():
if (align) {
align = 8;
if (env->GetCPUFlags() & CPUF_SSE2)
align = 16;
if (!(left_bytes & (align-1))) // We already have alignment.
align=0;
}
I couldn't work out why my SSE2 filter wouldn't work, even though I was using align=true when I cropped.
Edit: While I think of it, this error message isn't exactly right either.
if ( (_left<0) || (_top<0) )
env->ThrowError("Crop: Top and Left must be more than 0");
IanB
30th July 2006, 12:02
Yes it probably should be matching against the chroma plane alignment if PlanarChromaAlignmentState is set. But it really should be checking the actual alignment in the GetFrame call. As a concept I was never very impressed with the align arg in crop(). Reading a frame unaligned and writing it back aligned just so the next filter can read it aligned seems really clumsy.
And
I am guessing you think it should say ...Top and Left must be more than or equal to 0And yes the grammar sucks.
ARDA
30th July 2006, 12:33
Alignment in crop could become usefull if we have a long filter chain with SSE2 codes; we should measure the waste of time of copy planes and the gain we get afterwards. Anyway if chroma is not guaranteed at least 16 b aligment nothing done.
Arda
squid_80
30th July 2006, 12:44
I don't even use it, ordinarily; if I have to crop before filtering I use amounts that won't upset the alignment and do a smaller crop at the end (normally in conjunction with a resize back to mod 16 resolution for encoding). What other filters apart from crop can adjust the alignment of the planes?
ARDA
30th July 2006, 12:57
Anyone that doesn't work in place and when create a new plane makes like this
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame dst = env->NewVideoFrame(vi,32);//instead of default
env->MakeWritable(&dst);
Sorry I don't have sources here to look for.
But just to mention, you can crop with multiple of 16 but you can't be sure if all planes in your source have original 16 b alignment.
Arda
squid_80
30th July 2006, 13:05
But just to mention, you can crop with multiple of 16 but you can't be sure if all planes in your source have original 16 b alignment.
I think that's why IanB said it should be checked in GetFrame rather than the filter's constructor. A multiple of 16 isn't good enough anyway, that's only 8 bytes for YV12's chroma planes (which is the original problem I was having - crop thinks it is enough and doesn't do anything).
ARDA
30th July 2006, 13:21
As I said before "Anyway if chroma is not guaranteed at least 16 b aligment nothing done."
By now every filter (if SSE2 code) should take care to verify aligment and process unaligned data till arrives to aligned one; and probably will have reminder bytes as well. It is not a good condition but....
Arda
foxyshadis
30th July 2006, 14:17
Is GetWritePtr(PLANAR_Y_ALIGNED) etc a proper way to force alignment in the obtained video? I've heard of this, but not seen it used in actual filters.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.