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.

387 lines
9.4KB

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