diff options
50 files changed, 415 insertions, 897 deletions
diff --git a/build/make/Makefile b/build/make/Makefile index 0c5ff64f4..03dacce5e 100644 --- a/build/make/Makefile +++ b/build/make/Makefile @@ -22,6 +22,7 @@ clean:: .DEFAULT install:: .DEFAULT test:: .DEFAULT testdata:: .DEFAULT +utiltest: .DEFAULT # Note: md5sum is not installed on OS X, but openssl is. Openssl may not be @@ -52,8 +53,6 @@ dist: | sed -e 's/MD5(\(.*\))= \([0-9a-f]\{32\}\)/\2 \1/' \ > md5sums.txt;\ fi - - endif ifneq ($(target),) @@ -112,6 +111,8 @@ install:: test:: .PHONY: testdata testdata:: +.PHONY: utiltest +utiltest: # Add compiler flags for intrinsic files $(BUILD_PFX)%_mmx.c.d: CFLAGS += -mmmx @@ -531,3 +531,28 @@ $(OBJS-yes:.o=.d): $(RTCD) ## Update the global src list SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) + +## +## vpxdec/vpxenc tests. +## +ifeq ($(CONFIG_UNIT_TESTS),yes) +TEST_BIN_PATH = . +ifeq ($(CONFIG_MSVS),yes) +# MSVC will build both Debug and Release configurations of tools in a +# sub directory named for the current target. Assume the user wants to +# run the Release tools, and assign TEST_BIN_PATH accordingly. +# TODO(tomfinegan): Is this adequate for ARM? +# TODO(tomfinegan): Support running the debug versions of tools? +TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH)) +endif +utiltest: testdata + $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \ + --test-data-path $(LIBVPX_TEST_DATA_PATH) \ + --bin-path $(TEST_BIN_PATH) + $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \ + --test-data-path $(LIBVPX_TEST_DATA_PATH) \ + --bin-path $(TEST_BIN_PATH) +else +utiltest: + @echo Unit tests must be enabled to make the utiltest target. +endif diff --git a/test/borders_test.cc b/test/borders_test.cc index b30be4580..a2f5a1bdd 100644 --- a/test/borders_test.cc +++ b/test/borders_test.cc @@ -35,7 +35,6 @@ class BordersTest : public ::libvpx_test::EncoderTest, encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); - encoder->Control(VP8E_SET_ARNR_TYPE, 3); } } diff --git a/test/convolve_test.cc b/test/convolve_test.cc index e920de874..37ee0ef2a 100644 --- a/test/convolve_test.cc +++ b/test/convolve_test.cc @@ -306,19 +306,13 @@ TEST_P(ConvolveTest, Copy2D) { << "(" << x << "," << y << ")"; } -const int16_t (*kTestFilterList[])[8] = { - vp9_bilinear_filters, - vp9_sub_pel_filters_8, - vp9_sub_pel_filters_8s, - vp9_sub_pel_filters_8lp -}; -const int kNumFilterBanks = sizeof(kTestFilterList) / - sizeof(kTestFilterList[0]); +const int kNumFilterBanks = 4; const int kNumFilters = 16; TEST(ConvolveTest, FiltersWontSaturateWhenAddedPairwise) { for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) { - const int16_t (*filters)[8] = kTestFilterList[filter_bank]; + const InterpKernel *filters = + vp9_get_interp_kernel(static_cast<INTERP_FILTER>(filter_bank)); for (int i = 0; i < kNumFilters; i++) { const int p0 = filters[i][0] + filters[i][1]; const int p1 = filters[i][2] + filters[i][3]; @@ -345,8 +339,8 @@ TEST_P(ConvolveTest, MatchesReferenceSubpixelFilter) { for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) { - const int16_t (*filters)[8] = kTestFilterList[filter_bank]; - + const InterpKernel *filters = + vp9_get_interp_kernel(static_cast<INTERP_FILTER>(filter_bank)); for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) { for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) { filter_block2d_8_c(in, kInputStride, @@ -399,12 +393,9 @@ TEST_P(ConvolveTest, MatchesReferenceAveragingSubpixelFilter) { } } - const int kNumFilterBanks = sizeof(kTestFilterList) / - sizeof(kTestFilterList[0]); - for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) { - const int16_t (*filters)[8] = kTestFilterList[filter_bank]; - const int kNumFilters = 16; + const InterpKernel *filters = + vp9_get_interp_kernel(static_cast<INTERP_FILTER>(filter_bank)); for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) { for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) { diff --git a/test/cpu_speed_test.cc b/test/cpu_speed_test.cc index be651b4fe..ca201bbc7 100644 --- a/test/cpu_speed_test.cc +++ b/test/cpu_speed_test.cc @@ -37,7 +37,6 @@ class CpuSpeedTest : public ::libvpx_test::EncoderTest, encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); - encoder->Control(VP8E_SET_ARNR_TYPE, 3); } } diff --git a/test/tools_common.sh b/test/tools_common.sh index cd7977156..8e6bc4441 100755 --- a/test/tools_common.sh +++ b/test/tools_common.sh @@ -130,11 +130,9 @@ is_windows_target() { # Echoes yes to stdout when the file named by positional parameter one exists # in LIBVPX_BIN_PATH, and is executable. vpx_tool_available() { - tool_name="${1}" - if [ "$(is_windows_target)" = "yes" ]; then - tool_name="${tool_name}.exe" - fi - [ -x "${LIBVPX_BIN_PATH}/${1}" ] && echo yes + local tool_name="$1" + local tool="${LIBVPX_BIN_PATH}/${tool_name}${VPX_TEST_EXE_SUFFIX}" + [ -x "${tool}" ] && echo yes } # Echoes yes to stdout when vpx_config_option_enabled() reports yes for @@ -178,8 +176,8 @@ vpxdec_available() { # present, is interpreted as a boolean flag that means the input should be sent # to vpxdec via pipe from cat instead of directly. vpxdec() { - input="${1}" - pipe_input=${2} + local input="${1}" + local pipe_input=${2} if [ $# -gt 2 ]; then # shift away $1 and $2 so the remaining arguments can be passed to vpxdec @@ -187,11 +185,7 @@ vpxdec() { shift 2 fi - decoder="${LIBVPX_BIN_PATH}/vpxdec" - - if [ "$(is_windows_target)" = "yes" ]; then - decoder="${decoder}.exe" - fi + local decoder="${LIBVPX_BIN_PATH}/vpxdec${VPX_TEST_EXE_SUFFIX}" if [ -z "${pipe_input}" ]; then "${decoder}" "$input" --summary --noblit "$@" > /dev/null 2>&1 @@ -218,18 +212,14 @@ vpxenc_available() { # Note: Extra flags currently supports a special case: when set to "-" # input is piped to vpxenc via cat. vpxenc() { - encoder="${LIBVPX_BIN_PATH}/vpxenc" - codec="${1}" - width=${2} - height=${3} - frames=${4} - input=${5} - output="${VPX_TEST_OUTPUT_DIR}/${6}" - extra_flags=${7} - - if [ "$(is_windows_target)" = "yes" ]; then - encoder="${encoder}.exe" - fi + local encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}" + local codec="${1}" + local width=${2} + local height=${3} + local frames=${4} + local input=${5} + local output="${VPX_TEST_OUTPUT_DIR}/${6}" + local extra_flags=${7} # Because --ivf must be within the command line to get IVF from vpxenc. if echo "${output}" | egrep -q 'ivf$'; then @@ -421,6 +411,10 @@ if ! mkdir -p "${VPX_TEST_OUTPUT_DIR}" || \ exit 1 fi +if [ "$(is_windows_target)" = "yes" ]; then + VPX_TEST_EXE_SUFFIX=".exe" +fi + trap cleanup EXIT if [ "${VPX_TEST_VERBOSE_OUTPUT}" = "yes" ]; then diff --git a/vp8/common/x86/recon_sse2.asm b/vp8/common/x86/recon_sse2.asm index 1434bcd93..7141f8324 100644 --- a/vp8/common/x86/recon_sse2.asm +++ b/vp8/common/x86/recon_sse2.asm @@ -365,6 +365,7 @@ sym(vp8_intra_pred_uv_tm_%1): GET_GOT rbx push rsi push rdi + push rbx ; end prolog ; read top row @@ -395,8 +396,11 @@ sym(vp8_intra_pred_uv_tm_%1): movsxd rcx, dword ptr arg(1) ;dst_stride .vp8_intra_pred_uv_tm_%1_loop: - movd xmm3, [rsi] - movd xmm5, [rsi+rax] + mov bl, [rsi] + movd xmm3, ebx + + mov bl, [rsi+rax] + movd xmm5, ebx %ifidn %1, sse2 punpcklbw xmm3, xmm0 punpcklbw xmm5, xmm0 @@ -419,6 +423,7 @@ sym(vp8_intra_pred_uv_tm_%1): jnz .vp8_intra_pred_uv_tm_%1_loop ; begin epilog + pop rbx pop rdi pop rsi RESTORE_GOT @@ -486,10 +491,8 @@ sym(vp8_intra_pred_uv_ho_%1): SHADOW_ARGS_TO_STACK 5 push rsi push rdi -%ifidn %1, ssse3 -%ifndef GET_GOT_SAVE_ARG push rbx -%endif +%ifidn %1, ssse3 GET_GOT rbx %endif ; end prolog @@ -507,13 +510,16 @@ sym(vp8_intra_pred_uv_ho_%1): %ifidn %1, ssse3 lea rdx, [rcx*3] movdqa xmm2, [GLOBAL(dc_00001111)] - lea rbx, [rax*3] %endif %ifidn %1, mmx2 .vp8_intra_pred_uv_ho_%1_loop: - movd mm0, [rsi] - movd mm1, [rsi+rax] + mov bl, [rsi] + movd mm0, ebx + + mov bl, [rsi+rax] + movd mm1, ebx + punpcklbw mm0, mm0 punpcklbw mm1, mm1 pshufw mm0, mm0, 0x0 @@ -525,10 +531,19 @@ sym(vp8_intra_pred_uv_ho_%1): dec edx jnz .vp8_intra_pred_uv_ho_%1_loop %else - movd xmm0, [rsi] - movd xmm3, [rsi+rax] - movd xmm1, [rsi+rax*2] - movd xmm4, [rsi+rbx] + mov bl, [rsi] + movd xmm0, ebx + + mov bl, [rsi+rax] + movd xmm3, ebx + + mov bl, [rsi+rax*2] + movd xmm1, ebx + + lea rbx, [rax*3] + mov bl, [rsi+rbx] + movd xmm4, ebx + punpcklbw xmm0, xmm3 punpcklbw xmm1, xmm4 pshufb xmm0, xmm2 @@ -539,10 +554,20 @@ sym(vp8_intra_pred_uv_ho_%1): movhps [rdi+rdx], xmm1 lea rsi, [rsi+rax*4] lea rdi, [rdi+rcx*4] - movd xmm0, [rsi] - movd xmm3, [rsi+rax] - movd xmm1, [rsi+rax*2] - movd xmm4, [rsi+rbx] + + mov bl, [rsi] + movd xmm0, ebx + + mov bl, [rsi+rax] + movd xmm3, ebx + + mov bl, [rsi+rax*2] + movd xmm1, ebx + + lea rbx, [rax*3] + mov bl, [rsi+rbx] + movd xmm4, ebx + punpcklbw xmm0, xmm3 punpcklbw xmm1, xmm4 pshufb xmm0, xmm2 @@ -556,10 +581,8 @@ sym(vp8_intra_pred_uv_ho_%1): ; begin epilog %ifidn %1, ssse3 RESTORE_GOT -%ifndef GET_GOT_SAVE_ARG - pop rbx -%endif %endif + pop rbx pop rdi pop rsi UNSHADOW_ARGS @@ -893,6 +916,7 @@ sym(vp8_intra_pred_y_tm_%1): SAVE_XMM 7 push rsi push rdi + push rbx GET_GOT rbx ; end prolog @@ -926,8 +950,11 @@ sym(vp8_intra_pred_y_tm_%1): mov rdi, arg(0) ;dst; movsxd rcx, dword ptr arg(1) ;dst_stride vp8_intra_pred_y_tm_%1_loop: - movd xmm4, [rsi] - movd xmm5, [rsi+rax] + mov bl, [rsi] + movd xmm4, ebx + + mov bl, [rsi+rax] + movd xmm5, ebx %ifidn %1, sse2 punpcklbw xmm4, xmm0 punpcklbw xmm5, xmm0 @@ -956,6 +983,7 @@ vp8_intra_pred_y_tm_%1_loop: ; begin epilog RESTORE_GOT + pop rbx pop rdi pop rsi RESTORE_XMM @@ -1029,6 +1057,7 @@ sym(vp8_intra_pred_y_ho_sse2): SHADOW_ARGS_TO_STACK 5 push rsi push rdi + push rbx ; end prolog ;arg(2) not used @@ -1041,8 +1070,11 @@ sym(vp8_intra_pred_y_ho_sse2): movsxd rcx, dword ptr arg(1) ;dst_stride vp8_intra_pred_y_ho_sse2_loop: - movd xmm0, [rsi] - movd xmm1, [rsi+rax] + mov bl, [rsi] + movd xmm0, ebx + mov bl, [rsi+rax] + movd xmm1, ebx + ; FIXME use pshufb for ssse3 version punpcklbw xmm0, xmm0 punpcklbw xmm1, xmm1 @@ -1058,6 +1090,7 @@ vp8_intra_pred_y_ho_sse2_loop: jnz vp8_intra_pred_y_ho_sse2_loop ; begin epilog + pop rbx pop rdi pop rsi UNSHADOW_ARGS diff --git a/vp9/common/vp9_blockd.c b/vp9/common/vp9_blockd.c index fedfb18d9..43d6c6ef5 100644 --- a/vp9/common/vp9_blockd.c +++ b/vp9/common/vp9_blockd.c @@ -10,8 +10,8 @@ #include "vp9/common/vp9_blockd.h" -MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, - const MODE_INFO *left_mi, int b) { +PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, + const MODE_INFO *left_mi, int b) { if (b == 0 || b == 2) { if (!left_mi || is_inter_block(&left_mi->mbmi)) return DC_PRED; @@ -23,8 +23,8 @@ MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, } } -MB_PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, - const MODE_INFO *above_mi, int b) { +PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, + const MODE_INFO *above_mi, int b) { if (b == 0 || b == 1) { if (!above_mi || is_inter_block(&above_mi->mbmi)) return DC_PRED; diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 55320a6a4..8ca356dd6 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -77,9 +77,9 @@ typedef enum { ZEROMV, NEWMV, MB_MODE_COUNT -} MB_PREDICTION_MODE; +} PREDICTION_MODE; -static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { +static INLINE int is_inter_mode(PREDICTION_MODE mode) { return mode >= NEARESTMV && mode <= NEWMV; } @@ -94,7 +94,7 @@ static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { is a single probability table. */ typedef struct { - MB_PREDICTION_MODE as_mode; + PREDICTION_MODE as_mode; int_mv as_mv[2]; // first, second inter predictor motion vectors } b_mode_info; @@ -122,14 +122,14 @@ static INLINE int mi_width_log2(BLOCK_SIZE sb_type) { typedef struct { // Common for both INTER and INTRA blocks BLOCK_SIZE sb_type; - MB_PREDICTION_MODE mode; + PREDICTION_MODE mode; TX_SIZE tx_size; uint8_t skip; uint8_t segment_id; uint8_t seg_id_predicted; // valid only when temporal_update is enabled // Only for INTRA blocks - MB_PREDICTION_MODE uv_mode; + PREDICTION_MODE uv_mode; // Only for INTER blocks MV_REFERENCE_FRAME ref_frame[2]; @@ -144,7 +144,7 @@ typedef struct { b_mode_info bmi[4]; } MODE_INFO; -static INLINE MB_PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { +static INLINE PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode : mi->mbmi.mode; } @@ -157,11 +157,11 @@ static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { return mbmi->ref_frame[1] > INTRA_FRAME; } -MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, - const MODE_INFO *left_mi, int b); +PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, + const MODE_INFO *left_mi, int b); -MB_PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, - const MODE_INFO *above_mi, int b); +PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, + const MODE_INFO *above_mi, int b); enum mv_precision { MV_PRECISION_Q3, diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 6788eb698..3dc98a835 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -180,7 +180,7 @@ static const INLINE scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size, if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) { return &vp9_default_scan_orders[tx_size]; } else { - const MB_PREDICTION_MODE mode = get_y_mode(mi, block_idx); + const PREDICTION_MODE mode = get_y_mode(mi, block_idx); return &vp9_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]]; } } diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h index c7b191177..533757bef 100644 --- a/vp9/common/vp9_entropymode.h +++ b/vp9/common/vp9_entropymode.h @@ -101,8 +101,8 @@ static INLINE const vp9_prob *get_y_mode_probs(const MODE_INFO *mi, const MODE_INFO *above_mi, const MODE_INFO *left_mi, int block) { - const MB_PREDICTION_MODE above = vp9_above_block_mode(mi, above_mi, block); - const MB_PREDICTION_MODE left = vp9_left_block_mode(mi, left_mi, block); + const PREDICTION_MODE above = vp9_above_block_mode(mi, above_mi, block); + const PREDICTION_MODE left = vp9_left_block_mode(mi, left_mi, block); return vp9_kf_y_mode_prob[above][left]; } diff --git a/vp9/common/vp9_postproc.c b/vp9/common/vp9_postproc.c index 7baa9ee33..5601a936d 100644 --- a/vp9/common/vp9_postproc.c +++ b/vp9/common/vp9_postproc.c @@ -34,7 +34,7 @@ /* global constants */ #if 0 && CONFIG_POSTPROC_VISUALIZER -static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = { +static const unsigned char PREDICTION_MODE_colors[MB_MODE_COUNT][3] = { { RGB_TO_YUV(0x98FB98) }, /* PaleGreen */ { RGB_TO_YUV(0x00FF00) }, /* Green */ { RGB_TO_YUV(0xADFF2F) }, /* GreenYellow */ @@ -911,9 +911,9 @@ int vp9_post_proc_frame(struct VP9Common *cm, vl += y_stride * 1; } } else if (ppflags->display_mb_modes_flag & (1 << mi->mbmi.mode)) { - Y = MB_PREDICTION_MODE_colors[mi->mbmi.mode][0]; - U = MB_PREDICTION_MODE_colors[mi->mbmi.mode][1]; - V = MB_PREDICTION_MODE_colors[mi->mbmi.mode][2]; + Y = PREDICTION_MODE_colors[mi->mbmi.mode][0]; + U = PREDICTION_MODE_colors[mi->mbmi.mode][1]; + V = PREDICTION_MODE_colors[mi->mbmi.mode][2]; vp9_blend_mb_inner(y_ptr + x, u_ptr + (x >> 1), v_ptr + (x >> 1), Y, U, V, 0xc000, y_stride); diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c index 44951b54d..32e45510c 100644 --- a/vp9/common/vp9_reconintra.c +++ b/vp9/common/vp9_reconintra.c @@ -311,7 +311,7 @@ static void init_intra_pred_fn_ptrs(void) { static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, int ref_stride, uint8_t *dst, int dst_stride, - MB_PREDICTION_MODE mode, TX_SIZE tx_size, + PREDICTION_MODE mode, TX_SIZE tx_size, int up_available, int left_available, int right_available, int x, int y, int plane) { @@ -434,7 +434,7 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, } void vp9_predict_intra_block(const MACROBLOCKD *xd, int block_idx, int bwl_in, - TX_SIZE tx_size, MB_PREDICTION_MODE mode, + TX_SIZE tx_size, PREDICTION_MODE mode, const uint8_t *ref, int ref_stride, uint8_t *dst, int dst_stride, int aoff, int loff, int plane) { diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h index abc176787..d09d2a129 100644 --- a/vp9/common/vp9_reconintra.h +++ b/vp9/common/vp9_reconintra.h @@ -19,7 +19,7 @@ extern "C" { #endif void vp9_predict_intra_block(const MACROBLOCKD *xd, int block_idx, int bwl_in, - TX_SIZE tx_size, MB_PREDICTION_MODE mode, + TX_SIZE tx_size, PREDICTION_MODE mode, const uint8_t *ref, int ref_stride, uint8_t *dst, int dst_stride, int aoff, int loff, int plane); diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 022a4296f..b953452c5 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -246,8 +246,8 @@ static void predict_and_reconstruct_intra_block(int plane, int block, MACROBLOCKD *const xd = args->xd; struct macroblockd_plane *const pd = &xd->plane[plane]; MODE_INFO *const mi = xd->mi[0]; - const MB_PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) - : mi->mbmi.uv_mode; + const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) + : mi->mbmi.uv_mode; int x, y; uint8_t *dst; txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 3618f12d0..1afaee1e3 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -23,30 +23,29 @@ #include "vp9/decoder/vp9_decodeframe.h" #include "vp9/decoder/vp9_reader.h" -static MB_PREDICTION_MODE read_intra_mode(vp9_reader *r, const vp9_prob *p) { - return (MB_PREDICTION_MODE)vp9_read_tree(r, vp9_intra_mode_tree, p); +static PREDICTION_MODE read_intra_mode(vp9_reader *r, const vp9_prob *p) { + return (PREDICTION_MODE)vp9_read_tree(r, vp9_intra_mode_tree, p); } -static MB_PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, vp9_reader *r, +static PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, vp9_reader *r, int size_group) { - const MB_PREDICTION_MODE y_mode = read_intra_mode(r, - cm->fc.y_mode_prob[size_group]); + const PREDICTION_MODE y_mode = + read_intra_mode(r, cm->fc.y_mode_prob[size_group]); if (!cm->frame_parallel_decoding_mode) ++cm->counts.y_mode[size_group][y_mode]; return y_mode; } -static MB_PREDICTION_MODE read_intra_mode_uv(VP9_COMMON *cm, vp9_reader *r, - MB_PREDICTION_MODE y_mode) { - const MB_PREDICTION_MODE uv_mode = read_intra_mode(r, +static PREDICTION_MODE read_intra_mode_uv(VP9_COMMON *cm, vp9_reader *r, + PREDICTION_MODE y_mode) { + const PREDICTION_MODE uv_mode = read_intra_mode(r, cm->fc.uv_mode_prob[y_mode]); if (!cm->frame_parallel_decoding_mode) ++cm->counts.uv_mode[y_mode][uv_mode]; return uv_mode; } -static MB_PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r, - int ctx) { +static PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r, int ctx) { const int mode = vp9_read_tree(r, vp9_inter_mode_tree, cm->fc.inter_mode_probs[ctx]); if (!cm->frame_parallel_decoding_mode) @@ -362,7 +361,7 @@ static INLINE int is_mv_valid(const MV *mv) { mv->col > MV_LOW && mv->col < MV_UPP; } -static INLINE int assign_mv(VP9_COMMON *cm, MB_PREDICTION_MODE mode, +static INLINE int assign_mv(VP9_COMMON *cm, PREDICTION_MODE mode, int_mv mv[2], int_mv ref_mv[2], int_mv nearest_mv[2], int_mv near_mv[2], int is_compound, int allow_hp, vp9_reader *r) { @@ -469,7 +468,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm, const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2 int idx, idy; - MB_PREDICTION_MODE b_mode; + PREDICTION_MODE b_mode; int_mv nearest_sub8x8[2], near_sub8x8[2]; for (idy = 0; idy < 2; idy += num_4x4_h) { for (idx = 0; idx < 2; idx += num_4x4_w) { diff --git a/vp9/decoder/vp9_dsubexp.c b/vp9/decoder/vp9_dsubexp.c index e67b37240..c22617edb 100644 --- a/vp9/decoder/vp9_dsubexp.c +++ b/vp9/decoder/vp9_dsubexp.c @@ -26,22 +26,6 @@ static int decode_uniform(vp9_reader *r) { return v < m ? v : (v << 1) - m + vp9_read_bit(r); } - -static int merge_index(int v, int n, int modulus) { - int max1 = (n - 1 - modulus / 2) / modulus + 1; - if (v < max1) { - v = v * modulus + modulus / 2; - } else { - int w; - v -= max1; - w = v; - v += (v + modulus - modulus / 2) / modulus; - while (v % modulus == modulus / 2 || - w != v - (v + modulus - modulus / 2) / modulus) v++; - } - return v; -} - static int inv_remap_prob(int v, int m) { static int inv_map_table[MAX_PROB - 1] = { 6, 19, 32, 45, 58, 71, 84, 97, 110, 123, 136, 149, 162, 175, 188, diff --git a/vp9/encoder/vp9_aq_variance.h b/vp9/encoder/vp9_aq_variance.h index 381fe50cf..d1a459fe9 100644 --- a/vp9/encoder/vp9_aq_variance.h +++ b/vp9/encoder/vp9_aq_variance.h @@ -12,7 +12,7 @@ #ifndef VP9_ENCODER_VP9_AQ_VARIANCE_H_ #define VP9_ENCODER_VP9_AQ_VARIANCE_H_ -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #ifdef __cplusplus extern "C" { diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 8d2afb991..c5a85c9df 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -47,12 +47,12 @@ void vp9_entropy_mode_init() { vp9_tokens_from_tree(inter_mode_encodings, vp9_inter_mode_tree); } -static void write_intra_mode(vp9_writer *w, MB_PREDICTION_MODE mode, +static void write_intra_mode(vp9_writer *w, PREDICTION_MODE mode, const vp9_prob *probs) { vp9_write_token(w, vp9_intra_mode_tree, probs, &intra_mode_encodings[mode]); } -static void write_inter_mode(vp9_writer *w, MB_PREDICTION_MODE mode, +static void write_inter_mode(vp9_writer *w, PREDICTION_MODE mode, const vp9_prob *probs) { assert(is_inter_mode(mode)); vp9_write_token(w, vp9_inter_mode_tree, probs, @@ -233,7 +233,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, const MACROBLOCKD *const xd = &x->e_mbd; const struct segmentation *const seg = &cm->seg; const MB_MODE_INFO *const mbmi = &mi->mbmi; - const MB_PREDICTION_MODE mode = mbmi->mode; + const PREDICTION_MODE mode = mbmi->mode; const int segment_id = mbmi->segment_id; const BLOCK_SIZE bsize = mbmi->sb_type; const int allow_hp = cm->allow_high_precision_mv; @@ -273,7 +273,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; for (idy = 0; idy < 2; idy += num_4x4_h) { for (idx = 0; idx < 2; idx += num_4x4_w) { - const MB_PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode; + const PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode; write_intra_mode(w, b_mode, cm->fc.y_mode_prob[0]); } } @@ -308,7 +308,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, for (idy = 0; idy < 2; idy += num_4x4_h) { for (idx = 0; idx < 2; idx += num_4x4_w) { const int j = idy * 2 + idx; - const MB_PREDICTION_MODE b_mode = mi->bmi[j].as_mode; + const PREDICTION_MODE b_mode = mi->bmi[j].as_mode; write_inter_mode(w, b_mode, inter_probs); ++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(b_mode)]; if (b_mode == NEWMV) { @@ -903,7 +903,7 @@ static int get_refresh_mask(VP9_COMP *cpi) { // other uses are implemented (like RTC/temporal scaling) // // gld_fb_idx and alt_fb_idx need to be swapped for future frames, but - // that happens in vp9_onyx_if.c:update_reference_frames() so that it can + // that happens in vp9_encoder.c:update_reference_frames() so that it can // be done outside of the recode loop. return (cpi->refresh_last_frame << cpi->lst_fb_idx) | (cpi->refresh_golden_frame << cpi->alt_fb_idx); diff --git a/vp9/encoder/vp9_context_tree.h b/vp9/encoder/vp9_context_tree.h index 40d7394ed..66a6f00e3 100644 --- a/vp9/encoder/vp9_context_tree.h +++ b/vp9/encoder/vp9_context_tree.h @@ -11,7 +11,7 @@ #ifndef VP9_ENCODER_VP9_CONTEXT_TREE_H_ #define VP9_ENCODER_VP9_CONTEXT_TREE_H_ -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" void vp9_setup_pc_tree(VP9_COMMON *cm, MACROBLOCK *x); void vp9_free_pc_tree(MACROBLOCK *x); diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 9956acc0b..2e44f7df3 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -2412,7 +2412,7 @@ typedef enum { } motion_vector_context; static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, - MB_PREDICTION_MODE mode) { + PREDICTION_MODE mode) { mbmi->mode = mode; mbmi->uv_mode = mode; mbmi->mv[0].as_int = 0; @@ -2444,8 +2444,7 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize); } else { - MB_PREDICTION_MODE intramode = DC_PRED; - set_mode_info(&xd->mi[0]->mbmi, bsize, intramode); + set_mode_info(&xd->mi[0]->mbmi, bsize, DC_PRED); } duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); } @@ -3209,8 +3208,8 @@ void vp9_encode_frame(VP9_COMP *cpi) { } static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi) { - const MB_PREDICTION_MODE y_mode = mi->mbmi.mode; - const MB_PREDICTION_MODE uv_mode = mi->mbmi.uv_mode; + const PREDICTION_MODE y_mode = mi->mbmi.mode; + const PREDICTION_MODE uv_mode = mi->mbmi.uv_mode; const BLOCK_SIZE bsize = mi->mbmi.sb_type; if (bsize < BLOCK_8X8) { diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index b0c014eef..baa466554 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -473,7 +473,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); const scan_order *scan_order; TX_TYPE tx_type; - MB_PREDICTION_MODE mode; + PREDICTION_MODE mode; const int bwl = b_width_log2(plane_bsize); const int diff_stride = 4 * (1 << bwl); uint8_t *src, *dst; diff --git a/vp9/encoder/vp9_encodemb.h b/vp9/encoder/vp9_encodemb.h index dcf6e8759..edef1e224 100644 --- a/vp9/encoder/vp9_encodemb.h +++ b/vp9/encoder/vp9_encodemb.h @@ -13,7 +13,7 @@ #include "./vpx_config.h" #include "vp9/encoder/vp9_block.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/common/vp9_onyxc_int.h" #ifdef __cplusplus diff --git a/vp9/encoder/vp9_encodemv.h b/vp9/encoder/vp9_encodemv.h index 50cb9611b..e67f9e3b0 100644 --- a/vp9/encoder/vp9_encodemv.h +++ b/vp9/encoder/vp9_encodemv.h @@ -12,7 +12,7 @@ #ifndef VP9_ENCODER_VP9_ENCODEMV_H_ #define VP9_ENCODER_VP9_ENCODEMV_H_ -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #ifdef __cplusplus extern "C" { diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_encoder.c index 08a469ceb..370825883 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_encoder.c @@ -36,7 +36,7 @@ #include "vp9/encoder/vp9_encodemv.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_mbgraph.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_picklpf.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" @@ -555,7 +555,7 @@ static void init_config(struct VP9_COMP *cpi, VP9EncoderConfig *oxcf) { cpi->svc.number_temporal_layers = oxcf->ts_number_layers; if ((cpi->svc.number_temporal_layers > 1 && - cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) || + cpi->oxcf.rc_mode == RC_MODE_CBR) || (cpi->svc.number_spatial_layers > 1 && cpi->oxcf.mode == TWO_PASS_SECOND_BEST)) { vp9_init_layer_context(cpi); @@ -642,7 +642,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { cpi->encode_breakout = cpi->oxcf.encode_breakout; // local file playback mode == really big buffer - if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) { + if (cpi->oxcf.rc_mode == RC_MODE_VBR) { cpi->oxcf.starting_buffer_level = 60000; cpi->oxcf.optimal_buffer_level = 60000; cpi->oxcf.maximum_buffer_size = 240000; @@ -696,7 +696,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { update_frame_size(cpi); if ((cpi->svc.number_temporal_layers > 1 && - cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) || + cpi->oxcf.rc_mode == RC_MODE_CBR) || (cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) { vp9_update_layer_context_change_config(cpi, (int)cpi->oxcf.target_bandwidth); @@ -1600,7 +1600,7 @@ static int recode_loop_test(const VP9_COMP *cpi, if ((rc->projected_frame_size > high_limit && q < maxq) || (rc->projected_frame_size < low_limit && q > minq)) { force_recode = 1; - } else if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) { + } else if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY) { // Deal with frame undershoot and whether or not we are // below the automatically set cq level. if (q > oxcf->cq_level && @@ -1897,7 +1897,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi, frame_over_shoot_limit = 1; } - if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { + if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) { loop = 0; } else { if ((cm->frame_type == KEY_FRAME) && @@ -1995,7 +1995,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi, // This should only trigger where there is very substantial // undershoot on a frame and the auto cq level is above // the user passsed in value. - if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY && + if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY && q < q_low) { q_low = q; } @@ -2083,8 +2083,9 @@ static void set_ext_overrides(VP9_COMP *cpi) { } } -static YV12_BUFFER_CONFIG *scale_if_required(VP9_COMMON *cm, - YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled) { +YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled) { if (cm->mi_cols * MI_SIZE != unscaled->y_width || cm->mi_rows * MI_SIZE != unscaled->y_height) { scale_and_extend_frame_nonnormative(unscaled, scaled); @@ -2109,12 +2110,12 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, struct segmentation *const seg = &cm->seg; set_ext_overrides(cpi); - cpi->Source = scale_if_required(cm, cpi->un_scaled_source, - &cpi->scaled_source); + cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source, + &cpi->scaled_source); if (cpi->unscaled_last_source != NULL) - cpi->Last_Source = scale_if_required(cm, cpi->unscaled_last_source, - &cpi->scaled_last_source); + cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source, + &cpi->scaled_last_source); vp9_scale_references(cpi); @@ -2192,7 +2193,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, // For 1 pass CBR, check if we are dropping this frame. // Never drop on key frame. if (cpi->pass == 0 && - cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER && + cpi->oxcf.rc_mode == RC_MODE_CBR && cm->frame_type != KEY_FRAME) { if (vp9_rc_drop_frame(cpi)) { vp9_rc_postencode_update_drop_frame(cpi); @@ -2389,7 +2390,7 @@ static void SvcEncode(VP9_COMP *cpi, size_t *size, uint8_t *dest, static void Pass0Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest, unsigned int *frame_flags) { - if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { + if (cpi->oxcf.rc_mode == RC_MODE_CBR) { vp9_rc_get_one_pass_cbr_params(cpi); } else { vp9_rc_get_one_pass_vbr_params(cpi); @@ -2680,7 +2681,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } if (cpi->svc.number_temporal_layers > 1 && - cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { + cpi->oxcf.rc_mode == RC_MODE_CBR) { vp9_update_temporal_layer_framerate(cpi); vp9_restore_layer_context(cpi); } @@ -2713,7 +2714,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, if (cpi->pass == 2 && cm->current_video_frame == 0 && cpi->oxcf.allow_spatial_resampling && - cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) { + cpi->oxcf.rc_mode == RC_MODE_VBR) { // Internal scaling is triggered on the first frame. vp9_set_size_literal(cpi, cpi->oxcf.scaled_frame_width, cpi->oxcf.scaled_frame_height); @@ -2772,7 +2773,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, // Save layer specific state. if ((cpi->svc.number_temporal_layers > 1 && - cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) || + cpi->oxcf.rc_mode == RC_MODE_CBR) || (cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) { vp9_save_layer_context(cpi); } @@ -2894,9 +2895,10 @@ int vp9_set_roimap(VP9_COMP *cpi, unsigned char *map, unsigned int rows, unsigned int threshold[MAX_SEGMENTS]) { signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS]; struct segmentation *seg = &cpi->common.seg; + const VP9_COMMON *const cm = &cpi->common; int i; - if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols) + if (cm->mb_rows != rows || cm->mb_cols != cols) return -1; if (!map) { @@ -2904,8 +2906,7 @@ int vp9_set_roimap(VP9_COMP *cpi, unsigned char *map, unsigned int rows, return 0; } - // Set the segmentation Map - vp9_set_segmentation_map(cpi, map); + vpx_memcpy(cpi->segmentation_map, map, cm->mi_rows * cm->mi_cols); // Activate segmentation. vp9_enable_segmentation(seg); diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_encoder.h index 5f4112369..de8f3c914 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_encoder.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef VP9_ENCODER_VP9_ONYX_INT_H_ -#define VP9_ENCODER_VP9_ONYX_INT_H_ +#ifndef VP9_ENCODER_VP9_ENCODER_H_ +#define VP9_ENCODER_VP9_ENCODER_H_ #include <stdio.h> @@ -132,11 +132,11 @@ typedef enum { } VPX_SCALING; typedef enum { - USAGE_LOCAL_FILE_PLAYBACK = 0, - USAGE_STREAM_FROM_SERVER = 1, - USAGE_CONSTRAINED_QUALITY = 2, - USAGE_CONSTANT_QUALITY = 3, -} END_USAGE; + RC_MODE_VBR = 0, + RC_MODE_CBR = 1, + RC_MODE_CONSTRAINED_QUALITY = 2, + RC_MODE_CONSTANT_QUALITY = 3, +} RC_MODE; typedef enum { // Good Quality Fast Encoding. The encoder balances quality with the @@ -210,7 +210,7 @@ typedef struct VP9EncoderConfig { // ---------------------------------------------------------------- // DATARATE CONTROL OPTIONS - END_USAGE end_usage; // vbr or cbr + RC_MODE rc_mode; // vbr, cbr, constrained quality or constant quality // buffer targeting aggressiveness int under_shoot_pct; @@ -276,7 +276,6 @@ typedef struct VP9EncoderConfig { int arnr_max_frames; int arnr_strength; - int arnr_type; int tile_columns; int tile_rows; @@ -618,6 +617,10 @@ void vp9_update_reference_frames(VP9_COMP *cpi); int64_t vp9_rescale(int64_t val, int64_t num, int denom); +YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled); + static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, MV_REFERENCE_FRAME ref0, MV_REFERENCE_FRAME ref1) { @@ -631,4 +634,4 @@ static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, } // extern "C" #endif -#endif // VP9_ENCODER_VP9_ONYX_INT_H_ +#endif // VP9_ENCODER_VP9_ENCODER_H_ diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 1dacfaaae..314f8ab84 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -28,10 +28,10 @@ #include "vp9/encoder/vp9_encodeframe.h" #include "vp9/encoder/vp9_encodemb.h" #include "vp9/encoder/vp9_encodemv.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_extend.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_mcomp.h" -#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" @@ -533,6 +533,9 @@ void vp9_first_pass(VP9_COMP *cpi) { // Disable golden frame for svc first pass for now. gld_yv12 = NULL; set_ref_ptrs(cm, xd, ref_frame, NONE); + + cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source, + &cpi->scaled_source); } vp9_setup_src_planes(x, cpi->Source, 0, 0); @@ -849,6 +852,8 @@ void vp9_first_pass(VP9_COMP *cpi) { ++twopass->sr_update_lag; } + vp9_extend_frame_borders(new_yv12); + if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) { vp9_update_reference_frames(cpi); } else { @@ -856,8 +861,6 @@ void vp9_first_pass(VP9_COMP *cpi) { swap_yv12(lst_yv12, new_yv12); } - vp9_extend_frame_borders(lst_yv12); - // Special case for the first frame. Copy into the GF buffer as a second // reference. if (cm->current_video_frame == 0 && gld_yv12 != NULL) { @@ -930,7 +933,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi, } // Restriction on active max q for constrained quality mode. - if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) + if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY) q = MAX(q, oxcf->cq_level); return q; } @@ -2244,7 +2247,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { cm->frame_type = INTER_FRAME; #ifdef LONG_TERM_VBR_CORRECTION // Correction to rate target based on prior over or under shoot. - if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) + if (cpi->oxcf.rc_mode == RC_MODE_VBR) vbr_rate_correction(&modified_target, rc->vbr_bits_off_target); #endif vp9_rc_set_frame_target(cpi, modified_target); @@ -2258,7 +2261,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { twopass->gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs; } - if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { + if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) { twopass->active_worst_quality = cpi->oxcf.cq_level; } else if (cm->current_video_frame == 0 || (is_spatial_svc && lc->current_video_frame_in_layer == 0)) { @@ -2346,7 +2349,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { rc->base_frame_target = target; #ifdef LONG_TERM_VBR_CORRECTION // Correction to rate target based on prior over or under shoot. - if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) + if (cpi->oxcf.rc_mode == RC_MODE_VBR) vbr_rate_correction(&target, rc->vbr_bits_off_target); #endif vp9_rc_set_frame_target(cpi, target); diff --git a/vp9/encoder/vp9_lookahead.c b/vp9/encoder/vp9_lookahead.c index cf03e0142..a298f1c20 100644 --- a/vp9/encoder/vp9_lookahead.c +++ b/vp9/encoder/vp9_lookahead.c @@ -14,9 +14,9 @@ #include "vp9/common/vp9_common.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_extend.h" #include "vp9/encoder/vp9_lookahead.h" -#include "vp9/encoder/vp9_onyx_int.h" struct lookahead_ctx { unsigned int max_sz; /* Absolute size of the queue */ diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index 2f63a13a0..e7dcc7a18 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -131,11 +131,10 @@ static int do_16x16_zerozero_search(VP9_COMP *cpi, int_mv *dst_mv) { return err; } -static int find_best_16x16_intra(VP9_COMP *cpi, - MB_PREDICTION_MODE *pbest_mode) { +static int find_best_16x16_intra(VP9_COMP *cpi, PREDICTION_MODE *pbest_mode) { MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; - MB_PREDICTION_MODE best_mode = -1, mode; + PREDICTION_MODE best_mode = -1, mode; unsigned int best_err = INT_MAX; // calculate SATD for each intra prediction mode; diff --git a/vp9/encoder/vp9_mbgraph.h b/vp9/encoder/vp9_mbgraph.h index bc2a7048f..c3af972bc 100644 --- a/vp9/encoder/vp9_mbgraph.h +++ b/vp9/encoder/vp9_mbgraph.h @@ -20,7 +20,7 @@ typedef struct { int err; union { int_mv mv; - MB_PREDICTION_MODE mode; + PREDICTION_MODE mode; } m; } ref[MAX_REF_FRAMES]; } MBGRAPH_MB_STATS; diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 8a7901172..89937f5a6 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -18,7 +18,7 @@ #include "vp9/common/vp9_common.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_mcomp.h" // #define NEW_DIAMOND_SEARCH diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c index e003a0f42..7c42bb84f 100644 --- a/vp9/encoder/vp9_picklpf.c +++ b/vp9/encoder/vp9_picklpf.c @@ -19,7 +19,7 @@ #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_quant_common.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_picklpf.h" #include "vp9/encoder/vp9_quantize.h" diff --git a/vp9/encoder/vp9_picklpf.h b/vp9/encoder/vp9_picklpf.h index 7d08ddb5f..33c490f69 100644 --- a/vp9/encoder/vp9_picklpf.h +++ b/vp9/encoder/vp9_picklpf.h @@ -16,7 +16,7 @@ extern "C" { #endif -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" struct yv12_buffer_config; struct VP9_COMP; diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 3d398edc9..7a9260afe 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -22,7 +22,7 @@ #include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_reconintra.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" @@ -212,7 +212,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0]; - MB_PREDICTION_MODE this_mode, best_mode = ZEROMV; + PREDICTION_MODE this_mode, best_mode = ZEROMV; MV_REFERENCE_FRAME ref_frame, best_ref_frame = LAST_FRAME; INTERP_FILTER best_pred_filter = EIGHTTAP; int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; @@ -235,7 +235,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, unsigned char segment_id = mbmi->segment_id; const int *const rd_threshes = cpi->rd.threshes[segment_id][bsize]; const int *const rd_thresh_freq_fact = cpi->rd.thresh_freq_fact[bsize]; - // Mode index conversion form THR_MODES to MB_PREDICTION_MODE for a ref frame. + // Mode index conversion form THR_MODES to PREDICTION_MODE for a ref frame. int mode_idx[MB_MODE_COUNT] = {0}; INTERP_FILTER filter_ref = SWITCHABLE; diff --git a/vp9/encoder/vp9_pickmode.h b/vp9/encoder/vp9_pickmode.h index 05ff18762..a9c948d31 100644 --- a/vp9/encoder/vp9_pickmode.h +++ b/vp9/encoder/vp9_pickmode.h @@ -11,7 +11,7 @@ #ifndef VP9_ENCODER_VP9_PICKMODE_H_ #define VP9_ENCODER_VP9_PICKMODE_H_ -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #ifdef __cplusplus extern "C" { diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c index 2b2aa9add..5206bb671 100644 --- a/vp9/encoder/vp9_quantize.c +++ b/vp9/encoder/vp9_quantize.c @@ -15,7 +15,7 @@ #include "vp9/common/vp9_quant_common.h" #include "vp9/common/vp9_seg_common.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_rdopt.h" @@ -242,10 +242,10 @@ void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { } #if CONFIG_ALPHA - x->plane[3].quant = cpi->a_quant[qindex]; - x->plane[3].quant_shift = cpi->a_quant_shift[qindex]; - x->plane[3].zbin = cpi->a_zbin[qindex]; - x->plane[3].round = cpi->a_round[qindex]; + x->plane[3].quant = quants->a_quant[qindex]; + x->plane[3].quant_shift = quants->a_quant_shift[qindex]; + x->plane[3].zbin = quants->a_zbin[qindex]; + x->plane[3].round = quants->a_round[qindex]; x->plane[3].zbin_extra = (int16_t)((cm->a_dequant[qindex][1] * zbin) >> 7); xd->plane[3].dequant = cm->a_dequant[qindex]; #endif diff --git a/vp9/encoder/vp9_quantize.h b/vp9/encoder/vp9_quantize.h index 7a9388300..1835e9ccc 100644 --- a/vp9/encoder/vp9_quantize.h +++ b/vp9/encoder/vp9_quantize.h @@ -11,6 +11,7 @@ #ifndef VP9_ENCODER_VP9_QUANTIZE_H_ #define VP9_ENCODER_VP9_QUANTIZE_H_ +#include "./vpx_config.h" #include "vp9/encoder/vp9_block.h" #ifdef __cplusplus diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index b8d0ec40d..2e35e5fbc 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -181,13 +181,13 @@ static void update_buffer_level(VP9_COMP *cpi, int encoded_frame_size) { rc->bits_off_target = MIN(rc->bits_off_target, oxcf->maximum_buffer_size); rc->buffer_level = rc->bits_off_target; - if (cpi->use_svc && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { + if (cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR) { update_layer_buffer_level(&cpi->svc, encoded_frame_size); } } void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { - if (pass == 0 && oxcf->end_usage == USAGE_STREAM_FROM_SERVER) { + if (pass == 0 && oxcf->rc_mode == RC_MODE_CBR) { rc->avg_frame_qindex[0] = oxcf->worst_allowed_q; rc->avg_frame_qindex[1] = oxcf->worst_allowed_q; rc->avg_frame_qindex[2] = oxcf->worst_allowed_q; @@ -280,7 +280,7 @@ static double get_rate_correction_factor(const VP9_COMP *cpi) { } else { if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) && !cpi->rc.is_src_frame_alt_ref && - !(cpi->use_svc && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)) + !(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR)) return cpi->rc.gf_rate_correction_factor; else return cpi->rc.rate_correction_factor; @@ -293,7 +293,7 @@ static void set_rate_correction_factor(VP9_COMP *cpi, double factor) { } else { if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) && !cpi->rc.is_src_frame_alt_ref && - !(cpi->use_svc && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)) + !(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR)) cpi->rc.gf_rate_correction_factor = factor; else cpi->rc.rate_correction_factor = factor; @@ -671,7 +671,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, q = rc->avg_frame_qindex[KEY_FRAME]; } // For constrained quality dont allow Q less than the cq level - if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) { if (q < cq_level) q = cq_level; if (rc->frames_since_key > 1) { @@ -688,7 +688,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, // Constrained quality use slightly lower active best. active_best_quality = active_best_quality * 15 / 16; - } else if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + } else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { if (!cpi->refresh_alt_ref_frame) { active_best_quality = cq_level; } else { @@ -708,7 +708,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, gf_low_motion_minq, gf_high_motion_minq); } } else { - if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { active_best_quality = cq_level; } else { // Use the lower of active_worst_quality and recent/average Q. @@ -718,7 +718,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, active_best_quality = inter_minq[rc->avg_frame_qindex[KEY_FRAME]]; // For the constrained quality mode we don't want // q to fall below the cq level. - if ((oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) && + if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) && (active_best_quality < cq_level)) { active_best_quality = cq_level; } @@ -755,7 +755,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, } #endif - if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { q = active_best_quality; // Special case code to try and match quality with forced key frames } else if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced) { @@ -774,7 +774,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi, #if CONFIG_MULTIPLE_ARF // Force the quantizer determined by the coding order pattern. if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) && - cpi->oxcf.end_usage != USAGE_CONSTANT_QUALITY) { + cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) { double new_q; double current_q = vp9_convert_qindex_to_q(active_worst_quality); int level = cpi->this_frame_weight; @@ -862,7 +862,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, q = active_worst_quality; } // For constrained quality dont allow Q less than the cq level - if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) { if (q < cq_level) q = cq_level; if (rc->frames_since_key > 1) { @@ -879,7 +879,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, // Constrained quality use slightly lower active best. active_best_quality = active_best_quality * 15 / 16; - } else if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + } else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { if (!cpi->refresh_alt_ref_frame) { active_best_quality = cq_level; } else { @@ -899,14 +899,14 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, gf_low_motion_minq, gf_high_motion_minq); } } else { - if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { active_best_quality = cq_level; } else { active_best_quality = inter_minq[active_worst_quality]; // For the constrained quality mode we don't want // q to fall below the cq level. - if ((oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) && + if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) && (active_best_quality < cq_level)) { active_best_quality = cq_level; } @@ -932,7 +932,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, qdelta = vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, active_worst_quality, 2.0); } else if (!rc->is_src_frame_alt_ref && - (oxcf->end_usage != USAGE_STREAM_FROM_SERVER) && + (oxcf->rc_mode != RC_MODE_CBR) && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { qdelta = vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, active_worst_quality, 1.75); @@ -942,7 +942,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, } #endif - if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) { + if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) { q = active_best_quality; // Special case code to try and match quality with forced key frames. } else if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced) { @@ -961,7 +961,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, #if CONFIG_MULTIPLE_ARF // Force the quantizer determined by the coding order pattern. if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) && - cpi->oxcf.end_usage != USAGE_CONSTANT_QUALITY) { + cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) { double new_q; double current_q = vp9_convert_qindex_to_q(active_worst_quality); int level = cpi->this_frame_weight; @@ -987,7 +987,7 @@ int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi, int *bottom_index, int *top_index) { int q; if (cpi->pass == 0) { - if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) + if (cpi->oxcf.rc_mode == RC_MODE_CBR) q = rc_pick_q_and_bounds_one_pass_cbr(cpi, bottom_index, top_index); else q = rc_pick_q_and_bounds_one_pass_vbr(cpi, bottom_index, top_index); @@ -1015,7 +1015,7 @@ void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi, int frame_target, int *frame_under_shoot_limit, int *frame_over_shoot_limit) { - if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { + if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) { *frame_under_shoot_limit = 0; *frame_over_shoot_limit = INT_MAX; } else { @@ -1090,7 +1090,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { // Post encode loop adjustment of Q prediction. vp9_rc_update_rate_correction_factors( cpi, (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF || - oxcf->end_usage == USAGE_STREAM_FROM_SERVER) ? 2 : 0); + oxcf->rc_mode == RC_MODE_CBR) ? 2 : 0); // Keep a record of last Q and ambient average Q. if (cm->frame_type == KEY_FRAME) { @@ -1099,7 +1099,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[KEY_FRAME] + qindex, 2); } else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) && - !(cpi->use_svc && oxcf->end_usage == USAGE_STREAM_FROM_SERVER)) { + !(cpi->use_svc && oxcf->rc_mode == RC_MODE_CBR)) { rc->last_q[2] = qindex; rc->avg_frame_qindex[2] = ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[2] + qindex, 2); @@ -1247,7 +1247,7 @@ static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { int min_frame_target = MAX(rc->avg_frame_bandwidth >> 4, FRAME_OVERHEAD_BITS); int target = rc->avg_frame_bandwidth; if (svc->number_temporal_layers > 1 && - oxcf->end_usage == USAGE_STREAM_FROM_SERVER) { + oxcf->rc_mode == RC_MODE_CBR) { // Note that for layers, avg_frame_bandwidth is the cumulative // per-frame-bandwidth. For the target size of this frame, use the // layer average frame size (i.e., non-cumulative per-frame-bw). @@ -1280,7 +1280,7 @@ static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { int kf_boost = 32; double framerate = oxcf->framerate; if (svc->number_temporal_layers > 1 && - oxcf->end_usage == USAGE_STREAM_FROM_SERVER) { + oxcf->rc_mode == RC_MODE_CBR) { // Use the layer framerate for temporal layers CBR mode. const LAYER_CONTEXT *lc = &svc->layer_context[svc->temporal_layer_id]; framerate = lc->framerate; @@ -1305,12 +1305,12 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) { cpi->key_frame_frequency == 0))) { cm->frame_type = KEY_FRAME; rc->source_alt_ref_active = 0; - if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { + if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) { target = calc_iframe_target_size_one_pass_cbr(cpi); } } else { cm->frame_type = INTER_FRAME; - if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { + if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) { target = calc_pframe_target_size_one_pass_cbr(cpi); } } diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index f7f2ec6c8..f309aac96 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -33,8 +33,8 @@ #include "vp9/encoder/vp9_cost.h" #include "vp9/encoder/vp9_encodemb.h" #include "vp9/encoder/vp9_encodemv.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_mcomp.h" -#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" @@ -56,7 +56,7 @@ #define MIN_EARLY_TERM_INDEX 3 typedef struct { - MB_PREDICTION_MODE mode; + PREDICTION_MODE mode; MV_REFERENCE_FRAME ref_frame[2]; } MODE_DEFINITION; @@ -1021,8 +1021,8 @@ static void intra_super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, } -static int conditional_skipintra(MB_PREDICTION_MODE mode, - MB_PREDICTION_MODE best_intra_mode) { +static int conditional_skipintra(PREDICTION_MODE mode, + PREDICTION_MODE best_intra_mode) { if (mode == D117_PRED && best_intra_mode != V_PRED && best_intra_mode != D135_PRED) @@ -1043,13 +1043,13 @@ static int conditional_skipintra(MB_PREDICTION_MODE mode, } static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, - MB_PREDICTION_MODE *best_mode, + PREDICTION_MODE *best_mode, const int *bmode_costs, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int *bestrate, int *bestratey, int64_t *bestdistortion, BLOCK_SIZE bsize, int64_t rd_thresh) { - MB_PREDICTION_MODE mode; + PREDICTION_MODE mode; MACROBLOCKD *const xd = &x->e_mbd; int64_t best_rd = rd_thresh; @@ -1195,13 +1195,13 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP *cpi, MACROBLOCK *mb, // Pick modes for each sub-block (of size 4x4, 4x8, or 8x4) in an 8x8 block. for (idy = 0; idy < 2; idy += num_4x4_blocks_high) { for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) { - MB_PREDICTION_MODE best_mode = DC_PRED; + PREDICTION_MODE best_mode = DC_PRED; int r = INT_MAX, ry = INT_MAX; int64_t d = INT64_MAX, this_rd = INT64_MAX; i = idy * 2 + idx; if (cpi->common.frame_type == KEY_FRAME) { - const MB_PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, i); - const MB_PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, i); + const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, i); + const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, i); bmode_costs = mb->y_mode_costs[A][L]; } @@ -1242,8 +1242,8 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int64_t tx_cache[TX_MODES], int64_t best_rd) { - MB_PREDICTION_MODE mode; - MB_PREDICTION_MODE mode_selected = DC_PRED; + PREDICTION_MODE mode; + PREDICTION_MODE mode_selected = DC_PRED; MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *const mic = xd->mi[0]; int this_rate, this_rate_tokenonly, s; @@ -1266,8 +1266,8 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, continue; if (cpi->common.frame_type == KEY_FRAME) { - const MB_PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); - const MB_PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); + const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); + const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); bmode_costs = x->y_mode_costs[A][L]; } @@ -1361,8 +1361,8 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x, int64_t *distortion, int *skippable, BLOCK_SIZE bsize, TX_SIZE max_tx_size) { MACROBLOCKD *xd = &x->e_mbd; - MB_PREDICTION_MODE mode; - MB_PREDICTION_MODE mode_selected = DC_PRED; + PREDICTION_MODE mode; + PREDICTION_MODE mode_selected = DC_PRED; int64_t best_rd = INT64_MAX, this_rd; int this_rate_tokenonly, this_rate, s; int64_t this_distortion, this_sse; @@ -1434,7 +1434,7 @@ static void choose_intra_uv_mode(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, BLOCK_SIZE bsize, TX_SIZE max_tx_size, int *rate_uv, int *rate_uv_tokenonly, int64_t *dist_uv, int *skip_uv, - MB_PREDICTION_MODE *mode_uv) { + PREDICTION_MODE *mode_uv) { MACROBLOCK *const x = &cpi->mb; // Use an estimated rd for uv_intra based on DC_PRED if the @@ -1452,7 +1452,7 @@ static void choose_intra_uv_mode(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, *mode_uv = x->e_mbd.mi[0]->mbmi.uv_mode; } -static int cost_mv_ref(const VP9_COMP *cpi, MB_PREDICTION_MODE mode, +static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode, int mode_context) { const MACROBLOCK *const x = &cpi->mb; const int segment_id = x->e_mbd.mi[0]->mbmi.segment_id; @@ -1474,7 +1474,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, int *rate_mv); static int set_and_cost_bmi_mvs(VP9_COMP *cpi, MACROBLOCKD *xd, int i, - MB_PREDICTION_MODE mode, int_mv this_mv[2], + PREDICTION_MODE mode, int_mv this_mv[2], int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES], int_mv seg_mvs[MAX_REF_FRAMES], int_mv *best_ref_mv[2], const int *mvjcost, @@ -1627,7 +1627,7 @@ typedef struct { int64_t d; int64_t sse; int segment_yrate; - MB_PREDICTION_MODE modes[4]; + PREDICTION_MODE modes[4]; SEG_RDSTAT rdstat[4][INTER_MODES]; int mvthresh; } BEST_SEG_INFO; @@ -1725,7 +1725,7 @@ static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x, int mode_idx; int k, br = 0, idx, idy; int64_t bd = 0, block_sse = 0; - MB_PREDICTION_MODE this_mode; + PREDICTION_MODE this_mode; VP9_COMMON *cm = &cpi->common; struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0]; @@ -1769,7 +1769,7 @@ static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x, // loop for 4x4/4x8/8x4 block coding. to be replaced with new rd loop int_mv mode_mv[MB_MODE_COUNT][2]; int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; - MB_PREDICTION_MODE mode_selected = ZEROMV; + PREDICTION_MODE mode_selected = ZEROMV; int64_t best_rd = INT64_MAX; const int i = idy * 2 + idx; int ref; @@ -3132,7 +3132,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const struct segmentation *const seg = &cm->seg; - MB_PREDICTION_MODE this_mode; + PREDICTION_MODE this_mode; MV_REFERENCE_FRAME ref_frame, second_ref_frame; unsigned char segment_id = mbmi->segment_id; int comp_pred, i; @@ -3154,13 +3154,13 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, vp9_prob comp_mode_p; int64_t best_intra_rd = INT64_MAX; int64_t best_inter_rd = INT64_MAX; - MB_PREDICTION_MODE best_intra_mode = DC_PRED; + PREDICTION_MODE best_intra_mode = DC_PRED; MV_REFERENCE_FRAME best_inter_ref_frame = LAST_FRAME; INTERP_FILTER tmp_best_filter = SWITCHABLE; int rate_uv_intra[TX_SIZES], rate_uv_tokenonly[TX_SIZES]; int64_t dist_uv[TX_SIZES]; int skip_uv[TX_SIZES]; - MB_PREDICTION_MODE mode_uv[TX_SIZES]; + PREDICTION_MODE mode_uv[TX_SIZES]; int64_t mode_distortions[MB_MODE_COUNT] = {-1}; int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); const int bws = num_8x8_blocks_wide_lookup[bsize] / 2; @@ -3774,7 +3774,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, int rate_uv_intra, rate_uv_tokenonly; int64_t dist_uv; int skip_uv; - MB_PREDICTION_MODE mode_uv = DC_PRED; + PREDICTION_MODE mode_uv = DC_PRED; int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); int_mv seg_mvs[4][MAX_REF_FRAMES]; b_mode_info best_bmodes[4]; diff --git a/vp9/encoder/vp9_rdopt.h b/vp9/encoder/vp9_rdopt.h index e48566499..cd622d608 100644 --- a/vp9/encoder/vp9_rdopt.h +++ b/vp9/encoder/vp9_rdopt.h @@ -11,7 +11,7 @@ #ifndef VP9_ENCODER_VP9_RDOPT_H_ #define VP9_ENCODER_VP9_RDOPT_H_ -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #ifdef __cplusplus extern "C" { diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c index 9d3e6dc12..7537d1b52 100644 --- a/vp9/encoder/vp9_segmentation.c +++ b/vp9/encoder/vp9_segmentation.c @@ -29,18 +29,6 @@ void vp9_disable_segmentation(struct segmentation *seg) { seg->enabled = 0; } -void vp9_set_segmentation_map(VP9_COMP *cpi, unsigned char *segmentation_map) { - struct segmentation *const seg = &cpi->common.seg; - - // Copy in the new segmentation map - vpx_memcpy(cpi->segmentation_map, segmentation_map, - (cpi->common.mi_rows * cpi->common.mi_cols)); - - // Signal that the map should be updated. - seg->update_map = 1; - seg->update_data = 1; -} - void vp9_set_segment_data(struct segmentation *seg, signed char *feature_data, unsigned char abs_delta) { diff --git a/vp9/encoder/vp9_segmentation.h b/vp9/encoder/vp9_segmentation.h index 66c51a21b..50dd562c8 100644 --- a/vp9/encoder/vp9_segmentation.h +++ b/vp9/encoder/vp9_segmentation.h @@ -13,7 +13,7 @@ #define VP9_ENCODER_VP9_SEGMENTATION_H_ #include "vp9/common/vp9_blockd.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #ifdef __cplusplus extern "C" { @@ -28,9 +28,6 @@ void vp9_disable_segfeature(struct segmentation *seg, void vp9_clear_segdata(struct segmentation *seg, int segment_id, SEG_LVL_FEATURES feature_id); -// Valid values for a segment are 0 to 3 -// Segmentation map is arrange as [Rows][Columns] -void vp9_set_segmentation_map(VP9_COMP *cpi, unsigned char *segmentation_map); // The values given for each segment can be either deltas (from the default // value chosen for the frame) or absolute values. diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 86ab7dcad..f0ee7c721 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -10,7 +10,7 @@ #include <limits.h> -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_speed_features.h" enum { @@ -80,9 +80,6 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, } if (speed >= 2) { - sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD - : USE_LARGESTALL; - if (MIN(cm->width, cm->height) >= 720) sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; @@ -104,6 +101,8 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, } if (speed >= 3) { + sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD + : USE_LARGESTALL; if (MIN(cm->width, cm->height) >= 720) sf->disable_split_mask = DISABLE_ALL_SPLIT; else diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c index e408200b4..f59670d06 100644 --- a/vp9/encoder/vp9_svc_layercontext.c +++ b/vp9/encoder/vp9_svc_layercontext.c @@ -10,7 +10,7 @@ #include <math.h> -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_svc_layercontext.h" void vp9_init_layer_context(VP9_COMP *const cpi) { diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index a5694161c..ca9339155 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -19,7 +19,7 @@ #include "vp9/encoder/vp9_extend.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_mcomp.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_segmentation.h" @@ -345,74 +345,33 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi, void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { VP9_COMMON *const cm = &cpi->common; int frame = 0; - int frames_to_blur_backward = 0; - int frames_to_blur_forward = 0; int frames_to_blur = 0; int start_frame = 0; int strength = cpi->active_arnr_strength; - int blur_type = cpi->oxcf.arnr_type; int max_frames = cpi->active_arnr_frames; - const int num_frames_backward = distance; - const int num_frames_forward = vp9_lookahead_depth(cpi->lookahead) - - (num_frames_backward + 1); + int frames_to_blur_backward = distance; + int frames_to_blur_forward = vp9_lookahead_depth(cpi->lookahead) + - (distance + 1); struct scale_factors sf; - switch (blur_type) { - case 1: - // Backward Blur - frames_to_blur_backward = num_frames_backward; + // Determine which input frames to filter. + if (frames_to_blur_forward > frames_to_blur_backward) + frames_to_blur_forward = frames_to_blur_backward; - if (frames_to_blur_backward >= max_frames) - frames_to_blur_backward = max_frames - 1; + if (frames_to_blur_backward > frames_to_blur_forward) + frames_to_blur_backward = frames_to_blur_forward; - frames_to_blur = frames_to_blur_backward + 1; - break; + // When max_frames is even we have 1 more frame backward than forward + if (frames_to_blur_forward > (max_frames - 1) / 2) + frames_to_blur_forward = (max_frames - 1) / 2; - case 2: - // Forward Blur - frames_to_blur_forward = num_frames_forward; + if (frames_to_blur_backward > (max_frames / 2)) + frames_to_blur_backward = max_frames / 2; - if (frames_to_blur_forward >= max_frames) - frames_to_blur_forward = max_frames - 1; - - frames_to_blur = frames_to_blur_forward + 1; - break; - - case 3: - default: - // Center Blur - frames_to_blur_forward = num_frames_forward; - frames_to_blur_backward = num_frames_backward; - - if (frames_to_blur_forward > frames_to_blur_backward) - frames_to_blur_forward = frames_to_blur_backward; - - if (frames_to_blur_backward > frames_to_blur_forward) - frames_to_blur_backward = frames_to_blur_forward; - - // When max_frames is even we have 1 more frame backward than forward - if (frames_to_blur_forward > (max_frames - 1) / 2) - frames_to_blur_forward = ((max_frames - 1) / 2); - - if (frames_to_blur_backward > (max_frames / 2)) - frames_to_blur_backward = (max_frames / 2); - - frames_to_blur = frames_to_blur_backward + frames_to_blur_forward + 1; - break; - } + frames_to_blur = frames_to_blur_backward + frames_to_blur_forward + 1; start_frame = distance + frames_to_blur_forward; -#ifdef DEBUGFWG - // DEBUG FWG - printf( - "max:%d FBCK:%d FFWD:%d ftb:%d ftbbck:%d ftbfwd:%d sei:%d lasei:%d " - "start:%d", - max_frames, num_frames_backward, num_frames_forward, frames_to_blur, - frames_to_blur_backward, frames_to_blur_forward, cpi->source_encode_index, - cpi->last_alt_ref_sei, start_frame); -#endif - // Setup scaling factors. Scaling on each of the arnr frames is not supported vp9_setup_scale_factors_for_frame(&sf, get_frame_new_buffer(cm)->y_crop_width, @@ -421,7 +380,7 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { // Setup frame pointers, NULL indicates frame not included in filter vp9_zero(cpi->frames); - for (frame = 0; frame < frames_to_blur; frame++) { + for (frame = 0; frame < frames_to_blur; ++frame) { int which_buffer = start_frame - frame; struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead, which_buffer); @@ -435,11 +394,11 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { void vp9_configure_arnr_filter(VP9_COMP *cpi, const unsigned int frames_to_arnr, const int group_boost) { + int q; int half_gf_int; int frames_after_arf; - int frames_bwd = cpi->oxcf.arnr_max_frames - 1; - int frames_fwd = cpi->oxcf.arnr_max_frames - 1; - int q; + int frames_bwd; + int frames_fwd = (cpi->oxcf.arnr_max_frames - 1) >> 1; // Define the arnr filter width for this group of frames. We only // filter frames that lie within a distance of half the GF interval @@ -451,47 +410,26 @@ void vp9_configure_arnr_filter(VP9_COMP *cpi, frames_after_arf = vp9_lookahead_depth(cpi->lookahead) - frames_to_arnr - 1; - switch (cpi->oxcf.arnr_type) { - case 1: // Backward filter - frames_fwd = 0; - if (frames_bwd > half_gf_int) - frames_bwd = half_gf_int; - break; - - case 2: // Forward filter - if (frames_fwd > half_gf_int) - frames_fwd = half_gf_int; - if (frames_fwd > frames_after_arf) - frames_fwd = frames_after_arf; - frames_bwd = 0; - break; - - case 3: // Centered filter - default: - frames_fwd >>= 1; - if (frames_fwd > frames_after_arf) - frames_fwd = frames_after_arf; - if (frames_fwd > half_gf_int) - frames_fwd = half_gf_int; - - frames_bwd = frames_fwd; - - // For even length filter there is one more frame backward - // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff. - if (frames_bwd < half_gf_int) - frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1; - break; - } + if (frames_fwd > frames_after_arf) + frames_fwd = frames_after_arf; + if (frames_fwd > half_gf_int) + frames_fwd = half_gf_int; + + frames_bwd = frames_fwd; + + // For even length filter there is one more frame backward + // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff. + if (frames_bwd < half_gf_int) + frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1; cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd; // Adjust the strength based on active max q if (cpi->common.current_video_frame > 1) - q = ((int)vp9_convert_qindex_to_q( - cpi->rc.avg_frame_qindex[INTER_FRAME])); + q = ((int)vp9_convert_qindex_to_q(cpi->rc.avg_frame_qindex[INTER_FRAME])); else - q = ((int)vp9_convert_qindex_to_q( - cpi->rc.avg_frame_qindex[KEY_FRAME])); + q = ((int)vp9_convert_qindex_to_q(cpi->rc.avg_frame_qindex[KEY_FRAME])); + if (q > 16) { cpi->active_arnr_strength = cpi->oxcf.arnr_strength; } else { diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 291ccb37e..8ce98d938 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -20,7 +20,7 @@ #include "vp9/common/vp9_seg_common.h" #include "vp9/encoder/vp9_cost.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_tokenize.h" static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; diff --git a/vp9/encoder/vp9_variance.c b/vp9/encoder/vp9_variance.c index a31a476f3..696faf114 100644 --- a/vp9/encoder/vp9_variance.c +++ b/vp9/encoder/vp9_variance.c @@ -122,46 +122,45 @@ unsigned int vp9_variance64x32_c(const uint8_t *src_ptr, return (var - (((int64_t)avg * avg) >> 11)); } -unsigned int vp9_sub_pixel_variance64x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[65 * 64]; - uint8_t temp2[68 * 64]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 64, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 32, 64, vfilter); - - return vp9_variance64x32(temp2, 64, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[65 * 64]; - uint8_t temp2[68 * 64]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 64 * 64); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 64, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 32, 64, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 64, 32, temp2, 64); - return vp9_variance64x32(temp3, 64, dst_ptr, dst_pixels_per_line, sse); +#define SUBPIX_VAR(W, H) \ +unsigned int vp9_sub_pixel_variance##W##x##H##_c( \ + const uint8_t *src, int src_stride, \ + int xoffset, int yoffset, \ + const uint8_t *dst, int dst_stride, \ + unsigned int *sse) { \ + uint16_t fdata3[(H + 1) * W]; \ + uint8_t temp2[H * W]; \ +\ + var_filter_block2d_bil_first_pass(src, fdata3, src_stride, 1, H + 1, W, \ + BILINEAR_FILTERS_2TAP(xoffset)); \ + var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W, \ + BILINEAR_FILTERS_2TAP(yoffset)); \ +\ + return vp9_variance##W##x##H##_c(temp2, W, dst, dst_stride, sse); \ +} + +#define SUBPIX_AVG_VAR(W, H) \ +unsigned int vp9_sub_pixel_avg_variance##W##x##H##_c( \ + const uint8_t *src, int src_stride, \ + int xoffset, int yoffset, \ + const uint8_t *dst, int dst_stride, \ + unsigned int *sse, \ + const uint8_t *second_pred) { \ + uint16_t fdata3[(H + 1) * W]; \ + uint8_t temp2[H * W]; \ + DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, H * W); \ +\ + var_filter_block2d_bil_first_pass(src, fdata3, src_stride, 1, H + 1, W, \ + BILINEAR_FILTERS_2TAP(xoffset)); \ + var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W, \ + BILINEAR_FILTERS_2TAP(yoffset)); \ +\ + vp9_comp_avg_pred(temp3, second_pred, W, H, temp2, W); \ +\ + return vp9_variance##W##x##H##_c(temp3, W, dst, dst_stride, sse); \ } + unsigned int vp9_variance32x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, @@ -175,46 +174,6 @@ unsigned int vp9_variance32x64_c(const uint8_t *src_ptr, return (var - (((int64_t)avg * avg) >> 11)); } -unsigned int vp9_sub_pixel_variance32x64_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[65 * 64]; - uint8_t temp2[68 * 64]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 65, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 64, 32, vfilter); - - return vp9_variance32x64(temp2, 32, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[65 * 64]; - uint8_t temp2[68 * 64]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 64); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 65, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 64, 32, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 32, 64, temp2, 32); - return vp9_variance32x64(temp3, 32, dst_ptr, dst_pixels_per_line, sse); -} - unsigned int vp9_variance32x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, @@ -228,46 +187,6 @@ unsigned int vp9_variance32x16_c(const uint8_t *src_ptr, return (var - (((int64_t)avg * avg) >> 9)); } -unsigned int vp9_sub_pixel_variance32x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 16, 32, vfilter); - - return vp9_variance32x16(temp2, 32, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 16); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 16, 32, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 32, 16, temp2, 32); - return vp9_variance32x16(temp3, 32, dst_ptr, dst_pixels_per_line, sse); -} - unsigned int vp9_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, @@ -281,46 +200,6 @@ unsigned int vp9_variance16x32_c(const uint8_t *src_ptr, return (var - (((int64_t)avg * avg) >> 9)); } -unsigned int vp9_sub_pixel_variance16x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 32, 16, vfilter); - - return vp9_variance16x32(temp2, 16, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 32); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 32, 16, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 16, 32, temp2, 16); - return vp9_variance16x32(temp3, 16, dst_ptr, dst_pixels_per_line, sse); -} - unsigned int vp9_variance64x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, @@ -503,207 +382,44 @@ unsigned int vp9_mse8x8_c(const uint8_t *src_ptr, return var; } +SUBPIX_VAR(4, 4) +SUBPIX_AVG_VAR(4, 4) -unsigned int vp9_sub_pixel_variance4x4_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint8_t temp2[20 * 16]; - uint16_t fdata3[5 * 4]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 5, 4, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 4, 4, vfilter); - - return vp9_variance4x4(temp2, 4, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 4 * 4); - uint16_t fdata3[5 * 4]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 5, 4, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 4, 4, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 4, 4, temp2, 4); - return vp9_variance4x4(temp3, 4, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance8x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[9 * 8]; - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 8, 8, vfilter); - return vp9_variance8x8(temp2, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[9 * 8]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 8); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 8, 8, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 8, 8, temp2, 8); - - return vp9_variance8x8(temp3, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance16x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[17 * 16]; - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 16, 16, vfilter); - - return vp9_variance16x16(temp2, 16, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[17 * 16]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 16); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 16, 16, vfilter); - - vp9_comp_avg_pred(temp3, second_pred, 16, 16, temp2, 16); - return vp9_variance16x16(temp3, 16, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance64x64_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[65 * 64]; // Temp data buffer used in filtering - uint8_t temp2[68 * 64]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 65, 64, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 64, 64, vfilter); - - return vp9_variance64x64(temp2, 64, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[65 * 64]; - uint8_t temp2[68 * 64]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 64 * 64); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 65, 64, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 64, 64, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 64, 64, temp2, 64); - return vp9_variance64x64(temp3, 64, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance32x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 32, 32, vfilter); - - return vp9_variance32x32(temp2, 32, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[33 * 32]; - uint8_t temp2[36 * 32]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 32); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 33, 32, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 32, 32, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 32, 32, temp2, 32); - return vp9_variance32x32(temp3, 32, dst_ptr, dst_pixels_per_line, sse); -} +SUBPIX_VAR(4, 8) +SUBPIX_AVG_VAR(4, 8) + +SUBPIX_VAR(8, 4) +SUBPIX_AVG_VAR(8, 4) + +SUBPIX_VAR(8, 8) +SUBPIX_AVG_VAR(8, 8) + +SUBPIX_VAR(8, 16) +SUBPIX_AVG_VAR(8, 16) + +SUBPIX_VAR(16, 8) +SUBPIX_AVG_VAR(16, 8) + +SUBPIX_VAR(16, 16) +SUBPIX_AVG_VAR(16, 16) + +SUBPIX_VAR(16, 32) +SUBPIX_AVG_VAR(16, 32) + +SUBPIX_VAR(32, 16) +SUBPIX_AVG_VAR(32, 16) + +SUBPIX_VAR(32, 32) +SUBPIX_AVG_VAR(32, 32) + +SUBPIX_VAR(32, 64) +SUBPIX_AVG_VAR(32, 64) + +SUBPIX_VAR(64, 32) +SUBPIX_AVG_VAR(64, 32) + +SUBPIX_VAR(64, 64) +SUBPIX_AVG_VAR(64, 64) unsigned int vp9_variance_halfpixvar16x16_h_c(const uint8_t *src_ptr, int source_stride, @@ -825,169 +541,6 @@ unsigned int vp9_sub_pixel_mse64x64_c(const uint8_t *src_ptr, return *sse; } -unsigned int vp9_sub_pixel_variance16x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[16 * 9]; - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 8, 16, vfilter); - - return vp9_variance16x8(temp2, 16, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[16 * 9]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 8); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 16, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 8, 16, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 16, 8, temp2, 16); - return vp9_variance16x8(temp3, 16, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance8x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[9 * 16]; // Temp data buffer used in filtering - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 16, 8, vfilter); - - return vp9_variance8x16(temp2, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[9 * 16]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 16); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 17, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 16, 8, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 8, 16, temp2, 8); - return vp9_variance8x16(temp3, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance8x4_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[8 * 5]; - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 5, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 4, 8, vfilter); - - return vp9_variance8x4(temp2, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[8 * 5]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 4); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 5, 8, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 4, 8, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 8, 4, temp2, 8); - return vp9_variance8x4(temp3, 8, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_variance4x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse) { - uint16_t fdata3[5 * 8]; - // FIXME(jingning,rbultje): this temp2 buffer probably doesn't need to be - // of this big? same issue appears in all other block size settings. - uint8_t temp2[20 * 16]; - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 4, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter); - - return vp9_variance4x8(temp2, 4, dst_ptr, dst_pixels_per_line, sse); -} - -unsigned int vp9_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr, - int src_pixels_per_line, - int xoffset, - int yoffset, - const uint8_t *dst_ptr, - int dst_pixels_per_line, - unsigned int *sse, - const uint8_t *second_pred) { - uint16_t fdata3[5 * 8]; - uint8_t temp2[20 * 16]; - DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 4 * 8); - const int16_t *const hfilter = BILINEAR_FILTERS_2TAP(xoffset); - const int16_t *const vfilter = BILINEAR_FILTERS_2TAP(yoffset); - - var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, - 1, 9, 4, hfilter); - var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter); - vp9_comp_avg_pred(temp3, second_pred, 4, 8, temp2, 4); - return vp9_variance4x8(temp3, 4, dst_ptr, dst_pixels_per_line, sse); -} - - void vp9_comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride) { int i, j; diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 0328788f5..1d82b1955 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -14,7 +14,7 @@ #include "vpx/vpx_codec.h" #include "vpx/internal/vpx_codec_internal.h" #include "./vpx_version.h" -#include "vp9/encoder/vp9_onyx_int.h" +#include "vp9/encoder/vp9_encoder.h" #include "vpx/vp8cx.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/vp9_iface_common.h" @@ -30,7 +30,6 @@ struct vp9_extracfg { unsigned int tile_rows; unsigned int arnr_max_frames; unsigned int arnr_strength; - unsigned int arnr_type; vp8e_tuning tuning; unsigned int cq_level; // constrained quality level unsigned int rc_max_intra_bitrate_pct; @@ -60,7 +59,6 @@ static const struct extraconfig_map extracfg_map[] = { 0, // tile_rows 7, // arnr_max_frames 5, // arnr_strength - 3, // arnr_type VP8_TUNE_PSNR, // tuning 10, // cq_level 0, // rc_max_intra_bitrate_pct @@ -203,7 +201,6 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK_HI(extra_cfg, sharpness, 7); RANGE_CHECK(extra_cfg, arnr_max_frames, 0, 15); RANGE_CHECK_HI(extra_cfg, arnr_strength, 6); - RANGE_CHECK(extra_cfg, arnr_type, 1, 3); RANGE_CHECK(extra_cfg, cq_level, 0, 63); // TODO(yaowu): remove this when ssim tuning is implemented for vp9 @@ -318,13 +315,13 @@ static vpx_codec_err_t set_encoder_config( oxcf->lag_in_frames = cfg->g_pass == VPX_RC_FIRST_PASS ? 0 : cfg->g_lag_in_frames; - oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK; + oxcf->rc_mode = RC_MODE_VBR; if (cfg->rc_end_usage == VPX_CQ) - oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; + oxcf->rc_mode = RC_MODE_CONSTRAINED_QUALITY; else if (cfg->rc_end_usage == VPX_Q) - oxcf->end_usage = USAGE_CONSTANT_QUALITY; + oxcf->rc_mode = RC_MODE_CONSTANT_QUALITY; else if (cfg->rc_end_usage == VPX_CBR) - oxcf->end_usage = USAGE_STREAM_FROM_SERVER; + oxcf->rc_mode = RC_MODE_CBR; oxcf->target_bandwidth = cfg->rc_target_bitrate; oxcf->rc_max_intra_bitrate_pct = extra_cfg->rc_max_intra_bitrate_pct; @@ -367,7 +364,6 @@ static vpx_codec_err_t set_encoder_config( oxcf->arnr_max_frames = extra_cfg->arnr_max_frames; oxcf->arnr_strength = extra_cfg->arnr_strength; - oxcf->arnr_type = extra_cfg->arnr_type; oxcf->tuning = extra_cfg->tuning; @@ -498,7 +494,6 @@ static vpx_codec_err_t ctrl_set_param(vpx_codec_alg_priv_t *ctx, int ctrl_id, MAP(VP9E_SET_TILE_ROWS, extra_cfg.tile_rows); MAP(VP8E_SET_ARNR_MAXFRAMES, extra_cfg.arnr_max_frames); MAP(VP8E_SET_ARNR_STRENGTH, extra_cfg.arnr_strength); - MAP(VP8E_SET_ARNR_TYPE, extra_cfg.arnr_type); MAP(VP8E_SET_TUNING, extra_cfg.tuning); MAP(VP8E_SET_CQ_LEVEL, extra_cfg.cq_level); MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, extra_cfg.rc_max_intra_bitrate_pct); @@ -623,7 +618,8 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, } } - +// Turn on to test if supplemental superframe data breaks decoding +// #define TEST_SUPPLEMENTAL_SUPERFRAME_DATA static int write_superframe_index(vpx_codec_alg_priv_t *ctx) { uint8_t marker = 0xc0; unsigned int mask; @@ -649,6 +645,20 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) { if (ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz) { uint8_t *x = ctx->pending_cx_data + ctx->pending_cx_data_sz; int i, j; +#ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA + uint8_t marker_test = 0xc0; + int mag_test = 2; // 1 - 4 + int frames_test = 4; // 1 - 8 + int index_sz_test = 2 + mag_test * frames_test; + marker_test |= frames_test - 1; + marker_test |= (mag_test - 1) << 3; + *x++ = marker_test; + for (i = 0; i < mag_test * frames_test; ++i) + *x++ = 0; // fill up with arbitrary data + *x++ = marker_test; + ctx->pending_cx_data_sz += index_sz_test; + printf("Added supplemental superframe data\n"); +#endif *x++ = marker; for (i = 0; i < ctx->pending_frame_count; i++) { @@ -661,6 +671,9 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) { } *x++ = marker; ctx->pending_cx_data_sz += index_sz; +#ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA + index_sz += index_sz_test; +#endif } return index_sz; } @@ -1094,7 +1107,6 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { {VP9E_SET_TILE_ROWS, ctrl_set_param}, {VP8E_SET_ARNR_MAXFRAMES, ctrl_set_param}, {VP8E_SET_ARNR_STRENGTH, ctrl_set_param}, - {VP8E_SET_ARNR_TYPE, ctrl_set_param}, {VP8E_SET_TUNING, ctrl_set_param}, {VP8E_SET_CQ_LEVEL, ctrl_set_param}, {VP8E_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_param}, diff --git a/vp9/vp9cx.mk b/vp9/vp9cx.mk index 75b0e9e58..c444fe424 100644 --- a/vp9/vp9cx.mk +++ b/vp9/vp9cx.mk @@ -42,7 +42,7 @@ VP9_CX_SRCS-yes += encoder/vp9_firstpass.h VP9_CX_SRCS-yes += encoder/vp9_lookahead.c VP9_CX_SRCS-yes += encoder/vp9_lookahead.h VP9_CX_SRCS-yes += encoder/vp9_mcomp.h -VP9_CX_SRCS-yes += encoder/vp9_onyx_int.h +VP9_CX_SRCS-yes += encoder/vp9_encoder.h VP9_CX_SRCS-yes += encoder/vp9_quantize.h VP9_CX_SRCS-yes += encoder/vp9_ratectrl.h VP9_CX_SRCS-yes += encoder/vp9_rdopt.h @@ -52,7 +52,7 @@ VP9_CX_SRCS-yes += encoder/vp9_tokenize.h VP9_CX_SRCS-yes += encoder/vp9_treewriter.h VP9_CX_SRCS-yes += encoder/vp9_variance.h VP9_CX_SRCS-yes += encoder/vp9_mcomp.c -VP9_CX_SRCS-yes += encoder/vp9_onyx_if.c +VP9_CX_SRCS-yes += encoder/vp9_encoder.c VP9_CX_SRCS-yes += encoder/vp9_picklpf.c VP9_CX_SRCS-yes += encoder/vp9_picklpf.h VP9_CX_SRCS-yes += encoder/vp9_quantize.c @@ -363,7 +363,7 @@ static const arg_def_t frame_periodic_boost = ARG_DEF( static const arg_def_t *vp9_args[] = { &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, - &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, + &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &tune_ssim, &cq_level, &max_intra_rate_pct, &lossless, &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, NULL @@ -372,7 +372,7 @@ static const int vp9_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, - VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, + VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, VP9E_SET_FRAME_PERIODIC_BOOST, |