From 6b896b4eeca3db7170369c57137e151cb27a00d1 Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Sun, 18 Apr 2010 17:05:01 +0930
Subject: test-pattern: add interlaced support

---
 abs/core-testing/test-pattern/PKGBUILD          |  4 +--
 abs/core-testing/test-pattern/test_pattern.bash | 36 ++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/abs/core-testing/test-pattern/PKGBUILD b/abs/core-testing/test-pattern/PKGBUILD
index 3604a6f..db15a0d 100644
--- a/abs/core-testing/test-pattern/PKGBUILD
+++ b/abs/core-testing/test-pattern/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=test-pattern
 pkgver=1.0
-pkgrel=3
+pkgrel=4
 arch=('i686')
 pkgdesc="script to create test pattern videos"
 depends=(imagemagick)
@@ -13,4 +13,4 @@ build() {
   install -m755 -D test_pattern.bash $startdir/pkg/usr/bin/test_pattern.bash
 }
 
-md5sums=('67359cc8826c99ac09e8a1d0d87fc381')
+md5sums=('fbe06cf5a38090e2242f4c3e42f3fc7a')
diff --git a/abs/core-testing/test-pattern/test_pattern.bash b/abs/core-testing/test-pattern/test_pattern.bash
index c2af38e..6e7fff9 100755
--- a/abs/core-testing/test-pattern/test_pattern.bash
+++ b/abs/core-testing/test-pattern/test_pattern.bash
@@ -7,8 +7,9 @@ h=325
 rate=50
 TEMPDIR=
 unset remove_tempdir
+interlaced=
 
-while getopts ":w:h:t:r:" opt; do
+while getopts ":w:h:t:r:i" opt; do
   case $opt in
     w)
       w=$OPTARG
@@ -22,6 +23,9 @@ while getopts ":w:h:t:r:" opt; do
     r)
       rate=$OPTARG
       ;;
+    i)
+      interlaced=TRUE
+      ;;
     \?)
       echo -n"\
 Error: Invalid option -$OPTARG
@@ -35,6 +39,8 @@ Usage:
     -t tempdir
 	Temporary directory for intermediate files. If no directory is specified, one is created and deleted at the end of processing.
     -r framerate
+    -i
+	Generate an interlaced test pattern
 "
       exit 1
   esac
@@ -240,9 +246,16 @@ convert -size ${w}x${h} xc:grey50 \
 
 convert -size ${w}x${h} ${TEMPDIR}/grid.png ${TEMPDIR}/centre.png ${TEMPDIR}/circle.png -composite ${TEMPDIR}/background.png
 
+if [ -n "$interlaced" ] ; then
+  interlaced_frame=0
+  convert -size 1x${h} -tile-offset +0+1 pattern:gray50 \
+    -scale ${w}x${h}\! ${TEMPDIR}/interlace.png
+fi
+
 for ((i=0; i < $frames; i++)) ; do
 
-  image_name=${TEMPDIR}/test$(printf "%03d" $i).jpg
+  prev_image_name=$image_name
+  image_name=${TEMPDIR}/test$(printf "%03d" $i).png
   echo creating image $image_name
 
   convert -size ${w}x${h} ${TEMPDIR}/background.png \
@@ -253,10 +266,27 @@ for ((i=0; i < $frames; i++)) ; do
 	  -fill white \
           -stroke black -strokewidth 5 -annotate +$((w-2*i))+$((gridstartx+11*unit)) 'Judder Test' \
           -stroke none                 -annotate +$((w-2*i))+$((gridstartx+11*unit)) 'Judder Test' \
+	  -depth 8 \
 	  ${image_name}
+
+  if [ -n "$interlaced" ] ; then
+    interlaced_frame=$((interlaced_frame + 1))
+
+    if [ $interlaced_frame = 2 ] ; then
+      echo interlacing $((i-1)) and $i
+      interlaced_frame=0
+      convert -size ${w}x${h} -depth 8 $prev_image_name $image_name ${TEMPDIR}/interlace.png -composite ${TEMPDIR}/interlaced$(printf "%03d" $((i/2))).png
+    fi
+  fi
 done
 
-ffmpeg -r ${rate} -i ${TEMPDIR}/test%03d.jpg -r ${rate} -y test.mpg
+if [ -n "$interlaced" ] ; then
+  ffmpeg -r ${rate} -i ${TEMPDIR}/interlaced%03d.png -r ${rate} \
+    -vcodec mpeg2video -flags +ilme+ildct -y test.mpg
+else
+  ffmpeg -r ${rate} -i ${TEMPDIR}/test%03d.png -r ${rate} \
+    -vcodec mpeg2video -y test.mpg
+fi
 
 if [ -n "$remove_tempdir" ] ; then
   rm -Rf $TEMPDIR
-- 
cgit v0.12

