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.

520 lines
13KB

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