Commit c8b38b0b authored by Yue Chen's avatar Yue Chen

AV1 offline probability optimizer

This tool is a gadget for offline probability training.

A binary executable aom_entropy_optimizer will be generated in
tools/. It parses a binary file consisting of counts written in
the format of FRAME_COUNTS in entropymode.h, and computes the
optimized probability table, which will be written to a new c file
optimized_probs.c using the format in entropymode.c.

Command line:
./aom_entropy_optimizer [directory of the count file]

The input file can be either be generated from a single run by
turning on entropy_stats experiment(counts are accumulated from
frame to frame, and finally written to counts.stt), or be collected
at a larger scale, at which a python script (will be provided soon)
can be used to aggregate multiple stats output.

Optimization for initial CDFs will be also supported later.

Change-Id: I32070721aa8059439feb6b5a3a179f1001c66bb7
parent 86a67384
...@@ -25,6 +25,7 @@ Advanced options: ...@@ -25,6 +25,7 @@ Advanced options:
${toggle_analyzer} analyzer ${toggle_analyzer} analyzer
${toggle_docs} documentation ${toggle_docs} documentation
${toggle_unit_tests} unit tests ${toggle_unit_tests} unit tests
${toggle_tools} tools
${toggle_decode_perf_tests} build decoder perf tests with unit tests ${toggle_decode_perf_tests} build decoder perf tests with unit tests
${toggle_encode_perf_tests} build encoder perf tests with unit tests ${toggle_encode_perf_tests} build encoder perf tests with unit tests
--cpu=CPU tune for the specified CPU (ARM: cortex-a8, X86: sse3) --cpu=CPU tune for the specified CPU (ARM: cortex-a8, X86: sse3)
...@@ -146,7 +147,7 @@ all_platforms="${all_platforms} generic-gnu" ...@@ -146,7 +147,7 @@ all_platforms="${all_platforms} generic-gnu"
# all_targets is a list of all targets that can be configured # all_targets is a list of all targets that can be configured
# note that these should be in dependency order for now. # note that these should be in dependency order for now.
all_targets="libs examples docs" all_targets="libs examples docs tools"
# all targets available are enabled, by default. # all targets available are enabled, by default.
for t in ${all_targets}; do for t in ${all_targets}; do
...@@ -399,6 +400,7 @@ CMDLINE_SELECT=" ...@@ -399,6 +400,7 @@ CMDLINE_SELECT="
examples examples
analyzer analyzer
docs docs
tools
libc libc
as as
size_limit size_limit
...@@ -636,7 +638,7 @@ EOF ...@@ -636,7 +638,7 @@ EOF
# #
# Write makefiles for all enabled targets # Write makefiles for all enabled targets
# #
for tgt in libs examples docs solution; do for tgt in libs examples docs tools solution; do
tgt_fn="$tgt-$toolchain.mk" tgt_fn="$tgt-$toolchain.mk"
if enabled $tgt; then if enabled $tgt; then
......
##
## Copyright (c) 2017, Alliance for Open Media. All rights reserved
##
## This source code is subject to the terms of the BSD 2 Clause License and
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
## was not distributed with this source code in the LICENSE file, you can
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
# List of tools to build.
ifeq ($(CONFIG_ENTROPY_STATS), yes)
TOOLS-$(CONFIG_AV1_ENCODER) += aom_entropy_optimizer.c
aom_entropy_optimizer.GUID = 3afa9b05-940b-4d68-b5aa-55157d8ed7b4
aom_entropy_optimizer.DESCRIPTION = Offline default probability optimizer
endif
#
# End of specified files. The rest of the build rules should happen
# automagically from here.
#
# Tools need different flags based on whether we're building
# from an installed tree or a version controlled tree. Determine
# the proper paths.
ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
LIB_PATH-yes := $(SRC_PATH_BARE)/../lib
INC_PATH-yes := $(SRC_PATH_BARE)/../include
else
LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
INC_PATH-$(CONFIG_AV1_DECODER) += $(SRC_PATH_BARE)/av1
INC_PATH-$(CONFIG_AV1_ENCODER) += $(SRC_PATH_BARE)/av1
endif
INC_PATH-$(CONFIG_LIBYUV) += $(SRC_PATH_BARE)/third_party/libyuv/include
LIB_PATH := $(call enabled,LIB_PATH)
INC_PATH := $(call enabled,INC_PATH)
INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
# Expand list of selected tools to build (as specified above)
TOOLS = $(addprefix tools/,$(call enabled,TOOLS))
ALL_SRCS = $(foreach ex,$(TOOLS),$($(notdir $(ex:.c=)).SRCS))
CFLAGS += -I../include
CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
ifneq ($(CONFIG_CODEC_SRCS), yes)
CFLAGS += -I../include/vpx
endif
# Expand all tools sources into a variable containing all sources
# for that tools (not just them main one specified in TOOLS)
# and add this file to the list (for MSVS workspace generation)
$(foreach ex,$(TOOLS),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) tools.mk))
# Create build/install dependencies for all tools. The common case
# is handled here. The MSVS case is handled below.
NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(TOOLS:.c=$(EXE_SFX)))
DIST-SRCS-yes += $(ALL_SRCS)
OBJS-$(NOT_MSVS) += $(call objs,$(ALL_SRCS))
BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(TOOLS:.c=$(EXE_SFX)))
# Instantiate linker template for all tools.
ifeq ($(CONFIG_OS_SUPPORT), yes)
CODEC_EXTRA_LIBS-$(CONFIG_AV1) += m
else
ifeq ($(CONFIG_GCC), yes)
CODEC_EXTRA_LIBS-$(CONFIG_AV1) += m
endif
endif
CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),aom_g,aom)
ifneq ($(filter darwin%,$(TGT_OS)),)
SHARED_LIB_SUF=.dylib
else
ifneq ($(filter os2%,$(TGT_OS)),)
SHARED_LIB_SUF=_dll.a
else
SHARED_LIB_SUF=.so
endif
endif
CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
$(foreach bin,$(BINS-yes),\
$(eval $(bin):$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF))\
$(eval $(call linker_template,$(bin),\
$(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
-l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
)))
# The following pairs define a mapping of locations in the distribution
# tree to locations in the source/build trees.
INSTALL_MAPS += src/%.c %.c
INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
INSTALL_MAPS += bin/% %
INSTALL_MAPS += % %
# Build Visual Studio Projects. We use a template here to instantiate
# explicit rules rather than using an implicit rule because we want to
# leverage make's VPATH searching rather than specifying the paths on
# each file in TOOLS. This has the unfortunate side effect that
# touching the source files trigger a rebuild of the project files
# even though there is no real dependency there (the dependency is on
# the makefiles). We may want to revisit this.
define vcproj_template
$(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
$(if $(quiet),@echo " [vcproj] $$@")
$(qexec)$$(GEN_VCPROJ)\
--exe\
--target=$$(TOOLCHAIN)\
--name=$$(@:.$(VCPROJ_SFX)=)\
--ver=$$(CONFIG_VS_VERSION)\
--proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
--src-path-bare="$(SRC_PATH_BARE)" \
$$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
--out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
$$(INTERNAL_LDFLAGS) $$(LDFLAGS) $$^
endef
TOOLS_BASENAME := $(notdir $(TOOLS))
PROJECTS-$(CONFIG_MSVS) += $(TOOLS_BASENAME:.c=.$(VCPROJ_SFX))
INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
$(addprefix bin/$(p)/,$(TOOLS_BASENAME:.c=.exe)))
$(foreach proj,$(call enabled,PROJECTS),\
$(eval $(call vcproj_template,$(proj))))
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment