From: Minghai Shang Date: Tue, 20 May 2014 18:00:30 +0000 (-0700) Subject: [spatial svc] Remove some restrictions that are needed to improve the quality X-Git-Tag: v1.4.0~1539 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7af34402687ecfb95e52573ebac2af9e1c7cadc5;p=platform%2Fupstream%2Flibvpx.git [spatial svc] Remove some restrictions that are needed to improve the quality Change-Id: I76a48b03388a8c5cc74b871deb836cd92263b306 --- diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 17428a7..c5562d5 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -46,6 +46,9 @@ #define GF_RMAX 96.0 #define ERR_DIVISOR 150.0 #define MIN_DECAY_FACTOR 0.1 +#define SVC_FACTOR_PT_LOW 0.45 +#define FACTOR_PT_LOW 0.5 +#define FACTOR_PT_HIGH 0.9 #define KF_MB_INTRA_MIN 150 #define GF_MB_INTRA_MIN 100 @@ -938,8 +941,8 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi, for (q = rc->best_quality; q < rc->worst_quality; ++q) { const double factor = calc_correction_factor(err_per_mb, ERR_DIVISOR, - is_svc_upper_layer ? 0.8 : 0.5, - is_svc_upper_layer ? 1.0 : 0.90, q); + is_svc_upper_layer ? SVC_FACTOR_PT_LOW : + FACTOR_PT_LOW, FACTOR_PT_HIGH, q); const int bits_per_mb = vp9_rc_bits_per_mb(INTER_FRAME, q, factor * speed_term); if (bits_per_mb <= target_norm_bits_per_mb) @@ -2189,20 +2192,23 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { // Define next KF group and assign bits to it. this_frame_copy = this_frame; find_next_key_frame(cpi, &this_frame_copy); - // Don't place key frame in any enhancement layers in spatial svc - if (is_spatial_svc) { - lc->is_key_frame = 1; - if (cpi->svc.spatial_layer_id > 0) { - cm->frame_type = INTER_FRAME; - } - } } else { - if (is_spatial_svc) { - lc->is_key_frame = 0; - } cm->frame_type = INTER_FRAME; } + if (is_spatial_svc) { + if (cpi->svc.spatial_layer_id == 0) { + lc->is_key_frame = (cm->frame_type == KEY_FRAME); + } else { + cm->frame_type = INTER_FRAME; + lc->is_key_frame = cpi->svc.layer_context[0].is_key_frame; + + if (lc->is_key_frame) { + cpi->ref_frame_flags &= (~VP9_LAST_FLAG); + } + } + } + // Is this frame a GF / ARF? (Note: a key frame is always also a GF). if (rc->frames_till_gf_update_due == 0) { // Define next gf group and assign bits to it. diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c index b874be7..4009a8a 100644 --- a/vpx/src/svc_encodeframe.c +++ b/vpx/src/svc_encodeframe.c @@ -496,7 +496,6 @@ vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx, vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *enc_cfg) { - int max_intra_size_pct; vpx_codec_err_t res; SvcInternal *const si = get_svc_internal(svc_ctx); if (svc_ctx == NULL || codec_ctx == NULL || iface == NULL || @@ -575,7 +574,6 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, // modify encoder configuration enc_cfg->ss_number_layers = si->layers; enc_cfg->ts_number_layers = 1; // Temporal layers not used in this encoder. - enc_cfg->kf_mode = VPX_KF_DISABLED; // Lag in frames not currently supported enc_cfg->g_lag_in_frames = 0; @@ -605,16 +603,8 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, } vpx_codec_control(codec_ctx, VP9E_SET_SVC, 1); - vpx_codec_control(codec_ctx, VP8E_SET_CPUUSED, 1); - vpx_codec_control(codec_ctx, VP8E_SET_STATIC_THRESHOLD, 1); - vpx_codec_control(codec_ctx, VP8E_SET_NOISE_SENSITIVITY, 1); vpx_codec_control(codec_ctx, VP8E_SET_TOKEN_PARTITIONS, 1); - max_intra_size_pct = - (int)(((double)enc_cfg->rc_buf_optimal_sz * 0.5) * - ((double)enc_cfg->g_timebase.den / enc_cfg->g_timebase.num) / 10.0); - vpx_codec_control(codec_ctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, - max_intra_size_pct); return VPX_CODEC_OK; } @@ -869,8 +859,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, si->rc_stats_buf_used = 0; si->layers = svc_ctx->spatial_layers; - if (si->frame_within_gop >= si->kf_dist || - si->encode_frame_count == 0) { + if (si->encode_frame_count == 0) { si->frame_within_gop = 0; } si->is_keyframe = (si->frame_within_gop == 0);