aboutsummaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r--vp9/encoder/vp9_firstpass.c152
1 files changed, 85 insertions, 67 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index e9250e25c..a9cdf5353 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -152,6 +152,7 @@ static void zero_stats(FIRSTPASS_STATS *section) {
section->pcnt_intra_high = 0.0;
section->inactive_zone_rows = 0.0;
section->inactive_zone_cols = 0.0;
+ section->new_mv_count = 0.0;
section->MVr = 0.0;
section->mvr_abs = 0.0;
section->MVc = 0.0;
@@ -183,6 +184,7 @@ static void accumulate_stats(FIRSTPASS_STATS *section,
section->pcnt_intra_high += frame->pcnt_intra_high;
section->inactive_zone_rows += frame->inactive_zone_rows;
section->inactive_zone_cols += frame->inactive_zone_cols;
+ section->new_mv_count += frame->new_mv_count;
section->MVr += frame->MVr;
section->mvr_abs += frame->mvr_abs;
section->MVc += frame->MVc;
@@ -212,6 +214,7 @@ static void subtract_stats(FIRSTPASS_STATS *section,
section->pcnt_intra_high -= frame->pcnt_intra_high;
section->inactive_zone_rows -= frame->inactive_zone_rows;
section->inactive_zone_cols -= frame->inactive_zone_cols;
+ section->new_mv_count -= frame->new_mv_count;
section->MVr -= frame->MVr;
section->mvr_abs -= frame->mvr_abs;
section->MVc -= frame->MVc;
@@ -361,7 +364,6 @@ static vpx_variance_fn_t highbd_get_block_variance_fn(BLOCK_SIZE bsize,
case BLOCK_8X16: return vpx_highbd_8_mse8x16;
default: return vpx_highbd_8_mse16x16;
}
- break;
case 10:
switch (bsize) {
case BLOCK_8X8: return vpx_highbd_10_mse8x8;
@@ -369,7 +371,6 @@ static vpx_variance_fn_t highbd_get_block_variance_fn(BLOCK_SIZE bsize,
case BLOCK_8X16: return vpx_highbd_10_mse8x16;
default: return vpx_highbd_10_mse16x16;
}
- break;
case 12:
switch (bsize) {
case BLOCK_8X8: return vpx_highbd_12_mse8x8;
@@ -377,7 +378,6 @@ static vpx_variance_fn_t highbd_get_block_variance_fn(BLOCK_SIZE bsize,
case BLOCK_8X16: return vpx_highbd_12_mse8x16;
default: return vpx_highbd_12_mse16x16;
}
- break;
}
}
@@ -435,6 +435,9 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize];
const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY;
+ MV center_mv_full = ref_mv_full;
+ unsigned int start_mv_sad;
+ vp9_sad_fn_ptr_t sad_fn_ptr;
int step_param = 3;
int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
@@ -455,10 +458,18 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
+ // Calculate SAD of the start mv
+ clamp_mv(&ref_mv_full, x->mv_limits.col_min, x->mv_limits.col_max,
+ x->mv_limits.row_min, x->mv_limits.row_max);
+ start_mv_sad = get_start_mv_sad(x, &ref_mv_full, &center_mv_full,
+ cpi->fn_ptr[bsize].sdf, x->sadperbit16);
+ sad_fn_ptr.sdf = cpi->fn_ptr[bsize].sdf;
+ sad_fn_ptr.sdx4df = cpi->fn_ptr[bsize].sdx4df;
+
// Center the initial step/diamond search on best mv.
- tmp_err = cpi->diamond_search_sad(x, &cpi->ss_cfg, &ref_mv_full, &tmp_mv,
- step_param, x->sadperbit16, &num00,
- &v_fn_ptr, ref_mv);
+ tmp_err = cpi->diamond_search_sad(x, &cpi->ss_cfg, &ref_mv_full, start_mv_sad,
+ &tmp_mv, step_param, x->sadperbit16, &num00,
+ &sad_fn_ptr, ref_mv);
if (tmp_err < INT_MAX)
tmp_err = vp9_get_mvpred_var(x, &tmp_mv, ref_mv, &v_fn_ptr, 1);
if (tmp_err < INT_MAX - new_mv_mode_penalty) tmp_err += new_mv_mode_penalty;
@@ -478,9 +489,9 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
if (num00) {
--num00;
} else {
- tmp_err = cpi->diamond_search_sad(x, &cpi->ss_cfg, &ref_mv_full, &tmp_mv,
- step_param + n, x->sadperbit16, &num00,
- &v_fn_ptr, ref_mv);
+ tmp_err = cpi->diamond_search_sad(
+ x, &cpi->ss_cfg, &ref_mv_full, start_mv_sad, &tmp_mv, step_param + n,
+ x->sadperbit16, &num00, &sad_fn_ptr, ref_mv);
if (tmp_err < INT_MAX)
tmp_err = vp9_get_mvpred_var(x, &tmp_mv, ref_mv, &v_fn_ptr, 1);
if (tmp_err < INT_MAX - new_mv_mode_penalty)
@@ -595,11 +606,11 @@ static int get_smooth_intra_threshold(VP9_COMMON *cm) {
#define FP_MAX_DN_THRESH 24
#define KERNEL_SIZE 3
-// Baseline Kernal weights for first pass noise metric
-static uint8_t fp_dn_kernal_3[KERNEL_SIZE * KERNEL_SIZE] = { 1, 2, 1, 2, 4,
+// Baseline Kernel weights for first pass noise metric
+static uint8_t fp_dn_kernel_3[KERNEL_SIZE * KERNEL_SIZE] = { 1, 2, 1, 2, 4,
2, 1, 2, 1 };
-// Estimate noise at a single point based on the impace of a spatial kernal
+// Estimate noise at a single point based on the impact of a spatial kernel
// on the point value
static int fp_estimate_point_noise(uint8_t *src_ptr, const int stride) {
int sum_weight = 0;
@@ -609,23 +620,23 @@ static int fp_estimate_point_noise(uint8_t *src_ptr, const int stride) {
int diff;
int dn_diff;
uint8_t *tmp_ptr;
- uint8_t *kernal_ptr;
+ uint8_t *kernel_ptr;
uint8_t dn_val;
uint8_t centre_val = *src_ptr;
- kernal_ptr = fp_dn_kernal_3;
+ kernel_ptr = fp_dn_kernel_3;
- // Apply the kernal
+ // Apply the kernel
tmp_ptr = src_ptr - stride - 1;
for (i = 0; i < KERNEL_SIZE; ++i) {
for (j = 0; j < KERNEL_SIZE; ++j) {
diff = abs((int)centre_val - (int)tmp_ptr[j]);
max_diff = VPXMAX(max_diff, diff);
if (diff <= FP_DN_THRESH) {
- sum_weight += *kernal_ptr;
- sum_val += (int)tmp_ptr[j] * (int)*kernal_ptr;
+ sum_weight += *kernel_ptr;
+ sum_val += (int)tmp_ptr[j] * (int)*kernel_ptr;
}
- ++kernal_ptr;
+ ++kernel_ptr;
}
tmp_ptr += stride;
}
@@ -651,13 +662,13 @@ static int fp_highbd_estimate_point_noise(uint8_t *src_ptr, const int stride) {
int dn_diff;
uint8_t *tmp_ptr;
uint16_t *tmp_ptr16;
- uint8_t *kernal_ptr;
+ uint8_t *kernel_ptr;
uint16_t dn_val;
uint16_t centre_val = *CONVERT_TO_SHORTPTR(src_ptr);
- kernal_ptr = fp_dn_kernal_3;
+ kernel_ptr = fp_dn_kernel_3;
- // Apply the kernal
+ // Apply the kernel
tmp_ptr = src_ptr - stride - 1;
for (i = 0; i < KERNEL_SIZE; ++i) {
tmp_ptr16 = CONVERT_TO_SHORTPTR(tmp_ptr);
@@ -665,10 +676,10 @@ static int fp_highbd_estimate_point_noise(uint8_t *src_ptr, const int stride) {
diff = abs((int)centre_val - (int)tmp_ptr16[j]);
max_diff = VPXMAX(max_diff, diff);
if (diff <= FP_DN_THRESH) {
- sum_weight += *kernal_ptr;
- sum_val += (int)tmp_ptr16[j] * (int)*kernal_ptr;
+ sum_weight += *kernel_ptr;
+ sum_val += (int)tmp_ptr16[j] * (int)*kernel_ptr;
}
- ++kernal_ptr;
+ ++kernel_ptr;
}
tmp_ptr += stride;
}
@@ -793,6 +804,7 @@ static void first_pass_stat_calc(VP9_COMP *cpi, FIRSTPASS_STATS *fps,
fps->inactive_zone_cols = (double)0;
if (fp_acc_data->mvcount > 0) {
+ fps->new_mv_count = (double)(fp_acc_data->new_mv_count) / num_mbs;
fps->MVr = (double)(fp_acc_data->sum_mvr) / fp_acc_data->mvcount;
fps->mvr_abs = (double)(fp_acc_data->sum_mvr_abs) / fp_acc_data->mvcount;
fps->MVc = (double)(fp_acc_data->sum_mvc) / fp_acc_data->mvcount;
@@ -809,6 +821,7 @@ static void first_pass_stat_calc(VP9_COMP *cpi, FIRSTPASS_STATS *fps,
(double)(fp_acc_data->sum_in_vectors) / (fp_acc_data->mvcount * 2);
fps->pcnt_motion = (double)(fp_acc_data->mvcount) / num_mbs;
} else {
+ fps->new_mv_count = 0.0;
fps->MVr = 0.0;
fps->mvr_abs = 0.0;
fps->MVc = 0.0;
@@ -834,6 +847,7 @@ static void accumulate_fp_mb_row_stat(TileDataEnc *this_tile,
this_tile->fp_data.intra_count_low += fp_acc_data->intra_count_low;
this_tile->fp_data.intra_count_high += fp_acc_data->intra_count_high;
this_tile->fp_data.intra_skip_count += fp_acc_data->intra_skip_count;
+ this_tile->fp_data.new_mv_count += fp_acc_data->new_mv_count;
this_tile->fp_data.mvcount += fp_acc_data->mvcount;
this_tile->fp_data.sum_mvr += fp_acc_data->sum_mvr;
this_tile->fp_data.sum_mvr_abs += fp_acc_data->sum_mvr_abs;
@@ -904,6 +918,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
double mb_neutral_count;
int scaled_low_intra_thresh = scale_sse_threshold(cm, LOW_I_THRESH);
+ MV *first_top_mv = &tile_data->firstpass_top_mv;
+ MV last_nonzero_mv = { 0, 0 };
+
// First pass code requires valid last and new frame buffers.
assert(new_yv12 != NULL);
assert(frame_is_intra_only(cm) || (lst_yv12 != NULL));
@@ -944,6 +961,10 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
(*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, mb_row, c);
+ if (mb_col == mb_col_start) {
+ last_nonzero_mv = *first_top_mv;
+ }
+
// Adjust to the next column of MBs.
x->plane[0].src.buf = cpi->Source->y_buffer +
mb_row * 16 * x->plane[0].src.stride + mb_col * 16;
@@ -1253,7 +1274,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
xd->mi[0]->mv[0].as_mv = mv;
xd->mi[0]->tx_size = TX_4X4;
xd->mi[0]->ref_frame[0] = LAST_FRAME;
- xd->mi[0]->ref_frame[1] = NONE;
+ xd->mi[0]->ref_frame[1] = NO_REF_FRAME;
vp9_build_inter_predictors_sby(xd, mb_row << 1, mb_col << 1, bsize);
vp9_encode_sby_pass1(x, bsize);
fp_acc_data->sum_mvr += mv.row;
@@ -1268,6 +1289,10 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
if (!is_zero_mv(&mv)) {
++(fp_acc_data->mvcount);
+ if (!is_equal_mv(&mv, &last_nonzero_mv)) {
+ ++(fp_acc_data->new_mv_count);
+ }
+ last_nonzero_mv = mv;
// Does the row vector point inwards or outwards?
if (mb_row < cm->mb_rows / 2) {
@@ -1323,6 +1348,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
}
fp_acc_data->coded_error += (int64_t)this_error;
+ if (mb_col == mb_col_start) {
+ *first_top_mv = last_nonzero_mv;
+ }
recon_yoffset += 16;
recon_uvoffset += uv_mb_height;
@@ -1345,7 +1373,7 @@ static void first_pass_encode(VP9_COMP *cpi, FIRSTPASS_DATA *fp_acc_data) {
MV best_ref_mv;
// Tiling is ignored in the first pass.
vp9_tile_init(tile, cm, 0, 0);
-
+ tile_data.firstpass_top_mv = zero_mv;
#if CONFIG_RATE_CTRL
if (cpi->oxcf.use_simple_encode_api) {
fp_motion_vector_info_reset(cpi->frame_info.frame_width,
@@ -1411,7 +1439,7 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
if (cpi->row_mt_bit_exact && cpi->twopass.fp_mb_float_stats == NULL)
CHECK_MEM_ERROR(
- cm, cpi->twopass.fp_mb_float_stats,
+ &cm->error, cpi->twopass.fp_mb_float_stats,
vpx_calloc(cm->MBs * sizeof(*cpi->twopass.fp_mb_float_stats), 1));
{
@@ -1437,7 +1465,7 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
first_pass_stat_calc(cpi, &fps, &(first_tile_col->fp_data));
}
- // Dont allow a value of 0 for duration.
+ // Don't allow a value of 0 for duration.
// (Section duration is also defaulted to minimum of 1.0).
fps.duration = VPXMAX(1.0, (double)(source->ts_end - source->ts_start));
@@ -1447,7 +1475,7 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
accumulate_stats(&twopass->total_stats, &fps);
}
- // Copy the previous Last Frame back into gf and and arf buffers if
+ // Copy the previous Last Frame back into gf and arf buffers if
// the prediction is good enough... but also don't allow it to lag too far.
if ((twopass->sr_update_lag > 3) ||
((cm->current_video_frame > 0) &&
@@ -1476,22 +1504,6 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
cm->ref_frame_map[cpi->lst_fb_idx]);
}
- // Use this to see what the first pass reconstruction looks like.
- if (0) {
- char filename[512];
- FILE *recon_file;
- snprintf(filename, sizeof(filename), "enc%04d.yuv",
- (int)cm->current_video_frame);
-
- if (cm->current_video_frame == 0)
- recon_file = fopen(filename, "wb");
- else
- recon_file = fopen(filename, "ab");
-
- (void)fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1, recon_file);
- fclose(recon_file);
- }
-
// In the first pass, every frame is considered as a show frame.
update_frame_indexes(cm, /*show_frame=*/1);
if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
@@ -1664,7 +1676,7 @@ void vp9_init_second_pass(VP9_COMP *cpi) {
// Scan the first pass file and calculate a modified score for each
// frame that is used to distribute bits. The modified score is assumed
- // to provide a linear basis for bit allocation. I.e a frame A with a score
+ // to provide a linear basis for bit allocation. I.e., a frame A with a score
// that is double that of frame B will be allocated 2x as many bits.
{
double modified_score_total = 0.0;
@@ -1689,8 +1701,8 @@ void vp9_init_second_pass(VP9_COMP *cpi) {
}
// Second scan using clamps based on the previous cycle average.
- // This may modify the total and average somewhat but we dont bother with
- // further itterations.
+ // This may modify the total and average somewhat but we don't bother with
+ // further iterations.
modified_score_total = 0.0;
s = twopass->stats_in;
while (s < twopass->stats_in_end) {
@@ -1847,7 +1859,7 @@ static int detect_flash_from_frame_stats(const FIRSTPASS_STATS *frame_stats) {
// brief break in prediction (such as a flash) but subsequent frames
// are reasonably well predicted by an earlier (pre flash) frame.
// The recovery after a flash is indicated by a high pcnt_second_ref
- // useage or a second ref coded error notabley lower than the last
+ // usage or a second ref coded error notabley lower than the last
// frame coded error.
if (frame_stats == NULL) {
return 0;
@@ -2027,7 +2039,7 @@ static int compute_arf_boost(const FRAME_INFO *frame_info,
this_frame, &this_frame_mv_in_out, &mv_in_out_accumulator,
&abs_mv_in_out_accumulator, &mv_ratio_accumulator);
- // We want to discount the the flash frame itself and the recovery
+ // We want to discount the flash frame itself and the recovery
// frame that follows as both will have poor scores.
flash_detected = detect_flash_from_frame_stats(this_frame) ||
detect_flash_from_frame_stats(next_frame);
@@ -2158,7 +2170,7 @@ static double calculate_group_score(VP9_COMP *cpi, double av_score,
double score_total = 0.0;
int i = 0;
- // We dont ever want to return a 0 score here.
+ // We don't ever want to return a 0 score here.
if (frame_count == 0) return 1.0;
while ((i < frame_count) && (s < twopass->stats_in_end)) {
@@ -2492,7 +2504,7 @@ static int get_gop_coding_frame_num(
int *use_alt_ref, const FRAME_INFO *frame_info,
const TWO_PASS *const twopass, const RATE_CONTROL *rc,
int gf_start_show_idx, const RANGE *active_gf_interval,
- double gop_intra_factor, int lag_in_frames) {
+ double gop_intra_factor, int lag_in_frames, int *end_of_sequence) {
const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info;
double loop_decay_rate = 1.00;
double mv_ratio_accumulator = 0.0;
@@ -2518,6 +2530,7 @@ static int get_gop_coding_frame_num(
next_frame = fps_get_frame_stats(first_pass_info,
gf_start_show_idx + gop_coding_frames);
if (next_frame == NULL) {
+ *end_of_sequence = gop_coding_frames == 1 && rc->source_alt_ref_active;
break;
}
@@ -2586,7 +2599,7 @@ static int get_gop_coding_frame_num(
if (
// Don't break out with a very short interval.
(gop_coding_frames >= active_gf_interval->min) &&
- // If possible dont break very close to a kf
+ // If possible don't break very close to a kf
((rc->frames_to_key - gop_coding_frames) >= rc->min_gf_interval) &&
(gop_coding_frames & 0x01) && (!flash_detected) &&
((mv_ratio_accumulator > mv_ratio_accumulator_thresh) ||
@@ -2708,6 +2721,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) {
double gop_intra_factor;
int gop_frames;
RANGE active_gf_interval;
+ // Whether this is at the end of last GOP of this sequence.
+ int end_of_sequence = 0;
// Reset the GF group data structures unless this is a key
// frame in which case it will already have been done.
@@ -2739,7 +2754,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) {
gop_coding_frames = get_gop_coding_frame_num(
&use_alt_ref, frame_info, twopass, rc, gf_start_show_idx,
- &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
+ &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames,
+ &end_of_sequence);
use_alt_ref &= allow_alt_ref;
#if CONFIG_RATE_CTRL
// If the external gop_command is on, we will override the decisions
@@ -2757,7 +2773,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) {
// are overwritten. Specifically, |gop_coding_frames| and |use_alt_ref|
// will be overwritten.
if (cpi->ext_ratectrl.ready &&
- (cpi->ext_ratectrl.funcs.rc_type & VPX_RC_GOP) != 0) {
+ (cpi->ext_ratectrl.funcs.rc_type & VPX_RC_GOP) != 0 &&
+ cpi->ext_ratectrl.funcs.get_gop_decision != NULL && !end_of_sequence) {
vpx_codec_err_t codec_status;
vpx_rc_gop_decision_t gop_decision;
vpx_rc_gop_info_t gop_info;
@@ -3020,7 +3037,7 @@ static int intra_step_transition(const FIRSTPASS_STATS *this_frame,
next_frame->intra_error / DOUBLE_DIVIDE_CHECK(next_frame->coded_error);
// Return true the intra/inter ratio for the current frame is
- // low but better in the next and previous frame and the relative useage of
+ // low but better in the next and previous frame and the relative usage of
// intra in the current frame is markedly higher than the last and next frame.
if ((this_ii_ratio < 2.0) && (last_ii_ratio > 2.25) &&
(next_ii_ratio > 2.25) && (this_pcnt_intra > (3 * last_pcnt_intra)) &&
@@ -3041,8 +3058,8 @@ static int intra_step_transition(const FIRSTPASS_STATS *this_frame,
// Minimum % intra coding observed in first pass (1.0 = 100%)
#define MIN_INTRA_LEVEL 0.25
// Threshold for use of the lagging second reference frame. Scene cuts do not
-// usually have a high second ref useage.
-#define SECOND_REF_USEAGE_THRESH 0.2
+// usually have a high second ref usage.
+#define SECOND_REF_USAGE_THRESH 0.2
// Hard threshold where the first pass chooses intra for almost all blocks.
// In such a case even if the frame is not a scene cut coding a key frame
// may be a good option.
@@ -3072,7 +3089,7 @@ static int test_candidate_kf(const FIRST_PASS_INFO *first_pass_info,
detect_flash_from_frame_stats(next_frame);
if (!detect_flash_from_frame_stats(this_frame) &&
!detect_flash_from_frame_stats(next_frame) &&
- (this_frame->pcnt_second_ref < SECOND_REF_USEAGE_THRESH) &&
+ (this_frame->pcnt_second_ref < SECOND_REF_USAGE_THRESH) &&
((this_frame->pcnt_inter < VERY_LOW_INTER_THRESH) ||
(slide_transition(this_frame, last_frame, next_frame)) ||
(intra_step_transition(this_frame, last_frame, next_frame)) ||
@@ -3350,7 +3367,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) {
// The second (lagging) ref error is not valid immediately after
// a key frame because either the lag has not built up (in the case of
- // the first key frame or it points to a refernce before the new key
+ // the first key frame or it points to a reference before the new key
// frame.
if (i < 2) sr_accumulator = 0.0;
frame_boost =
@@ -3380,7 +3397,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) {
twopass->key_frame_section_intra_rating = calculate_section_intra_ratio(
start_position, twopass->stats_in_end, rc->frames_to_key);
- // Special case for static / slide show content but dont apply
+ // Special case for static / slide show content but don't apply
// if the kf group is very short.
if ((zero_motion_accumulator > 0.99) && (rc->frames_to_key > 8)) {
rc->kf_boost = (int)(twopass->kf_max_total_boost);
@@ -3494,8 +3511,8 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
FIRSTPASS_STATS this_frame;
const int show_idx = cm->current_video_frame;
- if (cpi->common.current_frame_coding_index == 0) {
- VP9_COMMON *cm = &cpi->common;
+ if (cpi->common.current_frame_coding_index == 0 &&
+ cpi->ext_ratectrl.funcs.send_firstpass_stats != NULL) {
const vpx_codec_err_t codec_status = vp9_extrc_send_firstpass_stats(
&cpi->ext_ratectrl, &cpi->twopass.first_pass_info);
if (codec_status != VPX_CODEC_OK) {
@@ -3513,7 +3530,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
vp9_init_vizier_params(twopass, screen_area);
}
- // If this is an arf frame then we dont want to read the stats file or
+ // If this is an arf frame then we don't want to read the stats file or
// advance the input pointer as we already have what we need.
if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
int target_rate;
@@ -3792,6 +3809,7 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf,
const int arf_active_or_kf = last_gop_use_alt_ref || first_is_key_frame;
RANGE active_gf_interval;
int arf_layers;
+ int end_of_sequence = 0;
if (oxcf->use_simple_encode_api) {
active_gf_interval = get_active_gf_inverval_range_simple(
rc->min_gf_interval, arf_active_or_kf, rc->frames_to_key);
@@ -3809,9 +3827,9 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf,
gop_intra_factor = 1.0;
}
- frame_count = get_gop_coding_frame_num(use_alt_ref, frame_info, twopass, rc,
- show_idx, &active_gf_interval,
- gop_intra_factor, oxcf->lag_in_frames);
+ frame_count = get_gop_coding_frame_num(
+ use_alt_ref, frame_info, twopass, rc, show_idx, &active_gf_interval,
+ gop_intra_factor, oxcf->lag_in_frames, &end_of_sequence);
*use_alt_ref &= allow_alt_ref;
return frame_count;
}