Log in

View Full Version : How to check a clip parity tag


jollye
11th April 2008, 13:21
Hi,

I want to know how to test if the BFF or TFF flag of one clip is set. The same as vi.IsTFF() or vi.IsBFF() within a filter code but in this case within an .avs script. Does someone know how to do this?

Thanks for your help

Guest
11th April 2008, 13:31
GetParity(clip)

...with caveats:

http://forum.doom9.org/showthread.php?t=55665

jollye
11th April 2008, 14:43
Thanks for your fast reply. I've made some tests but couldn't really find a solution.

Actually my problem is the following: When I open an .avc file (HD MPEG4 coming from some French TNT channel), the parity information returned by DirectShowSource is incorrect. Actually within a custom filter vi.IsTFF() and vi.IsBFF() both return false. If I use ComplementParity in my script they remain the same (both false).

What I want to do is detect this into my .avs script so that in that case I force the parity, to let's say TFF. However I don't want to force the parity for clips that exhibit a correct one. I couldn't find how to do this. I tried this script of my own but it doesn't seem to do what I want:


clip=DirectShowSource("myclip.avc")

#This is needed for my filter
clip=ConvertToYV12(clip,interlaced=true)

#Check if parity bits are correct
ord1 = getparity(clip) ? 1 : 0
clip = ComplementParity(clip)
ord2 = getparity(clip) ? 1 : 0

# Set the parity back to original value in case it was correct
clip = ComplementParity(clip)

condition = (ord1==ord2)

#now set the parity if needed
clip = (condition) ? AssumeTFF(clip) : clip
clip = (condition) ? ShowFrameNumber(clip) : clip

outclip=SomeFilter(clip)
return outclip

I'm not sure the parity returned by getparity has something to do with vi.IsTFF() and vi.IsBFF(). Is there a way to retrieve the values of IsTFF and IsBFF within one script because in my case that would do the job?

Thanks again for your help.

EDIT: The ShowFrameNumber is here for debug purposes only

IanB
11th April 2008, 15:47
DirectShowSource does not set the parity based on any source conditions.

Mpeg2source/DGDecode do.

jollye
14th April 2008, 10:27
Hi,

I solved my problem the following way:

First, I added those two functions to a custom filter:


// Inspired from AviSynth sources
static inline const VideoInfo& VI(const AVSValue& arg) { return arg.AsClip()->GetVideoInfo(); }
AVSValue GetIsBFF(AVSValue args, void*, IScriptEnvironment* env) { return VI(args[0]).IsBFF(); }
AVSValue GetIsTFF(AVSValue args, void*, IScriptEnvironment* env) { return VI(args[0]).IsTFF(); }


extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("IsBFF", "c", GetIsBFF, NULL);
env->AddFunction("IsTFF", "c", GetIsTFF, NULL);

Then in my script, I detect if the IsTFF and IsBFF functions return the same values, in which case I force the TFF flag of my clip.


clip=ConvertToYV12(clip,interlaced=true)

#Check if parity bits are file
ord1 = IsBFF(clip) ? 1 : 0
ord2 = IsTFF(clip) ? 1 : 0

condition = (ord1==ord2)

#now set the parity
clip = (condition) ? AssumeTFF(clip) : clip

result=MyFilter(clip)
return result


:thanks: