tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

aomdec.sh (7346B)


      1 #!/bin/sh
      2 ## Copyright (c) 2016, Alliance for Open Media. All rights reserved.
      3 ##
      4 ## This source code is subject to the terms of the BSD 2 Clause License and
      5 ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6 ## was not distributed with this source code in the LICENSE file, you can
      7 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8 ## Media Patent License 1.0 was not distributed with this source code in the
      9 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10 ##
     11 ## This file tests aomdec. To add new tests to this file, do the following:
     12 ##   1. Write a shell function (this is your test).
     13 ##   2. Add the function to aomdec_tests (on a new line).
     14 ##
     15 . $(dirname $0)/tools_common.sh
     16 
     17 AV1_MONOCHROME_B10="${LIBAOM_TEST_DATA_PATH}/av1-1-b10-24-monochrome.ivf"
     18 AV1_MONOCHROME_B8="${LIBAOM_TEST_DATA_PATH}/av1-1-b8-24-monochrome.ivf"
     19 
     20 # Environment check: Make sure input is available.
     21 aomdec_verify_environment() {
     22  if [ "$(av1_encode_available)" != "yes" ] ; then
     23    if [ ! -e "${AV1_IVF_FILE}" ] || \
     24       [ ! -e "${AV1_OBU_ANNEXB_FILE}" ] || \
     25       [ ! -e "${AV1_OBU_SEC5_FILE}" ] || \
     26       [ ! -e "${AV1_WEBM_FILE}" ] || \
     27       [ ! -e "${AV1_RAW_FILE}" ]; then
     28      elog "Libaom test data must exist before running this test script when " \
     29           " encoding is disabled. "
     30      return 1
     31    fi
     32  fi
     33  if [ ! -e "${AV1_MONOCHROME_B10}" ] || [ ! -e "${AV1_MONOCHROME_B8}" ]; then
     34    elog "Libaom test data must exist before running this test script."
     35  fi
     36  if [ -z "$(aom_tool_path aomdec)" ]; then
     37    elog "aomdec not found. It must exist in LIBAOM_BIN_PATH or its parent."
     38    return 1
     39  fi
     40 }
     41 
     42 # Wrapper function for running aomdec with pipe input. Requires that
     43 # LIBAOM_BIN_PATH points to the directory containing aomdec. $1 is used as the
     44 # input file path and shifted away. All remaining parameters are passed through
     45 # to aomdec.
     46 aomdec_pipe() {
     47  local input="$1"
     48  shift
     49  if [ ! -e "${input}" ]; then
     50    elog "Input file ($input) missing in aomdec_pipe()"
     51    return 1
     52  fi
     53  cat "${file}" | aomdec - "$@" ${devnull}
     54 }
     55 
     56 
     57 # Wrapper function for running aomdec. Requires that LIBAOM_BIN_PATH points to
     58 # the directory containing aomdec. $1 one is used as the input file path and
     59 # shifted away. All remaining parameters are passed through to aomdec.
     60 aomdec() {
     61  local decoder="$(aom_tool_path aomdec)"
     62  local input="$1"
     63  shift
     64  eval "${AOM_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull}
     65 }
     66 
     67 aomdec_can_decode_av1() {
     68  if [ "$(av1_decode_available)" = "yes" ]; then
     69    echo yes
     70  fi
     71 }
     72 
     73 aomdec_av1_ivf() {
     74  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
     75    local file="${AV1_IVF_FILE}"
     76    if [ ! -e "${file}" ]; then
     77      encode_yuv_raw_input_av1 "${file}" --ivf || return 1
     78    fi
     79    aomdec "${AV1_IVF_FILE}" --summary --noblit
     80  fi
     81 }
     82 
     83 aomdec_av1_ivf_error_resilient() {
     84  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
     85    local file="av1.error-resilient.ivf"
     86    if [ ! -e "${file}" ]; then
     87      encode_yuv_raw_input_av1 "${file}" --ivf --error-resilient=1 || return 1
     88    fi
     89    aomdec "${file}" --summary --noblit
     90  fi
     91 }
     92 
     93 ivf_multithread() {
     94  local row_mt="$1"
     95  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
     96    local file="${AV1_IVF_FILE}"
     97    if [ ! -e "${file}" ]; then
     98      encode_yuv_raw_input_av1 "${file}" --ivf || return 1
     99    fi
    100    for threads in 2 3 4 5 6 7 8; do
    101      aomdec "${file}" --summary --noblit --threads=$threads --row-mt=$row_mt \
    102        || return 1
    103    done
    104  fi
    105 }
    106 
    107 aomdec_av1_ivf_multithread() {
    108  ivf_multithread 0  # --row-mt=0
    109 }
    110 
    111 aomdec_av1_ivf_multithread_row_mt() {
    112  ivf_multithread 1  # --row-mt=1
    113 }
    114 
    115 aomdec_aom_ivf_pipe_input() {
    116  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    117    local file="${AV1_IVF_FILE}"
    118    if [ ! -e "${file}" ]; then
    119      encode_yuv_raw_input_av1 "${file}" --ivf || return 1
    120    fi
    121    aomdec_pipe "${AV1_IVF_FILE}" --summary --noblit
    122  fi
    123 }
    124 
    125 aomdec_av1_obu_annexb() {
    126  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    127    local file="${AV1_OBU_ANNEXB_FILE}"
    128    if [ ! -e "${file}" ]; then
    129      encode_yuv_raw_input_av1 "${file}" --obu --annexb=1 || return 1
    130    fi
    131    aomdec "${file}" --summary --noblit --annexb
    132  fi
    133 }
    134 
    135 aomdec_av1_obu_annexb_pipe_input() {
    136  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    137    local file="${AV1_OBU_ANNEXB_FILE}"
    138    if [ ! -e "${file}" ]; then
    139      encode_yuv_raw_input_av1 "${file}" --obu --annexb=1 || return 1
    140    fi
    141    aomdec_pipe "${file}" --summary --noblit --annexb
    142  fi
    143 }
    144 
    145 aomdec_av1_obu_section5() {
    146  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    147    local file="${AV1_OBU_SEC5_FILE}"
    148    if [ ! -e "${file}" ]; then
    149      encode_yuv_raw_input_av1 "${file}" --obu || return 1
    150    fi
    151    aomdec "${file}" --summary --noblit
    152  fi
    153 }
    154 
    155 aomdec_av1_obu_section5_pipe_input() {
    156  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    157    local file="${AV1_OBU_SEC5_FILE}"
    158    if [ ! -e "${file}" ]; then
    159      encode_yuv_raw_input_av1 "${file}" --obu || return 1
    160    fi
    161    aomdec_pipe "${file}" --summary --noblit
    162  fi
    163 }
    164 
    165 aomdec_av1_webm() {
    166  if [ "$(aomdec_can_decode_av1)" = "yes" ] && \
    167     [ "$(webm_io_available)" = "yes" ]; then
    168    local file="${AV1_WEBM_FILE}"
    169    if [ ! -e "${file}" ]; then
    170      encode_yuv_raw_input_av1 "${file}" || return 1
    171    fi
    172    aomdec "${AV1_WEBM_FILE}" --summary --noblit
    173  fi
    174 }
    175 
    176 aomdec_av1_monochrome_yuv() {
    177  if [ "$(aomdec_can_decode_av1)" = "yes" ]; then
    178    local input="$1"
    179    local basename="$(basename "${input}")"
    180    local output="${basename}-%wx%h-%4.i420"
    181    local md5file="${AOM_TEST_OUTPUT_DIR}/${basename}.md5"
    182    local decoder="$(aom_tool_path aomdec)"
    183    # Note aomdec() is not used to avoid ${devnull} which may also redirect
    184    # stdout.
    185    eval "${AOM_TEST_PREFIX}" "${decoder}" --md5 --i420 \
    186      -o "${output}" "${input}" ">" "${md5file}" 2>&1 || return 1
    187    diff "${1}.md5" "${md5file}"
    188  fi
    189 }
    190 
    191 aomdec_av1_monochrome_yuv_8bit() {
    192  aomdec_av1_monochrome_yuv "${AV1_MONOCHROME_B8}"
    193 }
    194 
    195 aomdec_av1_monochrome_yuv_10bit() {
    196  aomdec_av1_monochrome_yuv "${AV1_MONOCHROME_B10}"
    197 }
    198 
    199 # Ensures aomdec does not hang on a corrupted raw file
    200 aomdec_av1_rawfile() {
    201  if [ "$(aomdec_can_decode_av1)" = "yes"]; then
    202    local readonly decoder="$(aom_tool_path aomdec)"
    203    [ -x /usr/bin/timeout ] && local readonly TIMEOUT="/usr/bin/timeout 30s"
    204    ${TIMEOUT} ${AOM_TEST_PREFIX} "${decoder}" "${AV1_RAW_FILE}" -o /dev/null
    205    local readonly exit_status=$?
    206    # 124 exit status means aomdec timed out
    207    if [ "$exit_status" -eq 124 ]; then
    208      return 1
    209    fi
    210    return 0
    211  fi
    212 }
    213 
    214 aomdec_tests="aomdec_av1_ivf
    215              aomdec_av1_ivf_multithread
    216              aomdec_av1_ivf_multithread_row_mt
    217              aomdec_aom_ivf_pipe_input
    218              aomdec_av1_monochrome_yuv_8bit
    219              aomdec_av1_rawfile"
    220 
    221 if [ ! "$(realtime_only_build)" = "yes" ]; then
    222  aomdec_tests="${aomdec_tests}
    223                aomdec_av1_ivf_error_resilient
    224                aomdec_av1_obu_annexb
    225                aomdec_av1_obu_section5
    226                aomdec_av1_obu_annexb_pipe_input
    227                aomdec_av1_obu_section5_pipe_input
    228                aomdec_av1_webm"
    229 fi
    230 
    231 if [ "$(highbitdepth_available)" = "yes" ]; then
    232  aomdec_tests="${aomdec_tests}
    233                aomdec_av1_monochrome_yuv_10bit"
    234 fi
    235 
    236 run_tests aomdec_verify_environment "${aomdec_tests}"