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.

323 lines
7.7KB

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