View Single Post
Old 28th October 2021, 20:59   #20  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by StainlessS View Post
May be for 8-bit only, but did you see this,

Quote:
Maybe use (where masktools 2 used already)
Black=source.mt_lut("0")
White=black.mt_Invert() # OK for HBD, eg 16 bit Y becomes $FFFF, not $FF00 (FULL WHITE required for Mt_merge mask).
And its only really done the once, not at every frame so speed hardly matters at all.
For different bit depths blackclip(souce).expr should be faster than source.mt_lut; both will "flexible" in terms of bitdepth and correct on inverting
expr("0", "x", "x") for copy u,v and expr("0", "range_half", "range_half") for half uv at source bitdepth


Code:
source=("random 1080p source")

black = source.mt_lut("0").killaudio()
#black = blankclip(source).expr("0",  "range_half",  "range_half"").killaudio()
#black = blankclip(source).expr("0",  "x",  "x").killaudio()
#black = blankclip(source).mt_lut("0").killaudio()

black
8bit source benchmarks , fps, cpu%, no prefetch

(I believe expr is optimized with avx2 instructions, but it didn't make much of a difference on these benchmarks with SetMaxCPU("sse4.1") for this operation )

ffmpeg -i mt_lut.avs -f null NUL
285fps, 60%

ffmpeg -i blankclip_expr_uv_range_half.avs -f null NUL
1060fps, 25%

ffmpeg -i blankclip_expr_uv_copy.avs -f null NUL
1010fps, 25%

ffmpeg -i blankclip_mt_lut.avs -f null NUL
490fps, 22%

Eitherway, you're right it should have limited impact speedwise on John's specific script (it's not going to be the part that is the "bottleneck")

Do you need to copy the chroma channels for the mask ? Really you only need "Y" plane 100% white or 100% black. It might be slightly faster to do it in Y or Gray for the mask part, instead of YUV (discard instead of dragging the chroma channels along)
poisondeathray is offline   Reply With Quote