View Single Post
Old 11th July 2019, 16:19   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
V0.12Beta3, In sig below this post, HOSTED folder. [v2.58, avs/+ x86 & x64]

Code:
// 11/07/2019 Ver  0.12Beta_3 + Changes to debug metrics.
Code:
AviSource("D:\Parade.AVI")
#AviSource(".\ALTEST.AVI").Trim(74,11154).crop(0,46,0,-46)
#AviSource(".\ALTEST2.avi")
#convertToRGB32
#ConvertToY8
ORG=Last
######################
TITLES  = True
DEBUG_A = true
DEBUG_B = true
DEBUG_C = true
# DEFAULT
SCENECHGTHRESH=20       # SC if diff of min or max Y to prev frame is more than this : NEW additional SC if DiffMeanY(n,n-1) is more than 1/2 this. [If either, recheck for override to non SC via SC2 stuff]
#
MIDPOINT = 0.42         # Default stays 0.5
IGNORE_A = 1.0/256      # 1.0/256 # OLD Default
IGNORE_B = 1.0/512      # 1.0/512 # NEW Default
IGNORE_C = 1.0/512      # 1.0/512 # NEW Default
# If Scene change detected via SceneChgThresh, then re-check and override to NOT SC if not at least SC2PERC(33.33%) of luma pixels differ by more than SC2TH(8) when compared with prev frame.
SC2TH=12                # 12 Default
SC2PERC=33.33           # 33.33 Default
# NEW NEW
GAMMAX_A = 10.0         # OLD Default for AutoLevels(AutoGamma=true)
GAMMIN_A = 1.0/GAMMAX_A # OLD Default for AutoLevels(AutoGamma=true)
GAMMAX_B = 1.5          # Default 1.5,       : 1.0      <= GamMax <=  10.0 : Limit upwards   Gamma corrections
GAMMIN_B = 1.0/GAMMAX_B # Default 1.0/GAMMAX : 1.0/10.0 <= GamMim <=  1.0  : Limit Downwards Gamma corrections
GAMMAX_C = 1.25         #
GAMMIN_C = 1.0/GAMMAX_C #
######################
MINRNG_B=100            # Default 100  : Input Y range less than this will hae corrections reduced.
MINRNG_C=100            # Default 100
######################
# A, Nearly same as 0.7. sc2Th=256 switch off new sc overrides [still does 1/2 mean SC chk], also switch off MinRng : GammMax Unrestricted (well 10.0)
A=AutoLevels(autogamma=true,midpoint=MIDPOINT,sceneChgThresh=sceneChgThresh,ignore=IGNORE_A,debug=DEBUG_A,FilterRadius=5,gammax=GAMMAX_A,gammin=GAMMIN_A,sc2Th=256,MinRng=0)
B=AutoLevels(autogamma=true,midpoint=MIDPOINT,sceneChgThresh=sceneChgThresh,ignore=IGNORE_B,debug=DEBUG_B,FilterRadius=7,gammax=GAMMAX_B,gammin=GAMMIN_B,sc2Th=SC2TH,sc2Perc=SC2PERC,MinRng=MINRNG_B)
C=AutoLevels(autogamma=true,midpoint=MIDPOINT,sceneChgThresh=sceneChgThresh,ignore=IGNORE_C,debug=DEBUG_C,FilterRadius=7,gammax=GAMMAX_C,gammin=GAMMIN_C,sc2Th=SC2TH,sc2Perc=SC2PERC,MinRng=MINRNG_C)
######################
ORG=TITLES?ORG.TSub("ORG",True):ORG
A  =TITLES?A.TSub("A: "+String(GAMMAX_A," Gammax=%.3f")+String(IGNORE_A," Ignore=%.3f")+" SC2=OFF MinRNG=OFF"):A
B  =TITLES?B.TSub("B: "+String(GAMMAX_B," Gammax=%.3f")+String(IGNORE_B," Ignore=%.3f")+String(MINRNG_B," MinRng=%.3f")):B
C  =TITLES?C.TSub("C: "+String(GAMMAX_C," Gammax=%.3f")+String(IGNORE_C," Ignore=%.3f")+String(MINRNG_C," MinRng=%.3f")):C
RGT=StackVertical(A,C)
LFT=StackVertical(ORG,B)
Return StackHorizontal(LFT,RGT)

# Stack Overhead Subtitle Text, with optional FrameNumber shown.
Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){
    c.BlankClip(height=20,Color=Default(Col,0))
    (Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit)
    Return StackVertical(c).AudioDubEx(c)
}
Code:
    GamMax,   1.0->10.0. Default 1.5 where AutoLevels(AutoGamma=true) and Default 10.0 Where AutoGamma(). Limits amount of gamma correction, maybe only want to darken clip sor something.
    GamMin,   0.1->1.0.  Default 1.0/GammMax. Darken Limit for gamma.
    Sc2th,    Default 12. 0->256. 256=OFF. Secondary scene change detection, a check and possible override to primary detector which is quick but not so good.
    Sc2Perc,  Default 33.33. Range 0.0 <= Sc2Perc < 100.0. Secong arg to secondary scene change detector.
              If Scene change detected via SceneChgThresh, then re-check and override to NOT SC if not at least Sc2PErc(33.33%) of luma pixels differ by more than Sc2Th(12) when compared with prev frame.
    MinRng,   Default 100. 64->128 and also 0=OFF. If luma range less than this, then amount of autolevel/autogamma is reduced, more so where range approaches 0. [avoid horrible fade to black autolevels]

    Debug
        226:224,233] LHG+sSF : sc2=38.8%
        ymin=  3   ymin_avg =  3.5 {  3.5}
        ymax=217   ymax_avg =224.2 {224.2}
        mean= 79.7 ymean_avg= 82.2
        gamm=1.250 out_mean =105.80(0.41)

        Top line.
            226:224,233] ... Current frame: Frames sample range, limited by arg FilterRadius and detected Scene Changes.

            Flags, 'LHG+sSF', where hi-lited:
                L ... Low input to levels adjustment is changed from that of ymin.
                H ... High input to levels adjustment is changed from that of ymax.
                G ... Gamma to levels adjustment is not 1.0.
                + ... (Actually a single character with '+' appearing above '-'), Gamma levels adjustment is limited by GamMin, GamMax or low range fading.
                s ... Scene change detection via primary scene change detector arg sceneChgThresh.
                S ... Scene change detection via secondary scene change detector args sc2Th and sc2Perc. [Only hilited if primary detector also fired]
                F ... Low Luma Range detected via arg MinRng, levels inputs of ymin, ymax and gamma are adjusted to have lesser effect [F=Fade].

            sc2=38.8%
                Secondary detector percentage of luma pixel difference greater than arg Sc2th (WRT corresponding pixels of prev frame).

        ymin=3,          Luma Minimum of current frame ignoring at most arg ignore_low extreme (noise) pixels [as for YPlaneMin(threshold)].
        ymax=217,        Luma Maximum of current frame ignoring at most arg ignore_high extreme (noise) pixels [as for YPlaneMax(threshold)].
        mean=1.250       AverageLuma of current frame.
        ymin_avg=3.5,    Average of all luma ymin values of the current range of frames (range limited by FilterRadius and scene change detection).
                         { 3.5}, in this case same as ymin_avg, but will be hilited & different if levelling strength reduction due to arg MinRng.
        ymax_avg=224.2,  Average of all luma ymax values of the current range of frames.
                         {224.2}, in this case same as ymax_avg, but will be hilited & different if levelling strength reduction due to arg MinRng.
        ymean_avg=82.2,  Average of all AverageLuma values of the current range of frames.
        Gamm=12.250,     Gamma input to levels adjustment.
        out_mean=105.80, Resulting AverageLuma, on current frame after levelling.
                         (0.41), in this case 105.80/255.0, ie equivalent to the full PC levels range midpoint.
                                 At some future stage, will be implemented as eg (out_mean-out_min)/(out_max-out_min).
EDIT: Now looks like this.
EDIT: The below hi-lited flag +/- symbol indicates that Gamma has been restricted by the GamMax arg [in this case 1.25].
Also, the sc2=38.8% in status line, indicates that number of pixels with a difference greater than Sc2Th(12) is 38.8%, which is greater than arg Sc2Perc(33.33),
but as primary scene change detector is not fired, is not a scene change.(neither s nor S flag is hi-lited) [The scene is panning]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 11th July 2019 at 16:52.
StainlessS is offline   Reply With Quote