diff options
82 files changed, 2152 insertions, 313 deletions
@@ -101,13 +101,6 @@ COMPILING THE APPLICATIONS/LIBRARIES: x86_64-win64-vs10 x86_64-win64-vs11 x86_64-win64-vs12 - universal-darwin8-gcc - universal-darwin9-gcc - universal-darwin10-gcc - universal-darwin11-gcc - universal-darwin12-gcc - universal-darwin13-gcc - universal-darwin14-gcc generic-gnu The generic-gnu target, in conjunction with the CROSS environment variable, diff --git a/build/make/Android.mk b/build/make/Android.mk index 20f670aeb..0add523f9 100644 --- a/build/make/Android.mk +++ b/build/make/Android.mk @@ -170,6 +170,7 @@ ifeq ($(CONFIG_VP9), yes) $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vp9_rtcd.h endif $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_scale_rtcd.h +$(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_dsp_rtcd.h ifeq ($(TARGET_ARCH_ABI),x86) $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_config.asm diff --git a/build/make/Makefile b/build/make/Makefile index fc7749a55..a16f41c2f 100644 --- a/build/make/Makefile +++ b/build/make/Makefile @@ -56,13 +56,10 @@ dist: fi endif +# Since we invoke make recursively for multiple targets we need to include the +# .mk file for the correct target, but only when $(target) is non-empty. ifneq ($(target),) -# Normally, we want to build the filename from the target and the toolchain. -# This disambiguates from the $(target).mk file that exists in the source tree. -# However, the toolchain is part of the target in universal builds, so we -# don't want to include TOOLCHAIN in that case. FAT_ARCHS is used to test -# if we're in the universal case. -include $(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk +include $(target)-$(TOOLCHAIN).mk endif BUILD_ROOT?=. VPATH=$(SRC_PATH_BARE) @@ -313,21 +310,6 @@ $(1): $$(filter %.o,$$^) $$(extralibs) endef - - -define lipo_lib_template -$(1): $(addsuffix /$(1),$(FAT_ARCHS)) - $(if $(quiet),@echo " [LIPO] $$@") - $(qexec)libtool -static -o $$@ $$? -endef - -define lipo_bin_template -$(1): $(addsuffix /$(1),$(FAT_ARCHS)) - $(if $(quiet),@echo " [LIPO] $$@") - $(qexec)lipo -output $$@ -create $$? -endef - - # # Get current configuration # diff --git a/build/make/configure.sh b/build/make/configure.sh index 68cc8bb4a..c5bed61be 100644 --- a/build/make/configure.sh +++ b/build/make/configure.sh @@ -390,7 +390,7 @@ write_common_config_banner() { write_common_config_targets() { for t in ${all_targets}; do if enabled ${t}; then - if enabled universal || enabled child; then + if enabled child; then fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}" else fwrite config.mk "ALL_TARGETS += ${t}" @@ -647,14 +647,6 @@ process_common_toolchain() { # detect tgt_os case "$gcctarget" in - *darwin8*) - tgt_isa=universal - tgt_os=darwin8 - ;; - *darwin9*) - tgt_isa=universal - tgt_os=darwin9 - ;; *darwin10*) tgt_isa=x86_64 tgt_os=darwin10 @@ -1215,7 +1207,7 @@ EOF ;; esac ;; - universal*|*-gcc|generic-gnu) + *-gcc|generic-gnu) link_with_cc=gcc enable_feature gcc setup_gnu_toolchain @@ -148,13 +148,6 @@ all_platforms="${all_platforms} x86_64-win64-vs9" all_platforms="${all_platforms} x86_64-win64-vs10" all_platforms="${all_platforms} x86_64-win64-vs11" all_platforms="${all_platforms} x86_64-win64-vs12" -all_platforms="${all_platforms} universal-darwin8-gcc" -all_platforms="${all_platforms} universal-darwin9-gcc" -all_platforms="${all_platforms} universal-darwin10-gcc" -all_platforms="${all_platforms} universal-darwin11-gcc" -all_platforms="${all_platforms} universal-darwin12-gcc" -all_platforms="${all_platforms} universal-darwin13-gcc" -all_platforms="${all_platforms} universal-darwin14-gcc" all_platforms="${all_platforms} generic-gnu" # all_targets is a list of all targets that can be configured @@ -436,22 +429,8 @@ post_process_cmdline() { process_targets() { enabled child || write_common_config_banner - enabled universal || write_common_target_config_h ${BUILD_PFX}vpx_config.h - - # For fat binaries, call configure recursively to configure for each - # binary architecture to be included. - if enabled universal; then - # Call configure (ourselves) for each subarchitecture - for arch in $fat_bin_archs; do - BUILD_PFX=${arch}/ toolchain=${arch} $self --child $cmdline_args || exit $? - done - fi - - # The write_common_config (config.mk) logic is deferred until after the - # recursive calls to configure complete, because we want our universal - # targets to be executed last. + write_common_target_config_h ${BUILD_PFX}vpx_config.h write_common_config_targets - enabled universal && echo "FAT_ARCHS=${fat_bin_archs}" >> config.mk # Calculate the default distribution name, based on the enabled features cf="" @@ -596,24 +575,6 @@ EOF process_toolchain() { process_common_toolchain - # Handle universal binaries for this architecture - case $toolchain in - universal-darwin*) - darwin_ver=${tgt_os##darwin} - - # Tiger (10.4/darwin8) brought support for x86 - if [ $darwin_ver -ge 8 ]; then - fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}" - fi - - # Leopard (10.5/darwin9) brought 64 bit support - if [ $darwin_ver -ge 9 ]; then - fat_bin_archs="$fat_bin_archs x86_64-${tgt_os}-${tgt_cc}" - fi - ;; - esac - - # Enable some useful compiler flags if enabled gcc; then enabled werror && check_add_cflags -Werror @@ -701,7 +662,7 @@ process_toolchain() { esac # Other toolchain specific defaults - case $toolchain in x86*|universal*) soft_enable postproc;; esac + case $toolchain in x86*) soft_enable postproc;; esac if enabled postproc_visualizer; then enabled postproc || die "postproc_visualizer requires postproc to be enabled" diff --git a/examples.mk b/examples.mk index 4ff1de4ee..b92507a6f 100644 --- a/examples.mk +++ b/examples.mk @@ -254,14 +254,6 @@ CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS)) $(foreach ex,$(ALL_EXAMPLES),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) examples.mk)) -# If this is a universal (fat) binary, then all the subarchitectures have -# already been built and our job is to stitch them together. The -# BUILD_OBJS variable indicates whether we should be building -# (compiling, linking) the library. The LIPO_OBJS variable indicates -# that we're stitching. -$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes) - - # Create build/install dependencies for all examples. The common case # is handled here. The MSVS case is handled below. NOT_MSVS = $(if $(CONFIG_MSVS),,yes) @@ -269,7 +261,7 @@ DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(ALL_EXAMPLES:.c=$(EXE_SFX))) INSTALL-BINS-$(NOT_MSVS) += $(addprefix bin/,$(UTILS:.c=$(EXE_SFX))) DIST-SRCS-yes += $(ALL_SRCS) INSTALL-SRCS-yes += $(UTIL_SRCS) -OBJS-$(NOT_MSVS) += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS))) +OBJS-$(NOT_MSVS) += $(call objs,$(ALL_SRCS)) BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_SFX))) @@ -278,15 +270,11 @@ CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) SHARED_LIB_SUF=$(if $(filter darwin%,$(TGT_OS)),.dylib,.so) CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a) $(foreach bin,$(BINS-yes),\ - $(if $(BUILD_OBJS),$(eval $(bin):\ - $(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\ - $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\ + $(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))\ - )))\ - $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\ - ) - + ))) # The following pairs define a mapping of locations in the distribution # tree to locations in the source/build trees. diff --git a/examples/decode_to_md5.c b/examples/decode_to_md5.c index a3843bed3..1ae7a4b57 100644 --- a/examples/decode_to_md5.c +++ b/examples/decode_to_md5.c @@ -71,7 +71,7 @@ static void print_md5(FILE *stream, unsigned char digest[16]) { static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name); exit(EXIT_FAILURE); } diff --git a/examples/decode_with_drops.c b/examples/decode_with_drops.c index 36f7d80e1..2233e473d 100644 --- a/examples/decode_with_drops.c +++ b/examples/decode_with_drops.c @@ -65,7 +65,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name); exit(EXIT_FAILURE); } diff --git a/examples/postproc.c b/examples/postproc.c index e34426a61..a8ac208d9 100644 --- a/examples/postproc.c +++ b/examples/postproc.c @@ -52,7 +52,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name); exit(EXIT_FAILURE); } diff --git a/examples/resize_util.c b/examples/resize_util.c index f8c35255f..e6fdd5bb2 100644 --- a/examples/resize_util.c +++ b/examples/resize_util.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include <string.h> +#include "../tools_common.h" #include "../vp9/encoder/vp9_resize.h" static const char *exec_name = NULL; @@ -26,7 +27,7 @@ static void usage() { printf("<output_yuv> [<frames>]\n"); } -void usage_exit() { +void usage_exit(void) { usage(); exit(EXIT_FAILURE); } diff --git a/examples/set_maps.c b/examples/set_maps.c index 5555baac2..1dc3ac0c9 100644 --- a/examples/set_maps.c +++ b/examples/set_maps.c @@ -55,7 +55,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <codec> <width> <height> <infile> <outfile>\n", exec_name); exit(EXIT_FAILURE); diff --git a/examples/simple_decoder.c b/examples/simple_decoder.c index 08a216685..8ccc81035 100644 --- a/examples/simple_decoder.c +++ b/examples/simple_decoder.c @@ -88,7 +88,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name); exit(EXIT_FAILURE); } diff --git a/examples/simple_encoder.c b/examples/simple_encoder.c index e805c2587..a30772973 100644 --- a/examples/simple_encoder.c +++ b/examples/simple_encoder.c @@ -106,7 +106,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <codec> <width> <height> <infile> <outfile> " "<keyframe-interval> [<error-resilient>]\nSee comments in " diff --git a/examples/twopass_encoder.c b/examples/twopass_encoder.c index 0ec83ddcc..aecc11d3f 100644 --- a/examples/twopass_encoder.c +++ b/examples/twopass_encoder.c @@ -58,7 +58,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <codec> <width> <height> <infile> <outfile>\n", exec_name); exit(EXIT_FAILURE); diff --git a/examples/vp8_multi_resolution_encoder.c b/examples/vp8_multi_resolution_encoder.c index e623567b8..2b032049c 100644 --- a/examples/vp8_multi_resolution_encoder.c +++ b/examples/vp8_multi_resolution_encoder.c @@ -37,15 +37,14 @@ #include <unistd.h> #endif #include "vpx_ports/vpx_timer.h" -#define VPX_CODEC_DISABLE_COMPAT 1 #include "vpx/vpx_encoder.h" #include "vpx/vp8cx.h" #include "vpx_ports/mem_ops.h" -#include "./tools_common.h" +#include "../tools_common.h" #define interface (vpx_codec_vp8_cx()) #define fourcc 0x30385056 -void usage_exit() { +void usage_exit(void) { exit(EXIT_FAILURE); } diff --git a/examples/vp8cx_set_ref.c b/examples/vp8cx_set_ref.c index a2982821a..8b4cc303d 100644 --- a/examples/vp8cx_set_ref.c +++ b/examples/vp8cx_set_ref.c @@ -58,7 +58,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <width> <height> <infile> <outfile> <frame>\n", exec_name); exit(EXIT_FAILURE); diff --git a/examples/vp9_lossless_encoder.c b/examples/vp9_lossless_encoder.c index 54275770d..827251683 100644 --- a/examples/vp9_lossless_encoder.c +++ b/examples/vp9_lossless_encoder.c @@ -20,7 +20,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "vp9_lossless_encoder: Example demonstrating VP9 lossless " "encoding feature. Supports raw input only.\n"); fprintf(stderr, "Usage: %s <width> <height> <infile> <outfile>\n", exec_name); diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index f4deb693b..a3fd65f2a 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -116,7 +116,7 @@ typedef struct { static const char *exec_name; -void usage_exit() { +void usage_exit(void) { fprintf(stderr, "Usage: %s <options> input_filename output_filename\n", exec_name); fprintf(stderr, "Options:\n"); diff --git a/examples/vpx_temporal_svc_encoder.c b/examples/vpx_temporal_svc_encoder.c index 349875997..964954e91 100644 --- a/examples/vpx_temporal_svc_encoder.c +++ b/examples/vpx_temporal_svc_encoder.c @@ -28,7 +28,7 @@ static const char *exec_name; -void usage_exit() { +void usage_exit(void) { exit(EXIT_FAILURE); } @@ -25,7 +25,7 @@ $$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2) @echo " [CREATE] $$@" $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \ --sym=$(1) \ - --config=$$(CONFIG_DIR)$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \ + --config=$$(CONFIG_DIR)$$(target)-$$(TOOLCHAIN).mk \ $$(RTCD_OPTIONS) $$^ > $$@ CLEAN-OBJS += $$(BUILD_PFX)$(1).h RTCD += $$(BUILD_PFX)$(1).h @@ -34,13 +34,6 @@ endef CODEC_SRCS-yes += CHANGELOG CODEC_SRCS-yes += libs.mk -# If this is a universal (fat) binary, then all the subarchitectures have -# already been built and our job is to stitch them together. The -# BUILD_LIBVPX variable indicates whether we should be building -# (compiling, linking) the library. The LIPO_LIBVPX variable indicates -# that we're stitching. -$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes) - include $(SRC_PATH_BARE)/vpx/vpx_codec.mk CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS)) CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS)) @@ -140,18 +133,18 @@ INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%) INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%) endif -CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh -CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.pl -CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h -CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops.h -CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops_aligned.h -CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h -CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c +CODEC_SRCS-yes += build/make/version.sh +CODEC_SRCS-yes += build/make/rtcd.pl +CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h +CODEC_SRCS-yes += vpx_ports/mem_ops.h +CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h +CODEC_SRCS-yes += vpx_ports/vpx_once.h +CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm endif -CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com +CODEC_EXPORTS-yes += vpx/exports_com CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec @@ -218,7 +211,7 @@ vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \ --src-path-bare="$(SRC_PATH_BARE)" \ -PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX) +PROJECTS-yes += vpx.$(VCPROJ_SFX) vpx.$(VCPROJ_SFX): vpx_config.asm vpx.$(VCPROJ_SFX): $(RTCD) @@ -226,13 +219,10 @@ vpx.$(VCPROJ_SFX): $(RTCD) endif else LIBVPX_OBJS=$(call objs,$(CODEC_SRCS)) -OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS) -LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a +OBJS-yes += $(LIBVPX_OBJS) +LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) - -BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED)) - SO_VERSION_MAJOR := 2 SO_VERSION_MINOR := 0 SO_VERSION_PATCH := 0 @@ -249,7 +239,7 @@ LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR)) endif -LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\ +LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\ $(notdir $(LIBVPX_SO_SYMLINKS)) $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE) $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm @@ -283,11 +273,11 @@ $(eval $(call libvpx_symlink_template,\ $(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-yes += vpx.pc vpx.pc: config.mk libs.mk @echo " [CREATE] $@" $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@ @@ -313,9 +303,6 @@ INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc CLEAN-OBJS += vpx.pc endif -LIBS-$(LIPO_LIBVPX) += libvpx.a -$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a))) - # # Rule to make assembler configuration file from C configuration file # @@ -354,7 +341,7 @@ LIBVPX_TEST_DATA_PATH ?= . include $(SRC_PATH_BARE)/test/test.mk LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS)) -LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX) +LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX) LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\ $(call enabled,LIBVPX_TEST_DATA)) libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1) @@ -422,7 +409,7 @@ test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_ PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX) -LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS))) +LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN))) endif else @@ -435,28 +422,24 @@ $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0 endif $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include -OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS) -LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a +OBJS-yes += $(GTEST_OBJS) +LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS) LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS))) $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include -OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS) -BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS) +OBJS-yes += $(LIBVPX_TEST_OBJS) +BINS-yes += $(LIBVPX_TEST_BIN) CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a) -$(foreach bin,$(LIBVPX_TEST_BINS),\ - $(if $(BUILD_LIBVPX),$(eval $(bin): \ - lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\ - $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\ - $(LIBVPX_TEST_OBJS) \ - -L. -lvpx -lgtest $(extralibs) -lm)\ - )))\ - $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\ +$(LIBVPX_TEST_BIN): lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a +$(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \ + $(LIBVPX_TEST_OBJS) \ + -L. -lvpx -lgtest $(extralibs) -lm)) -endif +endif # CONFIG_UNIT_TESTS # Install test sources only if codec source is included INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\ @@ -465,13 +448,11 @@ INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS) define test_shard_template test:: test_shard.$(1) -test_shard.$(1): $(LIBVPX_TEST_BINS) testdata +test_shard.$(1): $(LIBVPX_TEST_BIN) testdata @set -e; \ - for t in $(LIBVPX_TEST_BINS); do \ - export GTEST_SHARD_INDEX=$(1); \ - export GTEST_TOTAL_SHARDS=$(2); \ - $$$$t; \ - done + export GTEST_SHARD_INDEX=$(1); \ + export GTEST_TOTAL_SHARDS=$(2); \ + $(LIBVPX_TEST_BIN) .PHONY: test_shard.$(1) endef diff --git a/test/dct16x16_test.cc b/test/dct16x16_test.cc index 587b27ac8..48a8006af 100644 --- a/test/dct16x16_test.cc +++ b/test/dct16x16_test.cc @@ -22,6 +22,7 @@ #include "vp9/common/vp9_entropy.h" #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" +#include "vpx_ports/mem.h" using libvpx_test::ACMRandom; diff --git a/test/dct32x32_test.cc b/test/dct32x32_test.cc index cddfb8b6f..267dfb85d 100644 --- a/test/dct32x32_test.cc +++ b/test/dct32x32_test.cc @@ -23,6 +23,7 @@ #include "vp9/common/vp9_entropy.h" #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" +#include "vpx_ports/mem.h" using libvpx_test::ACMRandom; @@ -380,4 +381,12 @@ INSTANTIATE_TEST_CASE_P( make_tuple(&vp9_fdct32x32_rd_avx2, &vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8))); #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE + +#if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE +INSTANTIATE_TEST_CASE_P( + MSA, Trans32x32Test, + ::testing::Values( + make_tuple(&vp9_fdct32x32_c, + &vp9_idct32x32_1024_add_msa, 0, VPX_BITS_8))); +#endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE } // namespace diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc index 610dbd44c..064a5a6c9 100644 --- a/test/fdct4x4_test.cc +++ b/test/fdct4x4_test.cc @@ -22,6 +22,7 @@ #include "vp9/common/vp9_entropy.h" #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" +#include "vpx_ports/mem.h" using libvpx_test::ACMRandom; diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc index 795a60863..4679516f4 100644 --- a/test/fdct8x8_test.cc +++ b/test/fdct8x8_test.cc @@ -22,6 +22,7 @@ #include "vp9/common/vp9_entropy.h" #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" +#include "vpx_ports/mem.h" const int kNumCoeffs = 64; const double kPi = 3.141592653589793238462643383279502884; @@ -777,4 +778,18 @@ INSTANTIATE_TEST_CASE_P( make_tuple(&vp9_fdct8x8_ssse3, &vp9_idct8x8_64_add_ssse3, 0, VPX_BITS_8))); #endif + +#if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE +INSTANTIATE_TEST_CASE_P( + MSA, FwdTrans8x8DCT, + ::testing::Values( + make_tuple(&vp9_fdct8x8_c, &vp9_idct8x8_64_add_msa, 0, VPX_BITS_8))); +INSTANTIATE_TEST_CASE_P( + MSA, FwdTrans8x8HT, + ::testing::Values( + make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_msa, 0, VPX_BITS_8), + make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_msa, 1, VPX_BITS_8), + make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_msa, 2, VPX_BITS_8), + make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_msa, 3, VPX_BITS_8))); +#endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE } // namespace diff --git a/test/partial_idct_test.cc b/test/partial_idct_test.cc index 87856a1b5..e08a62bcd 100644 --- a/test/partial_idct_test.cc +++ b/test/partial_idct_test.cc @@ -309,18 +309,30 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( MSA, PartialIDctTest, ::testing::Values( + make_tuple(&vp9_fdct32x32_c, + &vp9_idct32x32_1024_add_c, + &vp9_idct32x32_34_add_msa, + TX_32X32, 34), + make_tuple(&vp9_fdct32x32_c, + &vp9_idct32x32_1024_add_c, + &vp9_idct32x32_1_add_msa, + TX_32X32, 1), make_tuple(&vp9_fdct16x16_c, &vp9_idct16x16_256_add_c, &vp9_idct16x16_10_add_msa, TX_16X16, 10), make_tuple(&vp9_fdct16x16_c, - &vp9_idct16x16_256_add_msa, - &vp9_idct16x16_10_add_c, - TX_16X16, 10), - make_tuple(&vp9_fdct16x16_c, &vp9_idct16x16_256_add_c, &vp9_idct16x16_1_add_msa, - TX_16X16, 1))); + TX_16X16, 1), + make_tuple(&vp9_fdct8x8_c, + &vp9_idct8x8_64_add_c, + &vp9_idct8x8_12_add_msa, + TX_8X8, 10), + make_tuple(&vp9_fdct8x8_c, + &vp9_idct8x8_64_add_c, + &vp9_idct8x8_1_add_msa, + TX_8X8, 1))); #endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE } // namespace diff --git a/test/sad_test.cc b/test/sad_test.cc index 6c28edb51..001d21dad 100644 --- a/test/sad_test.cc +++ b/test/sad_test.cc @@ -16,22 +16,7 @@ #include "./vpx_config.h" #include "./vpx_dsp_rtcd.h" #include "vpx_mem/vpx_mem.h" - -/* Needed for ROUND_POWER_OF_TWO and CONVERT_TO* macros, both of which should be - * moved to a more generic location. Alternatively the *avg functions could be - * restricted to VP9 builds, but it would be better to avoid that sort of - * specificity. - * TODO(johannkoenig): move these macros to a common location. - */ -#if CONFIG_VP9_HIGHBITDEPTH -#include "vp9/common/vp9_common.h" -#endif // CONFIG_VP9_HIGHBITDEPTH - -#ifndef ROUND_POWER_OF_TWO -#define ROUND_POWER_OF_TWO(value, n) \ - (((value) + (1 << ((n) - 1))) >> (n)) -#endif // ROUND_POWER_OF_TWO - +#include "vpx_ports/mem.h" #include "test/acm_random.h" #include "test/clear_system_state.h" diff --git a/test/variance_test.cc b/test/variance_test.cc index a8dd7de13..e4e27af7c 100644 --- a/test/variance_test.cc +++ b/test/variance_test.cc @@ -20,6 +20,7 @@ #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #if CONFIG_VP8_ENCODER # include "./vp8_rtcd.h" # include "vp8/common/variance.h" diff --git a/tools_common.c b/tools_common.c index e243a9157..901734e0f 100644 --- a/tools_common.c +++ b/tools_common.c @@ -140,7 +140,7 @@ static const VpxInterface vpx_encoders[] = { #endif }; -int get_vpx_encoder_count() { +int get_vpx_encoder_count(void) { return sizeof(vpx_encoders) / sizeof(vpx_encoders[0]); } @@ -170,7 +170,7 @@ static const VpxInterface vpx_decoders[] = { #endif }; -int get_vpx_decoder_count() { +int get_vpx_decoder_count(void) { return sizeof(vpx_decoders) / sizeof(vpx_decoders[0]); } diff --git a/tools_common.h b/tools_common.h index de6c38f0f..a87e814c1 100644 --- a/tools_common.h +++ b/tools_common.h @@ -119,7 +119,7 @@ void warn(const char *fmt, ...); void die_codec(vpx_codec_ctx_t *ctx, const char *s) VPX_NO_RETURN; /* The tool including this file must define usage_exit() */ -void usage_exit() VPX_NO_RETURN; +void usage_exit(void) VPX_NO_RETURN; #undef VPX_NO_RETURN @@ -131,11 +131,11 @@ typedef struct VpxInterface { vpx_codec_iface_t *(*const codec_interface)(); } VpxInterface; -int get_vpx_encoder_count(); +int get_vpx_encoder_count(void); const VpxInterface *get_vpx_encoder_by_index(int i); const VpxInterface *get_vpx_encoder_by_name(const char *name); -int get_vpx_decoder_count(); +int get_vpx_decoder_count(void); const VpxInterface *get_vpx_decoder_by_index(int i); const VpxInterface *get_vpx_decoder_by_name(const char *name); const VpxInterface *get_vpx_decoder_by_fourcc(uint32_t fourcc); diff --git a/vp9/common/arm/neon/vp9_idct16x16_1_add_neon.c b/vp9/common/arm/neon/vp9_idct16x16_1_add_neon.c index 3c8c6a934..0233877dd 100644 --- a/vp9/common/arm/neon/vp9_idct16x16_1_add_neon.c +++ b/vp9/common/arm/neon/vp9_idct16x16_1_add_neon.c @@ -9,6 +9,8 @@ */ #include <arm_neon.h> + +#include "vpx_ports/mem.h" #include "vp9/common/vp9_idct.h" void vp9_idct16x16_1_add_neon( diff --git a/vp9/common/arm/neon/vp9_idct32x32_1_add_neon.c b/vp9/common/arm/neon/vp9_idct32x32_1_add_neon.c index d0e4b4f40..0ce45f2bf 100644 --- a/vp9/common/arm/neon/vp9_idct32x32_1_add_neon.c +++ b/vp9/common/arm/neon/vp9_idct32x32_1_add_neon.c @@ -9,10 +9,12 @@ */ #include <arm_neon.h> -#include "vp9/common/vp9_idct.h" #include "./vpx_config.h" +#include "vpx_ports/mem.h" +#include "vp9/common/vp9_idct.h" + static INLINE void LD_16x8( uint8_t *d, int d_stride, diff --git a/vp9/common/arm/neon/vp9_idct4x4_1_add_neon.c b/vp9/common/arm/neon/vp9_idct4x4_1_add_neon.c index 7c8a930b6..f0457358e 100644 --- a/vp9/common/arm/neon/vp9_idct4x4_1_add_neon.c +++ b/vp9/common/arm/neon/vp9_idct4x4_1_add_neon.c @@ -9,6 +9,8 @@ */ #include <arm_neon.h> + +#include "vpx_ports/mem.h" #include "vp9/common/vp9_idct.h" void vp9_idct4x4_1_add_neon( diff --git a/vp9/common/arm/neon/vp9_idct8x8_1_add_neon.c b/vp9/common/arm/neon/vp9_idct8x8_1_add_neon.c index 24c29fb77..5369697c7 100644 --- a/vp9/common/arm/neon/vp9_idct8x8_1_add_neon.c +++ b/vp9/common/arm/neon/vp9_idct8x8_1_add_neon.c @@ -9,6 +9,8 @@ */ #include <arm_neon.h> + +#include "vpx_ports/mem.h" #include "vp9/common/vp9_idct.h" void vp9_idct8x8_1_add_neon( diff --git a/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c b/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c index 19c582fd1..202d91381 100644 --- a/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c +++ b/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" diff --git a/vp9/common/mips/dspr2/vp9_itrans32_cols_dspr2.c b/vp9/common/mips/dspr2/vp9_itrans32_cols_dspr2.c index 132d88ce5..7ceebb6d8 100644 --- a/vp9/common/mips/dspr2/vp9_itrans32_cols_dspr2.c +++ b/vp9/common/mips/dspr2/vp9_itrans32_cols_dspr2.c @@ -12,6 +12,7 @@ #include "./vpx_config.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" diff --git a/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c b/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c index 1990348b8..280190a39 100644 --- a/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c +++ b/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" diff --git a/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c b/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c index fc44ffa31..04d226663 100644 --- a/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c +++ b/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" diff --git a/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h b/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h index 008cf8cac..675db654a 100644 --- a/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h +++ b/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h @@ -14,6 +14,7 @@ #include <stdlib.h> #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_onyxc_int.h" diff --git a/vp9/common/mips/msa/vp9_idct32x32_msa.c b/vp9/common/mips/msa/vp9_idct32x32_msa.c new file mode 100644 index 000000000..f576b50ea --- /dev/null +++ b/vp9/common/mips/msa/vp9_idct32x32_msa.c @@ -0,0 +1,1077 @@ +/* + * Copyright (c) 2015 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 "vpx_ports/mem.h" +#include "vp9/common/vp9_idct.h" +#include "vp9/common/mips/msa/vp9_macros_msa.h" + +#define DOTP_CONST_PAIR(reg0, reg1, const0, const1, out0, out1) { \ + v8i16 k0_m = __msa_fill_h(const0); \ + v8i16 s0_m, s1_m, s2_m, s3_m; \ + \ + s0_m = __msa_fill_h(const1); \ + k0_m = __msa_ilvev_h(s0_m, k0_m); \ + \ + s0_m = __msa_ilvl_h(-reg1, reg0); \ + s1_m = __msa_ilvr_h(-reg1, reg0); \ + s2_m = __msa_ilvl_h(reg0, reg1); \ + s3_m = __msa_ilvr_h(reg0, reg1); \ + s1_m = (v8i16)__msa_dotp_s_w(s1_m, k0_m); \ + s0_m = (v8i16)__msa_dotp_s_w(s0_m, k0_m); \ + s1_m = (v8i16)__msa_srari_w((v4i32)s1_m, DCT_CONST_BITS); \ + s0_m = (v8i16)__msa_srari_w((v4i32)s0_m, DCT_CONST_BITS); \ + out0 = __msa_pckev_h(s0_m, s1_m); \ + \ + s1_m = (v8i16)__msa_dotp_s_w(s3_m, k0_m); \ + s0_m = (v8i16)__msa_dotp_s_w(s2_m, k0_m); \ + s1_m = (v8i16)__msa_srari_w((v4i32)s1_m, DCT_CONST_BITS); \ + s0_m = (v8i16)__msa_srari_w((v4i32)s0_m, DCT_CONST_BITS); \ + out1 = __msa_pckev_h(s0_m, s1_m); \ +} + +#define VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS(dest, dest_stride, \ + in0, in1, in2, in3) { \ + uint64_t out0_m, out1_m, out2_m, out3_m; \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + v16u8 dest0_m, dest1_m, dest2_m, dest3_m; \ + v16i8 tmp0_m, tmp1_m; \ + v16i8 zero_m = { 0 }; \ + uint8_t *dst_m = (uint8_t *)(dest); \ + \ + dest0_m = LOAD_UB(dst_m); \ + dest1_m = LOAD_UB(dst_m + 4 * dest_stride); \ + dest2_m = LOAD_UB(dst_m + 8 * dest_stride); \ + dest3_m = LOAD_UB(dst_m + 12 * dest_stride); \ + \ + res0_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest0_m); \ + res1_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest1_m); \ + res2_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest2_m); \ + res3_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest3_m); \ + \ + res0_m += (v8i16)(in0); \ + res1_m += (v8i16)(in1); \ + res2_m += (v8i16)(in2); \ + res3_m += (v8i16)(in3); \ + \ + res0_m = CLIP_UNSIGNED_CHAR_H(res0_m); \ + res1_m = CLIP_UNSIGNED_CHAR_H(res1_m); \ + res2_m = CLIP_UNSIGNED_CHAR_H(res2_m); \ + res3_m = CLIP_UNSIGNED_CHAR_H(res3_m); \ + \ + tmp0_m = __msa_pckev_b((v16i8)res1_m, (v16i8)res0_m); \ + tmp1_m = __msa_pckev_b((v16i8)res3_m, (v16i8)res2_m); \ + \ + out0_m = __msa_copy_u_d((v2i64)tmp0_m, 0); \ + out1_m = __msa_copy_u_d((v2i64)tmp0_m, 1); \ + out2_m = __msa_copy_u_d((v2i64)tmp1_m, 0); \ + out3_m = __msa_copy_u_d((v2i64)tmp1_m, 1); \ + \ + STORE_DWORD(dst_m, out0_m); \ + dst_m += (4 * dest_stride); \ + STORE_DWORD(dst_m, out1_m); \ + dst_m += (4 * dest_stride); \ + STORE_DWORD(dst_m, out2_m); \ + dst_m += (4 * dest_stride); \ + STORE_DWORD(dst_m, out3_m); \ +} + +static void vp9_idct32x8_row_transpose_store(const int16_t *input, + int16_t *tmp_buf) { + v8i16 m0, m1, m2, m3, m4, m5, m6, m7; + v8i16 n0, n1, n2, n3, n4, n5, n6, n7; + + /* 1st & 2nd 8x8 */ + LOAD_8VECS_SH(input, 32, m0, n0, m1, n1, m2, n2, m3, n3); + LOAD_8VECS_SH((input + 8), 32, m4, n4, m5, n5, m6, n6, m7, n7); + TRANSPOSE8x8_H_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + TRANSPOSE8x8_H_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + STORE_4VECS_SH((tmp_buf), 8, m0, n0, m1, n1); + STORE_4VECS_SH((tmp_buf + 4 * 8), 8, m2, n2, m3, n3); + STORE_4VECS_SH((tmp_buf + 8 * 8), 8, m4, n4, m5, n5); + STORE_4VECS_SH((tmp_buf + 12 * 8), 8, m6, n6, m7, n7); + + /* 3rd & 4th 8x8 */ + LOAD_8VECS_SH((input + 16), 32, m0, n0, m1, n1, m2, n2, m3, n3); + LOAD_8VECS_SH((input + 24), 32, m4, n4, m5, n5, m6, n6, m7, n7); + TRANSPOSE8x8_H_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + TRANSPOSE8x8_H_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + STORE_4VECS_SH((tmp_buf + 16 * 8), 8, m0, n0, m1, n1); + STORE_4VECS_SH((tmp_buf + 20 * 8), 8, m2, n2, m3, n3); + STORE_4VECS_SH((tmp_buf + 24 * 8), 8, m4, n4, m5, n5); + STORE_4VECS_SH((tmp_buf + 28 * 8), 8, m6, n6, m7, n7); +} + +static void vp9_idct32x8_row_even_process_store(int16_t *tmp_buf, + int16_t *tmp_eve_buf) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + v8i16 stp0, stp1, stp2, stp3, stp4, stp5, stp6, stp7; + + /* Even stage 1 */ + LOAD_8VECS_SH(tmp_buf, 32, reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + + DOTP_CONST_PAIR(reg1, reg7, cospi_28_64, cospi_4_64, reg1, reg7); + DOTP_CONST_PAIR(reg5, reg3, cospi_12_64, cospi_20_64, reg5, reg3); + + vec0 = reg1 - reg5; + vec1 = reg1 + reg5; + vec2 = reg7 - reg3; + vec3 = reg7 + reg3; + + DOTP_CONST_PAIR(vec2, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + loc1 = vec3; + loc0 = vec1; + + DOTP_CONST_PAIR(reg0, reg4, cospi_16_64, cospi_16_64, reg0, reg4); + DOTP_CONST_PAIR(reg2, reg6, cospi_24_64, cospi_8_64, reg2, reg6); + + vec0 = reg4 - reg6; + vec1 = reg4 + reg6; + vec2 = reg0 - reg2; + vec3 = reg0 + reg2; + + stp4 = vec0 - loc0; + stp3 = vec0 + loc0; + stp7 = vec1 - loc1; + stp0 = vec1 + loc1; + stp5 = vec2 - loc2; + stp2 = vec2 + loc2; + stp6 = vec3 - loc3; + stp1 = vec3 + loc3; + + /* Even stage 2 */ + LOAD_8VECS_SH((tmp_buf + 16), 32, + reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + + DOTP_CONST_PAIR(reg0, reg7, cospi_30_64, cospi_2_64, reg0, reg7); + DOTP_CONST_PAIR(reg4, reg3, cospi_14_64, cospi_18_64, reg4, reg3); + DOTP_CONST_PAIR(reg2, reg5, cospi_22_64, cospi_10_64, reg2, reg5); + DOTP_CONST_PAIR(reg6, reg1, cospi_6_64, cospi_26_64, reg6, reg1); + + vec0 = reg0 + reg4; + reg0 = reg0 - reg4; + reg4 = reg6 + reg2; + reg6 = reg6 - reg2; + reg2 = reg1 + reg5; + reg1 = reg1 - reg5; + reg5 = reg7 + reg3; + reg7 = reg7 - reg3; + reg3 = vec0; + + vec1 = reg2; + reg2 = reg3 + reg4; + reg3 = reg3 - reg4; + reg4 = reg5 - vec1; + reg5 = reg5 + vec1; + + DOTP_CONST_PAIR(reg7, reg0, cospi_24_64, cospi_8_64, reg0, reg7); + DOTP_CONST_PAIR((-reg6), reg1, cospi_24_64, cospi_8_64, reg6, reg1); + + vec0 = reg0 - reg6; + reg0 = reg0 + reg6; + vec1 = reg7 - reg1; + reg7 = reg7 + reg1; + + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, reg6, reg1); + DOTP_CONST_PAIR(reg4, reg3, cospi_16_64, cospi_16_64, reg3, reg4); + + /* Even stage 3 : Dependency on Even stage 1 & Even stage 2 */ + loc0 = stp0 - reg5; + loc1 = stp0 + reg5; + loc2 = stp1 - reg7; + loc3 = stp1 + reg7; + STORE_SH(loc0, (tmp_eve_buf + 15 * 8)); + STORE_SH(loc1, (tmp_eve_buf)); + STORE_SH(loc2, (tmp_eve_buf + 14 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 8)); + + loc0 = stp2 - reg1; + loc1 = stp2 + reg1; + loc2 = stp3 - reg4; + loc3 = stp3 + reg4; + STORE_SH(loc0, (tmp_eve_buf + 13 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 2 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 12 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 3 * 8)); + + /* Store 8 */ + loc0 = stp4 - reg3; + loc1 = stp4 + reg3; + loc2 = stp5 - reg6; + loc3 = stp5 + reg6; + STORE_SH(loc0, (tmp_eve_buf + 11 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 4 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 10 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 5 * 8)); + + loc0 = stp6 - reg0; + loc1 = stp6 + reg0; + loc2 = stp7 - reg2; + loc3 = stp7 + reg2; + STORE_SH(loc0, (tmp_eve_buf + 9 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 6 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 8 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 7 * 8)); +} + +static void vp9_idct32x8_row_odd_process_store(int16_t *tmp_buf, + int16_t *tmp_odd_buf) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + + /* Odd stage 1 */ + reg0 = LOAD_SH(tmp_buf + 8); + reg1 = LOAD_SH(tmp_buf + 7 * 8); + reg2 = LOAD_SH(tmp_buf + 9 * 8); + reg3 = LOAD_SH(tmp_buf + 15 * 8); + reg4 = LOAD_SH(tmp_buf + 17 * 8); + reg5 = LOAD_SH(tmp_buf + 23 * 8); + reg6 = LOAD_SH(tmp_buf + 25 * 8); + reg7 = LOAD_SH(tmp_buf + 31 * 8); + + DOTP_CONST_PAIR(reg0, reg7, cospi_31_64, cospi_1_64, reg0, reg7); + DOTP_CONST_PAIR(reg4, reg3, cospi_15_64, cospi_17_64, reg3, reg4); + DOTP_CONST_PAIR(reg2, reg5, cospi_23_64, cospi_9_64, reg2, reg5); + DOTP_CONST_PAIR(reg6, reg1, cospi_7_64, cospi_25_64, reg1, reg6); + + vec0 = reg0 + reg3; + reg0 = reg0 - reg3; + reg3 = reg7 + reg4; + reg7 = reg7 - reg4; + reg4 = reg1 + reg2; + reg1 = reg1 - reg2; + reg2 = reg6 + reg5; + reg6 = reg6 - reg5; + reg5 = vec0; + + /* 4 Stores */ + vec0 = reg5 + reg4; + vec1 = reg3 + reg2; + STORE_SH(vec0, (tmp_odd_buf + 4 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 5 * 8)); + + vec0 = reg5 - reg4; + vec1 = reg3 - reg2; + DOTP_CONST_PAIR(vec1, vec0, cospi_24_64, cospi_8_64, vec0, vec1); + STORE_SH(vec0, (tmp_odd_buf)); + STORE_SH(vec1, (tmp_odd_buf + 8)); + + /* 4 Stores */ + DOTP_CONST_PAIR(reg7, reg0, cospi_28_64, cospi_4_64, reg0, reg7); + DOTP_CONST_PAIR(reg6, reg1, -cospi_4_64, cospi_28_64, reg1, reg6); + + vec0 = reg0 + reg1; + vec2 = reg7 - reg6; + vec1 = reg7 + reg6; + vec3 = reg0 - reg1; + STORE_SH(vec0, (tmp_odd_buf + 6 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 7 * 8)); + + DOTP_CONST_PAIR(vec2, vec3, cospi_24_64, cospi_8_64, vec2, vec3); + STORE_SH(vec2, (tmp_odd_buf + 2 * 8)); + STORE_SH(vec3, (tmp_odd_buf + 3 * 8)); + + /* Odd stage 2 */ + + /* 8 loads */ + reg0 = LOAD_SH(tmp_buf + 3 * 8); + reg1 = LOAD_SH(tmp_buf + 5 * 8); + reg2 = LOAD_SH(tmp_buf + 11 * 8); + reg3 = LOAD_SH(tmp_buf + 13 * 8); + reg4 = LOAD_SH(tmp_buf + 19 * 8); + reg5 = LOAD_SH(tmp_buf + 21 * 8); + reg6 = LOAD_SH(tmp_buf + 27 * 8); + reg7 = LOAD_SH(tmp_buf + 29 * 8); + + DOTP_CONST_PAIR(reg1, reg6, cospi_27_64, cospi_5_64, reg1, reg6); + DOTP_CONST_PAIR(reg5, reg2, cospi_11_64, cospi_21_64, reg2, reg5); + DOTP_CONST_PAIR(reg3, reg4, cospi_19_64, cospi_13_64, reg3, reg4); + DOTP_CONST_PAIR(reg7, reg0, cospi_3_64, cospi_29_64, reg0, reg7); + + /* 4 Stores */ + vec0 = reg1 - reg2; + vec1 = reg6 - reg5; + vec2 = reg0 - reg3; + vec3 = reg7 - reg4; + DOTP_CONST_PAIR(vec1, vec0, cospi_12_64, cospi_20_64, loc0, loc1); + DOTP_CONST_PAIR(vec3, vec2, -cospi_20_64, cospi_12_64, loc2, loc3); + + vec2 = loc2 - loc0; + vec3 = loc3 - loc1; + vec0 = loc2 + loc0; + vec1 = loc3 + loc1; + STORE_SH(vec0, (tmp_odd_buf + 12 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 15 * 8)); + + DOTP_CONST_PAIR(vec3, vec2, -cospi_8_64, cospi_24_64, vec0, vec1); + + STORE_SH(vec0, (tmp_odd_buf + 10 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 11 * 8)); + + /* 4 Stores */ + vec0 = reg0 + reg3; + vec1 = reg1 + reg2; + vec2 = reg6 + reg5; + vec3 = reg7 + reg4; + reg0 = vec0 + vec1; + reg1 = vec3 + vec2; + reg2 = vec0 - vec1; + reg3 = vec3 - vec2; + STORE_SH(reg0, (tmp_odd_buf + 13 * 8)); + STORE_SH(reg1, (tmp_odd_buf + 14 * 8)); + + DOTP_CONST_PAIR(reg3, reg2, -cospi_8_64, cospi_24_64, reg0, reg1); + + STORE_SH(reg0, (tmp_odd_buf + 8 * 8)); + STORE_SH(reg1, (tmp_odd_buf + 9 * 8)); + + /* Odd stage 3 : Dependency on Odd stage 1 & Odd stage 2 */ + + /* Load 8 & Store 8 */ + reg0 = LOAD_SH(tmp_odd_buf); + reg1 = LOAD_SH(tmp_odd_buf + 1 * 8); + reg2 = LOAD_SH(tmp_odd_buf + 2 * 8); + reg3 = LOAD_SH(tmp_odd_buf + 3 * 8); + reg4 = LOAD_SH(tmp_odd_buf + 8 * 8); + reg5 = LOAD_SH(tmp_odd_buf + 9 * 8); + reg6 = LOAD_SH(tmp_odd_buf + 10 * 8); + reg7 = LOAD_SH(tmp_odd_buf + 11 * 8); + + loc0 = reg0 + reg4; + loc1 = reg1 + reg5; + loc2 = reg2 + reg6; + loc3 = reg3 + reg7; + STORE_SH(loc0, (tmp_odd_buf)); + STORE_SH(loc1, (tmp_odd_buf + 1 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 2 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 3 * 8)); + + vec0 = reg0 - reg4; + vec1 = reg1 - reg5; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + vec0 = reg2 - reg6; + vec1 = reg3 - reg7; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + STORE_SH(loc0, (tmp_odd_buf + 8 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 9 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 10 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 11 * 8)); + + /* Load 8 & Store 8 */ + reg1 = LOAD_SH(tmp_odd_buf + 4 * 8); + reg2 = LOAD_SH(tmp_odd_buf + 5 * 8); + reg0 = LOAD_SH(tmp_odd_buf + 6 * 8); + reg3 = LOAD_SH(tmp_odd_buf + 7 * 8); + reg4 = LOAD_SH(tmp_odd_buf + 12 * 8); + reg5 = LOAD_SH(tmp_odd_buf + 13 * 8); + reg6 = LOAD_SH(tmp_odd_buf + 14 * 8); + reg7 = LOAD_SH(tmp_odd_buf + 15 * 8); + + loc0 = reg0 + reg4; + loc1 = reg1 + reg5; + loc2 = reg2 + reg6; + loc3 = reg3 + reg7; + STORE_SH(loc0, (tmp_odd_buf + 4 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 5 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 6 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 7 * 8)); + + vec0 = reg0 - reg4; + vec1 = reg3 - reg7; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + vec0 = reg1 - reg5; + vec1 = reg2 - reg6; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + STORE_SH(loc0, (tmp_odd_buf + 12 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 13 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 14 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 15 * 8)); +} + +static void vp9_idct_butterfly_transpose_store(int16_t *tmp_buf, + int16_t *tmp_eve_buf, + int16_t *tmp_odd_buf, + int16_t *dest) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 m0, m1, m2, m3, m4, m5, m6, m7; + v8i16 n0, n1, n2, n3, n4, n5, n6, n7; + + /* FINAL BUTTERFLY : Dependency on Even & Odd */ + /* Total: 32 loads, 32 stores */ + vec0 = LOAD_SH(tmp_odd_buf); + vec1 = LOAD_SH(tmp_odd_buf + 9 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 14 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 6 * 8); + loc0 = LOAD_SH(tmp_eve_buf); + loc1 = LOAD_SH(tmp_eve_buf + 8 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 4 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 12 * 8); + + m0 = (loc0 + vec3); + STORE_SH((loc0 - vec3), (tmp_buf + 31 * 8)); + STORE_SH((loc1 - vec2), (tmp_buf + 23 * 8)); + m4 = (loc1 + vec2); + STORE_SH((loc2 - vec1), (tmp_buf + 27 * 8)); + m2 = (loc2 + vec1); + STORE_SH((loc3 - vec0), (tmp_buf + 19 * 8)); + m6 = (loc3 + vec0); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 4 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 13 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 10 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 3 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 2 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 10 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 6 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 14 * 8); + + m1 = (loc0 + vec3); + STORE_SH((loc0 - vec3), (tmp_buf + 29 * 8)); + STORE_SH((loc1 - vec2), (tmp_buf + 21 * 8)); + m5 = (loc1 + vec2); + STORE_SH((loc2 - vec1), (tmp_buf + 25 * 8)); + m3 = (loc2 + vec1); + STORE_SH((loc3 - vec0), (tmp_buf + 17 * 8)); + m7 = (loc3 + vec0); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 2 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 11 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 12 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 7 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 1 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 9 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 5 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 13 * 8); + + n0 = (loc0 + vec3); + STORE_SH((loc0 - vec3), (tmp_buf + 30 * 8)); + STORE_SH((loc1 - vec2), (tmp_buf + 22 * 8)); + n4 = (loc1 + vec2); + STORE_SH((loc2 - vec1), (tmp_buf + 26 * 8)); + n2 = (loc2 + vec1); + STORE_SH((loc3 - vec0), (tmp_buf + 18 * 8)); + n6 = (loc3 + vec0); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 5 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 15 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 8 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 1 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 3 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 11 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 7 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 15 * 8); + + n1 = (loc0 + vec3); + STORE_SH((loc0 - vec3), (tmp_buf + 28 * 8)); + STORE_SH((loc1 - vec2), (tmp_buf + 20 * 8)); + n5 = (loc1 + vec2); + STORE_SH((loc2 - vec1), (tmp_buf + 24 * 8)); + n3 = (loc2 + vec1); + STORE_SH((loc3 - vec0), (tmp_buf + 16 * 8)); + n7 = (loc3 + vec0); + + /* Transpose : 16 vectors */ + /* 1st & 2nd 8x8 */ + TRANSPOSE8x8_H_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + STORE_4VECS_SH((dest + 0), 32, m0, n0, m1, n1); + STORE_4VECS_SH((dest + 4 * 32), 32, m2, n2, m3, n3); + + TRANSPOSE8x8_H_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + STORE_4VECS_SH((dest + 8), 32, m4, n4, m5, n5); + STORE_4VECS_SH((dest + 8 + 4 * 32), 32, m6, n6, m7, n7); + + /* 3rd & 4th 8x8 */ + LOAD_8VECS_SH((tmp_buf + 8 * 16), 8, m0, n0, m1, n1, m2, n2, m3, n3); + LOAD_8VECS_SH((tmp_buf + 12 * 16), 8, m4, n4, m5, n5, m6, n6, m7, n7); + TRANSPOSE8x8_H_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + STORE_4VECS_SH((dest + 16), 32, m0, n0, m1, n1); + STORE_4VECS_SH((dest + 16 + 4 * 32), 32, m2, n2, m3, n3); + + TRANSPOSE8x8_H_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + STORE_4VECS_SH((dest + 24), 32, m4, n4, m5, n5); + STORE_4VECS_SH((dest + 24 + 4 * 32), 32, m6, n6, m7, n7); +} + +static void vp9_idct32x8_1d_rows_msa(const int16_t *input, int16_t *output) { + DECLARE_ALIGNED(32, int16_t, tmp_buf[8 * 32]); + DECLARE_ALIGNED(32, int16_t, tmp_odd_buf[16 * 8]); + DECLARE_ALIGNED(32, int16_t, tmp_eve_buf[16 * 8]); + + vp9_idct32x8_row_transpose_store(input, &tmp_buf[0]); + + vp9_idct32x8_row_even_process_store(&tmp_buf[0], &tmp_eve_buf[0]); + + vp9_idct32x8_row_odd_process_store(&tmp_buf[0], &tmp_odd_buf[0]); + + vp9_idct_butterfly_transpose_store(&tmp_buf[0], &tmp_eve_buf[0], + &tmp_odd_buf[0], output); +} + +static void vp9_idct8x32_column_even_process_store(int16_t *tmp_buf, + int16_t *tmp_eve_buf) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + v8i16 stp0, stp1, stp2, stp3, stp4, stp5, stp6, stp7; + + /* Even stage 1 */ + LOAD_8VECS_SH(tmp_buf, (4 * 32), + reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + + DOTP_CONST_PAIR(reg1, reg7, cospi_28_64, cospi_4_64, reg1, reg7); + DOTP_CONST_PAIR(reg5, reg3, cospi_12_64, cospi_20_64, reg5, reg3); + + vec0 = reg1 - reg5; + vec1 = reg1 + reg5; + vec2 = reg7 - reg3; + vec3 = reg7 + reg3; + + DOTP_CONST_PAIR(vec2, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + loc1 = vec3; + loc0 = vec1; + + DOTP_CONST_PAIR(reg0, reg4, cospi_16_64, cospi_16_64, reg0, reg4); + DOTP_CONST_PAIR(reg2, reg6, cospi_24_64, cospi_8_64, reg2, reg6); + + vec0 = reg4 - reg6; + vec1 = reg4 + reg6; + vec2 = reg0 - reg2; + vec3 = reg0 + reg2; + + stp4 = vec0 - loc0; + stp3 = vec0 + loc0; + stp7 = vec1 - loc1; + stp0 = vec1 + loc1; + stp5 = vec2 - loc2; + stp2 = vec2 + loc2; + stp6 = vec3 - loc3; + stp1 = vec3 + loc3; + + /* Even stage 2 */ + /* Load 8 */ + LOAD_8VECS_SH((tmp_buf + 2 * 32), (4 * 32), + reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + + DOTP_CONST_PAIR(reg0, reg7, cospi_30_64, cospi_2_64, reg0, reg7); + DOTP_CONST_PAIR(reg4, reg3, cospi_14_64, cospi_18_64, reg4, reg3); + DOTP_CONST_PAIR(reg2, reg5, cospi_22_64, cospi_10_64, reg2, reg5); + DOTP_CONST_PAIR(reg6, reg1, cospi_6_64, cospi_26_64, reg6, reg1); + + vec0 = reg0 + reg4; + reg0 = reg0 - reg4; + reg4 = reg6 + reg2; + reg6 = reg6 - reg2; + reg2 = reg1 + reg5; + reg1 = reg1 - reg5; + reg5 = reg7 + reg3; + reg7 = reg7 - reg3; + reg3 = vec0; + + vec1 = reg2; + reg2 = reg3 + reg4; + reg3 = reg3 - reg4; + reg4 = reg5 - vec1; + reg5 = reg5 + vec1; + + DOTP_CONST_PAIR(reg7, reg0, cospi_24_64, cospi_8_64, reg0, reg7); + DOTP_CONST_PAIR((-reg6), reg1, cospi_24_64, cospi_8_64, reg6, reg1); + + vec0 = reg0 - reg6; + reg0 = reg0 + reg6; + vec1 = reg7 - reg1; + reg7 = reg7 + reg1; + + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, reg6, reg1); + DOTP_CONST_PAIR(reg4, reg3, cospi_16_64, cospi_16_64, reg3, reg4); + + /* Even stage 3 : Dependency on Even stage 1 & Even stage 2 */ + /* Store 8 */ + loc0 = stp0 - reg5; + loc1 = stp0 + reg5; + loc2 = stp1 - reg7; + loc3 = stp1 + reg7; + STORE_SH(loc0, (tmp_eve_buf + 15 * 8)); + STORE_SH(loc1, (tmp_eve_buf)); + STORE_SH(loc2, (tmp_eve_buf + 14 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 1 * 8)); + + loc0 = stp2 - reg1; + loc1 = stp2 + reg1; + loc2 = stp3 - reg4; + loc3 = stp3 + reg4; + STORE_SH(loc0, (tmp_eve_buf + 13 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 2 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 12 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 3 * 8)); + + /* Store 8 */ + loc0 = stp4 - reg3; + loc1 = stp4 + reg3; + loc2 = stp5 - reg6; + loc3 = stp5 + reg6; + STORE_SH(loc0, (tmp_eve_buf + 11 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 4 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 10 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 5 * 8)); + + loc0 = stp6 - reg0; + loc1 = stp6 + reg0; + loc2 = stp7 - reg2; + loc3 = stp7 + reg2; + STORE_SH(loc0, (tmp_eve_buf + 9 * 8)); + STORE_SH(loc1, (tmp_eve_buf + 6 * 8)); + STORE_SH(loc2, (tmp_eve_buf + 8 * 8)); + STORE_SH(loc3, (tmp_eve_buf + 7 * 8)); +} + +static void vp9_idct8x32_column_odd_process_store(int16_t *tmp_buf, + int16_t *tmp_odd_buf) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + + /* Odd stage 1 */ + reg0 = LOAD_SH(tmp_buf + 32); + reg1 = LOAD_SH(tmp_buf + 7 * 32); + reg2 = LOAD_SH(tmp_buf + 9 * 32); + reg3 = LOAD_SH(tmp_buf + 15 * 32); + reg4 = LOAD_SH(tmp_buf + 17 * 32); + reg5 = LOAD_SH(tmp_buf + 23 * 32); + reg6 = LOAD_SH(tmp_buf + 25 * 32); + reg7 = LOAD_SH(tmp_buf + 31 * 32); + + DOTP_CONST_PAIR(reg0, reg7, cospi_31_64, cospi_1_64, reg0, reg7); + DOTP_CONST_PAIR(reg4, reg3, cospi_15_64, cospi_17_64, reg3, reg4); + DOTP_CONST_PAIR(reg2, reg5, cospi_23_64, cospi_9_64, reg2, reg5); + DOTP_CONST_PAIR(reg6, reg1, cospi_7_64, cospi_25_64, reg1, reg6); + + vec0 = reg0 + reg3; + reg0 = reg0 - reg3; + reg3 = reg7 + reg4; + reg7 = reg7 - reg4; + reg4 = reg1 + reg2; + reg1 = reg1 - reg2; + reg2 = reg6 + reg5; + reg6 = reg6 - reg5; + reg5 = vec0; + + /* 4 Stores */ + vec0 = reg5 + reg4; + vec1 = reg3 + reg2; + STORE_SH(vec0, (tmp_odd_buf + 4 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 5 * 8)); + + vec0 = reg5 - reg4; + vec1 = reg3 - reg2; + DOTP_CONST_PAIR(vec1, vec0, cospi_24_64, cospi_8_64, vec0, vec1); + STORE_SH(vec0, (tmp_odd_buf)); + STORE_SH(vec1, (tmp_odd_buf + 1 * 8)); + + /* 4 Stores */ + DOTP_CONST_PAIR(reg7, reg0, cospi_28_64, cospi_4_64, reg0, reg7); + DOTP_CONST_PAIR(reg6, reg1, -cospi_4_64, cospi_28_64, reg1, reg6); + + vec0 = reg0 + reg1; + vec2 = reg7 - reg6; + vec1 = reg7 + reg6; + vec3 = reg0 - reg1; + STORE_SH(vec0, (tmp_odd_buf + 6 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 7 * 8)); + + DOTP_CONST_PAIR(vec2, vec3, cospi_24_64, cospi_8_64, vec2, vec3); + STORE_SH(vec2, (tmp_odd_buf + 2 * 8)); + STORE_SH(vec3, (tmp_odd_buf + 3 * 8)); + + /* Odd stage 2 */ + /* 8 loads */ + reg0 = LOAD_SH(tmp_buf + 3 * 32); + reg1 = LOAD_SH(tmp_buf + 5 * 32); + reg2 = LOAD_SH(tmp_buf + 11 * 32); + reg3 = LOAD_SH(tmp_buf + 13 * 32); + reg4 = LOAD_SH(tmp_buf + 19 * 32); + reg5 = LOAD_SH(tmp_buf + 21 * 32); + reg6 = LOAD_SH(tmp_buf + 27 * 32); + reg7 = LOAD_SH(tmp_buf + 29 * 32); + + DOTP_CONST_PAIR(reg1, reg6, cospi_27_64, cospi_5_64, reg1, reg6); + DOTP_CONST_PAIR(reg5, reg2, cospi_11_64, cospi_21_64, reg2, reg5); + DOTP_CONST_PAIR(reg3, reg4, cospi_19_64, cospi_13_64, reg3, reg4); + DOTP_CONST_PAIR(reg7, reg0, cospi_3_64, cospi_29_64, reg0, reg7); + + /* 4 Stores */ + vec0 = reg1 - reg2; + vec1 = reg6 - reg5; + vec2 = reg0 - reg3; + vec3 = reg7 - reg4; + DOTP_CONST_PAIR(vec1, vec0, cospi_12_64, cospi_20_64, loc0, loc1); + DOTP_CONST_PAIR(vec3, vec2, -cospi_20_64, cospi_12_64, loc2, loc3); + + vec2 = loc2 - loc0; + vec3 = loc3 - loc1; + vec0 = loc2 + loc0; + vec1 = loc3 + loc1; + STORE_SH(vec0, (tmp_odd_buf + 12 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 15 * 8)); + + DOTP_CONST_PAIR(vec3, vec2, -cospi_8_64, cospi_24_64, vec0, vec1); + + STORE_SH(vec0, (tmp_odd_buf + 10 * 8)); + STORE_SH(vec1, (tmp_odd_buf + 11 * 8)); + + /* 4 Stores */ + vec0 = reg0 + reg3; + vec1 = reg1 + reg2; + vec2 = reg6 + reg5; + vec3 = reg7 + reg4; + reg0 = vec0 + vec1; + reg1 = vec3 + vec2; + reg2 = vec0 - vec1; + reg3 = vec3 - vec2; + STORE_SH(reg0, (tmp_odd_buf + 13 * 8)); + STORE_SH(reg1, (tmp_odd_buf + 14 * 8)); + + DOTP_CONST_PAIR(reg3, reg2, -cospi_8_64, cospi_24_64, reg0, reg1); + + STORE_SH(reg0, (tmp_odd_buf + 8 * 8)); + STORE_SH(reg1, (tmp_odd_buf + 9 * 8)); + + /* Odd stage 3 : Dependency on Odd stage 1 & Odd stage 2 */ + /* Load 8 & Store 8 */ + reg0 = LOAD_SH(tmp_odd_buf); + reg1 = LOAD_SH(tmp_odd_buf + 1 * 8); + reg2 = LOAD_SH(tmp_odd_buf + 2 * 8); + reg3 = LOAD_SH(tmp_odd_buf + 3 * 8); + reg4 = LOAD_SH(tmp_odd_buf + 8 * 8); + reg5 = LOAD_SH(tmp_odd_buf + 9 * 8); + reg6 = LOAD_SH(tmp_odd_buf + 10 * 8); + reg7 = LOAD_SH(tmp_odd_buf + 11 * 8); + + loc0 = reg0 + reg4; + loc1 = reg1 + reg5; + loc2 = reg2 + reg6; + loc3 = reg3 + reg7; + STORE_SH(loc0, (tmp_odd_buf)); + STORE_SH(loc1, (tmp_odd_buf + 1 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 2 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 3 * 8)); + + vec0 = reg0 - reg4; + vec1 = reg1 - reg5; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + vec0 = reg2 - reg6; + vec1 = reg3 - reg7; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + STORE_SH(loc0, (tmp_odd_buf + 8 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 9 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 10 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 11 * 8)); + + /* Load 8 & Store 8 */ + reg1 = LOAD_SH(tmp_odd_buf + 4 * 8); + reg2 = LOAD_SH(tmp_odd_buf + 5 * 8); + reg0 = LOAD_SH(tmp_odd_buf + 6 * 8); + reg3 = LOAD_SH(tmp_odd_buf + 7 * 8); + reg4 = LOAD_SH(tmp_odd_buf + 12 * 8); + reg5 = LOAD_SH(tmp_odd_buf + 13 * 8); + reg6 = LOAD_SH(tmp_odd_buf + 14 * 8); + reg7 = LOAD_SH(tmp_odd_buf + 15 * 8); + + loc0 = reg0 + reg4; + loc1 = reg1 + reg5; + loc2 = reg2 + reg6; + loc3 = reg3 + reg7; + STORE_SH(loc0, (tmp_odd_buf + 4 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 5 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 6 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 7 * 8)); + + vec0 = reg0 - reg4; + vec1 = reg3 - reg7; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + vec0 = reg1 - reg5; + vec1 = reg2 - reg6; + DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + STORE_SH(loc0, (tmp_odd_buf + 12 * 8)); + STORE_SH(loc1, (tmp_odd_buf + 13 * 8)); + STORE_SH(loc2, (tmp_odd_buf + 14 * 8)); + STORE_SH(loc3, (tmp_odd_buf + 15 * 8)); +} + +static void vp9_idct8x32_column_butterfly_addblk(int16_t *tmp_eve_buf, + int16_t *tmp_odd_buf, + uint8_t *dest, + int32_t dest_stride) { + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 m0, m1, m2, m3, m4, m5, m6, m7; + v8i16 n0, n1, n2, n3, n4, n5, n6, n7; + + /* FINAL BUTTERFLY : Dependency on Even & Odd */ + vec0 = LOAD_SH(tmp_odd_buf); + vec1 = LOAD_SH(tmp_odd_buf + 9 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 14 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 6 * 8); + loc0 = LOAD_SH(tmp_eve_buf); + loc1 = LOAD_SH(tmp_eve_buf + 8 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 4 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 12 * 8); + + m0 = (loc0 + vec3); + m4 = (loc1 + vec2); + m2 = (loc2 + vec1); + m6 = (loc3 + vec0); + SRARI_H_4VECS_SH(m0, m2, m4, m6, m0, m2, m4, m6, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS(dest, dest_stride, m0, m2, m4, m6); + + m6 = (loc0 - vec3); + m2 = (loc1 - vec2); + m4 = (loc2 - vec1); + m0 = (loc3 - vec0); + SRARI_H_4VECS_SH(m0, m2, m4, m6, m0, m2, m4, m6, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 19 * dest_stride), + dest_stride, m0, m2, m4, m6); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 4 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 13 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 10 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 3 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 2 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 10 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 6 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 14 * 8); + + m1 = (loc0 + vec3); + m5 = (loc1 + vec2); + m3 = (loc2 + vec1); + m7 = (loc3 + vec0); + SRARI_H_4VECS_SH(m1, m3, m5, m7, m1, m3, m5, m7, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 2 * dest_stride), + dest_stride, m1, m3, m5, m7); + + m7 = (loc0 - vec3); + m3 = (loc1 - vec2); + m5 = (loc2 - vec1); + m1 = (loc3 - vec0); + SRARI_H_4VECS_SH(m1, m3, m5, m7, m1, m3, m5, m7, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 17 * dest_stride), + dest_stride, m1, m3, m5, m7); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 2 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 11 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 12 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 7 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 1 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 9 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 5 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 13 * 8); + + n0 = (loc0 + vec3); + n4 = (loc1 + vec2); + n2 = (loc2 + vec1); + n6 = (loc3 + vec0); + SRARI_H_4VECS_SH(n0, n2, n4, n6, n0, n2, n4, n6, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 1 * dest_stride), + dest_stride, n0, n2, n4, n6); + + n6 = (loc0 - vec3); + n2 = (loc1 - vec2); + n4 = (loc2 - vec1); + n0 = (loc3 - vec0); + SRARI_H_4VECS_SH(n0, n2, n4, n6, n0, n2, n4, n6, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 18 * dest_stride), + dest_stride, n0, n2, n4, n6); + + /* Load 8 & Store 8 */ + vec0 = LOAD_SH(tmp_odd_buf + 5 * 8); + vec1 = LOAD_SH(tmp_odd_buf + 15 * 8); + vec2 = LOAD_SH(tmp_odd_buf + 8 * 8); + vec3 = LOAD_SH(tmp_odd_buf + 1 * 8); + loc0 = LOAD_SH(tmp_eve_buf + 3 * 8); + loc1 = LOAD_SH(tmp_eve_buf + 11 * 8); + loc2 = LOAD_SH(tmp_eve_buf + 7 * 8); + loc3 = LOAD_SH(tmp_eve_buf + 15 * 8); + + n1 = (loc0 + vec3); + n5 = (loc1 + vec2); + n3 = (loc2 + vec1); + n7 = (loc3 + vec0); + SRARI_H_4VECS_SH(n1, n3, n5, n7, n1, n3, n5, n7, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 3 * dest_stride), + dest_stride, n1, n3, n5, n7); + + n7 = (loc0 - vec3); + n3 = (loc1 - vec2); + n5 = (loc2 - vec1); + n1 = (loc3 - vec0); + SRARI_H_4VECS_SH(n1, n3, n5, n7, n1, n3, n5, n7, 6); + VP9_ADDBLK_CLIP_AND_STORE_OFF_4H_VECS((dest + 16 * dest_stride), + dest_stride, n1, n3, n5, n7); +} + +static void vp9_idct8x32_1d_columns_addblk_msa(int16_t *input, uint8_t *dest, + int32_t dest_stride) { + DECLARE_ALIGNED(32, int16_t, tmp_odd_buf[16 * 8]); + DECLARE_ALIGNED(32, int16_t, tmp_eve_buf[16 * 8]); + + vp9_idct8x32_column_even_process_store(input, &tmp_eve_buf[0]); + + vp9_idct8x32_column_odd_process_store(input, &tmp_odd_buf[0]); + + vp9_idct8x32_column_butterfly_addblk(&tmp_eve_buf[0], &tmp_odd_buf[0], + dest, dest_stride); +} + +void vp9_idct32x32_1024_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + int32_t i; + DECLARE_ALIGNED(32, int16_t, out_arr[32 * 32]); + int16_t *out_ptr = out_arr; + + /* transform rows */ + for (i = 0; i < 4; ++i) { + /* process 32 * 8 block */ + vp9_idct32x8_1d_rows_msa((input + (i << 8)), (out_ptr + (i << 8))); + } + + /* transform columns */ + for (i = 0; i < 4; ++i) { + /* process 8 * 32 block */ + vp9_idct8x32_1d_columns_addblk_msa((out_ptr + (i << 3)), (dest + (i << 3)), + dest_stride); + } +} + +void vp9_idct32x32_34_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + int32_t i; + DECLARE_ALIGNED(32, int16_t, out_arr[32 * 32]); + int16_t *out_ptr = out_arr; + + for (i = 32; i--;) { + __asm__ __volatile__ ( + "sw $zero, 0(%[out_ptr]) \n\t" + "sw $zero, 4(%[out_ptr]) \n\t" + "sw $zero, 8(%[out_ptr]) \n\t" + "sw $zero, 12(%[out_ptr]) \n\t" + "sw $zero, 16(%[out_ptr]) \n\t" + "sw $zero, 20(%[out_ptr]) \n\t" + "sw $zero, 24(%[out_ptr]) \n\t" + "sw $zero, 28(%[out_ptr]) \n\t" + "sw $zero, 32(%[out_ptr]) \n\t" + "sw $zero, 36(%[out_ptr]) \n\t" + "sw $zero, 40(%[out_ptr]) \n\t" + "sw $zero, 44(%[out_ptr]) \n\t" + "sw $zero, 48(%[out_ptr]) \n\t" + "sw $zero, 52(%[out_ptr]) \n\t" + "sw $zero, 56(%[out_ptr]) \n\t" + "sw $zero, 60(%[out_ptr]) \n\t" + + : + : [out_ptr] "r" (out_ptr) + ); + + out_ptr += 32; + } + + out_ptr = out_arr; + + /* rows: only upper-left 8x8 has non-zero coeff */ + vp9_idct32x8_1d_rows_msa(input, out_ptr); + + /* transform columns */ + for (i = 0; i < 4; ++i) { + /* process 8 * 32 block */ + vp9_idct8x32_1d_columns_addblk_msa((out_ptr + (i << 3)), (dest + (i << 3)), + dest_stride); + } +} + +void vp9_idct32x32_1_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + int32_t i, const1; + v8i16 const2; + int16_t out; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v16u8 dest0, dest1, dest2, dest3; + v16u8 tmp0, tmp1, tmp2, tmp3; + v16i8 zero = { 0 }; + + out = dct_const_round_shift(input[0] * cospi_16_64); + out = dct_const_round_shift(out * cospi_16_64); + const1 = ROUND_POWER_OF_TWO(out, 6); + + const2 = __msa_fill_h(const1); + + for (i = 0; i < 16; ++i) { + dest0 = LOAD_UB(dest); + dest1 = LOAD_UB(dest + 16); + dest2 = LOAD_UB(dest + dest_stride); + dest3 = LOAD_UB(dest + dest_stride + 16); + + res0 = (v8i16)__msa_ilvr_b(zero, (v16i8)dest0); + res1 = (v8i16)__msa_ilvr_b(zero, (v16i8)dest1); + res2 = (v8i16)__msa_ilvr_b(zero, (v16i8)dest2); + res3 = (v8i16)__msa_ilvr_b(zero, (v16i8)dest3); + res4 = (v8i16)__msa_ilvl_b(zero, (v16i8)dest0); + res5 = (v8i16)__msa_ilvl_b(zero, (v16i8)dest1); + res6 = (v8i16)__msa_ilvl_b(zero, (v16i8)dest2); + res7 = (v8i16)__msa_ilvl_b(zero, (v16i8)dest3); + + res0 += const2; + res1 += const2; + res2 += const2; + res3 += const2; + res4 += const2; + res5 += const2; + res6 += const2; + res7 += const2; + + res0 = CLIP_UNSIGNED_CHAR_H(res0); + res1 = CLIP_UNSIGNED_CHAR_H(res1); + res2 = CLIP_UNSIGNED_CHAR_H(res2); + res3 = CLIP_UNSIGNED_CHAR_H(res3); + res4 = CLIP_UNSIGNED_CHAR_H(res4); + res5 = CLIP_UNSIGNED_CHAR_H(res5); + res6 = CLIP_UNSIGNED_CHAR_H(res6); + res7 = CLIP_UNSIGNED_CHAR_H(res7); + + tmp0 = (v16u8)__msa_pckev_b((v16i8)res4, (v16i8)res0); + tmp1 = (v16u8)__msa_pckev_b((v16i8)res5, (v16i8)res1); + tmp2 = (v16u8)__msa_pckev_b((v16i8)res6, (v16i8)res2); + tmp3 = (v16u8)__msa_pckev_b((v16i8)res7, (v16i8)res3); + + STORE_UB(tmp0, dest); + STORE_UB(tmp1, dest + 16); + dest += dest_stride; + STORE_UB(tmp2, dest); + STORE_UB(tmp3, dest + 16); + dest += dest_stride; + } +} diff --git a/vp9/common/mips/msa/vp9_idct8x8_msa.c b/vp9/common/mips/msa/vp9_idct8x8_msa.c new file mode 100644 index 000000000..77da389e7 --- /dev/null +++ b/vp9/common/mips/msa/vp9_idct8x8_msa.c @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2015 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 <assert.h> + +#include "vp9/common/vp9_idct.h" +#include "vp9/common/mips/msa/vp9_macros_msa.h" + +#define SET_COSPI_PAIR(c0_h, c1_h) ({ \ + v8i16 out0, r0_m, r1_m; \ + \ + r0_m = __msa_fill_h(c0_h); \ + r1_m = __msa_fill_h(c1_h); \ + out0 = __msa_ilvev_h(r1_m, r0_m); \ + \ + out0; \ +}) + +#define VP9_SET_CONST_PAIR(mask_h, idx1_h, idx2_h) ({ \ + v8i16 c0_m, c1_m; \ + \ + c0_m = __msa_splati_h((mask_h), (idx1_h)); \ + c1_m = __msa_splati_h((mask_h), (idx2_h)); \ + c0_m = __msa_ilvev_h(c1_m, c0_m); \ + \ + c0_m; \ +}) + +#define VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, \ + in0, in1, in2, in3) { \ + uint64_t out0_m, out1_m, out2_m, out3_m; \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + v16u8 dest0_m, dest1_m, dest2_m, dest3_m; \ + v16i8 tmp0_m, tmp1_m; \ + v16i8 zero_m = { 0 }; \ + uint8_t *dst_m = (uint8_t *)(dest); \ + \ + LOAD_4VECS_UB(dst_m, (dest_stride), \ + dest0_m, dest1_m, dest2_m, dest3_m); \ + \ + res0_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest0_m); \ + res1_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest1_m); \ + res2_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest2_m); \ + res3_m = (v8i16)__msa_ilvr_b(zero_m, (v16i8)dest3_m); \ + \ + res0_m += (v8i16)(in0); \ + res1_m += (v8i16)(in1); \ + res2_m += (v8i16)(in2); \ + res3_m += (v8i16)(in3); \ + \ + res0_m = CLIP_UNSIGNED_CHAR_H(res0_m); \ + res1_m = CLIP_UNSIGNED_CHAR_H(res1_m); \ + res2_m = CLIP_UNSIGNED_CHAR_H(res2_m); \ + res3_m = CLIP_UNSIGNED_CHAR_H(res3_m); \ + \ + tmp0_m = __msa_pckev_b((v16i8)res1_m, (v16i8)res0_m); \ + tmp1_m = __msa_pckev_b((v16i8)res3_m, (v16i8)res2_m); \ + \ + out0_m = __msa_copy_u_d((v2i64)tmp0_m, 0); \ + out1_m = __msa_copy_u_d((v2i64)tmp0_m, 1); \ + out2_m = __msa_copy_u_d((v2i64)tmp1_m, 0); \ + out3_m = __msa_copy_u_d((v2i64)tmp1_m, 1); \ + \ + STORE_DWORD(dst_m, out0_m); \ + dst_m += (dest_stride); \ + STORE_DWORD(dst_m, out1_m); \ + dst_m += (dest_stride); \ + STORE_DWORD(dst_m, out2_m); \ + dst_m += (dest_stride); \ + STORE_DWORD(dst_m, out3_m); \ +} + +/* multiply and add macro */ +#define VP9_MADD(inp0, inp1, inp2, inp3, \ + cst0, cst1, cst2, cst3, \ + out0, out1, out2, out3) { \ + v8i16 madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + ILV_H_LRLR_SH(inp0, inp1, inp2, inp3, \ + madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m); \ + \ + DOTP_S_W_4VECS_SW(madd_s1_m, cst0, madd_s0_m, cst0, \ + madd_s1_m, cst1, madd_s0_m, cst1, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + \ + SRARI_W_4VECS_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + DCT_CONST_BITS); \ + \ + PCKEV_H_2VECS_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, \ + out0, out1); \ + \ + DOTP_S_W_4VECS_SW(madd_s3_m, cst2, madd_s2_m, cst2, \ + madd_s3_m, cst3, madd_s2_m, cst3, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + \ + SRARI_W_4VECS_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + DCT_CONST_BITS); \ + \ + PCKEV_H_2VECS_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, \ + out2, out3); \ +} + +/* idct 8x8 macro */ +#define VP9_IDCT8x8_1D_ODD(in1, in3, in5, in7, \ + k0, k1, k2, k3, mask, \ + out0, out1, out2, out3) { \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + VP9_MADD(in1, in7, in3, in5, k0, k1, k2, k3, \ + in1, in7, in3, in5); \ + \ + res0_m = in1 - in3; \ + res1_m = in7 - in5; \ + \ + k0 = VP9_SET_CONST_PAIR(mask, 4, 7); \ + k1 = __msa_splati_h(mask, 4); \ + \ + res2_m = __msa_ilvr_h(res0_m, res1_m); \ + res3_m = __msa_ilvl_h(res0_m, res1_m); \ + \ + DOTP_S_W_4VECS_SW(res2_m, k0, res3_m, k0, \ + res2_m, k1, res3_m, k1, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + \ + SRARI_W_4VECS_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + DCT_CONST_BITS); \ + out0 = in1 + in3; \ + PCKEV_H_2VECS_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, \ + out1, out2); \ + out3 = in7 + in5; \ +} + +#define VP9_IDCT8x8_1D_EVEN(in0, in2, in4, in6, \ + k0, k1, k2, k3, \ + out0, out1, out2, out3) { \ + k2 = SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); \ + k3 = SET_COSPI_PAIR(cospi_8_64, cospi_24_64); \ + \ + VP9_MADD(in0, in4, in2, in6, k1, k0, k2, k3, \ + in0, in4, in2, in6); \ + \ + out0 = in0 + in6; \ + out1 = in4 + in2; \ + out2 = in4 - in2; \ + out3 = in0 - in6; \ +} + +#define VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) { \ + v8i16 res0_m, res1_m, res2_m, res3_m, res4_m, res5_m, res6_m, res7_m; \ + v8i16 k0_m, k1_m, k2_m, k3_m; \ + v8i16 mask_m = { cospi_28_64, cospi_4_64, cospi_20_64, cospi_12_64, \ + cospi_16_64, -cospi_4_64, -cospi_20_64, -cospi_16_64 \ + }; \ + \ + k0_m = VP9_SET_CONST_PAIR(mask_m, 0, 5); \ + k1_m = VP9_SET_CONST_PAIR(mask_m, 1, 0); \ + k2_m = VP9_SET_CONST_PAIR(mask_m, 6, 3); \ + k3_m = VP9_SET_CONST_PAIR(mask_m, 3, 2); \ + \ + VP9_IDCT8x8_1D_ODD(in1, in3, in5, in7, k0_m, k1_m, k2_m, k3_m, mask_m, \ + res4_m, res5_m, res6_m, res7_m); \ + \ + VP9_IDCT8x8_1D_EVEN(in0, in2, in4, in6, k0_m, k1_m, k2_m, k3_m, \ + res0_m, res1_m, res2_m, res3_m); \ + \ + BUTTERFLY_8(res0_m, res1_m, res2_m, res3_m, \ + res4_m, res5_m, res6_m, res7_m, \ + out0, out1, out2, out3, \ + out4, out5, out6, out7); \ +} + +#define DOT_ADD_SUB_SRARI_PCK(in0, in1, in2, in3, in4, in5, in6, in7, \ + dst0, dst1, dst2, dst3) { \ + v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9; \ + \ + tmp0 = __msa_dotp_s_w((in0), (in4)); \ + tmp2 = __msa_dotp_s_w((in1), (in4)); \ + tmp3 = __msa_dotp_s_w((in0), (in5)); \ + tmp4 = __msa_dotp_s_w((in1), (in5)); \ + tmp5 = __msa_dotp_s_w((in2), (in6)); \ + tmp6 = __msa_dotp_s_w((in3), (in6)); \ + tmp7 = __msa_dotp_s_w((in2), (in7)); \ + tmp8 = __msa_dotp_s_w((in3), (in7)); \ + \ + BUTTERFLY_4(tmp0, tmp3, tmp7, tmp5, tmp1, tmp9, tmp7, tmp5); \ + BUTTERFLY_4(tmp2, tmp4, tmp8, tmp6, tmp3, tmp0, tmp4, tmp2); \ + \ + SRARI_W_4VECS_SW(tmp1, tmp9, tmp7, tmp5, tmp1, tmp9, tmp7, tmp5, \ + DCT_CONST_BITS); \ + SRARI_W_4VECS_SW(tmp3, tmp0, tmp4, tmp2, tmp3, tmp0, tmp4, tmp2, \ + DCT_CONST_BITS); \ + \ + PCKEV_H_4VECS_SH(tmp1, tmp3, tmp9, tmp0, tmp7, tmp4, tmp5, tmp2, \ + dst0, dst1, dst2, dst3); \ +} + +#define DOT_SHIFT_RIGHT_PCK_H(in0, in1, in2) ({ \ + v8i16 dst_m; \ + v4i32 tp0_m, tp1_m; \ + \ + tp1_m = __msa_dotp_s_w((in0), (in2)); \ + tp0_m = __msa_dotp_s_w((in1), (in2)); \ + tp1_m = __msa_srari_w(tp1_m, DCT_CONST_BITS); \ + tp0_m = __msa_srari_w(tp0_m, DCT_CONST_BITS); \ + dst_m = __msa_pckev_h((v8i16)tp1_m, (v8i16)tp0_m); \ + \ + dst_m; \ +}) + +#define VP9_ADST8_ROW(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) { \ + v8i16 const0_m, const1_m, const2_m, const3_m, const4_m; \ + v8i16 temp0_m, temp1_m, temp2_m, temp3_m, s0_m, s1_m; \ + v8i16 coeff0_m = { cospi_2_64, cospi_6_64, cospi_10_64, \ + cospi_14_64, cospi_18_64, cospi_22_64, cospi_26_64, cospi_30_64 \ + }; \ + v8i16 coeff1_m = { cospi_8_64, -cospi_8_64, cospi_16_64, \ + -cospi_16_64, cospi_24_64, -cospi_24_64, 0, 0 \ + }; \ + \ + const0_m = __msa_splati_h(coeff0_m, 0); \ + const1_m = __msa_splati_h(coeff0_m, 7); \ + const2_m = -const0_m; \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = __msa_ilvev_h(const2_m, const1_m); \ + const2_m = __msa_splati_h(coeff0_m, 4); \ + const3_m = __msa_splati_h(coeff0_m, 3); \ + const4_m = -const2_m; \ + const2_m = __msa_ilvev_h(const3_m, const2_m); \ + const3_m = __msa_ilvev_h(const4_m, const3_m); \ + \ + ILV_H_LRLR_SH(in7, in0, in3, in4, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const1_m, const2_m, const3_m, \ + in7, in0, in4, in3); \ + \ + const0_m = __msa_splati_h(coeff0_m, 2); \ + const1_m = __msa_splati_h(coeff0_m, 5); \ + const2_m = -const0_m; \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = __msa_ilvev_h(const2_m, const1_m); \ + const2_m = __msa_splati_h(coeff0_m, 6); \ + const3_m = __msa_splati_h(coeff0_m, 1); \ + const4_m = -const2_m; \ + const2_m = __msa_ilvev_h(const3_m, const2_m); \ + const3_m = __msa_ilvev_h(const4_m, const3_m); \ + \ + ILV_H_LRLR_SH(in5, in2, in1, in6, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const1_m, const2_m, const3_m, \ + in5, in2, in6, in1); \ + \ + BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5); \ + out7 = -s0_m; \ + out0 = s1_m; \ + \ + SPLATI_H_4VECS_SH(coeff1_m, 0, 4, 1, 5, \ + const0_m, const1_m, const2_m, const3_m); \ + \ + const3_m = __msa_ilvev_h(const0_m, const3_m); \ + const2_m = __msa_ilvev_h(const2_m, const1_m); \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = const0_m; \ + \ + ILV_H_LRLR_SH(in3, in4, in1, in6, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const2_m, const3_m, const1_m, \ + out1, out6, s0_m, s1_m); \ + \ + const0_m = __msa_splati_h(coeff1_m, 2); \ + const1_m = __msa_splati_h(coeff1_m, 3); \ + const1_m = __msa_ilvev_h(const1_m, const0_m); \ + \ + ILV_H_LRLR_SH(in5, in2, s1_m, s0_m, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + out3 = DOT_SHIFT_RIGHT_PCK_H(temp0_m, temp1_m, const0_m); \ + out4 = DOT_SHIFT_RIGHT_PCK_H(temp0_m, temp1_m, const1_m); \ + out2 = DOT_SHIFT_RIGHT_PCK_H(temp2_m, temp3_m, const0_m); \ + out5 = DOT_SHIFT_RIGHT_PCK_H(temp2_m, temp3_m, const1_m); \ + \ + out1 = -out1; \ + out3 = -out3; \ + out5 = -out5; \ +} + +#define VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) { \ + v8i16 const0_m, const1_m, const2_m, const3_m, const4_m; \ + v8i16 temp0_m, temp1_m, temp2_m, temp3_m, s0_m, s1_m; \ + \ + const0_m = __msa_fill_h(cospi_2_64); \ + const1_m = __msa_fill_h(cospi_30_64); \ + const2_m = -const0_m; \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = __msa_ilvev_h(const2_m, const1_m); \ + const2_m = __msa_fill_h(cospi_18_64); \ + const3_m = __msa_fill_h(cospi_14_64); \ + const4_m = -const2_m; \ + const2_m = __msa_ilvev_h(const3_m, const2_m); \ + const3_m = __msa_ilvev_h(const4_m, const3_m); \ + \ + ILV_H_LRLR_SH(in7, in0, in3, in4, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const1_m, const2_m, const3_m, \ + in7, in0, in4, in3); \ + \ + const0_m = __msa_fill_h(cospi_10_64); \ + const1_m = __msa_fill_h(cospi_22_64); \ + const2_m = -const0_m; \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = __msa_ilvev_h(const2_m, const1_m); \ + const2_m = __msa_fill_h(cospi_26_64); \ + const3_m = __msa_fill_h(cospi_6_64); \ + const4_m = -const2_m; \ + const2_m = __msa_ilvev_h(const3_m, const2_m); \ + const3_m = __msa_ilvev_h(const4_m, const3_m); \ + \ + ILV_H_LRLR_SH(in5, in2, in1, in6, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const1_m, const2_m, const3_m, \ + in5, in2, in6, in1); \ + \ + BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5); \ + out7 = -s0_m; \ + out0 = s1_m; \ + \ + const1_m = __msa_fill_h(cospi_24_64); \ + const0_m = __msa_fill_h(cospi_8_64); \ + const3_m = -const1_m; \ + const2_m = -const0_m; \ + \ + const3_m = __msa_ilvev_h(const0_m, const3_m); \ + const2_m = __msa_ilvev_h(const2_m, const1_m); \ + const0_m = __msa_ilvev_h(const1_m, const0_m); \ + const1_m = const0_m; \ + \ + ILV_H_LRLR_SH(in3, in4, in1, in6, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(temp0_m, temp1_m, temp2_m, temp3_m, \ + const0_m, const2_m, const3_m, const1_m, \ + out1, out6, s0_m, s1_m); \ + \ + const0_m = __msa_fill_h(cospi_16_64); \ + const1_m = -const0_m; \ + const1_m = __msa_ilvev_h(const1_m, const0_m); \ + \ + ILV_H_LRLR_SH(in5, in2, s1_m, s0_m, \ + temp0_m, temp1_m, temp2_m, temp3_m); \ + \ + out3 = DOT_SHIFT_RIGHT_PCK_H(temp0_m, temp1_m, const0_m); \ + out4 = DOT_SHIFT_RIGHT_PCK_H(temp0_m, temp1_m, const1_m); \ + out2 = DOT_SHIFT_RIGHT_PCK_H(temp2_m, temp3_m, const0_m); \ + out5 = DOT_SHIFT_RIGHT_PCK_H(temp2_m, temp3_m, const1_m); \ + \ + out1 = -out1; \ + out3 = -out3; \ + out5 = -out5; \ +} + +void vp9_idct8x8_64_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + /* load vector elements of 8x8 block */ + LOAD_8VECS_SH(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + /* rows transform */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* columns transform */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H_4VECS_SH(in0, in1, in2, in3, in0, in1, in2, in3, 5); + SRARI_H_4VECS_SH(in4, in5, in6, in7, in4, in5, in6, in7, 5); + + /* add block and store 8x8 */ + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in0, in1, in2, in3); + dest += (4 * dest_stride); + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in4, in5, in6, in7); +} + +void vp9_idct8x8_12_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 s0, s1, s2, s3, s4, s5, s6, s7; + v8i16 k0, k1, k2, k3, m0, m1, m2, m3; + v4i32 tmp0, tmp1, tmp2, tmp3; + v8i16 zero = { 0 }; + + /* load vector elements of 8x8 block */ + LOAD_8VECS_SH(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + TRANSPOSE8X4_H(in0, in1, in2, in3, in0, in1, in2, in3); + + /* stage1 */ + s0 = __msa_ilvl_h(in3, in0); + s1 = __msa_ilvl_h(in2, in1); + + k0 = SET_COSPI_PAIR(cospi_28_64, -cospi_4_64); + k1 = SET_COSPI_PAIR(cospi_4_64, cospi_28_64); + k2 = SET_COSPI_PAIR(-cospi_20_64, cospi_12_64); + k3 = SET_COSPI_PAIR(cospi_12_64, cospi_20_64); + DOTP_S_W_4VECS_SW(s0, k0, s0, k1, s1, k2, s1, k3, tmp0, tmp1, tmp2, tmp3); + + SRARI_W_4VECS_SW(tmp0, tmp1, tmp2, tmp3, + tmp0, tmp1, tmp2, tmp3, DCT_CONST_BITS); + + PCKEV_H_2VECS_SH(zero, tmp0, zero, tmp1, s0, s1); + PCKEV_H_2VECS_SH(zero, tmp2, zero, tmp3, s2, s3); + + BUTTERFLY_4(s0, s1, s3, s2, s4, s7, s6, s5); + + /* stage2 */ + s0 = __msa_ilvr_h(in2, in0); + s1 = __msa_ilvr_h(in3, in1); + + k0 = SET_COSPI_PAIR(cospi_16_64, cospi_16_64); + k1 = SET_COSPI_PAIR(cospi_16_64, -cospi_16_64); + k2 = SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); + k3 = SET_COSPI_PAIR(cospi_8_64, cospi_24_64); + DOTP_S_W_4VECS_SW(s0, k0, s0, k1, s1, k2, s1, k3, tmp0, tmp1, tmp2, tmp3); + + SRARI_W_4VECS_SW(tmp0, tmp1, tmp2, tmp3, + tmp0, tmp1, tmp2, tmp3, DCT_CONST_BITS); + + PCKEV_H_2VECS_SH(zero, tmp0, zero, tmp1, s0, s1); + PCKEV_H_2VECS_SH(zero, tmp2, zero, tmp3, s2, s3); + + BUTTERFLY_4(s0, s1, s2, s3, m0, m1, m2, m3); + + /* stage3 */ + s0 = __msa_ilvr_h(s6, s5); + + k1 = SET_COSPI_PAIR(-cospi_16_64, cospi_16_64); + tmp0 = __msa_dotp_s_w(s0, k1); + tmp1 = __msa_dotp_s_w(s0, k0); + + tmp0 = __msa_srari_w(tmp0, DCT_CONST_BITS); + tmp1 = __msa_srari_w(tmp1, DCT_CONST_BITS); + + PCKEV_H_2VECS_SH(zero, tmp0, zero, tmp1, s2, s3); + + /* stage4 */ + BUTTERFLY_8(m0, m1, m2, m3, s4, s2, s3, s7, + in0, in1, in2, in3, in4, in5, in6, in7); + + TRANSPOSE4X8_H(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H_4VECS_SH(in0, in1, in2, in3, in0, in1, in2, in3, 5); + SRARI_H_4VECS_SH(in4, in5, in6, in7, in4, in5, in6, in7, 5); + + /* add block and store 8x8 */ + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in0, in1, in2, in3); + dest += (4 * dest_stride); + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in4, in5, in6, in7); +} + +void vp9_idct8x8_1_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride) { + int16_t out; + int32_t const1; + v8i16 const2; + + out = dct_const_round_shift(input[0] * cospi_16_64); + out = dct_const_round_shift(out * cospi_16_64); + const1 = ROUND_POWER_OF_TWO(out, 5); + const2 = __msa_fill_h(const1); + + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, + const2, const2, const2, const2); + dest += (4 * dest_stride); + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, + const2, const2, const2, const2); +} + +void vp9_iht8x8_64_add_msa(const int16_t *input, uint8_t *dest, + int32_t dest_stride, int32_t tx_type) { + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + /* load vector elements of 8x8 block */ + LOAD_8VECS_SH(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + switch (tx_type) { + case DCT_DCT: + /* DCT in horizontal */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* DCT in vertical */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + break; + case ADST_DCT: + /* DCT in horizontal */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* ADST in vertical */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + break; + case DCT_ADST: + /* ADST in horizontal */ + VP9_ADST8_ROW(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* DCT in vertical */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + break; + case ADST_ADST: + /* ADST in horizontal */ + VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* ADST in vertical */ + TRANSPOSE8x8_H_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + break; + default: + assert(0); + break; + } + + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H_4VECS_SH(in0, in1, in2, in3, in0, in1, in2, in3, 5); + SRARI_H_4VECS_SH(in4, in5, in6, in7, in4, in5, in6, in7, 5); + + /* add block and store 8x8 */ + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in0, in1, in2, in3); + dest += (4 * dest_stride); + VP9_ADDBLK_CLIP_AND_STORE_8_BYTES_4(dest, dest_stride, in4, in5, in6, in7); +} diff --git a/vp9/common/mips/msa/vp9_macros_msa.h b/vp9/common/mips/msa/vp9_macros_msa.h index 729273581..efe521490 100644 --- a/vp9/common/mips/msa/vp9_macros_msa.h +++ b/vp9/common/mips/msa/vp9_macros_msa.h @@ -358,6 +358,14 @@ src = (v16u8)__msa_insert_d((v2i64)(src), 1, (src1)); \ } +#define STORE_4VECS_SH(ptr, stride, \ + in0, in1, in2, in3) { \ + STORE_SH(in0, ((ptr) + 0 * stride)); \ + STORE_SH(in1, ((ptr) + 1 * stride)); \ + STORE_SH(in2, ((ptr) + 2 * stride)); \ + STORE_SH(in3, ((ptr) + 3 * stride)); \ +} + #define STORE_8VECS_SH(ptr, stride, \ in0, in1, in2, in3, \ in4, in5, in6, in7) { \ @@ -380,6 +388,44 @@ out_m; \ }) +#define TRANSPOSE4X8_H(in0, in1, in2, in3, \ + in4, in5, in6, in7, \ + out0, out1, out2, out3, \ + out4, out5, out6, out7) { \ + v8i16 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v8i16 tmp0_n, tmp1_n, tmp2_n, tmp3_n; \ + v8i16 zero_m = { 0 }; \ + \ + tmp0_n = __msa_ilvr_h((v8i16)(in1), (v8i16)(in0)); \ + tmp1_n = __msa_ilvr_h((v8i16)(in3), (v8i16)(in2)); \ + tmp2_n = __msa_ilvr_h((v8i16)(in5), (v8i16)(in4)); \ + tmp3_n = __msa_ilvr_h((v8i16)(in7), (v8i16)(in6)); \ + \ + ILV_W_LRLR_SH((tmp0_n), (tmp1_n), (tmp2_n), (tmp3_n), \ + tmp2_m, tmp0_m, tmp3_m, tmp1_m); \ + \ + out1 = (v8i16)__msa_ilvl_d((v2i64)tmp1_m, (v2i64)tmp0_m); \ + out0 = (v8i16)__msa_ilvr_d((v2i64)tmp1_m, (v2i64)tmp0_m); \ + out3 = (v8i16)__msa_ilvl_d((v2i64)tmp3_m, (v2i64)tmp2_m); \ + out2 = (v8i16)__msa_ilvr_d((v2i64)tmp3_m, (v2i64)tmp2_m); \ + \ + out4 = zero_m; \ + out5 = zero_m; \ + out6 = zero_m; \ + out7 = zero_m; \ +} + +#define TRANSPOSE8X4_H(in0, in1, in2, in3, \ + out0, out1, out2, out3) { \ + v8i16 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + ILV_H_LRLR_SH((in0), (in1), (in2), (in3), \ + tmp2_m, tmp0_m, tmp3_m, tmp1_m); \ + \ + ILV_W_LRLR_SH(tmp0_m, tmp1_m, tmp2_m, tmp3_m, \ + out1, out0, out3, out2); \ +} + /* halfword 8x8 transpose macro */ #define TRANSPOSE8x8_H_SH(in0, in1, in2, in3, \ in4, in5, in6, in7, \ @@ -437,6 +483,14 @@ out3 = __msa_ilvr_h((v8i16)(in3), (v8i16)(in2)); \ } +#define ILV_W_LRLR_SH(in0, in1, in2, in3, \ + out0, out1, out2, out3) { \ + out0 = (v8i16)__msa_ilvl_w((v4i32)(in1), (v4i32)(in0)); \ + out1 = (v8i16)__msa_ilvr_w((v4i32)(in1), (v4i32)(in0)); \ + out2 = (v8i16)__msa_ilvl_w((v4i32)(in3), (v4i32)(in2)); \ + out3 = (v8i16)__msa_ilvr_w((v4i32)(in3), (v4i32)(in2)); \ +} + #define ILV_H_LR_SH(in0, in1, out0, out1) { \ out0 = __msa_ilvl_h((v8i16)(in1), (v8i16)(in0)); \ out1 = __msa_ilvr_h((v8i16)(in1), (v8i16)(in0)); \ @@ -564,12 +618,29 @@ out3 = __msa_dotp_s_w((v8i16)(m3), (v8i16)(c3)); \ } +#define SPLATI_H_4VECS_SH(coeff, val0, val1, val2, val3, \ + out0, out1, out2, out3) { \ + out0 = __msa_splati_h((v8i16)(coeff), (val0)); \ + out1 = __msa_splati_h((v8i16)(coeff), (val1)); \ + out2 = __msa_splati_h((v8i16)(coeff), (val2)); \ + out3 = __msa_splati_h((v8i16)(coeff), (val3)); \ +} + #define PCKEV_H_2VECS_SH(in0_l, in0_r, in1_l, in1_r, \ out0, out1) { \ out0 = __msa_pckev_h((v8i16)(in0_l), (v8i16)(in0_r)); \ out1 = __msa_pckev_h((v8i16)(in1_l), (v8i16)(in1_r)); \ } +#define PCKEV_H_4VECS_SH(in0_l, in0_r, in1_l, in1_r, \ + in2_l, in2_r, in3_l, in3_r, \ + out0, out1, out2, out3) { \ + out0 = __msa_pckev_h((v8i16)(in0_l), (v8i16)(in0_r)); \ + out1 = __msa_pckev_h((v8i16)(in1_l), (v8i16)(in1_r)); \ + out2 = __msa_pckev_h((v8i16)(in2_l), (v8i16)(in2_r)); \ + out3 = __msa_pckev_h((v8i16)(in3_l), (v8i16)(in3_r)); \ +} + #define XORI_B_2VECS_UB(val0, val1, \ out0, out1, xor_val) { \ out0 = __msa_xori_b((v16u8)(val0), (xor_val)); \ diff --git a/vp9/common/vp9_common.h b/vp9/common/vp9_common.h index d06b8e040..9c2d7791e 100644 --- a/vp9/common/vp9_common.h +++ b/vp9/common/vp9_common.h @@ -27,12 +27,6 @@ extern "C" { #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define MAX(x, y) (((x) > (y)) ? (x) : (y)) -#define ROUND_POWER_OF_TWO(value, n) \ - (((value) + (1 << ((n) - 1))) >> (n)) - -#define ALIGN_POWER_OF_TWO(value, n) \ - (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1)) - // Only need this for fixed-size arrays, for structs just assign. #define vp9_copy(dest, src) { \ assert(sizeof(dest) == sizeof(src)); \ @@ -83,9 +77,6 @@ static INLINE uint16_t clip_pixel_highbd(int val, int bd) { typedef int64_t tran_high_t; typedef int32_t tran_low_t; -#define CONVERT_TO_SHORTPTR(x) ((uint16_t*)(((uintptr_t)x) << 1)) -#define CONVERT_TO_BYTEPTR(x) ((uint8_t*)(((uintptr_t)x) >> 1 )) - #else // Note: diff --git a/vp9/common/vp9_idct.c b/vp9/common/vp9_idct.c index 3b214371c..174b96e21 100644 --- a/vp9/common/vp9_idct.c +++ b/vp9/common/vp9_idct.c @@ -11,6 +11,7 @@ #include <math.h> #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" #include "vp9/common/vp9_systemdependent.h" diff --git a/vp9/common/vp9_idct.h b/vp9/common/vp9_idct.h index 6e2551dd4..cee1682a6 100644 --- a/vp9/common/vp9_idct.h +++ b/vp9/common/vp9_idct.h @@ -14,6 +14,7 @@ #include <assert.h> #include "./vpx_config.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_enums.h" diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index 69d393ef4..484e457df 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -13,6 +13,7 @@ #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_reconinter.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_seg_common.h" diff --git a/vp9/common/vp9_loopfilter_filters.c b/vp9/common/vp9_loopfilter_filters.c index 2e32c40b8..3cf4c3225 100644 --- a/vp9/common/vp9_loopfilter_filters.c +++ b/vp9/common/vp9_loopfilter_filters.c @@ -9,6 +9,7 @@ */ #include "./vpx_config.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_loopfilter.h" #include "vp9/common/vp9_onyxc_int.h" diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 6b4a2eed7..5179c6906 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -380,7 +380,8 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, xd->left_available = (mi_col > tile->mi_col_start); if (xd->up_available) { xd->above_mi = xd->mi[-xd->mi_stride]; - xd->above_mbmi = &xd->above_mi->mbmi; + // above_mi may be NULL in VP9 encoder's first pass. + xd->above_mbmi = xd->above_mi ? &xd->above_mi->mbmi : NULL; } else { xd->above_mi = NULL; xd->above_mbmi = NULL; @@ -388,7 +389,8 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, if (xd->left_available) { xd->left_mi = xd->mi[-1]; - xd->left_mbmi = &xd->left_mi->mbmi; + // left_mi may be NULL in VP9 encoder's first pass. + xd->left_mbmi = xd->left_mi ? &xd->left_mi->mbmi : NULL; } else { xd->left_mi = NULL; xd->left_mbmi = NULL; diff --git a/vp9/common/vp9_postproc.c b/vp9/common/vp9_postproc.c index 983a4744d..d26a6eb5c 100644 --- a/vp9/common/vp9_postproc.c +++ b/vp9/common/vp9_postproc.c @@ -16,12 +16,10 @@ #include "./vpx_scale_rtcd.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vpx_scale/vpx_scale.h" #include "vpx_scale/yv12config.h" -#if CONFIG_VP9_HIGHBITDEPTH -#include "vp9/common/vp9_common.h" -#endif #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_postproc.h" #include "vp9/common/vp9_systemdependent.h" diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c index 11dd3f325..650310d7d 100644 --- a/vp9/common/vp9_reconintra.c +++ b/vp9/common/vp9_reconintra.c @@ -12,6 +12,7 @@ #include "./vp9_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vpx_ports/vpx_once.h" #include "vp9/common/vp9_reconintra.h" @@ -657,8 +658,8 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd, int i; uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); uint16_t *ref = CONVERT_TO_SHORTPTR(ref8); - DECLARE_ALIGNED(16, uint16_t, left_col[64]); - DECLARE_ALIGNED(16, uint16_t, above_data[128 + 16]); + DECLARE_ALIGNED(16, uint16_t, left_col[32]); + DECLARE_ALIGNED(16, uint16_t, above_data[64 + 16]); uint16_t *above_row = above_data + 16; const uint16_t *const_above_row = above_row; const int bs = 4 << tx_size; @@ -780,8 +781,8 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, int right_available, int x, int y, int plane) { int i; - DECLARE_ALIGNED(16, uint8_t, left_col[64]); - DECLARE_ALIGNED(16, uint8_t, above_data[128 + 16]); + DECLARE_ALIGNED(16, uint8_t, left_col[32]); + DECLARE_ALIGNED(16, uint8_t, above_data[64 + 16]); uint8_t *above_row = above_data + 16; const uint8_t *const_above_row = above_row; const int bs = 4 << tx_size; diff --git a/vp9/common/vp9_rtcd_defs.pl b/vp9/common/vp9_rtcd_defs.pl index d09902345..c8169fd3b 100644 --- a/vp9/common/vp9_rtcd_defs.pl +++ b/vp9/common/vp9_rtcd_defs.pl @@ -168,7 +168,7 @@ add_proto qw/void vp9_dc_top_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride specialize qw/vp9_dc_top_predictor_16x16/, "$sse2_x86inc"; add_proto qw/void vp9_dc_left_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; -specialize qw/vp9_dc_left_predictor_16x16/; +specialize qw/vp9_dc_left_predictor_16x16/, "$sse2_x86inc"; add_proto qw/void vp9_dc_128_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_128_predictor_16x16/, "$sse2_x86inc"; @@ -204,13 +204,13 @@ add_proto qw/void vp9_dc_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, co specialize qw/vp9_dc_predictor_32x32/, "$sse2_x86inc"; add_proto qw/void vp9_dc_top_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; -specialize qw/vp9_dc_top_predictor_32x32/; +specialize qw/vp9_dc_top_predictor_32x32/, "$sse2_x86inc"; add_proto qw/void vp9_dc_left_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; -specialize qw/vp9_dc_left_predictor_32x32/; +specialize qw/vp9_dc_left_predictor_32x32/, "$sse2_x86inc"; add_proto qw/void vp9_dc_128_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; -specialize qw/vp9_dc_128_predictor_32x32/; +specialize qw/vp9_dc_128_predictor_32x32/, "$sse2_x86inc"; # # Loopfilter @@ -425,13 +425,13 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { specialize qw/vp9_idct4x4_16_add sse2 neon dspr2/; add_proto qw/void vp9_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct8x8_1_add sse2 neon dspr2/; + specialize qw/vp9_idct8x8_1_add sse2 neon dspr2 msa/; add_proto qw/void vp9_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct8x8_64_add sse2 neon dspr2/, "$ssse3_x86_64"; + specialize qw/vp9_idct8x8_64_add sse2 neon dspr2 msa/, "$ssse3_x86_64"; add_proto qw/void vp9_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct8x8_12_add sse2 neon dspr2/, "$ssse3_x86_64"; + specialize qw/vp9_idct8x8_12_add sse2 neon dspr2 msa/, "$ssse3_x86_64"; add_proto qw/void vp9_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_1_add sse2 neon dspr2 msa/; @@ -443,21 +443,21 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { specialize qw/vp9_idct16x16_10_add sse2 neon dspr2 msa/; add_proto qw/void vp9_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct32x32_1024_add sse2 neon dspr2/; + specialize qw/vp9_idct32x32_1024_add sse2 neon dspr2 msa/; add_proto qw/void vp9_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct32x32_34_add sse2 neon_asm dspr2/; + specialize qw/vp9_idct32x32_34_add sse2 neon_asm dspr2 msa/; #is this a typo? $vp9_idct32x32_34_add_neon_asm=vp9_idct32x32_1024_add_neon; add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; - specialize qw/vp9_idct32x32_1_add sse2 neon dspr2/; + specialize qw/vp9_idct32x32_1_add sse2 neon dspr2 msa/; add_proto qw/void vp9_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht4x4_16_add sse2 neon dspr2/; add_proto qw/void vp9_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; - specialize qw/vp9_iht8x8_64_add sse2 neon dspr2/; + specialize qw/vp9_iht8x8_64_add sse2 neon dspr2 msa/; add_proto qw/void vp9_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type"; specialize qw/vp9_iht16x16_256_add sse2 dspr2 msa/; diff --git a/vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c b/vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c index 1637f0e54..b40669c63 100644 --- a/vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c +++ b/vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c @@ -11,6 +11,7 @@ #include <emmintrin.h> // SSE2 #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_loopfilter.h" #include "vpx_ports/emmintrin_compat.h" diff --git a/vp9/common/x86/vp9_idct_intrin_sse2.c b/vp9/common/x86/vp9_idct_intrin_sse2.c index 0385c7955..6ad7c6294 100644 --- a/vp9/common/x86/vp9_idct_intrin_sse2.c +++ b/vp9/common/x86/vp9_idct_intrin_sse2.c @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "vpx_ports/mem.h" #include "vp9/common/x86/vp9_idct_intrin_sse2.h" #include "vp9/common/vp9_idct.h" diff --git a/vp9/common/x86/vp9_intrapred_sse2.asm b/vp9/common/x86/vp9_intrapred_sse2.asm index 92ac49100..22b573188 100644 --- a/vp9/common/x86/vp9_intrapred_sse2.asm +++ b/vp9/common/x86/vp9_intrapred_sse2.asm @@ -19,6 +19,7 @@ dc_128: times 16 db 128 pw2_4: times 8 dw 2 pw2_8: times 8 dw 4 pw2_16: times 8 dw 8 +pw2_32: times 8 dw 16 SECTION .text @@ -262,6 +263,37 @@ cglobal dc_top_predictor_16x16, 4, 5, 3, dst, stride, above, left, goffset RESTORE_GOT REP_RET +INIT_XMM sse2 +cglobal dc_left_predictor_16x16, 4, 5, 3, dst, stride, above, left, goffset + GET_GOT goffsetq + + pxor m1, m1 + pxor m2, m2 + mova m0, [leftq] + DEFINE_ARGS dst, stride, stride3, lines4 + lea stride3q, [strideq*3] + mov lines4d, 4 + psadbw m0, m1 + psadbw m2, m1 + paddw m0, m2 + movhlps m2, m0 + paddw m0, m2 + paddw m0, [GLOBAL(pw2_16)] + psraw m0, 4 + pshuflw m0, m0, 0x0 + punpcklqdq m0, m0 + packuswb m0, m0 +.loop: + mova [dstq ], m0 + mova [dstq+strideq ], m0 + mova [dstq+strideq*2], m0 + mova [dstq+stride3q ], m0 + lea dstq, [dstq+strideq*4] + dec lines4d + jnz .loop + + RESTORE_GOT + REP_RET INIT_XMM sse2 cglobal dc_128_predictor_16x16, 4, 5, 3, dst, stride, above, left, goffset @@ -325,6 +357,101 @@ cglobal dc_predictor_32x32, 4, 5, 5, dst, stride, above, left, goffset RESTORE_GOT REP_RET +INIT_XMM sse2 +cglobal dc_top_predictor_32x32, 4, 5, 5, dst, stride, above, left, goffset + GET_GOT goffsetq + + pxor m1, m1 + mova m0, [aboveq] + mova m2, [aboveq+16] + DEFINE_ARGS dst, stride, stride3, lines4 + lea stride3q, [strideq*3] + mov lines4d, 8 + psadbw m0, m1 + psadbw m2, m1 + paddw m0, m2 + movhlps m2, m0 + paddw m0, m2 + paddw m0, [GLOBAL(pw2_32)] + psraw m0, 5 + pshuflw m0, m0, 0x0 + punpcklqdq m0, m0 + packuswb m0, m0 +.loop: + mova [dstq ], m0 + mova [dstq +16], m0 + mova [dstq+strideq ], m0 + mova [dstq+strideq +16], m0 + mova [dstq+strideq*2 ], m0 + mova [dstq+strideq*2+16], m0 + mova [dstq+stride3q ], m0 + mova [dstq+stride3q +16], m0 + lea dstq, [dstq+strideq*4] + dec lines4d + jnz .loop + + RESTORE_GOT + REP_RET + +INIT_XMM sse2 +cglobal dc_left_predictor_32x32, 4, 5, 5, dst, stride, above, left, goffset + GET_GOT goffsetq + + pxor m1, m1 + mova m0, [leftq] + mova m2, [leftq+16] + DEFINE_ARGS dst, stride, stride3, lines4 + lea stride3q, [strideq*3] + mov lines4d, 8 + psadbw m0, m1 + psadbw m2, m1 + paddw m0, m2 + movhlps m2, m0 + paddw m0, m2 + paddw m0, [GLOBAL(pw2_32)] + psraw m0, 5 + pshuflw m0, m0, 0x0 + punpcklqdq m0, m0 + packuswb m0, m0 +.loop: + mova [dstq ], m0 + mova [dstq +16], m0 + mova [dstq+strideq ], m0 + mova [dstq+strideq +16], m0 + mova [dstq+strideq*2 ], m0 + mova [dstq+strideq*2+16], m0 + mova [dstq+stride3q ], m0 + mova [dstq+stride3q +16], m0 + lea dstq, [dstq+strideq*4] + dec lines4d + jnz .loop + + RESTORE_GOT + REP_RET + +INIT_XMM sse2 +cglobal dc_128_predictor_32x32, 4, 5, 3, dst, stride, above, left, goffset + GET_GOT goffsetq + + DEFINE_ARGS dst, stride, stride3, lines4 + lea stride3q, [strideq*3] + mov lines4d, 8 + mova m0, [GLOBAL(dc_128)] +.loop: + mova [dstq ], m0 + mova [dstq +16], m0 + mova [dstq+strideq ], m0 + mova [dstq+strideq +16], m0 + mova [dstq+strideq*2 ], m0 + mova [dstq+strideq*2+16], m0 + mova [dstq+stride3q ], m0 + mova [dstq+stride3q +16], m0 + lea dstq, [dstq+strideq*4] + dec lines4d + jnz .loop + RESTORE_GOT + RET + INIT_MMX sse cglobal v_predictor_4x4, 3, 3, 1, dst, stride, above movd m0, [aboveq] diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 94ba3fe4f..492ded4fb 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -15,6 +15,7 @@ #include "./vpx_scale_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vpx_ports/mem_ops.h" #include "vpx_scale/vpx_scale.h" @@ -1311,8 +1312,8 @@ static void read_bitdepth_colorspace_sampling( static size_t read_uncompressed_header(VP9Decoder *pbi, struct vp9_read_bit_buffer *rb) { VP9_COMMON *const cm = &pbi->common; - RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs; - BufferPool *const pool = pbi->common.buffer_pool; + BufferPool *const pool = cm->buffer_pool; + RefCntBuffer *const frame_bufs = pool->frame_bufs; int i, mask, ref_index = 0; size_t sz; @@ -1997,7 +1998,7 @@ void dec_build_inter_predictors(VP9Decoder *const pbi, MACROBLOCKD *xd, // Wait until reference block is ready. Pad 7 more pixels as last 7 // pixels of each superblock row can be changed by next superblock row. if (pbi->frame_parallel_decode) { - const int y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1; + const int y1 = (y0_16 + (h - 1) * ys) >> SUBPEL_BITS; vp9_frameworker_wait(pbi->frame_worker_owner, ref_frame_buf, MAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1)); } diff --git a/vp9/encoder/vp9_aq_variance.c b/vp9/encoder/vp9_aq_variance.c index be6f7e4ee..55c964903 100644 --- a/vp9/encoder/vp9_aq_variance.c +++ b/vp9/encoder/vp9_aq_variance.c @@ -10,6 +10,8 @@ #include <math.h> +#include "vpx_ports/mem.h" + #include "vp9/encoder/vp9_aq_variance.h" #include "vp9/common/vp9_seg_common.h" diff --git a/vp9/encoder/vp9_dct.c b/vp9/encoder/vp9_dct.c index 9e6ca3d59..414d2bb15 100644 --- a/vp9/encoder/vp9_dct.c +++ b/vp9/encoder/vp9_dct.c @@ -14,6 +14,7 @@ #include "./vpx_config.h" #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_idct.h" #include "vp9/common/vp9_systemdependent.h" diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 0e74784e9..3c490f837 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -15,6 +15,7 @@ #include "./vp9_rtcd.h" #include "./vpx_config.h" +#include "vpx_ports/mem.h" #include "vpx_ports/vpx_timer.h" #include "vp9/common/vp9_common.h" diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 9a4e61ec8..b115e0ef9 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_idct.h" #include "vp9/common/vp9_reconinter.h" diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index a1018adb8..4f5f8f3eb 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -17,6 +17,7 @@ #include "./vpx_dsp_rtcd.h" #include "./vpx_scale_rtcd.h" #include "vpx/internal/vpx_psnr.h" +#include "vpx_ports/mem.h" #include "vpx_ports/vpx_timer.h" #include "vp9/common/vp9_alloccommon.h" @@ -685,6 +686,27 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) { vp9_setup_pc_tree(&cpi->common, &cpi->td); } +void vp9_new_framerate(VP9_COMP *cpi, double framerate) { + cpi->framerate = framerate < 0.1 ? 30 : framerate; + vp9_rc_update_framerate(cpi); +} + +static void set_tile_limits(VP9_COMP *cpi) { + VP9_COMMON *const cm = &cpi->common; + + int min_log2_tile_cols, max_log2_tile_cols; + vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); + + if (is_two_pass_svc(cpi) && cpi->svc.encode_empty_frame_state == ENCODING) { + cm->log2_tile_cols = 0; + cm->log2_tile_rows = 0; + } else { + cm->log2_tile_cols = clamp(cpi->oxcf.tile_columns, + min_log2_tile_cols, max_log2_tile_cols); + cm->log2_tile_rows = cpi->oxcf.tile_rows; + } +} + static void update_frame_size(VP9_COMP *cpi) { VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; @@ -693,6 +715,8 @@ static void update_frame_size(VP9_COMP *cpi) { vp9_init_context_buffers(cm); init_macroblockd(cm, xd); + set_tile_limits(cpi); + if (is_two_pass_svc(cpi)) { if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, cm->width, cm->height, @@ -707,27 +731,6 @@ static void update_frame_size(VP9_COMP *cpi) { } } -void vp9_new_framerate(VP9_COMP *cpi, double framerate) { - cpi->framerate = framerate < 0.1 ? 30 : framerate; - vp9_rc_update_framerate(cpi); -} - -static void set_tile_limits(VP9_COMP *cpi) { - VP9_COMMON *const cm = &cpi->common; - - int min_log2_tile_cols, max_log2_tile_cols; - vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); - - if (is_two_pass_svc(cpi) && cpi->svc.encode_empty_frame_state == ENCODING) { - cm->log2_tile_cols = 0; - cm->log2_tile_rows = 0; - } else { - cm->log2_tile_cols = clamp(cpi->oxcf.tile_columns, - min_log2_tile_cols, max_log2_tile_cols); - cm->log2_tile_rows = cpi->oxcf.tile_rows; - } -} - static void init_buffer_indices(VP9_COMP *cpi) { cpi->lst_fb_idx = 0; cpi->gld_fb_idx = 1; @@ -4180,7 +4183,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, vp9_clear_system_state(); #if CONFIG_VP9_HIGHBITDEPTH - calc_highbd_psnr(orig, pp, &psnr, cpi->td.mb.e_mbd.bd, + calc_highbd_psnr(orig, pp, &psnr2, cpi->td.mb.e_mbd.bd, cpi->oxcf.input_bit_depth); #else calc_psnr(orig, pp, &psnr2); @@ -4231,31 +4234,38 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } } if (cpi->b_calculate_blockiness) { - double frame_blockiness = vp9_get_blockiness( - cpi->Source->y_buffer, cpi->Source->y_stride, - cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride, - cpi->Source->y_width, cpi->Source->y_height); - cpi->worst_blockiness = MAX(cpi->worst_blockiness, frame_blockiness); - cpi->total_blockiness += frame_blockiness; +#if CONFIG_VP9_HIGHBITDEPTH + if (!cm->use_highbitdepth) +#endif + { + double frame_blockiness = vp9_get_blockiness( + cpi->Source->y_buffer, cpi->Source->y_stride, + cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride, + cpi->Source->y_width, cpi->Source->y_height); + cpi->worst_blockiness = MAX(cpi->worst_blockiness, frame_blockiness); + cpi->total_blockiness += frame_blockiness; + } } if (cpi->b_calculate_consistency) { - double this_inconsistency = vp9_get_ssim_metrics( - cpi->Source->y_buffer, cpi->Source->y_stride, - cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride, - cpi->Source->y_width, cpi->Source->y_height, cpi->ssim_vars, - &cpi->metrics, 1); - - const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1); - - - double consistency = vpx_sse_to_psnr(samples, peak, +#if CONFIG_VP9_HIGHBITDEPTH + if (!cm->use_highbitdepth) +#endif + { + double this_inconsistency = vp9_get_ssim_metrics( + cpi->Source->y_buffer, cpi->Source->y_stride, + cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride, + cpi->Source->y_width, cpi->Source->y_height, cpi->ssim_vars, + &cpi->metrics, 1); + + const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1); + double consistency = vpx_sse_to_psnr(samples, peak, (double)cpi->total_inconsistency); - - if (consistency > 0.0) - cpi->worst_consistency = MIN(cpi->worst_consistency, - consistency); - cpi->total_inconsistency += this_inconsistency; + if (consistency > 0.0) + cpi->worst_consistency = MIN(cpi->worst_consistency, + consistency); + cpi->total_inconsistency += this_inconsistency; + } } if (cpi->b_calculate_ssimg) { @@ -4273,6 +4283,9 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, #endif // CONFIG_VP9_HIGHBITDEPTH adjust_image_stat(y, u, v, frame_all, &cpi->ssimg); } +#if CONFIG_VP9_HIGHBITDEPTH + if (!cm->use_highbitdepth) +#endif { double y, u, v, frame_all; frame_all = vp9_calc_fastssim(cpi->Source, cm->frame_to_show, &y, &u, @@ -4280,6 +4293,9 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, adjust_image_stat(y, u, v, frame_all, &cpi->fastssim); /* TODO(JBB): add 10/12 bit support */ } +#if CONFIG_VP9_HIGHBITDEPTH + if (!cm->use_highbitdepth) +#endif { double y, u, v, frame_all; frame_all = vp9_psnrhvs(cpi->Source, cm->frame_to_show, &y, &u, &v); diff --git a/vp9/encoder/vp9_extend.c b/vp9/encoder/vp9_extend.c index 96f3598b1..6e1ed365d 100644 --- a/vp9/encoder/vp9_extend.c +++ b/vp9/encoder/vp9_extend.c @@ -9,6 +9,7 @@ */ #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/encoder/vp9_extend.h" diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 9752668b1..9da4fc484 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -15,6 +15,7 @@ #include "./vpx_scale_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vpx_scale/vpx_scale.h" #include "vpx_scale/yv12config.h" diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 80c509a1b..8bdd4286a 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -15,6 +15,7 @@ #include "./vpx_config.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c index 5eb5d542b..8e1910385 100644 --- a/vp9/encoder/vp9_picklpf.c +++ b/vp9/encoder/vp9_picklpf.c @@ -14,6 +14,7 @@ #include "./vpx_scale_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_loopfilter.h" #include "vp9/common/vp9_onyxc_int.h" diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 9fb7cfba7..1e917159f 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -16,6 +16,7 @@ #include "./vp9_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_common.h" @@ -1594,7 +1595,6 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, if (cpi->sf.adaptive_rd_thresh) { THR_MODES best_mode_idx = mode_idx[best_ref_frame][mode_offset(mbmi->mode)]; - PREDICTION_MODE this_mode; if (best_ref_frame == INTRA_FRAME) { // Only consider the modes that are included in the intra_mode_list. @@ -1604,12 +1604,12 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, // TODO(yunqingwang): Check intra mode mask and only update freq_fact // for those valid modes. for (i = 0; i < intra_modes; i++) { - PREDICTION_MODE this_mode = intra_mode_list[i]; update_thresh_freq_fact(cpi, tile_data, bsize, INTRA_FRAME, - best_mode_idx, this_mode); + best_mode_idx, intra_mode_list[i]); } } else { for (ref_frame = LAST_FRAME; ref_frame <= GOLDEN_FRAME; ++ref_frame) { + PREDICTION_MODE this_mode; if (best_ref_frame != ref_frame) continue; for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) { update_thresh_freq_fact(cpi, tile_data, bsize, ref_frame, diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c index 3c07e2c24..db5460b6c 100644 --- a/vp9/encoder/vp9_quantize.c +++ b/vp9/encoder/vp9_quantize.c @@ -11,6 +11,7 @@ #include <math.h> #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_quant_common.h" #include "vp9/common/vp9_seg_common.h" diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 4c33ffd97..47932db20 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -16,6 +16,7 @@ #include <string.h> #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_alloccommon.h" #include "vp9/encoder/vp9_aq_cyclicrefresh.h" @@ -491,7 +492,10 @@ int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame, i = active_best_quality; do { - if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) { + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && + cm->seg.enabled && + cpi->svc.temporal_layer_id == 0 && + cpi->svc.spatial_layer_id == 0) { bits_per_mb_at_this_q = (int)vp9_cyclic_refresh_rc_bits_per_mb(cpi, i, correction_factor); } else { diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index 194001c51..9fa7b9d67 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -15,6 +15,7 @@ #include "./vp9_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_entropy.h" diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 738256237..6eb8f6cb5 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -14,6 +14,7 @@ #include "./vp9_rtcd.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_entropy.h" diff --git a/vp9/encoder/vp9_resize.c b/vp9/encoder/vp9_resize.c index 2ebdff291..a3cf954e3 100644 --- a/vp9/encoder/vp9_resize.c +++ b/vp9/encoder/vp9_resize.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include <string.h> +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/encoder/vp9_resize.h" diff --git a/vp9/encoder/vp9_ssim.c b/vp9/encoder/vp9_ssim.c index 88db5dda0..172de5d1d 100644 --- a/vp9/encoder/vp9_ssim.c +++ b/vp9/encoder/vp9_ssim.c @@ -10,6 +10,7 @@ #include <math.h> #include "./vp9_rtcd.h" +#include "vpx_ports/mem.h" #include "vp9/encoder/vp9_ssim.h" void vp9_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r, diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index d7979ab53..0fe531217 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -24,6 +24,7 @@ #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_segmentation.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vpx_ports/vpx_timer.h" #include "vpx_scale/vpx_scale.h" diff --git a/vp9/encoder/x86/vp9_highbd_quantize_intrin_sse2.c b/vp9/encoder/x86/vp9_highbd_quantize_intrin_sse2.c index ffa43b65a..cbdd1c93e 100644 --- a/vp9/encoder/x86/vp9_highbd_quantize_intrin_sse2.c +++ b/vp9/encoder/x86/vp9_highbd_quantize_intrin_sse2.c @@ -10,6 +10,7 @@ #include <emmintrin.h> +#include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #if CONFIG_VP9_HIGHBITDEPTH diff --git a/vp9/vp9_common.mk b/vp9/vp9_common.mk index f1702c955..f629d98b8 100644 --- a/vp9/vp9_common.mk +++ b/vp9/vp9_common.mk @@ -137,7 +137,9 @@ VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_convolve8_vert_msa.c VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_convolve_avg_msa.c VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_convolve_copy_msa.c VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_convolve_msa.h +VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_idct8x8_msa.c VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_idct16x16_msa.c +VP9_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/vp9_idct32x32_msa.c VP9_COMMON_SRCS-$(HAVE_SSE2) += common/x86/vp9_idct_intrin_sse2.c VP9_COMMON_SRCS-$(HAVE_SSE2) += common/x86/vp9_idct_intrin_sse2.h diff --git a/vp9/vp9_iface_common.h b/vp9/vp9_iface_common.h index e585aa147..58bb7d5d6 100644 --- a/vp9/vp9_iface_common.h +++ b/vp9/vp9_iface_common.h @@ -10,6 +10,8 @@ #ifndef VP9_VP9_IFACE_COMMON_H_ #define VP9_VP9_IFACE_COMMON_H_ +#include "vpx_ports/mem.h" + static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12, void *user_priv) { /** vpx_img_wrap() doesn't allow specifying independent strides for diff --git a/vpx/vpx_codec.mk b/vpx/vpx_codec.mk index a1ad3c531..ccdef040c 100644 --- a/vpx/vpx_codec.mk +++ b/vpx/vpx_codec.mk @@ -31,17 +31,17 @@ API_DOC_SRCS-yes += vpx_encoder.h API_DOC_SRCS-yes += vpx_frame_buffer.h API_DOC_SRCS-yes += vpx_image.h -API_SRCS-yes += src/vpx_decoder.c -API_SRCS-yes += vpx_decoder.h -API_SRCS-yes += src/vpx_encoder.c -API_SRCS-yes += vpx_encoder.h -API_SRCS-yes += internal/vpx_codec_internal.h -API_SRCS-yes += internal/vpx_psnr.h -API_SRCS-yes += src/vpx_codec.c -API_SRCS-yes += src/vpx_image.c -API_SRCS-yes += src/vpx_psnr.c -API_SRCS-yes += vpx_codec.h -API_SRCS-yes += vpx_codec.mk -API_SRCS-yes += vpx_frame_buffer.h -API_SRCS-yes += vpx_image.h -API_SRCS-$(BUILD_LIBVPX) += vpx_integer.h +API_SRCS-yes += src/vpx_decoder.c +API_SRCS-yes += vpx_decoder.h +API_SRCS-yes += src/vpx_encoder.c +API_SRCS-yes += vpx_encoder.h +API_SRCS-yes += internal/vpx_codec_internal.h +API_SRCS-yes += internal/vpx_psnr.h +API_SRCS-yes += src/vpx_codec.c +API_SRCS-yes += src/vpx_image.c +API_SRCS-yes += src/vpx_psnr.c +API_SRCS-yes += vpx_codec.h +API_SRCS-yes += vpx_codec.mk +API_SRCS-yes += vpx_frame_buffer.h +API_SRCS-yes += vpx_image.h +API_SRCS-yes += vpx_integer.h diff --git a/vpx_dsp/sad.c b/vpx_dsp/sad.c index 9db312fbe..9783e4363 100644 --- a/vpx_dsp/sad.c +++ b/vpx_dsp/sad.c @@ -14,13 +14,7 @@ #include "./vpx_dsp_rtcd.h" #include "vpx/vpx_integer.h" - -#if CONFIG_VP9_HIGHBITDEPTH -#include "vp9/common/vp9_common.h" -#endif // CONFIG_VP9_HIGHBITDEPTH -// Temporary ... -#define ROUND_POWER_OF_TWO(value, n) \ - (((value) + (1 << ((n) - 1))) >> (n)) +#include "vpx_ports/mem.h" /* Sum the difference between every corresponding element of the buffers. */ static INLINE unsigned int sad(const uint8_t *a, int a_stride, diff --git a/vpx_ports/mem.h b/vpx_ports/mem.h index 0106a45d6..7502f9063 100644 --- a/vpx_ports/mem.h +++ b/vpx_ports/mem.h @@ -38,4 +38,16 @@ #define __builtin_prefetch(x) #endif +/* Shift down with rounding */ +#define ROUND_POWER_OF_TWO(value, n) \ + (((value) + (1 << ((n) - 1))) >> (n)) + +#define ALIGN_POWER_OF_TWO(value, n) \ + (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1)) + +#if CONFIG_VP9_HIGHBITDEPTH +#define CONVERT_TO_SHORTPTR(x) ((uint16_t*)(((uintptr_t)x) << 1)) +#define CONVERT_TO_BYTEPTR(x) ((uint8_t*)(((uintptr_t)x) >> 1)) +#endif // CONFIG_VP9_HIGHBITDEPTH + #endif // VPX_PORTS_MEM_H_ diff --git a/vpx_ports/vpx_ports.mk b/vpx_ports/vpx_ports.mk index a7275431f..dfc75ab6f 100644 --- a/vpx_ports/vpx_ports.mk +++ b/vpx_ports/vpx_ports.mk @@ -11,13 +11,13 @@ PORTS_SRCS-yes += vpx_ports.mk -PORTS_SRCS-$(BUILD_LIBVPX) += mem.h -PORTS_SRCS-$(BUILD_LIBVPX) += vpx_timer.h +PORTS_SRCS-yes += mem.h +PORTS_SRCS-yes += vpx_timer.h ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) -PORTS_SRCS-$(BUILD_LIBVPX) += emms.asm -PORTS_SRCS-$(BUILD_LIBVPX) += x86.h -PORTS_SRCS-$(BUILD_LIBVPX) += x86_abi_support.asm +PORTS_SRCS-yes += emms.asm +PORTS_SRCS-yes += x86.h +PORTS_SRCS-yes += x86_abi_support.asm endif PORTS_SRCS-$(ARCH_ARM) += arm_cpudetect.c diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index 169c2ab2d..7582792d9 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -12,9 +12,7 @@ #include "vpx_scale/yv12config.h" #include "vpx_mem/vpx_mem.h" -#if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH -#include "vp9/common/vp9_common.h" -#endif +#include "vpx_ports/mem.h" /**************************************************************************** * Exports diff --git a/vpx_scale/generic/yv12extend.c b/vpx_scale/generic/yv12extend.c index 6214a1218..13ee3e99f 100644 --- a/vpx_scale/generic/yv12extend.c +++ b/vpx_scale/generic/yv12extend.c @@ -12,6 +12,7 @@ #include "./vpx_config.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" +#include "vpx_ports/mem.h" #include "vpx_scale/yv12config.h" #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH #include "vp9/common/vp9_common.h" @@ -169,7 +169,7 @@ static INLINE int libyuv_scale(vpx_image_t *src, vpx_image_t *dst, } #endif -void usage_exit() { +void usage_exit(void) { int i; fprintf(stderr, "Usage: %s <options> filename\n\n" @@ -312,7 +312,7 @@ static void write_image_file(const vpx_image_t *img, const int planes[3], } } -int file_is_raw(struct VpxInputContext *input) { +static int file_is_raw(struct VpxInputContext *input) { uint8_t buf[32]; int is_raw = 0; vpx_codec_stream_info_t si; @@ -343,7 +343,7 @@ int file_is_raw(struct VpxInputContext *input) { return is_raw; } -void show_progress(int frame_in, int frame_out, uint64_t dx_time) { +static void show_progress(int frame_in, int frame_out, uint64_t dx_time) { fprintf(stderr, "%d decoded frames/%d showed frames in %"PRId64" us (%.2f fps)\r", frame_in, frame_out, dx_time, @@ -365,8 +365,8 @@ struct ExternalFrameBufferList { // Application private data passed into the set function. |min_size| is the // minimum size in bytes needed to decode the next frame. |fb| pointer to the // frame buffer. -int get_vp9_frame_buffer(void *cb_priv, size_t min_size, - vpx_codec_frame_buffer_t *fb) { +static int get_vp9_frame_buffer(void *cb_priv, size_t min_size, + vpx_codec_frame_buffer_t *fb) { int i; struct ExternalFrameBufferList *const ext_fb_list = (struct ExternalFrameBufferList *)cb_priv; @@ -403,8 +403,8 @@ int get_vp9_frame_buffer(void *cb_priv, size_t min_size, // Callback used by libvpx when there are no references to the frame buffer. // |cb_priv| user private data passed into the set function. |fb| pointer // to the frame buffer. -int release_vp9_frame_buffer(void *cb_priv, - vpx_codec_frame_buffer_t *fb) { +static int release_vp9_frame_buffer(void *cb_priv, + vpx_codec_frame_buffer_t *fb) { struct ExternalFrameBuffer *const ext_fb = (struct ExternalFrameBuffer *)fb->priv; (void)cb_priv; @@ -412,9 +412,9 @@ int release_vp9_frame_buffer(void *cb_priv, return 0; } -void generate_filename(const char *pattern, char *out, size_t q_len, - unsigned int d_w, unsigned int d_h, - unsigned int frame_in) { +static void generate_filename(const char *pattern, char *out, size_t q_len, + unsigned int d_w, unsigned int d_h, + unsigned int frame_in) { const char *p = pattern; char *q = out; @@ -536,7 +536,7 @@ static int img_shifted_realloc_required(const vpx_image_t *img, } #endif -int main_loop(int argc, const char **argv_) { +static int main_loop(int argc, const char **argv_) { vpx_codec_ctx_t decoder; char *fn = NULL; int i; @@ -99,7 +99,7 @@ static void warn_or_exit_on_error(vpx_codec_ctx_t *ctx, int fatal, va_end(ap); } -int read_frame(struct VpxInputContext *input_ctx, vpx_image_t *img) { +static int read_frame(struct VpxInputContext *input_ctx, vpx_image_t *img) { FILE *f = input_ctx->file; y4m_input *y4m = &input_ctx->y4m; int shortread = 0; @@ -114,14 +114,14 @@ int read_frame(struct VpxInputContext *input_ctx, vpx_image_t *img) { return !shortread; } -int file_is_y4m(const char detect[4]) { +static int file_is_y4m(const char detect[4]) { if (memcmp(detect, "YUV4", 4) == 0) { return 1; } return 0; } -int fourcc_is_ivf(const char detect[4]) { +static int fourcc_is_ivf(const char detect[4]) { if (memcmp(detect, "DKIF", 4) == 0) { return 1; } @@ -467,7 +467,7 @@ static const int vp9_arg_ctrl_map[] = { static const arg_def_t *no_args[] = { NULL }; -void usage_exit() { +void usage_exit(void) { int i; fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n", @@ -793,8 +793,8 @@ struct stream_state { }; -void validate_positive_rational(const char *msg, - struct vpx_rational *rat) { +static void validate_positive_rational(const char *msg, + struct vpx_rational *rat) { if (rat->den < 0) { rat->num *= -1; rat->den *= -1; @@ -919,7 +919,7 @@ static void parse_global_config(struct VpxEncoderConfig *global, char **argv) { } -void open_input_file(struct VpxInputContext *input) { +static void open_input_file(struct VpxInputContext *input) { /* Parse certain options from the input file, if possible */ input->file = strcmp(input->filename, "-") ? fopen(input->filename, "rb") : set_binary_mode(stdin); |