From 3f14c779cc3f3de1da7cee18fb52868c1eb10354 Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Wed, 28 Oct 2009 19:50:17 +1030
Subject: dpgconv mpeg_stat: Add utility for transcoding to dpg for playback on
 Nintendo DS (including panscan patch)

---
 abs/extra-testing/dpgconv/PKGBUILD              | 22 +++++++
 abs/extra-testing/dpgconv/dpgconv-panscan.patch | 83 +++++++++++++++++++++++++
 abs/extra-testing/mpeg_stat/PKGBUILD            | 19 ++++++
 3 files changed, 124 insertions(+)
 create mode 100644 abs/extra-testing/dpgconv/PKGBUILD
 create mode 100644 abs/extra-testing/dpgconv/dpgconv-panscan.patch
 create mode 100644 abs/extra-testing/mpeg_stat/PKGBUILD

diff --git a/abs/extra-testing/dpgconv/PKGBUILD b/abs/extra-testing/dpgconv/PKGBUILD
new file mode 100644
index 0000000..82fe117
--- /dev/null
+++ b/abs/extra-testing/dpgconv/PKGBUILD
@@ -0,0 +1,22 @@
+# Contributor: Nick B <Shirakawasuna at gmail _dot_com>
+pkgname=dpgconv
+pkgver=9
+pkgrel=1
+pkgdesc="This is a converter to produce DPG movies for Moonshell software for Nintendo DS."
+arch=('i686' 'x86_64')
+url="http://theli.is-a-geek.org/blog/static/dpgconv"
+license=('GPL2')
+depends=('mpeg_stat' 'mplayer')
+source=(http://theli.is-a-geek.org/files/dpgconv/dpgconv-$pkgver.py.bz2
+	dpgconv-panscan.patch)
+
+build() {
+
+cd $startdir/src
+patch < dpgconv-panscan.patch
+install -m755 -D $startdir/src/dpgconv-$pkgver.py $startdir/pkg/usr/bin/dpgconv-$pkgver.py
+cd $startdir/pkg/usr/bin
+ln -s dpgconv-$pkgver.py dpgconv.py
+}
+md5sums=('fa61ceb4ebb241e98fc005aed86406e5')
+
diff --git a/abs/extra-testing/dpgconv/dpgconv-panscan.patch b/abs/extra-testing/dpgconv/dpgconv-panscan.patch
new file mode 100644
index 0000000..471d518
--- /dev/null
+++ b/abs/extra-testing/dpgconv/dpgconv-panscan.patch
@@ -0,0 +1,83 @@
+--- dpgconv-9.py.old	2009-10-28 19:33:46.000000000 +1030
++++ dpgconv-9.py	2009-10-28 19:28:01.000000000 +1030
+@@ -49,9 +49,12 @@
+ 	--width xxx
+ 		destination video width (default: 256)
+ 	--keep-aspect
+-		try to keep aspect ratio
++		try to keep aspect ratio by letterboxing
++        --keep-aspect-panscan
++		try to keep aspect ratio by cropping original
+ 	
+ 	NOTE:	width/height have no effect when --keep-aspect is set
++		--keep-aspect-panscan overrides --keep-aspect
+ 	
+ 	--mv
+ 		additional parameters for mencoder for video
+@@ -150,8 +153,38 @@
+ 		v_pf = "format=rgb24,"
+ 		options.pf = 3
+ 
+-	if options.aspect:
+-		aspect = commands.getoutput( MPLAYER + " -frames 1 -vo null -ao null -identify \"" + file + "\" | grep -E \"^ID_VIDEO_ASPECT\"")
++	crop=""
++	if options.panscan:
++		options.width=256
++		options.height=192
++
++		aspect = commands.getoutput( MPLAYER + " -frames 1 -vo null -ao null -identify \"" + file + "\" | grep -E \"^ID_VIDEO_ASPECT\" | tail -1")
++		p1 = re.compile ("ID_VIDEO_ASPECT=(.*)")
++		m1 = p1.search( aspect )
++		width = commands.getoutput( MPLAYER + " -frames 1 -vo null -ao null -identify \"" + file + "\" | grep -E \"^ID_VIDEO_WIDTH\" | tail -1")
++		p2 = re.compile ("ID_VIDEO_WIDTH=(.*)")
++		m2 = p2.search( width )
++		height = commands.getoutput( MPLAYER + " -frames 1 -vo null -ao null -identify \"" + file + "\" | grep -E \"^ID_VIDEO_HEIGHT\" | tail -1")
++		p3 = re.compile ("ID_VIDEO_HEIGHT=(.*)")
++		m3 = p3.search( height )
++		if m1 and m2 and m3:
++			print "Input Aspect %s" % m1.group(1)
++			print "Input Width %s" % m2.group(1)
++			print "Input Height %s" % m3.group(1)
++			ar = float (m1.group(1))
++			iw = int (m2.group(1))
++			ih = int (m3.group(1))
++			if aspect > 1.333333:
++				cropw=int(round(iw / ar * 4 / 3, 0))
++				croph=ih
++			else:
++				cropw=iw
++				croph=int(round(ih * ar * 3 / 4, 0))
++			crop="crop="+`cropw`+":"+`croph`+","
++			print crop
++
++	elif options.aspect:
++		aspect = commands.getoutput( MPLAYER + " -frames 1 -vo null -ao null -identify \"" + file + "\" | grep -E \"^ID_VIDEO_ASPECT\" | tail -1")
+ 		p = re.compile ("ID_VIDEO_ASPECT=(.*)")
+ 		m = p.search( aspect )
+ 		if m:
+@@ -169,13 +202,13 @@
+ 		if options.fps < 24:
+ 			print "mencoder won't work with double pass and fps < 24, forcing fps = 24"
+ 			options.fps = 24
+-		v_cmd =  ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + "scale=" + `options.width` + ":" + `options.height` +":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:vmax_b_frames=2:cmp=6:subcmp=6:precmp=6:dia=4:predia=4:bidir_refine=4:mv0_threshold=0:last_pred=3:vbitrate=" + `options.vbps` )
++		v_cmd =  ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + crop + "scale=" + `options.width` + ":" + `options.height` +":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:vmax_b_frames=2:cmp=6:subcmp=6:precmp=6:dia=4:predia=4:bidir_refine=4:mv0_threshold=0:last_pred=3:vbitrate=" + `options.vbps` )
+ 	elif options.hq:
+-		v_cmd =  ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + "scale=" + `options.width` + ":" + `options.height` +":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:cmp=6:subcmp=6:precmp=6:dia=3:predia=3:last_pred=3:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo" )
++		v_cmd =  ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + crop + "scale=" + `options.width` + ":" + `options.height` +":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:cmp=6:subcmp=6:precmp=6:dia=3:predia=3:last_pred=3:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo" )
+ 	elif options.lq:
+-		v_cmd = ( " \"" + file + "\" -v -ofps " + `options.fps` + " -vf " + v_pf + "scale=" + `options.width` + ":" + `options.height` + ",harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo" )
++		v_cmd = ( " \"" + file + "\" -v -ofps " + `options.fps` + " -vf " + v_pf + crop + "scale=" + `options.width` + ":" + `options.height` + ",harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo" )
+ 	else :
+-		v_cmd = ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + "scale=" + `options.width` + ":" + `options.height` + ":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:cmp=2:subcmp=2:precmp=2:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo")
++		v_cmd = ( " \""+ file +"\" -v -ofps " + `options.fps` + " -sws 9 -vf " + v_pf + crop + "scale=" + `options.width` + ":" + `options.height` + ":::3,harddup -nosound -ovc lavc -lavcopts vcodec=mpeg1video:vstrict=-2:mbd=2:trell:cbp:mv0:cmp=2:subcmp=2:precmp=2:vbitrate=" + `options.vbps` + " -o " + MPGTMP + " -of rawvideo")
+ 	
+ 	if options.nosub:
+ 		if options.sub != None:
+@@ -459,6 +492,7 @@
+ parser.add_option("-a","--abps", type="int", dest="abps", default=128)
+ parser.add_option("--volnorm", action="store_true", dest="volnorm", default=False)
+ parser.add_option("--keep-aspect", action="store_true", dest="aspect", default=False)
++parser.add_option("--keep-aspect-panscan", action="store_true", dest="panscan", default=False)
+ parser.add_option("--height", type="int", dest="height", default=192)
+ parser.add_option("--width", type="int", dest="width", default=256)
+ parser.add_option("-z","--hz", type="int", dest="hz", default=32000)
diff --git a/abs/extra-testing/mpeg_stat/PKGBUILD b/abs/extra-testing/mpeg_stat/PKGBUILD
new file mode 100644
index 0000000..37be249
--- /dev/null
+++ b/abs/extra-testing/mpeg_stat/PKGBUILD
@@ -0,0 +1,19 @@
+# Contributor: Nick B <Shirakawasuna at gmail _dot_com>
+pkgname=mpeg_stat
+pkgver=2.2b
+pkgrel=2
+pkgdesc="A Berkely MPEG Tools bitstream analysis tool."
+arch=('i686' 'x86_64')
+url="http://bmrc.berkeley.edu/ftp/pub/multimedia/mpeg/"
+license=('custom')
+depends=('ffmpeg')
+source=(http://www.sfr-fresh.com/unix/misc/old/${pkgname}-${pkgver}-src.tar.gz)
+
+build() {
+
+cd $startdir/src/mpeg_stat
+make || return 1
+install -m755 -D $startdir/src/mpeg_stat/mpeg_stat $startdir/pkg/usr/bin/mpeg_stat
+install -m644 -D $startdir/src/mpeg_stat/COPYRIGHT $startdir/pkg/usr/share/licenses/mpeg_stat/COPYRIGHT
+}
+
-- 
cgit v0.12