lavfi-regression.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. #
  3. # automatic regression test for libavfilter
  4. #
  5. #
  6. #set -x
  7. set -e
  8. . $(dirname $0)/regression-funcs.sh
  9. eval do_$test=y
  10. rm -f "$logfile"
  11. rm -f "$benchfile"
  12. do_video_filter() {
  13. label=$1
  14. filters=$2
  15. shift 2
  16. printf '%-20s' $label >>$logfile
  17. run_ffmpeg -f image2 -vcodec pgmyuv -i $raw_src \
  18. -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile
  19. }
  20. do_lavfi() {
  21. vfilters="slicify=random,$2"
  22. if [ $test = $1 ] ; then
  23. do_video_filter $test "$vfilters"
  24. fi
  25. }
  26. do_lavfi "crop" "crop=iw-100:ih-100:100:100"
  27. do_lavfi "crop_scale" "crop=iw-100:ih-100:100:100,scale=400:-1"
  28. do_lavfi "crop_scale_vflip" "null,null,crop=iw-200:ih-200:200:200,crop=iw-20:ih-20:20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=iw-100:ih-100:100:100,vflip,scale=200:200,null,vflip,crop=iw-100:ih-100:100:100,null"
  29. do_lavfi "crop_vflip" "crop=iw-100:ih-100:100:100,vflip"
  30. do_lavfi "null" "null"
  31. do_lavfi "scale200" "scale=200:200"
  32. do_lavfi "scale500" "scale=500:500"
  33. do_lavfi "vflip" "vflip"
  34. do_lavfi "vflip_crop" "vflip,crop=iw-100:ih-100:100:100"
  35. do_lavfi "vflip_vflip" "vflip,vflip"
  36. do_lavfi_pixfmts(){
  37. test ${test%_[bl]e} = pixfmts_$1 || return 0
  38. filter=$1
  39. filter_args=$2
  40. showfiltfmts="$target_exec $target_path/tools/lavfi-showfiltfmts"
  41. exclude_fmts=${outfile}${1}_exclude_fmts
  42. out_fmts=${outfile}${1}_out_fmts
  43. # exclude pixel formats which are not supported as input
  44. $ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^\..\.' | cut -d' ' -f2 | sort >$exclude_fmts
  45. $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ print $3 }' | sort | comm -23 - $exclude_fmts >$out_fmts
  46. pix_fmts=$($showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts)
  47. for pix_fmt in $pix_fmts; do
  48. do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt
  49. done
  50. rm $exclude_fmts $out_fmts
  51. }
  52. # all these filters have exactly one input and exactly one output
  53. do_lavfi_pixfmts "copy" ""
  54. do_lavfi_pixfmts "crop" "100:100:100:100"
  55. do_lavfi_pixfmts "hflip" ""
  56. do_lavfi_pixfmts "null" ""
  57. do_lavfi_pixfmts "pad" "500:400:20:20"
  58. do_lavfi_pixfmts "scale" "200:100"
  59. do_lavfi_pixfmts "vflip" ""
  60. if [ -n "$do_pixdesc_be" ] || [ -n "$do_pixdesc_le" ]; then
  61. pix_fmts="$($ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^IO' | cut -d' ' -f2 | sort)"
  62. for pix_fmt in $pix_fmts; do
  63. do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,pixdesctest" -pix_fmt $pix_fmt
  64. done
  65. fi
  66. # TODO: add tests for
  67. # direct rendering,
  68. # chains with feedback loops