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.

357 lines
8.6KB

  1. #!/bin/sh
  2. #
  3. # automatic regression test for ffmpeg
  4. #
  5. #
  6. #set -x
  7. set -e
  8. datadir="./data"
  9. logfile="$datadir/ffmpeg.regression"
  10. # tests to do
  11. if [ "$1" = "mpeg4" ] ; then
  12. do_mpeg4=y
  13. elif [ "$1" = "mpeg" ] ; then
  14. do_mpeg=y
  15. elif [ "$1" = "ac3" ] ; then
  16. do_ac3=y
  17. elif [ "$1" = "libavtest" ] ; then
  18. do_libav=y
  19. logfile="$datadir/libav.regression"
  20. else
  21. do_mpeg=y
  22. do_msmpeg4v2=y
  23. do_msmpeg4=y
  24. do_wmv1=y
  25. do_h263=y
  26. do_h263p=y
  27. do_mpeg4=y
  28. # do_huffyuv=y
  29. do_mjpeg=y
  30. do_rv10=y
  31. do_mp2=y
  32. do_ac3=y
  33. do_rc=y
  34. do_mpeg4adv=y
  35. do_mpeg1b=y
  36. fi
  37. # various files
  38. ffmpeg="../ffmpeg_g"
  39. outfile="$datadir/a-"
  40. reffile="$2"
  41. benchfile="$datadir/ffmpeg.bench"
  42. raw_src="vsynth1/%d.pgm"
  43. raw_dst="$datadir/out.yuv"
  44. pcm_src="asynth1.sw"
  45. pcm_dst="$datadir/out.wav"
  46. # create the data directory if it does not exists
  47. mkdir -p $datadir
  48. do_ffmpeg()
  49. {
  50. f="$1"
  51. shift
  52. echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
  53. $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp
  54. md5sum -b $f >> $logfile
  55. expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
  56. echo `cat $datadir/bench2.tmp` $f >> $benchfile
  57. }
  58. do_ffmpeg_crc()
  59. {
  60. f="$1"
  61. shift
  62. echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  63. $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  64. echo -n "$f " >> $logfile
  65. cat $datadir/ffmpeg.crc >> $logfile
  66. }
  67. echo "ffmpeg regression test" > $logfile
  68. echo "ffmpeg benchmarks" > $benchfile
  69. ###################################
  70. if [ -n "$do_mpeg" ] ; then
  71. # mpeg1 encoding
  72. file=${outfile}mpeg1.mpg
  73. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
  74. # mpeg1 decoding
  75. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  76. # mpeg2 decoding
  77. #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
  78. # -f rawvideo /tmp/out-mpeg2.yuv
  79. fi
  80. ###################################
  81. if [ -n "$do_msmpeg4v2" ] ; then
  82. # msmpeg4 encoding
  83. file=${outfile}msmpeg4v2.avi
  84. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
  85. # msmpeg4v2 decoding
  86. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  87. fi
  88. ###################################
  89. if [ -n "$do_msmpeg4" ] ; then
  90. # msmpeg4 encoding
  91. file=${outfile}msmpeg4.avi
  92. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
  93. # msmpeg4 decoding
  94. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  95. fi
  96. ###################################
  97. if [ -n "$do_wmv1" ] ; then
  98. # wmv1 encoding
  99. file=${outfile}wmv1.avi
  100. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
  101. # wmv1 decoding
  102. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  103. fi
  104. ###################################
  105. if [ -n "$do_h263" ] ; then
  106. # h263 encoding
  107. file=${outfile}h263.avi
  108. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
  109. # h263 decoding
  110. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  111. fi
  112. ###################################
  113. if [ -n "$do_h263p" ] ; then
  114. # h263p encoding
  115. file=${outfile}h263p.avi
  116. do_ffmpeg $file -y -qscale 10 -umv -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 1000 $file
  117. # h263p decoding
  118. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  119. fi
  120. ###################################
  121. if [ -n "$do_mpeg4" ] ; then
  122. # mpeg4
  123. file=${outfile}odivx.avi
  124. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  125. # mpeg4 decoding
  126. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  127. fi
  128. ###################################
  129. if [ -n "$do_huffyuv" ] ; then
  130. # huffyuv
  131. file=${outfile}huffyuv.avi
  132. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
  133. # huffyuv decoding
  134. do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
  135. fi
  136. ###################################
  137. if [ -n "$do_rc" ] ; then
  138. # mpeg4 rate control
  139. file=${outfile}mpeg4-rc.avi
  140. do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  141. # mpeg4 rate control decoding
  142. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  143. fi
  144. ###################################
  145. if [ -n "$do_mpeg4adv" ] ; then
  146. # mpeg4
  147. file=${outfile}mpeg4-adv.avi
  148. do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 1000 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  149. # mpeg4 decoding
  150. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  151. fi
  152. ###################################
  153. if [ -n "$do_mpeg1b" ] ; then
  154. # mpeg1
  155. file=${outfile}mpeg1b.mpg
  156. do_ffmpeg $file -y -qscale 8 -bf 3 -f pgmyuv -i $raw_src -an -vcodec mpeg1video $file
  157. # mpeg1 decoding
  158. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  159. fi
  160. ###################################
  161. if [ -n "$do_mjpeg" ] ; then
  162. # mjpeg
  163. file=${outfile}mjpeg.avi
  164. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
  165. # mjpeg decoding
  166. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  167. fi
  168. ###################################
  169. if [ -n "$do_rv10" ] ; then
  170. # rv10 encoding
  171. file=${outfile}rv10.rm
  172. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
  173. # rv10 decoding
  174. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  175. fi
  176. ###################################
  177. if [ -n "$do_mp2" ] ; then
  178. # mp2 encoding
  179. file=${outfile}mp2.mp2
  180. do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
  181. # mp2 decoding
  182. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  183. fi
  184. ###################################
  185. if [ -n "$do_ac3" ] ; then
  186. # ac3 encoding
  187. file=${outfile}ac3.rm
  188. do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
  189. # ac3 decoding
  190. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  191. fi
  192. ###################################
  193. # libav testing
  194. ###################################
  195. if [ -n "$do_libav" ] ; then
  196. # avi
  197. file=${outfile}libav.avi
  198. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  199. do_ffmpeg_crc $file -i $file
  200. # asf
  201. file=${outfile}libav.asf
  202. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  203. do_ffmpeg_crc $file -i $file
  204. # rm
  205. file=${outfile}libav.rm
  206. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  207. # broken
  208. #do_ffmpeg_crc $file -i $file
  209. # mpegps
  210. file=${outfile}libav.mpg
  211. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  212. do_ffmpeg_crc $file -i $file
  213. # swf (decode audio only)
  214. file=${outfile}libav.swf
  215. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  216. do_ffmpeg_crc $file -i $file
  217. # ffm
  218. file=${outfile}libav.ffm
  219. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  220. do_ffmpeg_crc $file -i $file
  221. # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
  222. ####################
  223. # streamed images
  224. # mjpeg
  225. file=${outfile}libav.mjpeg
  226. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  227. do_ffmpeg_crc $file -i $file
  228. # pbmpipe
  229. file=${outfile}libav.pbm
  230. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  231. do_ffmpeg_crc $file -f imagepipe -i $file
  232. # pgmpipe
  233. file=${outfile}libav.pgm
  234. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  235. do_ffmpeg_crc $file -f imagepipe -i $file
  236. # ppmpipe
  237. file=${outfile}libav.ppm
  238. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  239. do_ffmpeg_crc $file -f imagepipe -i $file
  240. # gif
  241. file=${outfile}libav.gif
  242. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  243. #do_ffmpeg_crc $file -i $file
  244. # yuv4mpeg
  245. file=${outfile}libav.yuv4mpeg
  246. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  247. #do_ffmpeg_crc $file -i $file
  248. ####################
  249. # image formats
  250. # pgm (we do not do md5 on image files yet)
  251. file=${outfile}libav%d.pgm
  252. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  253. do_ffmpeg_crc $file -i $file
  254. # ppm (we do not do md5 on image files yet)
  255. file=${outfile}libav%d.ppm
  256. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  257. do_ffmpeg_crc $file -i $file
  258. # jpeg (we do not do md5 on image files yet)
  259. file=${outfile}libav%d.jpg
  260. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  261. do_ffmpeg_crc $file -i $file
  262. ####################
  263. # audio only
  264. # wav
  265. file=${outfile}libav.wav
  266. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  267. do_ffmpeg_crc $file -i $file
  268. # alaw
  269. file=${outfile}libav.al
  270. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  271. do_ffmpeg_crc $file -i $file
  272. # mulaw
  273. file=${outfile}libav.ul
  274. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  275. do_ffmpeg_crc $file -i $file
  276. # au
  277. file=${outfile}libav.au
  278. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  279. do_ffmpeg_crc $file -i $file
  280. fi
  281. if diff -u $logfile $reffile ; then
  282. echo
  283. echo Regression test succeeded.
  284. exit 0
  285. else
  286. echo
  287. echo Regression test: Error.
  288. exit 1
  289. fi