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.

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