vpx_temporal_svc_encoder.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. #!/bin/sh
  2. ##
  3. ## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  4. ##
  5. ## Use of this source code is governed by a BSD-style license
  6. ## that can be found in the LICENSE file in the root of the source
  7. ## tree. An additional intellectual property rights grant can be found
  8. ## in the file PATENTS. All contributing project authors may
  9. ## be found in the AUTHORS file in the root of the source tree.
  10. ##
  11. ## This file tests the libvpx vpx_temporal_svc_encoder example. To add new
  12. ## tests to this file, do the following:
  13. ## 1. Write a shell function (this is your test).
  14. ## 2. Add the function to vpx_tsvc_encoder_tests (on a new line).
  15. ##
  16. . $(dirname $0)/tools_common.sh
  17. # Environment check: $YUV_RAW_INPUT is required.
  18. vpx_tsvc_encoder_verify_environment() {
  19. if [ ! -e "${YUV_RAW_INPUT}" ]; then
  20. echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
  21. return 1
  22. fi
  23. if [ "$(vpx_config_option_enabled CONFIG_TEMPORAL_DENOISING)" != "yes" ]; then
  24. elog "Warning: Temporal denoising is disabled! Spatial denoising will be " \
  25. "used instead, which is probably not what you want for this test."
  26. fi
  27. }
  28. # Runs vpx_temporal_svc_encoder using the codec specified by $1 and output file
  29. # name by $2. Additional positional parameters are passed directly to
  30. # vpx_temporal_svc_encoder.
  31. vpx_tsvc_encoder() {
  32. local encoder="${LIBVPX_BIN_PATH}/vpx_temporal_svc_encoder"
  33. encoder="${encoder}${VPX_TEST_EXE_SUFFIX}"
  34. local codec="$1"
  35. local output_file_base="$2"
  36. local output_file="${VPX_TEST_OUTPUT_DIR}/${output_file_base}"
  37. local timebase_num="1"
  38. local timebase_den="1000"
  39. local timebase_den_y4m="30"
  40. local speed="6"
  41. local frame_drop_thresh="30"
  42. local max_threads="4"
  43. local error_resilient="1"
  44. shift 2
  45. if [ ! -x "${encoder}" ]; then
  46. elog "${encoder} does not exist or is not executable."
  47. return 1
  48. fi
  49. # TODO(tomfinegan): Verify file output for all thread runs.
  50. for threads in $(seq $max_threads); do
  51. if [ "$(vpx_config_option_enabled CONFIG_VP9_HIGHBITDEPTH)" != "yes" ]; then
  52. eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" \
  53. "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
  54. "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \
  55. "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
  56. "$@" ${devnull}
  57. # Test for y4m input.
  58. eval "${VPX_TEST_PREFIX}" "${encoder}" "${Y4M_720P_INPUT}" \
  59. "${output_file}" "${codec}" "${Y4M_720P_INPUT_WIDTH}" \
  60. "${Y4M_720P_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den_y4m}" \
  61. "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
  62. "$@" ${devnull}
  63. else
  64. eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" \
  65. "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
  66. "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \
  67. "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \
  68. "$@" "8" ${devnull}
  69. fi
  70. done
  71. }
  72. # Confirms that all expected output files exist given the output file name
  73. # passed to vpx_temporal_svc_encoder.
  74. # The file name passed to vpx_temporal_svc_encoder is joined with the stream
  75. # number and the extension .ivf to produce per stream output files. Here $1 is
  76. # file name, and $2 is expected number of files.
  77. files_exist() {
  78. local file_name="${VPX_TEST_OUTPUT_DIR}/$1"
  79. local num_files="$(($2 - 1))"
  80. for stream_num in $(seq 0 ${num_files}); do
  81. [ -e "${file_name}_${stream_num}.ivf" ] || return 1
  82. done
  83. }
  84. # Run vpx_temporal_svc_encoder in all supported modes for vp8 and vp9.
  85. vpx_tsvc_encoder_vp8_mode_0() {
  86. if [ "$(vp8_encode_available)" = "yes" ]; then
  87. local output_basename="vpx_tsvc_encoder_vp8_mode_0"
  88. vpx_tsvc_encoder vp8 "${output_basename}" 0 200 || return 1
  89. # Mode 0 produces 1 stream
  90. files_exist "${output_basename}" 1 || return 1
  91. fi
  92. }
  93. vpx_tsvc_encoder_vp8_mode_1() {
  94. if [ "$(vp8_encode_available)" = "yes" ]; then
  95. local output_basename="vpx_tsvc_encoder_vp8_mode_1"
  96. vpx_tsvc_encoder vp8 "${output_basename}" 1 200 400 || return 1
  97. # Mode 1 produces 2 streams
  98. files_exist "${output_basename}" 2 || return 1
  99. fi
  100. }
  101. vpx_tsvc_encoder_vp8_mode_2() {
  102. if [ "$(vp8_encode_available)" = "yes" ]; then
  103. local output_basename="vpx_tsvc_encoder_vp8_mode_2"
  104. vpx_tsvc_encoder vp8 "${output_basename}" 2 200 400 || return 1
  105. # Mode 2 produces 2 streams
  106. files_exist "${output_basename}" 2 || return 1
  107. fi
  108. }
  109. vpx_tsvc_encoder_vp8_mode_3() {
  110. if [ "$(vp8_encode_available)" = "yes" ]; then
  111. local output_basename="vpx_tsvc_encoder_vp8_mode_3"
  112. vpx_tsvc_encoder vp8 "${output_basename}" 3 200 400 600 || return 1
  113. # Mode 3 produces 3 streams
  114. files_exist "${output_basename}" 3 || return 1
  115. fi
  116. }
  117. vpx_tsvc_encoder_vp8_mode_4() {
  118. if [ "$(vp8_encode_available)" = "yes" ]; then
  119. local output_basename="vpx_tsvc_encoder_vp8_mode_4"
  120. vpx_tsvc_encoder vp8 "${output_basename}" 4 200 400 600 || return 1
  121. # Mode 4 produces 3 streams
  122. files_exist "${output_basename}" 3 || return 1
  123. fi
  124. }
  125. vpx_tsvc_encoder_vp8_mode_5() {
  126. if [ "$(vp8_encode_available)" = "yes" ]; then
  127. local output_basename="vpx_tsvc_encoder_vp8_mode_5"
  128. vpx_tsvc_encoder vp8 "${output_basename}" 5 200 400 600 || return 1
  129. # Mode 5 produces 3 streams
  130. files_exist "${output_basename}" 3 || return 1
  131. fi
  132. }
  133. vpx_tsvc_encoder_vp8_mode_6() {
  134. if [ "$(vp8_encode_available)" = "yes" ]; then
  135. local output_basename="vpx_tsvc_encoder_vp8_mode_6"
  136. vpx_tsvc_encoder vp8 "${output_basename}" 6 200 400 600 || return 1
  137. # Mode 6 produces 3 streams
  138. files_exist "${output_basename}" 3 || return 1
  139. fi
  140. }
  141. vpx_tsvc_encoder_vp8_mode_7() {
  142. if [ "$(vp8_encode_available)" = "yes" ]; then
  143. local output_basename="vpx_tsvc_encoder_vp8_mode_7"
  144. vpx_tsvc_encoder vp8 "${output_basename}" 7 200 400 600 800 1000 || return 1
  145. # Mode 7 produces 5 streams
  146. files_exist "${output_basename}" 5 || return 1
  147. fi
  148. }
  149. vpx_tsvc_encoder_vp8_mode_8() {
  150. if [ "$(vp8_encode_available)" = "yes" ]; then
  151. local output_basename="vpx_tsvc_encoder_vp8_mode_8"
  152. vpx_tsvc_encoder vp8 "${output_basename}" 8 200 400 || return 1
  153. # Mode 8 produces 2 streams
  154. files_exist "${output_basename}" 2 || return 1
  155. fi
  156. }
  157. vpx_tsvc_encoder_vp8_mode_9() {
  158. if [ "$(vp8_encode_available)" = "yes" ]; then
  159. local output_basename="vpx_tsvc_encoder_vp8_mode_9"
  160. vpx_tsvc_encoder vp8 "${output_basename}" 9 200 400 600 || return 1
  161. # Mode 9 produces 3 streams
  162. files_exist "${output_basename}" 3 || return 1
  163. fi
  164. }
  165. vpx_tsvc_encoder_vp8_mode_10() {
  166. if [ "$(vp8_encode_available)" = "yes" ]; then
  167. local output_basename="vpx_tsvc_encoder_vp8_mode_10"
  168. vpx_tsvc_encoder vp8 "${output_basename}" 10 200 400 600 || return 1
  169. # Mode 10 produces 3 streams
  170. files_exist "${output_basename}" 3 || return 1
  171. fi
  172. }
  173. vpx_tsvc_encoder_vp8_mode_11() {
  174. if [ "$(vp8_encode_available)" = "yes" ]; then
  175. local output_basename="vpx_tsvc_encoder_vp8_mode_11"
  176. vpx_tsvc_encoder vp8 "${output_basename}" 11 200 400 600 || return 1
  177. # Mode 11 produces 3 streams
  178. files_exist "${output_basename}" 3 || return 1
  179. fi
  180. }
  181. vpx_tsvc_encoder_vp9_mode_0() {
  182. if [ "$(vp9_encode_available)" = "yes" ]; then
  183. local output_basename="vpx_tsvc_encoder_vp9_mode_0"
  184. vpx_tsvc_encoder vp9 "${output_basename}" 0 200 || return 1
  185. # Mode 0 produces 1 stream
  186. files_exist "${output_basename}" 1 || return 1
  187. fi
  188. }
  189. vpx_tsvc_encoder_vp9_mode_1() {
  190. if [ "$(vp9_encode_available)" = "yes" ]; then
  191. local output_basename="vpx_tsvc_encoder_vp9_mode_1"
  192. vpx_tsvc_encoder vp9 "${output_basename}" 1 200 400 || return 1
  193. # Mode 1 produces 2 streams
  194. files_exist "${output_basename}" 2 || return 1
  195. fi
  196. }
  197. vpx_tsvc_encoder_vp9_mode_2() {
  198. if [ "$(vp9_encode_available)" = "yes" ]; then
  199. local output_basename="vpx_tsvc_encoder_vp9_mode_2"
  200. vpx_tsvc_encoder vp9 "${output_basename}" 2 200 400 || return 1
  201. # Mode 2 produces 2 streams
  202. files_exist "${output_basename}" 2 || return 1
  203. fi
  204. }
  205. vpx_tsvc_encoder_vp9_mode_3() {
  206. if [ "$(vp9_encode_available)" = "yes" ]; then
  207. local output_basename="vpx_tsvc_encoder_vp9_mode_3"
  208. vpx_tsvc_encoder vp9 "${output_basename}" 3 200 400 600 || return 1
  209. # Mode 3 produces 3 streams
  210. files_exist "${output_basename}" 3 || return 1
  211. fi
  212. }
  213. vpx_tsvc_encoder_vp9_mode_4() {
  214. if [ "$(vp9_encode_available)" = "yes" ]; then
  215. local output_basename="vpx_tsvc_encoder_vp9_mode_4"
  216. vpx_tsvc_encoder vp9 "${output_basename}" 4 200 400 600 || return 1
  217. # Mode 4 produces 3 streams
  218. files_exist "${output_basename}" 3 || return 1
  219. fi
  220. }
  221. vpx_tsvc_encoder_vp9_mode_5() {
  222. if [ "$(vp9_encode_available)" = "yes" ]; then
  223. local output_basename="vpx_tsvc_encoder_vp9_mode_5"
  224. vpx_tsvc_encoder vp9 "${output_basename}" 5 200 400 600 || return 1
  225. # Mode 5 produces 3 streams
  226. files_exist "${output_basename}" 3 || return 1
  227. fi
  228. }
  229. vpx_tsvc_encoder_vp9_mode_6() {
  230. if [ "$(vp9_encode_available)" = "yes" ]; then
  231. local output_basename="vpx_tsvc_encoder_vp9_mode_6"
  232. vpx_tsvc_encoder vp9 "${output_basename}" 6 200 400 600 || return 1
  233. # Mode 6 produces 3 streams
  234. files_exist "${output_basename}" 3 || return 1
  235. fi
  236. }
  237. vpx_tsvc_encoder_vp9_mode_7() {
  238. if [ "$(vp9_encode_available)" = "yes" ]; then
  239. local output_basename="vpx_tsvc_encoder_vp9_mode_7"
  240. vpx_tsvc_encoder vp9 "${output_basename}" 7 200 400 600 800 1000 || return 1
  241. # Mode 7 produces 5 streams
  242. files_exist "${output_basename}" 5 || return 1
  243. fi
  244. }
  245. vpx_tsvc_encoder_vp9_mode_8() {
  246. if [ "$(vp9_encode_available)" = "yes" ]; then
  247. local output_basename="vpx_tsvc_encoder_vp9_mode_8"
  248. vpx_tsvc_encoder vp9 "${output_basename}" 8 200 400 || return 1
  249. # Mode 8 produces 2 streams
  250. files_exist "${output_basename}" 2 || return 1
  251. fi
  252. }
  253. vpx_tsvc_encoder_vp9_mode_9() {
  254. if [ "$(vp9_encode_available)" = "yes" ]; then
  255. local output_basename="vpx_tsvc_encoder_vp9_mode_9"
  256. vpx_tsvc_encoder vp9 "${output_basename}" 9 200 400 600 || return 1
  257. # Mode 9 produces 3 streams
  258. files_exist "${output_basename}" 3 || return 1
  259. fi
  260. }
  261. vpx_tsvc_encoder_vp9_mode_10() {
  262. if [ "$(vp9_encode_available)" = "yes" ]; then
  263. local output_basename="vpx_tsvc_encoder_vp9_mode_10"
  264. vpx_tsvc_encoder vp9 "${output_basename}" 10 200 400 600 || return 1
  265. # Mode 10 produces 3 streams
  266. files_exist "${output_basename}" 3 || return 1
  267. fi
  268. }
  269. vpx_tsvc_encoder_vp9_mode_11() {
  270. if [ "$(vp9_encode_available)" = "yes" ]; then
  271. local output_basename="vpx_tsvc_encoder_vp9_mode_11"
  272. vpx_tsvc_encoder vp9 "${output_basename}" 11 200 400 600 || return 1
  273. # Mode 11 produces 3 streams
  274. files_exist "${output_basename}" 3 || return 1
  275. fi
  276. }
  277. vpx_tsvc_encoder_tests="vpx_tsvc_encoder_vp8_mode_0
  278. vpx_tsvc_encoder_vp8_mode_1
  279. vpx_tsvc_encoder_vp8_mode_2
  280. vpx_tsvc_encoder_vp8_mode_3
  281. vpx_tsvc_encoder_vp8_mode_4
  282. vpx_tsvc_encoder_vp8_mode_5
  283. vpx_tsvc_encoder_vp8_mode_6
  284. vpx_tsvc_encoder_vp8_mode_7
  285. vpx_tsvc_encoder_vp8_mode_8
  286. vpx_tsvc_encoder_vp8_mode_9
  287. vpx_tsvc_encoder_vp8_mode_10
  288. vpx_tsvc_encoder_vp8_mode_11
  289. vpx_tsvc_encoder_vp9_mode_0
  290. vpx_tsvc_encoder_vp9_mode_1
  291. vpx_tsvc_encoder_vp9_mode_2
  292. vpx_tsvc_encoder_vp9_mode_3
  293. vpx_tsvc_encoder_vp9_mode_4
  294. vpx_tsvc_encoder_vp9_mode_5
  295. vpx_tsvc_encoder_vp9_mode_6
  296. vpx_tsvc_encoder_vp9_mode_7
  297. vpx_tsvc_encoder_vp9_mode_8
  298. vpx_tsvc_encoder_vp9_mode_9
  299. vpx_tsvc_encoder_vp9_mode_10
  300. vpx_tsvc_encoder_vp9_mode_11"
  301. run_tests vpx_tsvc_encoder_verify_environment "${vpx_tsvc_encoder_tests}"