You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

397 lines
9.7KB

  1. #!/bin/sh
  2. #
  3. # automatic regression test for ffmpeg
  4. #
  5. #
  6. #set -x
  7. # Even in the 21st century some diffs are not supporting -u.
  8. diff -u $0 $0 > /dev/null 2>&1
  9. if [ $? -eq 0 ]; then
  10. diff_cmd="diff -u"
  11. else
  12. diff_cmd="diff"
  13. fi
  14. set -e
  15. datadir="./data"
  16. logfile="$datadir/ffmpeg.regression"
  17. # tests to do
  18. if [ "$1" = "mpeg4" ] ; then
  19. do_mpeg4=y
  20. elif [ "$1" = "mpeg" ] ; then
  21. do_mpeg=y
  22. elif [ "$1" = "ac3" ] ; then
  23. do_ac3=y
  24. elif [ "$1" = "libavtest" ] ; then
  25. do_libav=y
  26. logfile="$datadir/libav.regression"
  27. else
  28. do_mpeg=y
  29. do_msmpeg4v2=y
  30. do_msmpeg4=y
  31. do_wmv1=y
  32. do_wmv2=y
  33. do_h263=y
  34. do_h263p=y
  35. do_mpeg4=y
  36. do_huffyuv=y
  37. do_mjpeg=y
  38. do_rv10=y
  39. do_mp2=y
  40. do_ac3=y
  41. do_rc=y
  42. do_mpeg4adv=y
  43. do_mpeg1b=y
  44. fi
  45. # various files
  46. ffmpeg="../ffmpeg_g"
  47. tiny_psnr="./tiny_psnr"
  48. outfile="$datadir/a-"
  49. reffile="$2"
  50. benchfile="$datadir/ffmpeg.bench"
  51. raw_src="$3/%d.pgm"
  52. raw_dst="$datadir/out.yuv"
  53. raw_ref="$datadir/ref.yuv"
  54. pcm_src="asynth1.sw"
  55. pcm_dst="$datadir/out.wav"
  56. # create the data directory if it does not exists
  57. mkdir -p $datadir
  58. do_ffmpeg()
  59. {
  60. f="$1"
  61. shift
  62. echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
  63. $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
  64. egrep -v "^(Stream|Press|Input|Output|frame| Stream)" /tmp/ffmpeg$$ || true
  65. rm -f /tmp/ffmpeg$$
  66. md5sum -b $f >> $logfile
  67. if [ $f = $raw_dst ] ; then
  68. $tiny_psnr $f $raw_ref >> $logfile
  69. fi
  70. expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
  71. echo `cat $datadir/bench2.tmp` $f >> $benchfile
  72. }
  73. do_ffmpeg_crc()
  74. {
  75. f="$1"
  76. shift
  77. echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  78. $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  79. echo -n "$f " >> $logfile
  80. cat $datadir/ffmpeg.crc >> $logfile
  81. }
  82. do_ffmpeg_nocheck()
  83. {
  84. f="$1"
  85. shift
  86. echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
  87. $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp
  88. expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
  89. echo `cat $datadir/bench2.tmp` $f >> $benchfile
  90. }
  91. echo "ffmpeg regression test" > $logfile
  92. echo "ffmpeg benchmarks" > $benchfile
  93. ###################################
  94. # generate reference for quality check
  95. do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
  96. ###################################
  97. if [ -n "$do_mpeg" ] ; then
  98. # mpeg1 encoding
  99. file=${outfile}mpeg1.mpg
  100. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
  101. # mpeg1 decoding
  102. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  103. # mpeg2 decoding
  104. #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
  105. # -f rawvideo /tmp/out-mpeg2.yuv
  106. fi
  107. ###################################
  108. if [ -n "$do_msmpeg4v2" ] ; then
  109. # msmpeg4 encoding
  110. file=${outfile}msmpeg4v2.avi
  111. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
  112. # msmpeg4v2 decoding
  113. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  114. fi
  115. ###################################
  116. if [ -n "$do_msmpeg4" ] ; then
  117. # msmpeg4 encoding
  118. file=${outfile}msmpeg4.avi
  119. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
  120. # msmpeg4 decoding
  121. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  122. fi
  123. ###################################
  124. if [ -n "$do_wmv1" ] ; then
  125. # wmv1 encoding
  126. file=${outfile}wmv1.avi
  127. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
  128. # wmv1 decoding
  129. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  130. fi
  131. ###################################
  132. if [ -n "$do_wmv2" ] ; then
  133. # wmv2 encoding
  134. file=${outfile}wmv2.avi
  135. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
  136. # wmv2 decoding
  137. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  138. fi
  139. ###################################
  140. if [ -n "$do_h263" ] ; then
  141. # h263 encoding
  142. file=${outfile}h263.avi
  143. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
  144. # h263 decoding
  145. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  146. fi
  147. ###################################
  148. if [ -n "$do_h263p" ] ; then
  149. # h263p encoding
  150. file=${outfile}h263p.avi
  151. do_ffmpeg $file -y -qscale 2 -umv -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
  152. # h263p decoding
  153. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  154. fi
  155. ###################################
  156. if [ -n "$do_mpeg4" ] ; then
  157. # mpeg4
  158. file=${outfile}odivx.avi
  159. do_ffmpeg $file -y -4mv -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  160. # mpeg4 decoding
  161. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  162. fi
  163. ###################################
  164. if [ -n "$do_huffyuv" ] ; then
  165. # huffyuv
  166. file=${outfile}huffyuv.avi
  167. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
  168. # huffyuv decoding
  169. do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
  170. fi
  171. ###################################
  172. if [ -n "$do_rc" ] ; then
  173. # mpeg4 rate control
  174. file=${outfile}mpeg4-rc.avi
  175. do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  176. # mpeg4 rate control decoding
  177. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  178. fi
  179. ###################################
  180. if [ -n "$do_mpeg4adv" ] ; then
  181. # mpeg4
  182. file=${outfile}mpeg4-adv.avi
  183. do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  184. # mpeg4 decoding
  185. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  186. fi
  187. ###################################
  188. if [ -n "$do_mpeg1b" ] ; then
  189. # mpeg1
  190. file=${outfile}mpeg1b.mpg
  191. do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video $file
  192. # mpeg1 decoding
  193. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  194. fi
  195. ###################################
  196. if [ -n "$do_mjpeg" ] ; then
  197. # mjpeg
  198. file=${outfile}mjpeg.avi
  199. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
  200. # mjpeg decoding
  201. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  202. fi
  203. ###################################
  204. if [ -n "$do_rv10" ] ; then
  205. # rv10 encoding
  206. file=${outfile}rv10.rm
  207. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
  208. # rv10 decoding
  209. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  210. fi
  211. ###################################
  212. if [ -n "$do_mp2" ] ; then
  213. # mp2 encoding
  214. file=${outfile}mp2.mp2
  215. do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
  216. # mp2 decoding
  217. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  218. fi
  219. ###################################
  220. if [ -n "$do_ac3" ] ; then
  221. # ac3 encoding
  222. file=${outfile}ac3.rm
  223. do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
  224. # ac3 decoding
  225. #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  226. fi
  227. ###################################
  228. # libav testing
  229. ###################################
  230. if [ -n "$do_libav" ] ; then
  231. # avi
  232. file=${outfile}libav.avi
  233. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  234. do_ffmpeg_crc $file -i $file
  235. # asf
  236. file=${outfile}libav.asf
  237. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  238. do_ffmpeg_crc $file -i $file
  239. # rm
  240. file=${outfile}libav.rm
  241. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  242. # broken
  243. #do_ffmpeg_crc $file -i $file
  244. # mpegps
  245. file=${outfile}libav.mpg
  246. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  247. do_ffmpeg_crc $file -i $file
  248. # swf (decode audio only)
  249. file=${outfile}libav.swf
  250. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  251. do_ffmpeg_crc $file -i $file
  252. # ffm
  253. file=${outfile}libav.ffm
  254. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  255. do_ffmpeg_crc $file -i $file
  256. # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
  257. ####################
  258. # streamed images
  259. # mjpeg
  260. file=${outfile}libav.mjpeg
  261. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  262. do_ffmpeg_crc $file -i $file
  263. # pbmpipe
  264. file=${outfile}libav.pbm
  265. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  266. do_ffmpeg_crc $file -f imagepipe -i $file
  267. # pgmpipe
  268. file=${outfile}libav.pgm
  269. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  270. do_ffmpeg_crc $file -f imagepipe -i $file
  271. # ppmpipe
  272. file=${outfile}libav.ppm
  273. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  274. do_ffmpeg_crc $file -f imagepipe -i $file
  275. # gif
  276. file=${outfile}libav.gif
  277. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  278. #do_ffmpeg_crc $file -i $file
  279. # yuv4mpeg
  280. file=${outfile}libav.yuv4mpeg
  281. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  282. #do_ffmpeg_crc $file -i $file
  283. ####################
  284. # image formats
  285. # pgm (we do not do md5 on image files yet)
  286. file=${outfile}libav%d.pgm
  287. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  288. do_ffmpeg_crc $file -i $file
  289. # ppm (we do not do md5 on image files yet)
  290. file=${outfile}libav%d.ppm
  291. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  292. do_ffmpeg_crc $file -i $file
  293. # jpeg (we do not do md5 on image files yet)
  294. file=${outfile}libav%d.jpg
  295. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  296. do_ffmpeg_crc $file -i $file
  297. ####################
  298. # audio only
  299. # wav
  300. file=${outfile}libav.wav
  301. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  302. do_ffmpeg_crc $file -i $file
  303. # alaw
  304. file=${outfile}libav.al
  305. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  306. do_ffmpeg_crc $file -i $file
  307. # mulaw
  308. file=${outfile}libav.ul
  309. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  310. do_ffmpeg_crc $file -i $file
  311. # au
  312. file=${outfile}libav.au
  313. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  314. do_ffmpeg_crc $file -i $file
  315. fi
  316. if $diff_cmd $logfile $reffile ; then
  317. echo
  318. echo Regression test succeeded.
  319. exit 0
  320. else
  321. echo
  322. echo Regression test: Error.
  323. exit 1
  324. fi