diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index d30860f5c7a0bfc16686725c6a18b237d07dd84d..f031c18d910d81b5350ba81cd4076c60c7999ad3 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -2268,8 +2268,15 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rate, &dummy_dist, 1, cpi->pc_root); } else { + GF_GROUP * gf_grp = &cpi->twopass.gf_group; + int last_was_mid_sequence_overlay = 0; + if ((cpi->pass == 2) && (gf_grp->index)) { + if (gf_grp->update_type[gf_grp->index - 1] == OVERLAY_UPDATE) + last_was_mid_sequence_overlay = 1; + } if ((cm->current_video_frame % sf->last_partitioning_redo_frequency) == 0 + || last_was_mid_sequence_overlay || cm->prev_mi == 0 || cm->show_frame == 0 || cm->frame_type == KEY_FRAME diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index abb15e90a78c10b400abd793c025b6ac2eadff35..67980bba5167ee9c867a9c23b32dde20c10ade18 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -2462,10 +2462,9 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, cm->show_frame = 1; cm->intra_only = 0; - // Check to see if the frame to be encoded is an overlay - // for a previous arf frame and if so configure it as such. - if (cpi->pass == 0) - is_src_altref(cpi); + // Check to see if the frame to be encoded is an overlay for a previous + // arf frame and if so configure it as such. + is_src_altref(cpi); } } diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 4ff109a0a98669455d776794740e41cd6ad862ce..b304095e949b40a8923fbedf705dfdb33e534ddc 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1340,7 +1340,7 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, twopass->gf_group.rf_level[frame_index] = GF_ARF_STD; twopass->gf_group.bit_allocation[frame_index] = gf_arf_bits; twopass->gf_group.arf_src_offset[frame_index] = - rc->baseline_gf_interval - 1; + (unsigned char)(rc->baseline_gf_interval - 1); twopass->gf_group.arf_update_idx[frame_index] = 2; twopass->gf_group.arf_ref_idx[frame_index] = 2; ++frame_index; @@ -1350,7 +1350,7 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, twopass->gf_group.update_type[frame_index] = ARF_UPDATE; twopass->gf_group.rf_level[frame_index] = GF_ARF_LOW; twopass->gf_group.arf_src_offset[frame_index] = - ((rc->baseline_gf_interval - 1) >> 1); + (unsigned char)((rc->baseline_gf_interval >> 1) - 1); twopass->gf_group.arf_update_idx[frame_index] = 3; twopass->gf_group.arf_ref_idx[frame_index] = 2; ++frame_index; @@ -1385,6 +1385,9 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, twopass->gf_group.arf_update_idx[frame_index] = 2; twopass->gf_group.arf_ref_idx[frame_index] = 2; } + } else { + twopass->gf_group.arf_update_idx[frame_index] = 2; + twopass->gf_group.arf_ref_idx[frame_index] = 2; } target_frame_size = clamp(target_frame_size, 0, @@ -1402,6 +1405,16 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, twopass->gf_group.bit_allocation[middle_frame_idx] + mid_boost_bits; twopass->gf_group.update_type[middle_frame_idx] = OVERLAY_UPDATE; twopass->gf_group.bit_allocation[middle_frame_idx] = 0; + + // Configure the overlay frame at the end of the sequence that will also + // be the start frame of the next group. The reason for doing this here + // is that on entry to vp9_get_compressed_data() for the overlay + // frame, but before the call to vp9_rc_get_second_pass_params() the + // data will otherwise be undefined. + twopass->gf_group.update_type[frame_index] = OVERLAY_UPDATE; + twopass->gf_group.rf_level[frame_index] = INTER_NORMAL; + twopass->gf_group.arf_update_idx[frame_index] = 2; + twopass->gf_group.arf_ref_idx[frame_index] = 2; } } diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index d54ed0874f068fda01e70bcc815d305dd3a486f3..9c3fb5ea052bc9dd4fdccbe25228a141d3d97886 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -84,16 +84,17 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, if (speed >= 2) { if (MIN(cm->width, cm->height) >= 720) { - sf->lf_motion_threshold = LOW_MOITION_THRESHOLD; + sf->lf_motion_threshold = LOW_MOTION_THRESHOLD; sf->last_partitioning_redo_frequency = 3; sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; } else { sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY; sf->last_partitioning_redo_frequency = 2; - sf->lf_motion_threshold = NO_MOITION_THRESHOLD; + sf->lf_motion_threshold = NO_MOTION_THRESHOLD; } - sf->adaptive_pred_interp_filter = 2; + + sf->adaptive_pred_interp_filter = 0; sf->reference_masking = 1; sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER | @@ -114,7 +115,7 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, else sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT; - sf->lf_motion_threshold = LOW_MOITION_THRESHOLD; + sf->lf_motion_threshold = LOW_MOTION_THRESHOLD; sf->last_partitioning_redo_frequency = 3; sf->recode_loop = ALLOW_RECODE_KFMAXBW; sf->adaptive_rd_thresh = 3; @@ -198,7 +199,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf, sf->comp_inter_joint_search_thresh = BLOCK_SIZES; sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION; - sf->lf_motion_threshold = LOW_MOITION_THRESHOLD; + sf->lf_motion_threshold = LOW_MOTION_THRESHOLD; sf->adjust_partitioning_from_last_frame = 1; sf->last_partitioning_redo_frequency = 3; sf->use_lp32x32fdct = 1; diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index c796421dbe08510050521120b00c6ac473438cb4..f5d0b85e22d8ed08ce8de215ab46feff7e5341b0 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -44,8 +44,8 @@ typedef enum { } SUBPEL_SEARCH_METHODS; typedef enum { - NO_MOITION_THRESHOLD = 0, - LOW_MOITION_THRESHOLD = 7 + NO_MOTION_THRESHOLD = 0, + LOW_MOTION_THRESHOLD = 7 } MOTION_THRESHOLD; typedef enum {