Function Interlacing2Reader(clip clp, float "mthresh", int "start", int "end", int "emount", int "inf", string "file", bool "lowprec", int "FontSize") { ###### PREPARATION ###### begin = default(start, 0) out = default(inf, 1) output = default(file,"H:\interlacing.log") lowprec = default(lowprec, false) global stop = default(end, framecount(clp)) global mthresh = default(mthresh, 3.0) global FontSize = default(FontSize, 16) amount = default(emount,300) dec = amount<100 ? amount : int(stop/amount)+1 mod3 = dec%3 mod5 = dec%5 global deci = dec%2==1 ? ( mod3!=0 && mod5!=0 ? dec : (mod3!=1 && mod5!=3 ? dec+2 : dec-2) ) : \ ( mod3!=1 && mod5!=1 ? dec-1 : (mod3!=2 && mod5!=4 ? dec+1 : dec+3) ) global source = lowprec==false ? clp.trim(begin,stop) : clp.trim(begin,stop).pointresize(width(clp)/2,height(clp)) global cltff = source.AssumeTFF().bob() global clbff = source.AssumeBFF().bob() global matched = source.tfm(mode=0,pp=2, MI=74,clip2=cltff.selecteven()) ###### VAR.. ###### global interlaced = 0 global progressive = 0 global fieldshifted = 0 global tffcount = 0 global bffcount = 0 global real_interlaced = 0 global currentframe_s = "CurrFrame: " global interlaced_s = "interlaced: " global progressive_s = "progressive: " global fieldshifted_s = "fieldshifted: " global real_s = " (real: " global real_s2 = ")" global bffcount_s = "bff: " global tffcount_s = "tff : " ###### Conditional Function Chain, evaluated from bottom to top (!) ###### c99= out==0 ? scriptclip(source, "source") : ( out==1 ? \ scriptclip(source, "Subtitle(currentframe_s+string(current_frame),size= FontSize )."+ \ "Subtitle(interlaced_s+string(interlaced)+real_s+string(real_interlaced)+real_s2,size=FontSize,y= FontSize )."+ \ "Subtitle(progressive_s+string(progressive),size=FontSize,y= FontSize*2 )."+ \ "Subtitle(fieldshifted_s+string(fieldshifted),size=FontSize,y= FontSize*3 )."+ \ "Subtitle(tffcount_s+string(tffcount),size=FontSize,y= FontSize*4 )."+ \ "Subtitle(bffcount_s+string(bffcount),size=FontSize,y= FontSize*5 )") : \ WriteFileIf(source, output, "current_frame>stop-deci", """ "interlaced:" """, "interlaced", """ ", progressive:" """, "progressive", \ """ ", fieldshifted:" """, "fieldshifted", """ ", real_interlaced:" """ , "real_interlaced", """ ", BFF:" """, \ "bffcount", """ ", TFF:" """, "tffcount", append=false, flush=true) ) c4=FrameEvaluate(c99, " global interlaced = count==2 || count==3 ? interlaced+1 : interlaced global progressive = count==0 ? progressive+1 : progressive global fieldshifted = count==1 ? fieldshifted+1 : fieldshifted global tffcount = count!=20 && (tffc+tffb)*1.25tffb || \ count==3 && bffc*0.7bffb ? real_interlaced+1 : real_interlaced") c3=FrameEvaluate(c4, " global count = (tffc>tffb && tffc>bffc && tffc>bffb ? tffc : (tffb>bffc && tffb>bffb ? tffb : \ (bffc>bffb ? bffc : bffb))) > mthresh ? (abs(LumaDifference(matched,cltff.selectodd())-tffc)<0.0001 ? \ (tffc+tffb