| Allora, visto che ad alcuni potrebbe interessare, mi sono messo di buona lena e ho scritto 'sta roba. Metto il codice sotto spoiler perché è roba lunghetta. CODICE #HardSub Utilities for Y416 v1.2 by mirkosp #Y416 is 16bit YUV 4:4:4, by the way. But if you care about this, you likely knew already. #And of course I mean dithertools' stacked thing, which technically is #a stacked 8bit thingie. Dem hacks. #Requires dithertools. Also vsfilter and/or vsfiltermod for the ass support. #I haven't done extensive testing, so please report any errors you find.
#First and foremost, rgb32 afx clips #l is the video to overlay on (typically left to last) #c is the clip to be overlayed #s is the frame on which to start the overlay #e is the frame on which to end the overlay #I'm nice enough to allow the usage of -num_frames style too, tho. #sm is the colormatrix and tv is a bool for tv range (true) or not (false). #You should be using dither_convert_rgb_to_yuv's values for sm, but #uf you're using avisynth's, I'm doing a somewhat rough check myself. #This also allows me to just call this function later on for ass hardsubbing...
function rgb32ony416(clip l, clip c, int "s", int "e", string "sm", bool "tv") { assert(c.isrgb32, "dudeplz.") assert(l.isyv24, "dudeplz.") assert(l.width == c.width, "check width") assert(l.height/2 == c.height, "check height") tv = defined(tv) ? tv : defined(sm) ? sm == "PC.601" ? false : sm == "PC.709" ? false : tv : true sm = defined(sm) ? sm == "Rec601" ? "601" : sm == "Rec709" ? "709" : sm == "PC.601" ? "601" : sm == "PC.709" ? "709" : sm : (c.width > 1024 || c.height > 600) ? "709" : "601" s = default(s,0) e = default(e,0) s=s+2 l e = (e > 0) ? e+2 : (e == 0) ? framecount+1 : e ps = s-1 pe = (e > 0) ? e+1 : s-e l = l.trim(0,1)+l+l.trim(0,1) #HAX! I don't feel like doing special case checks. Maybe it executes faster this way, too. l sa = l.trim(0,ps).converttorgb32()+stackvertical(c.showalpha("rgb32"),c.showalpha("rgb32"))+last.trim(pe,0).converttorgb32() oc = l.trim(0,ps)+(c.Dither_convert_rgb_to_yuv(output="yv24",matrix=sm,tv_range=tv).dither_convert_8_to_16())+last.trim(pe,0) l.trim(0,ps)+ytouv(overlay(last.utoy(),oc.utoy(),mask=sa),overlay(last.vtoy(),oc.vtoy(),mask=sa),overlay(last,oc,mask=sa)).trim(s,e)+l.trim(pe,0) return trim(2,framecount-3) }
#And now for the ass functions #sm is the colormatrix. If left unspecified, it's autoguessed based on res. #path is the ass' path, hack is for the bt601 typeset deal. #If the video you have to overlay on is bt709 and you #have typeset in bt601 to compensate for the old vsfilter, #set this to true. #vfr is the path to the timecodes. #At the time of the writing, softsubbed 4:4:4 has to be overlayed #in rgb tho, so it's better to avoid the hack if you're #dealing with 4:4:4 video, thus I won't account for it by default. #I'm not 100% sure these work correctly, please report bugs if you encounter them.
function textsubmodony416(clip cs, string path, string "vfr", string "sm", bool "hack") { hack = default(hack,false) c = cs.ditherpost(mode=8) sm = defined(sm) ? sm : (c.width > 1024 || c.height > 600) ? "Rec709" : "Rec601" bc = blankclip(c,pixel_type="RGB32",color=$FF000000)#pure alpha crgb = hack ? c.converttorgb32(matrix="Rec601") : c.converttorgb32(matrix=sm) mergeargb(bc.showalpha(),crgb.showred(),crgb.showgreen(),crgb.showblue()) defined(vfr) ? textsubmod(path,vfr=vfr) : textsubmod(path) mergeargb(showalpha().invert(),showred(),showgreen(),showblue()) savealpha = last o = converttoyv24(matrix="Rec601").converttorgb32(matrix="Rec709") return hack ? rgb32ony416(cs,mergeargb(savealpha.showalpha(),o.showred(),o.showgreen(),o.showblue()),sm=sm) : rgb32ony416(cs,last,sm=sm) }
function textsubony416(clip cs, string path, string "vfr", string "sm", bool "hack") { hack = default(hack,false) c = cs.ditherpost(mode=8) sm = defined(sm) ? sm : (c.width > 1024 || c.height > 600) ? "Rec709" : "Rec601" bc = blankclip(c,pixel_type="RGB32",color=$FF000000)#pure alpha crgb = hack ? c.converttorgb32(matrix="Rec601") : c.converttorgb32(matrix=sm) mergeargb(bc.showalpha(),crgb.showred(),crgb.showgreen(),crgb.showblue()) defined(vfr) ? textsub(path,vfr=vfr) : textsub(path) mergeargb(showalpha().invert(),showred(),showgreen(),showblue()) savealpha = last o = converttoyv24(matrix="Rec601").converttorgb32(matrix="Rec709") return hack ? rgb32ony416(cs,mergeargb(savealpha.showalpha(),o.showred(),o.showgreen(),o.showblue()),sm=sm) : rgb32ony416(cs,last,sm=sm) } Dovrebbero essere più o meno intuitivi da usare. Segnalate gli errori, che ho testato poco per via dell':eff:. Da quel che ho visto sembrerebbe andare più o meno tutto. Mi rimetto anche al buon senso di chi utilizzerà i filtri... Edited by mirkosp - 30/8/2012, 22:40
|