summaryrefslogtreecommitdiffstats
path: root/TOOLS/psnr-video.sh
diff options
context:
space:
mode:
authorgpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-09-13 11:38:39 +0000
committergpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-09-13 11:38:39 +0000
commit7a7bfba6ed98299c66755e52e7efb677848aae73 (patch)
tree2a375cea2f3d2dab78a929c14b9d99c66d73107c /TOOLS/psnr-video.sh
parentecea454c23a742ce3fc2c953d4f28c5a7dc868a4 (diff)
downloadmpv-7a7bfba6ed98299c66755e52e7efb677848aae73.tar.bz2
mpv-7a7bfba6ed98299c66755e52e7efb677848aae73.tar.xz
Nits suggested by Diego
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16474 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS/psnr-video.sh')
-rwxr-xr-xTOOLS/psnr-video.sh58
1 files changed, 29 insertions, 29 deletions
diff --git a/TOOLS/psnr-video.sh b/TOOLS/psnr-video.sh
index 1fdc8c106e..4e715d2b3b 100755
--- a/TOOLS/psnr-video.sh
+++ b/TOOLS/psnr-video.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-# Helper script to ease comparing two video files
-# Copyleft 2001 by Matthias Wieser
+# Helper script to ease comparing the PSNR between two video files
+# Copyleft 2005 by Matthias Wieser
# This file comes under GPL, see http://www.gnu.org/copyleft/gpl.html for more
-# information on it's licensing.
+# information on its licensing.
TEMPDIR="/tmp/psnr_video"
WORKDIR=`pwd`/
@@ -10,12 +10,12 @@ if [ $# -le 1 ]; then
echo
echo "Usage: `basename $0` <file1> <file2> [<frames>] [<options1>] [<options2>]"
echo
- echo " <file1> and <file2> are the video files for which the PSNR should be calculated."
+ echo " <file1> and <file2> are the files for which the PSNR should be calculated."
echo " [<frames>] is the number of frames to process, starting from frame 1."
- echo " [<options1>] are additional MPlayer options for <file1>"
- echo " [<options2>] are additional MPlayer options for <file2>"
+ echo " [<options1>] are additional MPlayer options for <file1>."
+ echo " [<options2>] are additional MPlayer options for <file2>."
echo
- echo " Be aware that `basename $0` needs a lot of temporal space inside /temp/."
+ echo " Be aware that `basename $0` needs a lot of temporary space inside /tmp/."
echo
echo "Example:"
echo " ./`basename $0` ./orig.avi ./test.avi 250 \"\" \"-vf pp=ac\""
@@ -31,17 +31,17 @@ LastFrame=-1
if [ $# -ge 3 ]; then
LastFrame=$3
echo
- echo "Will process $LastFrame frames"
+ echo "Will process $LastFrame frames."
fi
if [ $# -ge 4 ]; then
- FILE1Opts=$4
- echo "Mplayer options for ${FILE1}: $FILE1Opts"
+ FILE1_Options=$4
+ echo "MPlayer options for ${FILE1}: $FILE1_Options"
fi
if [ $# -ge 5 ]; then
- FILE2Opts=$5
- echo "Mplayer options for ${FILE2}: $FILE2Opts"
+ FILE2_Options=$5
+ echo "Mplayer options for ${FILE2}: $FILE2_Options"
fi
mkdir -p ${TEMPDIR}/FILE1
@@ -53,13 +53,13 @@ echo "############## $FILE1 #################"
cd ${TEMPDIR}/FILE1
-rm *ppm 2> /dev/null
-rm *del 2> /dev/null
+rm -f *ppm
+rm -f *del
if [ $LastFrame -ge 0 ]; then
- mplayer $FILE1Opts -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE1 >/dev/null
+ mplayer $FILE1_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE1 >/dev/null
else
- mplayer $FILE1Opts -nosound -vo pnm ${WORKDIR}$FILE1 >/dev/null
+ mplayer $FILE1_Options -nosound -vo pnm ${WORKDIR}$FILE1 > /dev/null
fi
### File 2
@@ -71,25 +71,25 @@ cd ${TEMPDIR}/FILE2
rm *ppm 2> /dev/null
if [ $LastFrame -ge 0 ]; then
- mplayer $FILE2Opts -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null
+ mplayer $FILE2_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null
else
- mplayer $FILE2Opts -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null
+ mplayer $FILE2_Options -nosound -vo pnm ${WORKDIR}$FILE2 >/dev/null
fi
### PSNR
echo
-echo "############## Calculation PSNR #################"
+echo "############## PSNR Calculation #################"
-if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm|wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` ]]
+if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
then
echo
else
echo "Files have differing numbers of frames!"
- echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm|wc -l` frames,"
- echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` frames."
- echo "Processing the first `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` frames."
+ echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames,"
+ echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
+ echo "Processing the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
echo
fi
@@ -118,7 +118,7 @@ for FILE in `ls -1 *.ppm`
echo "$ALL">>../psnr.dat
ERROR=`echo "scale=30; (e(-1*$Y/10*l(10))+e(-1*$CB/10*l(10))/4+e(-1*$CR/10*l(10))/4)/1.5"|bc -l`
ERRORSUM=`cat errorsum.del`
- echo `echo "scale=30; $ERROR + $ERRORSUM"|bc -l` > errorsum.del
+ echo `echo "scale=30; $ERROR + $ERRORSUM" | bc -l` > errorsum.del
i=$(($i+1))
if [[ $i = $LastFrame ]]
then
@@ -126,19 +126,19 @@ for FILE in `ls -1 *.ppm`
fi
done
ERRORSUM=`cat errorsum.del`
-PSNR=`echo "-10*l($ERRORSUM/$i)/l(10)"|bc -l`
+PSNR=`echo "-10*l($ERRORSUM/$i)/l(10)" | bc -l`
echo "PSNR:;$PSNR">>../psnr.dat
cd ..
mv psnr.dat ${WORKDIR}
-if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm|wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` ]]
+if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
then
echo
else
echo "Files have differing numbers of frames!"
- echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm|wc -l` frames,"
- echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` frames."
- echo "Processed the first `ls -1 ${TEMPDIR}/FILE2/*ppm|wc -l` frames."
+ echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames,"
+ echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
+ echo "Processed the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
echo
fi