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.

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