Merge changes from topic 'rm-loopfilter-count-param' * changes: lpf_8_test: remove unneeded function wrapper remove loopfilter 'count' param TODOs split vpx_highbd_lpf_horizontal_16 in two split vpx_lpf_horizontal_16 in two vpx_highbd_lpf_horizontal_4: remove unused count param vpx_highbd_lpf_horizontal_8: remove unused count param vpx_highbd_lpf_vertical_4: remove unused count param vpx_highbd_lpf_vertical_8: remove unused count param vpx_lpf_horizontal_4: remove unused count param vpx_lpf_horizontal_8: remove unused count param vpx_lpf_vertical_4: remove unused count param vpx_lpf_vertical_8: remove unused count param lpf_8_test: add missing dspr2 tests lpf_8_test: add missing vpx_lpf_horizontal_4 tests lpf_8_test: add missing vpx_lpf_vertical_4 tests lpf_8_test: simplify function wrapper generation
diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c index d3a4dc1..ea62ce9 100644 --- a/vp10/encoder/encoder.c +++ b/vp10/encoder/encoder.c
@@ -3808,21 +3808,15 @@ int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time) { - VP10_COMMON *volatile const cm = &cpi->common; + VP10_COMMON *const cm = &cpi->common; struct vpx_usec_timer timer; - volatile int res = 0; + int res = 0; const int subsampling_x = sd->subsampling_x; const int subsampling_y = sd->subsampling_y; #if CONFIG_VP9_HIGHBITDEPTH const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0; #endif - if (setjmp(cm->error.jmp)) { - cm->error.setjmp = 0; - return -1; - } - cm->error.setjmp = 1; - #if CONFIG_VP9_HIGHBITDEPTH check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y); #else @@ -3856,7 +3850,6 @@ res = -1; } - cm->error.setjmp = 0; return res; }
diff --git a/vp10/vp10_cx_iface.c b/vp10/vp10_cx_iface.c index 63d3adc..ea99d42 100644 --- a/vp10/vp10_cx_iface.c +++ b/vp10/vp10_cx_iface.c
@@ -14,6 +14,7 @@ #include "./vpx_config.h" #include "vpx/vpx_encoder.h" #include "vpx_ports/vpx_once.h" +#include "vpx_ports/system_state.h" #include "vpx/internal/vpx_codec_internal.h" #include "./vpx_version.h" #include "vp10/encoder/encoder.h" @@ -885,18 +886,21 @@ const vpx_image_t *img, vpx_codec_pts_t pts, unsigned long duration, - vpx_enc_frame_flags_t flags, + vpx_enc_frame_flags_t enc_flags, unsigned long deadline) { - vpx_codec_err_t res = VPX_CODEC_OK; + volatile vpx_codec_err_t res = VPX_CODEC_OK; + volatile vpx_enc_frame_flags_t flags = enc_flags; VP10_COMP *const cpi = ctx->cpi; const vpx_rational_t *const timebase = &ctx->cfg.g_timebase; size_t data_sz; + if (cpi == NULL) return VPX_CODEC_INVALID_PARAM; + if (img != NULL) { res = validate_img(ctx, img); // TODO(jzern) the checks related to cpi's validity should be treated as a // failure condition, encoder setup is done fully in init() currently. - if (res == VPX_CODEC_OK && cpi != NULL) { + if (res == VPX_CODEC_OK) { // There's no codec control for multiple alt-refs so check the encoder // instance for its status to determine the compressed data size. data_sz = ctx->cfg.g_w * ctx->cfg.g_h * get_image_bps(img) / 8 * @@ -924,6 +928,14 @@ return VPX_CODEC_INVALID_PARAM; } + if (setjmp(cpi->common.error.jmp)) { + cpi->common.error.setjmp = 0; + res = update_error_state(ctx, &cpi->common.error); + vpx_clear_system_state(); + return res; + } + cpi->common.error.setjmp = 1; + vp10_apply_encoding_flags(cpi, flags); // Handle fixed keyframe intervals @@ -935,8 +947,7 @@ } } - // Initialize the encoder instance on the first frame. - if (res == VPX_CODEC_OK && cpi != NULL) { + if (res == VPX_CODEC_OK) { unsigned int lib_flags = 0; YV12_BUFFER_CONFIG sd; int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts); @@ -975,7 +986,8 @@ * the buffer size anyway. */ if (cx_data_sz < ctx->cx_data_sz / 2) { - ctx->base.err_detail = "Compressed data buffer too small"; + vpx_internal_error(&cpi->common.error, VPX_CODEC_ERROR, + "Compressed data buffer too small"); return VPX_CODEC_ERROR; } } @@ -1064,6 +1076,7 @@ } } + cpi->common.error.setjmp = 0; return res; }
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index fc02209..7b490af 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c
@@ -728,10 +728,8 @@ }; static void extend_to_full_distribution(vpx_prob *probs, vpx_prob p) { - // TODO(aconverse): model[PIVOT_NODE] should never be zero. - // https://code.google.com/p/webm/issues/detail?id=1089 - memcpy(probs, vp9_pareto8_full[p == 0 ? 254 : p - 1], - MODEL_NODES * sizeof(vpx_prob)); + assert(p != 0); + memcpy(probs, vp9_pareto8_full[p - 1], MODEL_NODES * sizeof(vpx_prob)); } void vp9_model_to_full_probs(const vpx_prob *model, vpx_prob *full) {
diff --git a/vp9/encoder/vp9_cost.c b/vp9/encoder/vp9_cost.c index c85f763..5d14742 100644 --- a/vp9/encoder/vp9_cost.c +++ b/vp9/encoder/vp9_cost.c
@@ -12,9 +12,8 @@ #include "vp9/encoder/vp9_cost.h" /* round(-log2(i/256.) * (1 << VP9_PROB_COST_SHIFT)) - Begins and ends with a bogus entry to satisfy use of prob=0 in the firstpass. - https://code.google.com/p/webm/issues/detail?id=1089 */ -const uint16_t vp9_prob_cost[257] = { + Begins with a bogus entry for simpler addressing. */ +const uint16_t vp9_prob_cost[256] = { 4096, 4096, 3584, 3284, 3072, 2907, 2772, 2659, 2560, 2473, 2395, 2325, 2260, 2201, 2147, 2096, 2048, 2003, 1961, 1921, 1883, 1847, 1813, 1780, 1748, 1718, 1689, 1661, 1635, 1609, 1584, 1559, 1536, 1513, 1491, 1470, @@ -36,13 +35,14 @@ 125, 122, 119, 115, 112, 109, 105, 102, 99, 95, 92, 89, 86, 82, 79, 76, 73, 70, 66, 63, 60, 57, 54, 51, 48, 45, 42, 38, 35, 32, 29, 26, 23, 20, 18, 15, - 12, 9, 6, 3, 3}; + 12, 9, 6, 3}; static void cost(int *costs, vpx_tree tree, const vpx_prob *probs, int i, int c) { const vpx_prob prob = probs[i / 2]; int b; + assert(prob != 0); for (b = 0; b <= 1; ++b) { const int cc = c + vp9_cost_bit(prob, b); const vpx_tree_index ii = tree[i + b];
diff --git a/vp9/encoder/vp9_cost.h b/vp9/encoder/vp9_cost.h index 9831013..0c70b78 100644 --- a/vp9/encoder/vp9_cost.h +++ b/vp9/encoder/vp9_cost.h
@@ -18,7 +18,7 @@ extern "C" { #endif -extern const uint16_t vp9_prob_cost[257]; +extern const uint16_t vp9_prob_cost[256]; // The factor to scale from cost in bits to cost in vp9_prob_cost units. #define VP9_PROB_COST_SHIFT 9
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 0f4f93d..7cf5c97 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c
@@ -4157,21 +4157,15 @@ int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time) { - VP9_COMMON *volatile const cm = &cpi->common; + VP9_COMMON *const cm = &cpi->common; struct vpx_usec_timer timer; - volatile int res = 0; + int res = 0; const int subsampling_x = sd->subsampling_x; const int subsampling_y = sd->subsampling_y; #if CONFIG_VP9_HIGHBITDEPTH const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0; #endif - if (setjmp(cm->error.jmp)) { - cm->error.setjmp = 0; - return -1; - } - cm->error.setjmp = 1; - #if CONFIG_VP9_HIGHBITDEPTH check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y); #else @@ -4205,7 +4199,6 @@ res = -1; } - cm->error.setjmp = 0; return res; }
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index fc32d19..fba45ad 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c
@@ -286,29 +286,37 @@ set_block_thresholds(cm, rd); set_partition_probs(cm, xd); - if (!cpi->sf.use_nonrd_pick_mode || cm->frame_type == KEY_FRAME) - fill_token_costs(x->token_costs, cm->fc->coef_probs); + if (cpi->oxcf.pass == 1) { + if (!frame_is_intra_only(cm)) + vp9_build_nmv_cost_table( + x->nmvjointcost, + cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost, + &cm->fc->nmvc, cm->allow_high_precision_mv); + } else { + if (!cpi->sf.use_nonrd_pick_mode || cm->frame_type == KEY_FRAME) + fill_token_costs(x->token_costs, cm->fc->coef_probs); - if (cpi->sf.partition_search_type != VAR_BASED_PARTITION || - cm->frame_type == KEY_FRAME) { - for (i = 0; i < PARTITION_CONTEXTS; ++i) - vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(xd, i), - vp9_partition_tree); - } + if (cpi->sf.partition_search_type != VAR_BASED_PARTITION || + cm->frame_type == KEY_FRAME) { + for (i = 0; i < PARTITION_CONTEXTS; ++i) + vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(xd, i), + vp9_partition_tree); + } - if (!cpi->sf.use_nonrd_pick_mode || (cm->current_video_frame & 0x07) == 1 || - cm->frame_type == KEY_FRAME) { - fill_mode_costs(cpi); + if (!cpi->sf.use_nonrd_pick_mode || (cm->current_video_frame & 0x07) == 1 || + cm->frame_type == KEY_FRAME) { + fill_mode_costs(cpi); - if (!frame_is_intra_only(cm)) { - vp9_build_nmv_cost_table(x->nmvjointcost, - cm->allow_high_precision_mv ? x->nmvcost_hp - : x->nmvcost, - &cm->fc->nmvc, cm->allow_high_precision_mv); + if (!frame_is_intra_only(cm)) { + vp9_build_nmv_cost_table( + x->nmvjointcost, + cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost, + &cm->fc->nmvc, cm->allow_high_precision_mv); - for (i = 0; i < INTER_MODE_CONTEXTS; ++i) - vp9_cost_tokens((int *)cpi->inter_mode_cost[i], - cm->fc->inter_mode_probs[i], vp9_inter_mode_tree); + for (i = 0; i < INTER_MODE_CONTEXTS; ++i) + vp9_cost_tokens((int *)cpi->inter_mode_cost[i], + cm->fc->inter_mode_probs[i], vp9_inter_mode_tree); + } } } }
diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 8a34fd9..f684507 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c
@@ -303,14 +303,26 @@ FLAG_SKIP_INTRA_LOWVAR; sf->adaptive_pred_interp_filter = 2; - // Disable reference masking if using spatial scaling or for dynamic - // resizing (internal or external) since pred_mv_sad will not be set - // (since vp9_mv_pred will not be called). - // TODO(marpan): Fix this condition to allow reference masking for when - // all references have same resolution as source frame. - sf->reference_masking = (cpi->external_resize == 0 && - cpi->oxcf.resize_mode != RESIZE_DYNAMIC && - cpi->svc.number_spatial_layers == 1) ? 1 : 0; + // Reference masking only enabled for 1 spatial layer, and if none of the + // references have been scaled. The latter condition needs to be checked + // for external or internal dynamic resize. + sf->reference_masking = (cpi->svc.number_spatial_layers == 1); + if (sf->reference_masking == 1 && + (cpi->external_resize == 1 || + cpi->oxcf.resize_mode == RESIZE_DYNAMIC)) { + MV_REFERENCE_FRAME ref_frame; + static const int flag_list[4] = + {0, VP9_LAST_FLAG, VP9_GOLD_FLAG, VP9_ALT_FLAG}; + for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { + const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); + if (yv12 != NULL && (cpi->ref_frame_flags & flag_list[ref_frame])) { + const struct scale_factors *const scale_fac = + &cm->frame_refs[ref_frame - 1].sf; + if (vp9_is_scaled(scale_fac)) + sf->reference_masking = 0; + } + } + } sf->disable_filter_search_var_thresh = 50; sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index db7f537..11df1e4 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c
@@ -14,6 +14,7 @@ #include "./vpx_config.h" #include "vpx/vpx_encoder.h" #include "vpx_ports/vpx_once.h" +#include "vpx_ports/system_state.h" #include "vpx/internal/vpx_codec_internal.h" #include "./vpx_version.h" #include "vp9/encoder/vp9_encoder.h" @@ -967,18 +968,19 @@ const vpx_image_t *img, vpx_codec_pts_t pts, unsigned long duration, - vpx_enc_frame_flags_t flags, + vpx_enc_frame_flags_t enc_flags, unsigned long deadline) { - vpx_codec_err_t res = VPX_CODEC_OK; + volatile vpx_codec_err_t res = VPX_CODEC_OK; + volatile vpx_enc_frame_flags_t flags = enc_flags; VP9_COMP *const cpi = ctx->cpi; const vpx_rational_t *const timebase = &ctx->cfg.g_timebase; size_t data_sz; + if (cpi == NULL) return VPX_CODEC_INVALID_PARAM; + if (img != NULL) { res = validate_img(ctx, img); - // TODO(jzern) the checks related to cpi's validity should be treated as a - // failure condition, encoder setup is done fully in init() currently. - if (res == VPX_CODEC_OK && cpi != NULL) { + if (res == VPX_CODEC_OK) { // There's no codec control for multiple alt-refs so check the encoder // instance for its status to determine the compressed data size. data_sz = ctx->cfg.g_w * ctx->cfg.g_h * get_image_bps(img) / 8 * @@ -1006,6 +1008,14 @@ return VPX_CODEC_INVALID_PARAM; } + if (setjmp(cpi->common.error.jmp)) { + cpi->common.error.setjmp = 0; + res = update_error_state(ctx, &cpi->common.error); + vpx_clear_system_state(); + return res; + } + cpi->common.error.setjmp = 1; + vp9_apply_encoding_flags(cpi, flags); // Handle fixed keyframe intervals @@ -1017,8 +1027,7 @@ } } - // Initialize the encoder instance on the first frame. - if (res == VPX_CODEC_OK && cpi != NULL) { + if (res == VPX_CODEC_OK) { unsigned int lib_flags = 0; YV12_BUFFER_CONFIG sd; int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts); @@ -1057,7 +1066,8 @@ * the buffer size anyway. */ if (cx_data_sz < ctx->cx_data_sz / 2) { - ctx->base.err_detail = "Compressed data buffer too small"; + vpx_internal_error(&cpi->common.error, VPX_CODEC_ERROR, + "Compressed data buffer too small"); return VPX_CODEC_ERROR; } } @@ -1175,6 +1185,7 @@ } } + cpi->common.error.setjmp = 0; return res; }