foxyshadis
27th May 2010, 01:27
FYI to IanB and SEt: There's a small bug in avisynth.h, that you'll only run into if you use PLANAR_U_ALIGNED or PLANAR_V_ALIGNED:
- int GetHeight(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: if (pitchUV) return height>>1; return 0;} return height; }
+ int GetHeight(int plane) const { switch (plane)
+ {case PLANAR_U: case PLANAR_V: case PLANAR_U_ALIGNED: case PLANAR_V_ALIGNED: if (pitchUV) return height>>1; return 0;} return height; }
Same deal with GetPitch. I couldn't figure out why it kept crashing until I found that. The same bug is present in 2.6 interface.cpp:
int VideoFrame::GetHeight(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: if (pitchUV) return heightUV; return 0;} return height; }
The alternative, if you'd prefer, would be to make PLANAR_X_ALIGNED private and instead make dst->GetWritePtr(plane|PLANAR_ALIGNED); the standard and require PLANAR_X everywhere else - I'll probably do that in mine instead. I don't even think the above code is correct at all - it should be based on CS_Sub_Height_X (and GetRowSize with CS_Sub_Width_X). Wait, never mind, I see how NewVideoFrame calls GetPlaneWidthSubsampling/GetPlaneHeightSubsampling who use those. Still, the half-baked PLANAR_X_ALIGNED support needs to be fleshed out or dropped. (I'd vote for dropped.)
Edit: Even GetWritePointer doesn't work with PLANAR_ALIGNED, thanks to "if (plane==PLANAR_Y)" and "if (!plane || plane == PLANAR_Y)" in 2.6. Only GetReadPointer does.
- int GetHeight(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: if (pitchUV) return height>>1; return 0;} return height; }
+ int GetHeight(int plane) const { switch (plane)
+ {case PLANAR_U: case PLANAR_V: case PLANAR_U_ALIGNED: case PLANAR_V_ALIGNED: if (pitchUV) return height>>1; return 0;} return height; }
Same deal with GetPitch. I couldn't figure out why it kept crashing until I found that. The same bug is present in 2.6 interface.cpp:
int VideoFrame::GetHeight(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: if (pitchUV) return heightUV; return 0;} return height; }
The alternative, if you'd prefer, would be to make PLANAR_X_ALIGNED private and instead make dst->GetWritePtr(plane|PLANAR_ALIGNED); the standard and require PLANAR_X everywhere else - I'll probably do that in mine instead. I don't even think the above code is correct at all - it should be based on CS_Sub_Height_X (and GetRowSize with CS_Sub_Width_X). Wait, never mind, I see how NewVideoFrame calls GetPlaneWidthSubsampling/GetPlaneHeightSubsampling who use those. Still, the half-baked PLANAR_X_ALIGNED support needs to be fleshed out or dropped. (I'd vote for dropped.)
Edit: Even GetWritePointer doesn't work with PLANAR_ALIGNED, thanks to "if (plane==PLANAR_Y)" and "if (!plane || plane == PLANAR_Y)" in 2.6. Only GetReadPointer does.