mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 16:27:31 +09:00
Import aom library
This is the reference implementation for the Alliance for Open Media's av1 video code. The commit used was 4d668d7feb1f8abd809d1bca0418570a7f142a36.
This commit is contained in:
parent
eb8cd130a8
commit
edc8d83307
989 changed files with 470949 additions and 0 deletions
72
third_party/aom/tools/all_builds.py
vendored
Executable file
72
third_party/aom/tools/all_builds.py
vendored
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import getopt
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
LONG_OPTIONS = ["shard=", "shards="]
|
||||
BASE_COMMAND = "./configure --enable-internal-stats --enable-experimental"
|
||||
|
||||
def RunCommand(command):
|
||||
run = subprocess.Popen(command, shell=True)
|
||||
output = run.communicate()
|
||||
if run.returncode:
|
||||
print "Non-zero return code: " + str(run.returncode) + " => exiting!"
|
||||
sys.exit(1)
|
||||
|
||||
def list_of_experiments():
|
||||
experiments = []
|
||||
configure_file = open("configure")
|
||||
list_start = False
|
||||
for line in configure_file.read().split("\n"):
|
||||
if line == 'EXPERIMENT_LIST="':
|
||||
list_start = True
|
||||
elif line == '"':
|
||||
list_start = False
|
||||
elif list_start:
|
||||
currently_broken = ["csm"]
|
||||
experiment = line[4:]
|
||||
if experiment not in currently_broken:
|
||||
experiments.append(experiment)
|
||||
return experiments
|
||||
|
||||
def main(argv):
|
||||
# Parse arguments
|
||||
options = {"--shard": 0, "--shards": 1}
|
||||
if "--" in argv:
|
||||
opt_end_index = argv.index("--")
|
||||
else:
|
||||
opt_end_index = len(argv)
|
||||
try:
|
||||
o, _ = getopt.getopt(argv[1:opt_end_index], None, LONG_OPTIONS)
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
print "Usage: %s [--shard=<n> --shards=<n>] -- [configure flag ...]"%argv[0]
|
||||
sys.exit(2)
|
||||
|
||||
options.update(o)
|
||||
extra_args = argv[opt_end_index + 1:]
|
||||
|
||||
# Shard experiment list
|
||||
shard = int(options["--shard"])
|
||||
shards = int(options["--shards"])
|
||||
experiments = list_of_experiments()
|
||||
base_command = " ".join([BASE_COMMAND] + extra_args)
|
||||
configs = [base_command]
|
||||
configs += ["%s --enable-%s" % (base_command, e) for e in experiments]
|
||||
my_configs = zip(configs, range(len(configs)))
|
||||
my_configs = filter(lambda x: x[1] % shards == shard, my_configs)
|
||||
my_configs = [e[0] for e in my_configs]
|
||||
|
||||
# Run configs for this shard
|
||||
for config in my_configs:
|
||||
test_build(config)
|
||||
|
||||
def test_build(configure_command):
|
||||
print "\033[34m\033[47mTesting %s\033[0m" % (configure_command)
|
||||
RunCommand(configure_command)
|
||||
RunCommand("make clean")
|
||||
RunCommand("make")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
15
third_party/aom/tools/author_first_release.sh
vendored
Executable file
15
third_party/aom/tools/author_first_release.sh
vendored
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## List the release each author first contributed to.
|
||||
##
|
||||
## Usage: author_first_release.sh [TAGS]
|
||||
##
|
||||
## If the TAGS arguments are unspecified, all tags reported by `git tag`
|
||||
## will be considered.
|
||||
##
|
||||
tags=${@:-$(git tag)}
|
||||
for tag in $tags; do
|
||||
git shortlog -n -e -s $tag |
|
||||
cut -f2- |
|
||||
awk "{print \"${tag#v}\t\"\$0}"
|
||||
done | sort -k2 | uniq -f2
|
||||
16
third_party/aom/tools/build_inspector.sh
vendored
Executable file
16
third_party/aom/tools/build_inspector.sh
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
if ! [ -x "$(command -v emcc)" ] || ! [ -x "$(command -v emconfigure)" ] || ! [ -x "$(command -v emmake)" ]; then
|
||||
echo 'Emscripten SDK is not available (emcc, emconfigure or emmake is missing). Install it from https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html and try again.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 'Building JS Inspector'
|
||||
if [ ! -d ".inspect" ]; then
|
||||
mkdir .inspect
|
||||
cd .inspect && emconfigure ../../configure --disable-multithread --disable-runtime-cpu-detect --target=generic-gnu --enable-accounting --enable-inspection --enable-aom_highbitdepth --extra-cflags="-D_POSIX_SOURCE"
|
||||
fi
|
||||
|
||||
cd .inspect
|
||||
emmake make -j 8
|
||||
cp examples/inspect inspect.bc
|
||||
emcc -O3 inspect.bc -o inspect.js -s TOTAL_MEMORY=134217728 -s MODULARIZE=1 -s EXPORT_NAME="'DecoderModule'" --post-js "../inspect-post.js" --memory-init-file 0
|
||||
cp inspect.js ../inspect.js
|
||||
4756
third_party/aom/tools/cpplint.py
vendored
Executable file
4756
third_party/aom/tools/cpplint.py
vendored
Executable file
File diff suppressed because it is too large
Load diff
132
third_party/aom/tools/diff.py
vendored
Normal file
132
third_party/aom/tools/diff.py
vendored
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env python
|
||||
##
|
||||
## Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
##
|
||||
## This source code is subject to the terms of the BSD 2 Clause License and
|
||||
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
## was not distributed with this source code in the LICENSE file, you can
|
||||
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
## Media Patent License 1.0 was not distributed with this source code in the
|
||||
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
##
|
||||
"""Classes for representing diff pieces."""
|
||||
|
||||
__author__ = "jkoleszar@google.com"
|
||||
|
||||
import re
|
||||
|
||||
|
||||
class DiffLines(object):
|
||||
"""A container for one half of a diff."""
|
||||
|
||||
def __init__(self, filename, offset, length):
|
||||
self.filename = filename
|
||||
self.offset = offset
|
||||
self.length = length
|
||||
self.lines = []
|
||||
self.delta_line_nums = []
|
||||
|
||||
def Append(self, line):
|
||||
l = len(self.lines)
|
||||
if line[0] != " ":
|
||||
self.delta_line_nums.append(self.offset + l)
|
||||
self.lines.append(line[1:])
|
||||
assert l+1 <= self.length
|
||||
|
||||
def Complete(self):
|
||||
return len(self.lines) == self.length
|
||||
|
||||
def __contains__(self, item):
|
||||
return item >= self.offset and item <= self.offset + self.length - 1
|
||||
|
||||
|
||||
class DiffHunk(object):
|
||||
"""A container for one diff hunk, consisting of two DiffLines."""
|
||||
|
||||
def __init__(self, header, file_a, file_b, start_a, len_a, start_b, len_b):
|
||||
self.header = header
|
||||
self.left = DiffLines(file_a, start_a, len_a)
|
||||
self.right = DiffLines(file_b, start_b, len_b)
|
||||
self.lines = []
|
||||
|
||||
def Append(self, line):
|
||||
"""Adds a line to the DiffHunk and its DiffLines children."""
|
||||
if line[0] == "-":
|
||||
self.left.Append(line)
|
||||
elif line[0] == "+":
|
||||
self.right.Append(line)
|
||||
elif line[0] == " ":
|
||||
self.left.Append(line)
|
||||
self.right.Append(line)
|
||||
elif line[0] == "\\":
|
||||
# Ignore newline messages from git diff.
|
||||
pass
|
||||
else:
|
||||
assert False, ("Unrecognized character at start of diff line "
|
||||
"%r" % line[0])
|
||||
self.lines.append(line)
|
||||
|
||||
def Complete(self):
|
||||
return self.left.Complete() and self.right.Complete()
|
||||
|
||||
def __repr__(self):
|
||||
return "DiffHunk(%s, %s, len %d)" % (
|
||||
self.left.filename, self.right.filename,
|
||||
max(self.left.length, self.right.length))
|
||||
|
||||
|
||||
def ParseDiffHunks(stream):
|
||||
"""Walk a file-like object, yielding DiffHunks as they're parsed."""
|
||||
|
||||
file_regex = re.compile(r"(\+\+\+|---) (\S+)")
|
||||
range_regex = re.compile(r"@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))?")
|
||||
hunk = None
|
||||
while True:
|
||||
line = stream.readline()
|
||||
if not line:
|
||||
break
|
||||
|
||||
if hunk is None:
|
||||
# Parse file names
|
||||
diff_file = file_regex.match(line)
|
||||
if diff_file:
|
||||
if line.startswith("---"):
|
||||
a_line = line
|
||||
a = diff_file.group(2)
|
||||
continue
|
||||
if line.startswith("+++"):
|
||||
b_line = line
|
||||
b = diff_file.group(2)
|
||||
continue
|
||||
|
||||
# Parse offset/lengths
|
||||
diffrange = range_regex.match(line)
|
||||
if diffrange:
|
||||
if diffrange.group(2):
|
||||
start_a = int(diffrange.group(1))
|
||||
len_a = int(diffrange.group(3))
|
||||
else:
|
||||
start_a = 1
|
||||
len_a = int(diffrange.group(1))
|
||||
|
||||
if diffrange.group(5):
|
||||
start_b = int(diffrange.group(4))
|
||||
len_b = int(diffrange.group(6))
|
||||
else:
|
||||
start_b = 1
|
||||
len_b = int(diffrange.group(4))
|
||||
|
||||
header = [a_line, b_line, line]
|
||||
hunk = DiffHunk(header, a, b, start_a, len_a, start_b, len_b)
|
||||
else:
|
||||
# Add the current line to the hunk
|
||||
hunk.Append(line)
|
||||
|
||||
# See if the whole hunk has been parsed. If so, yield it and prepare
|
||||
# for the next hunk.
|
||||
if hunk.Complete():
|
||||
yield hunk
|
||||
hunk = None
|
||||
|
||||
# Partial hunks are a parse error
|
||||
assert hunk is None
|
||||
158
third_party/aom/tools/ftfy.sh
vendored
Executable file
158
third_party/aom/tools/ftfy.sh
vendored
Executable file
|
|
@ -0,0 +1,158 @@
|
|||
#!/bin/sh
|
||||
self="$0"
|
||||
dirname_self=$(dirname "$self")
|
||||
|
||||
usage() {
|
||||
cat <<EOF >&2
|
||||
Usage: $self [option]
|
||||
|
||||
This script applies a whitespace transformation to the commit at HEAD. If no
|
||||
options are given, then the modified files are left in the working tree.
|
||||
|
||||
Options:
|
||||
-h, --help Shows this message
|
||||
-n, --dry-run Shows a diff of the changes to be made.
|
||||
--amend Squashes the changes into the commit at HEAD
|
||||
This option will also reformat the commit message.
|
||||
--commit Creates a new commit containing only the whitespace changes
|
||||
--msg-only Reformat the commit message only, ignore the patch itself.
|
||||
|
||||
EOF
|
||||
rm -f ${CLEAN_FILES}
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
log() {
|
||||
echo "${self##*/}: $@" >&2
|
||||
}
|
||||
|
||||
|
||||
aom_style() {
|
||||
for f; do
|
||||
case "$f" in
|
||||
*.h|*.c|*.cc)
|
||||
clang-format -i --style=file "$f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
apply() {
|
||||
[ $INTERSECT_RESULT -ne 0 ] && patch -p1 < "$1"
|
||||
}
|
||||
|
||||
|
||||
commit() {
|
||||
LAST_CHANGEID=$(git show | awk '/Change-Id:/{print $2}')
|
||||
if [ -z "$LAST_CHANGEID" ]; then
|
||||
log "HEAD doesn't have a Change-Id, unable to generate a new commit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build a deterministic Change-Id from the parent's
|
||||
NEW_CHANGEID=${LAST_CHANGEID}-styled
|
||||
NEW_CHANGEID=I$(echo $NEW_CHANGEID | git hash-object --stdin)
|
||||
|
||||
# Commit, preserving authorship from the parent commit.
|
||||
git commit -a -C HEAD > /dev/null
|
||||
git commit --amend -F- << EOF
|
||||
Cosmetic: Fix whitespace in change ${LAST_CHANGEID:0:9}
|
||||
|
||||
Change-Id: ${NEW_CHANGEID}
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
show_commit_msg_diff() {
|
||||
if [ $DIFF_MSG_RESULT -ne 0 ]; then
|
||||
log "Modified commit message:"
|
||||
diff -u "$ORIG_COMMIT_MSG" "$NEW_COMMIT_MSG" | tail -n +3
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
amend() {
|
||||
show_commit_msg_diff
|
||||
if [ $DIFF_MSG_RESULT -ne 0 ] || [ $INTERSECT_RESULT -ne 0 ]; then
|
||||
git commit -a --amend -F "$NEW_COMMIT_MSG"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
diff_msg() {
|
||||
git log -1 --format=%B > "$ORIG_COMMIT_MSG"
|
||||
"${dirname_self}"/wrap-commit-msg.py \
|
||||
< "$ORIG_COMMIT_MSG" > "$NEW_COMMIT_MSG"
|
||||
cmp -s "$ORIG_COMMIT_MSG" "$NEW_COMMIT_MSG"
|
||||
DIFF_MSG_RESULT=$?
|
||||
}
|
||||
|
||||
|
||||
# Temporary files
|
||||
ORIG_DIFF=orig.diff.$$
|
||||
MODIFIED_DIFF=modified.diff.$$
|
||||
FINAL_DIFF=final.diff.$$
|
||||
ORIG_COMMIT_MSG=orig.commit-msg.$$
|
||||
NEW_COMMIT_MSG=new.commit-msg.$$
|
||||
CLEAN_FILES="${ORIG_DIFF} ${MODIFIED_DIFF} ${FINAL_DIFF}"
|
||||
CLEAN_FILES="${CLEAN_FILES} ${ORIG_COMMIT_MSG} ${NEW_COMMIT_MSG}"
|
||||
|
||||
# Preconditions
|
||||
[ $# -lt 2 ] || usage
|
||||
|
||||
if ! clang-format -version >/dev/null 2>&1; then
|
||||
log "clang-format not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git diff --quiet HEAD; then
|
||||
log "Working tree is dirty, commit your changes first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Need to be in the root
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
# Collect the original diff
|
||||
git show > "${ORIG_DIFF}"
|
||||
|
||||
# Apply the style guide on new and modified files and collect its diff
|
||||
for f in $(git diff HEAD^ --name-only -M90 --diff-filter=AM); do
|
||||
case "$f" in
|
||||
third_party/*) continue;;
|
||||
esac
|
||||
aom_style "$f"
|
||||
done
|
||||
git diff --no-color --no-ext-diff > "${MODIFIED_DIFF}"
|
||||
|
||||
# Intersect the two diffs
|
||||
"${dirname_self}"/intersect-diffs.py \
|
||||
"${ORIG_DIFF}" "${MODIFIED_DIFF}" > "${FINAL_DIFF}"
|
||||
INTERSECT_RESULT=$?
|
||||
git reset --hard >/dev/null
|
||||
|
||||
# Fixup the commit message
|
||||
diff_msg
|
||||
|
||||
# Handle options
|
||||
if [ -n "$1" ]; then
|
||||
case "$1" in
|
||||
-h|--help) usage;;
|
||||
-n|--dry-run) cat "${FINAL_DIFF}"; show_commit_msg_diff;;
|
||||
--commit) apply "${FINAL_DIFF}"; commit;;
|
||||
--amend) apply "${FINAL_DIFF}"; amend;;
|
||||
--msg-only) amend;;
|
||||
*) usage;;
|
||||
esac
|
||||
else
|
||||
apply "${FINAL_DIFF}"
|
||||
if ! git diff --quiet; then
|
||||
log "Formatting changes applied, verify and commit."
|
||||
log "See also: http://www.webmproject.org/code/contribute/conventions/"
|
||||
git diff --stat
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f ${CLEAN_FILES}
|
||||
10
third_party/aom/tools/gen_authors.sh
vendored
Executable file
10
third_party/aom/tools/gen_authors.sh
vendored
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Add organization names manually.
|
||||
|
||||
cat <<EOF
|
||||
# This file is automatically generated from the git commit history
|
||||
# by tools/gen_authors.sh.
|
||||
|
||||
$(git log --pretty=format:"%aN <%aE>" | sort | uniq | grep -v "corp.google\|clang-format")
|
||||
EOF
|
||||
120
third_party/aom/tools/gen_constrained_tokenset.py
vendored
Executable file
120
third_party/aom/tools/gen_constrained_tokenset.py
vendored
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
#!/usr/bin/python
|
||||
##
|
||||
## Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
##
|
||||
## This source code is subject to the terms of the BSD 2 Clause License and
|
||||
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
## was not distributed with this source code in the LICENSE file, you can
|
||||
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
## Media Patent License 1.0 was not distributed with this source code in the
|
||||
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
##
|
||||
"""Generate the probability model for the constrained token set.
|
||||
|
||||
Model obtained from a 2-sided zero-centered distribution derived
|
||||
from a Pareto distribution. The cdf of the distribution is:
|
||||
cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta]
|
||||
|
||||
For a given beta and a given probability of the 1-node, the alpha
|
||||
is first solved, and then the {alpha, beta} pair is used to generate
|
||||
the probabilities for the rest of the nodes.
|
||||
"""
|
||||
|
||||
import heapq
|
||||
import sys
|
||||
import numpy as np
|
||||
import scipy.optimize
|
||||
import scipy.stats
|
||||
|
||||
|
||||
def cdf_spareto(x, xm, beta):
|
||||
p = 1 - (xm / (np.abs(x) + xm))**beta
|
||||
p = 0.5 + 0.5 * np.sign(x) * p
|
||||
return p
|
||||
|
||||
|
||||
def get_spareto(p, beta):
|
||||
cdf = cdf_spareto
|
||||
|
||||
def func(x):
|
||||
return ((cdf(1.5, x, beta) - cdf(0.5, x, beta)) /
|
||||
(1 - cdf(0.5, x, beta)) - p)**2
|
||||
|
||||
alpha = scipy.optimize.fminbound(func, 1e-12, 10000, xtol=1e-12)
|
||||
parray = np.zeros(11)
|
||||
parray[0] = 2 * (cdf(0.5, alpha, beta) - 0.5)
|
||||
parray[1] = (2 * (cdf(1.5, alpha, beta) - cdf(0.5, alpha, beta)))
|
||||
parray[2] = (2 * (cdf(2.5, alpha, beta) - cdf(1.5, alpha, beta)))
|
||||
parray[3] = (2 * (cdf(3.5, alpha, beta) - cdf(2.5, alpha, beta)))
|
||||
parray[4] = (2 * (cdf(4.5, alpha, beta) - cdf(3.5, alpha, beta)))
|
||||
parray[5] = (2 * (cdf(6.5, alpha, beta) - cdf(4.5, alpha, beta)))
|
||||
parray[6] = (2 * (cdf(10.5, alpha, beta) - cdf(6.5, alpha, beta)))
|
||||
parray[7] = (2 * (cdf(18.5, alpha, beta) - cdf(10.5, alpha, beta)))
|
||||
parray[8] = (2 * (cdf(34.5, alpha, beta) - cdf(18.5, alpha, beta)))
|
||||
parray[9] = (2 * (cdf(66.5, alpha, beta) - cdf(34.5, alpha, beta)))
|
||||
parray[10] = 2 * (1. - cdf(66.5, alpha, beta))
|
||||
return parray
|
||||
|
||||
|
||||
def quantize_probs(p, save_first_bin, bits):
|
||||
"""Quantize probability precisely.
|
||||
|
||||
Quantize probabilities minimizing dH (Kullback-Leibler divergence)
|
||||
approximated by: sum (p_i-q_i)^2/p_i.
|
||||
References:
|
||||
https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
|
||||
https://github.com/JarekDuda/AsymmetricNumeralSystemsToolkit
|
||||
"""
|
||||
num_sym = p.size
|
||||
p = np.clip(p, 1e-16, 1)
|
||||
L = 2**bits
|
||||
pL = p * L
|
||||
ip = 1. / p # inverse probability
|
||||
q = np.clip(np.round(pL), 1, L + 1 - num_sym)
|
||||
quant_err = (pL - q)**2 * ip
|
||||
sgn = np.sign(L - q.sum()) # direction of correction
|
||||
if sgn != 0: # correction is needed
|
||||
v = [] # heap of adjustment results (adjustment err, index) of each symbol
|
||||
for i in range(1 if save_first_bin else 0, num_sym):
|
||||
q_adj = q[i] + sgn
|
||||
if q_adj > 0 and q_adj < L:
|
||||
adj_err = (pL[i] - q_adj)**2 * ip[i] - quant_err[i]
|
||||
heapq.heappush(v, (adj_err, i))
|
||||
while q.sum() != L:
|
||||
# apply lowest error adjustment
|
||||
(adj_err, i) = heapq.heappop(v)
|
||||
quant_err[i] += adj_err
|
||||
q[i] += sgn
|
||||
# calculate the cost of adjusting this symbol again
|
||||
q_adj = q[i] + sgn
|
||||
if q_adj > 0 and q_adj < L:
|
||||
adj_err = (pL[i] - q_adj)**2 * ip[i] - quant_err[i]
|
||||
heapq.heappush(v, (adj_err, i))
|
||||
return q
|
||||
|
||||
|
||||
def get_quantized_spareto(p, beta, bits, first_token):
|
||||
parray = get_spareto(p, beta)
|
||||
parray = parray[1:] / (1 - parray[0])
|
||||
# CONFIG_NEW_TOKENSET
|
||||
if first_token > 1:
|
||||
parray = parray[1:] / (1 - parray[0])
|
||||
qarray = quantize_probs(parray, first_token == 1, bits)
|
||||
return qarray.astype(np.int)
|
||||
|
||||
|
||||
def main(bits=15, first_token=1):
|
||||
beta = 8
|
||||
for q in range(1, 256):
|
||||
parray = get_quantized_spareto(q / 256., beta, bits, first_token)
|
||||
assert parray.sum() == 2**bits
|
||||
print '{', ', '.join('%d' % i for i in parray), '},'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 2:
|
||||
main(int(sys.argv[1]), int(sys.argv[2]))
|
||||
elif len(sys.argv) > 1:
|
||||
main(int(sys.argv[1]))
|
||||
else:
|
||||
main()
|
||||
39
third_party/aom/tools/inspect-cli.js
vendored
Normal file
39
third_party/aom/tools/inspect-cli.js
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* This tool lets you test if the compiled Javascript decoder is functioning properly. You'll
|
||||
* need to download a SpiderMonkey js-shell to run this script.
|
||||
* https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/
|
||||
*
|
||||
* Example:
|
||||
* js-shell inspect-cli.js video.ivf
|
||||
*/
|
||||
load("inspect.js");
|
||||
var buffer = read(scriptArgs[0], "binary");
|
||||
var Module = {
|
||||
noExitRuntime: true,
|
||||
noInitialRun: true,
|
||||
preInit: [],
|
||||
preRun: [],
|
||||
postRun: [function () {
|
||||
printErr(`Loaded Javascript Decoder OK`);
|
||||
}],
|
||||
memoryInitializerPrefixURL: "bin/",
|
||||
arguments: ['input.ivf', 'output.raw'],
|
||||
on_frame_decoded_json: function (jsonString) {
|
||||
let json = JSON.parse("[" + Module.UTF8ToString(jsonString) + "null]");
|
||||
json.forEach(frame => {
|
||||
if (frame) {
|
||||
print(frame.frame);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
DecoderModule(Module);
|
||||
Module.FS.writeFile("/tmp/input.ivf", buffer, { encoding: "binary" });
|
||||
Module._open_file();
|
||||
Module._set_layers(0xFFFFFFFF); // Set this to zero if you want to benchmark decoding.
|
||||
while(true) {
|
||||
printErr("Decoding Frame ...");
|
||||
if (Module._read_frame()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
1
third_party/aom/tools/inspect-post.js
vendored
Normal file
1
third_party/aom/tools/inspect-post.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
Module["FS"] = FS;
|
||||
78
third_party/aom/tools/intersect-diffs.py
vendored
Executable file
78
third_party/aom/tools/intersect-diffs.py
vendored
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python
|
||||
##
|
||||
## Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
##
|
||||
## This source code is subject to the terms of the BSD 2 Clause License and
|
||||
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
## was not distributed with this source code in the LICENSE file, you can
|
||||
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
## Media Patent License 1.0 was not distributed with this source code in the
|
||||
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
##
|
||||
"""Calculates the "intersection" of two unified diffs.
|
||||
|
||||
Given two diffs, A and B, it finds all hunks in B that had non-context lines
|
||||
in A and prints them to stdout. This is useful to determine the hunks in B that
|
||||
are relevant to A. The resulting file can be applied with patch(1) on top of A.
|
||||
"""
|
||||
|
||||
__author__ = "jkoleszar@google.com"
|
||||
|
||||
import sys
|
||||
|
||||
import diff
|
||||
|
||||
|
||||
def FormatDiffHunks(hunks):
|
||||
"""Re-serialize a list of DiffHunks."""
|
||||
r = []
|
||||
last_header = None
|
||||
for hunk in hunks:
|
||||
this_header = hunk.header[0:2]
|
||||
if last_header != this_header:
|
||||
r.extend(hunk.header)
|
||||
last_header = this_header
|
||||
else:
|
||||
r.extend(hunk.header[2])
|
||||
r.extend(hunk.lines)
|
||||
r.append("\n")
|
||||
return "".join(r)
|
||||
|
||||
|
||||
def ZipHunks(rhs_hunks, lhs_hunks):
|
||||
"""Join two hunk lists on filename."""
|
||||
for rhs_hunk in rhs_hunks:
|
||||
rhs_file = rhs_hunk.right.filename.split("/")[1:]
|
||||
|
||||
for lhs_hunk in lhs_hunks:
|
||||
lhs_file = lhs_hunk.left.filename.split("/")[1:]
|
||||
if lhs_file != rhs_file:
|
||||
continue
|
||||
yield (rhs_hunk, lhs_hunk)
|
||||
|
||||
|
||||
def main():
|
||||
old_hunks = [x for x in diff.ParseDiffHunks(open(sys.argv[1], "r"))]
|
||||
new_hunks = [x for x in diff.ParseDiffHunks(open(sys.argv[2], "r"))]
|
||||
out_hunks = []
|
||||
|
||||
# Join the right hand side of the older diff with the left hand side of the
|
||||
# newer diff.
|
||||
for old_hunk, new_hunk in ZipHunks(old_hunks, new_hunks):
|
||||
if new_hunk in out_hunks:
|
||||
continue
|
||||
old_lines = old_hunk.right
|
||||
new_lines = new_hunk.left
|
||||
|
||||
# Determine if this hunk overlaps any non-context line from the other
|
||||
for i in old_lines.delta_line_nums:
|
||||
if i in new_lines:
|
||||
out_hunks.append(new_hunk)
|
||||
break
|
||||
|
||||
if out_hunks:
|
||||
print FormatDiffHunks(out_hunks)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
146
third_party/aom/tools/lint-hunks.py
vendored
Executable file
146
third_party/aom/tools/lint-hunks.py
vendored
Executable file
|
|
@ -0,0 +1,146 @@
|
|||
#!/usr/bin/python
|
||||
##
|
||||
## Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
##
|
||||
## This source code is subject to the terms of the BSD 2 Clause License and
|
||||
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
## was not distributed with this source code in the LICENSE file, you can
|
||||
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
## Media Patent License 1.0 was not distributed with this source code in the
|
||||
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
##
|
||||
"""Performs style checking on each diff hunk."""
|
||||
import getopt
|
||||
import os
|
||||
import StringIO
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import diff
|
||||
|
||||
|
||||
SHORT_OPTIONS = "h"
|
||||
LONG_OPTIONS = ["help"]
|
||||
|
||||
TOPLEVEL_CMD = ["git", "rev-parse", "--show-toplevel"]
|
||||
DIFF_CMD = ["git", "diff"]
|
||||
DIFF_INDEX_CMD = ["git", "diff-index", "-u", "HEAD", "--"]
|
||||
SHOW_CMD = ["git", "show"]
|
||||
CPPLINT_FILTERS = ["-readability/casting"]
|
||||
|
||||
|
||||
class Usage(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class SubprocessException(Exception):
|
||||
def __init__(self, args):
|
||||
msg = "Failed to execute '%s'"%(" ".join(args))
|
||||
super(SubprocessException, self).__init__(msg)
|
||||
|
||||
|
||||
class Subprocess(subprocess.Popen):
|
||||
"""Adds the notion of an expected returncode to Popen."""
|
||||
|
||||
def __init__(self, args, expected_returncode=0, **kwargs):
|
||||
self._args = args
|
||||
self._expected_returncode = expected_returncode
|
||||
super(Subprocess, self).__init__(args, **kwargs)
|
||||
|
||||
def communicate(self, *args, **kwargs):
|
||||
result = super(Subprocess, self).communicate(*args, **kwargs)
|
||||
if self._expected_returncode is not None:
|
||||
try:
|
||||
ok = self.returncode in self._expected_returncode
|
||||
except TypeError:
|
||||
ok = self.returncode == self._expected_returncode
|
||||
if not ok:
|
||||
raise SubprocessException(self._args)
|
||||
return result
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], SHORT_OPTIONS, LONG_OPTIONS)
|
||||
except getopt.error, msg:
|
||||
raise Usage(msg)
|
||||
|
||||
# process options
|
||||
for o, _ in opts:
|
||||
if o in ("-h", "--help"):
|
||||
print __doc__
|
||||
sys.exit(0)
|
||||
|
||||
if args and len(args) > 1:
|
||||
print __doc__
|
||||
sys.exit(0)
|
||||
|
||||
# Find the fully qualified path to the root of the tree
|
||||
tl = Subprocess(TOPLEVEL_CMD, stdout=subprocess.PIPE)
|
||||
tl = tl.communicate()[0].strip()
|
||||
|
||||
# See if we're working on the index or not.
|
||||
if args:
|
||||
diff_cmd = DIFF_CMD + [args[0] + "^!"]
|
||||
else:
|
||||
diff_cmd = DIFF_INDEX_CMD
|
||||
|
||||
# Build the command line to execute cpplint
|
||||
cpplint_cmd = [os.path.join(tl, "tools", "cpplint.py"),
|
||||
"--filter=" + ",".join(CPPLINT_FILTERS),
|
||||
"-"]
|
||||
|
||||
# Get a list of all affected lines
|
||||
file_affected_line_map = {}
|
||||
p = Subprocess(diff_cmd, stdout=subprocess.PIPE)
|
||||
stdout = p.communicate()[0]
|
||||
for hunk in diff.ParseDiffHunks(StringIO.StringIO(stdout)):
|
||||
filename = hunk.right.filename[2:]
|
||||
if filename not in file_affected_line_map:
|
||||
file_affected_line_map[filename] = set()
|
||||
file_affected_line_map[filename].update(hunk.right.delta_line_nums)
|
||||
|
||||
# Run each affected file through cpplint
|
||||
lint_failed = False
|
||||
for filename, affected_lines in file_affected_line_map.iteritems():
|
||||
if filename.split(".")[-1] not in ("c", "h", "cc"):
|
||||
continue
|
||||
|
||||
if args:
|
||||
# File contents come from git
|
||||
show_cmd = SHOW_CMD + [args[0] + ":" + filename]
|
||||
show = Subprocess(show_cmd, stdout=subprocess.PIPE)
|
||||
lint = Subprocess(cpplint_cmd, expected_returncode=(0, 1),
|
||||
stdin=show.stdout, stderr=subprocess.PIPE)
|
||||
lint_out = lint.communicate()[1]
|
||||
else:
|
||||
# File contents come from the working tree
|
||||
lint = Subprocess(cpplint_cmd, expected_returncode=(0, 1),
|
||||
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdin = open(os.path.join(tl, filename)).read()
|
||||
lint_out = lint.communicate(stdin)[1]
|
||||
|
||||
for line in lint_out.split("\n"):
|
||||
fields = line.split(":")
|
||||
if fields[0] != "-":
|
||||
continue
|
||||
warning_line_num = int(fields[1])
|
||||
if warning_line_num in affected_lines:
|
||||
print "%s:%d:%s"%(filename, warning_line_num,
|
||||
":".join(fields[2:]))
|
||||
lint_failed = True
|
||||
|
||||
# Set exit code if any relevant lint errors seen
|
||||
if lint_failed:
|
||||
return 1
|
||||
|
||||
except Usage, err:
|
||||
print >>sys.stderr, err
|
||||
print >>sys.stderr, "for help use --help"
|
||||
return 2
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
72
third_party/aom/tools/wrap-commit-msg.py
vendored
Executable file
72
third_party/aom/tools/wrap-commit-msg.py
vendored
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python
|
||||
##
|
||||
## Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
##
|
||||
## This source code is subject to the terms of the BSD 2 Clause License and
|
||||
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
## was not distributed with this source code in the LICENSE file, you can
|
||||
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
## Media Patent License 1.0 was not distributed with this source code in the
|
||||
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
##
|
||||
"""Wraps paragraphs of text, preserving manual formatting
|
||||
|
||||
This is like fold(1), but has the special convention of not modifying lines
|
||||
that start with whitespace. This allows you to intersperse blocks with
|
||||
special formatting, like code blocks, with written prose. The prose will
|
||||
be wordwrapped, and the manual formatting will be preserved.
|
||||
|
||||
* This won't handle the case of a bulleted (or ordered) list specially, so
|
||||
manual wrapping must be done.
|
||||
|
||||
Occasionally it's useful to put something with explicit formatting that
|
||||
doesn't look at all like a block of text inline.
|
||||
|
||||
indicator = has_leading_whitespace(line);
|
||||
if (indicator)
|
||||
preserve_formatting(line);
|
||||
|
||||
The intent is that this docstring would make it through the transform
|
||||
and still be legible and presented as it is in the source. If additional
|
||||
cases are handled, update this doc to describe the effect.
|
||||
"""
|
||||
|
||||
__author__ = "jkoleszar@google.com"
|
||||
import textwrap
|
||||
import sys
|
||||
|
||||
def wrap(text):
|
||||
if text:
|
||||
return textwrap.fill(text, break_long_words=False) + '\n'
|
||||
return ""
|
||||
|
||||
|
||||
def main(fileobj):
|
||||
text = ""
|
||||
output = ""
|
||||
while True:
|
||||
line = fileobj.readline()
|
||||
if not line:
|
||||
break
|
||||
|
||||
if line.lstrip() == line:
|
||||
text += line
|
||||
else:
|
||||
output += wrap(text)
|
||||
text=""
|
||||
output += line
|
||||
output += wrap(text)
|
||||
|
||||
# Replace the file or write to stdout.
|
||||
if fileobj == sys.stdin:
|
||||
fileobj = sys.stdout
|
||||
else:
|
||||
fileobj.seek(0)
|
||||
fileobj.truncate(0)
|
||||
fileobj.write(output)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
main(open(sys.argv[1], "r+"))
|
||||
else:
|
||||
main(sys.stdin)
|
||||
Loading…
Add table
Add a link
Reference in a new issue