From a9c7597adcc3734e3528d4fbadf6332043cb4e44 Mon Sep 17 00:00:00 2001 From: John Koleszar Date: Thu, 8 Nov 2012 17:09:30 -0800 Subject: [PATCH] support building vp8 and vp9 into a single lib Change-Id: Ib8f8a66c9fd31e508cdc9caa662192f38433aa3d --- build/make/Makefile | 4 +- build/make/gen_msvs_proj.sh | 17 +++- build/x86-msvs/obj_int_extract.bat | 8 ++ examples.mk | 20 ++-- libs.mk | 34 ++++--- test/dct16x16_test.cc | 2 +- test/fdct4x4_test.cc | 2 +- test/fdct8x8_test.cc | 2 +- test/idct8x8_test.cc | 2 +- test/idctllm_test.cc | 2 +- test/intrapred_test.cc | 2 +- test/pp_filter_test.cc | 2 +- test/sad_test.cc | 2 +- test/sixtap_predict_test.cc | 2 +- test/subtract_test.cc | 2 +- test/variance_test.cc | 2 +- test/vp8_fdct4x4_test.cc | 2 +- tools/all_builds.py | 2 +- vp8/common/arm/armv6/idct_blk_v6.c | 2 +- vp8/common/arm/bilinearfilter_arm.c | 2 +- vp8/common/arm/filter_arm.c | 2 +- vp8/common/arm/loopfilter_arm.c | 2 +- vp8/common/arm/neon/idct_blk_neon.c | 2 +- vp8/common/arm/reconintra_arm.c | 2 +- vp8/common/arm/variance_arm.c | 2 +- vp8/common/dequantize.c | 2 +- vp8/common/generic/systemdependent.c | 2 +- vp8/common/idct_blk.c | 2 +- vp8/common/invtrans.h | 2 +- vp8/common/loopfilter.c | 2 +- vp8/common/loopfilter.h | 2 +- vp8/common/mfqe.c | 2 +- vp8/common/mips/dspr2/dequantize_dspr2.c | 2 +- vp8/common/mips/dspr2/filter_dspr2.c | 2 +- vp8/common/mips/dspr2/idct_blk_dspr2.c | 2 +- vp8/common/mips/dspr2/idctllm_dspr2.c | 2 +- .../mips/dspr2/loopfilter_filters_dspr2.c | 2 +- vp8/common/mips/dspr2/reconinter_dspr2.c | 2 +- vp8/common/onyxc_int.h | 2 +- vp8/common/postproc.c | 3 +- vp8/common/reconinter.c | 2 +- vp8/common/reconintra.c | 2 +- vp8/common/reconintra4x4.c | 6 +- vp8/common/rtcd.c | 96 ++---------------- vp8/common/rtcd_defs.sh | 46 ++------- vp8/common/x86/idct_blk_mmx.c | 2 +- vp8/common/x86/idct_blk_sse2.c | 2 +- vp8/common/x86/recon_wrapper_sse2.c | 2 +- vp8/common/x86/vp8_asm_stubs.c | 2 +- vp8/decoder/decodframe.c | 3 +- vp8/decoder/onyxd_if.c | 1 + vp8/decoder/threading.c | 2 +- vp8/encoder/arm/dct_arm.c | 2 +- vp8/encoder/arm/quantize_arm.c | 2 +- vp8/encoder/denoising.c | 2 +- vp8/encoder/encodeintra.c | 2 +- vp8/encoder/encodemb.c | 2 +- vp8/encoder/firstpass.c | 1 + vp8/encoder/onyx_if.c | 1 + vp8/encoder/picklpf.c | 1 + vp8/encoder/rdopt.c | 2 +- vp8/encoder/x86/denoising_sse2.c | 2 +- vp8/encoder/x86/vp8_enc_stubs_mmx.c | 2 +- vp8/encoder/x86/vp8_enc_stubs_sse2.c | 2 +- vp8/vp8_common.mk | 2 + vp8/vp8_cx_iface.c | 4 +- vp8/vp8_dx_iface.c | 4 +- vp9/common/filter.c | 2 +- vp9/common/generic/systemdependent.c | 4 +- vp9/common/onyxc_int.h | 2 +- vp9/common/recon.c | 2 +- vp9/common/reconintra.c | 2 +- vp9/common/reconintra4x4.c | 2 +- vp9/common/rtcd.c | 96 ++---------------- vp9/common/rtcd_defs.sh | 13 +-- vp9/common/x86/filter_sse2.c | 2 +- vp9/common/x86/filter_sse4.c | 2 +- vp9/common/x86/sadmxn_x86.c | 2 +- vp9/decoder/decodframe.c | 2 +- vp9/decoder/dequantize.c | 2 +- vp9/decoder/idct_blk.c | 2 +- vp9/encoder/arm/dct_arm.c | 2 +- vp9/encoder/encodeframe.c | 2 +- vp9/encoder/encodeintra.c | 2 +- vp9/encoder/encodemb.c | 2 +- vp9/encoder/rdopt.c | 2 +- vp9/encoder/satd_c.c | 2 +- vp9/exports_dec | 4 +- vp9/exports_enc | 8 +- vp9/vp9_common.mk | 2 + vp9/vp9_cx_iface.c | 6 +- vp9/vp9_dx_iface.c | 4 +- vpx/vp8cx.h | 6 +- vpx/vp8dx.h | 4 + vpx_ports/vpx_once.h | 97 +++++++++++++++++++ vpx_scale/generic/vpxscale.c | 2 +- vpx_scale/rtcd.c | 18 ++++ vpx_scale/vpx_scale.mk | 3 + vpx_scale/vpx_scale_rtcd.sh | 41 ++++++++ vpxdec.c | 13 +-- vpxenc.c | 59 ++++++++--- 101 files changed, 395 insertions(+), 370 deletions(-) create mode 100644 vpx_ports/vpx_once.h create mode 100644 vpx_scale/rtcd.c create mode 100644 vpx_scale/vpx_scale_rtcd.sh diff --git a/build/make/Makefile b/build/make/Makefile index 830360eaa..be9ee6ddf 100644 --- a/build/make/Makefile +++ b/build/make/Makefile @@ -105,14 +105,14 @@ testdata:: xform_obj_prefix:=.objs/$(TOOLCHAIN)/ xform_obj_path=$(if $(1),$(addprefix $(xform_obj_prefix),$(subst /,_,$(1))),$(xform_obj_prefix)) -xform_obj_path_o_d=$(call xform_obj_path,$(1).o) $(call xform_obj_path,$(1).d) +xform_obj_path_o_d=$(call xform_obj_path,$(1)).o $(call xform_obj_path,$(1)).d define obj_rules_template $(BUILD_PFX)$(call xform_obj_path,$(1))%.c.d: $(1)%.c $(if $(quiet),@echo " [DEP] $$@") $(qexec)mkdir -p $$(dir $$@) $(qexec)$(CC) $$(INTERNAL_CFLAGS) $$(CFLAGS) -M $$< | $(fmt_deps) > $$@ -$(BUILD_PFX)$(call xform_obj_path,$(1))%.c.o: $(1)%.c +$(BUILD_PFX)$(call xform_obj_path,$(1))%.c.o: $(1)%.c $(BUILD_PFX)$(call xform_obj_path,$(1))%.c.d $(if $(quiet),@echo " [CC] $$@") $(qexec)$(CC) $$(INTERNAL_CFLAGS) $$(CFLAGS) -c -o $$@ $$< diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh index 7d473899d..35fb4df77 100755 --- a/build/make/gen_msvs_proj.sh +++ b/build/make/gen_msvs_proj.sh @@ -143,7 +143,9 @@ generate_filter() { if [ "${f##*.}" == "$pat" ]; then unset file_list[i] + objf=$(echo ${f%.*}.obj | sed -e 's/^[\./]\+//g' -e 's,/,_,g') open_tag File RelativePath="./$f" + if [ "$pat" == "asm" ] && $asm_use_custom_step; then for plat in "${platforms[@]}"; do for cfg in Debug Release; do @@ -154,13 +156,26 @@ generate_filter() { Name="VCCustomBuildTool" \ Description="Assembling \$(InputFileName)" \ CommandLine="$(eval echo \$asm_${cfg}_cmdline)" \ - Outputs="\$(InputName).obj" \ + Outputs="\$(IntDir)$objf" \ close_tag FileConfiguration done done fi + if [ "$pat" == "c" ] || [ "$pat" == "cc" ] ; then + for plat in "${platforms[@]}"; do + for cfg in Debug Release; do + open_tag FileConfiguration \ + Name="${cfg}|${plat}" \ + tag Tool \ + Name="VCCLCompilerTool" \ + ObjectFile="\$(IntDir)$objf" \ + + close_tag FileConfiguration + done + done + fi close_tag File break diff --git a/build/x86-msvs/obj_int_extract.bat b/build/x86-msvs/obj_int_extract.bat index 90bb18184..1b77dfa1f 100644 --- a/build/x86-msvs/obj_int_extract.bat +++ b/build/x86-msvs/obj_int_extract.bat @@ -13,3 +13,11 @@ cl /I "./" /I "%1" /nologo /c "%1/vp9/encoder/asm_enc_offsets.c" obj_int_extract.exe rvds "asm_com_offsets.obj" > "vp9_asm_com_offsets.asm" obj_int_extract.exe rvds "asm_dec_offsets.obj" > "vp9_asm_dec_offsets.asm" obj_int_extract.exe rvds "asm_enc_offsets.obj" > "vp9_asm_enc_offsets.asm" + +cl /I "./" /I "%1" /nologo /c "%1/vp8/common/asm_com_offsets.c" +cl /I "./" /I "%1" /nologo /c "%1/vp8/decoder/asm_dec_offsets.c" +cl /I "./" /I "%1" /nologo /c "%1/vp8/encoder/asm_enc_offsets.c" +obj_int_extract.exe rvds "asm_com_offsets.obj" > "vp8_asm_com_offsets.asm" +obj_int_extract.exe rvds "asm_dec_offsets.obj" > "vp8_asm_dec_offsets.asm" +obj_int_extract.exe rvds "asm_enc_offsets.obj" > "vp8_asm_enc_offsets.asm" + diff --git a/examples.mk b/examples.mk index aea29ebca..e799a2bb6 100644 --- a/examples.mk +++ b/examples.mk @@ -38,7 +38,7 @@ vpxenc.SRCS += libmkv/EbmlWriter.c vpxenc.SRCS += libmkv/EbmlWriter.h vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1 vpxenc.DESCRIPTION = Full featured encoder -UTILS-$(CONFIG_ENCODERS) += vp8_scalable_patterns.c +UTILS-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c vp8_scalable_patterns.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder @@ -56,37 +56,37 @@ endif #example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022 #example_xma.DESCRIPTION = External Memory Allocation mode usage -GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c +GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += simple_decoder.c simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC simple_decoder.DESCRIPTION = Simplified decoder loop -GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c +GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += postproc.c postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7 postproc.DESCRIPTION = Decoder postprocessor control -GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c +GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += decode_to_md5.c decode_to_md5.SRCS += md5_utils.h md5_utils.c decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42 decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum -GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c +GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += simple_encoder.c simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD simple_encoder.DESCRIPTION = Simplified encoder loop -GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c +GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += twopass_encoder.c twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8 twopass_encoder.DESCRIPTION = Two-pass encoder loop -GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c +GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += force_keyframe.c force_keyframe.GUID = 3C67CADF-029F-4C86-81F5-D6D4F51177F0 force_keyframe.DESCRIPTION = Force generation of keyframes ifeq ($(CONFIG_DECODERS),yes) -GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c +GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += decode_with_drops.c endif decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26 decode_with_drops.DESCRIPTION = Drops frames while decoding -ifeq ($(CONFIG_DECODERS),yes) +ifeq ($(CONFIG_VP8_DECODER),yes) GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c endif decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E decode_with_partial_drops.DESCRIPTION = Drops parts of frames while decoding -GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c +GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += error_resilient.c error_resilient.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C error_resilient.DESCRIPTION = Error Resiliency Feature diff --git a/libs.mk b/libs.mk index 792e305e5..64a636d2c 100644 --- a/libs.mk +++ b/libs.mk @@ -44,6 +44,19 @@ endef endif # rvct endif # !gcc +# +# Rule to generate runtime cpu detection files +# +define rtcd_h_template +$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2) + @echo " [CREATE] $$@" + $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$$(TGT_ISA) \ + --sym=$(1) \ + --config=$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \ + $$(RTCD_OPTIONS) $$^ > $$@ +CLEAN-OBJS += $$(BUILD_PFX)$(1).h +RTCD += $$(BUILD_PFX)$(1).h +endef CODEC_SRCS-yes += CHANGELOG CODEC_SRCS-yes += libs.mk @@ -190,7 +203,8 @@ INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a endif -CODEC_SRCS=$(filter-out %_test.cc,$(call enabled,CODEC_SRCS)) +CODEC_SRCS=$(filter-out %_offsets.c,\ + $(filter-out %_test.cc,$(call enabled,CODEC_SRCS))) INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS) INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) @@ -245,7 +259,7 @@ vpx.vcproj: $(CODEC_SRCS) vpx.def PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj vpx.vcproj: vpx_config.asm -vpx.vcproj: vpx_rtcd.h +vpx.vcproj: $(RTCD) endif else @@ -362,18 +376,6 @@ $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h) CLEAN-OBJS += $(BUILD_PFX)vpx_version.h -# -# Rule to generate runtime cpu detection files -# -$(BUILD_PFX)vpx_rtcd.h: $(SRC_PATH_BARE)/$(sort $(filter %rtcd_defs.sh,$(CODEC_SRCS))) - @echo " [CREATE] $@" - $(qexec)$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$(TGT_ISA) \ - --sym=vpx_rtcd \ - --config=$(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk \ - $(RTCD_OPTIONS) $^ > $@ -CLEAN-OBJS += $(BUILD_PFX)vpx_rtcd.h - - CODEC_DOC_SRCS += vpx/vpx_codec.h \ vpx/vpx_decoder.h \ vpx/vpx_encoder.h \ @@ -501,8 +503,8 @@ libs.doxy: $(CODEC_DOC_SRCS) @echo "INCLUDE_PATH += ." >> $@; @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ -## Generate vpx_rtcd.h for all objects -$(OBJS-yes:.o=.d): $(BUILD_PFX)vpx_rtcd.h +## Generate rtcd.h for all objects +$(OBJS-yes:.o=.d): $(RTCD) ## Update the global src list SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) diff --git a/test/dct16x16_test.cc b/test/dct16x16_test.cc index d572ee6be..d85728082 100644 --- a/test/dct16x16_test.cc +++ b/test/dct16x16_test.cc @@ -17,7 +17,7 @@ extern "C" { #include "vp9/common/entropy.h" #include "vp9/common/idct.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" } #include "acm_random.h" diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc index e2eb28e5a..3fe4774ab 100644 --- a/test/fdct4x4_test.cc +++ b/test/fdct4x4_test.cc @@ -16,7 +16,7 @@ extern "C" { #include "vp9/common/idct.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" } #include "acm_random.h" diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc index fc7084ed8..729344d9f 100644 --- a/test/fdct8x8_test.cc +++ b/test/fdct8x8_test.cc @@ -16,7 +16,7 @@ extern "C" { #include "vp9/common/idct.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" } #include "acm_random.h" diff --git a/test/idct8x8_test.cc b/test/idct8x8_test.cc index 0155716b5..099efbf75 100644 --- a/test/idct8x8_test.cc +++ b/test/idct8x8_test.cc @@ -16,7 +16,7 @@ extern "C" { #include "vp9/common/idct.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" } #include "acm_random.h" diff --git a/test/idctllm_test.cc b/test/idctllm_test.cc index dd42e2299..3071a2aea 100644 --- a/test/idctllm_test.cc +++ b/test/idctllm_test.cc @@ -11,7 +11,7 @@ extern "C" { #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" } #include "third_party/googletest/src/include/gtest/gtest.h" diff --git a/test/intrapred_test.cc b/test/intrapred_test.cc index d2e0d61a1..692b67bc6 100644 --- a/test/intrapred_test.cc +++ b/test/intrapred_test.cc @@ -14,7 +14,7 @@ #include "third_party/googletest/src/include/gtest/gtest.h" extern "C" { #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/blockd.h" #include "vpx_mem/vpx_mem.h" } diff --git a/test/pp_filter_test.cc b/test/pp_filter_test.cc index af2f3bda9..36d2e63a2 100644 --- a/test/pp_filter_test.cc +++ b/test/pp_filter_test.cc @@ -10,7 +10,7 @@ #include "third_party/googletest/src/include/gtest/gtest.h" extern "C" { #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" } diff --git a/test/sad_test.cc b/test/sad_test.cc index 2b562e6dd..8cd528632 100644 --- a/test/sad_test.cc +++ b/test/sad_test.cc @@ -15,7 +15,7 @@ extern "C" { #include "./vpx_config.h" -#include "./vpx_rtcd.h" +#include "./vp8_rtcd.h" #include "vp8/common/blockd.h" #include "vpx_mem/vpx_mem.h" } diff --git a/test/sixtap_predict_test.cc b/test/sixtap_predict_test.cc index 06f14a1c7..22d5a8473 100644 --- a/test/sixtap_predict_test.cc +++ b/test/sixtap_predict_test.cc @@ -16,7 +16,7 @@ #include "third_party/googletest/src/include/gtest/gtest.h" extern "C" { #include "./vpx_config.h" -#include "./vpx_rtcd.h" +#include "./vp8_rtcd.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" } diff --git a/test/subtract_test.cc b/test/subtract_test.cc index 99363de64..f1c50d398 100644 --- a/test/subtract_test.cc +++ b/test/subtract_test.cc @@ -12,7 +12,7 @@ #include "test/acm_random.h" extern "C" { #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/blockd.h" #include "vp8/encoder/block.h" #include "vpx_mem/vpx_mem.h" diff --git a/test/variance_test.cc b/test/variance_test.cc index f838c05e2..2012b186e 100644 --- a/test/variance_test.cc +++ b/test/variance_test.cc @@ -16,7 +16,7 @@ extern "C" { #include "vp9/encoder/variance.h" #include "vpx/vpx_integer.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" } namespace { diff --git a/test/vp8_fdct4x4_test.cc b/test/vp8_fdct4x4_test.cc index 619b23d22..3c6001119 100644 --- a/test/vp8_fdct4x4_test.cc +++ b/test/vp8_fdct4x4_test.cc @@ -18,7 +18,7 @@ extern "C" { -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" } #include "test/acm_random.h" diff --git a/tools/all_builds.py b/tools/all_builds.py index 78581d9f0..d1f0c80c0 100755 --- a/tools/all_builds.py +++ b/tools/all_builds.py @@ -5,7 +5,7 @@ import subprocess import sys LONG_OPTIONS = ["shard=", "shards="] -BASE_COMMAND = "./configure --disable-vp8 --disable-unit-tests --enable-internal-stats --enable-experimental" +BASE_COMMAND = "./configure --enable-internal-stats --enable-experimental" def RunCommand(command): run = subprocess.Popen(command, shell=True) diff --git a/vp8/common/arm/armv6/idct_blk_v6.c b/vp8/common/arm/armv6/idct_blk_v6.c index 6002c0f12..c94f84a62 100644 --- a/vp8/common/arm/armv6/idct_blk_v6.c +++ b/vp8/common/arm/armv6/idct_blk_v6.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" void vp8_dequant_idct_add_y_block_v6(short *q, short *dq, diff --git a/vp8/common/arm/bilinearfilter_arm.c b/vp8/common/arm/bilinearfilter_arm.c index c63073c77..799c8bd96 100644 --- a/vp8/common/arm/bilinearfilter_arm.c +++ b/vp8/common/arm/bilinearfilter_arm.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include #include "vp8/common/filter.h" #include "bilinearfilter_arm.h" diff --git a/vp8/common/arm/filter_arm.c b/vp8/common/arm/filter_arm.c index 148951a92..7fe39674e 100644 --- a/vp8/common/arm/filter_arm.c +++ b/vp8/common/arm/filter_arm.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include #include "vp8/common/filter.h" #include "vpx_ports/mem.h" diff --git a/vp8/common/arm/loopfilter_arm.c b/vp8/common/arm/loopfilter_arm.c index b8f9bd90e..3bdc9675e 100644 --- a/vp8/common/arm/loopfilter_arm.c +++ b/vp8/common/arm/loopfilter_arm.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/loopfilter.h" #include "vp8/common/onyxc_int.h" diff --git a/vp8/common/arm/neon/idct_blk_neon.c b/vp8/common/arm/neon/idct_blk_neon.c index ee7f223b5..fb327a726 100644 --- a/vp8/common/arm/neon/idct_blk_neon.c +++ b/vp8/common/arm/neon/idct_blk_neon.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" /* place these declarations here because we don't want to maintain them * outside of this scope diff --git a/vp8/common/arm/reconintra_arm.c b/vp8/common/arm/reconintra_arm.c index 121e090e1..2874896e8 100644 --- a/vp8/common/arm/reconintra_arm.c +++ b/vp8/common/arm/reconintra_arm.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/blockd.h" #include "vpx_mem/vpx_mem.h" diff --git a/vp8/common/arm/variance_arm.c b/vp8/common/arm/variance_arm.c index 891d767f0..467a50942 100644 --- a/vp8/common/arm/variance_arm.c +++ b/vp8/common/arm/variance_arm.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/variance.h" #include "vp8/common/filter.h" diff --git a/vp8/common/dequantize.c b/vp8/common/dequantize.c index 8eda48623..6e2f69a77 100644 --- a/vp8/common/dequantize.c +++ b/vp8/common/dequantize.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/blockd.h" #include "vpx_mem/vpx_mem.h" diff --git a/vp8/common/generic/systemdependent.c b/vp8/common/generic/systemdependent.c index 5a6ac7b0e..2de019d70 100644 --- a/vp8/common/generic/systemdependent.c +++ b/vp8/common/generic/systemdependent.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #if ARCH_ARM #include "vpx_ports/arm.h" #elif ARCH_X86 || ARCH_X86_64 diff --git a/vp8/common/idct_blk.c b/vp8/common/idct_blk.c index 0b058c76a..8edfffbed 100644 --- a/vp8/common/idct_blk.c +++ b/vp8/common/idct_blk.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *dest, int stride); diff --git a/vp8/common/invtrans.h b/vp8/common/invtrans.h index d048665b9..9262640d5 100644 --- a/vp8/common/invtrans.h +++ b/vp8/common/invtrans.h @@ -13,7 +13,7 @@ #define __INC_INVTRANS_H #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "blockd.h" #include "onyxc_int.h" diff --git a/vp8/common/loopfilter.c b/vp8/common/loopfilter.c index 41b4f1214..2b1ee851b 100644 --- a/vp8/common/loopfilter.c +++ b/vp8/common/loopfilter.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "loopfilter.h" #include "onyxc_int.h" #include "vpx_mem/vpx_mem.h" diff --git a/vp8/common/loopfilter.h b/vp8/common/loopfilter.h index b3af2d650..1e47f3490 100644 --- a/vp8/common/loopfilter.h +++ b/vp8/common/loopfilter.h @@ -14,7 +14,7 @@ #include "vpx_ports/mem.h" #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #define MAX_LOOP_FILTER 63 /* fraction of total macroblock rows to be used in fast filter level picking */ diff --git a/vp8/common/mfqe.c b/vp8/common/mfqe.c index 3dff1505b..8a8f92f68 100644 --- a/vp8/common/mfqe.c +++ b/vp8/common/mfqe.c @@ -20,7 +20,7 @@ #include "postproc.h" #include "variance.h" #include "vpx_mem/vpx_mem.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_scale/yv12config.h" #include diff --git a/vp8/common/mips/dspr2/dequantize_dspr2.c b/vp8/common/mips/dspr2/dequantize_dspr2.c index 682332573..619ee808d 100644 --- a/vp8/common/mips/dspr2/dequantize_dspr2.c +++ b/vp8/common/mips/dspr2/dequantize_dspr2.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_mem/vpx_mem.h" #if HAVE_DSPR2 diff --git a/vp8/common/mips/dspr2/filter_dspr2.c b/vp8/common/mips/dspr2/filter_dspr2.c index 71fdcd715..ace5d400c 100644 --- a/vp8/common/mips/dspr2/filter_dspr2.c +++ b/vp8/common/mips/dspr2/filter_dspr2.c @@ -10,7 +10,7 @@ #include -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_ports/mem.h" #if HAVE_DSPR2 diff --git a/vp8/common/mips/dspr2/idct_blk_dspr2.c b/vp8/common/mips/dspr2/idct_blk_dspr2.c index 1e0ebd161..ab938cd6a 100644 --- a/vp8/common/mips/dspr2/idct_blk_dspr2.c +++ b/vp8/common/mips/dspr2/idct_blk_dspr2.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #if HAVE_DSPR2 diff --git a/vp8/common/mips/dspr2/idctllm_dspr2.c b/vp8/common/mips/dspr2/idctllm_dspr2.c index 25b793643..2eff71069 100644 --- a/vp8/common/mips/dspr2/idctllm_dspr2.c +++ b/vp8/common/mips/dspr2/idctllm_dspr2.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #if HAVE_DSPR2 #define CROP_WIDTH 256 diff --git a/vp8/common/mips/dspr2/loopfilter_filters_dspr2.c b/vp8/common/mips/dspr2/loopfilter_filters_dspr2.c index b8e5e4d07..9ae6bc8f9 100644 --- a/vp8/common/mips/dspr2/loopfilter_filters_dspr2.c +++ b/vp8/common/mips/dspr2/loopfilter_filters_dspr2.c @@ -10,7 +10,7 @@ #include -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/onyxc_int.h" #if HAVE_DSPR2 diff --git a/vp8/common/mips/dspr2/reconinter_dspr2.c b/vp8/common/mips/dspr2/reconinter_dspr2.c index a5239a3c8..a14b397d8 100644 --- a/vp8/common/mips/dspr2/reconinter_dspr2.c +++ b/vp8/common/mips/dspr2/reconinter_dspr2.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/vpx_integer.h" #if HAVE_DSPR2 diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h index 5325bace4..03c97187a 100644 --- a/vp8/common/onyxc_int.h +++ b/vp8/common/onyxc_int.h @@ -13,7 +13,7 @@ #define __INC_VP8C_INT_H #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/internal/vpx_codec_internal.h" #include "loopfilter.h" #include "entropymv.h" diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c index 80fa530ed..c6442c92e 100644 --- a/vp8/common/postproc.c +++ b/vp8/common/postproc.c @@ -10,7 +10,8 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" +#include "vpx_scale_rtcd.h" #include "vpx_scale/yv12config.h" #include "postproc.h" #include "common.h" diff --git a/vp8/common/reconinter.c b/vp8/common/reconinter.c index 3da3bc74f..43f84d01b 100644 --- a/vp8/common/reconinter.c +++ b/vp8/common/reconinter.c @@ -11,7 +11,7 @@ #include #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/vpx_integer.h" #include "blockd.h" #include "reconinter.h" diff --git a/vp8/common/reconintra.c b/vp8/common/reconintra.c index 4067a6851..a85121579 100644 --- a/vp8/common/reconintra.c +++ b/vp8/common/reconintra.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_mem/vpx_mem.h" #include "blockd.h" diff --git a/vp8/common/reconintra4x4.c b/vp8/common/reconintra4x4.c index 7bb8d0ac1..3d4f2c404 100644 --- a/vp8/common/reconintra4x4.c +++ b/vp8/common/reconintra4x4.c @@ -10,17 +10,17 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "blockd.h" void vp8_intra4x4_predict_c(unsigned char *Above, unsigned char *yleft, int left_stride, - B_PREDICTION_MODE b_mode, + int _b_mode, unsigned char *dst, int dst_stride, unsigned char top_left) { int i, r, c; - + B_PREDICTION_MODE b_mode = (B_PREDICTION_MODE)_b_mode; unsigned char Left[4]; Left[0] = yleft[0]; Left[1] = yleft[left_stride]; diff --git a/vp8/common/rtcd.c b/vp8/common/rtcd.c index 01dad4691..0b371b094 100644 --- a/vp8/common/rtcd.c +++ b/vp8/common/rtcd.c @@ -9,97 +9,13 @@ */ #include "vpx_config.h" #define RTCD_C -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" +#include "vpx_ports/vpx_once.h" -#if CONFIG_MULTITHREAD && defined(_WIN32) -#include -#include -static void once(void (*func)(void)) -{ - static CRITICAL_SECTION *lock; - static LONG waiters; - static int done; - void *lock_ptr = &lock; - - /* If the initialization is complete, return early. This isn't just an - * optimization, it prevents races on the destruction of the global - * lock. - */ - if(done) - return; - - InterlockedIncrement(&waiters); - - /* Get a lock. We create one and try to make it the one-true-lock, - * throwing it away if we lost the race. - */ - - { - /* Scope to protect access to new_lock */ - CRITICAL_SECTION *new_lock = malloc(sizeof(CRITICAL_SECTION)); - InitializeCriticalSection(new_lock); - if (InterlockedCompareExchangePointer(lock_ptr, new_lock, NULL) != NULL) - { - DeleteCriticalSection(new_lock); - free(new_lock); - } - } - - /* At this point, we have a lock that can be synchronized on. We don't - * care which thread actually performed the allocation. - */ - - EnterCriticalSection(lock); - - if (!done) - { - func(); - done = 1; - } - - LeaveCriticalSection(lock); - - /* Last one out should free resources. The destructed objects are - * protected by checking if(done) above. - */ - if(!InterlockedDecrement(&waiters)) - { - DeleteCriticalSection(lock); - free(lock); - lock = NULL; - } -} - - -#elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H -#include -static void once(void (*func)(void)) -{ - static pthread_once_t lock = PTHREAD_ONCE_INIT; - pthread_once(&lock, func); -} - - -#else -/* No-op version that performs no synchronization. vpx_rtcd() is idempotent, - * so as long as your platform provides atomic loads/stores of pointers - * no synchronization is strictly necessary. - */ - -static void once(void (*func)(void)) -{ - static int done; - - if(!done) - { - func(); - done = 1; - } -} -#endif - - -void vpx_rtcd() +extern void vpx_scale_rtcd(void); + +void vp8_rtcd() { + vpx_scale_rtcd(); once(setup_rtcd_internal); } diff --git a/vp8/common/rtcd_defs.sh b/vp8/common/rtcd_defs.sh index 0f950f8ab..4eb96b743 100644 --- a/vp8/common/rtcd_defs.sh +++ b/vp8/common/rtcd_defs.sh @@ -1,6 +1,8 @@ -common_forward_decls() { +vp8_common_forward_decls() { cat < #include "vp8/common/quant_common.h" +#include "./vpx_scale_rtcd.h" #include "vpx_scale/vpxscale.h" #include "vp8/common/systemdependent.h" #include "vpx_ports/vpx_timer.h" diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c index e52a707c0..a714856b0 100644 --- a/vp8/decoder/threading.c +++ b/vp8/decoder/threading.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #if !defined(WIN32) && CONFIG_OS_SUPPORT == 1 # include #endif diff --git a/vp8/encoder/arm/dct_arm.c b/vp8/encoder/arm/dct_arm.c index af0fb274e..f71300d2c 100644 --- a/vp8/encoder/arm/dct_arm.c +++ b/vp8/encoder/arm/dct_arm.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #if HAVE_MEDIA diff --git a/vp8/encoder/arm/quantize_arm.c b/vp8/encoder/arm/quantize_arm.c index 8999e347f..80d9ad054 100644 --- a/vp8/encoder/arm/quantize_arm.c +++ b/vp8/encoder/arm/quantize_arm.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/encoder/block.h" #include #include "vpx_mem/vpx_mem.h" diff --git a/vp8/encoder/denoising.c b/vp8/encoder/denoising.c index c0dd7c106..98526d640 100644 --- a/vp8/encoder/denoising.c +++ b/vp8/encoder/denoising.c @@ -13,7 +13,7 @@ #include "vp8/common/reconinter.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" static const unsigned int NOISE_MOTION_THRESHOLD = 25 * 25; /* SSE_DIFF_THRESHOLD is selected as ~95% confidence assuming diff --git a/vp8/encoder/encodeintra.c b/vp8/encoder/encodeintra.c index 340dd638d..cfa4cb927 100644 --- a/vp8/encoder/encodeintra.c +++ b/vp8/encoder/encodeintra.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "quantize.h" #include "vp8/common/reconintra4x4.h" #include "encodemb.h" diff --git a/vp8/encoder/encodemb.c b/vp8/encoder/encodemb.c index 7d494f2c6..7ed2fe1a1 100644 --- a/vp8/encoder/encodemb.c +++ b/vp8/encoder/encodemb.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "encodemb.h" #include "vp8/common/reconinter.h" #include "quantize.h" diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index b668c8f3b..e5306a425 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -12,6 +12,7 @@ #include #include +#include "./vpx_scale_rtcd.h" #include "block.h" #include "onyx_int.h" #include "vp8/common/variance.h" diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 4235662f1..e7d22701e 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -10,6 +10,7 @@ #include "vpx_config.h" +#include "./vpx_scale_rtcd.h" #include "vp8/common/onyxc_int.h" #include "vp8/common/blockd.h" #include "onyx_int.h" diff --git a/vp8/encoder/picklpf.c b/vp8/encoder/picklpf.c index 4121349a9..8114ec33a 100644 --- a/vp8/encoder/picklpf.c +++ b/vp8/encoder/picklpf.c @@ -9,6 +9,7 @@ */ +#include "./vpx_scale_rtcd.h" #include "vp8/common/onyxc_int.h" #include "onyx_int.h" #include "quantize.h" diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 28d5c1ee8..946d22a8f 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -14,7 +14,7 @@ #include #include #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vp8/common/pragmas.h" #include "tokenize.h" #include "treewriter.h" diff --git a/vp8/encoder/x86/denoising_sse2.c b/vp8/encoder/x86/denoising_sse2.c index c1ac6c137..87cccaa66 100644 --- a/vp8/encoder/x86/denoising_sse2.c +++ b/vp8/encoder/x86/denoising_sse2.c @@ -12,7 +12,7 @@ #include "vp8/common/reconinter.h" #include "vpx/vpx_integer.h" #include "vpx_mem/vpx_mem.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include diff --git a/vp8/encoder/x86/vp8_enc_stubs_mmx.c b/vp8/encoder/x86/vp8_enc_stubs_mmx.c index da25f5227..cf3d8ca4a 100644 --- a/vp8/encoder/x86/vp8_enc_stubs_mmx.c +++ b/vp8/encoder/x86/vp8_enc_stubs_mmx.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_ports/x86.h" #include "vp8/encoder/block.h" diff --git a/vp8/encoder/x86/vp8_enc_stubs_sse2.c b/vp8/encoder/x86/vp8_enc_stubs_sse2.c index 68db8155a..3dfbee368 100644 --- a/vp8/encoder/x86/vp8_enc_stubs_sse2.c +++ b/vp8/encoder/x86/vp8_enc_stubs_sse2.c @@ -10,7 +10,7 @@ #include "vpx_config.h" -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx_ports/x86.h" #include "vp8/encoder/block.h" diff --git a/vp8/vp8_common.mk b/vp8/vp8_common.mk index d54c2330c..2f73420a5 100644 --- a/vp8/vp8_common.mk +++ b/vp8/vp8_common.mk @@ -194,3 +194,5 @@ VP8_COMMON_SRCS-$(HAVE_NEON) += common/arm/neon/vp8_subpixelvariance16x16s_neon $(eval $(call asm_offsets_template,\ vp8_asm_com_offsets.asm, $(VP8_PREFIX)common/asm_com_offsets.c)) + +$(eval $(call rtcd_h_template,vp8_rtcd,vp8/common/rtcd_defs.sh)) diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c index eeac3a8b1..83eecba5c 100644 --- a/vp8/vp8_cx_iface.c +++ b/vp8/vp8_cx_iface.c @@ -9,7 +9,7 @@ */ -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/vpx_codec.h" #include "vpx/internal/vpx_codec_internal.h" #include "vpx_version.h" @@ -582,7 +582,7 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, struct VP8_COMP *optr; - vpx_rtcd(); + vp8_rtcd(); if (!ctx->priv) { diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index c13d69783..01482fcc7 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -11,7 +11,7 @@ #include #include -#include "vpx_rtcd.h" +#include "vp8_rtcd.h" #include "vpx/vpx_decoder.h" #include "vpx/vp8dx.h" #include "vpx/internal/vpx_codec_internal.h" @@ -194,7 +194,7 @@ static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx, vpx_codec_err_t res = VPX_CODEC_OK; (void) data; - vpx_rtcd(); + vp8_rtcd(); /* This function only allocates space for the vpx_codec_alg_priv_t * structure. More memory may be required at the time the stream diff --git a/vp9/common/filter.c b/vp9/common/filter.c index 4667b461d..429f408c7 100644 --- a/vp9/common/filter.c +++ b/vp9/common/filter.c @@ -12,7 +12,7 @@ #include #include "filter.h" #include "vpx_ports/mem.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" DECLARE_ALIGNED(16, const short, vp9_bilinear_filters[SUBPEL_SHIFTS][2]) = { { 128, 0 }, diff --git a/vp9/common/generic/systemdependent.c b/vp9/common/generic/systemdependent.c index a3d6cb478..749e3d358 100644 --- a/vp9/common/generic/systemdependent.c +++ b/vp9/common/generic/systemdependent.c @@ -10,7 +10,7 @@ #include "vpx_ports/config.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "vp9/common/subpixel.h" #include "vp9/common/loopfilter.h" #include "vp9/common/idct.h" @@ -84,5 +84,5 @@ void vp9_machine_specific_config(VP9_COMMON *ctx) { vp9_arch_arm_common_init(ctx); #endif - vpx_rtcd(); + vp9_rtcd(); } diff --git a/vp9/common/onyxc_int.h b/vp9/common/onyxc_int.h index 516bea3cc..62d79784c 100644 --- a/vp9/common/onyxc_int.h +++ b/vp9/common/onyxc_int.h @@ -14,7 +14,7 @@ #include "vpx_config.h" #include "vpx/internal/vpx_codec_internal.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "loopfilter.h" #include "entropymv.h" #include "entropy.h" diff --git a/vp9/common/recon.c b/vp9/common/recon.c index 4aee6c160..77035668e 100644 --- a/vp9/common/recon.c +++ b/vp9/common/recon.c @@ -10,7 +10,7 @@ #include "vpx_ports/config.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "blockd.h" void vp9_recon_b_c diff --git a/vp9/common/reconintra.c b/vp9/common/reconintra.c index 60de8eb43..98de2b401 100644 --- a/vp9/common/reconintra.c +++ b/vp9/common/reconintra.c @@ -10,7 +10,7 @@ #include #include "vpx_ports/config.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "reconintra.h" #include "vpx_mem/vpx_mem.h" diff --git a/vp9/common/reconintra4x4.c b/vp9/common/reconintra4x4.c index 7af613d33..1cf960cb7 100644 --- a/vp9/common/reconintra4x4.c +++ b/vp9/common/reconintra4x4.c @@ -12,7 +12,7 @@ #include "vpx_ports/config.h" #include "vpx_mem/vpx_mem.h" #include "reconintra.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #if CONFIG_NEWBINTRAMODES static int find_grad_measure(unsigned char *x, int stride, int n, int t, diff --git a/vp9/common/rtcd.c b/vp9/common/rtcd.c index 01dad4691..277d5b217 100644 --- a/vp9/common/rtcd.c +++ b/vp9/common/rtcd.c @@ -9,97 +9,13 @@ */ #include "vpx_config.h" #define RTCD_C -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" +#include "vpx_ports/vpx_once.h" -#if CONFIG_MULTITHREAD && defined(_WIN32) -#include -#include -static void once(void (*func)(void)) -{ - static CRITICAL_SECTION *lock; - static LONG waiters; - static int done; - void *lock_ptr = &lock; - - /* If the initialization is complete, return early. This isn't just an - * optimization, it prevents races on the destruction of the global - * lock. - */ - if(done) - return; - - InterlockedIncrement(&waiters); - - /* Get a lock. We create one and try to make it the one-true-lock, - * throwing it away if we lost the race. - */ - - { - /* Scope to protect access to new_lock */ - CRITICAL_SECTION *new_lock = malloc(sizeof(CRITICAL_SECTION)); - InitializeCriticalSection(new_lock); - if (InterlockedCompareExchangePointer(lock_ptr, new_lock, NULL) != NULL) - { - DeleteCriticalSection(new_lock); - free(new_lock); - } - } - - /* At this point, we have a lock that can be synchronized on. We don't - * care which thread actually performed the allocation. - */ - - EnterCriticalSection(lock); - - if (!done) - { - func(); - done = 1; - } - - LeaveCriticalSection(lock); - - /* Last one out should free resources. The destructed objects are - * protected by checking if(done) above. - */ - if(!InterlockedDecrement(&waiters)) - { - DeleteCriticalSection(lock); - free(lock); - lock = NULL; - } -} - - -#elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H -#include -static void once(void (*func)(void)) -{ - static pthread_once_t lock = PTHREAD_ONCE_INIT; - pthread_once(&lock, func); -} - - -#else -/* No-op version that performs no synchronization. vpx_rtcd() is idempotent, - * so as long as your platform provides atomic loads/stores of pointers - * no synchronization is strictly necessary. - */ - -static void once(void (*func)(void)) -{ - static int done; - - if(!done) - { - func(); - done = 1; - } -} -#endif - - -void vpx_rtcd() +extern void vpx_scale_rtcd(void); + +void vp9_rtcd() { + vpx_scale_rtcd(); once(setup_rtcd_internal); } diff --git a/vp9/common/rtcd_defs.sh b/vp9/common/rtcd_defs.sh index 14e9d7a75..2c94c9e8a 100644 --- a/vp9/common/rtcd_defs.sh +++ b/vp9/common/rtcd_defs.sh @@ -1,5 +1,8 @@ -common_forward_decls() { +vp9_common_forward_decls() { cat < // SSE2 #include "vp9/common/filter.h" #include "vpx_ports/mem.h" // for DECLARE_ALIGNED -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" // TODO(cd): After cleanup, commit faster versions for non 4x4 size. This is // just a quick partial snapshot so that other can already use some diff --git a/vp9/common/x86/filter_sse4.c b/vp9/common/x86/filter_sse4.c index ac2c92ce4..9efe9f44a 100644 --- a/vp9/common/x86/filter_sse4.c +++ b/vp9/common/x86/filter_sse4.c @@ -12,7 +12,7 @@ #include // SSE4.1 #include "vp9/common/filter.h" #include "vpx_ports/mem.h" // for DECLARE_ALIGNED -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" // TODO(cd): After cleanup, commit faster versions for non 4x4 size. This is // just a quick partial snapshot so that other can already use some diff --git a/vp9/common/x86/sadmxn_x86.c b/vp9/common/x86/sadmxn_x86.c index b12680d6c..1ba2d48de 100644 --- a/vp9/common/x86/sadmxn_x86.c +++ b/vp9/common/x86/sadmxn_x86.c @@ -10,7 +10,7 @@ #include // SSE2 #include "./vpx_config.h" -#include "./vpx_rtcd.h" +#include "./vp9_rtcd.h" #if HAVE_SSE2 diff --git a/vp9/decoder/decodframe.c b/vp9/decoder/decodframe.c index 5b56b158a..03a5d3ed6 100644 --- a/vp9/decoder/decodframe.c +++ b/vp9/decoder/decodframe.c @@ -32,7 +32,7 @@ #include "vp9/common/seg_common.h" #include "vp9/common/entropy.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include #include diff --git a/vp9/decoder/dequantize.c b/vp9/decoder/dequantize.c index e56426271..541293e61 100644 --- a/vp9/decoder/dequantize.c +++ b/vp9/decoder/dequantize.c @@ -9,7 +9,7 @@ */ -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "dequantize.h" #include "vp9/common/idct.h" #include "vpx_mem/vpx_mem.h" diff --git a/vp9/decoder/idct_blk.c b/vp9/decoder/idct_blk.c index cbf96e0da..0b440b476 100644 --- a/vp9/decoder/idct_blk.c +++ b/vp9/decoder/idct_blk.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "vp9/common/idct.h" void vp9_dequant_dc_idct_add_y_block_c(short *q, short *dq, diff --git a/vp9/encoder/arm/dct_arm.c b/vp9/encoder/arm/dct_arm.c index 3fd04f383..5e20a4723 100644 --- a/vp9/encoder/arm/dct_arm.c +++ b/vp9/encoder/arm/dct_arm.c @@ -9,7 +9,7 @@ */ #include "vpx_config.h" -#include "./vpx_rtcd.h" +#include "./vp9_rtcd.h" #if HAVE_ARMV6 diff --git a/vp9/encoder/encodeframe.c b/vp9/encoder/encodeframe.c index 4a739d468..b00ea3e04 100644 --- a/vp9/encoder/encodeframe.c +++ b/vp9/encoder/encodeframe.c @@ -29,7 +29,7 @@ #include "vp9/common/reconintra.h" #include "vp9/common/seg_common.h" #include "vp9/encoder/tokenize.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include #include #include diff --git a/vp9/encoder/encodeintra.c b/vp9/encoder/encodeintra.c index 365784c4f..a6bc1c3be 100644 --- a/vp9/encoder/encodeintra.c +++ b/vp9/encoder/encodeintra.c @@ -9,7 +9,7 @@ */ #include "vpx_ports/config.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "vp9/common/idct.h" #include "quantize.h" #include "vp9/common/reconintra.h" diff --git a/vp9/encoder/encodemb.c b/vp9/encoder/encodemb.c index 71e81edd0..6774a88f5 100644 --- a/vp9/encoder/encodemb.c +++ b/vp9/encoder/encodemb.c @@ -18,7 +18,7 @@ #include "vpx_mem/vpx_mem.h" #include "rdopt.h" #include "vp9/common/systemdependent.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #if CONFIG_RUNTIME_CPU_DETECT #define IF_RTCD(x) (x) diff --git a/vp9/encoder/rdopt.c b/vp9/encoder/rdopt.c index c99076e9b..59cff8527 100644 --- a/vp9/encoder/rdopt.c +++ b/vp9/encoder/rdopt.c @@ -40,7 +40,7 @@ #include "vp9/common/seg_common.h" #include "vp9/common/pred_common.h" #include "vp9/common/entropy.h" -#include "vpx_rtcd.h" +#include "vp9_rtcd.h" #include "vp9/common/mvref_common.h" #if CONFIG_RUNTIME_CPU_DETECT diff --git a/vp9/encoder/satd_c.c b/vp9/encoder/satd_c.c index 102aa73e5..63944f0e9 100644 --- a/vp9/encoder/satd_c.c +++ b/vp9/encoder/satd_c.c @@ -10,7 +10,7 @@ #include #include "vpx_ports/mem.h" -#include "./vpx_rtcd.h" +#include "./vp9_rtcd.h" unsigned int vp9_satd16x16_c(const unsigned char *src_ptr, int src_stride, const unsigned char *ref_ptr, diff --git a/vp9/exports_dec b/vp9/exports_dec index 100ac5c27..0a61fde39 100644 --- a/vp9/exports_dec +++ b/vp9/exports_dec @@ -1,2 +1,2 @@ -data vpx_codec_vp8_dx_algo -text vpx_codec_vp8_dx +data vpx_codec_vp9_dx_algo +text vpx_codec_vp9_dx diff --git a/vp9/exports_enc b/vp9/exports_enc index 5ae209806..25156e831 100644 --- a/vp9/exports_enc +++ b/vp9/exports_enc @@ -1,4 +1,4 @@ -data vpx_codec_vp8_cx_algo -text vpx_codec_vp8_cx -data vpx_codec_vp8x_cx_algo -text vpx_codec_vp8x_cx +data vpx_codec_vp9_cx_algo +text vpx_codec_vp9_cx +data vpx_codec_vp9x_cx_algo +text vpx_codec_vp9x_cx diff --git a/vp9/vp9_common.mk b/vp9/vp9_common.mk index f24313e4c..d6c9b2b12 100644 --- a/vp9/vp9_common.mk +++ b/vp9/vp9_common.mk @@ -182,3 +182,5 @@ VP9_COMMON_SRCS-$(HAVE_ARMV7) += common/arm/neon/recon_neon.c $(eval $(call asm_offsets_template,\ vp9_asm_com_offsets.asm, $(VP9_PREFIX)common/asm_com_offsets.c)) + +$(eval $(call rtcd_h_template,vp9_rtcd,vp9/common/rtcd_defs.sh)) diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index a10d7cdc7..f15531902 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -1083,8 +1083,8 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { #ifndef VERSION_STRING #define VERSION_STRING #endif -CODEC_INTERFACE(vpx_codec_vp8_cx) = { - "WebM Project VP8 Encoder" VERSION_STRING, +CODEC_INTERFACE(vpx_codec_vp9_cx) = { + "WebM Project VP9 Encoder" VERSION_STRING, VPX_CODEC_INTERNAL_ABI_VERSION, VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR | VPX_CODEC_CAP_OUTPUT_PARTITION, @@ -1113,7 +1113,7 @@ CODEC_INTERFACE(vpx_codec_vp8_cx) = { #if CONFIG_EXPERIMENTAL -CODEC_INTERFACE(vpx_codec_vp8x_cx) = { +CODEC_INTERFACE(vpx_codec_vp9x_cx) = { "VP8 Experimental Encoder" VERSION_STRING, VPX_CODEC_INTERNAL_ABI_VERSION, VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR, diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 71d140c9d..c85b423b2 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -659,8 +659,8 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = { #ifndef VERSION_STRING #define VERSION_STRING #endif -CODEC_INTERFACE(vpx_codec_vp8_dx) = { - "WebM Project VP8 Decoder" VERSION_STRING, +CODEC_INTERFACE(vpx_codec_vp9_dx) = { + "WebM Project VP9 Decoder" VERSION_STRING, VPX_CODEC_INTERNAL_ABI_VERSION, VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC, /* vpx_codec_caps_t caps; */ diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index 50fc7f031..90b7169d5 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -34,8 +34,10 @@ extern vpx_codec_iface_t vpx_codec_vp8_cx_algo; extern vpx_codec_iface_t *vpx_codec_vp8_cx(void); /* TODO(jkoleszar): These move to VP9 in a later patch set. */ -extern vpx_codec_iface_t vpx_codec_vp8x_cx_algo; -extern vpx_codec_iface_t *vpx_codec_vp8x_cx(void); +extern vpx_codec_iface_t vpx_codec_vp9_cx_algo; +extern vpx_codec_iface_t *vpx_codec_vp9_cx(void); +extern vpx_codec_iface_t vpx_codec_vp9x_cx_algo; +extern vpx_codec_iface_t *vpx_codec_vp9x_cx(void); /*!@} - end algorithm interface member group*/ diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h index a2c3a3928..e2ec8b213 100644 --- a/vpx/vp8dx.h +++ b/vpx/vp8dx.h @@ -32,6 +32,10 @@ */ extern vpx_codec_iface_t vpx_codec_vp8_dx_algo; extern vpx_codec_iface_t *vpx_codec_vp8_dx(void); + +/* TODO(jkoleszar): These move to VP9 in a later patch set. */ +extern vpx_codec_iface_t vpx_codec_vp9_dx_algo; +extern vpx_codec_iface_t *vpx_codec_vp9_dx(void); /*!@} - end algorithm interface member group*/ /* Include controls common to both the encoder and decoder */ diff --git a/vpx_ports/vpx_once.h b/vpx_ports/vpx_once.h new file mode 100644 index 000000000..16a735ccd --- /dev/null +++ b/vpx_ports/vpx_once.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011 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_config.h" + +#if CONFIG_MULTITHREAD && defined(_WIN32) +#include +#include +static void once(void (*func)(void)) +{ + static CRITICAL_SECTION *lock; + static LONG waiters; + static int done; + void *lock_ptr = &lock; + + /* If the initialization is complete, return early. This isn't just an + * optimization, it prevents races on the destruction of the global + * lock. + */ + if(done) + return; + + InterlockedIncrement(&waiters); + + /* Get a lock. We create one and try to make it the one-true-lock, + * throwing it away if we lost the race. + */ + + { + /* Scope to protect access to new_lock */ + CRITICAL_SECTION *new_lock = malloc(sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(new_lock); + if (InterlockedCompareExchangePointer(lock_ptr, new_lock, NULL) != NULL) + { + DeleteCriticalSection(new_lock); + free(new_lock); + } + } + + /* At this point, we have a lock that can be synchronized on. We don't + * care which thread actually performed the allocation. + */ + + EnterCriticalSection(lock); + + if (!done) + { + func(); + done = 1; + } + + LeaveCriticalSection(lock); + + /* Last one out should free resources. The destructed objects are + * protected by checking if(done) above. + */ + if(!InterlockedDecrement(&waiters)) + { + DeleteCriticalSection(lock); + free(lock); + lock = NULL; + } +} + + +#elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H +#include +static void once(void (*func)(void)) +{ + static pthread_once_t lock = PTHREAD_ONCE_INIT; + pthread_once(&lock, func); +} + + +#else +/* No-op version that performs no synchronization. vp8_rtcd() is idempotent, + * so as long as your platform provides atomic loads/stores of pointers + * no synchronization is strictly necessary. + */ + +static void once(void (*func)(void)) +{ + static int done; + + if(!done) + { + func(); + done = 1; + } +} +#endif diff --git a/vpx_scale/generic/vpxscale.c b/vpx_scale/generic/vpxscale.c index 7de85ca34..584ad4b31 100644 --- a/vpx_scale/generic/vpxscale.c +++ b/vpx_scale/generic/vpxscale.c @@ -20,7 +20,7 @@ /**************************************************************************** * Header Files ****************************************************************************/ -#include "./vpx_rtcd.h" +#include "./vpx_scale_rtcd.h" #include "vpx_mem/vpx_mem.h" #include "vpx_scale/yv12config.h" #include "vpx_scale/scale_mode.h" diff --git a/vpx_scale/rtcd.c b/vpx_scale/rtcd.c new file mode 100644 index 000000000..656a22f52 --- /dev/null +++ b/vpx_scale/rtcd.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2011 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_config.h" +#define RTCD_C +#include "vpx_scale_rtcd.h" +#include "vpx_ports/vpx_once.h" + +void vpx_scale_rtcd() +{ + once(setup_rtcd_internal); +} diff --git a/vpx_scale/vpx_scale.mk b/vpx_scale/vpx_scale.mk index 378b91725..6c93f9f19 100644 --- a/vpx_scale/vpx_scale.mk +++ b/vpx_scale/vpx_scale.mk @@ -6,6 +6,7 @@ SCALE_SRCS-yes += generic/vpxscale.c SCALE_SRCS-yes += generic/yv12config.c SCALE_SRCS-yes += generic/yv12extend.c SCALE_SRCS-$(CONFIG_SPATIAL_RESAMPLING) += generic/gen_scalers.c +SCALE_SRCS-yes += rtcd.c #neon SCALE_SRCS-$(HAVE_NEON) += arm/neon/vp8_vpxyv12_copyframe_func_neon$(ASM) @@ -15,3 +16,5 @@ SCALE_SRCS-$(HAVE_NEON) += arm/neon/vp8_vpxyv12_extendframeborders_neon$(ASM) SCALE_SRCS-$(HAVE_NEON) += arm/neon/yv12extend_arm.c SCALE_SRCS-no += $(SCALE_SRCS_REMOVE-yes) + +$(eval $(call rtcd_h_template,vpx_scale_rtcd,vpx_scale/vpx_scale_rtcd.sh)) diff --git a/vpx_scale/vpx_scale_rtcd.sh b/vpx_scale/vpx_scale_rtcd.sh new file mode 100644 index 000000000..f709aa61c --- /dev/null +++ b/vpx_scale/vpx_scale_rtcd.sh @@ -0,0 +1,41 @@ +vpx_scale_forward_decls() { +cat < filename\n\n" "Options:\n", exec_name); arg_show_usage(stderr, all_args); -#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER +#if CONFIG_VP8_DECODER fprintf(stderr, "\nVP8 Postprocessing Options:\n"); arg_show_usage(stderr, vp8_pp_args); #endif @@ -692,7 +693,7 @@ int main(int argc, const char **argv_) { unsigned int fps_num; void *out = NULL; vpx_codec_dec_cfg_t cfg = {0}; -#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER +#if CONFIG_VP8_DECODER vp8_postproc_cfg_t vp8_pp_cfg = {0}; int vp8_dbg_color_ref_frame = 0; int vp8_dbg_color_mb_modes = 0; @@ -752,7 +753,7 @@ int main(int argc, const char **argv_) { else if (arg_match(&arg, &verbosearg, argi)) quiet = 0; -#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER +#if CONFIG_VP8_DECODER else if (arg_match(&arg, &addnoise_level, argi)) { postproc = 1; vp8_pp_cfg.post_proc_flag |= VP8_ADDNOISE; @@ -924,7 +925,7 @@ int main(int argc, const char **argv_) { if (!quiet) fprintf(stderr, "%s\n", decoder.name); -#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER +#if CONFIG_VP8_DECODER if (vp8_pp_cfg.post_proc_flag && vpx_codec_control(&decoder, VP8_SET_POSTPROC, &vp8_pp_cfg)) { diff --git a/vpxenc.c b/vpxenc.c index beb7030c4..68b7a5c25 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -94,13 +94,13 @@ static const struct codec_item { } codecs[] = { #if CONFIG_VP8_ENCODER && CONFIG_VP8_DECODER {"vp8", &vpx_codec_vp8_cx, &vpx_codec_vp8_dx, 0x30385056}, -#elif CONFIG_VP9_ENCODER && !CONFIG_VP9_DECODER +#elif CONFIG_VP8_ENCODER && !CONFIG_VP8_DECODER {"vp8", &vpx_codec_vp8_cx, NULL, 0x30385056}, #endif #if CONFIG_VP9_ENCODER && CONFIG_VP9_DECODER - {"vp9", &vpx_codec_vp8_cx, &vpx_codec_vp8_dx, 0x30385056}, + {"vp9", &vpx_codec_vp9_cx, &vpx_codec_vp9_dx, 0x30395056}, #elif CONFIG_VP9_ENCODER && !CONFIG_VP9_DECODER - {"vp9", &vpx_codec_vp8_cx, NULL, 0x30385056}, + {"vp9", &vpx_codec_vp9_cx, NULL, 0x30395056}, #endif }; @@ -1058,22 +1058,14 @@ static const arg_def_t *kf_args[] = { }; -#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER static const arg_def_t noise_sens = ARG_DEF(NULL, "noise-sensitivity", 1, "Noise sensitivity (frames to blur)"); static const arg_def_t sharpness = ARG_DEF(NULL, "sharpness", 1, "Filter sharpness (0-7)"); static const arg_def_t static_thresh = ARG_DEF(NULL, "static-thresh", 1, "Motion detection threshold"); -#endif - -#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER static const arg_def_t cpu_used = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (-16..16)"); -#endif - - -#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER static const arg_def_t token_parts = ARG_DEF(NULL, "token-parts", 1, "Number of token partitions to use, log2"); static const arg_def_t auto_altref = ARG_DEF(NULL, "auto-alt-ref", 1, @@ -1099,16 +1091,34 @@ static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1, static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode"); #endif +#if CONFIG_VP8_ENCODER static const arg_def_t *vp8_args[] = { &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, &tune_ssim, &cq_level, &max_intra_rate_pct, + NULL +}; +static const int vp8_arg_ctrl_map[] = { + VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, + VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, + VP8E_SET_TOKEN_PARTITIONS, + VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, + VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, + 0 +}; +#endif + +#if CONFIG_VP9_ENCODER +static const arg_def_t *vp9_args[] = { + &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, + &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, + &tune_ssim, &cq_level, &max_intra_rate_pct, #if CONFIG_LOSSLESS &lossless, #endif NULL }; -static const int vp8_arg_ctrl_map[] = { +static const int vp9_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, VP8E_SET_TOKEN_PARTITIONS, @@ -1139,9 +1149,13 @@ static void usage_exit() { arg_show_usage(stdout, rc_twopass_args); fprintf(stderr, "\nKeyframe Placement Options:\n"); arg_show_usage(stdout, kf_args); -#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER +#if CONFIG_VP8_ENCODER fprintf(stderr, "\nVP8 Specific Options:\n"); arg_show_usage(stdout, vp8_args); +#endif +#if CONFIG_VP9_ENCODER + fprintf(stderr, "\nVP9 Specific Options:\n"); + arg_show_usage(stdout, vp9_args); #endif fprintf(stderr, "\nStream timebase (--timebase):\n" " The desired precision of timestamps in the output, expressed\n" @@ -1456,8 +1470,15 @@ static int compare_img(vpx_image_t *img1, vpx_image_t *img2) #define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) +#define MAX(x,y) ((x)>(y)?(x):(y)) +#if CONFIG_VP8_ENCODER && !CONFIG_VP9_ENCODER #define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map) - +#elif !CONFIG_VP8_ENCODER && CONFIG_VP9_ENCODER +#define ARG_CTRL_CNT_MAX NELEMENTS(vp9_arg_ctrl_map) +#else +#define ARG_CTRL_CNT_MAX MAX(NELEMENTS(vp8_arg_ctrl_map), \ + NELEMENTS(vp9_arg_ctrl_map)) +#endif /* Configuration elements common to all streams */ struct global_config { @@ -1738,9 +1759,17 @@ static int parse_stream_params(struct global_config *global, int eos_mark_found = 0; /* Handle codec specific options */ - if (global->codec->iface == vpx_codec_vp8_cx) { + if (0) { +#if CONFIG_VP8_ENCODER + } else if (global->codec->iface == vpx_codec_vp8_cx) { ctrl_args = vp8_args; ctrl_args_map = vp8_arg_ctrl_map; +#endif +#if CONFIG_VP9_ENCODER + } else if (global->codec->iface == vpx_codec_vp9_cx) { + ctrl_args = vp9_args; + ctrl_args_map = vp9_arg_ctrl_map; +#endif } for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {