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.

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