Skip to content

Instantly share code, notes, and snippets.

@tp7
tp7 / mt_lutspa.py
Created October 14, 2015 16:16
VSynth lutspa
# -*- coding: utf-8 -*-
import numpy as np
import vapoursynth as vs
def bool_to_number(function):
def wrapped(*args):
value = function(*args)
return np.where(value, np.array(1.0), np.array(-1.0))
return wrapped
@tp7
tp7 / lutpsa.py
Last active October 13, 2015 20:49
Sample lutspa implementation
# -*- coding: utf-8 -*-
import cv2
import numpy as np
binary_operators = {
"+": lambda x, y: x + y,
"-": lambda x, y: x - y,
"*": lambda x, y: x * y,
"/": lambda x, y: x / y,
}
@tp7
tp7 / main.py
Created March 15, 2015 20:45
Add two numbers in x86 assembly in Python
# -*- coding: utf-8 -*-
import mmap
import ctypes
def run():
code_stream = mmap.mmap(-1, 4096, mmap.MAP_PRIVATE,
mmap.PROT_EXEC | mmap.PROT_READ | mmap.PROT_WRITE)
code_stream.write(b"\x01\xf7") # add edi, esi
code_stream.write(b"\x89\xf8") # mov eax, edi
'''
A simple script that can remove useless \iclip's and invisible lines from your ass subtitles.
Usage: clean-iclips.py script.ass
It will not overwrite the input file. Probably.
You have to have avisynth, avsmeter, masktools and vsfilter plugin installed.
Also be sure the fonts are loaded (e.g. using some font manager), otherwise it might remove wrong clips/lines.
Poorly written by tp7, must be used for no evil.
'''
@tp7
tp7 / MtModes.avsi
Last active July 19, 2017 06:02
Avisynth+ MT modes definitions
###########################################################################
# DO NOT OPEN THIS DOCUMENT IN GOOGLE TRANSLATE OR BAD THINGS WILL HAPPEN #
###########################################################################
# General info:
# 1. Do not include core filters in the list
# 2. Specify the lowest mode that produces correct output with any settings.
# For example if something works with MT_MULTI_INSTANCE on some parameters and MT_SERIALIZED with other, MT_SERIALIZED should be used
# You can of course specify this in comments so people who do want to get MAXIMUM PERFORMANCE can modify the script themselves.
# 3. Do not specify MT modes for runtime filters. Behaviour of runtime filtering with mt is not very well known yet.
# 4. In case it isn't obvious, NICE_FILTER - mt mode 1, MULTI_INSTANCE - mt mode 2, SERIALIZED - mt mode 3. Variables are defined by avs+ core.