Commit f288c943 authored by Marco's avatar Marco

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
parent aff0a802
......@@ -127,6 +127,20 @@ unsigned int ScaleForFrameNumber(unsigned int frame, unsigned int val) {
return val / 2;
if (frame < 180)
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;
}
......@@ -134,7 +148,7 @@ class ResizingVideoSource : public ::libvpx_test::DummyVideoSource {
public:
ResizingVideoSource() {
SetSize(kInitialWidth, kInitialHeight);
limit_ = 200;
limit_ = 300;
}
virtual ~ResizingVideoSource() {}
......
......@@ -2975,8 +2975,19 @@ void vp9_scale_references(VP9_COMP *cpi) {
}
#endif // CONFIG_VP9_HIGHBITDEPTH
} else {
const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
RefCntBuffer *const buf = &pool->frame_bufs[buf_idx];
int 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_height = ref->y_crop_height;
cpi->scaled_ref_idx[ref_frame - 1] = buf_idx;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment