summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorsl1pkn072015-06-08 20:46:55 +0200
committersl1pkn072015-06-08 20:46:55 +0200
commit1e47f13fc082a42b1bea30f9ddb12a2e81fe7c16 (patch)
tree5bd529201beb01826c981290f457fe8c1e9d0d7d
downloadaur-1e47f13fc082a42b1bea30f9ddb12a2e81fe7c16.tar.gz
Initial commit
-rw-r--r--.SRCINFO13
-rw-r--r--.gitignore5
-rw-r--r--PKGBUILD18
-rw-r--r--averagehist.py63
4 files changed, 99 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..1fe269fd1f55
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,13 @@
+pkgbase = vapoursynth-plugin-averagehist
+ pkgdesc = Plugin for Vapoursynth: averagehist
+ pkgver = r0
+ pkgrel = 1
+ url = http://forum.doom9.org/showthread.php?t=168521
+ arch = any
+ license = GPL
+ depends = vapoursynth
+ source = averagehist.py
+ sha1sums = 7180cdb099965cd9cf300afad41e23fff4da82f6
+
+pkgname = vapoursynth-plugin-averagehist
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..71b96fd76f58
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*
+!.gitignore
+!.SRCINFO
+!PKGBUILD
+!averagehist.py
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..a5d63f3d8428
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Gustavo Alvarez <sl1pkn07@gmail.com>
+
+_plug=averagehist
+pkgname=vapoursynth-plugin-${_plug}
+pkgver=r0
+pkgrel=1
+pkgdesc="Plugin for Vapoursynth: ${_plug}"
+arch=('any')
+url="http://forum.doom9.org/showthread.php?t=168521"
+license=('GPL')
+depends=('vapoursynth')
+source=('averagehist.py')
+sha1sums=('7180cdb099965cd9cf300afad41e23fff4da82f6')
+_sites_packages="$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")"
+
+package(){
+ install -Dm644 averagehist.py "${pkgdir}${_sites_packages}/averagehist.py"
+}
diff --git a/averagehist.py b/averagehist.py
new file mode 100644
index 000000000000..2b06d653f173
--- /dev/null
+++ b/averagehist.py
@@ -0,0 +1,63 @@
+# averagehist.py : average histogram for vapoursynth
+# author : ganymede
+# requirement : histogram
+
+class AverageHist():
+ """Average histogram for vapoursynth."""
+ def __init__(self, core):
+ """core : vapoursynth's core instance."""
+ self.core = core
+
+ def get_hist(self, clip, mode):
+ """Returns a cropped histogram."""
+ if mode == 'Levels':
+ clip = self.core.hist.Levels(clip)
+ clip = self.core.std.CropRel(clip, (clip.width - 256), 0, 0, (clip.height - 256) )
+ elif mode == 'Color':
+ clip = self.core.hist.Color(clip)
+ clip = self.core.std.CropRel(clip, (clip.width - 256), 0, 0, (clip.height - 256) )
+ elif mode == 'Color2':
+ clip = self.core.hist.Color2(clip)
+ clip = self.core.std.CropRel(clip, (clip.width - 256), 0, 0, (clip.height - 256) )
+ elif mode == 'Combined1':
+ c1 = self.core.hist.Levels(clip)
+ c1 = self.core.std.CropRel(c1, (c1.width - 256), 0, 0, (c1.height - 256) )
+ c2 = self.core.hist.Color2(clip)
+ c2 = self.core.std.CropRel(c2, (c2.width - 256), 0, 0, (c2.height - 256) )
+ clip = self.core.std.StackVertical([c1,c2])
+ elif mode == "Combined2":
+ c1 = self.core.hist.Levels(clip)
+ c1 = self.core.std.CropRel(c1, (c1.width - 256), 0, 0, (c1.height - 256) )
+ c2 = self.core.hist.Color2(clip)
+ c2 = self.core.std.CropRel(c2, (c2.width - 256), 0, 0, (c2.height - 256) )
+ c3 = self.core.hist.Classic(clip)
+ c3 = self.core.std.CropRel(c3, (c3.width - 256), 0, 0, 0 )
+ c4 = self.core.std.StackVertical([c1,c2])
+ if c3.height < c4.height:
+ c3 = self.core.std.AddBorders(c3, 0, 0, 0, (c4.height - c3.height), [0,128,128])
+ elif c3.height > c4.height:
+ c4 = self.core.std.AddBorders(c4, 0, 0, 0, (c3.height - c4.height), [0,128,128])
+ clip = self.core.std.StackHorizontal([c3,c4])
+ else:
+ clip = self.core.hist.Classic(clip)
+ clip = self.core.std.CropRel(clip, (clip.width - 256), 0, 0, 0 )
+ return clip
+
+ def get_average(self, clip, mode='Classic'):
+ """mode can be one of 'Classic', 'Levels', 'Color', 'Color2', 'Combined1' or 'Combined2'."""
+ hist = self.get_hist(clip,mode)
+ average = hist[0]
+ for i in range(1, clip.num_frames):
+ average = self.core.std.Merge( [average, hist[i]], ( 1.0/(i+1) ) )
+ return average
+
+def usage():
+ msg = '''Usage :
+ import averagehist
+ AH = averagehist.AverageHist(core)
+ clip = AH.get_average(clip, mode='Classic')'''
+ print(msg)
+
+if __name__ == '__main__':
+ usage()
+