ref: 5dcdeb4cf8a619324099ed1715d5689055ff5494
parent: 00e49e4e6860ccfd6b9b35e2473debe0ab9551b2
author: Angie Chiang <angiebird@google.com>
date: Tue Jan 29 11:26:57 EST 2019
Add assertion in get_block_src_pred_buf Print error message and assert when ref_frame_idx is invalid Change-Id: Ice6d06c53ddae0a77d578671b896c4e4d04d5366
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -6015,10 +6015,10 @@
}
#if CONFIG_NON_GREEDY_MV
-static void get_block_src_pred_buf(MACROBLOCKD *xd, GF_PICTURE *gf_picture,
- int frame_idx, int rf_idx, int mi_row,
- int mi_col, struct buf_2d *src,
- struct buf_2d *pre) {
+static int get_block_src_pred_buf(MACROBLOCKD *xd, GF_PICTURE *gf_picture,
+ int frame_idx, int rf_idx, int mi_row,
+ int mi_col, struct buf_2d *src,
+ struct buf_2d *pre) {
const int mb_y_offset =
mi_row * MI_SIZE * xd->cur_buf->y_stride + mi_col * MI_SIZE;
YV12_BUFFER_CONFIG *ref_frame = NULL;
@@ -6025,12 +6025,17 @@
int ref_frame_idx = gf_picture[frame_idx].ref_frame[rf_idx];
if (ref_frame_idx != -1) {
ref_frame = gf_picture[ref_frame_idx].frame;
+ src->buf = xd->cur_buf->y_buffer + mb_y_offset;
+ src->stride = xd->cur_buf->y_stride;
+ pre->buf = ref_frame->y_buffer + mb_y_offset;
+ pre->stride = ref_frame->y_stride;
+ assert(src->stride == pre->stride);
+ return 1;
+ } else {
+ printf("invalid ref_frame_idx");
+ assert(ref_frame_idx != -1);
+ return 0;
}
- src->buf = xd->cur_buf->y_buffer + mb_y_offset;
- src->stride = xd->cur_buf->y_stride;
- pre->buf = ref_frame->y_buffer + mb_y_offset;
- pre->stride = ref_frame->y_stride;
- assert(src->stride == pre->stride);
}
#define kMvPreCheckLines 5
@@ -6136,12 +6141,16 @@
*mv = get_mv_from_mv_mode(mv_mode, cpi, tpl_frame, rf_idx, bsize, mi_row,
mi_col);
full_mv = get_full_mv(&mv->as_mv);
- get_block_src_pred_buf(xd, gf_picture, frame_idx, rf_idx, mi_row, mi_col,
- &src, &pre);
- // TODO(angiebird): Consider subpixel when computing the sse.
- cpi->fn_ptr[bsize].vf(src.buf, src.stride, get_buf_from_mv(&pre, &full_mv),
- pre.stride, &sse);
- return (double)sse;
+ if (get_block_src_pred_buf(xd, gf_picture, frame_idx, rf_idx, mi_row, mi_col,
+ &src, &pre)) {
+ // TODO(angiebird): Consider subpixel when computing the sse.
+ cpi->fn_ptr[bsize].vf(src.buf, src.stride, get_buf_from_mv(&pre, &full_mv),
+ pre.stride, &sse);
+ return (double)sse;
+ } else {
+ assert(0);
+ return 0;
+ }
}
static double get_mv_cost(int mv_mode) {