From: Jingning Han Date: Fri, 27 Jul 2018 22:08:39 +0000 (-0700) Subject: Add frame pointer to support recon frames in tpl model X-Git-Tag: v1.8.0~461^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b22c999ca9192cee05c28dd9dabb8977226d37b;p=libvpx Add frame pointer to support recon frames in tpl model Add frame pointer to re-use spare frames to store the reconstructed frames. Change-Id: I870aa048fc9b7d8b356aa73df3a92b4670425f95 --- diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index afe51366d..c08199785 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -5496,13 +5496,41 @@ typedef struct GF_PICTURE { 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; // Initialize Golden reference frame. diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 0c6375c65..038413a96 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -501,6 +501,7 @@ typedef struct VP9_COMP { 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.