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.

335 lines
8.0KB

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