Merge branch 'vp9-preview' of review:webm/libvpx

Merge the vp9-preview branch into master.

Change-Id: If700b9054676f24bed9deb59050af546c1ca5296
This commit is contained in:
John Koleszar 2012-12-21 15:20:41 -08:00
commit 16810c10c1
406 changed files with 101264 additions and 14340 deletions

79
args.c
View File

@ -25,8 +25,7 @@ extern void die(const char *fmt, ...);
#endif #endif
struct arg arg_init(char **argv) struct arg arg_init(char **argv) {
{
struct arg a; struct arg a;
a.argv = argv; a.argv = argv;
@ -37,8 +36,7 @@ struct arg arg_init(char **argv)
return a; return a;
} }
int arg_match(struct arg *arg_, const struct arg_def *def, char **argv) int arg_match(struct arg *arg_, const struct arg_def *def, char **argv) {
{
struct arg arg; struct arg arg;
if (!argv[0] || argv[0][0] != '-') if (!argv[0] || argv[0][0] != '-')
@ -48,23 +46,19 @@ int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
if (def->short_name if (def->short_name
&& strlen(arg.argv[0]) == strlen(def->short_name) + 1 && strlen(arg.argv[0]) == strlen(def->short_name) + 1
&& !strcmp(arg.argv[0] + 1, def->short_name)) && !strcmp(arg.argv[0] + 1, def->short_name)) {
{
arg.name = arg.argv[0] + 1; arg.name = arg.argv[0] + 1;
arg.val = def->has_val ? arg.argv[1] : NULL; arg.val = def->has_val ? arg.argv[1] : NULL;
arg.argv_step = def->has_val ? 2 : 1; arg.argv_step = def->has_val ? 2 : 1;
} } else if (def->long_name) {
else if (def->long_name)
{
const size_t name_len = strlen(def->long_name); const size_t name_len = strlen(def->long_name);
if (strlen(arg.argv[0]) >= name_len + 2 if (strlen(arg.argv[0]) >= name_len + 2
&& arg.argv[0][1] == '-' && arg.argv[0][1] == '-'
&& !strncmp(arg.argv[0] + 2, def->long_name, name_len) && !strncmp(arg.argv[0] + 2, def->long_name, name_len)
&& (arg.argv[0][name_len + 2] == '=' && (arg.argv[0][name_len + 2] == '='
|| arg.argv[0][name_len+2] == '\0')) || arg.argv[0][name_len + 2] == '\0')) {
{
arg.name = arg.argv[0] + 2; arg.name = arg.argv[0] + 2;
arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL; arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
@ -79,8 +73,7 @@ int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
die("Error: option %s requires no argument.\n", arg.name); die("Error: option %s requires no argument.\n", arg.name);
if (arg.name if (arg.name
&& (arg.val || !def->has_val)) && (arg.val || !def->has_val)) {
{
arg.def = def; arg.def = def;
*arg_ = arg; *arg_ = arg;
return 1; return 1;
@ -90,8 +83,7 @@ int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
} }
const char *arg_next(struct arg *arg) const char *arg_next(struct arg *arg) {
{
if (arg->argv[0]) if (arg->argv[0])
arg->argv += arg->argv_step; arg->argv += arg->argv_step;
@ -99,8 +91,7 @@ const char *arg_next(struct arg *arg)
} }
char **argv_dup(int argc, const char **argv) char **argv_dup(int argc, const char **argv) {
{
char **new_argv = malloc((argc + 1) * sizeof(*argv)); char **new_argv = malloc((argc + 1) * sizeof(*argv));
memcpy(new_argv, argv, argc * sizeof(*argv)); memcpy(new_argv, argv, argc * sizeof(*argv));
@ -109,25 +100,21 @@ char **argv_dup(int argc, const char **argv)
} }
void arg_show_usage(FILE *fp, const struct arg_def *const *defs) void arg_show_usage(FILE *fp, const struct arg_def *const *defs) {
{
char option_text[40] = {0}; char option_text[40] = {0};
for (; *defs; defs++) for (; *defs; defs++) {
{
const struct arg_def *def = *defs; const struct arg_def *def = *defs;
char *short_val = def->has_val ? " <arg>" : ""; char *short_val = def->has_val ? " <arg>" : "";
char *long_val = def->has_val ? "=<arg>" : ""; char *long_val = def->has_val ? "=<arg>" : "";
if (def->short_name && def->long_name) if (def->short_name && def->long_name) {
{
char *comma = def->has_val ? "," : ", "; char *comma = def->has_val ? "," : ", ";
snprintf(option_text, 37, "-%s%s%s --%s%6s", snprintf(option_text, 37, "-%s%s%s --%s%6s",
def->short_name, short_val, comma, def->short_name, short_val, comma,
def->long_name, long_val); def->long_name, long_val);
} } else if (def->short_name)
else if (def->short_name)
snprintf(option_text, 37, "-%s%s", snprintf(option_text, 37, "-%s%s",
def->short_name, short_val); def->short_name, short_val);
else if (def->long_name) else if (def->long_name)
@ -136,8 +123,7 @@ void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
fprintf(fp, " %-37s\t%s\n", option_text, def->desc); fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
if(def->enums) if (def->enums) {
{
const struct arg_enum_list *listptr; const struct arg_enum_list *listptr;
fprintf(fp, " %-37s\t ", ""); fprintf(fp, " %-37s\t ", "");
@ -150,15 +136,13 @@ void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
} }
unsigned int arg_parse_uint(const struct arg *arg) unsigned int arg_parse_uint(const struct arg *arg) {
{
long int rawval; long int rawval;
char *endptr; char *endptr;
rawval = strtol(arg->val, &endptr, 10); rawval = strtol(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') if (arg->val[0] != '\0' && endptr[0] == '\0') {
{
if (rawval >= 0 && rawval <= UINT_MAX) if (rawval >= 0 && rawval <= UINT_MAX)
return rawval; return rawval;
@ -171,15 +155,13 @@ unsigned int arg_parse_uint(const struct arg *arg)
} }
int arg_parse_int(const struct arg *arg) int arg_parse_int(const struct arg *arg) {
{
long int rawval; long int rawval;
char *endptr; char *endptr;
rawval = strtol(arg->val, &endptr, 10); rawval = strtol(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') if (arg->val[0] != '\0' && endptr[0] == '\0') {
{
if (rawval >= INT_MIN && rawval <= INT_MAX) if (rawval >= INT_MIN && rawval <= INT_MAX)
return rawval; return rawval;
@ -192,13 +174,11 @@ int arg_parse_int(const struct arg *arg)
} }
struct vpx_rational struct vpx_rational {
{
int num; /**< fraction numerator */ int num; /**< fraction numerator */
int den; /**< fraction denominator */ int den; /**< fraction denominator */
}; };
struct vpx_rational arg_parse_rational(const struct arg *arg) struct vpx_rational arg_parse_rational(const struct arg *arg) {
{
long int rawval; long int rawval;
char *endptr; char *endptr;
struct vpx_rational rat; struct vpx_rational rat;
@ -206,41 +186,35 @@ struct vpx_rational arg_parse_rational(const struct arg *arg)
/* parse numerator */ /* parse numerator */
rawval = strtol(arg->val, &endptr, 10); rawval = strtol(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '/') if (arg->val[0] != '\0' && endptr[0] == '/') {
{
if (rawval >= INT_MIN && rawval <= INT_MAX) if (rawval >= INT_MIN && rawval <= INT_MAX)
rat.num = rawval; rat.num = rawval;
else die("Option %s: Value %ld out of range for signed int\n", else die("Option %s: Value %ld out of range for signed int\n",
arg->name, rawval); arg->name, rawval);
} } else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
/* parse denominator */ /* parse denominator */
rawval = strtol(endptr + 1, &endptr, 10); rawval = strtol(endptr + 1, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') if (arg->val[0] != '\0' && endptr[0] == '\0') {
{
if (rawval >= INT_MIN && rawval <= INT_MAX) if (rawval >= INT_MIN && rawval <= INT_MAX)
rat.den = rawval; rat.den = rawval;
else die("Option %s: Value %ld out of range for signed int\n", else die("Option %s: Value %ld out of range for signed int\n",
arg->name, rawval); arg->name, rawval);
} } else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
return rat; return rat;
} }
int arg_parse_enum(const struct arg *arg) int arg_parse_enum(const struct arg *arg) {
{
const struct arg_enum_list *listptr; const struct arg_enum_list *listptr;
long int rawval; long int rawval;
char *endptr; char *endptr;
/* First see if the value can be parsed as a raw value */ /* First see if the value can be parsed as a raw value */
rawval = strtol(arg->val, &endptr, 10); rawval = strtol(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') if (arg->val[0] != '\0' && endptr[0] == '\0') {
{
/* Got a raw value, make sure it's valid */ /* Got a raw value, make sure it's valid */
for (listptr = arg->def->enums; listptr->name; listptr++) for (listptr = arg->def->enums; listptr->name; listptr++)
if (listptr->val == rawval) if (listptr->val == rawval)
@ -257,8 +231,7 @@ int arg_parse_enum(const struct arg *arg)
} }
int arg_parse_enum_or_int(const struct arg *arg) int arg_parse_enum_or_int(const struct arg *arg) {
{
if (arg->def->enums) if (arg->def->enums)
return arg_parse_enum(arg); return arg_parse_enum(arg);
return arg_parse_int(arg); return arg_parse_int(arg);

9
args.h
View File

@ -13,8 +13,7 @@
#define ARGS_H #define ARGS_H
#include <stdio.h> #include <stdio.h>
struct arg struct arg {
{
char **argv; char **argv;
const char *name; const char *name;
const char *val; const char *val;
@ -22,15 +21,13 @@ struct arg
const struct arg_def *def; const struct arg_def *def;
}; };
struct arg_enum_list struct arg_enum_list {
{
const char *name; const char *name;
int val; int val;
}; };
#define ARG_ENUM_LIST_END {0} #define ARG_ENUM_LIST_END {0}
typedef struct arg_def typedef struct arg_def {
{
const char *short_name; const char *short_name;
const char *long_name; const char *long_name;
int has_val; int has_val;

View File

@ -208,4 +208,3 @@ endif
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
$(call import-module,cpufeatures) $(call import-module,cpufeatures)
endif endif

View File

@ -253,10 +253,25 @@ $(1):
$(if $(quiet),@echo " [LD] $$@") $(if $(quiet),@echo " [LD] $$@")
$(qexec)$$(LD) -shared $$(LDFLAGS) \ $(qexec)$$(LD) -shared $$(LDFLAGS) \
-Wl,--no-undefined -Wl,-soname,$$(SONAME) \ -Wl,--no-undefined -Wl,-soname,$$(SONAME) \
-Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \ -Wl,--version-script,$$(EXPORTS_FILE) -o $$@ \
$$(filter %.o,$$?) $$(extralibs) $$(filter %.o,$$^) $$(extralibs)
endef 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 define lipo_lib_template
$(1): $(addsuffix /$(1),$(FAT_ARCHS)) $(1): $(addsuffix /$(1),$(FAT_ARCHS))
$(if $(quiet),@echo " [LIPO] $$@") $(if $(quiet),@echo " [LIPO] $$@")
@ -321,6 +336,7 @@ LIBS=$(call enabled,LIBS)
@touch $@ @touch $@
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib)))) $(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 %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) INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist) ifeq ($(MAKECMDGOALS),dist)

View File

@ -277,6 +277,7 @@ clean_temp_files() {
# Toolchain Check Functions # Toolchain Check Functions
# #
check_cmd() { check_cmd() {
enabled external_build && return
log "$@" log "$@"
"$@" >>${logfile} 2>&1 "$@" >>${logfile} 2>&1
} }
@ -435,10 +436,10 @@ RTCD_OPTIONS = ${RTCD_OPTIONS}
EOF EOF
if enabled rvct; then cat >> $1 << 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 EOF
else cat >> $1 << 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 EOF
fi fi
@ -1001,7 +1002,11 @@ EOF
soft_enable sse2 soft_enable sse2
soft_enable sse3 soft_enable sse3
soft_enable ssse3 soft_enable ssse3
if enabled gcc && ! disabled sse4_1 && ! check_cflags -msse4; then
RTCD_OPTIONS="${RTCD_OPTIONS}--disable-sse4_1 "
else
soft_enable sse4_1 soft_enable sse4_1
fi
case ${tgt_os} in case ${tgt_os} in
win*) win*)
@ -1176,9 +1181,6 @@ EOF
;; ;;
esac esac
# for sysconf(3) and friends.
check_header unistd.h
# glibc needs these # glibc needs these
if enabled linux; then if enabled linux; then
add_cflags -D_LARGEFILE_SOURCE add_cflags -D_LARGEFILE_SOURCE

View File

@ -26,6 +26,7 @@ Options:
--help Print this message --help Print this message
--exe Generate a project for building an Application --exe Generate a project for building an Application
--lib Generate a project for creating a static library --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) --static-crt Use the static C runtime (/MT)
--target=isa-os-cc Target specifier (required) --target=isa-os-cc Target specifier (required)
--out=filename Write output to a file [stdout] --out=filename Write output to a file [stdout]
@ -142,7 +143,9 @@ generate_filter() {
if [ "${f##*.}" == "$pat" ]; then if [ "${f##*.}" == "$pat" ]; then
unset file_list[i] unset file_list[i]
objf=$(echo ${f%.*}.obj | sed -e 's/^[\./]\+//g' -e 's,/,_,g')
open_tag File RelativePath="./$f" open_tag File RelativePath="./$f"
if [ "$pat" == "asm" ] && $asm_use_custom_step; then if [ "$pat" == "asm" ] && $asm_use_custom_step; then
for plat in "${platforms[@]}"; do for plat in "${platforms[@]}"; do
for cfg in Debug Release; do for cfg in Debug Release; do
@ -152,14 +155,27 @@ generate_filter() {
tag Tool \ tag Tool \
Name="VCCustomBuildTool" \ Name="VCCustomBuildTool" \
Description="Assembling \$(InputFileName)" \ Description="Assembling \$(InputFileName)" \
CommandLine="$(eval echo \$asm_${cfg}_cmdline)" \ CommandLine="$(eval echo \$asm_${cfg}_cmdline) -o \$(IntDir)$objf" \
Outputs="\$(InputName).obj" \ Outputs="\$(IntDir)$objf" \
close_tag FileConfiguration close_tag FileConfiguration
done done
done done
fi 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 close_tag File
break break
@ -190,6 +206,8 @@ for opt in "$@"; do
;; ;;
--exe) proj_kind="exe" --exe) proj_kind="exe"
;; ;;
--dll) proj_kind="dll"
;;
--lib) proj_kind="lib" --lib) proj_kind="lib"
;; ;;
--src-path-bare=*) src_path_bare="$optval" --src-path-bare=*) src_path_bare="$optval"
@ -244,8 +262,10 @@ case "${vs_ver:-8}" in
asm_use_custom_step=$uses_asm asm_use_custom_step=$uses_asm
;; ;;
8) vs_ver_id="8.00" 8) vs_ver_id="8.00"
asm_use_custom_step=$uses_asm
;; ;;
9) vs_ver_id="9.00" 9) vs_ver_id="9.00"
asm_use_custom_step=$uses_asm
;; ;;
esac esac
@ -284,10 +304,11 @@ esac
case "$target" in case "$target" in
x86_64*) x86_64*)
platforms[0]="x64" platforms[0]="x64"
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
;; ;;
x86*) x86*)
platforms[0]="Win32" platforms[0]="Win32"
# these are only used by vs7
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;" asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;" asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} &quot;\$(InputPath)&quot;"
;; ;;
@ -299,6 +320,8 @@ generate_vcproj() {
case "$proj_kind" in case "$proj_kind" in
exe) vs_ConfigurationType=1 exe) vs_ConfigurationType=1
;; ;;
dll) vs_ConfigurationType=2
;;
*) vs_ConfigurationType=4 *) vs_ConfigurationType=4
;; ;;
esac esac
@ -318,13 +341,6 @@ generate_vcproj() {
done done
close_tag Platforms 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 open_tag Configurations
for plat in "${platforms[@]}"; do for plat in "${platforms[@]}"; do
plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'` plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`

View File

@ -17,15 +17,13 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
typedef enum typedef enum {
{
OUTPUT_FMT_PLAIN, OUTPUT_FMT_PLAIN,
OUTPUT_FMT_RVDS, OUTPUT_FMT_RVDS,
OUTPUT_FMT_GAS, OUTPUT_FMT_GAS,
} output_fmt_t; } output_fmt_t;
int log_msg(const char *fmt, ...) int log_msg(const char *fmt, ...) {
{
int res; int res;
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@ -40,8 +38,7 @@ int log_msg(const char *fmt, ...)
#include <mach-o/loader.h> #include <mach-o/loader.h>
#include <mach-o/nlist.h> #include <mach-o/nlist.h>
int parse_macho(uint8_t *base_buf, size_t sz) int parse_macho(uint8_t *base_buf, size_t sz) {
{
int i, j; int i, j;
struct mach_header header; struct mach_header header;
uint8_t *buf = base_buf; uint8_t *buf = base_buf;
@ -56,54 +53,40 @@ int parse_macho(uint8_t *base_buf, size_t sz)
*/ */
memcpy(&header, buf, sizeof(struct mach_header)); memcpy(&header, buf, sizeof(struct mach_header));
if (header.magic == MH_MAGIC) if (header.magic == MH_MAGIC) {
{
if (header.cputype == CPU_TYPE_ARM if (header.cputype == CPU_TYPE_ARM
|| header.cputype == CPU_TYPE_X86) || header.cputype == CPU_TYPE_X86) {
{
bits = 32; bits = 32;
buf += sizeof(struct mach_header); buf += sizeof(struct mach_header);
} } else {
else
{
log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_[ARM|X86].\n"); log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_[ARM|X86].\n");
goto bail; goto bail;
} }
} } else if (header.magic == MH_MAGIC_64) {
else if (header.magic == MH_MAGIC_64) if (header.cputype == CPU_TYPE_X86_64) {
{
if (header.cputype == CPU_TYPE_X86_64)
{
bits = 64; bits = 64;
buf += sizeof(struct mach_header_64); buf += sizeof(struct mach_header_64);
} } else {
else
{
log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_X86_64.\n"); log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_X86_64.\n");
goto bail; goto bail;
} }
} } else {
else
{
log_msg("Bad magic number for object file. 0x%x or 0x%x expected, 0x%x found.\n", log_msg("Bad magic number for object file. 0x%x or 0x%x expected, 0x%x found.\n",
MH_MAGIC, MH_MAGIC_64, header.magic); MH_MAGIC, MH_MAGIC_64, header.magic);
goto bail; goto bail;
} }
if (header.filetype != MH_OBJECT) if (header.filetype != MH_OBJECT) {
{
log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n"); log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n");
goto bail; goto bail;
} }
for (i = 0; i < header.ncmds; i++) for (i = 0; i < header.ncmds; i++) {
{
struct load_command lc; struct load_command lc;
memcpy(&lc, buf, sizeof(struct load_command)); memcpy(&lc, buf, sizeof(struct load_command));
if (lc.cmd == LC_SEGMENT) if (lc.cmd == LC_SEGMENT) {
{
uint8_t *seg_buf = buf; uint8_t *seg_buf = buf;
struct section s; struct section s;
struct segment_command seg_c; struct segment_command seg_c;
@ -118,17 +101,14 @@ int parse_macho(uint8_t *base_buf, size_t sz)
* debug sections mixed in, the offset of the debug section * debug sections mixed in, the offset of the debug section
* increases but n_value still references the first section. * increases but n_value still references the first section.
*/ */
if (seg_c.nsects < 1) if (seg_c.nsects < 1) {
{
log_msg("Not enough sections\n"); log_msg("Not enough sections\n");
goto bail; goto bail;
} }
memcpy(&s, seg_buf, sizeof(struct section)); memcpy(&s, seg_buf, sizeof(struct section));
base_data_section = s.offset; base_data_section = s.offset;
} } else if (lc.cmd == LC_SEGMENT_64) {
else if (lc.cmd == LC_SEGMENT_64)
{
uint8_t *seg_buf = buf; uint8_t *seg_buf = buf;
struct section_64 s; struct section_64 s;
struct segment_command_64 seg_c; struct segment_command_64 seg_c;
@ -137,27 +117,22 @@ int parse_macho(uint8_t *base_buf, size_t sz)
seg_buf += sizeof(struct segment_command_64); seg_buf += sizeof(struct segment_command_64);
/* Explanation in LG_SEGMENT */ /* Explanation in LG_SEGMENT */
if (seg_c.nsects < 1) if (seg_c.nsects < 1) {
{
log_msg("Not enough sections\n"); log_msg("Not enough sections\n");
goto bail; goto bail;
} }
memcpy(&s, seg_buf, sizeof(struct section_64)); memcpy(&s, seg_buf, sizeof(struct section_64));
base_data_section = s.offset; base_data_section = s.offset;
} } else if (lc.cmd == LC_SYMTAB) {
else if (lc.cmd == LC_SYMTAB) if (base_data_section != 0) {
{
if (base_data_section != 0)
{
struct symtab_command sc; struct symtab_command sc;
uint8_t *sym_buf = base_buf; uint8_t *sym_buf = base_buf;
uint8_t *str_buf = base_buf; uint8_t *str_buf = base_buf;
memcpy(&sc, buf, sizeof(struct symtab_command)); memcpy(&sc, buf, sizeof(struct symtab_command));
if (sc.cmdsize != sizeof(struct symtab_command)) if (sc.cmdsize != sizeof(struct symtab_command)) {
{
log_msg("Can't find symbol table!\n"); log_msg("Can't find symbol table!\n");
goto bail; goto bail;
} }
@ -165,16 +140,14 @@ int parse_macho(uint8_t *base_buf, size_t sz)
sym_buf += sc.symoff; sym_buf += sc.symoff;
str_buf += sc.stroff; str_buf += sc.stroff;
for (j = 0; j < sc.nsyms; j++) for (j = 0; j < sc.nsyms; j++) {
{
/* Location of string is cacluated each time from the /* Location of string is cacluated each time from the
* start of the string buffer. On darwin the symbols * start of the string buffer. On darwin the symbols
* are prefixed by "_", so we bump the pointer by 1. * are prefixed by "_", so we bump the pointer by 1.
* The target value is defined as an int in asm_*_offsets.c, * The target value is defined as an int in asm_*_offsets.c,
* which is 4 bytes on all targets we currently use. * which is 4 bytes on all targets we currently use.
*/ */
if (bits == 32) if (bits == 32) {
{
struct nlist nl; struct nlist nl;
int val; int val;
@ -185,9 +158,7 @@ int parse_macho(uint8_t *base_buf, size_t sz)
sizeof(val)); sizeof(val));
printf("%-40s EQU %5d\n", printf("%-40s EQU %5d\n",
str_buf + nl.n_un.n_strx + 1, val); str_buf + nl.n_un.n_strx + 1, val);
} } else { /* if (bits == 64) */
else /* if (bits == 64) */
{
struct nlist_64 nl; struct nlist_64 nl;
int val; int val;
@ -229,8 +200,7 @@ bail:
ENDIAN_ASSIGN(memb, memb);\ ENDIAN_ASSIGN(memb, memb);\
} while(0) } while(0)
typedef struct typedef struct {
{
uint8_t *buf; /* Buffer containing ELF data */ uint8_t *buf; /* Buffer containing ELF data */
size_t sz; /* Buffer size */ size_t sz; /* Buffer size */
int le_data; /* Data is little-endian */ int le_data; /* Data is little-endian */
@ -240,8 +210,7 @@ typedef struct
Elf64_Ehdr hdr64; Elf64_Ehdr hdr64;
} elf_obj_t; } elf_obj_t;
int parse_elf_header(elf_obj_t *elf) int parse_elf_header(elf_obj_t *elf) {
{
int res; int res;
/* Verify ELF Magic numbers */ /* Verify ELF Magic numbers */
COPY_STRUCT(&elf->e_ident, elf->buf, 0, elf->sz); COPY_STRUCT(&elf->e_ident, elf->buf, 0, elf->sz);
@ -258,8 +227,7 @@ int parse_elf_header(elf_obj_t *elf)
elf->le_data = elf->e_ident[EI_DATA] == ELFDATA2LSB; elf->le_data = elf->e_ident[EI_DATA] == ELFDATA2LSB;
/* Read in relevant values */ /* Read in relevant values */
if (elf->e_ident[EI_CLASS] == ELFCLASS32) if (elf->e_ident[EI_CLASS] == ELFCLASS32) {
{
elf->bits = 32; elf->bits = 32;
COPY_STRUCT(&elf->hdr32, elf->buf, 0, elf->sz); COPY_STRUCT(&elf->hdr32, elf->buf, 0, elf->sz);
@ -276,9 +244,7 @@ int parse_elf_header(elf_obj_t *elf)
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shentsize); ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shentsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shnum); ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shnum);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shstrndx); ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shstrndx);
} } else { /* if (elf->e_ident[EI_CLASS] == ELFCLASS64) */
else /* if (elf->e_ident[EI_CLASS] == ELFCLASS64) */
{
elf->bits = 64; elf->bits = 64;
COPY_STRUCT(&elf->hdr64, elf->buf, 0, elf->sz); COPY_STRUCT(&elf->hdr64, elf->buf, 0, elf->sz);
@ -303,10 +269,8 @@ bail:
return 1; return 1;
} }
int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hdr64) int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hdr64) {
{ if (hdr32) {
if (hdr32)
{
if (idx >= elf->hdr32.e_shnum) if (idx >= elf->hdr32.e_shnum)
goto bail; goto bail;
@ -322,9 +286,7 @@ int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hd
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_info); ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_info);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addralign); ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addralign);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_entsize); ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_entsize);
} } else { /* if (hdr64) */
else /* if (hdr64) */
{
if (idx >= elf->hdr64.e_shnum) if (idx >= elf->hdr64.e_shnum)
goto bail; goto bail;
@ -347,27 +309,21 @@ bail:
return 1; return 1;
} }
char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx) char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx) {
{ if (elf->bits == 32) {
if (elf->bits == 32)
{
Elf32_Shdr shdr; Elf32_Shdr shdr;
if (parse_elf_section(elf, s_idx, &shdr, NULL)) if (parse_elf_section(elf, s_idx, &shdr, NULL)) {
{
log_msg("Failed to parse ELF string table: section %d, index %d\n", log_msg("Failed to parse ELF string table: section %d, index %d\n",
s_idx, idx); s_idx, idx);
return ""; return "";
} }
return (char *)(elf->buf + shdr.sh_offset + idx); return (char *)(elf->buf + shdr.sh_offset + idx);
} } else { /* if (elf->bits == 64) */
else /* if (elf->bits == 64) */
{
Elf64_Shdr shdr; Elf64_Shdr shdr;
if (parse_elf_section(elf, s_idx, NULL, &shdr)) if (parse_elf_section(elf, s_idx, NULL, &shdr)) {
{
log_msg("Failed to parse ELF string table: section %d, index %d\n", log_msg("Failed to parse ELF string table: section %d, index %d\n",
s_idx, idx); s_idx, idx);
return ""; return "";
@ -377,10 +333,8 @@ char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx)
} }
} }
int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_Sym *sym64) int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_Sym *sym64) {
{ if (sym32) {
if (sym32)
{
COPY_STRUCT(sym32, elf->buf, ofst, elf->sz); COPY_STRUCT(sym32, elf->buf, ofst, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_name); ENDIAN_ASSIGN_IN_PLACE(sym32->st_name);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_value); ENDIAN_ASSIGN_IN_PLACE(sym32->st_value);
@ -388,9 +342,7 @@ int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_
ENDIAN_ASSIGN_IN_PLACE(sym32->st_info); ENDIAN_ASSIGN_IN_PLACE(sym32->st_info);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_other); ENDIAN_ASSIGN_IN_PLACE(sym32->st_other);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_shndx); ENDIAN_ASSIGN_IN_PLACE(sym32->st_shndx);
} } else { /* if (sym64) */
else /* if (sym64) */
{
COPY_STRUCT(sym64, elf->buf, ofst, elf->sz); COPY_STRUCT(sym64, elf->buf, ofst, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_name); ENDIAN_ASSIGN_IN_PLACE(sym64->st_name);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_value); ENDIAN_ASSIGN_IN_PLACE(sym64->st_value);
@ -404,8 +356,7 @@ bail:
return 1; return 1;
} }
int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode) int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode) {
{
elf_obj_t elf; elf_obj_t elf;
unsigned int ofst; unsigned int ofst;
int i; int i;
@ -420,43 +371,34 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
if (parse_elf_header(&elf)) if (parse_elf_header(&elf))
goto bail; goto bail;
if (elf.bits == 32) if (elf.bits == 32) {
{
Elf32_Shdr shdr; Elf32_Shdr shdr;
for (i = 0; i < elf.hdr32.e_shnum; i++) for (i = 0; i < elf.hdr32.e_shnum; i++) {
{
parse_elf_section(&elf, i, &shdr, NULL); parse_elf_section(&elf, i, &shdr, NULL);
if (shdr.sh_type == SHT_STRTAB) if (shdr.sh_type == SHT_STRTAB) {
{
char strtsb_name[128]; char strtsb_name[128];
strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name)); strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
if (!(strcmp(strtsb_name, ".shstrtab"))) if (!(strcmp(strtsb_name, ".shstrtab"))) {
{
/* log_msg("found section: %s\n", strtsb_name); */ /* log_msg("found section: %s\n", strtsb_name); */
strtab_off32 = shdr.sh_offset; strtab_off32 = shdr.sh_offset;
break; break;
} }
} }
} }
} } else { /* if (elf.bits == 64) */
else /* if (elf.bits == 64) */
{
Elf64_Shdr shdr; Elf64_Shdr shdr;
for (i = 0; i < elf.hdr64.e_shnum; i++) for (i = 0; i < elf.hdr64.e_shnum; i++) {
{
parse_elf_section(&elf, i, NULL, &shdr); parse_elf_section(&elf, i, NULL, &shdr);
if (shdr.sh_type == SHT_STRTAB) if (shdr.sh_type == SHT_STRTAB) {
{
char strtsb_name[128]; char strtsb_name[128];
strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name)); strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
if (!(strcmp(strtsb_name, ".shstrtab"))) if (!(strcmp(strtsb_name, ".shstrtab"))) {
{
/* log_msg("found section: %s\n", strtsb_name); */ /* log_msg("found section: %s\n", strtsb_name); */
strtab_off64 = shdr.sh_offset; strtab_off64 = shdr.sh_offset;
break; break;
@ -466,19 +408,15 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
} }
/* Parse all Symbol Tables */ /* Parse all Symbol Tables */
if (elf.bits == 32) if (elf.bits == 32) {
{
Elf32_Shdr shdr; Elf32_Shdr shdr;
for (i = 0; i < elf.hdr32.e_shnum; i++) for (i = 0; i < elf.hdr32.e_shnum; i++) {
{
parse_elf_section(&elf, i, &shdr, NULL); parse_elf_section(&elf, i, &shdr, NULL);
if (shdr.sh_type == SHT_SYMTAB) if (shdr.sh_type == SHT_SYMTAB) {
{
for (ofst = shdr.sh_offset; for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size; ofst < shdr.sh_offset + shdr.sh_size;
ofst += shdr.sh_entsize) ofst += shdr.sh_entsize) {
{
Elf32_Sym sym; Elf32_Sym sym;
parse_elf_symbol(&elf, ofst, &sym, NULL); parse_elf_symbol(&elf, ofst, &sym, NULL);
@ -494,8 +432,7 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
*/ */
if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT
&& sym.st_size == 4) && sym.st_size == 4) {
{
Elf32_Shdr dhdr; Elf32_Shdr dhdr;
int val = 0; int val = 0;
char section_name[128]; char section_name[128];
@ -506,10 +443,8 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
strcpy(section_name, (char *)(elf.buf + strtab_off32 + dhdr.sh_name)); strcpy(section_name, (char *)(elf.buf + strtab_off32 + dhdr.sh_name));
/* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */ /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
if (strcmp(section_name, ".bss")) if (strcmp(section_name, ".bss")) {
{ if (sizeof(val) != sym.st_size) {
if (sizeof(val) != sym.st_size)
{
/* The target value is declared as an int in /* The target value is declared as an int in
* asm_*_offsets.c, which is 4 bytes on all * asm_*_offsets.c, which is 4 bytes on all
* targets we currently use. Complain loudly if * targets we currently use. Complain loudly if
@ -524,14 +459,12 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
sym.st_size); sym.st_size);
} }
if (!elf.le_data) if (!elf.le_data) {
{
log_msg("Big Endian data not supported yet!\n"); log_msg("Big Endian data not supported yet!\n");
goto bail; goto bail;
} }
switch (mode) switch (mode) {
{
case OUTPUT_FMT_RVDS: case OUTPUT_FMT_RVDS:
printf("%-40s EQU %5d\n", printf("%-40s EQU %5d\n",
parse_elf_string_table(&elf, parse_elf_string_table(&elf,
@ -557,20 +490,15 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
} }
} }
} }
} } else { /* if (elf.bits == 64) */
else /* if (elf.bits == 64) */
{
Elf64_Shdr shdr; Elf64_Shdr shdr;
for (i = 0; i < elf.hdr64.e_shnum; i++) for (i = 0; i < elf.hdr64.e_shnum; i++) {
{
parse_elf_section(&elf, i, NULL, &shdr); parse_elf_section(&elf, i, NULL, &shdr);
if (shdr.sh_type == SHT_SYMTAB) if (shdr.sh_type == SHT_SYMTAB) {
{
for (ofst = shdr.sh_offset; for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size; ofst < shdr.sh_offset + shdr.sh_size;
ofst += shdr.sh_entsize) ofst += shdr.sh_entsize) {
{
Elf64_Sym sym; Elf64_Sym sym;
parse_elf_symbol(&elf, ofst, NULL, &sym); parse_elf_symbol(&elf, ofst, NULL, &sym);
@ -586,8 +514,7 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
*/ */
if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT
&& sym.st_size == 4) && sym.st_size == 4) {
{
Elf64_Shdr dhdr; Elf64_Shdr dhdr;
int val = 0; int val = 0;
char section_name[128]; char section_name[128];
@ -598,10 +525,8 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
strcpy(section_name, (char *)(elf.buf + strtab_off64 + dhdr.sh_name)); strcpy(section_name, (char *)(elf.buf + strtab_off64 + dhdr.sh_name));
/* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */ /* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
if ((strcmp(section_name, ".bss"))) if ((strcmp(section_name, ".bss"))) {
{ if (sizeof(val) != sym.st_size) {
if (sizeof(val) != sym.st_size)
{
/* The target value is declared as an int in /* The target value is declared as an int in
* asm_*_offsets.c, which is 4 bytes on all * asm_*_offsets.c, which is 4 bytes on all
* targets we currently use. Complain loudly if * targets we currently use. Complain loudly if
@ -616,14 +541,12 @@ int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode)
sym.st_size); sym.st_size);
} }
if (!elf.le_data) if (!elf.le_data) {
{
log_msg("Big Endian data not supported yet!\n"); log_msg("Big Endian data not supported yet!\n");
goto bail; goto bail;
} }
switch (mode) switch (mode) {
{
case OUTPUT_FMT_RVDS: case OUTPUT_FMT_RVDS:
printf("%-40s EQU %5d\n", printf("%-40s EQU %5d\n",
parse_elf_string_table(&elf, parse_elf_string_table(&elf,
@ -671,8 +594,7 @@ bail:
#define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 ) #define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 )
#define get_le16(x) ((*(x)) | (*(x+1)) << 8) #define get_le16(x) ((*(x)) | (*(x+1)) << 8)
int parse_coff(uint8_t *buf, size_t sz) int parse_coff(uint8_t *buf, size_t sz) {
{
unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr; unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
unsigned int sectionrawdata_ptr; unsigned int sectionrawdata_ptr;
unsigned int i; unsigned int i;
@ -687,16 +609,14 @@ int parse_coff(uint8_t *buf, size_t sz)
symtab_sz = get_le32(buf + 12); symtab_sz = get_le32(buf + 12);
strtab_ptr = symtab_ptr + symtab_sz * 18; strtab_ptr = symtab_ptr + symtab_sz * 18;
if (nsections > 96) if (nsections > 96) {
{
log_msg("Too many sections\n"); log_msg("Too many sections\n");
return 1; return 1;
} }
sectionlist = malloc(nsections * sizeof(sectionlist)); sectionlist = malloc(nsections * sizeof(sectionlist));
if (sectionlist == NULL) if (sectionlist == NULL) {
{
log_msg("Allocating first level of section list failed\n"); log_msg("Allocating first level of section list failed\n");
return 1; return 1;
} }
@ -710,16 +630,14 @@ int parse_coff(uint8_t *buf, size_t sz)
ptr = buf + 20; // section header ptr = buf + 20; // section header
for (i = 0; i < nsections; i++) for (i = 0; i < nsections; i++) {
{
char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
strncpy(sectionname, ptr, 8); strncpy(sectionname, ptr, 8);
// log_msg("COFF: Parsing section %s\n",sectionname); // log_msg("COFF: Parsing section %s\n",sectionname);
sectionlist[i] = malloc(strlen(sectionname) + 1); sectionlist[i] = malloc(strlen(sectionname) + 1);
if (sectionlist[i] == NULL) if (sectionlist[i] == NULL) {
{
log_msg("Allocating storage for %s failed\n", sectionname); log_msg("Allocating storage for %s failed\n", sectionname);
goto bail; goto bail;
} }
@ -753,16 +671,13 @@ int parse_coff(uint8_t *buf, size_t sz)
*/ */
ptr = buf + symtab_ptr; ptr = buf + symtab_ptr;
for (i = 0; i < symtab_sz; i++) for (i = 0; i < symtab_sz; i++) {
{
int16_t section = get_le16(ptr + 12); // section number int16_t section = get_le16(ptr + 12); // section number
if (section > 0 && ptr[16] == 2) if (section > 0 && ptr[16] == 2) {
{
// if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) { // if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) {
if (get_le32(ptr)) if (get_le32(ptr)) {
{
char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
strncpy(name, ptr, 8); strncpy(name, ptr, 8);
// log_msg("COFF: Parsing symbol %s\n",name); // log_msg("COFF: Parsing symbol %s\n",name);
@ -773,9 +688,7 @@ int parse_coff(uint8_t *buf, size_t sz)
printf("%-40s EQU ", name + 1); printf("%-40s EQU ", name + 1);
else else
printf("%-40s EQU ", name); printf("%-40s EQU ", name);
} } else {
else
{
// log_msg("COFF: Parsing symbol %s\n", // log_msg("COFF: Parsing symbol %s\n",
// buf + strtab_ptr + get_le32(ptr+4)); // buf + strtab_ptr + get_le32(ptr+4));
if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_') if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_')
@ -785,12 +698,9 @@ int parse_coff(uint8_t *buf, size_t sz)
printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4)); printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
} }
if (!(strcmp(sectionlist[section-1], ".bss"))) if (!(strcmp(sectionlist[section - 1], ".bss"))) {
{
symoffset = 0; symoffset = 0;
} } else {
else
{
symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8)); symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8));
} }
@ -807,8 +717,7 @@ int parse_coff(uint8_t *buf, size_t sz)
printf(" END\n"); printf(" END\n");
for (i = 0; i < nsections; i++) for (i = 0; i < nsections; i++) {
{
free(sectionlist[i]); free(sectionlist[i]);
} }
@ -817,8 +726,7 @@ int parse_coff(uint8_t *buf, size_t sz)
return 0; return 0;
bail: bail:
for (i = 0; i < nsections; i++) for (i = 0; i < nsections; i++) {
{
free(sectionlist[i]); free(sectionlist[i]);
} }
@ -828,8 +736,7 @@ bail:
} }
#endif /* defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) */ #endif /* defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) */
int main(int argc, char **argv) int main(int argc, char **argv) {
{
output_fmt_t mode = OUTPUT_FMT_PLAIN; output_fmt_t mode = OUTPUT_FMT_PLAIN;
const char *f; const char *f;
uint8_t *file_buf; uint8_t *file_buf;
@ -837,8 +744,7 @@ int main(int argc, char **argv)
FILE *fp; FILE *fp;
long int file_size; long int file_size;
if (argc < 2 || argc > 3) if (argc < 2 || argc > 3) {
{
fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]); fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
fprintf(stderr, " <obj file>\tobject file to parse\n"); fprintf(stderr, " <obj file>\tobject file to parse\n");
fprintf(stderr, "Output Formats:\n"); fprintf(stderr, "Output Formats:\n");
@ -858,14 +764,12 @@ int main(int argc, char **argv)
fp = fopen(f, "rb"); fp = fopen(f, "rb");
if (!fp) if (!fp) {
{
perror("Unable to open file"); perror("Unable to open file");
goto bail; goto bail;
} }
if (fseek(fp, 0, SEEK_END)) if (fseek(fp, 0, SEEK_END)) {
{
perror("stat"); perror("stat");
goto bail; goto bail;
} }
@ -873,22 +777,19 @@ int main(int argc, char **argv)
file_size = ftell(fp); file_size = ftell(fp);
file_buf = malloc(file_size); file_buf = malloc(file_size);
if (!file_buf) if (!file_buf) {
{
perror("malloc"); perror("malloc");
goto bail; goto bail;
} }
rewind(fp); rewind(fp);
if (fread(file_buf, sizeof(char), file_size, fp) != file_size) if (fread(file_buf, sizeof(char), file_size, fp) != file_size) {
{
perror("read"); perror("read");
goto bail; goto bail;
} }
if (fclose(fp)) if (fclose(fp)) {
{
perror("close"); perror("close");
goto bail; goto bail;
} }

View File

@ -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. REM be found in the AUTHORS file in the root of the source tree.
echo on 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/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/decoder/asm_dec_offsets.c"
cl /I "./" /I "%1" /nologo /c "%1/vp8/encoder/asm_enc_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_com_offsets.obj" > "vp8_asm_com_offsets.asm"
obj_int_extract.exe rvds "asm_dec_offsets.obj" > "asm_dec_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" > "asm_enc_offsets.asm" obj_int_extract.exe rvds "asm_enc_offsets.obj" > "vp8_asm_enc_offsets.asm"

View File

@ -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 (&apos;symbol&apos; or &apos;symbol = value&apos;) "
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 (&apos;nasm&apos; or &apos;raw&apos;)"
>
<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 (&apos;nasm&apos;) or AT&amp;T ( &apos;gas&apos;) 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
View File

@ -34,6 +34,7 @@ Advanced options:
${toggle_md5} support for output of checksum data ${toggle_md5} support for output of checksum data
${toggle_static_msvcrt} use static MSVCRT (VS builds only) ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
${toggle_vp8} VP8 codec support ${toggle_vp8} VP8 codec support
${toggle_vp9} VP9 codec support
${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders) ${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
${toggle_mem_tracker} track memory usage ${toggle_mem_tracker} track memory usage
${toggle_postproc} postprocessing ${toggle_postproc} postprocessing
@ -176,19 +177,24 @@ enable os_support
enable temporal_denoising enable temporal_denoising
[ -d ${source_path}/../include ] && enable alt_tree_layout [ -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; [ -d ${source_path}/${d} ] && disable alt_tree_layout;
done done
if ! enabled alt_tree_layout; then if ! enabled alt_tree_layout; then
# development environment # development environment
[ -d ${source_path}/vp8 ] && CODECS="${CODECS} vp8_encoder vp8_decoder" [ -d ${source_path}/vp8 ] && CODECS="${CODECS} vp8_encoder vp8_decoder"
[ -d ${source_path}/vp9 ] && CODECS="${CODECS} vp9_encoder vp9_decoder"
else else
# customer environment # customer environment
[ -f ${source_path}/../include/vpx/vp8cx.h ] && CODECS="${CODECS} vp8_encoder" [ -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/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/vp8cx.h ] || disable vp8_encoder
[ -f ${source_path}/../include/vpx/vp8dx.h ] || disable vp8_decoder [ -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 [ -f ${source_path}/../lib/*/*mt.lib ] && soft_enable static_msvcrt
fi fi
@ -230,6 +236,18 @@ HAVE_LIST="
sys_mman_h sys_mman_h
unistd_h unistd_h
" "
EXPERIMENT_LIST="
csm
comp_intra_pred
superblocks
pred_filter
lossless
subpelrefmv
new_mvref
implicit_segmentation
newbintramodes
comp_interintra_pred
"
CONFIG_LIST=" CONFIG_LIST="
external_build external_build
install_docs install_docs
@ -276,8 +294,11 @@ CONFIG_LIST="
unit_tests unit_tests
multi_res_encoding multi_res_encoding
temporal_denoising temporal_denoising
experimental
${EXPERIMENT_LIST}
" "
CMDLINE_SELECT=" CMDLINE_SELECT="
external_build
extra_warnings extra_warnings
werror werror
install_docs install_docs
@ -322,6 +343,7 @@ CMDLINE_SELECT="
unit_tests unit_tests
multi_res_encoding multi_res_encoding
temporal_denoising temporal_denoising
experimental
" "
process_cmdline() { process_cmdline() {
@ -329,6 +351,18 @@ process_cmdline() {
optval="${opt#*=}" optval="${opt#*=}"
case "$opt" in case "$opt" in
--disable-codecs) for c in ${CODECS}; do disable $c; done ;; --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" *) process_common_cmdline "$opt"
;; ;;
esac esac
@ -464,7 +498,7 @@ process_detect() {
fi fi
fi fi
fi fi
if [ -z "$CC" ]; then if [ -z "$CC" ] || enabled external_build; then
echo "Bypassing toolchain for environment detection." echo "Bypassing toolchain for environment detection."
enable external_build enable external_build
check_header() { check_header() {
@ -473,6 +507,7 @@ process_detect() {
shift shift
var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'` var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
disable $var disable $var
# Headers common to all environments
case $header in case $header in
stdio.h) stdio.h)
true; true;
@ -484,6 +519,25 @@ process_detect() {
done done
${result:-true} ${result:-true}
esac && enable $var 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() { check_ld() {
true true
@ -497,6 +551,7 @@ EOF
check_header stdint.h check_header stdint.h
check_header pthread.h check_header pthread.h
check_header sys/mman.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 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 -Wpointer-arith
check_add_cflags -Wtype-limits check_add_cflags -Wtype-limits
check_add_cflags -Wcast-qual check_add_cflags -Wcast-qual
check_add_cflags -Wvla
check_add_cflags -Wimplicit-function-declaration check_add_cflags -Wimplicit-function-declaration
check_add_cflags -Wuninitialized check_add_cflags -Wuninitialized
check_add_cflags -Wunused-variable check_add_cflags -Wunused-variable

View File

@ -18,26 +18,23 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#if CONFIG_VP8_DECODER #if CONFIG_VP9_DECODER
#include "vpx/vp8dx.h" #include "vpx/vp8dx.h"
#endif #endif
static char *exec_name; static char *exec_name;
static int verbose = 0; static int verbose = 0;
static const struct static const struct {
{
const char *name; const char *name;
const vpx_codec_iface_t *iface; const vpx_codec_iface_t *iface;
} ifaces[] = } ifaces[] = {
{ #if CONFIG_VP9_DECODER
#if CONFIG_VP8_DECODER {"vp9", &vpx_codec_vp8_dx_algo},
{"vp8", &vpx_codec_vp8_dx_algo},
#endif #endif
}; };
static void usage_exit(void) static void usage_exit(void) {
{
int i; int i;
printf("Usage: %s <options>\n\n" printf("Usage: %s <options>\n\n"
@ -61,8 +58,7 @@ static void usage_exit(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
static void usage_error(const char *fmt, ...) static void usage_error(const char *fmt, ...) {
{
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vprintf(fmt, ap); vprintf(fmt, ap);
@ -70,16 +66,14 @@ static void usage_error(const char *fmt, ...)
usage_exit(); usage_exit();
} }
void my_mem_dtor(vpx_codec_mmap_t *mmap) void my_mem_dtor(vpx_codec_mmap_t *mmap) {
{
if (verbose) if (verbose)
printf("freeing segment %d\n", mmap->id); printf("freeing segment %d\n", mmap->id);
free(mmap->priv); free(mmap->priv);
} }
int main(int argc, char **argv) int main(int argc, char **argv) {
{
vpx_codec_ctx_t decoder; vpx_codec_ctx_t decoder;
vpx_codec_iface_t *iface = ifaces[0].iface; vpx_codec_iface_t *iface = ifaces[0].iface;
vpx_codec_iter_t iter; vpx_codec_iter_t iter;
@ -92,12 +86,9 @@ int main(int argc, char **argv)
exec_name = argv[0]; exec_name = argv[0];
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++) {
{ if (!strcmp(argv[i], "--codec")) {
if (!strcmp(argv[i], "--codec")) if (i + 1 < argc) {
{
if (i + 1 < argc)
{
int j, k = -1; int j, k = -1;
i++; i++;
@ -111,25 +102,19 @@ int main(int argc, char **argv)
else else
usage_error("Error: Unrecognized argument (%s) to --codec\n", usage_error("Error: Unrecognized argument (%s) to --codec\n",
argv[i]); argv[i]);
} } else
else
usage_error("Error: Option --codec requires argument.\n"); usage_error("Error: Option --codec requires argument.\n");
} } else if (!strcmp(argv[i], "-v"))
else if (!strcmp(argv[i], "-v"))
verbose = 1; verbose = 1;
else if (!strcmp(argv[i], "-h")) else if (!strcmp(argv[i], "-h"))
if (i + 1 < argc) if (i + 1 < argc) {
{
h = atoi(argv[++i]); h = atoi(argv[++i]);
} } else
else
usage_error("Error: Option -h requires argument.\n"); usage_error("Error: Option -h requires argument.\n");
else if (!strcmp(argv[i], "-w")) else if (!strcmp(argv[i], "-w"))
if (i + 1 < argc) if (i + 1 < argc) {
{
w = atoi(argv[++i]); w = atoi(argv[++i]);
} } else
else
usage_error("Error: Option -w requires argument.\n"); usage_error("Error: Option -w requires argument.\n");
else if (!strcmp(argv[i], "--help")) else if (!strcmp(argv[i], "--help"))
usage_exit(); usage_exit();
@ -141,8 +126,7 @@ int main(int argc, char **argv)
printf("Using built-in defaults. For options, rerun with --help\n\n"); printf("Using built-in defaults. For options, rerun with --help\n\n");
/* XMA mode is not supported on all decoders! */ /* XMA mode is not supported on all decoders! */
if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA)) if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA)) {
{
printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface)); printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -157,8 +141,7 @@ int main(int argc, char **argv)
cfg.h = h; cfg.h = h;
/* Initialize the decoder in XMA mode. */ /* Initialize the decoder in XMA mode. */
if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA)) 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)); printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -168,16 +151,14 @@ int main(int argc, char **argv)
*/ */
iter = NULL; iter = NULL;
do do {
{
vpx_codec_mmap_t mmap; vpx_codec_mmap_t mmap;
unsigned int align; unsigned int align;
res = vpx_codec_get_mem_map(&decoder, &mmap, &iter); res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
align = mmap.align ? mmap.align - 1 : 0; align = mmap.align ? mmap.align - 1 : 0;
if (!res) if (!res) {
{
if (verbose) if (verbose)
printf("Allocating segment %u, size %lu, align %u %s\n", printf("Allocating segment %u, size %lu, align %u %s\n",
mmap.id, mmap.sz, mmap.align, mmap.id, mmap.sz, mmap.align,
@ -192,19 +173,15 @@ int main(int argc, char **argv)
mmap.dtor = my_mem_dtor; mmap.dtor = my_mem_dtor;
alloc_sz += mmap.sz + align; alloc_sz += mmap.sz + align;
if (vpx_codec_set_mem_map(&decoder, &mmap, 1)) if (vpx_codec_set_mem_map(&decoder, &mmap, 1)) {
{
printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder)); printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} } else if (res != VPX_CODEC_LIST_END) {
else if (res != VPX_CODEC_LIST_END)
{
printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder)); printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} } while (res != VPX_CODEC_LIST_END);
while (res != VPX_CODEC_LIST_END);
printf("%s\n %d bytes external memory required for %dx%d.\n", printf("%s\n %d bytes external memory required for %dx%d.\n",
decoder.name, alloc_sz, cfg.w, cfg.h); decoder.name, alloc_sz, cfg.w, cfg.h);

View File

@ -38,7 +38,7 @@ vpxenc.SRCS += libmkv/EbmlWriter.c
vpxenc.SRCS += libmkv/EbmlWriter.h vpxenc.SRCS += libmkv/EbmlWriter.h
vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1 vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
vpxenc.DESCRIPTION = Full featured encoder 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.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder
@ -56,37 +56,37 @@ endif
#example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022 #example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022
#example_xma.DESCRIPTION = External Memory Allocation mode usage #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.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
simple_decoder.DESCRIPTION = Simplified decoder loop 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.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
postproc.DESCRIPTION = Decoder postprocessor control 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.SRCS += md5_utils.h md5_utils.c
decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42 decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum 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.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
simple_encoder.DESCRIPTION = Simplified encoder loop 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.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
twopass_encoder.DESCRIPTION = Two-pass encoder loop 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.GUID = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
force_keyframe.DESCRIPTION = Force generation of keyframes force_keyframe.DESCRIPTION = Force generation of keyframes
ifeq ($(CONFIG_DECODERS),yes) ifeq ($(CONFIG_DECODERS),yes)
GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += decode_with_drops.c
endif endif
decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26 decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
decode_with_drops.DESCRIPTION = Drops frames while decoding 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 GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c
endif endif
decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E
decode_with_partial_drops.DESCRIPTION = Drops parts of frames while decoding 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.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C
error_resilient.DESCRIPTION = Error Resiliency Feature 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 # when building for bare-metal targets
ifeq ($(CONFIG_OS_SUPPORT), yes) ifeq ($(CONFIG_OS_SUPPORT), yes)
CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
else else
ifeq ($(CONFIG_GCC), yes) ifeq ($(CONFIG_GCC), yes)
CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
endif endif
endif endif
# #
@ -136,6 +138,8 @@ else
LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.) LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8 INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8
INC_PATH-$(CONFIG_VP8_ENCODER) += $(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) LIB_PATH := $(call enabled,LIB_PATH)
INC_PATH := $(call enabled,INC_PATH) INC_PATH := $(call enabled,INC_PATH)
endif endif
@ -179,7 +183,8 @@ BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_S
# Instantiate linker template for all examples. # Instantiate linker template for all examples.
CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) 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),\ $(foreach bin,$(BINS-yes),\
$(if $(BUILD_OBJS),$(eval $(bin):\ $(if $(BUILD_OBJS),$(eval $(bin):\
$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\ $(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\
@ -209,7 +214,7 @@ INSTALL_MAPS += % %
# Set up additional MSVS environment # Set up additional MSVS environment
ifeq ($(CONFIG_MSVS),yes) 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 # This variable uses deferred expansion intentionally, since the results of
# $(wildcard) may change during the course of the Make. # $(wildcard) may change during the course of the Make.
VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))

View File

@ -12,6 +12,7 @@
/* /*
@*INTRODUCTION @*INTRODUCTION
*/ */
#include "vpx_config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -1,7 +1,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
#define VPX_CODEC_DISABLE_COMPAT 1 #define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "vpx/vp8dx.h" #include "vpx/vp9dx.h"
#define interface (vpx_codec_vp8_dx()) #define interface (vpx_codec_vp8_dx())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES

View File

@ -1,7 +1,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES
#define VPX_CODEC_DISABLE_COMPAT 1 #define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "vpx/vp8cx.h" #include "vpx/vp9cx.h"
#define interface (vpx_codec_vp8_cx()) #define interface (vpx_codec_vp8_cx())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES

View File

@ -51,7 +51,7 @@ Some codecs provide fine grained controls over their built-in
postprocessors. VP8 is one example. The following sample code toggles postprocessors. VP8 is one example. The following sample code toggles
postprocessing on and off every 15 frames. postprocessing on and off every 15 frames.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE
#if CONFIG_VP8_DECODER #if CONFIG_VP9_DECODER
if(frame_cnt%30 == 1) { if(frame_cnt%30 == 1) {
vp8_postproc_cfg_t pp = {0, 0, 0}; vp8_postproc_cfg_t pp = {0, 0, 0};

View File

@ -8,18 +8,15 @@
#include <wchar.h> #include <wchar.h>
#include <string.h> #include <string.h>
void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) void Ebml_Write(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
{
unsigned char *src = glob->buf; unsigned char *src = glob->buf;
src += glob->offset; src += glob->offset;
memcpy(src, buffer_in, len); memcpy(src, buffer_in, len);
glob->offset += len; glob->offset += len;
} }
static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q) static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned char *q) {
{ while (q != p) {
while (q != p)
{
--q; --q;
unsigned long cbWritten; unsigned long cbWritten;
@ -28,8 +25,7 @@ static void _Serialize(EbmlGlobal *glob, const unsigned char *p, const unsigned
} }
} }
void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len) void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len) {
{
// assert(buf); // assert(buf);
const unsigned char *const p = (const unsigned char *)(buffer_in); const unsigned char *const p = (const unsigned char *)(buffer_in);
@ -39,8 +35,7 @@ void Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, unsigned long len)
} }
void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id) void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long class_id) {
{
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
ebmlLoc->offset = glob->offset; ebmlLoc->offset = glob->offset;
// todo this is always taking 8 bytes, this may need later optimization // todo this is always taking 8 bytes, this may need later optimization
@ -48,8 +43,7 @@ void Ebml_StartSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc, unsigned long clas
Ebml_Serialize(glob, (void *)&unknownLen, 8); // this is a key that says lenght unknown Ebml_Serialize(glob, (void *)&unknownLen, 8); // this is a key that says lenght unknown
} }
void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) void Ebml_EndSubElement(EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
{
unsigned long long size = glob->offset - ebmlLoc->offset - 8; unsigned long long size = glob->offset - ebmlLoc->offset - 8;
unsigned long long curOffset = glob->offset; unsigned long long curOffset = glob->offset;
glob->offset = ebmlLoc->offset; glob->offset = ebmlLoc->offset;

View File

@ -1,13 +1,11 @@
#ifndef EBMLBUFFERWRITER_HPP #ifndef EBMLBUFFERWRITER_HPP
#define EBMLBUFFERWRITER_HPP #define EBMLBUFFERWRITER_HPP
typedef struct typedef struct {
{
unsigned long long offset; unsigned long long offset;
} EbmlLoc; } EbmlLoc;
typedef struct typedef struct {
{
unsigned char *buf; unsigned char *buf;
unsigned int length; unsigned int length;
unsigned int offset; unsigned int offset;

View File

@ -12,8 +12,7 @@
/* Commenting out values not available in webm, but available in matroska */ /* Commenting out values not available in webm, but available in matroska */
enum mkv enum mkv {
{
EBML = 0x1A45DFA3, EBML = 0x1A45DFA3,
EBMLVersion = 0x4286, EBMLVersion = 0x4286,
EBMLReadVersion = 0x42F7, EBMLReadVersion = 0x42F7,

View File

@ -18,16 +18,14 @@
#define LITERALU64(n) n##LLU #define LITERALU64(n) n##LLU
#endif #endif
void Ebml_WriteLen(EbmlGlobal *glob, int64_t val) void Ebml_WriteLen(EbmlGlobal *glob, int64_t val) {
{
/* TODO check and make sure we are not > than 0x0100000000000000LLU */ /* TODO check and make sure we are not > than 0x0100000000000000LLU */
unsigned char size = 8; /* size in bytes to output */ unsigned char size = 8; /* size in bytes to output */
/* mask to compare for byte size */ /* mask to compare for byte size */
int64_t minVal = 0xff; int64_t minVal = 0xff;
for (size = 1; size < 8; size ++) for (size = 1; size < 8; size ++) {
{
if (val < minVal) if (val < minVal)
break; break;
@ -39,8 +37,7 @@ void Ebml_WriteLen(EbmlGlobal *glob, int64_t val)
Ebml_Serialize(glob, (void *) &val, sizeof(val), size); Ebml_Serialize(glob, (void *) &val, sizeof(val), size);
} }
void Ebml_WriteString(EbmlGlobal *glob, const char *str) void Ebml_WriteString(EbmlGlobal *glob, const char *str) {
{
const size_t size_ = strlen(str); const size_t size_ = strlen(str);
const uint64_t size = size_; const uint64_t size = size_;
Ebml_WriteLen(glob, size); Ebml_WriteLen(glob, size);
@ -50,8 +47,7 @@ void Ebml_WriteString(EbmlGlobal *glob, const char *str)
Ebml_Write(glob, str, (unsigned long)size); Ebml_Write(glob, str, (unsigned long)size);
} }
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) {
{
const size_t strlen = wcslen(wstr); const size_t strlen = wcslen(wstr);
/* TODO: it's not clear from the spec whether the nul terminator /* TODO: it's not clear from the spec whether the nul terminator
@ -63,8 +59,7 @@ void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr)
Ebml_Write(glob, wstr, (unsigned long)size); Ebml_Write(glob, wstr, (unsigned long)size);
} }
void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id) void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id) {
{
int len; int len;
if (class_id >= 0x01000000) if (class_id >= 0x01000000)
@ -79,16 +74,14 @@ void Ebml_WriteID(EbmlGlobal *glob, unsigned long class_id)
Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len); Ebml_Serialize(glob, (void *)&class_id, sizeof(class_id), len);
} }
void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) void Ebml_SerializeUnsigned64(EbmlGlobal *glob, unsigned long class_id, uint64_t ui) {
{
unsigned char sizeSerialized = 8 | 0x80; unsigned char sizeSerialized = 8 | 0x80;
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1); Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
Ebml_Serialize(glob, &ui, sizeof(ui), 8); Ebml_Serialize(glob, &ui, sizeof(ui), 8);
} }
void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui) void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned long ui) {
{
unsigned char size = 8; /* size in bytes to output */ unsigned char size = 8; /* size in bytes to output */
unsigned char sizeSerialized = 0; unsigned char sizeSerialized = 0;
unsigned long minVal; unsigned long minVal;
@ -96,10 +89,8 @@ void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned l
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
minVal = 0x7fLU; /* mask to compare for byte size */ minVal = 0x7fLU; /* mask to compare for byte size */
for (size = 1; size < 4; size ++) for (size = 1; size < 4; size ++) {
{ if (ui < minVal) {
if (ui < minVal)
{
break; break;
} }
@ -111,11 +102,9 @@ void Ebml_SerializeUnsigned(EbmlGlobal *glob, unsigned long class_id, unsigned l
Ebml_Serialize(glob, &ui, sizeof(ui), size); Ebml_Serialize(glob, &ui, sizeof(ui), size);
} }
/* TODO: perhaps this is a poor name for this id serializer helper function */ /* 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) void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin) {
{
int size; int size;
for (size=4; size > 1; size--) for (size = 4; size > 1; size--) {
{
if (bin & 0x000000ff << ((size - 1) * 8)) if (bin & 0x000000ff << ((size - 1) * 8))
break; break;
} }
@ -124,8 +113,7 @@ void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned lon
Ebml_WriteID(glob, bin); Ebml_WriteID(glob, bin);
} }
void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d) void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d) {
{
unsigned char len = 0x88; unsigned char len = 0x88;
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
@ -133,41 +121,35 @@ void Ebml_SerializeFloat(EbmlGlobal *glob, unsigned long class_id, double d)
Ebml_Serialize(glob, &d, sizeof(d), 8); Ebml_Serialize(glob, &d, sizeof(d), 8);
} }
void Ebml_WriteSigned16(EbmlGlobal *glob, short val) void Ebml_WriteSigned16(EbmlGlobal *glob, short val) {
{
signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8; signed long out = ((val & 0x003FFFFF) | 0x00200000) << 8;
Ebml_Serialize(glob, &out, sizeof(out), 3); Ebml_Serialize(glob, &out, sizeof(out), 3);
} }
void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s) void Ebml_SerializeString(EbmlGlobal *glob, unsigned long class_id, const char *s) {
{
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
Ebml_WriteString(glob, s); Ebml_WriteString(glob, s);
} }
void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s) void Ebml_SerializeUTF8(EbmlGlobal *glob, unsigned long class_id, wchar_t *s) {
{
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
Ebml_WriteUTF8(glob, s); Ebml_WriteUTF8(glob, s);
} }
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length) void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length) {
{
Ebml_WriteID(glob, class_id); Ebml_WriteID(glob, class_id);
Ebml_WriteLen(glob, data_length); Ebml_WriteLen(glob, data_length);
Ebml_Write(glob, data, data_length); Ebml_Write(glob, data, data_length);
} }
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) {
{
unsigned char tmp = 0; unsigned char tmp = 0;
unsigned long i = 0; unsigned long i = 0;
Ebml_WriteID(glob, 0xEC); Ebml_WriteID(glob, 0xEC);
Ebml_WriteLen(glob, vSize); Ebml_WriteLen(glob, vSize);
for (i = 0; i < vSize; i++) for (i = 0; i < vSize; i++) {
{
Ebml_Write(glob, &tmp, 1); Ebml_Write(glob, &tmp, 1);
} }
} }

View File

@ -14,8 +14,7 @@
#define kVorbisPrivateMaxSize 4000 #define kVorbisPrivateMaxSize 4000
void writeHeader(EbmlGlobal *glob) void writeHeader(EbmlGlobal *glob) {
{
EbmlLoc start; EbmlLoc start;
Ebml_StartSubElement(glob, &start, EBML); Ebml_StartSubElement(glob, &start, EBML);
Ebml_SerializeUnsigned(glob, EBMLVersion, 1); Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
@ -30,8 +29,7 @@ void writeHeader(EbmlGlobal *glob)
void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCode, void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCode,
int isKeyframe, unsigned char lacingFlag, int discardable, int isKeyframe, unsigned char lacingFlag, int discardable,
unsigned char *data, unsigned long dataLength) unsigned char *data, unsigned long dataLength) {
{
Ebml_WriteID(glob, SimpleBlock); Ebml_WriteID(glob, SimpleBlock);
unsigned long blockLength = 4 + dataLength; unsigned long blockLength = 4 + dataLength;
blockLength |= 0x10000000; // TODO check length < 0x0FFFFFFFF blockLength |= 0x10000000; // TODO check length < 0x0FFFFFFFF
@ -45,8 +43,7 @@ void writeSimpleBlock(EbmlGlobal *glob, unsigned char trackNumber, short timeCod
Ebml_Write(glob, data, dataLength); Ebml_Write(glob, data, dataLength);
} }
static UInt64 generateTrackID(unsigned int trackNumber) static UInt64 generateTrackID(unsigned int trackNumber) {
{
UInt64 t = time(NULL) * trackNumber; UInt64 t = time(NULL) * trackNumber;
UInt64 r = rand(); UInt64 r = rand();
r = r << 32; r = r << 32;
@ -57,8 +54,7 @@ static UInt64 generateTrackID(unsigned int trackNumber)
void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing, void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
char *codecId, unsigned int pixelWidth, unsigned int pixelHeight, char *codecId, unsigned int pixelWidth, unsigned int pixelHeight,
double frameRate) double frameRate) {
{
EbmlLoc start; EbmlLoc start;
Ebml_StartSubElement(glob, &start, TrackEntry); Ebml_StartSubElement(glob, &start, TrackEntry);
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber); Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
@ -80,8 +76,7 @@ void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
} }
void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing, void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
char *codecId, double samplingFrequency, unsigned int channels, char *codecId, double samplingFrequency, unsigned int channels,
unsigned char *private, unsigned long privateSize) unsigned char *private, unsigned long privateSize) {
{
EbmlLoc start; EbmlLoc start;
Ebml_StartSubElement(glob, &start, TrackEntry); Ebml_StartSubElement(glob, &start, TrackEntry);
Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber); Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
@ -106,8 +101,7 @@ void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing,
} }
Ebml_EndSubElement(glob, &start); Ebml_EndSubElement(glob, &start);
} }
void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc* startInfo, unsigned long timeCodeScale, double duration) void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration) {
{
Ebml_StartSubElement(ebml, startInfo, Info); Ebml_StartSubElement(ebml, startInfo, Info);
Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale); Ebml_SerializeUnsigned(ebml, TimecodeScale, timeCodeScale);
Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); // Currently fixed to using milliseconds Ebml_SerializeFloat(ebml, Segment_Duration, duration * 1000.0); // Currently fixed to using milliseconds

View File

@ -13,8 +13,7 @@
#include "WebMElement.h" #include "WebMElement.h"
#include <stdio.h> #include <stdio.h>
int main(int argc, char *argv[]) int main(int argc, char *argv[]) {
{
// init the datatype we're using for ebml output // init the datatype we're using for ebml output
unsigned char data[8192]; unsigned char data[8192];
EbmlGlobal ebml; EbmlGlobal ebml;

199
libs.mk
View File

@ -17,6 +17,47 @@ else
ASM:=.asm ASM:=.asm
endif 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 += CHANGELOG
CODEC_SRCS-yes += libs.mk 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 include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS)) 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) ifeq ($(CONFIG_VP8_ENCODER),yes)
VP8_PREFIX=vp8/
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS)) CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS)) CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
@ -52,7 +96,6 @@ ifeq ($(CONFIG_VP8_ENCODER),yes)
endif endif
ifeq ($(CONFIG_VP8_DECODER),yes) ifeq ($(CONFIG_VP8_DECODER),yes)
VP8_PREFIX=vp8/
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS)) CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS)) CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
@ -61,6 +104,35 @@ ifeq ($(CONFIG_VP8_DECODER),yes)
CODEC_DOC_SECTIONS += vp8 vp8_decoder CODEC_DOC_SECTIONS += vp8 vp8_decoder
endif 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) ifeq ($(CONFIG_ENCODERS),yes)
CODEC_DOC_SECTIONS += encoder CODEC_DOC_SECTIONS += encoder
@ -91,8 +163,11 @@ endif
CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.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 CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
INSTALL-SRCS-no += $(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-$(BUILD_LIBVPX) += vpx/exports_com
CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec 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 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
endif 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) += $(CODEC_SRCS)
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
@ -158,7 +233,7 @@ CLEAN-OBJS += vpx.def
vpx.vcproj: $(CODEC_SRCS) vpx.def vpx.vcproj: $(CODEC_SRCS) vpx.def
@echo " [CREATE] $@" @echo " [CREATE] $@"
$(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \ $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
--lib \ $(if $(CONFIG_SHARED),--dll,--lib) \
--target=$(TOOLCHAIN) \ --target=$(TOOLCHAIN) \
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
--name=vpx \ --name=vpx \
@ -171,7 +246,7 @@ vpx.vcproj: $(CODEC_SRCS) vpx.def
PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj
vpx.vcproj: vpx_config.asm vpx.vcproj: vpx_config.asm
vpx.vcproj: vpx_rtcd.h vpx.vcproj: $(RTCD)
endif endif
else 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 LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED)) 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) LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\ EXPORT_FILE := libvpx.ver
$(notdir $(LIBVPX_SO_SYMLINKS)) SYM_LINK := libvpx.so
$(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
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
libvpx.so libvpx.so.$(VERSION_MAJOR) \ libvpx.so libvpx.so.$(VERSION_MAJOR) \
libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR)) 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) libvpx.ver: $(call enabled,CODEC_EXPORTS)
@echo " [CREATE] $@" @echo " [CREATE] $@"
@ -199,10 +286,16 @@ libvpx.ver: $(call enabled,CODEC_EXPORTS)
$(qexec)echo "local: *; };" >> $@ $(qexec)echo "local: *; };" >> $@
CLEAN-OBJS += libvpx.ver CLEAN-OBJS += libvpx.ver
libvpx.syms: $(call enabled,CODEC_EXPORTS)
@echo " [CREATE] $@"
$(qexec)awk '{print "_"$$2}' $^ >$@
CLEAN-OBJS += libvpx.syms
define libvpx_symlink_template define libvpx_symlink_template
$(1): $(2) $(1): $(2)
@echo " [LN] $$@" @echo " [LN] $(2) $$@"
$(qexec)ln -sf $(LIBVPX_SO) $$@ $(qexec)mkdir -p $$(dir $$@)
$(qexec)ln -sf $(2) $$@
endef endef
$(eval $(call libvpx_symlink_template,\ $(eval $(call libvpx_symlink_template,\
@ -210,10 +303,12 @@ $(eval $(call libvpx_symlink_template,\
$(BUILD_PFX)$(LIBVPX_SO))) $(BUILD_PFX)$(LIBVPX_SO)))
$(eval $(call libvpx_symlink_template,\ $(eval $(call libvpx_symlink_template,\
$(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\ $(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 LIBS-$(BUILD_LIBVPX) += vpx.pc
vpx.pc: config.mk libs.mk 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 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
$(qexec)echo 'Requires:' >> $@ $(qexec)echo 'Requires:' >> $@
$(qexec)echo 'Conflicts:' >> $@ $(qexec)echo 'Conflicts:' >> $@
$(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@ $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
$(qexec)echo 'Libs.private: -lm -lpthread' >> $@ $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
$(qexec)echo 'Cflags: -I$${includedir}' >> $@ $(qexec)echo 'Cflags: -I$${includedir}' >> $@
INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
@ -265,71 +360,10 @@ endif
$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm $(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
$(filter %$(ASM).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) $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
CLEAN-OBJS += $(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 ## 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 \ --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
--ver=$(CONFIG_VS_VERSION) \ --ver=$(CONFIG_VS_VERSION) \
--src-path-bare="$(SRC_PATH_BARE)" \ --src-path-bare="$(SRC_PATH_BARE)" \
-D_VARIADIC_MAX=10 \
--out=gtest.vcproj $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \ --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" -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 \ --exe \
--target=$(TOOLCHAIN) \ --target=$(TOOLCHAIN) \
--name=test_libvpx \ --name=test_libvpx \
-D_VARIADIC_MAX=10 \
--proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
--ver=$(CONFIG_VS_VERSION) \ --ver=$(CONFIG_VS_VERSION) \
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
@ -450,5 +486,8 @@ libs.doxy: $(CODEC_DOC_SRCS)
@echo "INCLUDE_PATH += ." >> $@; @echo "INCLUDE_PATH += ." >> $@;
@echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
## Generate vpx_rtcd.h for all objects ## Generate rtcd.h for all objects
$(OBJS-yes:.o=.d): $(BUILD_PFX)vpx_rtcd.h $(OBJS-yes:.o=.d): $(RTCD)
## Update the global src list
SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)

View File

@ -25,8 +25,7 @@
#include "md5_utils.h" #include "md5_utils.h"
void void
byteSwap(UWORD32 *buf, unsigned words) byteSwap(UWORD32 *buf, unsigned words) {
{
md5byte *p; md5byte *p;
/* Only swap bytes for big endian machines */ /* Only swap bytes for big endian machines */
@ -37,13 +36,11 @@ byteSwap(UWORD32 *buf, unsigned words)
p = (md5byte *)buf; p = (md5byte *)buf;
do do {
{
*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 | *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
((unsigned)p[1] << 8 | p[0]); ((unsigned)p[1] << 8 | p[0]);
p += 4; p += 4;
} } while (--words);
while (--words);
} }
/* /*
@ -51,8 +48,7 @@ byteSwap(UWORD32 *buf, unsigned words)
* initialization constants. * initialization constants.
*/ */
void void
MD5Init(struct MD5Context *ctx) MD5Init(struct MD5Context *ctx) {
{
ctx->buf[0] = 0x67452301; ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89; ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe; ctx->buf[2] = 0x98badcfe;
@ -67,8 +63,7 @@ MD5Init(struct MD5Context *ctx)
* of bytes. * of bytes.
*/ */
void void
MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) {
{
UWORD32 t; UWORD32 t;
/* Update byte count */ /* Update byte count */
@ -80,8 +75,7 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
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) if (t > len) {
{
memcpy((md5byte *)ctx->in + 64 - t, buf, len); memcpy((md5byte *)ctx->in + 64 - t, buf, len);
return; return;
} }
@ -94,8 +88,7 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
len -= t; len -= t;
/* Process data in 64-byte chunks */ /* Process data in 64-byte chunks */
while (len >= 64) while (len >= 64) {
{
memcpy(ctx->in, buf, 64); memcpy(ctx->in, buf, 64);
byteSwap(ctx->in, 16); byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in); MD5Transform(ctx->buf, ctx->in);
@ -112,8 +105,7 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
* 1 0* (64-bit count of bits processed, MSB-first) * 1 0* (64-bit count of bits processed, MSB-first)
*/ */
void void
MD5Final(md5byte digest[16], struct MD5Context *ctx) MD5Final(md5byte digest[16], struct MD5Context *ctx) {
{
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
md5byte *p = (md5byte *)ctx->in + count; md5byte *p = (md5byte *)ctx->in + count;
@ -123,8 +115,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
/* Bytes of padding needed to make 56 bytes (-8..55) */ /* Bytes of padding needed to make 56 bytes (-8..55) */
count = 56 - 1 - count; count = 56 - 1 - count;
if (count < 0) /* Padding forces an extra block */ if (count < 0) { /* Padding forces an extra block */
{
memset(p, 0, count + 8); memset(p, 0, count + 8);
byteSwap(ctx->in, 16); byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in); MD5Transform(ctx->buf, ctx->in);
@ -165,8 +156,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
* the data and converts bytes into longwords for this routine. * the data and converts bytes into longwords for this routine.
*/ */
void void
MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) {
{
register UWORD32 a, b, c, d; register UWORD32 a, b, c, d;
a = buf[0]; a = buf[0];

View File

@ -27,8 +27,7 @@
#define UWORD32 unsigned int #define UWORD32 unsigned int
typedef struct MD5Context MD5Context; typedef struct MD5Context MD5Context;
struct MD5Context struct MD5Context {
{
UWORD32 buf[4]; UWORD32 buf[4];
UWORD32 bytes[2]; UWORD32 bytes[2];
UWORD32 in[16]; UWORD32 in[16];

View File

@ -67,6 +67,7 @@ extern "C" {
#define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */ #define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */
#define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis 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_SET 0 /**< Seek offset relative to beginning of stream. */
#define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */ #define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */

View File

@ -127,6 +127,7 @@ enum ebml_type_enum {
/* Track IDs */ /* Track IDs */
#define TRACK_ID_VP8 "V_VP8" #define TRACK_ID_VP8 "V_VP8"
#define TRACK_ID_VP9 "V_VP9"
#define TRACK_ID_VORBIS "A_VORBIS" #define TRACK_ID_VORBIS "A_VORBIS"
enum vint_mask { enum vint_mask {
@ -1669,6 +1670,9 @@ nestegg_track_codec_id(nestegg * ctx, unsigned int track)
if (strcmp(codec_id, TRACK_ID_VP8) == 0) if (strcmp(codec_id, TRACK_ID_VP8) == 0)
return NESTEGG_CODEC_VP8; return NESTEGG_CODEC_VP8;
if (strcmp(codec_id, TRACK_ID_VP9) == 0)
return NESTEGG_CODEC_VP9;
if (strcmp(codec_id, TRACK_ID_VORBIS) == 0) if (strcmp(codec_id, TRACK_ID_VORBIS) == 0)
return NESTEGG_CODEC_VORBIS; return NESTEGG_CODEC_VORBIS;

356
test/dct16x16_test.cc Normal file
View 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

View File

@ -8,72 +8,24 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <math.h> #include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include "third_party/googletest/src/include/gtest/gtest.h"
extern "C" { extern "C" {
#include "vpx_rtcd.h" #include "vp9_rtcd.h"
} }
#include "test/acm_random.h" #include "acm_random.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vpx/vpx_integer.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; using libvpx_test::ACMRandom;
TEST(Vp8FdctTest, SignBiasCheck) { namespace {
TEST(Vp9FdctTest, SignBiasCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed()); ACMRandom rnd(ACMRandom::DeterministicSeed());
int16_t test_input_block[16]; int16_t test_input_block[16];
int16_t test_output_block[16]; int16_t test_output_block[16];
@ -88,7 +40,9 @@ TEST(Vp8FdctTest, SignBiasCheck) {
for (int j = 0; j < 16; ++j) for (int j = 0; j < 16; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8(); 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) { for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0) if (test_output_block[j] < 0)
@ -98,13 +52,13 @@ TEST(Vp8FdctTest, SignBiasCheck) {
} }
} }
bool bias_acceptable = true; for (int j = 0; j < 16; ++j) {
for (int j = 0; j < 16; ++j) const bool bias_acceptable = (abs(count_sign_block[j][0] -
bias_acceptable = bias_acceptable && count_sign_block[j][1]) < 10000);
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 10000); EXPECT_TRUE(bias_acceptable)
<< "Error: 4x4 FDCT has a sign bias > 1%"
EXPECT_EQ(true, bias_acceptable) << " for input range [-255, 255] at index " << j;
<< "Error: 4x4 FDCT has a sign bias > 1% for input range [-255, 255]"; }
memset(count_sign_block, 0, sizeof(count_sign_block)); memset(count_sign_block, 0, sizeof(count_sign_block));
@ -113,7 +67,9 @@ TEST(Vp8FdctTest, SignBiasCheck) {
for (int j = 0; j < 16; ++j) for (int j = 0; j < 16; ++j)
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4); 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) { for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0) if (test_output_block[j] < 0)
@ -123,16 +79,16 @@ TEST(Vp8FdctTest, SignBiasCheck) {
} }
} }
bias_acceptable = true; for (int j = 0; j < 16; ++j) {
for (int j = 0; j < 16; ++j) const bool bias_acceptable = (abs(count_sign_block[j][0] -
bias_acceptable = bias_acceptable && count_sign_block[j][1]) < 100000);
(abs(count_sign_block[j][0] - count_sign_block[j][1]) < 100000); EXPECT_TRUE(bias_acceptable)
<< "Error: 4x4 FDCT has a sign bias > 10%"
EXPECT_EQ(true, bias_acceptable) << " for input range [-15, 15] at index " << j;
<< "Error: 4x4 FDCT has a sign bias > 10% for input range [-15, 15]"; }
}; };
TEST(Vp8FdctTest, RoundTripErrorCheck) { TEST(Vp9FdctTest, RoundTripErrorCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed()); ACMRandom rnd(ACMRandom::DeterministicSeed());
int max_error = 0; int max_error = 0;
double total_error = 0; double total_error = 0;
@ -146,9 +102,25 @@ TEST(Vp8FdctTest, RoundTripErrorCheck) {
for (int j = 0; j < 16; ++j) for (int j = 0; j < 16; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8(); 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; const int pitch = 8;
vp8_short_fdct4x4_c(test_input_block, test_temp_block, pitch); vp9_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) {
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) { for (int j = 0; j < 16; ++j) {
const int diff = test_input_block[j] - test_output_block[j]; const int diff = test_input_block[j] - test_output_block[j];
@ -158,7 +130,6 @@ TEST(Vp8FdctTest, RoundTripErrorCheck) {
total_error += error; total_error += error;
} }
} }
EXPECT_GE(1, max_error) EXPECT_GE(1, max_error)
<< "Error: FDCT/IDCT has an individual roundtrip error > 1"; << "Error: FDCT/IDCT has an individual roundtrip error > 1";

168
test/fdct8x8_test.cc Normal file
View 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
View 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

View File

@ -11,7 +11,7 @@
extern "C" { extern "C" {
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
} }
#include "test/register_state_check.h" #include "test/register_state_check.h"
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"

View File

@ -15,7 +15,7 @@
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
extern "C" { extern "C" {
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
} }

View File

@ -11,7 +11,7 @@
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
extern "C" { extern "C" {
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
} }

View File

@ -15,7 +15,7 @@
extern "C" { extern "C" {
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vpx_rtcd.h" #include "./vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
} }

View File

@ -17,7 +17,7 @@
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
extern "C" { extern "C" {
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vpx_rtcd.h" #include "./vp8_rtcd.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
} }

View File

@ -13,7 +13,7 @@
#include "test/register_state_check.h" #include "test/register_state_check.h"
extern "C" { extern "C" {
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#include "vp8/encoder/block.h" #include "vp8/encoder/block.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"

View File

@ -1,6 +1,7 @@
LIBVPX_TEST_SRCS-yes += acm_random.h
LIBVPX_TEST_SRCS-yes += register_state_check.h LIBVPX_TEST_SRCS-yes += register_state_check.h
LIBVPX_TEST_SRCS-yes += test.mk LIBVPX_TEST_SRCS-yes += test.mk
LIBVPX_TEST_SRCS-yes += acm_random.h
LIBVPX_TEST_SRCS-yes += test_libvpx.cc LIBVPX_TEST_SRCS-yes += test_libvpx.cc
LIBVPX_TEST_SRCS-yes += util.h LIBVPX_TEST_SRCS-yes += util.h
LIBVPX_TEST_SRCS-yes += video_source.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),) ifeq ($(CONFIG_SHARED),)
## VP8
ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
# These tests require both the encoder and decoder to be built. # These tests require both the encoder and decoder to be built.
ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes) ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes)
LIBVPX_TEST_SRCS-yes += boolcoder_test.cc LIBVPX_TEST_SRCS-yes += vp8_boolcoder_test.cc
endif endif
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += fdct4x4_test.cc
LIBVPX_TEST_SRCS-yes += idctllm_test.cc LIBVPX_TEST_SRCS-yes += idctllm_test.cc
LIBVPX_TEST_SRCS-yes += intrapred_test.cc LIBVPX_TEST_SRCS-yes += intrapred_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_POSTPROC) += pp_filter_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-$(CONFIG_VP8_ENCODER) += set_roi.cc
LIBVPX_TEST_SRCS-yes += sixtap_predict_test.cc LIBVPX_TEST_SRCS-yes += sixtap_predict_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += subtract_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 endif

View File

@ -9,11 +9,17 @@
*/ */
#include <string> #include <string>
#include "vpx_config.h" #include "vpx_config.h"
#if ARCH_X86 || ARCH_X86_64
extern "C" { extern "C" {
#if ARCH_X86 || ARCH_X86_64
#include "vpx_ports/x86.h" #include "vpx_ports/x86.h"
}
#endif #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" #include "third_party/googletest/src/include/gtest/gtest.h"
static void append_gtest_filter(const char *str) { static void append_gtest_filter(const char *str) {
@ -41,5 +47,15 @@ int main(int argc, char **argv) {
append_gtest_filter(":-SSE4_1/*"); append_gtest_filter(":-SSE4_1/*");
#endif #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(); return RUN_ALL_TESTS();
} }

123
test/variance_test.cc Normal file
View 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
View 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

View 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
View 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
View 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

File diff suppressed because it is too large Load Diff

72
tools/all_builds.py Executable file
View 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

File diff suppressed because it is too large Load Diff

127
tools/diff.py Normal file
View 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

View File

@ -29,12 +29,13 @@ log() {
vpx_style() { vpx_style() {
astyle --style=bsd --min-conditional-indent=0 --break-blocks \ for f; do
--pad-oper --pad-header --unpad-paren \ case "$f" in
--align-pointer=name \ *.h|*.c|*.cc)
--indent-preprocessor --convert-tabs --indent-labels \ "${dirname_self}"/vpx-astyle.sh "$f"
--suffix=none --quiet "$@" ;;
sed -i "" 's/[[:space:]]\{1,\},/,/g' "$@" esac
done
} }
@ -119,8 +120,7 @@ cd "$(git rev-parse --show-toplevel)"
git show > "${ORIG_DIFF}" git show > "${ORIG_DIFF}"
# Apply the style guide on new and modified files and collect its 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 \ for f in $(git diff HEAD^ --name-only -M90 --diff-filter=AM); do
| grep '\.[ch]$'); do
case "$f" in case "$f" in
third_party/*) continue;; third_party/*) continue;;
nestegg/*) continue;; nestegg/*) continue;;

View File

@ -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" __author__ = "jkoleszar@google.com"
import re
import sys import sys
import diff
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
def FormatDiffHunks(hunks): def FormatDiffHunks(hunks):
@ -162,8 +50,8 @@ def ZipHunks(rhs_hunks, lhs_hunks):
def main(): def main():
old_hunks = [x for x in ParseDiffHunks(open(sys.argv[1], "r"))] old_hunks = [x for x in diff.ParseDiffHunks(open(sys.argv[1], "r"))]
new_hunks = [x for x in ParseDiffHunks(open(sys.argv[2], "r"))] new_hunks = [x for x in diff.ParseDiffHunks(open(sys.argv[2], "r"))]
out_hunks = [] out_hunks = []
# Join the right hand side of the older diff with the left hand side of the # Join the right hand side of the older diff with the left hand side of the

144
tools/lint-hunks.py Executable file
View 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
View 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' \
"$@"

View File

@ -20,8 +20,7 @@
#endif #endif
#endif #endif
FILE* set_binary_mode(FILE *stream) FILE *set_binary_mode(FILE *stream) {
{
(void)stream; (void)stream;
#if defined(_WIN32) || defined(__OS2__) #if defined(_WIN32) || defined(__OS2__)
_setmode(_fileno(stream), _O_BINARY); _setmode(_fileno(stream), _O_BINARY);

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
void vp8_dequant_idct_add_y_block_v6(short *q, short *dq, void vp8_dequant_idct_add_y_block_v6(short *q, short *dq,

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include <math.h> #include <math.h>
#include "vp8/common/filter.h" #include "vp8/common/filter.h"
#include "bilinearfilter_arm.h" #include "bilinearfilter_arm.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include <math.h> #include <math.h>
#include "vp8/common/filter.h" #include "vp8/common/filter.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/loopfilter.h" #include "vp8/common/loopfilter.h"
#include "vp8/common/onyxc_int.h" #include "vp8/common/onyxc_int.h"

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
/* place these declarations here because we don't want to maintain them /* place these declarations here because we don't want to maintain them
* outside of this scope * outside of this scope

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/variance.h" #include "vp8/common/variance.h"
#include "vp8/common/filter.h" #include "vp8/common/filter.h"

View File

@ -12,7 +12,6 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx/vpx_codec.h" #include "vpx/vpx_codec.h"
#include "vpx_ports/asm_offsets.h" #include "vpx_ports/asm_offsets.h"
#include "vpx_scale/yv12config.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#if CONFIG_POSTPROC #if CONFIG_POSTPROC
@ -21,19 +20,6 @@
BEGIN 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 #if CONFIG_POSTPROC
/* mfqe.c / filter_by_weight */ /* mfqe.c / filter_by_weight */
DEFINE(MFQE_PRECISION_VAL, MFQE_PRECISION); 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); ct_assert(B_HU_PRED, B_HU_PRED == 9);
#endif #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 HAVE_SSE2
#if CONFIG_POSTPROC #if CONFIG_POSTPROC
/* vp8_filter_by_weight16x16 and 8x8 */ /* vp8_filter_by_weight16x16 and 8x8 */

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#if ARCH_ARM #if ARCH_ARM
#include "vpx_ports/arm.h" #include "vpx_ports/arm.h"
#elif ARCH_X86 || ARCH_X86_64 #elif ARCH_X86 || ARCH_X86_64

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
void vp8_dequant_idct_add_c(short *input, short *dq, void vp8_dequant_idct_add_c(short *input, short *dq,
unsigned char *dest, int stride); unsigned char *dest, int stride);

View File

@ -13,7 +13,7 @@
#define __INC_INVTRANS_H #define __INC_INVTRANS_H
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "blockd.h" #include "blockd.h"
#include "onyxc_int.h" #include "onyxc_int.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "loopfilter.h" #include "loopfilter.h"
#include "onyxc_int.h" #include "onyxc_int.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"

View File

@ -14,7 +14,7 @@
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#define MAX_LOOP_FILTER 63 #define MAX_LOOP_FILTER 63
/* fraction of total macroblock rows to be used in fast filter level picking */ /* fraction of total macroblock rows to be used in fast filter level picking */

View File

@ -20,7 +20,7 @@
#include "postproc.h" #include "postproc.h"
#include "variance.h" #include "variance.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_scale/yv12config.h" #include "vpx_scale/yv12config.h"
#include <limits.h> #include <limits.h>

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#if HAVE_DSPR2 #if HAVE_DSPR2

View File

@ -10,7 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
#if HAVE_DSPR2 #if HAVE_DSPR2

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#if HAVE_DSPR2 #if HAVE_DSPR2

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#if HAVE_DSPR2 #if HAVE_DSPR2
#define CROP_WIDTH 256 #define CROP_WIDTH 256

View File

@ -10,7 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/onyxc_int.h" #include "vp8/common/onyxc_int.h"
#if HAVE_DSPR2 #if HAVE_DSPR2

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#if HAVE_DSPR2 #if HAVE_DSPR2

View File

@ -13,7 +13,7 @@
#define __INC_VP8C_INT_H #define __INC_VP8C_INT_H
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx/internal/vpx_codec_internal.h" #include "vpx/internal/vpx_codec_internal.h"
#include "loopfilter.h" #include "loopfilter.h"
#include "entropymv.h" #include "entropymv.h"

View File

@ -10,7 +10,8 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_scale_rtcd.h"
#include "vpx_scale/yv12config.h" #include "vpx_scale/yv12config.h"
#include "postproc.h" #include "postproc.h"
#include "common.h" #include "common.h"

View File

@ -12,13 +12,8 @@
#include "subpixel.h" #include "subpixel.h"
#include "loopfilter.h" #include "loopfilter.h"
#include "recon.h" #include "recon.h"
#include "idct.h"
#include "onyxc_int.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)( extern void (*vp8_post_proc_down_and_across_mb_row)(
unsigned char *src_ptr, unsigned char *src_ptr,
unsigned char *dst_ptr, unsigned char *dst_ptr,

View File

@ -11,7 +11,7 @@
#include <limits.h> #include <limits.h>
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#include "blockd.h" #include "blockd.h"
#include "reconinter.h" #include "reconinter.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "blockd.h" #include "blockd.h"

View File

@ -10,17 +10,17 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "blockd.h" #include "blockd.h"
void vp8_intra4x4_predict_c(unsigned char *Above, void vp8_intra4x4_predict_c(unsigned char *Above,
unsigned char *yleft, int left_stride, unsigned char *yleft, int left_stride,
B_PREDICTION_MODE b_mode, int _b_mode,
unsigned char *dst, int dst_stride, unsigned char *dst, int dst_stride,
unsigned char top_left) unsigned char top_left)
{ {
int i, r, c; int i, r, c;
B_PREDICTION_MODE b_mode = (B_PREDICTION_MODE)_b_mode;
unsigned char Left[4]; unsigned char Left[4];
Left[0] = yleft[0]; Left[0] = yleft[0];
Left[1] = yleft[left_stride]; Left[1] = yleft[left_stride];

View File

@ -9,97 +9,13 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#define RTCD_C #define RTCD_C
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_ports/vpx_once.h"
#if CONFIG_MULTITHREAD && defined(_WIN32) extern void vpx_scale_rtcd(void);
#include <windows.h>
#include <stdlib.h> void vp8_rtcd()
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()
{ {
vpx_scale_rtcd();
once(setup_rtcd_internal); once(setup_rtcd_internal);
} }

View File

@ -1,6 +1,8 @@
common_forward_decls() { vp8_common_forward_decls() {
cat <<EOF cat <<EOF
#include "vp8/common/blockd.h" /*
* VP8
*/
struct blockd; struct blockd;
struct macroblockd; struct macroblockd;
@ -14,7 +16,7 @@ union int_mv;
struct yv12_buffer_config; struct yv12_buffer_config;
EOF EOF
} }
forward_decls common_forward_decls forward_decls vp8_common_forward_decls
# #
# Dequant # 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" 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 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 specialize vp8_intra4x4_predict media
vp8_intra4x4_predict_media=vp8_intra4x4_predict_armv6 vp8_intra4x4_predict_media=vp8_intra4x4_predict_armv6
@ -530,39 +532,3 @@ fi
# End of encoder only functions # End of encoder only functions
fi 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

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"
extern void vp8_dequantize_b_impl_mmx(short *sq, short *dq, short *q); extern void vp8_dequantize_b_impl_mmx(short *sq, short *dq, short *q);

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
void vp8_idct_dequant_0_2x_sse2 void vp8_idct_dequant_0_2x_sse2
(short *q, short *dq , (short *q, short *dq ,

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vp8/common/blockd.h" #include "vp8/common/blockd.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
#include "filter_x86.h" #include "filter_x86.h"

View File

@ -10,7 +10,8 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "./vpx_scale_rtcd.h"
#include "onyxd_int.h" #include "onyxd_int.h"
#include "vp8/common/header.h" #include "vp8/common/header.h"
#include "vp8/common/reconintra4x4.h" #include "vp8/common/reconintra4x4.h"

View File

@ -25,6 +25,7 @@
#include <assert.h> #include <assert.h>
#include "vp8/common/quant_common.h" #include "vp8/common/quant_common.h"
#include "./vpx_scale_rtcd.h"
#include "vpx_scale/vpxscale.h" #include "vpx_scale/vpxscale.h"
#include "vp8/common/systemdependent.h" #include "vp8/common/systemdependent.h"
#include "vpx_ports/vpx_timer.h" #include "vpx_ports/vpx_timer.h"

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#if !defined(WIN32) && CONFIG_OS_SUPPORT == 1 #if !defined(WIN32) && CONFIG_OS_SUPPORT == 1
# include <unistd.h> # include <unistd.h>
#endif #endif

View File

@ -15,7 +15,7 @@
EXPORT |vp8_encode_value| EXPORT |vp8_encode_value|
IMPORT |vp8_validate_buffer_arm| IMPORT |vp8_validate_buffer_arm|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -12,7 +12,7 @@
EXPORT |vp8cx_pack_tokens_armv5| EXPORT |vp8cx_pack_tokens_armv5|
IMPORT |vp8_validate_buffer_arm| IMPORT |vp8_validate_buffer_arm|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -12,7 +12,7 @@
EXPORT |vp8cx_pack_mb_row_tokens_armv5| EXPORT |vp8cx_pack_mb_row_tokens_armv5|
IMPORT |vp8_validate_buffer_arm| IMPORT |vp8_validate_buffer_arm|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -12,7 +12,7 @@
EXPORT |vp8cx_pack_tokens_into_partitions_armv5| EXPORT |vp8cx_pack_tokens_into_partitions_armv5|
IMPORT |vp8_validate_buffer_arm| IMPORT |vp8_validate_buffer_arm|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -11,7 +11,7 @@
EXPORT |vp8_fast_quantize_b_armv6| EXPORT |vp8_fast_quantize_b_armv6|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -13,7 +13,7 @@
EXPORT |vp8_subtract_mbuv_armv6| EXPORT |vp8_subtract_mbuv_armv6|
EXPORT |vp8_subtract_b_armv6| EXPORT |vp8_subtract_b_armv6|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -9,7 +9,7 @@
*/ */
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#if HAVE_MEDIA #if HAVE_MEDIA

View File

@ -12,7 +12,7 @@
EXPORT |vp8_fast_quantize_b_neon| EXPORT |vp8_fast_quantize_b_neon|
EXPORT |vp8_fast_quantize_b_pair_neon| EXPORT |vp8_fast_quantize_b_pair_neon|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -12,7 +12,7 @@
EXPORT |vp8_subtract_mby_neon| EXPORT |vp8_subtract_mby_neon|
EXPORT |vp8_subtract_mbuv_neon| EXPORT |vp8_subtract_mbuv_neon|
INCLUDE asm_enc_offsets.asm INCLUDE vp8_asm_enc_offsets.asm
ARM ARM
REQUIRE8 REQUIRE8

View File

@ -10,7 +10,7 @@
#include "vpx_config.h" #include "vpx_config.h"
#include "vpx_rtcd.h" #include "vp8_rtcd.h"
#include "vp8/encoder/block.h" #include "vp8/encoder/block.h"
#include <math.h> #include <math.h>
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"

Some files were not shown because too many files have changed in this diff Show More