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.

413 lines
11KB

  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 -y -bitexact -dct_algo 1 -idct_algo 2 $*
  63. $ffmpeg -y -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 > /tmp/ffmpeg$$ 2>&1
  79. egrep -v "^(Stream|Press|Input|Output|frame| Stream)" /tmp/ffmpeg$$ || true
  80. rm -f /tmp/ffmpeg$$
  81. echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
  82. }
  83. do_ffmpeg_nocheck()
  84. {
  85. f="$1"
  86. shift
  87. echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
  88. $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
  89. egrep -v "^(Stream|Press|Input|Output|frame| Stream)" /tmp/ffmpeg$$ || true
  90. rm -f /tmp/ffmpeg$$
  91. expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
  92. echo `cat $datadir/bench2.tmp` $f >> $benchfile
  93. }
  94. echo "ffmpeg regression test" > $logfile
  95. echo "ffmpeg benchmarks" > $benchfile
  96. ###################################
  97. # generate reference for quality check
  98. do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
  99. ###################################
  100. if [ -n "$do_mpeg" ] ; then
  101. # mpeg1 encoding
  102. file=${outfile}mpeg1.mpg
  103. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
  104. # mpeg1 decoding
  105. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  106. # mpeg2 decoding
  107. #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
  108. # -f rawvideo /tmp/out-mpeg2.yuv
  109. fi
  110. ###################################
  111. if [ -n "$do_msmpeg4v2" ] ; then
  112. # msmpeg4 encoding
  113. file=${outfile}msmpeg4v2.avi
  114. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
  115. # msmpeg4v2 decoding
  116. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  117. fi
  118. ###################################
  119. if [ -n "$do_msmpeg4" ] ; then
  120. # msmpeg4 encoding
  121. file=${outfile}msmpeg4.avi
  122. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
  123. # msmpeg4 decoding
  124. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  125. fi
  126. ###################################
  127. if [ -n "$do_wmv1" ] ; then
  128. # wmv1 encoding
  129. file=${outfile}wmv1.avi
  130. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
  131. # wmv1 decoding
  132. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  133. fi
  134. ###################################
  135. if [ -n "$do_wmv2" ] ; then
  136. # wmv2 encoding
  137. file=${outfile}wmv2.avi
  138. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
  139. # wmv2 decoding
  140. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  141. fi
  142. ###################################
  143. if [ -n "$do_h263" ] ; then
  144. # h263 encoding
  145. file=${outfile}h263.avi
  146. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
  147. # h263 decoding
  148. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  149. fi
  150. ###################################
  151. if [ -n "$do_h263p" ] ; then
  152. # h263p encoding
  153. file=${outfile}h263p.avi
  154. do_ffmpeg $file -y -qscale 2 -umv -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
  155. # h263p decoding
  156. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  157. fi
  158. ###################################
  159. if [ -n "$do_mpeg4" ] ; then
  160. # mpeg4
  161. file=${outfile}odivx.avi
  162. do_ffmpeg $file -y -4mv -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  163. # mpeg4 decoding
  164. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  165. fi
  166. ###################################
  167. if [ -n "$do_huffyuv" ] ; then
  168. # huffyuv
  169. file=${outfile}huffyuv.avi
  170. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
  171. # huffyuv decoding
  172. do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
  173. fi
  174. ###################################
  175. if [ -n "$do_rc" ] ; then
  176. # mpeg4 rate control
  177. file=${outfile}mpeg4-rc.avi
  178. do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  179. # mpeg4 rate control decoding
  180. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  181. fi
  182. ###################################
  183. if [ -n "$do_mpeg4adv" ] ; then
  184. # mpeg4
  185. file=${outfile}mpeg4-adv.avi
  186. do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  187. # mpeg4 decoding
  188. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  189. fi
  190. ###################################
  191. if [ -n "$do_mpeg1b" ] ; then
  192. # mpeg1
  193. file=${outfile}mpeg1b.mpg
  194. do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video $file
  195. # mpeg1 decoding
  196. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  197. fi
  198. ###################################
  199. if [ -n "$do_mjpeg" ] ; then
  200. # mjpeg
  201. file=${outfile}mjpeg.avi
  202. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
  203. # mjpeg decoding
  204. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  205. fi
  206. ###################################
  207. if [ -n "$do_rv10" ] ; then
  208. # rv10 encoding
  209. file=${outfile}rv10.rm
  210. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
  211. # rv10 decoding
  212. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  213. fi
  214. ###################################
  215. if [ -n "$do_mp2" ] ; then
  216. # mp2 encoding
  217. file=${outfile}mp2.mp2
  218. do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
  219. # mp2 decoding
  220. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  221. fi
  222. ###################################
  223. if [ -n "$do_ac3" ] ; then
  224. # ac3 encoding
  225. file=${outfile}ac3.rm
  226. do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
  227. # ac3 decoding
  228. #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  229. fi
  230. ###################################
  231. # libav testing
  232. ###################################
  233. if [ -n "$do_libav" ] ; then
  234. # avi
  235. file=${outfile}libav.avi
  236. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  237. do_ffmpeg_crc $file -i $file
  238. # asf
  239. file=${outfile}libav.asf
  240. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  241. do_ffmpeg_crc $file -i $file
  242. # rm
  243. file=${outfile}libav.rm
  244. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  245. # broken
  246. #do_ffmpeg_crc $file -i $file
  247. # mpegps
  248. file=${outfile}libav.mpg
  249. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  250. do_ffmpeg_crc $file -i $file
  251. # swf (decode audio only)
  252. file=${outfile}libav.swf
  253. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  254. do_ffmpeg_crc $file -i $file
  255. # ffm
  256. file=${outfile}libav.ffm
  257. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  258. do_ffmpeg_crc $file -i $file
  259. # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
  260. ####################
  261. # streamed images
  262. # mjpeg
  263. #file=${outfile}libav.mjpeg
  264. #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  265. #do_ffmpeg_crc $file -i $file
  266. # pbmpipe
  267. file=${outfile}libav.pbm
  268. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  269. do_ffmpeg_crc $file -f imagepipe -i $file
  270. # pgmpipe
  271. file=${outfile}libav.pgm
  272. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  273. do_ffmpeg_crc $file -f imagepipe -i $file
  274. # ppmpipe
  275. file=${outfile}libav.ppm
  276. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  277. do_ffmpeg_crc $file -f imagepipe -i $file
  278. # gif
  279. file=${outfile}libav.gif
  280. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  281. #do_ffmpeg_crc $file -i $file
  282. # yuv4mpeg
  283. file=${outfile}libav.yuv4mpeg
  284. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  285. #do_ffmpeg_crc $file -i $file
  286. ####################
  287. # image formats
  288. # pgm (we do not do md5 on image files yet)
  289. file=${outfile}libav%d.pgm
  290. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  291. do_ffmpeg_crc $file -i $file
  292. # ppm (we do not do md5 on image files yet)
  293. file=${outfile}libav%d.ppm
  294. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  295. do_ffmpeg_crc $file -i $file
  296. # jpeg (we do not do md5 on image files yet)
  297. #file=${outfile}libav%d.jpg
  298. #$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  299. #do_ffmpeg_crc $file -i $file
  300. ####################
  301. # audio only
  302. # wav
  303. file=${outfile}libav.wav
  304. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  305. do_ffmpeg_crc $file -i $file
  306. # alaw
  307. file=${outfile}libav.al
  308. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  309. do_ffmpeg_crc $file -i $file
  310. # mulaw
  311. file=${outfile}libav.ul
  312. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  313. do_ffmpeg_crc $file -i $file
  314. # au
  315. file=${outfile}libav.au
  316. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  317. do_ffmpeg_crc $file -i $file
  318. ####################
  319. # pix_fmt conversions
  320. conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
  321. yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
  322. monob pal8"
  323. for pix_fmt in $conversions ; do
  324. file=${outfile}libav-${pix_fmt}.yuv
  325. do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
  326. -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
  327. do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
  328. -f rawvideo -s 352x288 -pix_fmt yuv444p $file
  329. done
  330. fi
  331. if $diff_cmd $logfile $reffile ; then
  332. echo
  333. echo Regression test succeeded.
  334. exit 0
  335. else
  336. echo
  337. echo Regression test: Error.
  338. exit 1
  339. fi