vp9-dynamic resize: Fix bug on releasing scaled reference.

When the codec frame size is the same as the reference frame size,
release the scaled reference before assigning it a new buf_idx.
Only affects 1 pass non-svc mode, where the scaled references are
release only under certain conditions (to prevent un-needed scaling
of the references every frame).

Modified a unittest that can trigger this bug without this change.

https://code.google.com/p/chromium/issues/detail?id=582598

Change-Id: I9a884e36ebd7608b1641ec2a469e20a4f829cf43
This commit is contained in:
Marco 2016-02-08 10:41:13 -08:00
parent aff0a802e7
commit f288c943c4
2 changed files with 28 additions and 3 deletions

View File

@ -127,6 +127,20 @@ unsigned int ScaleForFrameNumber(unsigned int frame, unsigned int val) {
return val / 2; return val / 2;
if (frame < 180) if (frame < 180)
return val * 3 / 4; return val * 3 / 4;
if (frame < 190)
return val;
if (frame < 200)
return val * 3 / 4;
if (frame < 210)
return val / 2;
if (frame < 220)
return val * 3 / 4;
if (frame < 230)
return val;
if (frame < 240)
return val / 2;
if (frame < 250)
return val * 3 / 4;
return val; return val;
} }
@ -134,7 +148,7 @@ class ResizingVideoSource : public ::libvpx_test::DummyVideoSource {
public: public:
ResizingVideoSource() { ResizingVideoSource() {
SetSize(kInitialWidth, kInitialHeight); SetSize(kInitialWidth, kInitialHeight);
limit_ = 200; limit_ = 300;
} }
virtual ~ResizingVideoSource() {} virtual ~ResizingVideoSource() {}

View File

@ -2975,8 +2975,19 @@ void vp9_scale_references(VP9_COMP *cpi) {
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
} else { } else {
const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame); int buf_idx;
RefCntBuffer *const buf = &pool->frame_bufs[buf_idx]; RefCntBuffer *buf = NULL;
if (cpi->oxcf.pass == 0 && !cpi->use_svc) {
// Check for release of scaled reference.
buf_idx = cpi->scaled_ref_idx[ref_frame - 1];
buf = (buf_idx != INVALID_IDX) ? &pool->frame_bufs[buf_idx] : NULL;
if (buf != NULL) {
--buf->ref_count;
cpi->scaled_ref_idx[ref_frame - 1] = INVALID_IDX;
}
}
buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
buf = &pool->frame_bufs[buf_idx];
buf->buf.y_crop_width = ref->y_crop_width; buf->buf.y_crop_width = ref->y_crop_width;
buf->buf.y_crop_height = ref->y_crop_height; buf->buf.y_crop_height = ref->y_crop_height;
cpi->scaled_ref_idx[ref_frame - 1] = buf_idx; cpi->scaled_ref_idx[ref_frame - 1] = buf_idx;