From 5aefcc76e9b8fbe6be38d109a4d4ac090b70daf6 Mon Sep 17 00:00:00 2001 From: Greg Frost Date: Sat, 24 Apr 2010 13:43:58 +0930 Subject: test-pattern: add aspect ratio support --- abs/core-testing/test-pattern/test_pattern.bash | 133 +++++++++++++----------- 1 file changed, 75 insertions(+), 58 deletions(-) diff --git a/abs/core-testing/test-pattern/test_pattern.bash b/abs/core-testing/test-pattern/test_pattern.bash index 6e7fff9..a68249a 100755 --- a/abs/core-testing/test-pattern/test_pattern.bash +++ b/abs/core-testing/test-pattern/test_pattern.bash @@ -8,8 +8,9 @@ rate=50 TEMPDIR= unset remove_tempdir interlaced= +aspect_ratio= -while getopts ":w:h:t:r:i" opt; do +while getopts ":w:h:t:r:ia:" opt; do case $opt in w) w=$OPTARG @@ -26,6 +27,9 @@ while getopts ":w:h:t:r:i" opt; do i) interlaced=TRUE ;; + a) + aspect_ratio=$OPTARG + ;; \?) echo -n"\ Error: Invalid option -$OPTARG @@ -41,11 +45,20 @@ Usage: -r framerate -i Generate an interlaced test pattern + -a n:m + Aspect ratio of generated video. " exit 1 esac done +if [ -z "$aspect_ratio" ] ; then + aspect_ratio="${w}:${h}" +fi + +aspectx=$(echo $aspect_ratio | cut -d: -f1) +aspecty=$(echo $aspect_ratio | cut -d: -f2) + # Calculate some dimensions based on the requested size. barw=$((w/32)) @@ -54,14 +67,18 @@ barstart=$((-barw/barstep-1)) frames=$((w/2)) -unit=$((h*2/27)) -gridlw=$((unit*3/43)) +unity=$((h*2/27)) +unitx=$((unity*aspecty*w/(aspectx*h))) +gridlw=$((unity*3/43)) + +echo unity=$unity +echo unitx=$unitx -nvgrid=$(((h-gridlw)/unit)) -nhgrid=$(((((w-gridlw)/unit)-1)/2*2+1)) +nvgrid=$(((h-gridlw)/unity)) +nhgrid=$(((((w-gridlw)/unitx)-1)/2*2+1)) -gridstartx=$((w/2-(nhgrid*unit+gridlw)/2-1)) -gridstarty=$((h/2-(nvgrid*unit+gridlw)/2-1)) +gridstartx=$((w/2-(nhgrid*unitx+gridlw)/2-1)) +gridstarty=$((h/2-(nvgrid*unity+gridlw)/2-1)) echo nvgrid=$nvgrid echo nhgrid=$nhgrid @@ -86,88 +103,88 @@ checker=( -fill "rgb(192,192,192)" ) for ((g=-9;g<=7;g=g+2)) ; do checker=( "${checker[@]}" -draw - "rectangle $((w/2+g*unit*7/10)),$((gridstarty+unit*3+gridlw)) $((w/2+(g+1)*unit*7/10)),$((gridstarty+unit*4+gridlw))" ) + "rectangle $((w/2+g*unitx*7/10)),$((gridstarty+unity*3+gridlw)) $((w/2+(g+1)*unitx*7/10)),$((gridstarty+unity*4+gridlw))" ) done checker=( "${checker[@]}" -fill black ) for ((g=-8;g<=8;g=g+2)) ; do checker=( "${checker[@]}" -draw - "rectangle $((w/2+g*unit*7/10)),$((gridstarty+unit*3+gridlw)) $((w/2+(g+1)*unit*7/10)),$((gridstarty+unit*4+gridlw))" ) + "rectangle $((w/2+g*unitx*7/10)),$((gridstarty+unity*3+gridlw)) $((w/2+(g+1)*unitx*7/10)),$((gridstarty+unity*4+gridlw))" ) done unset stripe stripe=( -fill white ) for ((g=0;g<5;g++)) ; do - startx=$((w/2+(3-g*2)*unit)) - endx=$((startx+2*unit)) + startx=$((w/2+(3-g*2)*unitx)) + endx=$((startx+2*unitx)) for ((x=startx;x