annotate TOOLS/psnr-video.sh @ 27839:9a46fffef0fc

vobsub: add sanity check
author aurel
date Sat, 01 Nov 2008 13:51:39 +0000
parents abd0a4e9daa0
children 32725ca88fed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27199
abd0a4e9daa0 Run bash-specific shell scripts with bash, not sh.
diego
parents: 16657
diff changeset
1 #!/bin/bash
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
2 # Helper script to ease comparing the PSNR between two video files
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
3 # Copyleft 2005 by Matthias Wieser
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
4 # Copyleft 2005 by Ivo
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
5 # This file comes under GPL, see http://www.gnu.org/copyleft/gpl.html for more
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
6 # information on its licensing.
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
7
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
8 warning_frame_number () {
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
9 echo "Files have differing numbers of frames!"
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
10 echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames,"
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
11 echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
12 echo "Processing the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
13 }
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
14
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
15
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
16 TEMPDIR="/tmp/psnr_video"
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
17 WORKDIR=`pwd`
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
18 OUTFILE=psnr.dat
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
19 ERRFILE=errorsum.del
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
20
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
21 exit=0
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
22 if [[ `which pnmpsnr 2> /dev/null` = "" ]]
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
23 then
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
24 echo
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
25 echo "To use this script you have to install the program \"pnmpsnr\" which is"
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
26 echo " included in the netpbm package."
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
27 echo
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
28 exit=1
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
29 fi
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
30
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
31 if [[ `which bc 2> /dev/null` = "" ]]
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
32 then
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
33 echo
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
34 echo "To use this script you have to install the GNU command line calculator \"bc\"."
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
35 echo
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
36 exit=1
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
37 fi
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
38
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
39 if [ $# -le 1 ]; then
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
40 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
41 echo "Usage: `basename $0` <file1> <file2> [<frames>] [<options1>] [<options2>]"
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
42 echo
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
43 echo " <file1> and <file2> are the files for which the PSNR should be calculated."
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
44 echo " [<frames>] is the number of frames to process, starting from frame 1."
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
45 echo " [<options1>] are additional MPlayer options for <file1>."
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
46 echo " [<options2>] are additional MPlayer options for <file2>."
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
47 echo
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
48 echo " Be aware that `basename $0` needs a lot of temporary space inside /tmp/."
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
49 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
50 echo "Example:"
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
51 echo " ./`basename $0` ./orig.avi ./test.avi 250 \"\" \"-vf pp=ac\""
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
52 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
53
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
54 exit=1
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
55 fi
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
56
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
57 if [ "$exit" -eq 1 ]; then
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
58 exit 1
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
59 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
60
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
61 FILE1=$1
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
62 FILE2=$2
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
63
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
64 LastFrame=-1
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
65 if [ $# -ge 3 ]; then
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
66 LastFrame=$3
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
67 echo
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
68 echo "Will process $LastFrame frames."
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
69 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
70
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
71 if [ $# -ge 4 ]; then
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
72 FILE1_Options=$4
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
73 echo "MPlayer options for ${FILE1}: $FILE1_Options"
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
74 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
75
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
76 if [ $# -ge 5 ]; then
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
77 FILE2_Options=$5
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
78 echo "MPlayer options for ${FILE2}: $FILE2_Options"
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
79 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
80
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
81
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
82 mkdir -p ${TEMPDIR}/FILE1
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
83 mkdir -p ${TEMPDIR}/FILE2
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
84
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
85 ### File 1
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
86 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
87 echo "############## $FILE1 #################"
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
88
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
89 cd ${TEMPDIR}/FILE1
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
90
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
91 rm -f *ppm
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
92 rm -f *del
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
93
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
94 if [ $LastFrame -ge 0 ]; then
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
95 mplayer $FILE1_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}/$FILE1 > /dev/null
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
96 else
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
97 mplayer $FILE1_Options -nosound -vo pnm ${WORKDIR}/$FILE1 > /dev/null
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
98 fi
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
99
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
100 ### File 2
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
101 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
102 echo "############## $FILE2 #################"
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
103
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
104 cd ${TEMPDIR}/FILE2
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
105
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
106 rm -f *ppm
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
107
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
108 if [ $LastFrame -ge 0 ]; then
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
109 mplayer $FILE2_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}/$FILE2 > /dev/null
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
110 else
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
111 mplayer $FILE2_Options -nosound -vo pnm ${WORKDIR}/$FILE2 > /dev/null
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
112 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
113
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
114
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
115 ### PSNR
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
116
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
117 echo
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
118 echo "############## PSNR Calculation #################"
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
119
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
120 if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
121 then
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
122 echo
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
123 else
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
124 warning_frame_number
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
125 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
126 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
127
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
128
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
129 cd ${TEMPDIR}/FILE2
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
130 #rm ../$OUTFILE
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
131 echo "File;Y;Cb;Cr" > ../$OUTFILE
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
132 echo "0" > $ERRFILE
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
133 i=0
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
134 for FILE in `ls -1 *.ppm`
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
135 do
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
136 echo $FILE
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
137 echo -n "$FILE" >> ../$OUTFILE
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
138 echo -n ";" >> ../$OUTFILE
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
139
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
140 YCBCR=`pnmpsnr ../FILE1/$FILE $FILE 2>&1 | tail -n 3 | cut -f 3 -d ':' | \
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
141 ( read Y X; read CB X; read CR X; echo "$Y;$CB;$CR;")`
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
142 Y=`echo $YCBCR | cut -f 1 -d ';'`
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
143 CB=`echo $YCBCR | cut -f 2 -d ';'`
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
144 CR=`echo $YCBCR | cut -f 3 -d ';'`
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
145 echo $YCBCR >> ../$OUTFILE
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
146
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
147 ALL=`echo "(-10)*l((e(-$Y/10*l(10))+e(-$CB/10*l(10))/4+e(-$CR/10*l(10))/4)/1.5)/l(10)" | bc -l`
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
148 echo "$ALL" >> ../$OUTFILE
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
149 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`
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
150 ERRORSUM=`cat $ERRFILE`
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
151 echo `echo "scale=30; $ERROR + $ERRORSUM" | bc -l` > $ERRFILE
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
152
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
153 i=$(($i+1))
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
154 if [[ $i = $LastFrame ]]
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
155 then
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
156 break
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
157 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
158 done
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
159
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
160 ERRORSUM=`cat $ERRFILE`
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
161 PSNR=`echo "-10*l($ERRORSUM/$i)/l(10)" | bc -l`
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
162 echo "PSNR:;$PSNR" >> ../$OUTFILE
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
163
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
164 cd ..
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
165 mv $OUTFILE ${WORKDIR}/
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
166
16473
d9697b778be2 Nits suggested by Diego
gpoirier
parents: 16462
diff changeset
167 if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
168 then
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
169 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
170 else
16636
fca80748d11b Nits suggested by Ivo and Diego. Patch by Matthias Wieser < mwieser AH gmx POIS de >
gpoirier
parents: 16473
diff changeset
171 warning_frame_number
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
172 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
173 fi
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
174
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
175 cd ..
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
176 rm -r ${TEMPDIR}
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
177
16657
f2e90fc97a39 random improvements plus some readability cosmetics
diego
parents: 16636
diff changeset
178 echo "Created ${WORKDIR}/$OUTFILE"
16462
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
179 echo
fce59530dcfd Adds the script psnr-video.sh to calculate the PSNR between two existing video files.
gpoirier
parents:
diff changeset
180