From f5d0d12e734d4af0b4a4ed477c7de63d2b3bb9b0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 16 Jul 2011 13:09:49 +0200 Subject: [PATCH] fix PSNR calc --- misc/tools/cached-converter.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/misc/tools/cached-converter.sh b/misc/tools/cached-converter.sh index f1e535e6..8ce189c4 100755 --- a/misc/tools/cached-converter.sh +++ b/misc/tools/cached-converter.sh @@ -150,9 +150,16 @@ pickdxta() pd_i=$1; shift pd_o=$1; shift for pd_dd in $pd_d; do - if [ -f "$pd_o".dds ]; then + if [ -f "$pd_o" ]; then "$meprefix"compress-texture "$pd_t" "$pd_dd" "$pd_i" "$pd_o".tmp.dds "$@" - pd_psnr_tmp=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o".tmp.dds NULL:` + pd_psnr_tmp=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o".tmp.dds NULL: 2>&1` + case "$pd_psnr_tmp" in + [0-9.]*) + ;; + *) + pd_psnr_tmp=999.9 + ;; + esac echo >&2 "$pd_dd: $pd_psnr_tmp dB" pd_psnr_diff=`echo "($pd_psnr_tmp) - ($pd_psnr)" | bc -l` case "$pd_psnr_diff" in @@ -171,7 +178,14 @@ pickdxta() esac else "$meprefix"compress-texture "$pd_t" "$pd_dd" "$pd_i" "$pd_o" "$@" - pd_psnr=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o" NULL:` + pd_psnr=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o" NULL: 2>&1` + case "$pd_psnr" in + [0-9.]*) + ;; + *) + pd_psnr=999.9 + ;; + esac echo >&2 "$pd_dd: $pd_psnr dB" echo >&2 "PICKED (first)" fi -- 2.39.2