scripts: Provide bin2png.sh helper
authorKieran Bingham <kieran.bingham@ideasonboard.com>
Thu, 1 Dec 2016 21:31:46 +0000 (21:31 +0000)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 13 Feb 2017 18:43:48 +0000 (20:43 +0200)
Identify the size and format from the test output filename, and pass
to raw2rgbpnm for conversion to a PNM file.

From there we can convert easily to a PNG output file.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
scripts/Makefile
scripts/bin2png.sh [new file with mode: 0755]

index 8c452f4..6586b29 100644 (file)
@@ -1,4 +1,4 @@
-SCRIPTS=logger.sh vsp-lib.sh
+SCRIPTS=$(wildcard *.sh)
 
 all:
 
 
 all:
 
diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
new file mode 100755 (executable)
index 0000000..88726aa
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+FILE="$1"
+
+PNM=${FILE/%bin/pnm}
+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|')
+
+case $fmt in
+       yuv*|yvu*)
+               fmt=$(echo $fmt | tr 'M' 'P')
+               ;;
+       nv*)
+               fmt=$(echo $fmt | tr -d 'M')
+               ;;
+       *rgb*)
+               fmt=$(echo $fmt | tr -d 'AX')
+               ;;
+esac
+
+raw2rgbpnm -s $size -f $fmt $FILE $PNM && \
+       convert $PNM $PNG
+rm $PNM