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.

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