aomenc.sh 11.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#!/bin/sh
##
##  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
##
Adrian Grange's avatar
Adrian Grange committed
11
##  This file tests aomenc using hantro_collage_w352h288.yuv as input. To add
12
13
##  new tests to this file, do the following:
##    1. Write a shell function (this is your test).
Adrian Grange's avatar
Adrian Grange committed
14
##    2. Add the function to aomenc_tests (on a new line).
15
16
17
##
. $(dirname $0)/tools_common.sh

18
readonly TEST_FRAMES=10
19
20

# Environment check: Make sure input is available.
Adrian Grange's avatar
Adrian Grange committed
21
aomenc_verify_environment() {
22
  if [ ! -e "${YUV_RAW_INPUT}" ]; then
Adrian Grange's avatar
Adrian Grange committed
23
    elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
24
25
    return 1
  fi
Adrian Grange's avatar
Adrian Grange committed
26
  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
27
28
    if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
      elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
Adrian Grange's avatar
Adrian Grange committed
29
      elog "LIBAOM_TEST_DATA_PATH."
30
31
32
      return 1
    fi
  fi
Adrian Grange's avatar
Adrian Grange committed
33
34
  if [ -z "$(aom_tool_path aomenc)" ]; then
    elog "aomenc not found. It must exist in LIBAOM_BIN_PATH or its parent."
35
36
    return 1
  fi
37
38
}

Adrian Grange's avatar
Adrian Grange committed
39
40
aomenc_can_encode_aom() {
  if [ "$(aom_encode_available)" = "yes" ]; then
41
42
43
44
    echo yes
  fi
}

Adrian Grange's avatar
Adrian Grange committed
45
46
aomenc_can_encode_av1() {
  if [ "$(av1_encode_available)" = "yes" ]; then
47
48
49
50
    echo yes
  fi
}

Adrian Grange's avatar
Adrian Grange committed
51
# Echo aomenc command line parameters allowing use of
52
53
54
55
56
57
58
# hantro_collage_w352h288.yuv as input.
yuv_input_hantro_collage() {
  echo ""${YUV_RAW_INPUT}"
       --width="${YUV_RAW_INPUT_WIDTH}"
       --height="${YUV_RAW_INPUT_HEIGHT}""
}

59
60
61
62
y4m_input_non_square_par() {
  echo ""${Y4M_NOSQ_PAR_INPUT}""
}

63
64
65
66
y4m_input_720p() {
  echo ""${Y4M_720P_INPUT}""
}

Adrian Grange's avatar
Adrian Grange committed
67
# Echo default aomenc real time encoding params. $1 is the codec, which defaults
Adrian Grange's avatar
Adrian Grange committed
68
# to aom if unspecified.
Adrian Grange's avatar
Adrian Grange committed
69
aomenc_rt_params() {
Adrian Grange's avatar
Adrian Grange committed
70
  local readonly codec="${1:-aom}"
71
72
73
74
  echo "--codec=${codec}
    --buf-initial-sz=500
    --buf-optimal-sz=600
    --buf-sz=1000
75
    --cpu-used=-6
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
    --end-usage=cbr
    --error-resilient=1
    --kf-max-dist=90000
    --lag-in-frames=0
    --max-intra-rate=300
    --max-q=56
    --min-q=2
    --noise-sensitivity=0
    --overshoot-pct=50
    --passes=1
    --profile=0
    --resize-allowed=0
    --rt
    --static-thresh=0
    --undershoot-pct=50"
}

Adrian Grange's avatar
Adrian Grange committed
93
94
# Wrapper function for running aomenc with pipe input. Requires that
# LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
95
# input file path and shifted away. All remaining parameters are passed through
Adrian Grange's avatar
Adrian Grange committed
96
97
98
# to aomenc.
aomenc_pipe() {
  local readonly encoder="$(aom_tool_path aomenc)"
99
100
  local readonly input="$1"
  shift
Adrian Grange's avatar
Adrian Grange committed
101
  cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \
102
103
    --test-decode=fatal \
    "$@" ${devnull}
104
}
105

Adrian Grange's avatar
Adrian Grange committed
106
107
108
109
110
# Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to
# the directory containing aomenc. $1 one is used as the input file path and
# shifted away. All remaining parameters are passed through to aomenc.
aomenc() {
  local readonly encoder="$(aom_tool_path aomenc)"
Tom Finegan's avatar
Tom Finegan committed
111
  local readonly input="$1"
112
  shift
Adrian Grange's avatar
Adrian Grange committed
113
  eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \
114
115
    --test-decode=fatal \
    "$@" ${devnull}
116
117
}

Adrian Grange's avatar
Adrian Grange committed
118
119
120
aomenc_aom_ivf() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ]; then
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom.ivf"
Adrian Grange's avatar
Adrian Grange committed
121
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
122
      --codec=aom \
123
124
      --limit="${TEST_FRAMES}" \
      --ivf \
125
      --output="${output}"
126
127
128
129
130

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
131
132
133
  fi
}

Adrian Grange's avatar
Adrian Grange committed
134
135
aomenc_aom_webm() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ] && \
136
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
137
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom.webm"
Adrian Grange's avatar
Adrian Grange committed
138
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
139
      --codec=aom \
140
      --limit="${TEST_FRAMES}" \
141
      --output="${output}"
142
143
144
145
146
147
148
149

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
150
151
aomenc_aom_webm_rt() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ] && \
Tom Finegan's avatar
Tom Finegan committed
152
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
153
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom_rt.webm"
Adrian Grange's avatar
Adrian Grange committed
154
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
155
      $(aomenc_rt_params aom) \
156
      --output="${output}"
Tom Finegan's avatar
Tom Finegan committed
157
158
159
160
161
162
163
    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
164
165
aomenc_aom_webm_2pass() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ] && \
166
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
167
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom.webm"
Adrian Grange's avatar
Adrian Grange committed
168
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
169
      --codec=aom \
170
171
      --limit="${TEST_FRAMES}" \
      --output="${output}" \
172
      --passes=2
173
174
175
176
177
178
179
180

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
181
182
aomenc_aom_webm_lag10_frames20() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ] && \
183
184
185
     [ "$(webm_io_available)" = "yes" ]; then
    local readonly lag_total_frames=20
    local readonly lag_frames=10
Adrian Grange's avatar
Adrian Grange committed
186
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom_lag10_frames20.webm"
Adrian Grange's avatar
Adrian Grange committed
187
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
188
      --codec=aom \
189
190
191
192
      --limit="${lag_total_frames}" \
      --lag-in-frames="${lag_frames}" \
      --output="${output}" \
      --auto-alt-ref=1 \
193
      --passes=2
194
195
196
197
198
199
200
201

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
202
203
204
aomenc_aom_ivf_piped_input() {
  if [ "$(aomenc_can_encode_aom)" = "yes" ]; then
    local readonly output="${AOM_TEST_OUTPUT_DIR}/aom_piped_input.ivf"
Adrian Grange's avatar
Adrian Grange committed
205
    aomenc_pipe $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
206
      --codec=aom \
207
208
209
      --limit="${TEST_FRAMES}" \
      --ivf \
      --output="${output}"
210
211
212
213
214

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
215
216
217
  fi
}

Adrian Grange's avatar
Adrian Grange committed
218
219
220
aomenc_av1_ivf() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf"
Adrian Grange's avatar
Adrian Grange committed
221
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
222
      --codec=av1 \
223
      --limit="${TEST_FRAMES}" \
224
      --ivf \
225
      --output="${output}"
226
227
228
229
230

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
231
232
233
  fi
}

Adrian Grange's avatar
Adrian Grange committed
234
235
aomenc_av1_webm() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
236
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
237
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Adrian Grange's avatar
Adrian Grange committed
238
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
239
      --codec=av1 \
240
      --limit="${TEST_FRAMES}" \
241
      --output="${output}"
242
243
244
245
246

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
247
248
249
  fi
}

Adrian Grange's avatar
Adrian Grange committed
250
251
aomenc_av1_webm_rt() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
Tom Finegan's avatar
Tom Finegan committed
252
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
253
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt.webm"
Adrian Grange's avatar
Adrian Grange committed
254
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
255
      $(aomenc_rt_params av1) \
256
      --output="${output}"
Tom Finegan's avatar
Tom Finegan committed
257
258
259
260
261
262
263
264

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
265
266
aomenc_av1_webm_rt_multithread_tiled() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
267
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
268
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt_multithread_tiled.webm"
269
270
271
272
273
274
275
    local readonly tilethread_min=2
    local readonly tilethread_max=4
    local readonly num_threads="$(seq ${tilethread_min} ${tilethread_max})"
    local readonly num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})"

    for threads in ${num_threads}; do
      for tile_cols in ${num_tile_cols}; do
Adrian Grange's avatar
Adrian Grange committed
276
        aomenc $(y4m_input_720p) \
Adrian Grange's avatar
Adrian Grange committed
277
          $(aomenc_rt_params av1) \
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
          --threads=${threads} \
          --tile-columns=${tile_cols} \
          --output="${output}"
      done
    done

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi

    rm "${output}"
  fi
}

Adrian Grange's avatar
Adrian Grange committed
293
294
aomenc_av1_webm_rt_multithread_tiled_frameparallel() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
295
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
296
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_rt_mt_t_fp.webm"
297
298
299
300
301
302
303
    local readonly tilethread_min=2
    local readonly tilethread_max=4
    local readonly num_threads="$(seq ${tilethread_min} ${tilethread_max})"
    local readonly num_tile_cols="$(seq ${tilethread_min} ${tilethread_max})"

    for threads in ${num_threads}; do
      for tile_cols in ${num_tile_cols}; do
Adrian Grange's avatar
Adrian Grange committed
304
        aomenc $(y4m_input_720p) \
Adrian Grange's avatar
Adrian Grange committed
305
          $(aomenc_rt_params av1) \
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
          --threads=${threads} \
          --tile-columns=${tile_cols} \
          --frame-parallel=1 \
          --output="${output}"
      done
    done

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi

    rm "${output}"
  fi
}

Adrian Grange's avatar
Adrian Grange committed
322
323
aomenc_av1_webm_2pass() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
324
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
325
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
Adrian Grange's avatar
Adrian Grange committed
326
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
327
      --codec=av1 \
328
329
      --limit="${TEST_FRAMES}" \
      --output="${output}" \
330
      --passes=2
331
332
333
334
335

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
336
337
338
  fi
}

Adrian Grange's avatar
Adrian Grange committed
339
340
341
aomenc_av1_ivf_lossless() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
Adrian Grange's avatar
Adrian Grange committed
342
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
343
      --codec=av1 \
344
345
346
      --limit="${TEST_FRAMES}" \
      --ivf \
      --output="${output}" \
347
      --lossless=1
348
349
350
351
352
353
354
355

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
356
357
358
aomenc_av1_ivf_minq0_maxq0() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
Adrian Grange's avatar
Adrian Grange committed
359
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
360
      --codec=av1 \
361
362
363
364
      --limit="${TEST_FRAMES}" \
      --ivf \
      --output="${output}" \
      --min-q=0 \
365
      --max-q=0
366
367
368
369
370

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
371
372
373
  fi
}

Adrian Grange's avatar
Adrian Grange committed
374
375
aomenc_av1_webm_lag10_frames20() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
376
377
378
     [ "$(webm_io_available)" = "yes" ]; then
    local readonly lag_total_frames=20
    local readonly lag_frames=10
Adrian Grange's avatar
Adrian Grange committed
379
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag10_frames20.webm"
Adrian Grange's avatar
Adrian Grange committed
380
    aomenc $(yuv_input_hantro_collage) \
Adrian Grange's avatar
Adrian Grange committed
381
      --codec=av1 \
382
383
384
385
      --limit="${lag_total_frames}" \
      --lag-in-frames="${lag_frames}" \
      --output="${output}" \
      --passes=2 \
386
      --auto-alt-ref=1
387
388
389
390
391
392
393
394

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

395
# TODO(fgalligan): Test that DisplayWidth is different than video width.
Adrian Grange's avatar
Adrian Grange committed
396
397
aomenc_av1_webm_non_square_par() {
  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
398
     [ "$(webm_io_available)" = "yes" ]; then
Adrian Grange's avatar
Adrian Grange committed
399
    local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
Adrian Grange's avatar
Adrian Grange committed
400
    aomenc $(y4m_input_non_square_par) \
Adrian Grange's avatar
Adrian Grange committed
401
      --codec=av1 \
402
403
404
405
406
407
408
409
410
411
      --limit="${TEST_FRAMES}" \
      --output="${output}"

    if [ ! -e "${output}" ]; then
      elog "Output file does not exist."
      return 1
    fi
  fi
}

Adrian Grange's avatar
Adrian Grange committed
412
413
414
415
416
417
aomenc_tests="aomenc_aom_ivf
              aomenc_aom_webm
              aomenc_aom_webm_rt
              aomenc_aom_webm_2pass
              aomenc_aom_webm_lag10_frames20
              aomenc_aom_ivf_piped_input
Adrian Grange's avatar
Adrian Grange committed
418
419
420
421
422
423
424
425
426
427
              aomenc_av1_ivf
              aomenc_av1_webm
              aomenc_av1_webm_rt
              aomenc_av1_webm_rt_multithread_tiled
              aomenc_av1_webm_rt_multithread_tiled_frameparallel
              aomenc_av1_webm_2pass
              aomenc_av1_ivf_lossless
              aomenc_av1_ivf_minq0_maxq0
              aomenc_av1_webm_lag10_frames20
              aomenc_av1_webm_non_square_par"
Adrian Grange's avatar
Adrian Grange committed
428
429

run_tests aomenc_verify_environment "${aomenc_tests}"