Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th March 2019, 23:13   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
ShufflessS v1.05 - 25 Aug 2020

ShufflessS, plugin. (req VS 2008 runtimes).
v1.05, Plugin dll basename renamed to "ShufflessS" (Conflict with Stickboy dll name). [ ssS added ]

Plugin prompted by these two threads:-
https://forum.doom9.org/showthread.php?t=176118
https://forum.doom9.org/showthread.php?t=176150

Code:
ShufflessS, by StainlessS @ Doom9 : https://forum.doom9.org/showthread.php?t=176193

v1.05, dll base name renamed from Shuffle to ShufflessS, to avoid confusion with existing Stickboy dll.

Shuffle spacial columns or rows (1D), or blocks(2D) of frames, or temporal shuffle (frame order), all shuffles Inversable, ie undoable.
Potential usage in clip obfuscation using 'secret keys', or slideshow random ordering of frames.

Plugin for all Avs/+ valid colorspace. [v1.04+, MT compatible for AVS+]
Dll's for Avs v2.58, v2.60/+ x86 and x64.

    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                                            # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )                   # Vertical   1D Shuffle
    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle
    ShuffleT   (clip c, Int "Seed"=0, Bool "Inverse"=False )                                                                             # Shuffle Temporal, ie frame order.

    c,          Clip to Shuffle
    Seed,       -1=Random seed (Non inverse-able), 0 (default) same shuffle every time, Else any other int = UserSeed or 'SECRET_KEY'.
    BlkW,       Default 8, width of blocks or columns to shuffle.
                (Must be compatible with X Crop args, eg 2 or multiple thereof for YV12, also must divide exactly into Width of clip, use crop or Addborders where necessary).
    BlkH,       Shuffle1D_Y Default=8. Shuffle2D Default=BlkW, NOTE, Changed from original default 8.
                Height of blocks or rows to shuffle.
                (Must be compatible with Y Crop args, eg 2 or multiple thereof for YV12, also must divide exactly into Height of clip, use crop or Addborders where necessary).
    Interlaced, If True, then doubles minimum requirement of BlkH (Shuffle1D_Y and Shuffle2D ONLY).
                    eg YV12, where Interlaced=False blkH would require multiple of 2, and where Interlaced, Would would require multiple of 4, so as not to destroy interlacing.
    Once,       Default False. If true, then uses the same shuffle pattern for every frame, else shuffled differently for every frame.
                    Perhaps better compression if not using ShuffleT.
    Inverse,    Reverses previously done shuffling, Must Use Same Key as was used for the Shuffling stage (and maybe ideally all in reverse shuffle order).

Where ONLY 2 x 1D shuffles (ie both X and Y shuffling), then the order for de-shuffling does not matter, can use Inverse X and then Inverse Y or vice versa.
Shuffle2D is much better than 2x1D shuffles ie Shuffle1D_X + Shuffle1D_Y (or vice versa).
Shuffle2D together with either of the 1D shuffles is a bit pointless.
If using ShuffleT (frame order shuffle) suggest before or after ALL other shuffles, and in reverse order when Inverse = true.
If Inverse, then must uses same Seed, BlkW, BlkH, Interlaced and Once args to recover obfuscated source.
Seed, can be different for all Shuffle instances, if any of them use random seed (-1), you will not be able to inverse the result.
For ShuffleT(), source clip should be frame accurate and ideally not from eg DIVX/XDIV (they can often have a key frame only every 8 seconds or so, so would be VERY slow).

(Q) What use is seed=0      ? (A) Exact same sequence every time.
(Q) What use is Random seed ? (A) maybe for ShuffleT() of pics for slideshow.


Shuffled and compressed clip will likely be quite a bit larger than the source clips especially for small block sizes and temporal (frame order) shuffles.
Here some numbers regarding compression.

ORIG_PLUS_AddBorders         34MB     # Source clip, recompressed as x264 CRF 21.5, Slow. Addborders to enable Shuffling BlkW=32 and BlkH=32 args. Below compressed similar.
Shuffle_2x1D_4x4.mp4        169MB
Shuffle_2x1D_8x8.mp4        153MB
Shuffle_2x1D_16x16.mp4      145MB
Shuffle_2x1D_32x32.mp4      131MB

Shuffle_2D_4x4.mp4          173MB
Shuffle_2D_8x8.mp4          159MB
Shuffle_2D_16x16.mp4        151MB
Shuffle_2D_32x32.mp4        137MB

ONCE=True
Shuffle_2D_4x4.mp4          117MB
Shuffle_2D_8x8.mp4          104MB
Shuffle_2D_16x16.mp4         82MB
Shuffle_2D_32x32.mp4         53MB


The AVS Folder has a number of Demos (7 at time of writing) that will run with Colorbars or An Avi.

StainlessS
Code:
# Shuffle_2x1D.avs
/*

    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                           # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # Vertical   1D Shuffle

*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

SECRET_KEY_X = 123456789
SECRET_KEY_Y = 987654321
BlkW=64                  # Blks for Horizontal Shuffle
BlkH=BlkW               # Blks for Vertial Shuffle
INTERLACED=False        # Doubles minimum required Shuffle1D_Y BlkH, eg YV12 interlaced requires multiple of 4 when INTERLACED=True, else 2
Once1D__X=False         # ONCE for Shuffle1D_X, Keep same shuffle for all frames.
Once1D__Y=False         # ONCE for Shuffle1D_Y, Keep same shuffle for all frames.
DOCROP=False            # True, Crop to mod BLKW,BLKH else AddBorders [width/height must be multiple of blkW,BlkH]
TITLE=True
STACK=True

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")

PADW =  ((Width+BLkW-1)  / BlkW * BlkW) - width
PADH =  ((Height+BlkH-1) / BlkH * BlkH) - Height
(PADW==0 && PADH==0) ? NOP : DOCROP ? Crop(0,0,Width/BLKW*BLKW,Height/BlkH*BlkH) : AddBorders(0,0,PADW,PADH,$808080)

### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                         # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

Shuffled_X=Shuffle1D_X(seed=SECRET_KEY_X,blkW=BLKW,Once=Once1D__X,Inverse=False)                              # Shuffle Horizontal
Shuffled_Y=Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Interlaced=INTERLACED,once=Once1D__Y,Inverse=False)        # Shuffle Vertical
Shuffled=Shuffled_X.Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Once=Once1D__Y,Inverse=False)                     # Combined Horizontal & Vertical Shuffle

Last=Shuffled
Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Interlaced=INTERLACED,once=Once1D__Y,Inverse=True)                    # Inverse: De-Shuffle V/H, Order does not really matter here.
Shuffle1D_X(seed=SECRET_KEY_X,blkW=BLKW,once=Once1D__X,Inverse=True)
UNSHUFFLED=Last

SHUFFLED_X=(TITLE) ? SHUFFLED_X.TSub("Shuffled1D_X"+String(BlkW," BlkW=%.0f Once=")+(Once1D__X?"T":"F"),true) : SHUFFLED_X
SHUFFLED_Y=(TITLE) ? SHUFFLED_Y.TSub("Shuffled1D_Y"+String(BlkH," BlkH=%.0f Once=")+(Once1D__Y?"T":"F"),true) : SHUFFLED_Y
SHUFFLED  =(TITLE) ? Shuffled.TSub("Shuffled1D_X_&_Y"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f ONCE=")+(Once1D__X?"T":"F")+":"+(Once1D__Y?"T":"F"),true) : SHUFFLED
UNSHUFFLED=(TITLE) ? UNSHUFFLED.TSub("Shuffled1D_X_&_Y De-Shuffled") : UNSHUFFLED

TOP = StackHorizontal(SHUFFLED_X,SHUFFLED)
BOT = StackHorizontal(SHUFFLED_Y,UNSHUFFLED)

(STACK) ? StackVertical(TOP,BOT) : SHUFFLED

Return Last.ConvertToRGB32 # For View

#################################

# 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)
}



See MediaFire in sig below this post.
Zip (~110KB) contains 3 dll's, avs v2.58, avs/+ v2.60 x86 & x64.
Also 7 scripts and source + full VS 2008 project files for easy rebuild.

Last edited by StainlessS; 25th August 2020 at 18:58. Reason: Update
StainlessS is offline   Reply With Quote
Old 13th March 2019, 05:03   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Shuffle v1.01 Update, see 1st post.

Main diff, Once arg (Inserted before existing Inverse arg, hope it dont break too many scripts for the half dozen hours its been up).
Code:
    Shuffle1D_Y(clip c, Int "Seed"=0 , Int "blkH"=8 , Bool "Interlaced"=False ,Bool "Once"=False, Bool "Inverse"=False )                # Vertical   Shuffle
    Shuffle1D_X(clip c, Int "Seed"=0 , Int "blkW"=8 ,Bool "Once"=False, Bool "Inverse"=False )                                          # Horizontal Shuffle
    Shuffle2D(clip c, Int "Seed"=0 ,Int "BlkW", Int "blkH"=8 , Bool "Interlaced"=False ,Bool "Once"=False, Bool "Inverse"=False )       # 2D Shuffle


    Once,       Default False. If true, then shuffles for every frame uses the same shuffle pattern, else shuffled differently at every frame. Perhaps better compression.

ORIG_PLUS_AddBorders         34MB     # Source clip, recompressed as x264 CRF 21.5, Slow. Addborders to enable Shuffling BlkW=32 and BlkH=32 args. Below compressed similar.
Shuffle_2x1D_4x4.mp4        169MB
Shuffle_2x1D_8x8.mp4        153MB
Shuffle_2x1D_16x16.mp4      145MB
Shuffle_2x1D_32x32.mp4      131MB

Shuffle_2D_4x4.mp4          173MB
Shuffle_2D_8x8.mp4          159MB
Shuffle_2D_16x16.mp4        151MB
Shuffle_2D_32x32.mp4        137MB

v1.01, ONCE=True
Shuffle_2D_4x4.mp4          117MB
Shuffle_2D_8x8.mp4          104MB
Shuffle_2D_16x16.mp4         82MB
Shuffle_2D_32x32.mp4         53MB
__________________
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; 13th March 2019 at 23:23.
StainlessS is offline   Reply With Quote
Old 13th March 2019, 11:41   #3  |  Link
spoRv
Registered User
 
Join Date: Nov 2016
Posts: 151
Thanks again for the script, and its update!

With once=true is mostly like what I wanted to obtain here https://forum.doom9.org/showthread.php?t=176150
Now, next step would be to inverse/flipvertical/fliphorizontal/turn180/swapuv etc. every single block to shuffle even more.

P.S. My lossless video (lagarith) with once=true has almost the same size of once=false; so, I'd use once=true only for lossy compression.
spoRv is offline   Reply With Quote
Old 13th March 2019, 13:10   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Why not just chop clip in half (V or H, you decide) and flip-V one, Flip-H other, maybe stack back together, and chop in other direction, and do other stuff,
then let the shuffler apply its magic, will be already well disguised.

EDIT: Perhaps of some use, perhaps not. (I think encoders take more care of Luma)
Code:
 
AviSource("D:\Parade.avi")
Limiter
# Maybe Convert PCLevels, and encode full range
BLKH=32 BLKW=BLKH
H=Height%BLKH
W=Width%BLKW
(W!=0||H!=0) ? AddBorders(0,0,BlkW-W,BlkH-H,$808080) : NOP
StackVertical(ConverttoY8,UtoY8.StackHorizontal(VtoY8))
ConvertToYV12  # For Encoder


EDIT:
Code:
V1.01, ONCE=True
Shuffle_2D_4x4.mp4          117MB
Shuffle_2D_32x32.mp4        53MB

# With above prep
Shuffle_2D_4x4.mp4          126MB
Shuffle_2D_32x32.mp4       56.9MB

# With 10 bit encode
Shuffle_2D_32x32.mp4       56.3MB # Read somewhere recently that 10 bit compressed better than 8 bit, did not really believe it.
Above bigger but might be better quality result.
__________________
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; 13th March 2019 at 23:04.
StainlessS is offline   Reply With Quote
Old 21st June 2020, 02:57   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Shuffle v1.02, New version, see 1st post.

Code:
Added ShuffleT(clip c, Int "Seed"=0 , Bool "Inverse"=False )    # Shuffle Temporal, ie shuffle frame order. All valid colorspaces.
ShuffleT.Avs [in zip]
Code:
# ShuffleT.avs

/*
    ShuffleT   (clip c, Int "Seed"=0, Bool "Inverse"=False )               # Shuffle Temporal, ie frame order.
*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")

SECRET_KEY = 123456789

### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                          # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

A=ShuffleT(Seed=SECRET_KEY)
B=A.ShuffleT(Seed=SECRET_KEY,Inverse=true)
A=A.TSub("A=ShuffleT(seed="+String(SECRET_KEY)+")",True)
B=B.TSub("B=A.ShuffleT(seed="+String(SECRET_KEY)+",Inverse=true)",True)
StackHorizontal(A,B)
Return ConvertToRGB32    # For View

####################################

# 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)
}

The top left hand side title number is output frame number, the yellow vertical stack of numbers are input frame numbers [shuffled in the left image].

EDIT: Script and image updated for v1.03. all AVS+ Colorspaces now supported.
__________________
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; 25th August 2020 at 18:46. Reason: Update
StainlessS is offline   Reply With Quote
Old 21st June 2020, 03:07   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Thanks,

ShuffleT works nicely for "Slideshow" type scenarios; and it's a nice working combo with RT_Stats and ImageSplicer

I haven't played with Shuffle1D / 2D yet, but it looks cool too
poisondeathray is offline   Reply With Quote
Old 16th August 2020, 06:25   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #1 of 4.

Shuffle v1.03, new version. See 1st post.

Code:
/*
	v1.02, 21 June 2020, Added ShuffleT.
	v1.03, 16 Aug  2020,
		Fixed a couple of problems. All Colorspaces Supported.
*/
Code:
Shuffle, by StainlessS @ Doom9 : https://forum.doom9.org/showthread.php?t=176193

Shuffle spacial columns or rows (1D), or blocks(2D) of frames, or temporal shuffle (frame order), all shuffles Inversable, ie undoable.
Potential usage in clip obfuscation using 'secret keys', or slideshow random ordering of frames.

Plugin for all Avs/+ valid colorspace.
Dll's for Avs v2.58, v2.60/+ x86 and x64.

    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                                            # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )                   # Vertical   1D Shuffle
    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle
    ShuffleT   (clip c, Int "Seed"=0, Bool "Inverse"=False )                                                                             # Shuffle Temporal, ie frame order.

    c,          Clip to Shuffle
    Seed,       -1=Random seed (Non inverse-able), 0 (default) same shuffle every time, Else any other int = UserSeed or 'SECRET_KEY'.
    BlkW,       Default 8, width of blocks or columns to shuffle.
                (Must be compatible with X Crop args, eg 2 or multiple thereof for YV12, also must divide exactly into Width of clip, use crop or Addborders where necessary).
    BlkH,       Shuffle1D_Y Default=8. Shuffle2D Default=BlkW, NOTE, Changed from original default 8.
                Height of blocks or rows to shuffle.
                (Must be compatible with Y Crop args, eg 2 or multiple thereof for YV12, also must divide exactly into Height of clip, use crop or Addborders where necessary).
    Interlaced, If True, then doubles minimum requirement of BlkH (Shuffle1D_Y and Shuffle2D ONLY).
                    eg YV12, where Interlaced=False blkH would require multiple of 2, and where Interlaced, Would would require multiple of 4, so as not to destroy interlacing.
    Once,       Default False. If true, then uses the same shuffle pattern for every frame, else shuffled differently for every frame.
                    Perhaps better compression if not using ShuffleT.
    Inverse,    Reverses previously done shuffling, Must Use Same Key as was used for the Shuffling stage (and maybe ideally all in reverse shuffle order).

Also see above post, I updated that script and image.

Shuffle_2D.avs
Code:
# Shuffle2D.avs

/*

    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle

*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

SECRET_KEY = 123456789
BlkW=64                 # Blks for Horizontal Shuffle
BlkH=BlkW               # Blks for Vertial Shuffle
INTERLACED=False        # Doubles minimum required Shuffle BlkH, eg YV12 interlaced requires multiple of 4 when INTERLACED=True, else 2
ONCE=False              # Once, Keep same shuffle for all frames.
DOCROP=False            # True, Crop to mod BLKW,BLKH else AddBorders [width/height must be multiple of blkW,BlkH]
TITLE=True
STACK=True

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")

PADW =  ((Width+BLkW-1)  / BlkW * BlkW) - width
PADH =  ((Height+BlkH-1) / BlkH * BlkH) - Height
(PADW==0 && PADH==0) ? NOP : DOCROP ? Crop(0,0,Width/BLKW*BLKW,Height/BlkH*BlkH) : AddBorders(0,0,PADW,PADH,$808080)

### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                         # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

SHUFFLED=Shuffle2D(seed=SECRET_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,Once=ONCE,Inverse=False)                         # Shuffle 2D
UNSHUFFLED=SHUFFLED.Shuffle2D(seed=SECRET_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,Once=ONCE,Inverse=True)               # Inverse 2D shuffle
SHUFFLED  =(TITLE) ? SHUFFLED.TSub("Shuffled2D"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : SHUFFLED
UNSHUFFLED=(TITLE) ? UNSHUFFLED.TSub("Shuffled2D De-Shuffled",true) : UNSHUFFLED
(STACK)?StackHorizontal(SHUFFLED,UNSHUFFLED):SHUFFLED

Return ConvertToRGB32 # For View

############################

# 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)
}
__________________
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; 25th August 2020 at 18:47. Reason: Update
StainlessS is offline   Reply With Quote
Old 16th August 2020, 06:29   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #2 of 4.

Shuffle_3D.avs

Code:
# Shuffle_3D.avs

/*
    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle
    ShuffleT   (clip c, Int "Seed"=0, Bool "Inverse"=False )                                                                             # Shuffle Temporal, ie frame order.
*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")


BlkW=64                         # Blks for Horizontal Shuffle
BlkH=BlkW                       # Blks for Vertial Shuffle
INTERLACED=False                # Doubles minimum required Shuffle BlkH, eg YV12 interlaced requires multiple of 4 when INTERLACED=True, else 2
ONCE=false                      # Once, Keep same shuffle for all frames.
DOCROP=False                    # True, Crop to mod BLKW,BLKH else AddBorders [width/height must be multiple of blkW,BlkH]
SECRET_2D_KEY = 123456789       # Spatial 2D shuffle Key
SECRET_3D_KEY = 987654321       # Temporal (frame order) Shuffle Key, combined with 2D shuffle = 3D Shuffle.
TITLE=True


PADW =  ((Width+BLkW-1)  / BlkW * BlkW) - width
PADH =  ((Height+BlkH-1) / BlkH * BlkH) - Height
(PADW==0 && PADH==0) ? NOP : DOCROP ? Crop(0,0,Width/BLKW*BLKW,Height/BlkH*BlkH) : AddBorders(0,0,PADW,PADH,$808080)


### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                         # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

SHUFFLED = Shuffle2D(seed=SECRET_2D_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,Once=ONCE,Inverse=False)              # Spatial Shuffle 2D
SHUFFLED = SHUFFLED.ShuffleT(Seed=SECRET_3D_KEY, Inverse=False )                                                        # + Temporal Shuffle 3D

DESHUFFLED = SHUFFLED.ShuffleT(Seed=SECRET_3D_KEY, Inverse=True )                                                       # Deshuffle in reverse order, Temporal with 3D key
DESHUFFLED = DESHUFFLED.Shuffle2D(seed=SECRET_2D_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,Once=ONCE,Inverse=true)  # Spatial De-Shuffle 2D, with 2D key

SHUFFLED   = (TITLE) ? SHUFFLED.TSub("Shuffled3D"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : SHUFFLED
DESHUFFLED = (TITLE) ? DESHUFFLED.TSub("Shuffled De-Shuffled",true) : DESHUFFLED
StackHorizontal(SHUFFLED,DESHUFFLED)

Return Last.ConvertToRGB32 # For View

########################################

# 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)
}


EDIT: Shuffled frame 0 comes from (what looks like) frame 58778, Unshuffled restores to original frame 0.
__________________
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; 25th August 2020 at 18:47. Reason: Update
StainlessS is offline   Reply With Quote
Old 16th August 2020, 06:32   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #3 of 4.

Shuffle_2x1D.avs
Code:
# Shuffle_2x1D.avs
/*

    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                           # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # Vertical   1D Shuffle

*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

SECRET_KEY_X = 123456789
SECRET_KEY_Y = 987654321
BlkW=64                  # Blks for Horizontal Shuffle
BlkH=BlkW               # Blks for Vertial Shuffle
INTERLACED=False        # Doubles minimum required Shuffle1D_Y BlkH, eg YV12 interlaced requires multiple of 4 when INTERLACED=True, else 2
Once1D__X=False         # ONCE for Shuffle1D_X, Keep same shuffle for all frames.
Once1D__Y=False         # ONCE for Shuffle1D_Y, Keep same shuffle for all frames.
DOCROP=False            # True, Crop to mod BLKW,BLKH else AddBorders [width/height must be multiple of blkW,BlkH]
TITLE=True
STACK=True

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")

PADW =  ((Width+BLkW-1)  / BlkW * BlkW) - width
PADH =  ((Height+BlkH-1) / BlkH * BlkH) - Height
(PADW==0 && PADH==0) ? NOP : DOCROP ? Crop(0,0,Width/BLKW*BLKW,Height/BlkH*BlkH) : AddBorders(0,0,PADW,PADH,$808080)

### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                         # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

Shuffled_X=Shuffle1D_X(seed=SECRET_KEY_X,blkW=BLKW,Once=Once1D__X,Inverse=False)                              # Shuffle Horizontal
Shuffled_Y=Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Interlaced=INTERLACED,once=Once1D__Y,Inverse=False)        # Shuffle Vertical
Shuffled=Shuffled_X.Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Once=Once1D__Y,Inverse=False)                     # Combined Horizontal & Vertical Shuffle

Last=Shuffled
Shuffle1D_Y(seed=SECRET_KEY_Y,blkH=BLKH,Interlaced=INTERLACED,once=Once1D__Y,Inverse=True)                    # Inverse: De-Shuffle V/H, Order does not really matter here.
Shuffle1D_X(seed=SECRET_KEY_X,blkW=BLKW,once=Once1D__X,Inverse=True)
UNSHUFFLED=Last

SHUFFLED_X=(TITLE) ? SHUFFLED_X.TSub("Shuffled1D_X"+String(BlkW," BlkW=%.0f Once=")+(Once1D__X?"T":"F"),true) : SHUFFLED_X
SHUFFLED_Y=(TITLE) ? SHUFFLED_Y.TSub("Shuffled1D_Y"+String(BlkH," BlkH=%.0f Once=")+(Once1D__Y?"T":"F"),true) : SHUFFLED_Y
SHUFFLED  =(TITLE) ? Shuffled.TSub("Shuffled1D_X_&_Y"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f ONCE=")+(Once1D__X?"T":"F")+":"+(Once1D__Y?"T":"F"),true) : SHUFFLED
UNSHUFFLED=(TITLE) ? UNSHUFFLED.TSub("Shuffled1D_X_&_Y De-Shuffled") : UNSHUFFLED

TOP = StackHorizontal(SHUFFLED_X,SHUFFLED)
BOT = StackHorizontal(SHUFFLED_Y,UNSHUFFLED)

(STACK) ? StackVertical(TOP,BOT) : SHUFFLED

Return Last.ConvertToRGB32 # For View

#################################

# 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)
}
__________________
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; 25th August 2020 at 18:47. Reason: Update
StainlessS is offline   Reply With Quote
Old 16th August 2020, 06:35   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #4 of 4.

Shuffle_Compared.avs [1D and 2D, not 3D ie no temporal frame shuffling]
Code:
# Shuffle_Compared.avs

/*

    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                                            # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )                   # Vertical   1D Shuffle
    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle

*/

#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")

SECRET_KEY = 123456789
BlkW=4                  # Blks for Horizontal Shuffle
BlkH=BlkW               # Blks for Vertial Shuffle
INTERLACED=False        # Doubles minimum required ShuffleV BlkH, eg YV12 interlaced requires multiple of 4 when INTERLACED=True, else 2
ONCE=False              # Once, Keep same shuffle for all frames.
DOCROP=false            # True, Crop to mod BLKW,BLKH else AddBorders [width/height must be multiple of blkW,BlkH]
TITLE=True

Colorbars.ShowFrameNumber
#AviSource("D:\Parade.avi")


PADW =  ((Width+BLkW-1)  / BlkW * BlkW) - width
PADH =  ((Height+BlkH-1) / BlkH * BlkH) - Height
(PADW==0 && PADH==0) ? NOP : DOCROP ? Crop(0,0,Width/BLKW*BLKW,Height/BlkH*BlkH) : AddBorders(0,0,PADW,PADH,$808080)

### Can Uncomment ONE of below lines for a colorspace test

#ConvertToRGB24                                         # RGB24
#ConvertToRGB32                                         # RGB32
#ConvertToYUY2                                          # YUY2
#ConvertToYV12                                         # YV12
# v2.60 +
#ConvertToYV411                                         # YV411
#ConvertToYV16                                          # YV16
#ConvertToYV24                                          # YV24
#ConvertToY8                                            # Y8
# Avs+
# 8 Bit
#ConvertToPlanarRGB                                     # RGBP8
#ConvertToPlanarRGBA                                    # RGBAP8
# 10 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(10)      # RGBP10
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(10)     # RGBAP10
#ConvertToY8.ConvertBits(10)                            # Y10
#ConvertToYV12.ConvertBits(10)                          # YUV420P10
#ConvertToYV16.ConvertBits(10)                          # YUV422P10
#ConvertToYV24.ConvertBits(10)                          # YUV444P10
#ConvertToYV12.ConvertBits(10).AddAlphaPlane            # YUVA420P10
#ConvertToYV16.ConvertBits(10).AddAlphaPlane            # YUVA422P10
#ConvertToYV24.ConvertBits(10).AddAlphaPlane            # YUVA444P10
# 12 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(12)      # RGBP12
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(12)     # RGBAP12
#ConvertToY8.ConvertBits(12)                            # Y12
#ConvertToYV12.ConvertBits(12)                          # YUV420P12
#ConvertToYV16.ConvertBits(12)                          # YUV422P12
#ConvertToYV24.ConvertBits(12)                          # YUV444P12
#ConvertToYV12.ConvertBits(12).AddAlphaPlane            # YUVA420P12
#ConvertToYV16.ConvertBits(12).AddAlphaPlane            # YUVA422P12
#ConvertToYV24.ConvertBits(12).AddAlphaPlane            # YUVA444P12
# 14 Bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(14)      # RGBP14
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(14)     # RGBAP14
#ConvertToY8.ConvertBits(14)                            # Y14
#ConvertToYV12.ConvertBits(14)                          # YUV420P14
#ConvertToYV16.ConvertBits(14)                          # YUV422P14
#ConvertToYV24.ConvertBits(14)                          # YUV444P14
#ConvertToYV12.ConvertBits(14).AddAlphaPlane            # YUVA420P14
#ConvertToYV16.ConvertBits(14).AddAlphaPlane            # YUVA422P14
#ConvertToYV24.ConvertBits(14).AddAlphaPlane            # YUVA444P14
# 16 Bit
#ConvertToRGB48                                         # RGB48     Intereleaved RGB  16 bit
#ConvertToRGB64                                         # RGB64     Intereleaved RGBA 16 bit
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(16)      # RGBP16
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(16)     # RGBAP16
#ConvertToY8.ConvertBits(16)                            # Y16
#ConvertToYV12.ConvertBits(16)                          # YUV420P16
#ConvertToYV16.ConvertBits(16)                          # YUV422P16
#ConvertToYV24.ConvertBits(16)                          # YUV444P16
#ConvertToYV12.ConvertBits(16).AddAlphaPlane            # YUVA420P16
#ConvertToYV16.ConvertBits(16).AddAlphaPlane            # YUVA422P16
#ConvertToYV24.ConvertBits(16).AddAlphaPlane            # YUVA444P16
# 32 Bit Float
#ConvertToRGB48.ConvertToPlanarRGB.ConvertBits(32)      # RGBPS
#ConvertToRGB64.ConvertToPlanarRGBA.ConvertBits(32)     # RGBAPS
#ConvertToY8.ConvertBits(32)                            # Y32
#ConvertToYV12.ConvertBits(32)                          # YUV420PS
#ConvertToYV16.ConvertBits(32)                          # YUV422PS
#ConvertToYV24.ConvertBits(32)                          # YUV444PS
#ConvertToYV12.ConvertBits(32).AddAlphaPlane            # YUVA420PS
#ConvertToYV16.ConvertBits(32).AddAlphaPlane            # YUVA422PS
#ConvertToYV24.ConvertBits(32).AddAlphaPlane            # YUVA444PS

#return Last.Info.ConvertToRGB32 # for view

Shuffled_X    = Shuffle1D_X(seed=SECRET_KEY,blkW=BLKW,once=ONCE,Inverse=False)                                          # Shuffle Horizontal
Shuffled_Y    = Shuffle1D_Y(seed=SECRET_KEY,blkH=BLKH,Interlaced=INTERLACED,once=ONCE,Inverse=False)                    # Shuffle Vertical
Shuffled_1D   = Shuffled_X.Shuffle1D_Y(seed=SECRET_KEY,blkH=BLKH,Interlaced=INTERLACED,once=ONCE,Inverse=False)         # Shuffle 2x1D
SHUFFLED_2D   = Shuffle2D(seed=SECRET_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,once=ONCE,Inverse=False)            # Shuffle 2D

UNSHUFFLED_1D = Shuffled_1D.Shuffle1D_Y(seed=SECRET_KEY,blkH=BLKH,Interlaced=INTERLACED,once=ONCE,Inverse=True)
            \ .Shuffle1D_X(seed=SECRET_KEY,blkW=BLKW,once=ONCE,Inverse=True)                                            # Shuffle 2x1D, Unshuffled
UNSHUFFLED_2D = Shuffled_2D.Shuffle2D(seed=SECRET_KEY,blkW=BLKW,blkH=BLKH,Interlaced=INTERLACED,once=ONCE,Inverse=True) # Shuffle 2D,   Unshuffled

SHUFFLED_X =(TITLE) ? SHUFFLED_X.TSub("Shuffled1D_X"+String(BlkW," BlkW=%.0f"),true) : SHUFFLED_X
SHUFFLED_Y =(TITLE) ? SHUFFLED_Y.TSub("Shuffled1D_Y"+String(BlkH," BlkH=%.0f"),true) : SHUFFLED_Y
SHUFFLED_1D=(TITLE) ? Shuffled_1D.TSub("Shuffled1D_X_&_Y"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : SHUFFLED_1D
SHUFFLED_2D=(TITLE) ? Shuffled_2D.TSub("Shuffled2D"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : SHUFFLED_2D
UNSHUFFLED_1D=(TITLE) ? UNSHUFFLED_1D.TSub("UnShuffled1D_X_&_Y"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : UNSHUFFLED_1D
UNSHUFFLED_2D=(TITLE) ? UNSHUFFLED_2D.TSub("UnShuffled2D"+String(BlkW," Blk=%.0f")+String(BlkH,"x%.0f"),true) : UNSHUFFLED_2D

TOP=StackHorizontal(SHUFFLED_X,SHUFFLED_1D,  SHUFFLED_2D)
BOT=StackHorizontal(SHUFFLED_Y,UNSHUFFLED_1D,UNSHUFFLED_2D)
StackVertical(TOP,BOT)

Return ConvertToRGB32  # For view

####################################

# 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)
}
__________________
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; 25th August 2020 at 18:48. Reason: Update
StainlessS is offline   Reply With Quote
Old 19th August 2020, 19:40   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Shuffle v1.04, update, see 1st post.
Previous scripts all updated.

Code:
/*
	v1.02, 21 June 2020,	Added ShuffleT.
	v1.03, 16 Aug  2020,	Fixed a couple of problems. All Colorspaces Supported.
	v1.04, 19 Aug 2020,	All class variables now constant, MT compatible. Pretty much total re-write.
*/
Added DOCROP var to scripts, where not width,height multuples of BlkW,BlkH, then false = Addborders, true=Crop.
__________________
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; 19th August 2020 at 19:45.
StainlessS is offline   Reply With Quote
Old 25th August 2020, 16:41   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Just a word to the wise, seems that there was already a StickBoy plugin going by the name Shuffle
Stickboy stuff:- http://www.avisynth.nl/users/stickboy/
Shuffle frame order in groups of frames (where frame order within each group is maintained).

Ah well, too late now I guess.

Anyway, is an alternative [ to ShuffleT() ] for PDR (PoisonDeathRay) requirement.

EDIT: Stickboy even suggests random SlideShow as a possible usage.

EDIT: Could also use together with my Shuffle (Using renamed plugin name of eg stickboys version), Filternames seem not to collide only dll name.
Possible to maybe add in a twist where clip obfuscation required, Stickboy filter also takes a 'seed' argument.
EDIT: No you cant, dont seem to be Inverse-able.
__________________
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; 25th August 2020 at 18:38.
StainlessS is offline   Reply With Quote
Old 25th August 2020, 17:02   #13  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
since Stickboy was the first, your plugin should be renamed then like SShuffle or ShuffleS
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 25th August 2020, 17:04   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I hate you.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 25th August 2020, 17:08   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
As my dll's are called
Shuffle_25.dll
Shuffle_x86.dll
Shuffle_x64.dll

So OK, you're back in my good books, nobody gotta rename anything [Stickboy's is Shuffle.dll).

EDIT: OK, I hate you again. I'll rename to ShufflessS_x64.dl etc.
__________________
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; 25th August 2020 at 17:14.
StainlessS is offline   Reply With Quote
Old 25th August 2020, 17:15   #16  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
the point is the function name, not just the dll name
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 25th August 2020, 18:40   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
None of my functions are called 'Shuffle',

Code:
    Shuffle1D_X(clip c, Int "Seed"=0, Int "blkW"=8, Bool "Once"=False, Bool "Inverse"=False )                                            # Horizontal 1D Shuffle
    Shuffle1D_Y(clip c, Int "Seed"=0, Int "blkH"=8, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )                   # Vertical   1D Shuffle
    Shuffle2D  (clip c, Int "Seed"=0, Int "blkW"=8, Int "blkH"=blkW, Bool "Interlaced"=False, Bool "Once"=False, Bool "Inverse"=False )  # 2D Shuffle
    ShuffleT   (clip c, Int "Seed"=0, Bool "Inverse"=False )                                                                             # Shuffle Temporal, ie frame order.
Done it now (Renamed dll to basename "ShufflessS").
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 25th August 2020, 18:52   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Update to v1.05, same as v1.04, except source, Version resource, dll's, project files, and thread, renamed to ShufflessS.
See 1st post.

Code:
/*
	v1.02, 21 June 2020,	Added ShuffleT.
	v1.03, 16 Aug  2020,	Fixed a couple of problems. All Colorspaces Supported.
	v1.04, 19 Aug 2020,		All class variables now constant, MT compatible. Pretty much total re-write.
	v1.05, 25 Aug 2020,     Renamed dll's from style "Shuffle_x86.dll" to style "ShufflessS_x86.dll", conflict with Stickboy Shuffle.dll.
*/
Previous posted scripts updated as per
Code:
#LoadPlugin(".\ShufflessS_25.dll")
#LoadPlugin(".\ShufflessS_x86.dll")
#LoadPlugin(".\ShufflessS_x64.dll")
I will no doubt keep referring to it as Shuffle.
__________________
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; 25th August 2020 at 18:56.
StainlessS is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.