rd_collect.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. #!/bin/bash
  2. set -e
  3. CODECS="<daala|vp8|vp9|x264|x265|libjpeg|mozjpeg|theora>"
  4. if [ $# == 0 ]; then
  5. echo "usage: DAALA_ROOT=<build_dir> $0 $CODECS *.y4m"
  6. exit 1
  7. fi
  8. export CODEC=$1
  9. shift
  10. if [ $# == 0 ] || [[ ! $CODECS =~ [\<\|]$CODEC[\|\>] ]]; then
  11. echo "usage: DAALA_ROOT=<build_dir> $0 $CODECS *.y4m"
  12. exit 1
  13. fi
  14. if [ -z $DAALA_ROOT ]; then
  15. DAALA_ROOT=.
  16. fi
  17. if [ ! -d $DAALA_ROOT ]; then
  18. echo "Please set DAALA_ROOT to the location of your daala git clone"
  19. exit 1
  20. fi
  21. case $CODEC in
  22. daala)
  23. if [ ! -f $DAALA_ROOT/config.h ]; then
  24. echo "File not found $DAALA_ROOT/config.h"
  25. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  26. exit 1
  27. fi
  28. if ((! grep -Fxq "#define OD_DUMP_IMAGES 1" "$DAALA_ROOT/config.h") &&
  29. (! grep -Fxq "#define OD_DUMP_RECONS 1" "$DAALA_ROOT/config.h")); then
  30. echo "Video dumping not enabled, re-run configure with --enable-dump-recons"
  31. exit 1
  32. fi
  33. if [ -z "$ENCODER_EXAMPLE" ]; then
  34. export ENCODER_EXAMPLE=$DAALA_ROOT/examples/encoder_example
  35. fi
  36. if [ ! -x "$ENCODER_EXAMPLE" ]; then
  37. echo "Executable not found ENCODER_EXAMPLE=$ENCODER_EXAMPLE"
  38. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  39. exit 1
  40. fi
  41. export RD_COLLECT_SUB=$(dirname "$0")/rd_collect_daala.sh
  42. ;;
  43. vp8 | vp9)
  44. if [ -z $LIBVPX_ROOT ] || [ ! -d $LIBVPX_ROOT ]; then
  45. echo "Please set LIBVPX_ROOT to the location of your libvpx git clone"
  46. exit 1
  47. fi
  48. if [ -z "$VPXENC" ]; then
  49. export VPXENC=$LIBVPX_ROOT/vpxenc
  50. fi
  51. if [ -z "$VPXDEC" ]; then
  52. export VPXDEC=$LIBVPX_ROOT/vpxdec
  53. fi
  54. if [ ! -x "$VPXENC" ]; then
  55. echo "Executable not found VPXENC=$VPXENC"
  56. echo "Do you have the right LIBVPX_ROOT=$LIBVPX_ROOT"
  57. exit 1
  58. fi
  59. if [ ! -x "$VPXDEC" ]; then
  60. echo "Executable not found VPXDEC=$VPXDEC"
  61. echo "Do you have the right LIBVPX_ROOT=$LIBVPX_ROOT"
  62. exit 1
  63. fi
  64. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_libvpx.sh
  65. ;;
  66. x264)
  67. if [ -z $X264_ROOT ] || [ ! -d $X264_ROOT ]; then
  68. echo "Please set X264_ROOT to the location of your x264 git clone"
  69. exit 1
  70. fi
  71. if [ -z "$X264" ]; then
  72. export X264=$X264_ROOT/x264
  73. fi
  74. if [ ! -x "$X264" ]; then
  75. echo "Executable not found X264=$X264"
  76. echo "Do you have the right X264_ROOT=$X264_ROOT"
  77. exit 1
  78. fi
  79. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_x264.sh
  80. ;;
  81. x265)
  82. if [ -z $X265_ROOT ] || [ ! -d $X265_ROOT ]; then
  83. echo "Please set X265_ROOT to the location of your x265 hg checkout"
  84. exit 1
  85. fi
  86. if [ -z "$X265" ]; then
  87. export X265=$X265_ROOT/build/linux/x265
  88. fi
  89. if [ ! -x "$X265" ]; then
  90. echo "Executable not found X265=$X265"
  91. echo "Do you have the right X265_ROOT=$X265_ROOT"
  92. exit 1
  93. fi
  94. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_x265.sh
  95. ;;
  96. libjpeg)
  97. if [ -z "$YUVJPEG" ]; then
  98. export YUVJPEG=$DAALA_ROOT/tools/yuvjpeg
  99. fi
  100. if [ -z "$JPEGYUV" ]; then
  101. export JPEGYUV=$DAALA_ROOT/tools/jpegyuv
  102. fi
  103. if [ ! -x "$YUVJPEG" ]; then
  104. echo "Executable not found YUVJPEG=$YUVJPEG"
  105. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  106. exit 1
  107. fi
  108. if [ ! -x "$JPEGYUV" ]; then
  109. echo "Executable not found JPEGYUV=$JPEGYUV"
  110. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  111. exit 1
  112. fi
  113. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_jpeg.sh
  114. ;;
  115. mozjpeg)
  116. if [ -z $MOZJPEG_ROOT ] || [ ! -d $MOZJPEG_ROOT ]; then
  117. echo "Please set MOZJPEG_ROOT to the location of your mozjpeg git clone"
  118. exit 1
  119. fi
  120. if [ -z "$YUVJPEG" ]; then
  121. export YUVJPEG=$MOZJPEG_ROOT/yuvjpeg
  122. fi
  123. if [ -z "$JPEGYUV" ]; then
  124. export JPEGYUV=$MOZJPEG_ROOT/jpegyuv
  125. fi
  126. if [ ! -x "$YUVJPEG" ]; then
  127. echo "Executable not found YUVJPEG=$YUVJPEG"
  128. echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
  129. exit 1
  130. fi
  131. if [ ! -x "$JPEGYUV" ]; then
  132. echo "Executable not found JPEGYUV=$JPEGYUV"
  133. echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
  134. exit 1
  135. fi
  136. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_jpeg.sh
  137. ;;
  138. theora)
  139. if [ -z $THEORA_ROOT ] || [ ! -d $THEORA_ROOT ]; then
  140. echo "Please set THEORA_ROOT to the location of your theora svn checkout"
  141. exit 1
  142. fi
  143. if [ -z "$ENCODER_EXAMPLE" ]; then
  144. export ENCODER_EXAMPLE=$THEORA_ROOT/examples/encoder_example
  145. fi
  146. if [ -z "$DUMP_VIDEO" ]; then
  147. export DUMP_VIDEO=$THEORA_ROOT/examples/dump_video
  148. fi
  149. if [ ! -x "$ENCODER_EXAMPLE" ]; then
  150. echo "Executable not found ENCODER_EXAMPLE=$ENCODER_EXAMPLE"
  151. echo "Do you have the right THEORA_ROOT=$THEORA_ROOT"
  152. exit 1
  153. fi
  154. if [ ! -x "$DUMP_VIDEO" ]; then
  155. echo "Executable not found DUMP_VIDEO=$DUMP_VIDEO"
  156. echo "Do you have the right THEORA_ROOT=$THEORA_ROOT"
  157. exit 1
  158. fi
  159. export RD_COLLECT_SUB=$(dirname $0)/rd_collect_theora.sh
  160. ;;
  161. *)
  162. echo "Unknown codec: $CODEC"
  163. exit 1
  164. esac
  165. if [ -z "$PLANE" ]; then
  166. export PLANE=0
  167. fi
  168. if [ $PLANE != 0 ] && [ $PLANE != 1 ] && [ $PLANE != 2 ] &&
  169. [ $PLANE != -1 ]; then
  170. echo "Invalid plane $PLANE. Must be 0, 1, 2, or -1 (all planes)."
  171. exit 1
  172. fi
  173. # TODO refactor these out of the daala project into a metrics project
  174. if [ -z "$YUV2YUV4MPEG" ]; then
  175. export YUV2YUV4MPEG=$DAALA_ROOT/tools/yuv2yuv4mpeg
  176. fi
  177. if [ -z "$DUMP_PSNR" ]; then
  178. export DUMP_PSNR=$DAALA_ROOT/tools/dump_psnr
  179. fi
  180. if [ -z "$DUMP_PSNRHVS" ]; then
  181. export DUMP_PSNRHVS=$DAALA_ROOT/tools/dump_psnrhvs
  182. fi
  183. if [ -z "$DUMP_SSIM" ]; then
  184. export DUMP_SSIM=$DAALA_ROOT/tools/dump_ssim
  185. fi
  186. if [ -z "$DUMP_FASTSSIM" ]; then
  187. export DUMP_FASTSSIM=$DAALA_ROOT/tools/dump_fastssim
  188. fi
  189. if [ ! -x "$YUV2YUV4MPEG" ]; then
  190. echo "Executable not found YUV2YUV4MPEG=$YUV2YUV4MPEG"
  191. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  192. exit 1
  193. fi
  194. if [ ! -x "$DUMP_PSNR" ]; then
  195. echo "Executable not found DUMP_PSNR=$DUMP_PSNR"
  196. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  197. exit 1
  198. fi
  199. if [ ! -x "$DUMP_PSNRHVS" ]; then
  200. echo "Executable not found DUMP_PSNRHVS=$DUMP_PSNRHVS"
  201. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  202. exit 1
  203. fi
  204. if [ ! -x "$DUMP_SSIM" ]; then
  205. echo "Executable not found DUMP_FASTSSIM=$DUMP_SSIM"
  206. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  207. exit 1
  208. fi
  209. if [ ! -x "$DUMP_FASTSSIM" ]; then
  210. echo "Executable not found DUMP_FASTSSIM=$DUMP_FASTSSIM"
  211. echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
  212. exit 1
  213. fi
  214. if [ -z "$CORES" ]; then
  215. CORES=`grep -i processor /proc/cpuinfo | wc -l`
  216. #echo "CORES not set, using $CORES"
  217. fi
  218. find -L $@ -type f -name "*.y4m" -print0 | xargs -0 -n1 -P$CORES $RD_COLLECT_SUB