forked from cisco/thor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
executable file
·85 lines (69 loc) · 1.96 KB
/
check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
CONFIG=$1
FRAMES=$2
VALGRIND=$3
FILES=$4
VALGRIND_PREFIX="valgrind --leak-check=full --max-stackframe=5000000 --error-exitcode=123";
if [[ $VALGRIND == 0 ]]; then
VALGRIND_PREFIX=""
fi
if [ -z $FRAMES ]; then
FRAMES=3
fi
W=( 1920 1280 640 640 )
H=( 1080 720 480 360 )
if [ -z $FILES ]; then #generate some random files
TEST_FILES=()
for idx in $(seq 0 $((${#W[@]}-1))); do
w=${W[$idx]}
h=${H[$idx]}
YUV_FILE_SIZE=$((${w}*${h}*${FRAMES}*3/2))
FILE=rnd_test_tmp_${w}x${h}_30.yuv
head --bytes ${YUV_FILE_SIZE} </dev/urandom > ${FILE} #generate random file
TEST_FILES+=(${FILE})
done
SRCH="rnd_test_tmp*.yuv"
PTH="."
else
if [[ $FILES == *".yuv" ]]; then
SRCH=$(basename "${FILES}")
PTH=$(dirname "${FILES}")
else
SRCH="*.yuv"
PTH=$FILES
fi
fi
find ${PTH} -iname "${SRCH}" | while read f
do
wh=$(echo ${f} | rev | cut -d'_' -f2 | rev)
rc=$(echo ${f} | rev | cut -d'_' -f1 | rev)
rc=$(echo ${rc}| cut -d'.' -f1)
w=$(echo ${wh} | cut -d'x' -f1)
h=$(echo ${wh} | cut -d'x' -f2)
echo $w $h $rc $f $FRAMES
${VALGRIND_PREFIX} ./build/Thorenc \
-cf ${CONFIG} -width ${w} -height ${h} -if ${f} \
-of str_tmp.bit -rf rec_tmp.yuv -n ${FRAMES}
if [ $? != 0 ]; then
echo "Encoder error detected"
exit
fi
${VALGRIND_PREFIX} ./build/Thordec str_tmp.bit out_tmp.yuv
if [ $? != 0 ]; then
echo "Decoder error detected"
exit
fi
cmpout=$(cmp out_tmp.yuv rec_tmp.yuv) #mismatch checking
if [ $? != 0 ]; then
FRAME_SIZE=$((${w}*${h}*3/2))
ATBYTE=$(echo ${cmpout} | grep -o -E '[0-9]+' | head -1)
mth=$(expr $ATBYTE / $FRAME_SIZE + 1)
echo "Encoder/Decoder mismatch detected. Frame nr.:" ${mth}
exit
fi
done
#cleanup
rm str_tmp.bit;rm rec_tmp.yuv;rm out_tmp.yuv
if [ -z $FILES ]; then
rm ${TEST_FILES[@]}
fi