Merge branch 'vp9-preview' of review:webm/libvpx
Merge the vp9-preview branch into master. Change-Id: If700b9054676f24bed9deb59050af546c1ca5296
This commit is contained in:
commit
16810c10c1
371
args.c
371
args.c
@ -25,241 +25,214 @@ extern void die(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
|
||||
struct arg arg_init(char **argv)
|
||||
{
|
||||
struct arg a;
|
||||
struct arg arg_init(char **argv) {
|
||||
struct arg a;
|
||||
|
||||
a.argv = argv;
|
||||
a.argv_step = 1;
|
||||
a.name = NULL;
|
||||
a.val = NULL;
|
||||
a.def = NULL;
|
||||
return a;
|
||||
a.argv = argv;
|
||||
a.argv_step = 1;
|
||||
a.name = NULL;
|
||||
a.val = NULL;
|
||||
a.def = NULL;
|
||||
return a;
|
||||
}
|
||||
|
||||
int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
|
||||
{
|
||||
struct arg arg;
|
||||
int arg_match(struct arg *arg_, const struct arg_def *def, char **argv) {
|
||||
struct arg arg;
|
||||
|
||||
if (!argv[0] || argv[0][0] != '-')
|
||||
return 0;
|
||||
if (!argv[0] || argv[0][0] != '-')
|
||||
return 0;
|
||||
|
||||
arg = arg_init(argv);
|
||||
arg = arg_init(argv);
|
||||
|
||||
if (def->short_name
|
||||
&& strlen(arg.argv[0]) == strlen(def->short_name) + 1
|
||||
&& !strcmp(arg.argv[0] + 1, def->short_name))
|
||||
{
|
||||
if (def->short_name
|
||||
&& strlen(arg.argv[0]) == strlen(def->short_name) + 1
|
||||
&& !strcmp(arg.argv[0] + 1, def->short_name)) {
|
||||
|
||||
arg.name = arg.argv[0] + 1;
|
||||
arg.val = def->has_val ? arg.argv[1] : NULL;
|
||||
arg.argv_step = def->has_val ? 2 : 1;
|
||||
arg.name = arg.argv[0] + 1;
|
||||
arg.val = def->has_val ? arg.argv[1] : NULL;
|
||||
arg.argv_step = def->has_val ? 2 : 1;
|
||||
} else if (def->long_name) {
|
||||
const size_t name_len = strlen(def->long_name);
|
||||
|
||||
if (strlen(arg.argv[0]) >= name_len + 2
|
||||
&& arg.argv[0][1] == '-'
|
||||
&& !strncmp(arg.argv[0] + 2, def->long_name, name_len)
|
||||
&& (arg.argv[0][name_len + 2] == '='
|
||||
|| arg.argv[0][name_len + 2] == '\0')) {
|
||||
|
||||
arg.name = arg.argv[0] + 2;
|
||||
arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
|
||||
arg.argv_step = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.name && !arg.val && def->has_val)
|
||||
die("Error: option %s requires argument.\n", arg.name);
|
||||
|
||||
if (arg.name && arg.val && !def->has_val)
|
||||
die("Error: option %s requires no argument.\n", arg.name);
|
||||
|
||||
if (arg.name
|
||||
&& (arg.val || !def->has_val)) {
|
||||
arg.def = def;
|
||||
*arg_ = arg;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char *arg_next(struct arg *arg) {
|
||||
if (arg->argv[0])
|
||||
arg->argv += arg->argv_step;
|
||||
|
||||
return *arg->argv;
|
||||
}
|
||||
|
||||
|
||||
char **argv_dup(int argc, const char **argv) {
|
||||
char **new_argv = malloc((argc + 1) * sizeof(*argv));
|
||||
|
||||
memcpy(new_argv, argv, argc * sizeof(*argv));
|
||||
new_argv[argc] = NULL;
|
||||
return new_argv;
|
||||
}
|
||||
|
||||
|
||||
void arg_show_usage(FILE *fp, const struct arg_def *const *defs) {
|
||||
char option_text[40] = {0};
|
||||
|
||||
for (; *defs; defs++) {
|
||||
const struct arg_def *def = *defs;
|
||||
char *short_val = def->has_val ? " <arg>" : "";
|
||||
char *long_val = def->has_val ? "=<arg>" : "";
|
||||
|
||||
if (def->short_name && def->long_name) {
|
||||
char *comma = def->has_val ? "," : ", ";
|
||||
|
||||
snprintf(option_text, 37, "-%s%s%s --%s%6s",
|
||||
def->short_name, short_val, comma,
|
||||
def->long_name, long_val);
|
||||
} else if (def->short_name)
|
||||
snprintf(option_text, 37, "-%s%s",
|
||||
def->short_name, short_val);
|
||||
else if (def->long_name)
|
||||
{
|
||||
const size_t name_len = strlen(def->long_name);
|
||||
snprintf(option_text, 37, " --%s%s",
|
||||
def->long_name, long_val);
|
||||
|
||||
if (strlen(arg.argv[0]) >= name_len + 2
|
||||
&& arg.argv[0][1] == '-'
|
||||
&& !strncmp(arg.argv[0] + 2, def->long_name, name_len)
|
||||
&& (arg.argv[0][name_len+2] == '='
|
||||
|| arg.argv[0][name_len+2] == '\0'))
|
||||
{
|
||||
fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
|
||||
|
||||
arg.name = arg.argv[0] + 2;
|
||||
arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
|
||||
arg.argv_step = 1;
|
||||
}
|
||||
if (def->enums) {
|
||||
const struct arg_enum_list *listptr;
|
||||
|
||||
fprintf(fp, " %-37s\t ", "");
|
||||
|
||||
for (listptr = def->enums; listptr->name; listptr++)
|
||||
fprintf(fp, "%s%s", listptr->name,
|
||||
listptr[1].name ? ", " : "\n");
|
||||
}
|
||||
|
||||
if (arg.name && !arg.val && def->has_val)
|
||||
die("Error: option %s requires argument.\n", arg.name);
|
||||
|
||||
if (arg.name && arg.val && !def->has_val)
|
||||
die("Error: option %s requires no argument.\n", arg.name);
|
||||
|
||||
if (arg.name
|
||||
&& (arg.val || !def->has_val))
|
||||
{
|
||||
arg.def = def;
|
||||
*arg_ = arg;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *arg_next(struct arg *arg)
|
||||
{
|
||||
if (arg->argv[0])
|
||||
arg->argv += arg->argv_step;
|
||||
unsigned int arg_parse_uint(const struct arg *arg) {
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
|
||||
return *arg->argv;
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0') {
|
||||
if (rawval >= 0 && rawval <= UINT_MAX)
|
||||
return rawval;
|
||||
|
||||
die("Option %s: Value %ld out of range for unsigned int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
|
||||
die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char **argv_dup(int argc, const char **argv)
|
||||
{
|
||||
char **new_argv = malloc((argc + 1) * sizeof(*argv));
|
||||
int arg_parse_int(const struct arg *arg) {
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
|
||||
memcpy(new_argv, argv, argc * sizeof(*argv));
|
||||
new_argv[argc] = NULL;
|
||||
return new_argv;
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0') {
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
return rawval;
|
||||
|
||||
die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
|
||||
die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
|
||||
{
|
||||
char option_text[40] = {0};
|
||||
|
||||
for (; *defs; defs++)
|
||||
{
|
||||
const struct arg_def *def = *defs;
|
||||
char *short_val = def->has_val ? " <arg>" : "";
|
||||
char *long_val = def->has_val ? "=<arg>" : "";
|
||||
|
||||
if (def->short_name && def->long_name)
|
||||
{
|
||||
char *comma = def->has_val ? "," : ", ";
|
||||
|
||||
snprintf(option_text, 37, "-%s%s%s --%s%6s",
|
||||
def->short_name, short_val, comma,
|
||||
def->long_name, long_val);
|
||||
}
|
||||
else if (def->short_name)
|
||||
snprintf(option_text, 37, "-%s%s",
|
||||
def->short_name, short_val);
|
||||
else if (def->long_name)
|
||||
snprintf(option_text, 37, " --%s%s",
|
||||
def->long_name, long_val);
|
||||
|
||||
fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
|
||||
|
||||
if(def->enums)
|
||||
{
|
||||
const struct arg_enum_list *listptr;
|
||||
|
||||
fprintf(fp, " %-37s\t ", "");
|
||||
|
||||
for(listptr = def->enums; listptr->name; listptr++)
|
||||
fprintf(fp, "%s%s", listptr->name,
|
||||
listptr[1].name ? ", " : "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned int arg_parse_uint(const struct arg *arg)
|
||||
{
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0')
|
||||
{
|
||||
if (rawval >= 0 && rawval <= UINT_MAX)
|
||||
return rawval;
|
||||
|
||||
die("Option %s: Value %ld out of range for unsigned int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
|
||||
die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int arg_parse_int(const struct arg *arg)
|
||||
{
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0')
|
||||
{
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
return rawval;
|
||||
|
||||
die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
|
||||
die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct vpx_rational
|
||||
{
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
struct vpx_rational {
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
};
|
||||
struct vpx_rational arg_parse_rational(const struct arg *arg)
|
||||
{
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
struct vpx_rational rat;
|
||||
struct vpx_rational arg_parse_rational(const struct arg *arg) {
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
struct vpx_rational rat;
|
||||
|
||||
/* parse numerator */
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
/* parse numerator */
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '/')
|
||||
{
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
rat.num = rawval;
|
||||
else die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
|
||||
if (arg->val[0] != '\0' && endptr[0] == '/') {
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
rat.num = rawval;
|
||||
else die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
} else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
|
||||
|
||||
/* parse denominator */
|
||||
rawval = strtol(endptr + 1, &endptr, 10);
|
||||
/* parse denominator */
|
||||
rawval = strtol(endptr + 1, &endptr, 10);
|
||||
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0')
|
||||
{
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
rat.den = rawval;
|
||||
else die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
}
|
||||
else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0') {
|
||||
if (rawval >= INT_MIN && rawval <= INT_MAX)
|
||||
rat.den = rawval;
|
||||
else die("Option %s: Value %ld out of range for signed int\n",
|
||||
arg->name, rawval);
|
||||
} else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
|
||||
|
||||
return rat;
|
||||
return rat;
|
||||
}
|
||||
|
||||
|
||||
int arg_parse_enum(const struct arg *arg)
|
||||
{
|
||||
const struct arg_enum_list *listptr;
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
int arg_parse_enum(const struct arg *arg) {
|
||||
const struct arg_enum_list *listptr;
|
||||
long int rawval;
|
||||
char *endptr;
|
||||
|
||||
/* First see if the value can be parsed as a raw value */
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0')
|
||||
{
|
||||
/* Got a raw value, make sure it's valid */
|
||||
for(listptr = arg->def->enums; listptr->name; listptr++)
|
||||
if(listptr->val == rawval)
|
||||
return rawval;
|
||||
}
|
||||
/* First see if the value can be parsed as a raw value */
|
||||
rawval = strtol(arg->val, &endptr, 10);
|
||||
if (arg->val[0] != '\0' && endptr[0] == '\0') {
|
||||
/* Got a raw value, make sure it's valid */
|
||||
for (listptr = arg->def->enums; listptr->name; listptr++)
|
||||
if (listptr->val == rawval)
|
||||
return rawval;
|
||||
}
|
||||
|
||||
/* Next see if it can be parsed as a string */
|
||||
for(listptr = arg->def->enums; listptr->name; listptr++)
|
||||
if(!strcmp(arg->val, listptr->name))
|
||||
return listptr->val;
|
||||
/* Next see if it can be parsed as a string */
|
||||
for (listptr = arg->def->enums; listptr->name; listptr++)
|
||||
if (!strcmp(arg->val, listptr->name))
|
||||
return listptr->val;
|
||||
|
||||
die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
|
||||
return 0;
|
||||
die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int arg_parse_enum_or_int(const struct arg *arg)
|
||||
{
|
||||
if(arg->def->enums)
|
||||
return arg_parse_enum(arg);
|
||||
return arg_parse_int(arg);
|
||||
int arg_parse_enum_or_int(const struct arg *arg) {
|
||||
if (arg->def->enums)
|
||||
return arg_parse_enum(arg);
|
||||
return arg_parse_int(arg);
|
||||
}
|
||||
|
33
args.h
33
args.h
@ -13,29 +13,26 @@
|
||||
#define ARGS_H
|
||||
#include <stdio.h>
|
||||
|
||||
struct arg
|
||||
{
|
||||
char **argv;
|
||||
const char *name;
|
||||
const char *val;
|
||||
unsigned int argv_step;
|
||||
const struct arg_def *def;
|
||||
struct arg {
|
||||
char **argv;
|
||||
const char *name;
|
||||
const char *val;
|
||||
unsigned int argv_step;
|
||||
const struct arg_def *def;
|
||||
};
|
||||
|
||||
struct arg_enum_list
|
||||
{
|
||||
const char *name;
|
||||
int val;
|
||||
struct arg_enum_list {
|
||||
const char *name;
|
||||
int val;
|
||||
};
|
||||
#define ARG_ENUM_LIST_END {0}
|
||||
|
||||
typedef struct arg_def
|
||||
{
|
||||
const char *short_name;
|
||||
const char *long_name;
|
||||
int has_val;
|
||||
const char *desc;
|
||||
const struct arg_enum_list *enums;
|
||||
typedef struct arg_def {
|
||||
const char *short_name;
|
||||
const char *long_name;
|
||||
int has_val;
|
||||
const char *desc;
|
||||
const struct arg_enum_list *enums;
|
||||
} arg_def_t;
|
||||
#define ARG_DEF(s,l,v,d) {s,l,v,d, NULL}
|
||||
#define ARG_DEF_ENUM(s,l,v,d,e) {s,l,v,d,e}
|
||||
|
@ -208,4 +208,3 @@ endif
|
||||
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
|
||||
$(call import-module,cpufeatures)
|
||||
endif
|
||||
|
||||
|
@ -253,10 +253,25 @@ $(1):
|
||||
$(if $(quiet),@echo " [LD] $$@")
|
||||
$(qexec)$$(LD) -shared $$(LDFLAGS) \
|
||||
-Wl,--no-undefined -Wl,-soname,$$(SONAME) \
|
||||
-Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \
|
||||
$$(filter %.o,$$?) $$(extralibs)
|
||||
-Wl,--version-script,$$(EXPORTS_FILE) -o $$@ \
|
||||
$$(filter %.o,$$^) $$(extralibs)
|
||||
endef
|
||||
|
||||
define dl_template
|
||||
# Not using a pattern rule here because we don't want to generate empty
|
||||
# archives when they are listed as a dependency in files not responsible
|
||||
# for creating them.
|
||||
$(1):
|
||||
$(if $(quiet),@echo " [LD] $$@")
|
||||
$(qexec)$$(LD) -dynamiclib $$(LDFLAGS) \
|
||||
-exported_symbols_list $$(EXPORTS_FILE) \
|
||||
-Wl,-headerpad_max_install_names,-compatibility_version,1.0,-current_version,$$(VERSION_MAJOR) \
|
||||
-o $$@ \
|
||||
$$(filter %.o,$$^) $$(extralibs)
|
||||
endef
|
||||
|
||||
|
||||
|
||||
define lipo_lib_template
|
||||
$(1): $(addsuffix /$(1),$(FAT_ARCHS))
|
||||
$(if $(quiet),@echo " [LIPO] $$@")
|
||||
@ -321,6 +336,7 @@ LIBS=$(call enabled,LIBS)
|
||||
@touch $@
|
||||
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
|
||||
$(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
|
||||
$(foreach lib,$(filter %$(VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib))))
|
||||
|
||||
INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
|
||||
ifeq ($(MAKECMDGOALS),dist)
|
||||
|
@ -277,6 +277,7 @@ clean_temp_files() {
|
||||
# Toolchain Check Functions
|
||||
#
|
||||
check_cmd() {
|
||||
enabled external_build && return
|
||||
log "$@"
|
||||
"$@" >>${logfile} 2>&1
|
||||
}
|
||||
@ -435,10 +436,10 @@ RTCD_OPTIONS = ${RTCD_OPTIONS}
|
||||
EOF
|
||||
|
||||
if enabled rvct; then cat >> $1 << EOF
|
||||
fmt_deps = sed -e 's;^__image.axf;\$(dir \$@)\$(notdir \$<).o \$@;' #hide
|
||||
fmt_deps = sed -e 's;^__image.axf;\$\${@:.d=.o} \$\$@;' #hide
|
||||
EOF
|
||||
else cat >> $1 << EOF
|
||||
fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\$(dir \$@)\1\$(suffix \$<).o \$@;'
|
||||
fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\$\${@:.d=.o} \$\$@;'
|
||||
EOF
|
||||
fi
|
||||
|
||||
@ -1001,7 +1002,11 @@ EOF
|
||||
soft_enable sse2
|
||||
soft_enable sse3
|
||||
soft_enable ssse3
|
||||
soft_enable sse4_1
|
||||
if enabled gcc && ! disabled sse4_1 && ! check_cflags -msse4; then
|
||||
RTCD_OPTIONS="${RTCD_OPTIONS}--disable-sse4_1 "
|
||||
else
|
||||
soft_enable sse4_1
|
||||
fi
|
||||
|
||||
case ${tgt_os} in
|
||||
win*)
|
||||
@ -1176,9 +1181,6 @@ EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
# for sysconf(3) and friends.
|
||||
check_header unistd.h
|
||||
|
||||
# glibc needs these
|
||||
if enabled linux; then
|
||||
add_cflags -D_LARGEFILE_SOURCE
|
||||
|
@ -26,6 +26,7 @@ Options:
|
||||
--help Print this message
|
||||
--exe Generate a project for building an Application
|
||||
--lib Generate a project for creating a static library
|
||||
--dll Generate a project for creating a dll
|
||||
--static-crt Use the static C runtime (/MT)
|
||||
--target=isa-os-cc Target specifier (required)
|
||||
--out=filename Write output to a file [stdout]
|
||||
@ -142,7 +143,9 @@ generate_filter() {
|
||||
if [ "${f##*.}" == "$pat" ]; then
|
||||
unset file_list[i]
|
||||
|
||||
objf=$(echo ${f%.*}.obj | sed -e 's/^[\./]\+//g' -e 's,/,_,g')
|
||||
open_tag File RelativePath="./$f"
|
||||
|
||||
if [ "$pat" == "asm" ] && $asm_use_custom_step; then
|
||||
for plat in "${platforms[@]}"; do
|
||||
for cfg in Debug Release; do
|
||||
@ -152,14 +155,27 @@ generate_filter() {
|
||||
tag Tool \
|
||||
Name="VCCustomBuildTool" \
|
||||
Description="Assembling \$(InputFileName)" \
|
||||
CommandLine="$(eval echo \$asm_${cfg}_cmdline)" \
|
||||
Outputs="\$(InputName).obj" \
|
||||
CommandLine="$(eval echo \$asm_${cfg}_cmdline) -o \$(IntDir)$objf" \
|
||||
Outputs="\$(IntDir)$objf" \
|
||||
|
||||
close_tag FileConfiguration
|
||||
done
|
||||
done
|
||||
fi
|
||||
if [ "$pat" == "c" ] || [ "$pat" == "cc" ] ; then
|
||||
for plat in "${platforms[@]}"; do
|
||||
for cfg in Debug Release; do
|
||||
open_tag FileConfiguration \
|
||||
Name="${cfg}|${plat}" \
|
||||
|
||||
tag Tool \
|
||||
Name="VCCLCompilerTool" \
|
||||
ObjectFile="\$(IntDir)$objf" \
|
||||
|
||||
close_tag FileConfiguration
|
||||
done
|
||||
done
|
||||
fi
|
||||
close_tag File
|
||||
|
||||
break
|
||||
@ -190,6 +206,8 @@ for opt in "$@"; do
|
||||
;;
|
||||
--exe) proj_kind="exe"
|
||||
;;
|
||||
--dll) proj_kind="dll"
|
||||
;;
|
||||
--lib) proj_kind="lib"
|
||||
;;
|
||||
--src-path-bare=*) src_path_bare="$optval"
|
||||
@ -244,8 +262,10 @@ case "${vs_ver:-8}" in
|
||||
asm_use_custom_step=$uses_asm
|
||||
;;
|
||||
8) vs_ver_id="8.00"
|
||||
asm_use_custom_step=$uses_asm
|
||||
;;
|
||||
9) vs_ver_id="9.00"
|
||||
asm_use_custom_step=$uses_asm
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -284,10 +304,11 @@ esac
|
||||
case "$target" in
|
||||
x86_64*)
|
||||
platforms[0]="x64"
|
||||
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
|
||||
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
|
||||
;;
|
||||
x86*)
|
||||
platforms[0]="Win32"
|
||||
# these are only used by vs7
|
||||
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
|
||||
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
|
||||
;;
|
||||
@ -299,6 +320,8 @@ generate_vcproj() {
|
||||
case "$proj_kind" in
|
||||
exe) vs_ConfigurationType=1
|
||||
;;
|
||||
dll) vs_ConfigurationType=2
|
||||
;;
|
||||
*) vs_ConfigurationType=4
|
||||
;;
|
||||
esac
|
||||
@ -318,13 +341,6 @@ generate_vcproj() {
|
||||
done
|
||||
close_tag Platforms
|
||||
|
||||
open_tag ToolFiles
|
||||
case "$target" in
|
||||
x86*) $uses_asm && tag ToolFile RelativePath="$self_dirname/../x86-msvs/yasm.rules"
|
||||
;;
|
||||
esac
|
||||
close_tag ToolFiles
|
||||
|
||||
open_tag Configurations
|
||||
for plat in "${platforms[@]}"; do
|
||||
plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,9 +7,17 @@ REM in the file PATENTS. All contributing project authors may
|
||||
REM be found in the AUTHORS file in the root of the source tree.
|
||||
echo on
|
||||
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp9/common/vp9_asm_com_offsets.c"
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp9/decoder/vp9_asm_dec_offsets.c"
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp9/encoder/vp9_asm_enc_offsets.c"
|
||||
obj_int_extract.exe rvds "vp9_asm_com_offsets.obj" > "vp9_asm_com_offsets.asm"
|
||||
obj_int_extract.exe rvds "vp9_asm_dec_offsets.obj" > "vp9_asm_dec_offsets.asm"
|
||||
obj_int_extract.exe rvds "vp9_asm_enc_offsets.obj" > "vp9_asm_enc_offsets.asm"
|
||||
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp8/common/asm_com_offsets.c"
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp8/decoder/asm_dec_offsets.c"
|
||||
cl /I "./" /I "%1" /nologo /c "%1/vp8/encoder/asm_enc_offsets.c"
|
||||
obj_int_extract.exe rvds "asm_com_offsets.obj" > "asm_com_offsets.asm"
|
||||
obj_int_extract.exe rvds "asm_dec_offsets.obj" > "asm_dec_offsets.asm"
|
||||
obj_int_extract.exe rvds "asm_enc_offsets.obj" > "asm_enc_offsets.asm"
|
||||
obj_int_extract.exe rvds "asm_com_offsets.obj" > "vp8_asm_com_offsets.asm"
|
||||
obj_int_extract.exe rvds "asm_dec_offsets.obj" > "vp8_asm_dec_offsets.asm"
|
||||
obj_int_extract.exe rvds "asm_enc_offsets.obj" > "vp8_asm_enc_offsets.asm"
|
||||
|
||||
|
@ -1,115 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VisualStudioToolFile
|
||||
Name="Yasm"
|
||||
Version="8.00"
|
||||
>
|
||||
<Rules>
|
||||
<CustomBuildRule
|
||||
Name="YASM"
|
||||
DisplayName="Yasm Assembler"
|
||||
CommandLine="yasm -Xvc -f $(PlatformName) [AllOptions] [AdditionalOptions] [Inputs]"
|
||||
Outputs="[$ObjectFileName]"
|
||||
FileExtensions="*.asm"
|
||||
ExecutionDescription="Assembling $(InputFileName)"
|
||||
ShowOnlyRuleProperties="false"
|
||||
>
|
||||
<Properties>
|
||||
<StringProperty
|
||||
Name="Defines"
|
||||
DisplayName="Definitions"
|
||||
Category="Pre-Defined Symbols"
|
||||
Description="Specify pre-defined symbols ('symbol' or 'symbol = value') "
|
||||
Switch="-D [value]"
|
||||
Delimited="true"
|
||||
Inheritable="true"
|
||||
/>
|
||||
<StringProperty
|
||||
Name="IncludePaths"
|
||||
DisplayName="Include Paths"
|
||||
Category="Configuration"
|
||||
Description="Set the paths for any additional include files"
|
||||
Switch="-I [value]"
|
||||
Delimited="true"
|
||||
Inheritable="true"
|
||||
/>
|
||||
<StringProperty
|
||||
Name="UnDefines"
|
||||
DisplayName="Remove Definitions"
|
||||
Category="Pre-Defined Symbols"
|
||||
Description="Remove pre-defined symbols "
|
||||
Switch="-U [value]"
|
||||
Delimited="true"
|
||||
Inheritable="true"
|
||||
/>
|
||||
<StringProperty
|
||||
Name="ObjectFileName"
|
||||
DisplayName="Object File Name"
|
||||
Category="Output"
|
||||
Description="Select the output file name"
|
||||
Switch="-o [value]"
|
||||
DefaultValue="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
<StringProperty
|
||||
Name="ListFileName"
|
||||
DisplayName="List File Name"
|
||||
Category="Output"
|
||||
Description="Select an output listing by setting its file name"
|
||||
Switch="-l [value]"
|
||||
/>
|
||||
<StringProperty
|
||||
Name="PreIncludeFile"
|
||||
DisplayName="Pre Include File"
|
||||
Category="Configuration"
|
||||
Description="Select a pre-included file by setting its name"
|
||||
Switch="-P [value]"
|
||||
/>
|
||||
<BooleanProperty
|
||||
Name="Debug"
|
||||
DisplayName="Debug Information"
|
||||
Category="Output"
|
||||
Description="Generate debugging information"
|
||||
Switch="-g cv8"
|
||||
/>
|
||||
<EnumProperty
|
||||
Name="PreProc"
|
||||
DisplayName="Pre-Processor"
|
||||
Category="Configuration"
|
||||
Description="Select the pre-processor ('nasm' or 'raw')"
|
||||
>
|
||||
<Values>
|
||||
<EnumValue
|
||||
Value="0"
|
||||
Switch="-rnasm"
|
||||
DisplayName="Nasm "
|
||||
/>
|
||||
<EnumValue
|
||||
Value="1"
|
||||
Switch="-rraw"
|
||||
DisplayName="Raw"
|
||||
/>
|
||||
</Values>
|
||||
</EnumProperty>
|
||||
<EnumProperty
|
||||
Name="Parser"
|
||||
DisplayName="Parser"
|
||||
Category="Configuration"
|
||||
Description="Select the parser for Intel ('nasm') or AT&T ( 'gas') syntax"
|
||||
>
|
||||
<Values>
|
||||
<EnumValue
|
||||
Value="0"
|
||||
Switch="-pnasm"
|
||||
DisplayName="Nasm"
|
||||
/>
|
||||
<EnumValue
|
||||
Value="1"
|
||||
Switch="-pgas"
|
||||
DisplayName="Gas"
|
||||
/>
|
||||
</Values>
|
||||
</EnumProperty>
|
||||
</Properties>
|
||||
</CustomBuildRule>
|
||||
</Rules>
|
||||
</VisualStudioToolFile>
|
||||
|
60
configure
vendored
60
configure
vendored
@ -34,6 +34,7 @@ Advanced options:
|
||||
${toggle_md5} support for output of checksum data
|
||||
${toggle_static_msvcrt} use static MSVCRT (VS builds only)
|
||||
${toggle_vp8} VP8 codec support
|
||||
${toggle_vp9} VP9 codec support
|
||||
${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
|
||||
${toggle_mem_tracker} track memory usage
|
||||
${toggle_postproc} postprocessing
|
||||
@ -176,19 +177,24 @@ enable os_support
|
||||
enable temporal_denoising
|
||||
|
||||
[ -d ${source_path}/../include ] && enable alt_tree_layout
|
||||
for d in vp8; do
|
||||
for d in vp8 vp9; do
|
||||
[ -d ${source_path}/${d} ] && disable alt_tree_layout;
|
||||
done
|
||||
|
||||
if ! enabled alt_tree_layout; then
|
||||
# development environment
|
||||
[ -d ${source_path}/vp8 ] && CODECS="${CODECS} vp8_encoder vp8_decoder"
|
||||
[ -d ${source_path}/vp9 ] && CODECS="${CODECS} vp9_encoder vp9_decoder"
|
||||
else
|
||||
# customer environment
|
||||
[ -f ${source_path}/../include/vpx/vp8cx.h ] && CODECS="${CODECS} vp8_encoder"
|
||||
[ -f ${source_path}/../include/vpx/vp8dx.h ] && CODECS="${CODECS} vp8_decoder"
|
||||
[ -f ${source_path}/../include/vpx/vp9cx.h ] && CODECS="${CODECS} vp9_encoder"
|
||||
[ -f ${source_path}/../include/vpx/vp9dx.h ] && CODECS="${CODECS} vp9_decoder"
|
||||
[ -f ${source_path}/../include/vpx/vp8cx.h ] || disable vp8_encoder
|
||||
[ -f ${source_path}/../include/vpx/vp8dx.h ] || disable vp8_decoder
|
||||
[ -f ${source_path}/../include/vpx/vp9cx.h ] || disable vp9_encoder
|
||||
[ -f ${source_path}/../include/vpx/vp9dx.h ] || disable vp9_decoder
|
||||
|
||||
[ -f ${source_path}/../lib/*/*mt.lib ] && soft_enable static_msvcrt
|
||||
fi
|
||||
@ -230,6 +236,18 @@ HAVE_LIST="
|
||||
sys_mman_h
|
||||
unistd_h
|
||||
"
|
||||
EXPERIMENT_LIST="
|
||||
csm
|
||||
comp_intra_pred
|
||||
superblocks
|
||||
pred_filter
|
||||
lossless
|
||||
subpelrefmv
|
||||
new_mvref
|
||||
implicit_segmentation
|
||||
newbintramodes
|
||||
comp_interintra_pred
|
||||
"
|
||||
CONFIG_LIST="
|
||||
external_build
|
||||
install_docs
|
||||
@ -276,8 +294,11 @@ CONFIG_LIST="
|
||||
unit_tests
|
||||
multi_res_encoding
|
||||
temporal_denoising
|
||||
experimental
|
||||
${EXPERIMENT_LIST}
|
||||
"
|
||||
CMDLINE_SELECT="
|
||||
external_build
|
||||
extra_warnings
|
||||
werror
|
||||
install_docs
|
||||
@ -322,6 +343,7 @@ CMDLINE_SELECT="
|
||||
unit_tests
|
||||
multi_res_encoding
|
||||
temporal_denoising
|
||||
experimental
|
||||
"
|
||||
|
||||
process_cmdline() {
|
||||
@ -329,6 +351,18 @@ process_cmdline() {
|
||||
optval="${opt#*=}"
|
||||
case "$opt" in
|
||||
--disable-codecs) for c in ${CODECS}; do disable $c; done ;;
|
||||
--enable-?*|--disable-?*)
|
||||
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
|
||||
if echo "${EXPERIMENT_LIST}" | grep "^ *$option\$" >/dev/null; then
|
||||
if enabled experimental; then
|
||||
$action $option
|
||||
else
|
||||
log_echo "Ignoring $opt -- not in experimental mode."
|
||||
fi
|
||||
else
|
||||
process_common_cmdline $opt
|
||||
fi
|
||||
;;
|
||||
*) process_common_cmdline "$opt"
|
||||
;;
|
||||
esac
|
||||
@ -464,7 +498,7 @@ process_detect() {
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -z "$CC" ]; then
|
||||
if [ -z "$CC" ] || enabled external_build; then
|
||||
echo "Bypassing toolchain for environment detection."
|
||||
enable external_build
|
||||
check_header() {
|
||||
@ -473,6 +507,7 @@ process_detect() {
|
||||
shift
|
||||
var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
|
||||
disable $var
|
||||
# Headers common to all environments
|
||||
case $header in
|
||||
stdio.h)
|
||||
true;
|
||||
@ -484,6 +519,25 @@ process_detect() {
|
||||
done
|
||||
${result:-true}
|
||||
esac && enable $var
|
||||
|
||||
# Specialize windows and POSIX environments.
|
||||
case $toolchain in
|
||||
*-win*-*)
|
||||
case $header-$toolchain in
|
||||
stdint*-gcc) true;;
|
||||
*) false;;
|
||||
esac && enable $var
|
||||
;;
|
||||
*)
|
||||
case $header in
|
||||
stdint.h) true;;
|
||||
pthread.h) true;;
|
||||
sys/mman.h) true;;
|
||||
unistd.h) true;;
|
||||
*) false;;
|
||||
esac && enable $var
|
||||
esac
|
||||
enabled $var
|
||||
}
|
||||
check_ld() {
|
||||
true
|
||||
@ -497,6 +551,7 @@ EOF
|
||||
check_header stdint.h
|
||||
check_header pthread.h
|
||||
check_header sys/mman.h
|
||||
check_header unistd.h # for sysconf(3) and friends.
|
||||
|
||||
check_header vpx/vpx_integer.h -I${source_path} && enable vpx_ports
|
||||
}
|
||||
@ -537,6 +592,7 @@ process_toolchain() {
|
||||
check_add_cflags -Wpointer-arith
|
||||
check_add_cflags -Wtype-limits
|
||||
check_add_cflags -Wcast-qual
|
||||
check_add_cflags -Wvla
|
||||
check_add_cflags -Wimplicit-function-declaration
|
||||
check_add_cflags -Wuninitialized
|
||||
check_add_cflags -Wunused-variable
|
||||
|
301
example_xma.c
301
example_xma.c
@ -18,197 +18,174 @@
|
||||
#include "vpx_config.h"
|
||||
#include "vpx/vpx_decoder.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
#if CONFIG_VP8_DECODER
|
||||
#if CONFIG_VP9_DECODER
|
||||
#include "vpx/vp8dx.h"
|
||||
#endif
|
||||
|
||||
static char *exec_name;
|
||||
static int verbose = 0;
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
const vpx_codec_iface_t *iface;
|
||||
} ifaces[] =
|
||||
{
|
||||
#if CONFIG_VP8_DECODER
|
||||
{"vp8", &vpx_codec_vp8_dx_algo},
|
||||
static const struct {
|
||||
const char *name;
|
||||
const vpx_codec_iface_t *iface;
|
||||
} ifaces[] = {
|
||||
#if CONFIG_VP9_DECODER
|
||||
{"vp9", &vpx_codec_vp8_dx_algo},
|
||||
#endif
|
||||
};
|
||||
|
||||
static void usage_exit(void)
|
||||
{
|
||||
int i;
|
||||
static void usage_exit(void) {
|
||||
int i;
|
||||
|
||||
printf("Usage: %s <options>\n\n"
|
||||
"Options:\n"
|
||||
"\t--codec <name>\tCodec to use (default=%s)\n"
|
||||
"\t-h <height>\tHeight of the simulated video frame, in pixels\n"
|
||||
"\t-w <width> \tWidth of the simulated video frame, in pixels\n"
|
||||
"\t-v \tVerbose mode (show individual segment sizes)\n"
|
||||
"\t--help \tShow this message\n"
|
||||
"\n"
|
||||
"Included decoders:\n"
|
||||
"\n",
|
||||
exec_name,
|
||||
ifaces[0].name);
|
||||
printf("Usage: %s <options>\n\n"
|
||||
"Options:\n"
|
||||
"\t--codec <name>\tCodec to use (default=%s)\n"
|
||||
"\t-h <height>\tHeight of the simulated video frame, in pixels\n"
|
||||
"\t-w <width> \tWidth of the simulated video frame, in pixels\n"
|
||||
"\t-v \tVerbose mode (show individual segment sizes)\n"
|
||||
"\t--help \tShow this message\n"
|
||||
"\n"
|
||||
"Included decoders:\n"
|
||||
"\n",
|
||||
exec_name,
|
||||
ifaces[0].name);
|
||||
|
||||
for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
|
||||
printf(" %-6s - %s\n",
|
||||
ifaces[i].name,
|
||||
vpx_codec_iface_name(ifaces[i].iface));
|
||||
for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
|
||||
printf(" %-6s - %s\n",
|
||||
ifaces[i].name,
|
||||
vpx_codec_iface_name(ifaces[i].iface));
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void usage_error(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
printf("\n");
|
||||
usage_exit();
|
||||
static void usage_error(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
printf("\n");
|
||||
usage_exit();
|
||||
}
|
||||
|
||||
void my_mem_dtor(vpx_codec_mmap_t *mmap)
|
||||
{
|
||||
if (verbose)
|
||||
printf("freeing segment %d\n", mmap->id);
|
||||
void my_mem_dtor(vpx_codec_mmap_t *mmap) {
|
||||
if (verbose)
|
||||
printf("freeing segment %d\n", mmap->id);
|
||||
|
||||
free(mmap->priv);
|
||||
free(mmap->priv);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
vpx_codec_ctx_t decoder;
|
||||
vpx_codec_iface_t *iface = ifaces[0].iface;
|
||||
vpx_codec_iter_t iter;
|
||||
vpx_codec_dec_cfg_t cfg;
|
||||
vpx_codec_err_t res = VPX_CODEC_OK;
|
||||
unsigned int alloc_sz = 0;
|
||||
unsigned int w = 352;
|
||||
unsigned int h = 288;
|
||||
int i;
|
||||
int main(int argc, char **argv) {
|
||||
vpx_codec_ctx_t decoder;
|
||||
vpx_codec_iface_t *iface = ifaces[0].iface;
|
||||
vpx_codec_iter_t iter;
|
||||
vpx_codec_dec_cfg_t cfg;
|
||||
vpx_codec_err_t res = VPX_CODEC_OK;
|
||||
unsigned int alloc_sz = 0;
|
||||
unsigned int w = 352;
|
||||
unsigned int h = 288;
|
||||
int i;
|
||||
|
||||
exec_name = argv[0];
|
||||
exec_name = argv[0];
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "--codec"))
|
||||
{
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
int j, k = -1;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "--codec")) {
|
||||
if (i + 1 < argc) {
|
||||
int j, k = -1;
|
||||
|
||||
i++;
|
||||
i++;
|
||||
|
||||
for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
|
||||
if (!strcmp(ifaces[j].name, argv[i]))
|
||||
k = j;
|
||||
for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
|
||||
if (!strcmp(ifaces[j].name, argv[i]))
|
||||
k = j;
|
||||
|
||||
if (k >= 0)
|
||||
iface = ifaces[k].iface;
|
||||
else
|
||||
usage_error("Error: Unrecognized argument (%s) to --codec\n",
|
||||
argv[i]);
|
||||
}
|
||||
else
|
||||
usage_error("Error: Option --codec requires argument.\n");
|
||||
}
|
||||
else if (!strcmp(argv[i], "-v"))
|
||||
verbose = 1;
|
||||
else if (!strcmp(argv[i], "-h"))
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
h = atoi(argv[++i]);
|
||||
}
|
||||
else
|
||||
usage_error("Error: Option -h requires argument.\n");
|
||||
else if (!strcmp(argv[i], "-w"))
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
w = atoi(argv[++i]);
|
||||
}
|
||||
else
|
||||
usage_error("Error: Option -w requires argument.\n");
|
||||
else if (!strcmp(argv[i], "--help"))
|
||||
usage_exit();
|
||||
if (k >= 0)
|
||||
iface = ifaces[k].iface;
|
||||
else
|
||||
usage_error("Error: Unrecognized option %s\n\n", argv[i]);
|
||||
}
|
||||
usage_error("Error: Unrecognized argument (%s) to --codec\n",
|
||||
argv[i]);
|
||||
} else
|
||||
usage_error("Error: Option --codec requires argument.\n");
|
||||
} else if (!strcmp(argv[i], "-v"))
|
||||
verbose = 1;
|
||||
else if (!strcmp(argv[i], "-h"))
|
||||
if (i + 1 < argc) {
|
||||
h = atoi(argv[++i]);
|
||||
} else
|
||||
usage_error("Error: Option -h requires argument.\n");
|
||||
else if (!strcmp(argv[i], "-w"))
|
||||
if (i + 1 < argc) {
|
||||
w = atoi(argv[++i]);
|
||||
} else
|
||||
usage_error("Error: Option -w requires argument.\n");
|
||||
else if (!strcmp(argv[i], "--help"))
|
||||
usage_exit();
|
||||
else
|
||||
usage_error("Error: Unrecognized option %s\n\n", argv[i]);
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
printf("Using built-in defaults. For options, rerun with --help\n\n");
|
||||
if (argc == 1)
|
||||
printf("Using built-in defaults. For options, rerun with --help\n\n");
|
||||
|
||||
/* XMA mode is not supported on all decoders! */
|
||||
if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA))
|
||||
{
|
||||
printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
|
||||
/* XMA mode is not supported on all decoders! */
|
||||
if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA)) {
|
||||
printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* The codec knows how much memory to allocate based on the size of the
|
||||
* encoded frames. This data can be parsed from the bitstream with
|
||||
* vpx_codec_peek_stream_info() if a bitstream is available. Otherwise,
|
||||
* a fixed size can be used that will be the upper limit on the frame
|
||||
* size the decoder can decode.
|
||||
*/
|
||||
cfg.w = w;
|
||||
cfg.h = h;
|
||||
|
||||
/* Initialize the decoder in XMA mode. */
|
||||
if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA)) {
|
||||
printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Iterate through the list of memory maps, allocating them with the
|
||||
* requested alignment.
|
||||
*/
|
||||
iter = NULL;
|
||||
|
||||
do {
|
||||
vpx_codec_mmap_t mmap;
|
||||
unsigned int align;
|
||||
|
||||
res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
|
||||
align = mmap.align ? mmap.align - 1 : 0;
|
||||
|
||||
if (!res) {
|
||||
if (verbose)
|
||||
printf("Allocating segment %u, size %lu, align %u %s\n",
|
||||
mmap.id, mmap.sz, mmap.align,
|
||||
mmap.flags & VPX_CODEC_MEM_ZERO ? "(ZEROED)" : "");
|
||||
|
||||
if (mmap.flags & VPX_CODEC_MEM_ZERO)
|
||||
mmap.priv = calloc(1, mmap.sz + align);
|
||||
else
|
||||
mmap.priv = malloc(mmap.sz + align);
|
||||
|
||||
mmap.base = (void *)((((uintptr_t)mmap.priv) + align) & ~(uintptr_t)align);
|
||||
mmap.dtor = my_mem_dtor;
|
||||
alloc_sz += mmap.sz + align;
|
||||
|
||||
if (vpx_codec_set_mem_map(&decoder, &mmap, 1)) {
|
||||
printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if (res != VPX_CODEC_LIST_END) {
|
||||
printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} while (res != VPX_CODEC_LIST_END);
|
||||
|
||||
/* The codec knows how much memory to allocate based on the size of the
|
||||
* encoded frames. This data can be parsed from the bitstream with
|
||||
* vpx_codec_peek_stream_info() if a bitstream is available. Otherwise,
|
||||
* a fixed size can be used that will be the upper limit on the frame
|
||||
* size the decoder can decode.
|
||||
*/
|
||||
cfg.w = w;
|
||||
cfg.h = h;
|
||||
|
||||
/* Initialize the decoder in XMA mode. */
|
||||
if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA))
|
||||
{
|
||||
printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Iterate through the list of memory maps, allocating them with the
|
||||
* requested alignment.
|
||||
*/
|
||||
iter = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
vpx_codec_mmap_t mmap;
|
||||
unsigned int align;
|
||||
|
||||
res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
|
||||
align = mmap.align ? mmap.align - 1 : 0;
|
||||
|
||||
if (!res)
|
||||
{
|
||||
if (verbose)
|
||||
printf("Allocating segment %u, size %lu, align %u %s\n",
|
||||
mmap.id, mmap.sz, mmap.align,
|
||||
mmap.flags & VPX_CODEC_MEM_ZERO ? "(ZEROED)" : "");
|
||||
|
||||
if (mmap.flags & VPX_CODEC_MEM_ZERO)
|
||||
mmap.priv = calloc(1, mmap.sz + align);
|
||||
else
|
||||
mmap.priv = malloc(mmap.sz + align);
|
||||
|
||||
mmap.base = (void *)((((uintptr_t)mmap.priv) + align) & ~(uintptr_t)align);
|
||||
mmap.dtor = my_mem_dtor;
|
||||
alloc_sz += mmap.sz + align;
|
||||
|
||||
if (vpx_codec_set_mem_map(&decoder, &mmap, 1))
|
||||
{
|
||||
printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (res != VPX_CODEC_LIST_END)
|
||||
{
|
||||
printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
while (res != VPX_CODEC_LIST_END);
|
||||
|
||||
printf("%s\n %d bytes external memory required for %dx%d.\n",
|
||||
decoder.name, alloc_sz, cfg.w, cfg.h);
|
||||
vpx_codec_destroy(&decoder);
|
||||
return EXIT_SUCCESS;
|
||||
printf("%s\n %d bytes external memory required for %dx%d.\n",
|
||||
decoder.name, alloc_sz, cfg.w, cfg.h);
|
||||
vpx_codec_destroy(&decoder);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
29
examples.mk
29
examples.mk
@ -38,7 +38,7 @@ vpxenc.SRCS += libmkv/EbmlWriter.c
|
||||
vpxenc.SRCS += libmkv/EbmlWriter.h
|
||||
vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
|
||||
vpxenc.DESCRIPTION = Full featured encoder
|
||||
UTILS-$(CONFIG_ENCODERS) += vp8_scalable_patterns.c
|
||||
UTILS-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c
|
||||
vp8_scalable_patterns.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
|
||||
vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder
|
||||
|
||||
@ -56,37 +56,37 @@ endif
|
||||
#example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022
|
||||
#example_xma.DESCRIPTION = External Memory Allocation mode usage
|
||||
|
||||
GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += simple_decoder.c
|
||||
simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
|
||||
simple_decoder.DESCRIPTION = Simplified decoder loop
|
||||
GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += postproc.c
|
||||
postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
|
||||
postproc.DESCRIPTION = Decoder postprocessor control
|
||||
GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += decode_to_md5.c
|
||||
decode_to_md5.SRCS += md5_utils.h md5_utils.c
|
||||
decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
|
||||
decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum
|
||||
|
||||
GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += simple_encoder.c
|
||||
simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
|
||||
simple_encoder.DESCRIPTION = Simplified encoder loop
|
||||
GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += twopass_encoder.c
|
||||
twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
|
||||
twopass_encoder.DESCRIPTION = Two-pass encoder loop
|
||||
GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += force_keyframe.c
|
||||
force_keyframe.GUID = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
|
||||
force_keyframe.DESCRIPTION = Force generation of keyframes
|
||||
ifeq ($(CONFIG_DECODERS),yes)
|
||||
GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += decode_with_drops.c
|
||||
endif
|
||||
decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
|
||||
decode_with_drops.DESCRIPTION = Drops frames while decoding
|
||||
ifeq ($(CONFIG_DECODERS),yes)
|
||||
ifeq ($(CONFIG_VP8_DECODER),yes)
|
||||
GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c
|
||||
endif
|
||||
decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E
|
||||
decode_with_partial_drops.DESCRIPTION = Drops parts of frames while decoding
|
||||
GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c
|
||||
GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += error_resilient.c
|
||||
error_resilient.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C
|
||||
error_resilient.DESCRIPTION = Error Resiliency Feature
|
||||
|
||||
@ -115,9 +115,11 @@ vp8_multi_resolution_encoder.DESCRIPTION = VP8 Multiple-resolution Encoding
|
||||
# when building for bare-metal targets
|
||||
ifeq ($(CONFIG_OS_SUPPORT), yes)
|
||||
CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
|
||||
CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
|
||||
else
|
||||
ifeq ($(CONFIG_GCC), yes)
|
||||
CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
|
||||
CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
|
||||
endif
|
||||
endif
|
||||
#
|
||||
@ -136,6 +138,8 @@ else
|
||||
LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
|
||||
INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8
|
||||
INC_PATH-$(CONFIG_VP8_ENCODER) += $(SRC_PATH_BARE)/vp8
|
||||
INC_PATH-$(CONFIG_VP9_DECODER) += $(SRC_PATH_BARE)/vp9
|
||||
INC_PATH-$(CONFIG_VP9_ENCODER) += $(SRC_PATH_BARE)/vp9
|
||||
LIB_PATH := $(call enabled,LIB_PATH)
|
||||
INC_PATH := $(call enabled,INC_PATH)
|
||||
endif
|
||||
@ -179,7 +183,8 @@ BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_S
|
||||
|
||||
# Instantiate linker template for all examples.
|
||||
CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
|
||||
CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
|
||||
SHARED_LIB_SUF=$(if $(filter darwin%,$(TGT_OS)),.dylib,.so)
|
||||
CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
|
||||
$(foreach bin,$(BINS-yes),\
|
||||
$(if $(BUILD_OBJS),$(eval $(bin):\
|
||||
$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\
|
||||
@ -209,7 +214,7 @@ INSTALL_MAPS += % %
|
||||
|
||||
# Set up additional MSVS environment
|
||||
ifeq ($(CONFIG_MSVS),yes)
|
||||
CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
|
||||
CODEC_LIB=$(if $(CONFIG_SHARED),vpx,$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd))
|
||||
# This variable uses deferred expansion intentionally, since the results of
|
||||
# $(wildcard) may change during the course of the Make.
|
||||
VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
|
||||
|
@ -12,6 +12,7 @@
|
||||
/*
|
||||
@*INTRODUCTION
|
||||
*/
|
||||
#include "vpx_config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
|
||||
#define VPX_CODEC_DISABLE_COMPAT 1
|
||||
#include "vpx/vpx_decoder.h"
|
||||
#include "vpx/vp8dx.h"
|
||||
#include "vpx/vp9dx.h"
|
||||
#define interface (vpx_codec_vp8_dx())
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES
|
||||
#define VPX_CODEC_DISABLE_COMPAT 1
|
||||
#include "vpx/vpx_encoder.h"
|
||||
#include "vpx/vp8cx.h"
|
||||
#include "vpx/vp9cx.h"
|
||||
#define interface (vpx_codec_vp8_cx())
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES
|
||||
|
||||
|
@ -51,7 +51,7 @@ Some codecs provide fine grained controls over their built-in
|
||||
postprocessors. VP8 is one example. The following sample code toggles
|
||||
postprocessing on and off every 15 frames.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE
|
||||
#if CONFIG_VP8_DECODER
|
||||
#if CONFIG_VP9_DECODER
|
||||
if(frame_cnt%30 == 1) {
|
||||
vp8_postproc_cfg_t pp = {0, 0, 0};
|
||||
|
||||
|
@ -1,60 +1,54 @@
|
||||
//#include <strmif.h>
|
||||
// #include <strmif.h>
|
||||
#include "EbmlBufferWriter.h"
|
||||
#include "EbmlWriter.h"
|
||||
//#include <cassert>
|
||||
//#include <limits>
|
||||
//#include <malloc.h> //_alloca
|
||||
// #include <cassert>
|
||||
// #include <limits>
|
||||
// #include <malloc.h> //_alloca
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
|
||||
{
|
||||
unsigned char *src = glob->buf;
|
||||
src += glob->offset;
|
||||
memcpy(src, buffer_in, len);
|
||||
glob->offset += len;
|
||||
void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
|
||||
unsigned char *src = glob->buf;
|
||||
src += glob->offset;
|
||||
memcpy(src, buffer_in, len);
|
||||
glob->offset += len;
|
||||
}
|
||||
|
||||
static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q)
|
||||
{
|
||||
while (q != p)
|
||||
{
|
||||
--q;
|
||||
static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q) {
|
||||
while (q != p) {
|
||||
--q;
|
||||
|
||||
unsigned long cbWritten;
|
||||
memcpy(&(glob->buf[glob->offset]), q, 1);
|
||||
glob->offset ++;
|
||||
}
|
||||
unsigned long cbWritten;
|
||||
memcpy(&(glob->buf[glob->offset]), q, 1);
|
||||
glob->offset++;
|
||||
}
|
||||
}
|
||||
|
||||
void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
|
||||
{
|
||||
//assert(buf);
|
||||
void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
|
||||
// assert(buf);
|
||||
|
||||
const unsigned char *const p = (const unsigned char *)(buffer_in);
|
||||
const unsigned char *const q = p + len;
|
||||
const unsigned char *const p = (const unsigned char *)(buffer_in);
|
||||
const unsigned char *const q = p + len;
|
||||
|
||||
_Serialize(glob, p, q);
|
||||
_Serialize(glob, p, q);
|
||||
}
|
||||
|
||||
|
||||
void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id)
|
||||
{
|
||||
Ebml_WriteID(glob, class_id);
|
||||
ebmlLoc->offset = glob->offset;
|
||||
//todo this is always taking 8 bytes, this may need later optimization
|
||||
unsigned long long unknownLen = 0x01FFFFFFFFFFFFFFLLU;
|
||||
Ebml_Serialize(glob, (void *)&unknownLen, 8); //this is a key that says lenght unknown
|
||||
void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
ebmlLoc->offset = glob->offset;
|
||||
// todo this is always taking 8 bytes, this may need later optimization
|
||||
unsigned long long unknownLen = 0x01FFFFFFFFFFFFFFLLU;
|
||||
Ebml_Serialize(glob, (void *)&unknownLen, 8); // this is a key that says lenght unknown
|
||||
}
|
||||
|
||||
void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc)
|
||||
{
|
||||
unsigned long long size = glob->offset - ebmlLoc->offset - 8;
|
||||
unsigned long long curOffset = glob->offset;
|
||||
glob->offset = ebmlLoc->offset;
|
||||
size |= 0x0100000000000000LLU;
|
||||
Ebml_Serialize(glob, &size, 8);
|
||||
glob->offset = curOffset;
|
||||
void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
|
||||
unsigned long long size = glob->offset - ebmlLoc->offset - 8;
|
||||
unsigned long long curOffset = glob->offset;
|
||||
glob->offset = ebmlLoc->offset;
|
||||
size |= 0x0100000000000000LLU;
|
||||
Ebml_Serialize(glob, &size, 8);
|
||||
glob->offset = curOffset;
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,14 @@
|
||||
#ifndef EBMLBUFFERWRITER_HPP
|
||||
#define EBMLBUFFERWRITER_HPP
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long long offset;
|
||||
typedef struct {
|
||||
unsigned long long offset;
|
||||
} EbmlLoc;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *buf;
|
||||
unsigned int length;
|
||||
unsigned int offset;
|
||||
typedef struct {
|
||||
unsigned char *buf;
|
||||
unsigned int length;
|
||||
unsigned int offset;
|
||||
} EbmlGlobal;
|
||||
|
||||
|
||||
|
189
libmkv/EbmlIDs.h
189
libmkv/EbmlIDs.h
@ -12,35 +12,34 @@
|
||||
|
||||
/* Commenting out values not available in webm, but available in matroska */
|
||||
|
||||
enum mkv
|
||||
{
|
||||
EBML = 0x1A45DFA3,
|
||||
EBMLVersion = 0x4286,
|
||||
EBMLReadVersion = 0x42F7,
|
||||
EBMLMaxIDLength = 0x42F2,
|
||||
EBMLMaxSizeLength = 0x42F3,
|
||||
DocType = 0x4282,
|
||||
DocTypeVersion = 0x4287,
|
||||
DocTypeReadVersion = 0x4285,
|
||||
enum mkv {
|
||||
EBML = 0x1A45DFA3,
|
||||
EBMLVersion = 0x4286,
|
||||
EBMLReadVersion = 0x42F7,
|
||||
EBMLMaxIDLength = 0x42F2,
|
||||
EBMLMaxSizeLength = 0x42F3,
|
||||
DocType = 0x4282,
|
||||
DocTypeVersion = 0x4287,
|
||||
DocTypeReadVersion = 0x4285,
|
||||
/* CRC_32 = 0xBF, */
|
||||
Void = 0xEC,
|
||||
SignatureSlot = 0x1B538667,
|
||||
SignatureAlgo = 0x7E8A,
|
||||
SignatureHash = 0x7E9A,
|
||||
SignaturePublicKey = 0x7EA5,
|
||||
Signature = 0x7EB5,
|
||||
SignatureElements = 0x7E5B,
|
||||
SignatureElementList = 0x7E7B,
|
||||
SignedElement = 0x6532,
|
||||
/* segment */
|
||||
Segment = 0x18538067,
|
||||
/* Meta Seek Information */
|
||||
SeekHead = 0x114D9B74,
|
||||
Seek = 0x4DBB,
|
||||
SeekID = 0x53AB,
|
||||
SeekPosition = 0x53AC,
|
||||
/* Segment Information */
|
||||
Info = 0x1549A966,
|
||||
Void = 0xEC,
|
||||
SignatureSlot = 0x1B538667,
|
||||
SignatureAlgo = 0x7E8A,
|
||||
SignatureHash = 0x7E9A,
|
||||
SignaturePublicKey = 0x7EA5,
|
||||
Signature = 0x7EB5,
|
||||
SignatureElements = 0x7E5B,
|
||||
SignatureElementList = 0x7E7B,
|
||||
SignedElement = 0x6532,
|
||||
/* segment */
|
||||
Segment = 0x18538067,
|
||||
/* Meta Seek Information */
|
||||
SeekHead = 0x114D9B74,
|
||||
Seek = 0x4DBB,
|
||||
SeekID = 0x53AB,
|
||||
SeekPosition = 0x53AC,
|
||||
/* Segment Information */
|
||||
Info = 0x1549A966,
|
||||
/* SegmentUID = 0x73A4, */
|
||||
/* SegmentFilename = 0x7384, */
|
||||
/* PrevUID = 0x3CB923, */
|
||||
@ -52,61 +51,61 @@ enum mkv
|
||||
/* ChapterTranslateEditionUID = 0x69FC, */
|
||||
/* ChapterTranslateCodec = 0x69BF, */
|
||||
/* ChapterTranslateID = 0x69A5, */
|
||||
TimecodeScale = 0x2AD7B1,
|
||||
Segment_Duration = 0x4489,
|
||||
DateUTC = 0x4461,
|
||||
TimecodeScale = 0x2AD7B1,
|
||||
Segment_Duration = 0x4489,
|
||||
DateUTC = 0x4461,
|
||||
/* Title = 0x7BA9, */
|
||||
MuxingApp = 0x4D80,
|
||||
WritingApp = 0x5741,
|
||||
/* Cluster */
|
||||
Cluster = 0x1F43B675,
|
||||
Timecode = 0xE7,
|
||||
MuxingApp = 0x4D80,
|
||||
WritingApp = 0x5741,
|
||||
/* Cluster */
|
||||
Cluster = 0x1F43B675,
|
||||
Timecode = 0xE7,
|
||||
/* SilentTracks = 0x5854, */
|
||||
/* SilentTrackNumber = 0x58D7, */
|
||||
/* Position = 0xA7, */
|
||||
PrevSize = 0xAB,
|
||||
BlockGroup = 0xA0,
|
||||
Block = 0xA1,
|
||||
PrevSize = 0xAB,
|
||||
BlockGroup = 0xA0,
|
||||
Block = 0xA1,
|
||||
/* BlockVirtual = 0xA2, */
|
||||
/* BlockAdditions = 0x75A1, */
|
||||
/* BlockMore = 0xA6, */
|
||||
/* BlockAddID = 0xEE, */
|
||||
/* BlockAdditional = 0xA5, */
|
||||
BlockDuration = 0x9B,
|
||||
BlockDuration = 0x9B,
|
||||
/* ReferencePriority = 0xFA, */
|
||||
ReferenceBlock = 0xFB,
|
||||
ReferenceBlock = 0xFB,
|
||||
/* ReferenceVirtual = 0xFD, */
|
||||
/* CodecState = 0xA4, */
|
||||
/* Slices = 0x8E, */
|
||||
/* TimeSlice = 0xE8, */
|
||||
LaceNumber = 0xCC,
|
||||
LaceNumber = 0xCC,
|
||||
/* FrameNumber = 0xCD, */
|
||||
/* BlockAdditionID = 0xCB, */
|
||||
/* MkvDelay = 0xCE, */
|
||||
/* Cluster_Duration = 0xCF, */
|
||||
SimpleBlock = 0xA3,
|
||||
SimpleBlock = 0xA3,
|
||||
/* EncryptedBlock = 0xAF, */
|
||||
/* Track */
|
||||
Tracks = 0x1654AE6B,
|
||||
TrackEntry = 0xAE,
|
||||
TrackNumber = 0xD7,
|
||||
TrackUID = 0x73C5,
|
||||
TrackType = 0x83,
|
||||
FlagEnabled = 0xB9,
|
||||
FlagDefault = 0x88,
|
||||
FlagForced = 0x55AA,
|
||||
FlagLacing = 0x9C,
|
||||
/* Track */
|
||||
Tracks = 0x1654AE6B,
|
||||
TrackEntry = 0xAE,
|
||||
TrackNumber = 0xD7,
|
||||
TrackUID = 0x73C5,
|
||||
TrackType = 0x83,
|
||||
FlagEnabled = 0xB9,
|
||||
FlagDefault = 0x88,
|
||||
FlagForced = 0x55AA,
|
||||
FlagLacing = 0x9C,
|
||||
/* MinCache = 0x6DE7, */
|
||||
/* MaxCache = 0x6DF8, */
|
||||
DefaultDuration = 0x23E383,
|
||||
DefaultDuration = 0x23E383,
|
||||
/* TrackTimecodeScale = 0x23314F, */
|
||||
/* TrackOffset = 0x537F, */
|
||||
/* MaxBlockAdditionID = 0x55EE, */
|
||||
Name = 0x536E,
|
||||
Language = 0x22B59C,
|
||||
CodecID = 0x86,
|
||||
CodecPrivate = 0x63A2,
|
||||
CodecName = 0x258688,
|
||||
Name = 0x536E,
|
||||
Language = 0x22B59C,
|
||||
CodecID = 0x86,
|
||||
CodecPrivate = 0x63A2,
|
||||
CodecName = 0x258688,
|
||||
/* AttachmentLink = 0x7446, */
|
||||
/* CodecSettings = 0x3A9697, */
|
||||
/* CodecInfoURL = 0x3B4040, */
|
||||
@ -117,33 +116,33 @@ enum mkv
|
||||
/* TrackTranslateEditionUID = 0x66FC, */
|
||||
/* TrackTranslateCodec = 0x66BF, */
|
||||
/* TrackTranslateTrackID = 0x66A5, */
|
||||
/* video */
|
||||
Video = 0xE0,
|
||||
FlagInterlaced = 0x9A,
|
||||
StereoMode = 0x53B8,
|
||||
PixelWidth = 0xB0,
|
||||
PixelHeight = 0xBA,
|
||||
PixelCropBottom = 0x54AA,
|
||||
PixelCropTop = 0x54BB,
|
||||
PixelCropLeft = 0x54CC,
|
||||
PixelCropRight = 0x54DD,
|
||||
DisplayWidth = 0x54B0,
|
||||
DisplayHeight = 0x54BA,
|
||||
DisplayUnit = 0x54B2,
|
||||
AspectRatioType = 0x54B3,
|
||||
/* video */
|
||||
Video = 0xE0,
|
||||
FlagInterlaced = 0x9A,
|
||||
StereoMode = 0x53B8,
|
||||
PixelWidth = 0xB0,
|
||||
PixelHeight = 0xBA,
|
||||
PixelCropBottom = 0x54AA,
|
||||
PixelCropTop = 0x54BB,
|
||||
PixelCropLeft = 0x54CC,
|
||||
PixelCropRight = 0x54DD,
|
||||
DisplayWidth = 0x54B0,
|
||||
DisplayHeight = 0x54BA,
|
||||
DisplayUnit = 0x54B2,
|
||||
AspectRatioType = 0x54B3,
|
||||
/* ColourSpace = 0x2EB524, */
|
||||
/* GammaValue = 0x2FB523, */
|
||||
FrameRate = 0x2383E3,
|
||||
/* end video */
|
||||
/* audio */
|
||||
Audio = 0xE1,
|
||||
SamplingFrequency = 0xB5,
|
||||
OutputSamplingFrequency = 0x78B5,
|
||||
Channels = 0x9F,
|
||||
FrameRate = 0x2383E3,
|
||||
/* end video */
|
||||
/* audio */
|
||||
Audio = 0xE1,
|
||||
SamplingFrequency = 0xB5,
|
||||
OutputSamplingFrequency = 0x78B5,
|
||||
Channels = 0x9F,
|
||||
/* ChannelPositions = 0x7D7B, */
|
||||
BitDepth = 0x6264,
|
||||
/* end audio */
|
||||
/* content encoding */
|
||||
BitDepth = 0x6264,
|
||||
/* end audio */
|
||||
/* content encoding */
|
||||
/* ContentEncodings = 0x6d80, */
|
||||
/* ContentEncoding = 0x6240, */
|
||||
/* ContentEncodingOrder = 0x5031, */
|
||||
@ -159,22 +158,22 @@ enum mkv
|
||||
/* ContentSigKeyID = 0x47e4, */
|
||||
/* ContentSigAlgo = 0x47e5, */
|
||||
/* ContentSigHashAlgo = 0x47e6, */
|
||||
/* end content encoding */
|
||||
/* Cueing Data */
|
||||
Cues = 0x1C53BB6B,
|
||||
CuePoint = 0xBB,
|
||||
CueTime = 0xB3,
|
||||
CueTrackPositions = 0xB7,
|
||||
CueTrack = 0xF7,
|
||||
CueClusterPosition = 0xF1,
|
||||
CueBlockNumber = 0x5378
|
||||
/* end content encoding */
|
||||
/* Cueing Data */
|
||||
Cues = 0x1C53BB6B,
|
||||
CuePoint = 0xBB,
|
||||
CueTime = 0xB3,
|
||||
CueTrackPositions = 0xB7,
|
||||
CueTrack = 0xF7,
|
||||
CueClusterPosition = 0xF1,
|
||||
CueBlockNumber = 0x5378
|
||||
/* CueCodecState = 0xEA, */
|
||||
/* CueReference = 0xDB, */
|
||||
/* CueRefTime = 0x96, */
|
||||
/* CueRefCluster = 0x97, */
|
||||
/* CueRefNumber = 0x535F, */
|
||||
/* CueRefCodecState = 0xEB, */
|
||||
/* Attachment */
|
||||
/* Attachment */
|
||||
/* Attachments = 0x1941A469, */
|
||||
/* AttachedFile = 0x61A7, */
|
||||
/* FileDescription = 0x467E, */
|
||||
@ -183,7 +182,7 @@ enum mkv
|
||||
/* FileData = 0x465C, */
|
||||
/* FileUID = 0x46AE, */
|
||||
/* FileReferral = 0x4675, */
|
||||
/* Chapters */
|
||||
/* Chapters */
|
||||
/* Chapters = 0x1043A770, */
|
||||
/* EditionEntry = 0x45B9, */
|
||||
/* EditionUID = 0x45BC, */
|
||||
@ -211,7 +210,7 @@ enum mkv
|
||||
/* ChapProcessCommand = 0x6911, */
|
||||
/* ChapProcessTime = 0x6922, */
|
||||
/* ChapProcessData = 0x6933, */
|
||||
/* Tagging */
|
||||
/* Tagging */
|
||||
/* Tags = 0x1254C367, */
|
||||
/* Tag = 0x7373, */
|
||||
/* Targets = 0x63C0, */
|
||||
|
@ -18,158 +18,140 @@
|
||||
#define LITERALU64(n) n##LLU
|
||||
#endif
|
||||
|
||||
void Ebml_WriteLen(EbmlGlobal *glob, int64_t val)
|
||||
{
|
||||
/* TODO check and make sure we are not > than 0x0100000000000000LLU */
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
void Ebml_WriteLen(EbmlGlobal *glob, int64_t val) {
|
||||
/* TODO check and make sure we are not > than 0x0100000000000000LLU */
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
|
||||
/* mask to compare for byte size */
|
||||
int64_t minVal = 0xff;
|
||||
/* mask to compare for byte size */
|
||||
int64_t minVal = 0xff;
|
||||
|
||||
for (size = 1; size < 8; size ++)
|
||||
{
|
||||
if (val < minVal)
|
||||
break;
|
||||
for (size = 1; size < 8; size ++) {
|
||||
if (val < minVal)
|
||||
break;
|
||||
|
||||
minVal = (minVal << 7);
|
||||
minVal = (minVal << 7);
|
||||
}
|
||||
|
||||
val |= (((uint64_t)0x80) << ((size - 1) * 7));
|
||||
|
||||
Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
|
||||
}
|
||||
|
||||
void Ebml_WriteString(EbmlGlobal *glob, const char *str) {
|
||||
const size_t size_ = strlen(str);
|
||||
const uint64_t size = size_;
|
||||
Ebml_WriteLen(glob, size);
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we omit the null terminator.
|
||||
*/
|
||||
Ebml_Write(glob, str, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) {
|
||||
const size_t strlen = wcslen(wstr);
|
||||
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we include it.
|
||||
*/
|
||||
const uint64_t size = strlen;
|
||||
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_Write(glob, wstr, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id) {
|
||||
int len;
|
||||
|
||||
if (class_id >= 0x01000000)
|
||||
len = 4;
|
||||
else if (class_id >= 0x00010000)
|
||||
len = 3;
|
||||
else if (class_id >= 0x00000100)
|
||||
len = 2;
|
||||
else
|
||||
len = 1;
|
||||
|
||||
Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) {
|
||||
unsigned char sizeSerialized = 8 | 0x80;
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), 8);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui) {
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
unsigned char sizeSerialized = 0;
|
||||
unsigned long minVal;
|
||||
|
||||
Ebml_WriteID(glob, class_id);
|
||||
minVal = 0x7fLU; /* mask to compare for byte size */
|
||||
|
||||
for (size = 1; size < 4; size ++) {
|
||||
if (ui < minVal) {
|
||||
break;
|
||||
}
|
||||
|
||||
val |= (((uint64_t)0x80) << ((size - 1) * 7));
|
||||
minVal <<= 7;
|
||||
}
|
||||
|
||||
Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
|
||||
}
|
||||
|
||||
void Ebml_WriteString(EbmlGlobal *glob, const char *str)
|
||||
{
|
||||
const size_t size_ = strlen(str);
|
||||
const uint64_t size = size_;
|
||||
Ebml_WriteLen(glob, size);
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we omit the null terminator.
|
||||
*/
|
||||
Ebml_Write(glob, str, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr)
|
||||
{
|
||||
const size_t strlen = wcslen(wstr);
|
||||
|
||||
/* TODO: it's not clear from the spec whether the nul terminator
|
||||
* should be serialized too. For now we include it.
|
||||
*/
|
||||
const uint64_t size = strlen;
|
||||
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_Write(glob, wstr, (unsigned long)size);
|
||||
}
|
||||
|
||||
void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (class_id >= 0x01000000)
|
||||
len = 4;
|
||||
else if (class_id >= 0x00010000)
|
||||
len = 3;
|
||||
else if (class_id >= 0x00000100)
|
||||
len = 2;
|
||||
else
|
||||
len = 1;
|
||||
|
||||
Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui)
|
||||
{
|
||||
unsigned char sizeSerialized = 8 | 0x80;
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), 8);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui)
|
||||
{
|
||||
unsigned char size = 8; /* size in bytes to output */
|
||||
unsigned char sizeSerialized = 0;
|
||||
unsigned long minVal;
|
||||
|
||||
Ebml_WriteID(glob, class_id);
|
||||
minVal = 0x7fLU; /* mask to compare for byte size */
|
||||
|
||||
for (size = 1; size < 4; size ++)
|
||||
{
|
||||
if (ui < minVal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
minVal <<= 7;
|
||||
}
|
||||
|
||||
sizeSerialized = 0x80 | size;
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), size);
|
||||
sizeSerialized = 0x80 | size;
|
||||
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
|
||||
Ebml_Serialize(glob, &ui, sizeof(ui), size);
|
||||
}
|
||||
/* TODO: perhaps this is a poor name for this id serializer helper function */
|
||||
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin)
|
||||
{
|
||||
int size;
|
||||
for (size=4; size > 1; size--)
|
||||
{
|
||||
if (bin & 0x000000ff << ((size-1) * 8))
|
||||
break;
|
||||
}
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_WriteID(glob, bin);
|
||||
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin) {
|
||||
int size;
|
||||
for (size = 4; size > 1; size--) {
|
||||
if (bin & 0x000000ff << ((size - 1) * 8))
|
||||
break;
|
||||
}
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, size);
|
||||
Ebml_WriteID(glob, bin);
|
||||
}
|
||||
|
||||
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d)
|
||||
{
|
||||
unsigned char len = 0x88;
|
||||
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d) {
|
||||
unsigned char len = 0x88;
|
||||
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &len, sizeof(len), 1);
|
||||
Ebml_Serialize(glob, &d, sizeof(d), 8);
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_Serialize(glob, &len, sizeof(len), 1);
|
||||
Ebml_Serialize(glob, &d, sizeof(d), 8);
|
||||
}
|
||||
|
||||
void Ebml_WriteSigned16(EbmlGlobal *glob, short val)
|
||||
{
|
||||
signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
|
||||
Ebml_Serialize(glob, &out, sizeof(out), 3);
|
||||
void Ebml_WriteSigned16(EbmlGlobal *glob, short val) {
|
||||
signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
|
||||
Ebml_Serialize(glob, &out, sizeof(out), 3);
|
||||
}
|
||||
|
||||
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s)
|
||||
{
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteString(glob, s);
|
||||
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteString(glob, s);
|
||||
}
|
||||
|
||||
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s)
|
||||
{
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteUTF8(glob, s);
|
||||
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteUTF8(glob, s);
|
||||
}
|
||||
|
||||
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length)
|
||||
{
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, data_length);
|
||||
Ebml_Write(glob, data, data_length);
|
||||
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length) {
|
||||
Ebml_WriteID(glob, class_id);
|
||||
Ebml_WriteLen(glob, data_length);
|
||||
Ebml_Write(glob, data, data_length);
|
||||
}
|
||||
|
||||
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize)
|
||||
{
|
||||
unsigned char tmp = 0;
|
||||
unsigned long i = 0;
|
||||
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) {
|
||||
unsigned char tmp = 0;
|
||||
unsigned long i = 0;
|
||||
|
||||
Ebml_WriteID(glob, 0xEC);
|
||||
Ebml_WriteLen(glob, vSize);
|
||||
Ebml_WriteID(glob, 0xEC);
|
||||
Ebml_WriteLen(glob, vSize);
|
||||
|
||||
for (i = 0; i < vSize; i++)
|
||||
{
|
||||
Ebml_Write(glob, &tmp, 1);
|
||||
}
|
||||
for (i = 0; i < vSize; i++) {
|
||||
Ebml_Write(glob, &tmp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO Serialize Date */
|
||||
|
@ -14,106 +14,100 @@
|
||||
|
||||
#define kVorbisPrivateMaxSize 4000
|
||||
|
||||
void writeHeader(EbmlGlobal *glob)
|
||||
{
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, EBML);
|
||||
Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
|
||||
Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); //EBML Read Version
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); //EBML Max ID Length
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); //EBML Max Size Length
|
||||
Ebml_SerializeString(glob, DocType, "webm"); //Doc Type
|
||||
Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); //Doc Type Version
|
||||
Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); //Doc Type Read Version
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
void writeHeader(EbmlGlobal *glob) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, EBML);
|
||||
Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
|
||||
Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); // EBML Read Version
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); // EBML Max ID Length
|
||||
Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); // EBML Max Size Length
|
||||
Ebml_SerializeString(glob, DocType, "webm"); // Doc Type
|
||||
Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); // Doc Type Version
|
||||
Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); // Doc Type Read Version
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
}
|
||||
|
||||
void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCode,
|
||||
int isKeyframe, unsigned char lacingFlag, int discardable,
|
||||
unsigned char *data, unsigned long dataLength)
|
||||
{
|
||||
Ebml_WriteID(glob, SimpleBlock);
|
||||
unsigned long blockLength = 4 + dataLength;
|
||||
blockLength |= 0x10000000; //TODO check length < 0x0FFFFFFFF
|
||||
Ebml_Serialize(glob, &blockLength, sizeof(blockLength), 4);
|
||||
trackNumber |= 0x80; //TODO check track nubmer < 128
|
||||
Ebml_Write(glob, &trackNumber, 1);
|
||||
//Ebml_WriteSigned16(glob, timeCode,2); //this is 3 bytes
|
||||
Ebml_Serialize(glob, &timeCode, sizeof(timeCode), 2);
|
||||
unsigned char flags = 0x00 | (isKeyframe ? 0x80 : 0x00) | (lacingFlag << 1) | discardable;
|
||||
Ebml_Write(glob, &flags, 1);
|
||||
Ebml_Write(glob, data, dataLength);
|
||||
unsigned char *data, unsigned long dataLength) {
|
||||
Ebml_WriteID(glob, SimpleBlock);
|
||||
unsigned long blockLength = 4 + dataLength;
|
||||
blockLength |= 0x10000000; // TODO check length < 0x0FFFFFFFF
|
||||
Ebml_Serialize(glob, &blockLength, sizeof(blockLength), 4);
|
||||
trackNumber |= 0x80; // TODO check track nubmer < 128
|
||||
Ebml_Write(glob, &trackNumber, 1);
|
||||
// Ebml_WriteSigned16(glob, timeCode,2); //this is 3 bytes
|
||||
Ebml_Serialize(glob, &timeCode, sizeof(timeCode), 2);
|
||||
unsigned char flags = 0x00 | (isKeyframe ? 0x80 : 0x00) | (lacingFlag << 1) | discardable;
|
||||
Ebml_Write(glob, &flags, 1);
|
||||
Ebml_Write(glob, data, dataLength);
|
||||
}
|
||||
|
||||
static UInt64 generateTrackID(unsigned int trackNumber)
|
||||
{
|
||||
UInt64 t = time(NULL) * trackNumber;
|
||||
UInt64 r = rand();
|
||||
r = r << 32;
|
||||
r += rand();
|
||||
UInt64 rval = t ^ r;
|
||||
return rval;
|
||||
static UInt64 generateTrackID(unsigned int trackNumber) {
|
||||
UInt64 t = time(NULL) * trackNumber;
|
||||
UInt64 r = rand();
|
||||
r = r << 32;
|
||||
r += rand();
|
||||
UInt64 rval = t ^ r;
|
||||
return rval;
|
||||
}
|
||||
|
||||
void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
|
||||
char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
|
||||
double frameRate)
|
||||
{
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
UInt64 trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeString(glob, CodecName, "VP8"); //TODO shouldn't be fixed
|
||||
double frameRate) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
UInt64 trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeString(glob, CodecName, "VP8"); // TODO shouldn't be fixed
|
||||
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 1); //video is always 1
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
{
|
||||
EbmlLoc videoStart;
|
||||
Ebml_StartSubElement(glob, &videoStart, Video);
|
||||
Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
|
||||
Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
|
||||
Ebml_SerializeFloat(glob, FrameRate, frameRate);
|
||||
Ebml_EndSubElement(glob, &videoStart); //Video
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start); //Track Entry
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
{
|
||||
EbmlLoc videoStart;
|
||||
Ebml_StartSubElement(glob, &videoStart, Video);
|
||||
Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
|
||||
Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
|
||||
Ebml_SerializeFloat(glob, FrameRate, frameRate);
|
||||
Ebml_EndSubElement(glob, &videoStart); // Video
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start); // Track Entry
|
||||
}
|
||||
void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
|
||||
char *codecId, double samplingFrequency, unsigned int channels,
|
||||
unsigned char *private, unsigned long privateSize)
|
||||
{
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
UInt64 trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 2); //audio is always 2
|
||||
//I am using defaults for thesed required fields
|
||||
/* Ebml_SerializeUnsigned(glob, FlagEnabled, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagDefault, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagForced, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagLacing, flagLacing);*/
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
Ebml_SerializeData(glob, CodecPrivate, private, privateSize);
|
||||
unsigned char *private, unsigned long privateSize) {
|
||||
EbmlLoc start;
|
||||
Ebml_StartSubElement(glob, &start, TrackEntry);
|
||||
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
|
||||
UInt64 trackID = generateTrackID(trackNumber);
|
||||
Ebml_SerializeUnsigned(glob, TrackUID, trackID);
|
||||
Ebml_SerializeUnsigned(glob, TrackType, 2); // audio is always 2
|
||||
// I am using defaults for thesed required fields
|
||||
/* Ebml_SerializeUnsigned(glob, FlagEnabled, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagDefault, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagForced, 1);
|
||||
Ebml_SerializeUnsigned(glob, FlagLacing, flagLacing);*/
|
||||
Ebml_SerializeString(glob, CodecID, codecId);
|
||||
Ebml_SerializeData(glob, CodecPrivate, private, privateSize);
|
||||
|
||||
Ebml_SerializeString(glob, CodecName, "VORBIS"); //fixed for now
|
||||
{
|
||||
EbmlLoc AudioStart;
|
||||
Ebml_StartSubElement(glob, &AudioStart, Audio);
|
||||
Ebml_SerializeFloat(glob, SamplingFrequency, samplingFrequency);
|
||||
Ebml_SerializeUnsigned(glob, Channels, channels);
|
||||
Ebml_EndSubElement(glob, &AudioStart);
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
Ebml_SerializeString(glob, CodecName, "VORBIS"); // fixed for now
|
||||
{
|
||||
EbmlLoc AudioStart;
|
||||
Ebml_StartSubElement(glob, &AudioStart, Audio);
|
||||
Ebml_SerializeFloat(glob, SamplingFrequency, samplingFrequency);
|
||||
Ebml_SerializeUnsigned(glob, Channels, channels);
|
||||
Ebml_EndSubElement(glob, &AudioStart);
|
||||
}
|
||||
Ebml_EndSubElement(glob, &start);
|
||||
}
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc* startInfo, unsigned long timeCodeScale, double duration)
|
||||
{
|
||||
Ebml_StartSubElement(ebml, startInfo, Info);
|
||||
Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
|
||||
Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); //Currently fixed to using milliseconds
|
||||
Ebml_SerializeString(ebml, 0x4D80, "QTmuxingAppLibWebM-0.0.1");
|
||||
Ebml_SerializeString(ebml, 0x5741, "QTwritingAppLibWebM-0.0.1");
|
||||
Ebml_EndSubElement(ebml, startInfo);
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration) {
|
||||
Ebml_StartSubElement(ebml, startInfo, Info);
|
||||
Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
|
||||
Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); // Currently fixed to using milliseconds
|
||||
Ebml_SerializeString(ebml, 0x4D80, "QTmuxingAppLibWebM-0.0.1");
|
||||
Ebml_SerializeString(ebml, 0x5741, "QTwritingAppLibWebM-0.0.1");
|
||||
Ebml_EndSubElement(ebml, startInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -142,7 +136,7 @@ void Mkv_WriteSegmentInformation(Ebml& ebml_out, SegmentInformationStruct& segme
|
||||
Ebml_SerializeString(ebml_out, 0x7384, segmentInformation.filename);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x2AD7B1, segmentInformation.TimecodeScale);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x4489, segmentInformation.Duration);
|
||||
//TODO date
|
||||
// TODO date
|
||||
Ebml_SerializeWString(ebml_out, 0x4D80, L"MKVMUX");
|
||||
Ebml_SerializeWString(ebml_out, 0x5741, segmentInformation.WritingApp);
|
||||
}
|
||||
@ -173,9 +167,9 @@ static void Mkv_WriteGenericTrackData(Ebml& ebml_out, TrackStruct& track)
|
||||
void Mkv_WriteVideoTrack(Ebml& ebml_out, TrackStruct & track, VideoTrackStruct& video)
|
||||
{
|
||||
EbmlLoc trackHeadLoc, videoHeadLoc;
|
||||
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE); //start Track
|
||||
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE); // start Track
|
||||
Mkv_WriteGenericTrackData(ebml_out, track);
|
||||
Ebml_StartSubElement(ebml_out, videoHeadLoc, 0xE0); //start Video
|
||||
Ebml_StartSubElement(ebml_out, videoHeadLoc, 0xE0); // start Video
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x9A, video.FlagInterlaced ? 1 :0);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xB0, video.PixelWidth);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0xBA, video.PixelHeight);
|
||||
@ -193,7 +187,7 @@ void Mkv_WriteAudioTrack(Ebml& ebml_out, TrackStruct & track, AudioTrackStruct&
|
||||
EbmlLoc trackHeadLoc, audioHeadLoc;
|
||||
Ebml_StartSubElement(ebml_out, trackHeadLoc, 0xAE);
|
||||
Mkv_WriteGenericTrackData(ebml_out, track);
|
||||
Ebml_StartSubElement(ebml_out, audioHeadLoc, 0xE0); //start Audio
|
||||
Ebml_StartSubElement(ebml_out, audioHeadLoc, 0xE0); // start Audio
|
||||
Ebml_SerializeFloat(ebml_out, 0xB5, video.SamplingFrequency);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x9F, video.Channels);
|
||||
Ebml_SerializeUnsigned(ebml_out, 0x6264, video.BitDepth);
|
||||
@ -213,7 +207,7 @@ void Mkv_WriteSimpleBlockHead(Ebml& ebml_out, EbmlLoc& ebmlLoc, SimpleBlockStru
|
||||
Ebml_Write1UInt(ebml_out, block.TrackNumber);
|
||||
Ebml_WriteSigned16(ebml_out,block.TimeCode);
|
||||
unsigned char flags = 0x00 | (block.iskey ? 0x80:0x00) | (block.lacing << 1) | block.discardable;
|
||||
Ebml_Write1UInt(ebml_out, flags); //TODO this may be the wrong function
|
||||
Ebml_Write1UInt(ebml_out, flags); // TODO this may be the wrong function
|
||||
Ebml_Serialize(ebml_out, block.data, block.dataLength);
|
||||
Ebml_EndSubElement(ebml_out,ebmlLoc);
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ void writeSimpleBock(EbmlGlobal *ebml, unsigned char trackNumber, unsigned short
|
||||
|
||||
// these are helper functions
|
||||
void writeHeader(EbmlGlobal *ebml);
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc* startInfo , unsigned long timeCodeScale, double duration);
|
||||
//this function is a helper only, it assumes a lot of defaults
|
||||
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration);
|
||||
// this function is a helper only, it assumes a lot of defaults
|
||||
void writeVideoTrack(EbmlGlobal *ebml, unsigned int trackNumber, int flagLacing,
|
||||
char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
|
||||
double frameRate);
|
||||
|
@ -13,51 +13,50 @@
|
||||
#include "WebMElement.h"
|
||||
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//init the datatype we're using for ebml output
|
||||
unsigned char data[8192];
|
||||
EbmlGlobal ebml;
|
||||
ebml.buf = data;
|
||||
ebml.offset = 0;
|
||||
ebml.length = 8192;
|
||||
int main(int argc, char *argv[]) {
|
||||
// init the datatype we're using for ebml output
|
||||
unsigned char data[8192];
|
||||
EbmlGlobal ebml;
|
||||
ebml.buf = data;
|
||||
ebml.offset = 0;
|
||||
ebml.length = 8192;
|
||||
|
||||
writeHeader(&ebml);
|
||||
writeHeader(&ebml);
|
||||
{
|
||||
EbmlLoc startSegment;
|
||||
Ebml_StartSubElement(&ebml, &startSegment, Segment); // segment
|
||||
{
|
||||
EbmlLoc startSegment;
|
||||
Ebml_StartSubElement(&ebml, &startSegment, Segment); //segment
|
||||
{
|
||||
//segment info
|
||||
EbmlLoc startInfo;
|
||||
Ebml_StartSubElement(&ebml, &startInfo, Info);
|
||||
Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
|
||||
Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
|
||||
Ebml_EndSubElement(&ebml, &startInfo);
|
||||
}
|
||||
|
||||
{
|
||||
EbmlLoc trackStart;
|
||||
Ebml_StartSubElement(&ebml, &trackStart, Tracks);
|
||||
writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97);
|
||||
//writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0);
|
||||
Ebml_EndSubElement(&ebml, &trackStart);
|
||||
}
|
||||
|
||||
{
|
||||
EbmlLoc clusterStart;
|
||||
Ebml_StartSubElement(&ebml, &clusterStart, Cluster); //cluster
|
||||
Ebml_SerializeUnsigned(&ebml, Timecode, 0);
|
||||
|
||||
unsigned char someData[4] = {1, 2, 3, 4};
|
||||
writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4);
|
||||
Ebml_EndSubElement(&ebml, &clusterStart);
|
||||
} //end cluster
|
||||
Ebml_EndSubElement(&ebml, &startSegment);
|
||||
// segment info
|
||||
EbmlLoc startInfo;
|
||||
Ebml_StartSubElement(&ebml, &startInfo, Info);
|
||||
Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
|
||||
Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
|
||||
Ebml_EndSubElement(&ebml, &startInfo);
|
||||
}
|
||||
|
||||
//dump ebml stuff to the file
|
||||
FILE *file_out = fopen("test.mkv", "wb");
|
||||
size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
|
||||
fclose(file_out);
|
||||
return 0;
|
||||
{
|
||||
EbmlLoc trackStart;
|
||||
Ebml_StartSubElement(&ebml, &trackStart, Tracks);
|
||||
writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97);
|
||||
// writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0);
|
||||
Ebml_EndSubElement(&ebml, &trackStart);
|
||||
}
|
||||
|
||||
{
|
||||
EbmlLoc clusterStart;
|
||||
Ebml_StartSubElement(&ebml, &clusterStart, Cluster); // cluster
|
||||
Ebml_SerializeUnsigned(&ebml, Timecode, 0);
|
||||
|
||||
unsigned char someData[4] = {1, 2, 3, 4};
|
||||
writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4);
|
||||
Ebml_EndSubElement(&ebml, &clusterStart);
|
||||
} // end cluster
|
||||
Ebml_EndSubElement(&ebml, &startSegment);
|
||||
}
|
||||
|
||||
// dump ebml stuff to the file
|
||||
FILE *file_out = fopen("test.mkv", "wb");
|
||||
size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
|
||||
fclose(file_out);
|
||||
return 0;
|
||||
}
|
201
libs.mk
201
libs.mk
@ -17,6 +17,47 @@ else
|
||||
ASM:=.asm
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Calculate platform- and compiler-specific offsets for hand coded assembly
|
||||
#
|
||||
ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
|
||||
OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
|
||||
define asm_offsets_template
|
||||
$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).S
|
||||
@echo " [CREATE] $$@"
|
||||
$$(qexec)LC_ALL=C grep $$(OFFSET_PATTERN) $$< | tr -d '$$$$\#' $$(ADS2GAS) > $$@
|
||||
$$(BUILD_PFX)$(2).S: $(2)
|
||||
CLEAN-OBJS += $$(BUILD_PFX)$(1) $(2).S
|
||||
endef
|
||||
else
|
||||
ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
|
||||
define asm_offsets_template
|
||||
$$(BUILD_PFX)$(1): obj_int_extract
|
||||
$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).o
|
||||
@echo " [CREATE] $$@"
|
||||
$$(qexec)./obj_int_extract rvds $$< $$(ADS2GAS) > $$@
|
||||
OBJS-yes += $$(BUILD_PFX)$(2).o
|
||||
CLEAN-OBJS += $$(BUILD_PFX)$(1)
|
||||
$$(filter %$$(ASM).o,$$(OBJS-yes)): $$(BUILD_PFX)$(1)
|
||||
endef
|
||||
endif # rvct
|
||||
endif # !gcc
|
||||
|
||||
#
|
||||
# Rule to generate runtime cpu detection files
|
||||
#
|
||||
define rtcd_h_template
|
||||
$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
|
||||
@echo " [CREATE] $$@"
|
||||
$$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$$(TGT_ISA) \
|
||||
--sym=$(1) \
|
||||
--config=$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \
|
||||
$$(RTCD_OPTIONS) $$^ > $$@
|
||||
CLEAN-OBJS += $$(BUILD_PFX)$(1).h
|
||||
RTCD += $$(BUILD_PFX)$(1).h
|
||||
endef
|
||||
|
||||
CODEC_SRCS-yes += CHANGELOG
|
||||
CODEC_SRCS-yes += libs.mk
|
||||
|
||||
@ -40,9 +81,12 @@ CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
|
||||
include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
|
||||
CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
|
||||
|
||||
ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
|
||||
VP8_PREFIX=vp8/
|
||||
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VP8_ENCODER),yes)
|
||||
VP8_PREFIX=vp8/
|
||||
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
|
||||
CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
|
||||
CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
|
||||
@ -52,7 +96,6 @@ ifeq ($(CONFIG_VP8_ENCODER),yes)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VP8_DECODER),yes)
|
||||
VP8_PREFIX=vp8/
|
||||
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
|
||||
CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
|
||||
CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
|
||||
@ -61,6 +104,35 @@ ifeq ($(CONFIG_VP8_DECODER),yes)
|
||||
CODEC_DOC_SECTIONS += vp8 vp8_decoder
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
|
||||
VP9_PREFIX=vp9/
|
||||
include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VP9_ENCODER),yes)
|
||||
VP9_PREFIX=vp9/
|
||||
include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
|
||||
CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
|
||||
CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
|
||||
CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
|
||||
INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
|
||||
INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
|
||||
CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
|
||||
CODEC_DOC_SECTIONS += vp9 vp9_encoder
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VP9_DECODER),yes)
|
||||
VP9_PREFIX=vp9/
|
||||
include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
|
||||
CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
|
||||
CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
|
||||
CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
|
||||
INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
|
||||
INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
|
||||
CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
|
||||
CODEC_DOC_SECTIONS += vp9 vp9_decoder
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_ENCODERS),yes)
|
||||
CODEC_DOC_SECTIONS += encoder
|
||||
@ -91,8 +163,11 @@ endif
|
||||
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.sh
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
|
||||
INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
|
||||
CODEC_SRCS-$(BUILD_LIBVPX) += third_party/x86inc/x86inc.asm
|
||||
CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
|
||||
CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
|
||||
CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
|
||||
@ -116,7 +191,7 @@ INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
|
||||
INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
|
||||
endif
|
||||
|
||||
CODEC_SRCS=$(filter-out %_test.cc,$(call enabled,CODEC_SRCS))
|
||||
CODEC_SRCS=$(call enabled,CODEC_SRCS)
|
||||
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
|
||||
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
|
||||
|
||||
@ -158,8 +233,8 @@ CLEAN-OBJS += vpx.def
|
||||
vpx.vcproj: $(CODEC_SRCS) vpx.def
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
|
||||
--lib \
|
||||
--target=$(TOOLCHAIN) \
|
||||
$(if $(CONFIG_SHARED),--dll,--lib) \
|
||||
--target=$(TOOLCHAIN) \
|
||||
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
|
||||
--name=vpx \
|
||||
--proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
|
||||
@ -171,7 +246,7 @@ vpx.vcproj: $(CODEC_SRCS) vpx.def
|
||||
PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj
|
||||
|
||||
vpx.vcproj: vpx_config.asm
|
||||
vpx.vcproj: vpx_rtcd.h
|
||||
vpx.vcproj: $(RTCD)
|
||||
|
||||
endif
|
||||
else
|
||||
@ -180,17 +255,29 @@ OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
|
||||
LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
|
||||
$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
|
||||
|
||||
|
||||
BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
|
||||
|
||||
ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
|
||||
LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
|
||||
EXPORT_FILE := libvpx.syms
|
||||
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
|
||||
libvpx.dylib )
|
||||
else
|
||||
LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
|
||||
LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
|
||||
$(notdir $(LIBVPX_SO_SYMLINKS))
|
||||
$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) libvpx.ver
|
||||
$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
|
||||
$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
|
||||
$(BUILD_PFX)$(LIBVPX_SO): SO_VERSION_SCRIPT = libvpx.ver
|
||||
EXPORT_FILE := libvpx.ver
|
||||
SYM_LINK := libvpx.so
|
||||
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
|
||||
libvpx.so libvpx.so.$(VERSION_MAJOR) \
|
||||
libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
|
||||
endif
|
||||
|
||||
LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
|
||||
$(notdir $(LIBVPX_SO_SYMLINKS))
|
||||
$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
|
||||
$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
|
||||
$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
|
||||
$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
|
||||
|
||||
libvpx.ver: $(call enabled,CODEC_EXPORTS)
|
||||
@echo " [CREATE] $@"
|
||||
@ -199,10 +286,16 @@ libvpx.ver: $(call enabled,CODEC_EXPORTS)
|
||||
$(qexec)echo "local: *; };" >> $@
|
||||
CLEAN-OBJS += libvpx.ver
|
||||
|
||||
libvpx.syms: $(call enabled,CODEC_EXPORTS)
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)awk '{print "_"$$2}' $^ >$@
|
||||
CLEAN-OBJS += libvpx.syms
|
||||
|
||||
define libvpx_symlink_template
|
||||
$(1): $(2)
|
||||
@echo " [LN] $$@"
|
||||
$(qexec)ln -sf $(LIBVPX_SO) $$@
|
||||
@echo " [LN] $(2) $$@"
|
||||
$(qexec)mkdir -p $$(dir $$@)
|
||||
$(qexec)ln -sf $(2) $$@
|
||||
endef
|
||||
|
||||
$(eval $(call libvpx_symlink_template,\
|
||||
@ -210,10 +303,12 @@ $(eval $(call libvpx_symlink_template,\
|
||||
$(BUILD_PFX)$(LIBVPX_SO)))
|
||||
$(eval $(call libvpx_symlink_template,\
|
||||
$(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
|
||||
$(DIST_DIR)/$(LIBSUBDIR)/$(LIBVPX_SO)))
|
||||
$(LIBVPX_SO)))
|
||||
|
||||
|
||||
INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
|
||||
INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
|
||||
|
||||
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
|
||||
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
|
||||
|
||||
LIBS-$(BUILD_LIBVPX) += vpx.pc
|
||||
vpx.pc: config.mk libs.mk
|
||||
@ -229,7 +324,7 @@ vpx.pc: config.mk libs.mk
|
||||
$(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
|
||||
$(qexec)echo 'Requires:' >> $@
|
||||
$(qexec)echo 'Conflicts:' >> $@
|
||||
$(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@
|
||||
$(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
|
||||
$(qexec)echo 'Libs.private: -lm -lpthread' >> $@
|
||||
$(qexec)echo 'Cflags: -I$${includedir}' >> $@
|
||||
INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
|
||||
@ -265,71 +360,10 @@ endif
|
||||
$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
|
||||
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
|
||||
|
||||
#
|
||||
# Calculate platform- and compiler-specific offsets for hand coded assembly
|
||||
#
|
||||
|
||||
OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
|
||||
|
||||
ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
|
||||
$(BUILD_PFX)asm_com_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
|
||||
$(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S: $(VP8_PREFIX)common/asm_com_offsets.c
|
||||
CLEAN-OBJS += $(BUILD_PFX)asm_com_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
|
||||
|
||||
$(BUILD_PFX)asm_enc_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
|
||||
$(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S: $(VP8_PREFIX)encoder/asm_enc_offsets.c
|
||||
CLEAN-OBJS += $(BUILD_PFX)asm_enc_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
|
||||
|
||||
$(BUILD_PFX)asm_dec_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
|
||||
$(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S: $(VP8_PREFIX)decoder/asm_dec_offsets.c
|
||||
CLEAN-OBJS += $(BUILD_PFX)asm_dec_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
|
||||
else
|
||||
ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
|
||||
asm_com_offsets.asm: obj_int_extract
|
||||
asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
|
||||
OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o
|
||||
CLEAN-OBJS += asm_com_offsets.asm
|
||||
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm
|
||||
|
||||
asm_enc_offsets.asm: obj_int_extract
|
||||
asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
|
||||
OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
|
||||
CLEAN-OBJS += asm_enc_offsets.asm
|
||||
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm
|
||||
|
||||
asm_dec_offsets.asm: obj_int_extract
|
||||
asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
|
||||
OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
|
||||
CLEAN-OBJS += asm_dec_offsets.asm
|
||||
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm
|
||||
endif
|
||||
endif
|
||||
|
||||
$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
|
||||
CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
|
||||
|
||||
#
|
||||
# Rule to generate runtime cpu detection files
|
||||
#
|
||||
$(BUILD_PFX)vpx_rtcd.h: $(SRC_PATH_BARE)/$(sort $(filter %rtcd_defs.sh,$(CODEC_SRCS)))
|
||||
@echo " [CREATE] $@"
|
||||
$(qexec)$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$(TGT_ISA) \
|
||||
--sym=vpx_rtcd \
|
||||
--config=$(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk \
|
||||
$(RTCD_OPTIONS) $^ > $@
|
||||
CLEAN-OBJS += $(BUILD_PFX)vpx_rtcd.h
|
||||
|
||||
##
|
||||
## libvpx test directives
|
||||
@ -375,6 +409,7 @@ gtest.vcproj: $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
|
||||
--proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
|
||||
--ver=$(CONFIG_VS_VERSION) \
|
||||
--src-path-bare="$(SRC_PATH_BARE)" \
|
||||
-D_VARIADIC_MAX=10 \
|
||||
--out=gtest.vcproj $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
|
||||
-I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
|
||||
|
||||
@ -386,6 +421,7 @@ test_libvpx.vcproj: $(LIBVPX_TEST_SRCS)
|
||||
--exe \
|
||||
--target=$(TOOLCHAIN) \
|
||||
--name=test_libvpx \
|
||||
-D_VARIADIC_MAX=10 \
|
||||
--proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
|
||||
--ver=$(CONFIG_VS_VERSION) \
|
||||
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
|
||||
@ -450,5 +486,8 @@ libs.doxy: $(CODEC_DOC_SRCS)
|
||||
@echo "INCLUDE_PATH += ." >> $@;
|
||||
@echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
|
||||
|
||||
## Generate vpx_rtcd.h for all objects
|
||||
$(OBJS-yes:.o=.d): $(BUILD_PFX)vpx_rtcd.h
|
||||
## Generate rtcd.h for all objects
|
||||
$(OBJS-yes:.o=.d): $(RTCD)
|
||||
|
||||
## Update the global src list
|
||||
SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
|
||||
|
298
md5_utils.c
298
md5_utils.c
@ -25,25 +25,22 @@
|
||||
#include "md5_utils.h"
|
||||
|
||||
void
|
||||
byteSwap(UWORD32 *buf, unsigned words)
|
||||
{
|
||||
md5byte *p;
|
||||
byteSwap(UWORD32 *buf, unsigned words) {
|
||||
md5byte *p;
|
||||
|
||||
/* Only swap bytes for big endian machines */
|
||||
int i = 1;
|
||||
/* Only swap bytes for big endian machines */
|
||||
int i = 1;
|
||||
|
||||
if (*(char *)&i == 1)
|
||||
return;
|
||||
if (*(char *)&i == 1)
|
||||
return;
|
||||
|
||||
p = (md5byte *)buf;
|
||||
p = (md5byte *)buf;
|
||||
|
||||
do
|
||||
{
|
||||
*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
|
||||
((unsigned)p[1] << 8 | p[0]);
|
||||
p += 4;
|
||||
}
|
||||
while (--words);
|
||||
do {
|
||||
*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
|
||||
((unsigned)p[1] << 8 | p[0]);
|
||||
p += 4;
|
||||
} while (--words);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -51,15 +48,14 @@ byteSwap(UWORD32 *buf, unsigned words)
|
||||
* initialization constants.
|
||||
*/
|
||||
void
|
||||
MD5Init(struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
MD5Init(struct MD5Context *ctx) {
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bytes[0] = 0;
|
||||
ctx->bytes[1] = 0;
|
||||
ctx->bytes[0] = 0;
|
||||
ctx->bytes[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -67,44 +63,41 @@ MD5Init(struct MD5Context *ctx)
|
||||
* of bytes.
|
||||
*/
|
||||
void
|
||||
MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
|
||||
{
|
||||
UWORD32 t;
|
||||
MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) {
|
||||
UWORD32 t;
|
||||
|
||||
/* Update byte count */
|
||||
/* Update byte count */
|
||||
|
||||
t = ctx->bytes[0];
|
||||
t = ctx->bytes[0];
|
||||
|
||||
if ((ctx->bytes[0] = t + len) < t)
|
||||
ctx->bytes[1]++; /* Carry from low to high */
|
||||
if ((ctx->bytes[0] = t + len) < t)
|
||||
ctx->bytes[1]++; /* Carry from low to high */
|
||||
|
||||
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
|
||||
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
|
||||
|
||||
if (t > len)
|
||||
{
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, len);
|
||||
return;
|
||||
}
|
||||
if (t > len) {
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, len);
|
||||
return;
|
||||
}
|
||||
|
||||
/* First chunk is an odd size */
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, t);
|
||||
/* First chunk is an odd size */
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, t);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
|
||||
/* Process data in 64-byte chunks */
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Process data in 64-byte chunks */
|
||||
while (len >= 64)
|
||||
{
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
memcpy(ctx->in, buf, len);
|
||||
/* Handle any remaining bytes of data. */
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -112,37 +105,35 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void
|
||||
MD5Final(md5byte digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
|
||||
md5byte *p = (md5byte *)ctx->in + count;
|
||||
MD5Final(md5byte digest[16], struct MD5Context *ctx) {
|
||||
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
|
||||
md5byte *p = (md5byte *)ctx->in + count;
|
||||
|
||||
/* Set the first char of padding to 0x80. There is always room. */
|
||||
*p++ = 0x80;
|
||||
/* Set the first char of padding to 0x80. There is always room. */
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 56 bytes (-8..55) */
|
||||
count = 56 - 1 - count;
|
||||
/* Bytes of padding needed to make 56 bytes (-8..55) */
|
||||
count = 56 - 1 - count;
|
||||
|
||||
if (count < 0) /* Padding forces an extra block */
|
||||
{
|
||||
memset(p, 0, count + 8);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
p = (md5byte *)ctx->in;
|
||||
count = 56;
|
||||
}
|
||||
|
||||
memset(p, 0, count);
|
||||
byteSwap(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
ctx->in[14] = ctx->bytes[0] << 3;
|
||||
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
|
||||
if (count < 0) { /* Padding forces an extra block */
|
||||
memset(p, 0, count + 8);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
p = (md5byte *)ctx->in;
|
||||
count = 56;
|
||||
}
|
||||
|
||||
byteSwap(ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
memset(p, 0, count);
|
||||
byteSwap(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
ctx->in[14] = ctx->bytes[0] << 3;
|
||||
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
|
||||
byteSwap(ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
@ -157,7 +148,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f,w,x,y,z,in,s) \
|
||||
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
|
||||
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
@ -165,87 +156,86 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void
|
||||
MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
|
||||
{
|
||||
register UWORD32 a, b, c, d;
|
||||
MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) {
|
||||
register UWORD32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -27,11 +27,10 @@
|
||||
#define UWORD32 unsigned int
|
||||
|
||||
typedef struct MD5Context MD5Context;
|
||||
struct MD5Context
|
||||
{
|
||||
UWORD32 buf[4];
|
||||
UWORD32 bytes[2];
|
||||
UWORD32 in[16];
|
||||
struct MD5Context {
|
||||
UWORD32 buf[4];
|
||||
UWORD32 bytes[2];
|
||||
UWORD32 in[16];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
|
@ -67,6 +67,7 @@ extern "C" {
|
||||
|
||||
#define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */
|
||||
#define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis codec. */
|
||||
#define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
|
||||
|
||||
#define NESTEGG_SEEK_SET 0 /**< Seek offset relative to beginning of stream. */
|
||||
#define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */
|
||||
|
@ -127,6 +127,7 @@ enum ebml_type_enum {
|
||||
|
||||
/* Track IDs */
|
||||
#define TRACK_ID_VP8 "V_VP8"
|
||||
#define TRACK_ID_VP9 "V_VP9"
|
||||
#define TRACK_ID_VORBIS "A_VORBIS"
|
||||
|
||||
enum vint_mask {
|
||||
@ -1669,6 +1670,9 @@ nestegg_track_codec_id(nestegg * ctx, unsigned int track)
|
||||
if (strcmp(codec_id, TRACK_ID_VP8) == 0)
|
||||
return NESTEGG_CODEC_VP8;
|
||||
|
||||
if (strcmp(codec_id, TRACK_ID_VP9) == 0)
|
||||
return NESTEGG_CODEC_VP9;
|
||||
|
||||
if (strcmp(codec_id, TRACK_ID_VORBIS) == 0)
|
||||
return NESTEGG_CODEC_VORBIS;
|
||||
|
||||
|
356
test/dct16x16_test.cc
Normal file
356
test/dct16x16_test.cc
Normal file
@ -0,0 +1,356 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "vp9/common/entropy.h"
|
||||
#include "vp9_rtcd.h"
|
||||
}
|
||||
|
||||
#include "acm_random.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
namespace {
|
||||
|
||||
const double PI = 3.1415926535898;
|
||||
void reference2_16x16_idct_2d(double *input, double *output) {
|
||||
double x;
|
||||
for (int l = 0; l < 16; ++l) {
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
double s = 0;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
x=cos(PI*j*(l+0.5)/16.0)*cos(PI*i*(k+0.5)/16.0)*input[i*16+j]/256;
|
||||
if (i != 0)
|
||||
x *= sqrt(2.0);
|
||||
if (j != 0)
|
||||
x *= sqrt(2.0);
|
||||
s += x;
|
||||
}
|
||||
}
|
||||
output[k*16+l] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const double C1 = 0.995184726672197;
|
||||
static const double C2 = 0.98078528040323;
|
||||
static const double C3 = 0.956940335732209;
|
||||
static const double C4 = 0.923879532511287;
|
||||
static const double C5 = 0.881921264348355;
|
||||
static const double C6 = 0.831469612302545;
|
||||
static const double C7 = 0.773010453362737;
|
||||
static const double C8 = 0.707106781186548;
|
||||
static const double C9 = 0.634393284163646;
|
||||
static const double C10 = 0.555570233019602;
|
||||
static const double C11 = 0.471396736825998;
|
||||
static const double C12 = 0.38268343236509;
|
||||
static const double C13 = 0.290284677254462;
|
||||
static const double C14 = 0.195090322016128;
|
||||
static const double C15 = 0.098017140329561;
|
||||
|
||||
static void butterfly_16x16_dct_1d(double input[16], double output[16]) {
|
||||
double step[16];
|
||||
double intermediate[16];
|
||||
double temp1, temp2;
|
||||
|
||||
// step 1
|
||||
step[ 0] = input[0] + input[15];
|
||||
step[ 1] = input[1] + input[14];
|
||||
step[ 2] = input[2] + input[13];
|
||||
step[ 3] = input[3] + input[12];
|
||||
step[ 4] = input[4] + input[11];
|
||||
step[ 5] = input[5] + input[10];
|
||||
step[ 6] = input[6] + input[ 9];
|
||||
step[ 7] = input[7] + input[ 8];
|
||||
step[ 8] = input[7] - input[ 8];
|
||||
step[ 9] = input[6] - input[ 9];
|
||||
step[10] = input[5] - input[10];
|
||||
step[11] = input[4] - input[11];
|
||||
step[12] = input[3] - input[12];
|
||||
step[13] = input[2] - input[13];
|
||||
step[14] = input[1] - input[14];
|
||||
step[15] = input[0] - input[15];
|
||||
|
||||
// step 2
|
||||
output[0] = step[0] + step[7];
|
||||
output[1] = step[1] + step[6];
|
||||
output[2] = step[2] + step[5];
|
||||
output[3] = step[3] + step[4];
|
||||
output[4] = step[3] - step[4];
|
||||
output[5] = step[2] - step[5];
|
||||
output[6] = step[1] - step[6];
|
||||
output[7] = step[0] - step[7];
|
||||
|
||||
temp1 = step[ 8]*C7;
|
||||
temp2 = step[15]*C9;
|
||||
output[ 8] = temp1 + temp2;
|
||||
|
||||
temp1 = step[ 9]*C11;
|
||||
temp2 = step[14]*C5;
|
||||
output[ 9] = temp1 - temp2;
|
||||
|
||||
temp1 = step[10]*C3;
|
||||
temp2 = step[13]*C13;
|
||||
output[10] = temp1 + temp2;
|
||||
|
||||
temp1 = step[11]*C15;
|
||||
temp2 = step[12]*C1;
|
||||
output[11] = temp1 - temp2;
|
||||
|
||||
temp1 = step[11]*C1;
|
||||
temp2 = step[12]*C15;
|
||||
output[12] = temp2 + temp1;
|
||||
|
||||
temp1 = step[10]*C13;
|
||||
temp2 = step[13]*C3;
|
||||
output[13] = temp2 - temp1;
|
||||
|
||||
temp1 = step[ 9]*C5;
|
||||
temp2 = step[14]*C11;
|
||||
output[14] = temp2 + temp1;
|
||||
|
||||
temp1 = step[ 8]*C9;
|
||||
temp2 = step[15]*C7;
|
||||
output[15] = temp2 - temp1;
|
||||
|
||||
// step 3
|
||||
step[ 0] = output[0] + output[3];
|
||||
step[ 1] = output[1] + output[2];
|
||||
step[ 2] = output[1] - output[2];
|
||||
step[ 3] = output[0] - output[3];
|
||||
|
||||
temp1 = output[4]*C14;
|
||||
temp2 = output[7]*C2;
|
||||
step[ 4] = temp1 + temp2;
|
||||
|
||||
temp1 = output[5]*C10;
|
||||
temp2 = output[6]*C6;
|
||||
step[ 5] = temp1 + temp2;
|
||||
|
||||
temp1 = output[5]*C6;
|
||||
temp2 = output[6]*C10;
|
||||
step[ 6] = temp2 - temp1;
|
||||
|
||||
temp1 = output[4]*C2;
|
||||
temp2 = output[7]*C14;
|
||||
step[ 7] = temp2 - temp1;
|
||||
|
||||
step[ 8] = output[ 8] + output[11];
|
||||
step[ 9] = output[ 9] + output[10];
|
||||
step[10] = output[ 9] - output[10];
|
||||
step[11] = output[ 8] - output[11];
|
||||
|
||||
step[12] = output[12] + output[15];
|
||||
step[13] = output[13] + output[14];
|
||||
step[14] = output[13] - output[14];
|
||||
step[15] = output[12] - output[15];
|
||||
|
||||
// step 4
|
||||
output[ 0] = (step[ 0] + step[ 1]);
|
||||
output[ 8] = (step[ 0] - step[ 1]);
|
||||
|
||||
temp1 = step[2]*C12;
|
||||
temp2 = step[3]*C4;
|
||||
temp1 = temp1 + temp2;
|
||||
output[ 4] = 2*(temp1*C8);
|
||||
|
||||
temp1 = step[2]*C4;
|
||||
temp2 = step[3]*C12;
|
||||
temp1 = temp2 - temp1;
|
||||
output[12] = 2*(temp1*C8);
|
||||
|
||||
output[ 2] = 2*((step[4] + step[ 5])*C8);
|
||||
output[14] = 2*((step[7] - step[ 6])*C8);
|
||||
|
||||
temp1 = step[4] - step[5];
|
||||
temp2 = step[6] + step[7];
|
||||
output[ 6] = (temp1 + temp2);
|
||||
output[10] = (temp1 - temp2);
|
||||
|
||||
intermediate[8] = step[8] + step[14];
|
||||
intermediate[9] = step[9] + step[15];
|
||||
|
||||
temp1 = intermediate[8]*C12;
|
||||
temp2 = intermediate[9]*C4;
|
||||
temp1 = temp1 - temp2;
|
||||
output[3] = 2*(temp1*C8);
|
||||
|
||||
temp1 = intermediate[8]*C4;
|
||||
temp2 = intermediate[9]*C12;
|
||||
temp1 = temp2 + temp1;
|
||||
output[13] = 2*(temp1*C8);
|
||||
|
||||
output[ 9] = 2*((step[10] + step[11])*C8);
|
||||
|
||||
intermediate[11] = step[10] - step[11];
|
||||
intermediate[12] = step[12] + step[13];
|
||||
intermediate[13] = step[12] - step[13];
|
||||
intermediate[14] = step[ 8] - step[14];
|
||||
intermediate[15] = step[ 9] - step[15];
|
||||
|
||||
output[15] = (intermediate[11] + intermediate[12]);
|
||||
output[ 1] = -(intermediate[11] - intermediate[12]);
|
||||
|
||||
output[ 7] = 2*(intermediate[13]*C8);
|
||||
|
||||
temp1 = intermediate[14]*C12;
|
||||
temp2 = intermediate[15]*C4;
|
||||
temp1 = temp1 - temp2;
|
||||
output[11] = -2*(temp1*C8);
|
||||
|
||||
temp1 = intermediate[14]*C4;
|
||||
temp2 = intermediate[15]*C12;
|
||||
temp1 = temp2 + temp1;
|
||||
output[ 5] = 2*(temp1*C8);
|
||||
}
|
||||
|
||||
static void reference_16x16_dct_1d(double in[16], double out[16]) {
|
||||
const double kPi = 3.141592653589793238462643383279502884;
|
||||
const double kInvSqrt2 = 0.707106781186547524400844362104;
|
||||
for (int k = 0; k < 16; k++) {
|
||||
out[k] = 0.0;
|
||||
for (int n = 0; n < 16; n++)
|
||||
out[k] += in[n]*cos(kPi*(2*n+1)*k/32.0);
|
||||
if (k == 0)
|
||||
out[k] = out[k]*kInvSqrt2;
|
||||
}
|
||||
}
|
||||
|
||||
void reference_16x16_dct_2d(int16_t input[16*16], double output[16*16]) {
|
||||
// First transform columns
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
double temp_in[16], temp_out[16];
|
||||
for (int j = 0; j < 16; ++j)
|
||||
temp_in[j] = input[j*16 + i];
|
||||
butterfly_16x16_dct_1d(temp_in, temp_out);
|
||||
for (int j = 0; j < 16; ++j)
|
||||
output[j*16 + i] = temp_out[j];
|
||||
}
|
||||
// Then transform rows
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
double temp_in[16], temp_out[16];
|
||||
for (int j = 0; j < 16; ++j)
|
||||
temp_in[j] = output[j + i*16];
|
||||
butterfly_16x16_dct_1d(temp_in, temp_out);
|
||||
// Scale by some magic number
|
||||
for (int j = 0; j < 16; ++j)
|
||||
output[j + i*16] = temp_out[j]/2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(VP9Idct16x16Test, AccuracyCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
const int count_test_block = 1000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t in[256], coeff[256];
|
||||
int16_t out_c[256];
|
||||
double out_r[256];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 256; ++j)
|
||||
in[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
reference_16x16_dct_2d(in, out_r);
|
||||
for (int j = 0; j < 256; j++)
|
||||
coeff[j] = round(out_r[j]);
|
||||
vp9_short_idct16x16_c(coeff, out_c, 32);
|
||||
for (int j = 0; j < 256; ++j) {
|
||||
const int diff = out_c[j] - in[j];
|
||||
const int error = diff * diff;
|
||||
EXPECT_GE(1, error)
|
||||
<< "Error: 16x16 IDCT has error " << error
|
||||
<< " at index " << j;
|
||||
}
|
||||
|
||||
vp9_short_fdct16x16_c(in, out_c, 32);
|
||||
for (int j = 0; j < 256; ++j) {
|
||||
const double diff = coeff[j] - out_c[j];
|
||||
const double error = diff * diff;
|
||||
EXPECT_GE(1.0, error)
|
||||
<< "Error: 16x16 FDCT has error " << error
|
||||
<< " at index " << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(VP9Fdct16x16Test, AccuracyCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int max_error = 0;
|
||||
double total_error = 0;
|
||||
const int count_test_block = 1000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t test_input_block[256];
|
||||
int16_t test_temp_block[256];
|
||||
int16_t test_output_block[256];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 256; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
const int pitch = 32;
|
||||
vp9_short_fdct16x16_c(test_input_block, test_temp_block, pitch);
|
||||
vp9_short_idct16x16_c(test_temp_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 256; ++j) {
|
||||
const int diff = test_input_block[j] - test_output_block[j];
|
||||
const int error = diff * diff;
|
||||
if (max_error < error)
|
||||
max_error = error;
|
||||
total_error += error;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_GE(1, max_error)
|
||||
<< "Error: 16x16 FDCT/IDCT has an individual roundtrip error > 1";
|
||||
|
||||
EXPECT_GE(count_test_block/10, total_error)
|
||||
<< "Error: 16x16 FDCT/IDCT has average roundtrip error > 1/10 per block";
|
||||
}
|
||||
|
||||
TEST(VP9Fdct16x16Test, CoeffSizeCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
const int count_test_block = 1000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t input_block[256], input_extreme_block[256];
|
||||
int16_t output_block[256], output_extreme_block[256];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 256; ++j) {
|
||||
input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
input_extreme_block[j] = rnd.Rand8() % 2 ? 255 : -255;
|
||||
}
|
||||
if (i == 0)
|
||||
for (int j = 0; j < 256; ++j)
|
||||
input_extreme_block[j] = 255;
|
||||
|
||||
const int pitch = 32;
|
||||
vp9_short_fdct16x16_c(input_block, output_block, pitch);
|
||||
vp9_short_fdct16x16_c(input_extreme_block, output_extreme_block, pitch);
|
||||
|
||||
// The minimum quant value is 4.
|
||||
for (int j = 0; j < 256; ++j) {
|
||||
EXPECT_GE(4*DCT_MAX_VALUE, abs(output_block[j]))
|
||||
<< "Error: 16x16 FDCT has coefficient larger than 4*DCT_MAX_VALUE";
|
||||
EXPECT_GE(4*DCT_MAX_VALUE, abs(output_extreme_block[j]))
|
||||
<< "Error: 16x16 FDCT extreme has coefficient larger than 4*DCT_MAX_VALUE";
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
@ -1,79 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp9_rtcd.h"
|
||||
}
|
||||
|
||||
#include "test/acm_random.h"
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
#include "acm_random.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
const int cospi8sqrt2minus1 = 20091;
|
||||
const int sinpi8sqrt2 = 35468;
|
||||
|
||||
void reference_idct4x4(const int16_t *input, int16_t *output) {
|
||||
const int16_t *ip = input;
|
||||
int16_t *op = output;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int a1 = ip[0] + ip[8];
|
||||
const int b1 = ip[0] - ip[8];
|
||||
const int temp1 = (ip[4] * sinpi8sqrt2) >> 16;
|
||||
const int temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
|
||||
const int c1 = temp1 - temp2;
|
||||
const int temp3 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
|
||||
const int temp4 = (ip[12] * sinpi8sqrt2) >> 16;
|
||||
const int d1 = temp3 + temp4;
|
||||
op[0] = a1 + d1;
|
||||
op[12] = a1 - d1;
|
||||
op[4] = b1 + c1;
|
||||
op[8] = b1 - c1;
|
||||
++ip;
|
||||
++op;
|
||||
}
|
||||
ip = output;
|
||||
op = output;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int a1 = ip[0] + ip[2];
|
||||
const int b1 = ip[0] - ip[2];
|
||||
const int temp1 = (ip[1] * sinpi8sqrt2) >> 16;
|
||||
const int temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
|
||||
const int c1 = temp1 - temp2;
|
||||
const int temp3 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
|
||||
const int temp4 = (ip[3] * sinpi8sqrt2) >> 16;
|
||||
const int d1 = temp3 + temp4;
|
||||
op[0] = (a1 + d1 + 4) >> 3;
|
||||
op[3] = (a1 - d1 + 4) >> 3;
|
||||
op[1] = (b1 + c1 + 4) >> 3;
|
||||
op[2] = (b1 - c1 + 4) >> 3;
|
||||
ip += 4;
|
||||
op += 4;
|
||||
}
|
||||
}
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
namespace {
|
||||
|
||||
TEST(Vp9FdctTest, SignBiasCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int16_t test_input_block[16];
|
||||
int16_t test_output_block[16];
|
||||
@ -88,7 +40,9 @@ TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
// TODO(Yaowu): this should be converted to a parameterized test
|
||||
// to test optimized versions of this function.
|
||||
vp9_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
@ -98,13 +52,13 @@ TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
}
|
||||
}
|
||||
|
||||
bool bias_acceptable = true;
|
||||
for (int j = 0; j < 16; ++j)
|
||||
bias_acceptable = bias_acceptable &&
|
||||
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 10000);
|
||||
|
||||
EXPECT_EQ(true, bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 1% for input range [-255, 255]";
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
const bool bias_acceptable = (abs(count_sign_block[j][0] -
|
||||
count_sign_block[j][1]) < 10000);
|
||||
EXPECT_TRUE(bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 1%"
|
||||
<< " for input range [-255, 255] at index " << j;
|
||||
}
|
||||
|
||||
memset(count_sign_block, 0, sizeof(count_sign_block));
|
||||
|
||||
@ -113,7 +67,9 @@ TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
|
||||
|
||||
vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
// TODO(Yaowu): this should be converted to a parameterized test
|
||||
// to test optimized versions of this function.
|
||||
vp9_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
@ -123,16 +79,16 @@ TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
}
|
||||
}
|
||||
|
||||
bias_acceptable = true;
|
||||
for (int j = 0; j < 16; ++j)
|
||||
bias_acceptable = bias_acceptable &&
|
||||
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 100000);
|
||||
|
||||
EXPECT_EQ(true, bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 10% for input range [-15, 15]";
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
const bool bias_acceptable = (abs(count_sign_block[j][0] -
|
||||
count_sign_block[j][1]) < 100000);
|
||||
EXPECT_TRUE(bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 10%"
|
||||
<< " for input range [-15, 15] at index " << j;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Vp8FdctTest, RoundTripErrorCheck) {
|
||||
TEST(Vp9FdctTest, RoundTripErrorCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int max_error = 0;
|
||||
double total_error = 0;
|
||||
@ -146,9 +102,25 @@ TEST(Vp8FdctTest, RoundTripErrorCheck) {
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
// TODO(Yaowu): this should be converted to a parameterized test
|
||||
// to test optimized versions of this function.
|
||||
const int pitch = 8;
|
||||
vp8_short_fdct4x4_c(test_input_block, test_temp_block, pitch);
|
||||
reference_idct4x4(test_temp_block, test_output_block);
|
||||
vp9_short_fdct4x4_c(test_input_block, test_temp_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if(test_temp_block[j] > 0) {
|
||||
test_temp_block[j] += 2;
|
||||
test_temp_block[j] /= 4;
|
||||
test_temp_block[j] *= 4;
|
||||
} else {
|
||||
test_temp_block[j] -= 2;
|
||||
test_temp_block[j] /= 4;
|
||||
test_temp_block[j] *= 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Because the bitstream is not frozen yet, use the idct in the codebase.
|
||||
vp9_short_idct4x4llm_c(test_temp_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
const int diff = test_input_block[j] - test_output_block[j];
|
||||
@ -158,12 +130,11 @@ TEST(Vp8FdctTest, RoundTripErrorCheck) {
|
||||
total_error += error;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_GE(1, max_error )
|
||||
<< "Error: FDCT/IDCT has an individual roundtrip error > 1";
|
||||
EXPECT_GE(1, max_error)
|
||||
<< "Error: FDCT/IDCT has an individual roundtrip error > 1";
|
||||
|
||||
EXPECT_GE(count_test_block, total_error)
|
||||
<< "Error: FDCT/IDCT has average roundtrip error > 1 per block";
|
||||
<< "Error: FDCT/IDCT has average roundtrip error > 1 per block";
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
168
test/fdct8x8_test.cc
Normal file
168
test/fdct8x8_test.cc
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "vp9_rtcd.h"
|
||||
}
|
||||
|
||||
#include "acm_random.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(VP9Fdct8x8Test, SignBiasCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int16_t test_input_block[64];
|
||||
int16_t test_output_block[64];
|
||||
const int pitch = 16;
|
||||
int count_sign_block[64][2];
|
||||
const int count_test_block = 100000;
|
||||
|
||||
memset(count_sign_block, 0, sizeof(count_sign_block));
|
||||
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 64; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
vp9_short_fdct8x8_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
++count_sign_block[j][0];
|
||||
else if (test_output_block[j] > 0)
|
||||
++count_sign_block[j][1];
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const bool bias_acceptable = (abs(count_sign_block[j][0] -
|
||||
count_sign_block[j][1]) < 1000);
|
||||
EXPECT_TRUE(bias_acceptable)
|
||||
<< "Error: 8x8 FDCT has a sign bias > 1%"
|
||||
<< " for input range [-255, 255] at index " << j;
|
||||
}
|
||||
|
||||
memset(count_sign_block, 0, sizeof(count_sign_block));
|
||||
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
// Initialize a test block with input range [-15, 15].
|
||||
for (int j = 0; j < 64; ++j)
|
||||
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
|
||||
|
||||
vp9_short_fdct8x8_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
++count_sign_block[j][0];
|
||||
else if (test_output_block[j] > 0)
|
||||
++count_sign_block[j][1];
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const bool bias_acceptable = (abs(count_sign_block[j][0] -
|
||||
count_sign_block[j][1]) < 10000);
|
||||
EXPECT_TRUE(bias_acceptable)
|
||||
<< "Error: 8x8 FDCT has a sign bias > 10%"
|
||||
<< " for input range [-15, 15] at index " << j;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(VP9Fdct8x8Test, RoundTripErrorCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int max_error = 0;
|
||||
double total_error = 0;
|
||||
const int count_test_block = 100000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t test_input_block[64];
|
||||
int16_t test_temp_block[64];
|
||||
int16_t test_output_block[64];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 64; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
const int pitch = 16;
|
||||
vp9_short_fdct8x8_c(test_input_block, test_temp_block, pitch);
|
||||
for (int j = 0; j < 64; ++j){
|
||||
if(test_temp_block[j] > 0) {
|
||||
test_temp_block[j] += 2;
|
||||
test_temp_block[j] /= 4;
|
||||
test_temp_block[j] *= 4;
|
||||
} else {
|
||||
test_temp_block[j] -= 2;
|
||||
test_temp_block[j] /= 4;
|
||||
test_temp_block[j] *= 4;
|
||||
}
|
||||
}
|
||||
vp9_short_idct8x8_c(test_temp_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const int diff = test_input_block[j] - test_output_block[j];
|
||||
const int error = diff * diff;
|
||||
if (max_error < error)
|
||||
max_error = error;
|
||||
total_error += error;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_GE(1, max_error)
|
||||
<< "Error: 8x8 FDCT/IDCT has an individual roundtrip error > 1";
|
||||
|
||||
EXPECT_GE(count_test_block/5, total_error)
|
||||
<< "Error: 8x8 FDCT/IDCT has average roundtrip error > 1/5 per block";
|
||||
};
|
||||
|
||||
TEST(VP9Fdct8x8Test, ExtremalCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int max_error = 0;
|
||||
double total_error = 0;
|
||||
const int count_test_block = 100000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t test_input_block[64];
|
||||
int16_t test_temp_block[64];
|
||||
int16_t test_output_block[64];
|
||||
|
||||
// Initialize a test block with input range {-255, 255}.
|
||||
for (int j = 0; j < 64; ++j)
|
||||
test_input_block[j] = rnd.Rand8() % 2 ? 255 : -255;
|
||||
|
||||
const int pitch = 16;
|
||||
vp9_short_fdct8x8_c(test_input_block, test_temp_block, pitch);
|
||||
vp9_short_idct8x8_c(test_temp_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const int diff = test_input_block[j] - test_output_block[j];
|
||||
const int error = diff * diff;
|
||||
if (max_error < error)
|
||||
max_error = error;
|
||||
total_error += error;
|
||||
}
|
||||
|
||||
EXPECT_GE(1, max_error)
|
||||
<< "Error: Extremal 8x8 FDCT/IDCT has an"
|
||||
<< " individual roundtrip error > 1";
|
||||
|
||||
EXPECT_GE(count_test_block/5, total_error)
|
||||
<< "Error: Extremal 8x8 FDCT/IDCT has average"
|
||||
<< " roundtrip error > 1/5 per block";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
162
test/idct8x8_test.cc
Normal file
162
test/idct8x8_test.cc
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "vp9_rtcd.h"
|
||||
}
|
||||
|
||||
#include "acm_random.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static int round(double x) {
|
||||
if(x < 0)
|
||||
return (int)ceil(x - 0.5);
|
||||
else
|
||||
return (int)floor(x + 0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
void reference_dct_1d(double input[8], double output[8]) {
|
||||
const double kPi = 3.141592653589793238462643383279502884;
|
||||
const double kInvSqrt2 = 0.707106781186547524400844362104;
|
||||
for (int k = 0; k < 8; k++) {
|
||||
output[k] = 0.0;
|
||||
for (int n = 0; n < 8; n++)
|
||||
output[k] += input[n]*cos(kPi*(2*n+1)*k/16.0);
|
||||
if (k == 0)
|
||||
output[k] = output[k]*kInvSqrt2;
|
||||
}
|
||||
}
|
||||
|
||||
void reference_dct_2d(int16_t input[64], double output[64]) {
|
||||
// First transform columns
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
double temp_in[8], temp_out[8];
|
||||
for (int j = 0; j < 8; ++j)
|
||||
temp_in[j] = input[j*8 + i];
|
||||
reference_dct_1d(temp_in, temp_out);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
output[j*8 + i] = temp_out[j];
|
||||
}
|
||||
// Then transform rows
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
double temp_in[8], temp_out[8];
|
||||
for (int j = 0; j < 8; ++j)
|
||||
temp_in[j] = output[j + i*8];
|
||||
reference_dct_1d(temp_in, temp_out);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
output[j + i*8] = temp_out[j];
|
||||
}
|
||||
// Scale by some magic number
|
||||
for (int i = 0; i < 64; ++i)
|
||||
output[i] *= 2;
|
||||
}
|
||||
|
||||
void reference_idct_1d(double input[8], double output[8]) {
|
||||
const double kPi = 3.141592653589793238462643383279502884;
|
||||
const double kSqrt2 = 1.414213562373095048801688724209698;
|
||||
for (int k = 0; k < 8; k++) {
|
||||
output[k] = 0.0;
|
||||
for (int n = 0; n < 8; n++) {
|
||||
output[k] += input[n]*cos(kPi*(2*k+1)*n/16.0);
|
||||
if (n == 0)
|
||||
output[k] = output[k]/kSqrt2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reference_idct_2d(double input[64], int16_t output[64]) {
|
||||
double out[64], out2[64];
|
||||
// First transform rows
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
double temp_in[8], temp_out[8];
|
||||
for (int j = 0; j < 8; ++j)
|
||||
temp_in[j] = input[j + i*8];
|
||||
reference_idct_1d(temp_in, temp_out);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
out[j + i*8] = temp_out[j];
|
||||
}
|
||||
// Then transform columns
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
double temp_in[8], temp_out[8];
|
||||
for (int j = 0; j < 8; ++j)
|
||||
temp_in[j] = out[j*8 + i];
|
||||
reference_idct_1d(temp_in, temp_out);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
out2[j*8 + i] = temp_out[j];
|
||||
}
|
||||
for (int i = 0; i < 64; ++i)
|
||||
output[i] = round(out2[i]/32);
|
||||
}
|
||||
|
||||
TEST(VP9Idct8x8Test, AccuracyCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
const int count_test_block = 10000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t input[64], coeff[64];
|
||||
int16_t output_c[64];
|
||||
double output_r[64];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 64; ++j)
|
||||
input[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
const int pitch = 16;
|
||||
vp9_short_fdct8x8_c(input, output_c, pitch);
|
||||
reference_dct_2d(input, output_r);
|
||||
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const double diff = output_c[j] - output_r[j];
|
||||
const double error = diff * diff;
|
||||
// An error in a DCT coefficient isn't that bad.
|
||||
// We care more about the reconstructed pixels.
|
||||
EXPECT_GE(2.0, error)
|
||||
<< "Error: 8x8 FDCT/IDCT has error " << error
|
||||
<< " at index " << j;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Tests that the reference iDCT and fDCT match.
|
||||
reference_dct_2d(input, output_r);
|
||||
reference_idct_2d(output_r, output_c);
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const int diff = output_c[j] -input[j];
|
||||
const int error = diff * diff;
|
||||
EXPECT_EQ(0, error)
|
||||
<< "Error: 8x8 FDCT/IDCT has error " << error
|
||||
<< " at index " << j;
|
||||
}
|
||||
#endif
|
||||
reference_dct_2d(input, output_r);
|
||||
for (int j = 0; j < 64; ++j)
|
||||
coeff[j] = round(output_r[j]);
|
||||
vp9_short_idct8x8_c(coeff, output_c, pitch);
|
||||
for (int j = 0; j < 64; ++j) {
|
||||
const int diff = output_c[j] -input[j];
|
||||
const int error = diff * diff;
|
||||
EXPECT_GE(1, error)
|
||||
<< "Error: 8x8 FDCT/IDCT has error " << error
|
||||
<< " at index " << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
@ -11,7 +11,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
}
|
||||
#include "test/register_state_check.h"
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "./vpx_config.h"
|
||||
#include "./vpx_rtcd.h"
|
||||
#include "./vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "./vpx_config.h"
|
||||
#include "./vpx_rtcd.h"
|
||||
#include "./vp8_rtcd.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "test/register_state_check.h"
|
||||
extern "C" {
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
#include "vp8/encoder/block.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
30
test/test.mk
30
test/test.mk
@ -1,6 +1,7 @@
|
||||
LIBVPX_TEST_SRCS-yes += acm_random.h
|
||||
LIBVPX_TEST_SRCS-yes += register_state_check.h
|
||||
LIBVPX_TEST_SRCS-yes += test.mk
|
||||
LIBVPX_TEST_SRCS-yes += acm_random.h
|
||||
|
||||
LIBVPX_TEST_SRCS-yes += test_libvpx.cc
|
||||
LIBVPX_TEST_SRCS-yes += util.h
|
||||
LIBVPX_TEST_SRCS-yes += video_source.h
|
||||
@ -34,12 +35,14 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += test_vector_test.cc
|
||||
##
|
||||
ifeq ($(CONFIG_SHARED),)
|
||||
|
||||
## VP8
|
||||
ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
|
||||
|
||||
# These tests require both the encoder and decoder to be built.
|
||||
ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes)
|
||||
LIBVPX_TEST_SRCS-yes += boolcoder_test.cc
|
||||
LIBVPX_TEST_SRCS-yes += vp8_boolcoder_test.cc
|
||||
endif
|
||||
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += fdct4x4_test.cc
|
||||
LIBVPX_TEST_SRCS-yes += idctllm_test.cc
|
||||
LIBVPX_TEST_SRCS-yes += intrapred_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_POSTPROC) += pp_filter_test.cc
|
||||
@ -47,6 +50,27 @@ LIBVPX_TEST_SRCS-yes += sad_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += set_roi.cc
|
||||
LIBVPX_TEST_SRCS-yes += sixtap_predict_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += subtract_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += vp8_fdct4x4_test.cc
|
||||
|
||||
endif # VP8
|
||||
|
||||
## VP9
|
||||
ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
|
||||
|
||||
# These tests require both the encoder and decoder to be built.
|
||||
ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),yesyes)
|
||||
LIBVPX_TEST_SRCS-yes += vp9_boolcoder_test.cc
|
||||
|
||||
# IDCT test currently depends on FDCT function
|
||||
LIBVPX_TEST_SRCS-yes += idct8x8_test.cc
|
||||
endif
|
||||
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += fdct4x4_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += fdct8x8_test.cc
|
||||
#LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += dct16x16_test.cc
|
||||
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += variance_test.cc
|
||||
endif # VP9
|
||||
|
||||
|
||||
endif
|
||||
|
||||
|
@ -9,11 +9,17 @@
|
||||
*/
|
||||
#include <string>
|
||||
#include "vpx_config.h"
|
||||
#if ARCH_X86 || ARCH_X86_64
|
||||
extern "C" {
|
||||
#if ARCH_X86 || ARCH_X86_64
|
||||
#include "vpx_ports/x86.h"
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_VP8
|
||||
extern void vp8_rtcd();
|
||||
#endif
|
||||
#if CONFIG_VP9
|
||||
extern void vp9_rtcd();
|
||||
#endif
|
||||
}
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
static void append_gtest_filter(const char *str) {
|
||||
@ -27,19 +33,29 @@ int main(int argc, char **argv) {
|
||||
|
||||
#if ARCH_X86 || ARCH_X86_64
|
||||
const int simd_caps = x86_simd_caps();
|
||||
if(!(simd_caps & HAS_MMX))
|
||||
if (!(simd_caps & HAS_MMX))
|
||||
append_gtest_filter(":-MMX/*");
|
||||
if(!(simd_caps & HAS_SSE))
|
||||
if (!(simd_caps & HAS_SSE))
|
||||
append_gtest_filter(":-SSE/*");
|
||||
if(!(simd_caps & HAS_SSE2))
|
||||
if (!(simd_caps & HAS_SSE2))
|
||||
append_gtest_filter(":-SSE2/*");
|
||||
if(!(simd_caps & HAS_SSE3))
|
||||
if (!(simd_caps & HAS_SSE3))
|
||||
append_gtest_filter(":-SSE3/*");
|
||||
if(!(simd_caps & HAS_SSSE3))
|
||||
if (!(simd_caps & HAS_SSSE3))
|
||||
append_gtest_filter(":-SSSE3/*");
|
||||
if(!(simd_caps & HAS_SSE4_1))
|
||||
if (!(simd_caps & HAS_SSE4_1))
|
||||
append_gtest_filter(":-SSE4_1/*");
|
||||
#endif
|
||||
|
||||
#if !CONFIG_SHARED
|
||||
/* Shared library builds don't support whitebox tests that exercise internal symbols. */
|
||||
#if CONFIG_VP8
|
||||
vp8_rtcd();
|
||||
#endif
|
||||
#if CONFIG_VP9
|
||||
vp9_rtcd();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
123
test/variance_test.cc
Normal file
123
test/variance_test.cc
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
#include "vpx_config.h"
|
||||
extern "C" {
|
||||
#include "vp9/encoder/vp9_variance.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
#include "vp9_rtcd.h"
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using ::std::tr1::get;
|
||||
using ::std::tr1::make_tuple;
|
||||
using ::std::tr1::tuple;
|
||||
|
||||
class VP9VarianceTest :
|
||||
public ::testing::TestWithParam<tuple<int, int, vp9_variance_fn_t> > {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
const tuple<int, int, vp9_variance_fn_t>& params = GetParam();
|
||||
width_ = get<0>(params);
|
||||
height_ = get<1>(params);
|
||||
variance_ = get<2>(params);
|
||||
|
||||
block_size_ = width_ * height_;
|
||||
src_ = new uint8_t[block_size_];
|
||||
ref_ = new uint8_t[block_size_];
|
||||
ASSERT_TRUE(src_ != NULL);
|
||||
ASSERT_TRUE(ref_ != NULL);
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
delete[] src_;
|
||||
delete[] ref_;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t* src_;
|
||||
uint8_t* ref_;
|
||||
int width_;
|
||||
int height_;
|
||||
int block_size_;
|
||||
vp9_variance_fn_t variance_;
|
||||
};
|
||||
|
||||
TEST_P(VP9VarianceTest, Zero) {
|
||||
for (int i = 0; i <= 255; ++i) {
|
||||
memset(src_, i, block_size_);
|
||||
for (int j = 0; j <= 255; ++j) {
|
||||
memset(ref_, j, block_size_);
|
||||
unsigned int sse;
|
||||
const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
|
||||
EXPECT_EQ(0u, var) << "src values: " << i << "ref values: " << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(VP9VarianceTest, OneQuarter) {
|
||||
memset(src_, 255, block_size_);
|
||||
const int half = block_size_ / 2;
|
||||
memset(ref_, 255, half);
|
||||
memset(ref_ + half, 0, half);
|
||||
unsigned int sse;
|
||||
const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
|
||||
const unsigned int expected = block_size_ * 255 * 255 / 4;
|
||||
EXPECT_EQ(expected, var);
|
||||
}
|
||||
|
||||
const vp9_variance_fn_t variance4x4_c = vp9_variance4x4_c;
|
||||
const vp9_variance_fn_t variance8x8_c = vp9_variance8x8_c;
|
||||
const vp9_variance_fn_t variance8x16_c = vp9_variance8x16_c;
|
||||
const vp9_variance_fn_t variance16x8_c = vp9_variance16x8_c;
|
||||
const vp9_variance_fn_t variance16x16_c = vp9_variance16x16_c;
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
C, VP9VarianceTest,
|
||||
::testing::Values(make_tuple(4, 4, variance4x4_c),
|
||||
make_tuple(8, 8, variance8x8_c),
|
||||
make_tuple(8, 16, variance8x16_c),
|
||||
make_tuple(16, 8, variance16x8_c),
|
||||
make_tuple(16, 16, variance16x16_c)));
|
||||
|
||||
#if HAVE_MMX
|
||||
const vp9_variance_fn_t variance4x4_mmx = vp9_variance4x4_mmx;
|
||||
const vp9_variance_fn_t variance8x8_mmx = vp9_variance8x8_mmx;
|
||||
const vp9_variance_fn_t variance8x16_mmx = vp9_variance8x16_mmx;
|
||||
const vp9_variance_fn_t variance16x8_mmx = vp9_variance16x8_mmx;
|
||||
const vp9_variance_fn_t variance16x16_mmx = vp9_variance16x16_mmx;
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
MMX, VP9VarianceTest,
|
||||
::testing::Values(make_tuple(4, 4, variance4x4_mmx),
|
||||
make_tuple(8, 8, variance8x8_mmx),
|
||||
make_tuple(8, 16, variance8x16_mmx),
|
||||
make_tuple(16, 8, variance16x8_mmx),
|
||||
make_tuple(16, 16, variance16x16_mmx)));
|
||||
#endif
|
||||
|
||||
#if HAVE_SSE2
|
||||
const vp9_variance_fn_t variance4x4_wmt = vp9_variance4x4_wmt;
|
||||
const vp9_variance_fn_t variance8x8_wmt = vp9_variance8x8_wmt;
|
||||
const vp9_variance_fn_t variance8x16_wmt = vp9_variance8x16_wmt;
|
||||
const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_wmt;
|
||||
const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_wmt;
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SSE2, VP9VarianceTest,
|
||||
::testing::Values(make_tuple(4, 4, variance4x4_wmt),
|
||||
make_tuple(8, 8, variance8x8_wmt),
|
||||
make_tuple(8, 16, variance8x16_wmt),
|
||||
make_tuple(16, 8, variance16x8_wmt),
|
||||
make_tuple(16, 16, variance16x16_wmt)));
|
||||
#endif
|
||||
} // namespace
|
169
test/vp8_fdct4x4_test.cc
Normal file
169
test/vp8_fdct4x4_test.cc
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include "vp8_rtcd.h"
|
||||
}
|
||||
|
||||
#include "test/acm_random.h"
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
const int cospi8sqrt2minus1 = 20091;
|
||||
const int sinpi8sqrt2 = 35468;
|
||||
|
||||
void reference_idct4x4(const int16_t *input, int16_t *output) {
|
||||
const int16_t *ip = input;
|
||||
int16_t *op = output;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int a1 = ip[0] + ip[8];
|
||||
const int b1 = ip[0] - ip[8];
|
||||
const int temp1 = (ip[4] * sinpi8sqrt2) >> 16;
|
||||
const int temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
|
||||
const int c1 = temp1 - temp2;
|
||||
const int temp3 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
|
||||
const int temp4 = (ip[12] * sinpi8sqrt2) >> 16;
|
||||
const int d1 = temp3 + temp4;
|
||||
op[0] = a1 + d1;
|
||||
op[12] = a1 - d1;
|
||||
op[4] = b1 + c1;
|
||||
op[8] = b1 - c1;
|
||||
++ip;
|
||||
++op;
|
||||
}
|
||||
ip = output;
|
||||
op = output;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int a1 = ip[0] + ip[2];
|
||||
const int b1 = ip[0] - ip[2];
|
||||
const int temp1 = (ip[1] * sinpi8sqrt2) >> 16;
|
||||
const int temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
|
||||
const int c1 = temp1 - temp2;
|
||||
const int temp3 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
|
||||
const int temp4 = (ip[3] * sinpi8sqrt2) >> 16;
|
||||
const int d1 = temp3 + temp4;
|
||||
op[0] = (a1 + d1 + 4) >> 3;
|
||||
op[3] = (a1 - d1 + 4) >> 3;
|
||||
op[1] = (b1 + c1 + 4) >> 3;
|
||||
op[2] = (b1 - c1 + 4) >> 3;
|
||||
ip += 4;
|
||||
op += 4;
|
||||
}
|
||||
}
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
TEST(Vp8FdctTest, SignBiasCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int16_t test_input_block[16];
|
||||
int16_t test_output_block[16];
|
||||
const int pitch = 8;
|
||||
int count_sign_block[16][2];
|
||||
const int count_test_block = 1000000;
|
||||
|
||||
memset(count_sign_block, 0, sizeof(count_sign_block));
|
||||
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
++count_sign_block[j][0];
|
||||
else if (test_output_block[j] > 0)
|
||||
++count_sign_block[j][1];
|
||||
}
|
||||
}
|
||||
|
||||
bool bias_acceptable = true;
|
||||
for (int j = 0; j < 16; ++j)
|
||||
bias_acceptable = bias_acceptable &&
|
||||
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 10000);
|
||||
|
||||
EXPECT_EQ(true, bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 1% for input range [-255, 255]";
|
||||
|
||||
memset(count_sign_block, 0, sizeof(count_sign_block));
|
||||
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
// Initialize a test block with input range [-15, 15].
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
|
||||
|
||||
vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (test_output_block[j] < 0)
|
||||
++count_sign_block[j][0];
|
||||
else if (test_output_block[j] > 0)
|
||||
++count_sign_block[j][1];
|
||||
}
|
||||
}
|
||||
|
||||
bias_acceptable = true;
|
||||
for (int j = 0; j < 16; ++j)
|
||||
bias_acceptable = bias_acceptable &&
|
||||
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 100000);
|
||||
|
||||
EXPECT_EQ(true, bias_acceptable)
|
||||
<< "Error: 4x4 FDCT has a sign bias > 10% for input range [-15, 15]";
|
||||
};
|
||||
|
||||
TEST(Vp8FdctTest, RoundTripErrorCheck) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
int max_error = 0;
|
||||
double total_error = 0;
|
||||
const int count_test_block = 1000000;
|
||||
for (int i = 0; i < count_test_block; ++i) {
|
||||
int16_t test_input_block[16];
|
||||
int16_t test_temp_block[16];
|
||||
int16_t test_output_block[16];
|
||||
|
||||
// Initialize a test block with input range [-255, 255].
|
||||
for (int j = 0; j < 16; ++j)
|
||||
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
|
||||
|
||||
const int pitch = 8;
|
||||
vp8_short_fdct4x4_c(test_input_block, test_temp_block, pitch);
|
||||
reference_idct4x4(test_temp_block, test_output_block);
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
const int diff = test_input_block[j] - test_output_block[j];
|
||||
const int error = diff * diff;
|
||||
if (max_error < error)
|
||||
max_error = error;
|
||||
total_error += error;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_GE(1, max_error )
|
||||
<< "Error: FDCT/IDCT has an individual roundtrip error > 1";
|
||||
|
||||
EXPECT_GE(count_test_block, total_error)
|
||||
<< "Error: FDCT/IDCT has average roundtrip error > 1 per block";
|
||||
};
|
||||
|
||||
} // namespace
|
88
test/vp9_boolcoder_test.cc
Normal file
88
test/vp9_boolcoder_test.cc
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "vp9/encoder/vp9_boolhuff.h"
|
||||
#include "vp9/decoder/vp9_dboolhuff.h"
|
||||
}
|
||||
|
||||
#include "acm_random.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
using libvpx_test::ACMRandom;
|
||||
|
||||
namespace {
|
||||
const int num_tests = 10;
|
||||
} // namespace
|
||||
|
||||
TEST(VP9, TestBitIO) {
|
||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||
for (int n = 0; n < num_tests; ++n) {
|
||||
for (int method = 0; method <= 7; ++method) { // we generate various proba
|
||||
const int bits_to_test = 1000;
|
||||
uint8_t probas[bits_to_test];
|
||||
|
||||
for (int i = 0; i < bits_to_test; ++i) {
|
||||
const int parity = i & 1;
|
||||
probas[i] =
|
||||
(method == 0) ? 0 : (method == 1) ? 255 :
|
||||
(method == 2) ? 128 :
|
||||
(method == 3) ? rnd.Rand8() :
|
||||
(method == 4) ? (parity ? 0 : 255) :
|
||||
// alternate between low and high proba:
|
||||
(method == 5) ? (parity ? rnd(128) : 255 - rnd(128)) :
|
||||
(method == 6) ?
|
||||
(parity ? rnd(64) : 255 - rnd(64)) :
|
||||
(parity ? rnd(32) : 255 - rnd(32));
|
||||
}
|
||||
for (int bit_method = 0; bit_method <= 3; ++bit_method) {
|
||||
const int random_seed = 6432;
|
||||
const int buffer_size = 10000;
|
||||
ACMRandom bit_rnd(random_seed);
|
||||
BOOL_CODER bw;
|
||||
uint8_t bw_buffer[buffer_size];
|
||||
vp9_start_encode(&bw, bw_buffer);
|
||||
|
||||
int bit = (bit_method == 0) ? 0 : (bit_method == 1) ? 1 : 0;
|
||||
for (int i = 0; i < bits_to_test; ++i) {
|
||||
if (bit_method == 2) {
|
||||
bit = (i & 1);
|
||||
} else if (bit_method == 3) {
|
||||
bit = bit_rnd(2);
|
||||
}
|
||||
encode_bool(&bw, bit, static_cast<int>(probas[i]));
|
||||
}
|
||||
|
||||
vp9_stop_encode(&bw);
|
||||
|
||||
BOOL_DECODER br;
|
||||
vp9_start_decode(&br, bw_buffer, buffer_size);
|
||||
bit_rnd.Reset(random_seed);
|
||||
for (int i = 0; i < bits_to_test; ++i) {
|
||||
if (bit_method == 2) {
|
||||
bit = (i & 1);
|
||||
} else if (bit_method == 3) {
|
||||
bit = bit_rnd(2);
|
||||
}
|
||||
GTEST_ASSERT_EQ(decode_bool(&br, probas[i]), bit)
|
||||
<< "pos: " << i << " / " << bits_to_test
|
||||
<< " bit_method: " << bit_method
|
||||
<< " method: " << method;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
third_party/x86inc/LICENSE
vendored
Normal file
18
third_party/x86inc/LICENSE
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Copyright (C) 2005-2012 x264 project
|
||||
|
||||
Authors: Loren Merritt <lorenm@u.washington.edu>
|
||||
Anton Mitrofanov <BugMaster@narod.ru>
|
||||
Jason Garrett-Glaser <darkshikari@gmail.com>
|
||||
Henrik Gramner <hengar-6@student.ltu.se>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
11
third_party/x86inc/README.webm
vendored
Normal file
11
third_party/x86inc/README.webm
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
URL: http://git.videolan.org/?p=x264.git
|
||||
Version: 999b753ff0f4dc872077f4fa90d465e948cbe656
|
||||
License: ISC
|
||||
License File: LICENSE
|
||||
|
||||
Description:
|
||||
x264/libav's framework for x86 assembly. Contains a variety of macros and
|
||||
defines that help automatically allow assembly to work cross-platform.
|
||||
|
||||
Local Modifications:
|
||||
Some modifications to allow PIC to work with x86inc.
|
1118
third_party/x86inc/x86inc.asm
vendored
Normal file
1118
third_party/x86inc/x86inc.asm
vendored
Normal file
File diff suppressed because it is too large
Load Diff
72
tools/all_builds.py
Executable file
72
tools/all_builds.py
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)
|
3361
tools/cpplint.py
vendored
Executable file
3361
tools/cpplint.py
vendored
Executable file
File diff suppressed because it is too large
Load Diff
127
tools/diff.py
Normal file
127
tools/diff.py
Normal file
@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python
|
||||
## Copyright (c) 2012 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.
|
||||
##
|
||||
"""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)
|
||||
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
|
@ -29,12 +29,13 @@ log() {
|
||||
|
||||
|
||||
vpx_style() {
|
||||
astyle --style=bsd --min-conditional-indent=0 --break-blocks \
|
||||
--pad-oper --pad-header --unpad-paren \
|
||||
--align-pointer=name \
|
||||
--indent-preprocessor --convert-tabs --indent-labels \
|
||||
--suffix=none --quiet "$@"
|
||||
sed -i "" 's/[[:space:]]\{1,\},/,/g' "$@"
|
||||
for f; do
|
||||
case "$f" in
|
||||
*.h|*.c|*.cc)
|
||||
"${dirname_self}"/vpx-astyle.sh "$f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
@ -119,8 +120,7 @@ cd "$(git rev-parse --show-toplevel)"
|
||||
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 \
|
||||
| grep '\.[ch]$'); do
|
||||
for f in $(git diff HEAD^ --name-only -M90 --diff-filter=AM); do
|
||||
case "$f" in
|
||||
third_party/*) continue;;
|
||||
nestegg/*) continue;;
|
||||
|
@ -16,121 +16,9 @@ are relevant to A. The resulting file can be applied with patch(1) on top of A.
|
||||
|
||||
__author__ = "jkoleszar@google.com"
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
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)
|
||||
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
|
||||
import diff
|
||||
|
||||
|
||||
def FormatDiffHunks(hunks):
|
||||
@ -162,8 +50,8 @@ def ZipHunks(rhs_hunks, lhs_hunks):
|
||||
|
||||
|
||||
def main():
|
||||
old_hunks = [x for x in ParseDiffHunks(open(sys.argv[1], "r"))]
|
||||
new_hunks = [x for x in ParseDiffHunks(open(sys.argv[2], "r"))]
|
||||
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
|
||||
|
144
tools/lint-hunks.py
Executable file
144
tools/lint-hunks.py
Executable file
@ -0,0 +1,144 @@
|
||||
#!/usr/bin/python
|
||||
## Copyright (c) 2012 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.
|
||||
##
|
||||
"""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", "-runtime/int"]
|
||||
|
||||
|
||||
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())
|
27
tools/vpx-astyle.sh
Executable file
27
tools/vpx-astyle.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
astyle --style=java --indent=spaces=2 --indent-switches\
|
||||
--min-conditional-indent=0 \
|
||||
--pad-oper --pad-header --unpad-paren \
|
||||
--align-pointer=name \
|
||||
--indent-preprocessor --convert-tabs --indent-labels \
|
||||
--suffix=none --quiet --max-instatement-indent=80 "$@"
|
||||
# Disabled, too greedy?
|
||||
#sed -i 's;[[:space:]]\{1,\}\[;[;g' "$@"
|
||||
|
||||
sed_i() {
|
||||
# Incompatible sed parameter parsing.
|
||||
if sed -i 2>&1 | grep -q 'requires an argument'; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
sed_i -e 's/[[:space:]]\{1,\}\([,;]\)/\1/g' \
|
||||
-e 's/[[:space:]]\{1,\}\([+-]\{2\};\)/\1/g' \
|
||||
-e 's/,[[:space:]]*}/}/g' \
|
||||
-e 's;//\([^/[:space:]].*$\);// \1;g' \
|
||||
-e 's/^\(public\|private\|protected\):$/ \1:/g' \
|
||||
-e 's/[[:space:]]\{1,\}$//g' \
|
||||
"$@"
|
@ -20,11 +20,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FILE* set_binary_mode(FILE *stream)
|
||||
{
|
||||
(void)stream;
|
||||
FILE *set_binary_mode(FILE *stream) {
|
||||
(void)stream;
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
_setmode(_fileno(stream), _O_BINARY);
|
||||
_setmode(_fileno(stream), _O_BINARY);
|
||||
#endif
|
||||
return stream;
|
||||
return stream;
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
#define TOOLS_COMMON_H
|
||||
|
||||
/* Sets a stdio stream into binary mode */
|
||||
FILE* set_binary_mode(FILE *stream);
|
||||
FILE *set_binary_mode(FILE *stream);
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
|
||||
void vp8_dequant_idct_add_y_block_v6(short *q, short *dq,
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include <math.h>
|
||||
#include "vp8/common/filter.h"
|
||||
#include "bilinearfilter_arm.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include <math.h>
|
||||
#include "vp8/common/filter.h"
|
||||
#include "vpx_ports/mem.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/loopfilter.h"
|
||||
#include "vp8/common/onyxc_int.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
/* place these declarations here because we don't want to maintain them
|
||||
* outside of this scope
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/variance.h"
|
||||
#include "vp8/common/filter.h"
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "vpx_config.h"
|
||||
#include "vpx/vpx_codec.h"
|
||||
#include "vpx_ports/asm_offsets.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
|
||||
#if CONFIG_POSTPROC
|
||||
@ -21,19 +20,6 @@
|
||||
|
||||
BEGIN
|
||||
|
||||
/* vpx_scale */
|
||||
DEFINE(yv12_buffer_config_y_width, offsetof(YV12_BUFFER_CONFIG, y_width));
|
||||
DEFINE(yv12_buffer_config_y_height, offsetof(YV12_BUFFER_CONFIG, y_height));
|
||||
DEFINE(yv12_buffer_config_y_stride, offsetof(YV12_BUFFER_CONFIG, y_stride));
|
||||
DEFINE(yv12_buffer_config_uv_width, offsetof(YV12_BUFFER_CONFIG, uv_width));
|
||||
DEFINE(yv12_buffer_config_uv_height, offsetof(YV12_BUFFER_CONFIG, uv_height));
|
||||
DEFINE(yv12_buffer_config_uv_stride, offsetof(YV12_BUFFER_CONFIG, uv_stride));
|
||||
DEFINE(yv12_buffer_config_y_buffer, offsetof(YV12_BUFFER_CONFIG, y_buffer));
|
||||
DEFINE(yv12_buffer_config_u_buffer, offsetof(YV12_BUFFER_CONFIG, u_buffer));
|
||||
DEFINE(yv12_buffer_config_v_buffer, offsetof(YV12_BUFFER_CONFIG, v_buffer));
|
||||
DEFINE(yv12_buffer_config_border, offsetof(YV12_BUFFER_CONFIG, border));
|
||||
DEFINE(VP8BORDERINPIXELS_VAL, VP8BORDERINPIXELS);
|
||||
|
||||
#if CONFIG_POSTPROC
|
||||
/* mfqe.c / filter_by_weight */
|
||||
DEFINE(MFQE_PRECISION_VAL, MFQE_PRECISION);
|
||||
@ -58,11 +44,6 @@ ct_assert(B_HD_PRED, B_HD_PRED == 8);
|
||||
ct_assert(B_HU_PRED, B_HU_PRED == 9);
|
||||
#endif
|
||||
|
||||
#if HAVE_NEON
|
||||
/* vp8_yv12_extend_frame_borders_neon makes several assumptions based on this */
|
||||
ct_assert(VP8BORDERINPIXELS_VAL, VP8BORDERINPIXELS == 32)
|
||||
#endif
|
||||
|
||||
#if HAVE_SSE2
|
||||
#if CONFIG_POSTPROC
|
||||
/* vp8_filter_by_weight16x16 and 8x8 */
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#if ARCH_ARM
|
||||
#include "vpx_ports/arm.h"
|
||||
#elif ARCH_X86 || ARCH_X86_64
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
void vp8_dequant_idct_add_c(short *input, short *dq,
|
||||
unsigned char *dest, int stride);
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define __INC_INVTRANS_H
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "blockd.h"
|
||||
#include "onyxc_int.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "loopfilter.h"
|
||||
#include "onyxc_int.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "vpx_ports/mem.h"
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
#define MAX_LOOP_FILTER 63
|
||||
/* fraction of total macroblock rows to be used in fast filter level picking */
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "postproc.h"
|
||||
#include "variance.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_ports/mem.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
#define CROP_WIDTH 256
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/onyxc_int.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
#if HAVE_DSPR2
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define __INC_VP8C_INT_H
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx/internal/vpx_codec_internal.h"
|
||||
#include "loopfilter.h"
|
||||
#include "entropymv.h"
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_scale_rtcd.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "postproc.h"
|
||||
#include "common.h"
|
||||
|
@ -12,13 +12,8 @@
|
||||
#include "subpixel.h"
|
||||
#include "loopfilter.h"
|
||||
#include "recon.h"
|
||||
#include "idct.h"
|
||||
#include "onyxc_int.h"
|
||||
|
||||
void (*vp8_short_idct4x4)(short *input, short *output, int pitch);
|
||||
void (*vp8_short_idct4x4_1)(short *input, short *output, int pitch);
|
||||
void (*vp8_dc_only_idct)(short input_dc, short *output, int pitch);
|
||||
|
||||
extern void (*vp8_post_proc_down_and_across_mb_row)(
|
||||
unsigned char *src_ptr,
|
||||
unsigned char *dst_ptr,
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
#include "blockd.h"
|
||||
#include "reconinter.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "blockd.h"
|
||||
|
||||
|
@ -10,17 +10,17 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "blockd.h"
|
||||
|
||||
void vp8_intra4x4_predict_c(unsigned char *Above,
|
||||
unsigned char *yleft, int left_stride,
|
||||
B_PREDICTION_MODE b_mode,
|
||||
int _b_mode,
|
||||
unsigned char *dst, int dst_stride,
|
||||
unsigned char top_left)
|
||||
{
|
||||
int i, r, c;
|
||||
|
||||
B_PREDICTION_MODE b_mode = (B_PREDICTION_MODE)_b_mode;
|
||||
unsigned char Left[4];
|
||||
Left[0] = yleft[0];
|
||||
Left[1] = yleft[left_stride];
|
||||
|
@ -9,97 +9,13 @@
|
||||
*/
|
||||
#include "vpx_config.h"
|
||||
#define RTCD_C
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_ports/vpx_once.h"
|
||||
|
||||
#if CONFIG_MULTITHREAD && defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
static void once(void (*func)(void))
|
||||
{
|
||||
static CRITICAL_SECTION *lock;
|
||||
static LONG waiters;
|
||||
static int done;
|
||||
void *lock_ptr = &lock;
|
||||
|
||||
/* If the initialization is complete, return early. This isn't just an
|
||||
* optimization, it prevents races on the destruction of the global
|
||||
* lock.
|
||||
*/
|
||||
if(done)
|
||||
return;
|
||||
|
||||
InterlockedIncrement(&waiters);
|
||||
|
||||
/* Get a lock. We create one and try to make it the one-true-lock,
|
||||
* throwing it away if we lost the race.
|
||||
*/
|
||||
|
||||
{
|
||||
/* Scope to protect access to new_lock */
|
||||
CRITICAL_SECTION *new_lock = malloc(sizeof(CRITICAL_SECTION));
|
||||
InitializeCriticalSection(new_lock);
|
||||
if (InterlockedCompareExchangePointer(lock_ptr, new_lock, NULL) != NULL)
|
||||
{
|
||||
DeleteCriticalSection(new_lock);
|
||||
free(new_lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point, we have a lock that can be synchronized on. We don't
|
||||
* care which thread actually performed the allocation.
|
||||
*/
|
||||
|
||||
EnterCriticalSection(lock);
|
||||
|
||||
if (!done)
|
||||
{
|
||||
func();
|
||||
done = 1;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(lock);
|
||||
|
||||
/* Last one out should free resources. The destructed objects are
|
||||
* protected by checking if(done) above.
|
||||
*/
|
||||
if(!InterlockedDecrement(&waiters))
|
||||
{
|
||||
DeleteCriticalSection(lock);
|
||||
free(lock);
|
||||
lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H
|
||||
#include <pthread.h>
|
||||
static void once(void (*func)(void))
|
||||
{
|
||||
static pthread_once_t lock = PTHREAD_ONCE_INIT;
|
||||
pthread_once(&lock, func);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
/* No-op version that performs no synchronization. vpx_rtcd() is idempotent,
|
||||
* so as long as your platform provides atomic loads/stores of pointers
|
||||
* no synchronization is strictly necessary.
|
||||
*/
|
||||
|
||||
static void once(void (*func)(void))
|
||||
{
|
||||
static int done;
|
||||
|
||||
if(!done)
|
||||
{
|
||||
func();
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void vpx_rtcd()
|
||||
extern void vpx_scale_rtcd(void);
|
||||
|
||||
void vp8_rtcd()
|
||||
{
|
||||
vpx_scale_rtcd();
|
||||
once(setup_rtcd_internal);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
common_forward_decls() {
|
||||
vp8_common_forward_decls() {
|
||||
cat <<EOF
|
||||
#include "vp8/common/blockd.h"
|
||||
/*
|
||||
* VP8
|
||||
*/
|
||||
|
||||
struct blockd;
|
||||
struct macroblockd;
|
||||
@ -14,7 +16,7 @@ union int_mv;
|
||||
struct yv12_buffer_config;
|
||||
EOF
|
||||
}
|
||||
forward_decls common_forward_decls
|
||||
forward_decls vp8_common_forward_decls
|
||||
|
||||
#
|
||||
# Dequant
|
||||
@ -146,7 +148,7 @@ specialize vp8_build_intra_predictors_mby_s sse2 ssse3
|
||||
prototype void vp8_build_intra_predictors_mbuv_s "struct macroblockd *x, unsigned char * uabove_row, unsigned char * vabove_row, unsigned char *uleft, unsigned char *vleft, int left_stride, unsigned char * upred_ptr, unsigned char * vpred_ptr, int pred_stride"
|
||||
specialize vp8_build_intra_predictors_mbuv_s sse2 ssse3
|
||||
|
||||
prototype void vp8_intra4x4_predict "unsigned char *Above, unsigned char *yleft, int left_stride, B_PREDICTION_MODE b_mode, unsigned char *dst, int dst_stride, unsigned char top_left"
|
||||
prototype void vp8_intra4x4_predict "unsigned char *Above, unsigned char *yleft, int left_stride, int b_mode, unsigned char *dst, int dst_stride, unsigned char top_left"
|
||||
specialize vp8_intra4x4_predict media
|
||||
vp8_intra4x4_predict_media=vp8_intra4x4_predict_armv6
|
||||
|
||||
@ -530,39 +532,3 @@ fi
|
||||
|
||||
# End of encoder only functions
|
||||
fi
|
||||
|
||||
# Scaler functions
|
||||
if [ "CONFIG_SPATIAL_RESAMPLING" != "yes" ]; then
|
||||
prototype void vp8_horizontal_line_4_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_2_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_1_2_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_5_4_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_5_3_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_2_1_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_1_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_1_scale_i "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
fi
|
||||
|
||||
prototype void vp8_yv12_extend_frame_borders "struct yv12_buffer_config *ybf"
|
||||
specialize vp8_yv12_extend_frame_borders neon
|
||||
|
||||
prototype void vp8_yv12_copy_frame "struct yv12_buffer_config *src_ybc, struct yv12_buffer_config *dst_ybc"
|
||||
specialize vp8_yv12_copy_frame neon
|
||||
|
||||
prototype void vp8_yv12_copy_y "struct yv12_buffer_config *src_ybc, struct yv12_buffer_config *dst_ybc"
|
||||
specialize vp8_yv12_copy_y neon
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
|
||||
extern void vp8_dequantize_b_impl_mmx(short *sq, short *dq, short *q);
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
void vp8_idct_dequant_0_2x_sse2
|
||||
(short *q, short *dq ,
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vp8/common/blockd.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "vpx_ports/mem.h"
|
||||
#include "filter_x86.h"
|
||||
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
#include "onyxd_int.h"
|
||||
#include "vp8/common/header.h"
|
||||
#include "vp8/common/reconintra4x4.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "vp8/common/quant_common.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "vp8/common/systemdependent.h"
|
||||
#include "vpx_ports/vpx_timer.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
#if !defined(WIN32) && CONFIG_OS_SUPPORT == 1
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@
|
||||
EXPORT |vp8_encode_value|
|
||||
IMPORT |vp8_validate_buffer_arm|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -12,7 +12,7 @@
|
||||
EXPORT |vp8cx_pack_tokens_armv5|
|
||||
IMPORT |vp8_validate_buffer_arm|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -12,7 +12,7 @@
|
||||
EXPORT |vp8cx_pack_mb_row_tokens_armv5|
|
||||
IMPORT |vp8_validate_buffer_arm|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -12,7 +12,7 @@
|
||||
EXPORT |vp8cx_pack_tokens_into_partitions_armv5|
|
||||
IMPORT |vp8_validate_buffer_arm|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
EXPORT |vp8_fast_quantize_b_armv6|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -13,7 +13,7 @@
|
||||
EXPORT |vp8_subtract_mbuv_armv6|
|
||||
EXPORT |vp8_subtract_b_armv6|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_rtcd.h"
|
||||
#include "vp8_rtcd.h"
|
||||
|
||||
#if HAVE_MEDIA
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
EXPORT |vp8_fast_quantize_b_neon|
|
||||
EXPORT |vp8_fast_quantize_b_pair_neon|
|
||||
|
||||
INCLUDE asm_enc_offsets.asm
|
||||
INCLUDE vp8_asm_enc_offsets.asm
|
||||
|
||||
ARM
|
||||
REQUIRE8
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user