summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encoder.c
diff options
context:
space:
mode:
authorAngie Chiang <angiebird@google.com>2020-10-21 21:26:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-10-21 21:26:34 +0000
commitee482c87c749e727915e8c5cb7d6e0b414286851 (patch)
treeca5160fd34d181c368e0077cb8215e350acf3d27 /vp9/encoder/vp9_encoder.c
parent13aad8bb6404d56138c16886939cf50c63850651 (diff)
parenta207a0f6b9af8e05e4379d5a8f29f549d3b32c61 (diff)
downloadlibvpx-ee482c87c749e727915e8c5cb7d6e0b414286851.tar
libvpx-ee482c87c749e727915e8c5cb7d6e0b414286851.tar.gz
libvpx-ee482c87c749e727915e8c5cb7d6e0b414286851.tar.bz2
libvpx-ee482c87c749e727915e8c5cb7d6e0b414286851.zip
Merge changes I27932c41,I2ff9e54a,I4ebed472
* changes: Small changes of vp9_ext_ratectrl_test.cc Add ref frame info to vpx_rc_encodeframe_info_t Add vpx_rc_status_t
Diffstat (limited to 'vp9/encoder/vp9_encoder.c')
-rw-r--r--vp9/encoder/vp9_encoder.c102
1 files changed, 57 insertions, 45 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 8d1d3b805..f2e6ba1ac 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4206,6 +4206,27 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
return 1;
}
+static int get_ref_frame_flags(const VP9_COMP *cpi) {
+ const int *const map = cpi->common.ref_frame_map;
+ const int gold_is_last = map[cpi->gld_fb_idx] == map[cpi->lst_fb_idx];
+ const int alt_is_last = map[cpi->alt_fb_idx] == map[cpi->lst_fb_idx];
+ const int gold_is_alt = map[cpi->gld_fb_idx] == map[cpi->alt_fb_idx];
+ int flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG;
+
+ if (gold_is_last) flags &= ~VP9_GOLD_FLAG;
+
+ if (cpi->rc.frames_till_gf_update_due == INT_MAX &&
+ (cpi->svc.number_temporal_layers == 1 &&
+ cpi->svc.number_spatial_layers == 1))
+ flags &= ~VP9_GOLD_FLAG;
+
+ if (alt_is_last) flags &= ~VP9_ALT_FLAG;
+
+ if (gold_is_alt) flags &= ~VP9_ALT_FLAG;
+
+ return flags;
+}
+
#if !CONFIG_REALTIME_ONLY
#define MAX_QSTEP_ADJ 4
static int get_qstep_adj(int rate_excess, int rate_limit) {
@@ -4482,9 +4503,14 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest
if (cpi->ext_ratectrl.ready) {
const GF_GROUP *gf_group = &cpi->twopass.gf_group;
vpx_rc_encodeframe_decision_t encode_frame_decision;
+ FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index];
+ const int ref_frame_flags = get_ref_frame_flags(cpi);
+ RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES];
+ get_ref_frame_bufs(cpi, ref_frame_bufs);
vp9_extrc_get_encodeframe_decision(
- &cpi->ext_ratectrl, gf_group, cm->current_video_frame,
- cm->current_frame_coding_index, &encode_frame_decision);
+ &cpi->ext_ratectrl, cm->current_video_frame,
+ cm->current_frame_coding_index, update_type, ref_frame_bufs,
+ ref_frame_flags, &encode_frame_decision);
q = encode_frame_decision.q_index;
}
@@ -4773,27 +4799,6 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, uint8_t *dest
}
#endif // !CONFIG_REALTIME_ONLY
-static int get_ref_frame_flags(const VP9_COMP *cpi) {
- const int *const map = cpi->common.ref_frame_map;
- const int gold_is_last = map[cpi->gld_fb_idx] == map[cpi->lst_fb_idx];
- const int alt_is_last = map[cpi->alt_fb_idx] == map[cpi->lst_fb_idx];
- const int gold_is_alt = map[cpi->gld_fb_idx] == map[cpi->alt_fb_idx];
- int flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG;
-
- if (gold_is_last) flags &= ~VP9_GOLD_FLAG;
-
- if (cpi->rc.frames_till_gf_update_due == INT_MAX &&
- (cpi->svc.number_temporal_layers == 1 &&
- cpi->svc.number_spatial_layers == 1))
- flags &= ~VP9_GOLD_FLAG;
-
- if (alt_is_last) flags &= ~VP9_ALT_FLAG;
-
- if (gold_is_alt) flags &= ~VP9_ALT_FLAG;
-
- return flags;
-}
-
static void set_ext_overrides(VP9_COMP *cpi) {
// Overrides the defaults with the externally supplied values with
// vp9_update_reference() and vp9_update_entropy() calls
@@ -5098,9 +5103,7 @@ static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
ref_buffer->frame_index =
cm->current_video_frame + gf_group->arf_src_offset[gf_group->index];
-#if CONFIG_RATE_CTRL
ref_buffer->frame_coding_index = cm->current_frame_coding_index;
-#endif // CONFIG_RATE_CTRL
}
}
@@ -7392,6 +7395,30 @@ static void setup_tpl_stats(VP9_COMP *cpi) {
#endif // CONFIG_NON_GREEDY_MV
}
+void vp9_get_ref_frame_info(FRAME_UPDATE_TYPE update_type, int ref_frame_flags,
+ RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES],
+ int *ref_frame_coding_indexes,
+ int *ref_frame_valid_list) {
+ if (update_type != KF_UPDATE) {
+ const VP9_REFFRAME inter_ref_flags[MAX_INTER_REF_FRAMES] = { VP9_LAST_FLAG,
+ VP9_GOLD_FLAG,
+ VP9_ALT_FLAG };
+ int i;
+ for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) {
+ assert(ref_frame_bufs[i] != NULL);
+ ref_frame_coding_indexes[i] = ref_frame_bufs[i]->frame_coding_index;
+ ref_frame_valid_list[i] = (ref_frame_flags & inter_ref_flags[i]) != 0;
+ }
+ } else {
+ // No reference frame is available when this is a key frame.
+ int i;
+ for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) {
+ ref_frame_coding_indexes[i] = -1;
+ ref_frame_valid_list[i] = 0;
+ }
+ }
+}
+
#if !CONFIG_REALTIME_ONLY
#if CONFIG_RATE_CTRL
static void copy_frame_counts(const FRAME_COUNTS *input_counts,
@@ -7539,6 +7566,7 @@ static void yv12_buffer_to_image_buffer(const YV12_BUFFER_CONFIG *yv12_buffer,
}
}
#endif // CONFIG_RATE_CTRL
+
static void update_encode_frame_result(
int ref_frame_flags, FRAME_UPDATE_TYPE update_type,
const YV12_BUFFER_CONFIG *source_frame, const RefCntBuffer *coded_frame_buf,
@@ -7561,26 +7589,10 @@ static void update_encode_frame_result(
#endif // CONFIG_VP9_HIGHBITDEPTH
encode_frame_result->frame_coding_index = coded_frame_buf->frame_coding_index;
- if (update_type != KF_UPDATE) {
- const VP9_REFFRAME inter_ref_flags[MAX_INTER_REF_FRAMES] = { VP9_LAST_FLAG,
- VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
- int i;
- for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) {
- assert(ref_frame_bufs[i] != NULL);
- encode_frame_result->ref_frame_coding_indexes[i] =
- ref_frame_bufs[i]->frame_coding_index;
- encode_frame_result->ref_frame_valid_list[i] =
- (ref_frame_flags & inter_ref_flags[i]) != 0;
- }
- } else {
- // No reference frame is available when this is a key frame.
- int i;
- for (i = 0; i < MAX_INTER_REF_FRAMES; ++i) {
- encode_frame_result->ref_frame_coding_indexes[i] = -1;
- encode_frame_result->ref_frame_valid_list[i] = 0;
- }
- }
+ vp9_get_ref_frame_info(update_type, ref_frame_flags, ref_frame_bufs,
+ encode_frame_result->ref_frame_coding_indexes,
+ encode_frame_result->ref_frame_valid_list);
+
encode_frame_result->psnr = psnr.psnr[0];
encode_frame_result->sse = psnr.sse[0];
copy_frame_counts(counts, &encode_frame_result->frame_counts);