ref: 0d203054b3f51eb42a36895dc70c0b2ce599df90
parent: b2f9b627e3ed2db23b6f856f4307e97879f68575
author: Jingning Han <jingning@google.com>
date: Mon Aug 27 11:22:24 EDT 2018
Rework enc/dec mismatch detection The previous enc/dec mismatch detection assumes the previously reconstructed frame would always stay at frame buffer pool index at 0. It could hence cause certain delay in enc/dec mismatch detection when the immediate reconstruction frame is not yet propagated to index 0 in the buffer map pool. This change always keeps the latest decoded show frame buffer index and directly gets the reconstructed frame from encoder and decoder buffer pools to check for mismatch. Change-Id: If53092cbc42ab78d55af5b83f12a489fc362f3ae
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -128,6 +128,8 @@
int new_fb_idx;
+ int cur_show_frame_fb_idx;
+
#if CONFIG_VP9_POSTPROC
YV12_BUFFER_CONFIG post_proc_buffer;
YV12_BUFFER_CONFIG post_proc_buffer_int;
@@ -259,6 +261,12 @@
int lf_row;
} VP9_COMMON;
+
+static INLINE YV12_BUFFER_CONFIG *get_buf_frame(VP9_COMMON *cm, int index) {
+ if (index < 0 || index >= FRAME_BUFFERS) return NULL;
+ if (cm->error.error_code != VPX_CODEC_OK) return NULL;
+ return &cm->buffer_pool->frame_bufs[index].buf;
+}
static INLINE YV12_BUFFER_CONFIG *get_ref_frame(VP9_COMMON *cm, int index) {
if (index < 0 || index >= REF_FRAMES) return NULL;
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -365,6 +365,8 @@
if (cm->seg.enabled) vp9_swap_current_and_last_seg_map(cm);
}
+ if (cm->show_frame) cm->cur_show_frame_fb_idx = cm->new_fb_idx;
+
// Update progress in frame parallel decode.
cm->last_width = cm->width;
cm->last_height = cm->height;
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -6280,6 +6280,8 @@
}
#endif // CONFIG_REALTIME_ONLY
+ if (cm->show_frame) cm->cur_show_frame_fb_idx = cm->new_fb_idx;
+
if (cm->refresh_frame_context)
cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1317,9 +1317,9 @@
vp9_ref_frame_t *const frame = va_arg(args, vp9_ref_frame_t *);
if (frame != NULL) {
- YV12_BUFFER_CONFIG *fb = get_ref_frame(&ctx->cpi->common, frame->idx);
+ const int fb_idx = ctx->cpi->common.cur_show_frame_fb_idx;
+ YV12_BUFFER_CONFIG *fb = get_buf_frame(&ctx->cpi->common, fb_idx);
if (fb == NULL) return VPX_CODEC_ERROR;
-
yuvconfig2image(&frame->img, fb, NULL);
return VPX_CODEC_OK;
}
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -471,8 +471,8 @@
vp9_ref_frame_t *data = va_arg(args, vp9_ref_frame_t *);
if (data) {
- YV12_BUFFER_CONFIG *fb;
- fb = get_ref_frame(&ctx->pbi->common, data->idx);
+ const int fb_idx = ctx->pbi->common.cur_show_frame_fb_idx;
+ YV12_BUFFER_CONFIG *fb = get_buf_frame(&ctx->pbi->common, fb_idx);
if (fb == NULL) return VPX_CODEC_ERROR;
yuvconfig2image(&data->img, fb, NULL);
return VPX_CODEC_OK;