summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorJingning Han <jingning@google.com>2018-08-27 15:22:24 -0700
committerJingning Han <jingning@google.com>2018-08-27 16:40:45 -0700
commit0d203054b3f51eb42a36895dc70c0b2ce599df90 (patch)
tree525de19e209cc41692c686c2212ef14e1c587af6 /vp9
parentb2f9b627e3ed2db23b6f856f4307e97879f68575 (diff)
downloadlibvpx-0d203054b3f51eb42a36895dc70c0b2ce599df90.tar
libvpx-0d203054b3f51eb42a36895dc70c0b2ce599df90.tar.gz
libvpx-0d203054b3f51eb42a36895dc70c0b2ce599df90.tar.bz2
libvpx-0d203054b3f51eb42a36895dc70c0b2ce599df90.zip
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
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_onyxc_int.h8
-rw-r--r--vp9/decoder/vp9_decoder.c2
-rw-r--r--vp9/encoder/vp9_encoder.c2
-rw-r--r--vp9/vp9_cx_iface.c4
-rw-r--r--vp9/vp9_dx_iface.c4
5 files changed, 16 insertions, 4 deletions
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index e053e2ee0..c72b6e64f 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -128,6 +128,8 @@ typedef struct VP9Common {
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;
@@ -260,6 +262,12 @@ typedef struct VP9Common {
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;
if (cm->ref_frame_map[index] < 0) return NULL;
diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c
index d6eacaf44..b4d05f663 100644
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -365,6 +365,8 @@ int vp9_receive_compressed_data(VP9Decoder *pbi, size_t size,
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;
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 44683f04b..e1a3fbf06 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -6280,6 +6280,8 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
}
#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;
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 11ba8df08..d7ed514c1 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1317,9 +1317,9 @@ static vpx_codec_err_t ctrl_get_reference(vpx_codec_alg_priv_t *ctx,
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;
}
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 7f45ab28f..fdff87768 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -471,8 +471,8 @@ static vpx_codec_err_t ctrl_get_reference(vpx_codec_alg_priv_t *ctx,
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;