ref: 88cc292b224daf2e9f10e163ac534e2264be3958
parent: 319c93f20d87cc06d7506f1e3ae67152400a52e4
parent: 6b22c999ca9192cee05c28dd9dabb8977226d37b
author: Jingning Han <[email protected]>
date: Wed Aug 1 22:36:41 EDT 2018
Merge "Add frame pointer to support recon frames in tpl model"
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5496,12 +5496,40 @@
void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
const GF_GROUP *gf_group, int *tpl_group_frames) {
- int frame_idx, i;
+ VP9_COMMON *cm = &cpi->common;
+ int frame_idx = 0;
+ int i;
int gld_index = -1;
int alt_index = -1;
int lst_index = -1;
int extend_frame_count = 0;
int pframe_qindex = cpi->tpl_stats[2].base_qindex;
+
+ RefCntBuffer *frame_bufs = cm->buffer_pool->frame_bufs;
+ int recon_frame_index[REFS_PER_FRAME + 1] = { -1, -1, -1, -1 };
+
+ for (i = 0; i < FRAME_BUFFERS && frame_idx < REFS_PER_FRAME + 1; ++i) {
+ if (frame_bufs[i].ref_count == 0) {
+ alloc_frame_mvs(cm, i);
+ if (vpx_realloc_frame_buffer(&frame_bufs[i].buf, cm->width, cm->height,
+ cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_VP9_HIGHBITDEPTH
+ cm->use_highbitdepth,
+#endif
+ VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
+ NULL, NULL, NULL))
+ vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate frame buffer");
+
+ recon_frame_index[frame_idx] = i;
+ ++frame_idx;
+ }
+ }
+
+ for (i = 0; i < REFS_PER_FRAME + 1; ++i) {
+ assert(recon_frame_index[i] >= 0);
+ cpi->tpl_recon_frames[i] = &frame_bufs[recon_frame_index[i]].buf;
+ }
*tpl_group_frames = 0;
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -501,6 +501,7 @@
YV12_BUFFER_CONFIG *raw_source_frame;
TplDepFrame tpl_stats[MAX_LAG_BUFFERS];
+ YV12_BUFFER_CONFIG *tpl_recon_frames[REFS_PER_FRAME + 1];
TileDataEnc *tile_data;
int allocated_tiles; // Keep track of memory allocated for tiles.