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.

491 lines
12KB

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