summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-02-13 16:14:05 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-02-13 20:43:48 +0200
commitd29ee6719d717f51e4063f96b6aebf7d90ba6fd0 (patch)
treeac2861ef061ef2f0f3a46b479decf770d67f3510 /scripts
parent9e023de20265fc4211f3b34d45c5dfc9f526de3f (diff)
scripts: bin2png: Support conversion of all files in a directory
When the first argument is a directory name instead of a file name, convert all test script output binaries in that directory. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bin2png.sh47
1 files changed, 31 insertions, 16 deletions
diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
index 88726aa..090f31f 100755
--- a/scripts/bin2png.sh
+++ b/scripts/bin2png.sh
@@ -1,25 +1,40 @@
#!/bin/sh
-FILE="$1"
+FILE=${1:-.}
-PNM=${FILE/%bin/pnm}
-PNG=${FILE/%bin/png}
+convert_image() {
+ local file=$1
+ local pnm=${file/%bin/pnm}
+ local png=${file/%bin/png}
-fmt=$(echo $FILE | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\1|' | tr '[:lower:]' '[:upper:]')
-size=$(echo $FILE | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\2|')
+ local format=$(echo $file | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\1|' | tr '[:lower:]' '[:upper:]')
+ local size=$(echo $file | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\2|')
-case $fmt in
- yuv*|yvu*)
- fmt=$(echo $fmt | tr 'M' 'P')
+ case $format in
+ YUV*|YVU*)
+ format=$(echo $format | tr 'M' 'P')
;;
- nv*)
- fmt=$(echo $fmt | tr -d 'M')
+ NV*)
+ format=$(echo $format | tr -d 'M')
;;
- *rgb*)
- fmt=$(echo $fmt | tr -d 'AX')
+ *RGB*)
+ format=$(echo $format | tr -d 'AX')
;;
-esac
+ esac
-raw2rgbpnm -s $size -f $fmt $FILE $PNM && \
- convert $PNM $PNG
-rm $PNM
+ raw2rgbpnm -f $format -s $size $file $pnm && \
+ convert $pnm $png
+ rm $pnm
+}
+
+if [ -d $FILE ] ; then
+ if [ $(ls $FILE/vsp-unit-test-00*-*frame*.bin 2>/dev/null | wc -l) != 0 ] ; then
+ for f in $FILE/vsp-unit-test-00*-*frame*.bin ; do
+ convert_image $f
+ done
+ fi
+elif [ -f $FILE ] ; then
+ convert_image $FILE
+else
+ echo "Usage: $0 <file or directory>"
+fi