Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
11th March 2010, 23:12 | #1 | Link |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Subframe and SeparateFields
Some questions about Subframe and SeparateFields:
Code:
PVideoFrame SeparateFields::GetFrame(int n, IScriptEnvironment* env) { PVideoFrame frame = child->GetFrame(n>>1, env); if (vi.IsPlanar()) { const bool topfield = (child->GetParity(n)+n)&1; const int UVoffset = !topfield ? frame->GetPitch(PLANAR_U) : 0; const int Yoffset = !topfield ? frame->GetPitch(PLANAR_Y) : 0; return env->SubframePlanar(frame,Yoffset, frame->GetPitch()*2, frame->GetRowSize(), frame->GetHeight()>>1, UVoffset, UVoffset, frame->GetPitch(PLANAR_U)*2); } return env->Subframe(frame,(GetParity(n) ^ vi.IsYUY2()) * frame->GetPitch(), frame->GetPitch()*2, frame->GetRowSize(), frame->GetHeight()>>1); } Code:
if (vi.IsPlanar()) { const bool topfield = child->GetParity(n); ... Code:
return env->Subframe(frame, GetParity(n) * frame->GetPitch(), frame->GetPitch()*2, frame->GetRowSize(), frame->GetHeight()>>1); |
12th March 2010, 12:47 | #2 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
However, I would expect it to be this->GetParity(n) (or just GetParity(n)) instead. Otherwise, source clips that have gone through a filter that re-orders parity on a per-frame basis (eg SelectEvery) will not give the right results. Quote:
|
||
12th March 2010, 21:39 | #3 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Code:
const bool topfield = (child->GetParity(n)+n)&1; Given the GetParity code is this Code:
inline bool __stdcall GetParity(int n) { return child->GetParity(n>>1) ^ (n&1); } |
13th March 2010, 00:48 | #4 | Link |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
It's all tricky stuff, but i agree with both of you. Strange that we didn't notice this before, because you get incorrect results.
Example: source = 2 frames (frame 0 = BFF, frame 1 = TFF): Code:
2 frames => 4 fields (planar colorformat) GetParity(n): output: n=0 => GetParity(n>>1) ^ (n&1) = GetParity(0) ^ 0 = 0 ^ 0 = 0 (correct; since GetParity(0)=0=BFF) output: n=1 => GetParity(n>>1) ^ (n&1) = GetParity(0) ^ 1 = 0 ^ 1 = 1 (correct) output: n=2 => GetParity(n>>1) ^ (n&1) = GetParity(1) ^ 0 = 1 ^ 0 = 1 (correct; since GetParity(1)=1=TFF) output: n=3 => GetParity(n>>1) ^ (n&1) = GetParity(1) ^ 1 = 1 ^ 1 = 0 (correct) topfield = (child->GetParity(n)+n)&1; output: n=0 => (0+0)&1 = 0 (correct) output: n=1 => (1+1)&1 = 0 (wrong) output: n=2 => (1+2)&1 = 1 (correct) output: n=3 => (0+3)&1 = 1 (wrong) Btw, I still don't understand what happens when SubframePlanar is called. I'm looking at avisynth.cpp, but it is still a mistery. Could you explain it? |
13th March 2010, 11:41 | #5 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
The problem only shows up if an earlier filter has introduced a non-standard parity function, where the parity depends on the frame number. Last edited by Gavino; 13th March 2010 at 11:43. |
|
13th March 2010, 14:32 | #6 | Link | |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|