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.

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