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.

498 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_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.mpg
  118. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file
  119. # mpeg2 decoding
  120. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  121. # mpeg2 encoding interlaced
  122. file=${outfile}mpeg2i.mpg
  123. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -interlace $file
  124. # mpeg2 decoding
  125. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  126. fi
  127. ###################################
  128. if [ -n "$do_msmpeg4v2" ] ; then
  129. # msmpeg4 encoding
  130. file=${outfile}msmpeg4v2.avi
  131. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
  132. # msmpeg4v2 decoding
  133. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  134. fi
  135. ###################################
  136. if [ -n "$do_msmpeg4" ] ; then
  137. # msmpeg4 encoding
  138. file=${outfile}msmpeg4.avi
  139. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
  140. # msmpeg4 decoding
  141. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  142. fi
  143. ###################################
  144. if [ -n "$do_wmv1" ] ; then
  145. # wmv1 encoding
  146. file=${outfile}wmv1.avi
  147. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
  148. # wmv1 decoding
  149. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  150. fi
  151. ###################################
  152. if [ -n "$do_wmv2" ] ; then
  153. # wmv2 encoding
  154. file=${outfile}wmv2.avi
  155. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
  156. # wmv2 decoding
  157. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  158. fi
  159. ###################################
  160. if [ -n "$do_h263" ] ; then
  161. # h263 encoding
  162. file=${outfile}h263.avi
  163. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
  164. # h263 decoding
  165. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  166. fi
  167. ###################################
  168. if [ -n "$do_h263p" ] ; then
  169. # h263p encoding
  170. file=${outfile}h263p.avi
  171. do_ffmpeg $file -y -qscale 2 -umv -aiv -aic -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
  172. # h263p decoding
  173. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  174. fi
  175. ###################################
  176. if [ -n "$do_mpeg4" ] ; then
  177. # mpeg4
  178. file=${outfile}odivx.mp4
  179. do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  180. # mpeg4 decoding
  181. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  182. fi
  183. ###################################
  184. if [ -n "$do_huffyuv" ] ; then
  185. # huffyuv
  186. file=${outfile}huffyuv.avi
  187. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
  188. # huffyuv decoding
  189. do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
  190. fi
  191. ###################################
  192. if [ -n "$do_rc" ] ; then
  193. # mpeg4 rate control
  194. file=${outfile}mpeg4-rc.avi
  195. do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  196. # mpeg4 rate control decoding
  197. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  198. fi
  199. ###################################
  200. if [ -n "$do_mpeg4adv" ] ; then
  201. # mpeg4
  202. file=${outfile}mpeg4-adv.avi
  203. do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  204. # mpeg4 decoding
  205. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  206. fi
  207. ###################################
  208. if [ -n "$do_mpeg1b" ] ; then
  209. # mpeg1
  210. file=${outfile}mpeg1b.mpg
  211. do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video -f mpeg1video $file
  212. # mpeg1 decoding
  213. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  214. fi
  215. ###################################
  216. if [ -n "$do_mjpeg" ] ; then
  217. # mjpeg
  218. file=${outfile}mjpeg.avi
  219. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
  220. # mjpeg decoding
  221. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  222. fi
  223. ###################################
  224. if [ -n "$do_ljpeg" ] ; then
  225. # ljpeg
  226. file=${outfile}ljpeg.avi
  227. do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
  228. # ljpeg decoding
  229. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  230. fi
  231. ###################################
  232. if [ -n "$do_rv10" ] ; then
  233. # rv10 encoding
  234. file=${outfile}rv10.rm
  235. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
  236. # rv10 decoding
  237. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  238. fi
  239. ###################################
  240. if [ -n "$do_asv1" ] ; then
  241. # asv1 encoding
  242. file=${outfile}asv1.avi
  243. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
  244. # asv1 decoding
  245. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  246. fi
  247. ###################################
  248. if [ -n "$do_asv2" ] ; then
  249. # asv2 encoding
  250. file=${outfile}asv2.avi
  251. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
  252. # asv2 decoding
  253. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  254. fi
  255. ###################################
  256. if [ -n "$do_flv" ] ; then
  257. # flv encoding
  258. file=${outfile}flv.flv
  259. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
  260. # flv decoding
  261. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  262. fi
  263. ###################################
  264. if [ -n "$do_ffv1" ] ; then
  265. # ffv1 encoding
  266. file=${outfile}ffv1.avi
  267. do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
  268. # ffv1 decoding
  269. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  270. fi
  271. ###################################
  272. if [ -n "$do_mp2" ] ; then
  273. # mp2 encoding
  274. file=${outfile}mp2.mp2
  275. do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
  276. # mp2 decoding
  277. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  278. fi
  279. ###################################
  280. if [ -n "$do_ac3" ] ; then
  281. # ac3 encoding
  282. file=${outfile}ac3.rm
  283. do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
  284. # ac3 decoding
  285. #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  286. fi
  287. ###################################
  288. # libav testing
  289. ###################################
  290. if [ -n "$do_libav" ] ; then
  291. # avi
  292. file=${outfile}libav.avi
  293. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  294. do_ffmpeg_crc $file -i $file
  295. # asf
  296. file=${outfile}libav.asf
  297. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  298. do_ffmpeg_crc $file -i $file
  299. # rm
  300. file=${outfile}libav.rm
  301. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  302. # broken
  303. #do_ffmpeg_crc $file -i $file
  304. # mpegps
  305. file=${outfile}libav.mpg
  306. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  307. do_ffmpeg_crc $file -i $file
  308. # swf (decode audio only)
  309. file=${outfile}libav.swf
  310. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  311. do_ffmpeg_crc $file -i $file
  312. # ffm
  313. file=${outfile}libav.ffm
  314. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  315. do_ffmpeg_crc $file -i $file
  316. # flv
  317. file=${outfile}libav.flv
  318. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  319. do_ffmpeg_crc $file -i $file
  320. # mov
  321. #file=${outfile}libav.mov
  322. #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  323. #do_ffmpeg_crc $file -i $file
  324. # nut
  325. file=${outfile}libav.nut
  326. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  327. do_ffmpeg_crc $file -i $file
  328. # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
  329. ####################
  330. # streamed images
  331. # mjpeg
  332. #file=${outfile}libav.mjpeg
  333. #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  334. #do_ffmpeg_crc $file -i $file
  335. # pbmpipe
  336. file=${outfile}libav.pbm
  337. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  338. do_ffmpeg_crc $file -f imagepipe -i $file
  339. # pgmpipe
  340. file=${outfile}libav.pgm
  341. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  342. do_ffmpeg_crc $file -f imagepipe -i $file
  343. # ppmpipe
  344. file=${outfile}libav.ppm
  345. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  346. do_ffmpeg_crc $file -f imagepipe -i $file
  347. # gif
  348. file=${outfile}libav.gif
  349. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  350. #do_ffmpeg_crc $file -i $file
  351. # yuv4mpeg
  352. file=${outfile}libav.yuv4mpeg
  353. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  354. #do_ffmpeg_crc $file -i $file
  355. ####################
  356. # image formats
  357. # pgm (we do not do md5 on image files yet)
  358. file=${outfile}libav%d.pgm
  359. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  360. do_ffmpeg_crc $file -i $file
  361. # ppm (we do not do md5 on image files yet)
  362. file=${outfile}libav%d.ppm
  363. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  364. do_ffmpeg_crc $file -i $file
  365. # jpeg (we do not do md5 on image files yet)
  366. #file=${outfile}libav%d.jpg
  367. #$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  368. #do_ffmpeg_crc $file -i $file
  369. ####################
  370. # audio only
  371. # wav
  372. file=${outfile}libav.wav
  373. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  374. do_ffmpeg_crc $file -i $file
  375. # alaw
  376. file=${outfile}libav.al
  377. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  378. do_ffmpeg_crc $file -i $file
  379. # mulaw
  380. file=${outfile}libav.ul
  381. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  382. do_ffmpeg_crc $file -i $file
  383. # au
  384. file=${outfile}libav.au
  385. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  386. do_ffmpeg_crc $file -i $file
  387. ####################
  388. # pix_fmt conversions
  389. conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
  390. yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
  391. monob pal8"
  392. for pix_fmt in $conversions ; do
  393. file=${outfile}libav-${pix_fmt}.yuv
  394. do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
  395. -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
  396. do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
  397. -f rawvideo -s 352x288 -pix_fmt yuv444p $file
  398. done
  399. fi
  400. if $diff_cmd $logfile $reffile ; then
  401. echo
  402. echo Regression test succeeded.
  403. exit 0
  404. else
  405. echo
  406. echo Regression test: Error.
  407. exit 1
  408. fi