diff options
author | jackychen <jackychen@google.com> | 2015-09-21 09:37:46 -0700 |
---|---|---|
committer | jackychen <jackychen@google.com> | 2015-09-21 10:57:05 -0700 |
commit | 55f092db09e0bec0f953f77830ac8ac6bb67fdf9 (patch) | |
tree | 7e2125b4ff53bd4e2a94eeb7d8f553b8581ccdbd | |
parent | 67ec82a2620b890e9a0ccbf446b1447f8ab3a80d (diff) | |
download | libvpx-55f092db09e0bec0f953f77830ac8ac6bb67fdf9.tar libvpx-55f092db09e0bec0f953f77830ac8ac6bb67fdf9.tar.gz libvpx-55f092db09e0bec0f953f77830ac8ac6bb67fdf9.tar.bz2 libvpx-55f092db09e0bec0f953f77830ac8ac6bb67fdf9.zip |
Change size on first frame and change config cause crash.
Reallocation of mi buffer fails if change size on the first frame and
change config in subsequent frames. Add a condition for resolution
check to avoid assertion failure.
BUG=1074
Change-Id: Ie26ed816a57fa871ba27a72db9805baaaeaba9f3
-rw-r--r-- | test/resize_test.cc | 39 | ||||
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 11 |
2 files changed, 40 insertions, 10 deletions
diff --git a/test/resize_test.cc b/test/resize_test.cc index a86c9d115..98b6f87e1 100644 --- a/test/resize_test.cc +++ b/test/resize_test.cc @@ -196,13 +196,27 @@ class ResizeInternalTest : public ResizeTest { virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video, libvpx_test::Encoder *encoder) { - if (video->frame() == kStepDownFrame) { - struct vpx_scaling_mode mode = {VP8E_FOURFIVE, VP8E_THREEFIVE}; - encoder->Control(VP8E_SET_SCALEMODE, &mode); - } - if (video->frame() == kStepUpFrame) { - struct vpx_scaling_mode mode = {VP8E_NORMAL, VP8E_NORMAL}; - encoder->Control(VP8E_SET_SCALEMODE, &mode); + if (change_config_) { + int new_q = 60; + if (video->frame() == 0) { + struct vpx_scaling_mode mode = {VP8E_ONETWO, VP8E_ONETWO}; + encoder->Control(VP8E_SET_SCALEMODE, &mode); + } + if (video->frame() == 1) { + struct vpx_scaling_mode mode = {VP8E_NORMAL, VP8E_NORMAL}; + encoder->Control(VP8E_SET_SCALEMODE, &mode); + cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = new_q; + encoder->Config(&cfg_); + } + } else { + if (video->frame() == kStepDownFrame) { + struct vpx_scaling_mode mode = {VP8E_FOURFIVE, VP8E_THREEFIVE}; + encoder->Control(VP8E_SET_SCALEMODE, &mode); + } + if (video->frame() == kStepUpFrame) { + struct vpx_scaling_mode mode = {VP8E_NORMAL, VP8E_NORMAL}; + encoder->Control(VP8E_SET_SCALEMODE, &mode); + } } } @@ -227,6 +241,7 @@ class ResizeInternalTest : public ResizeTest { #endif double frame0_psnr_; + bool change_config_; #if WRITE_COMPRESSED_STREAM FILE *outfile_; unsigned int out_frames_; @@ -237,6 +252,7 @@ TEST_P(ResizeInternalTest, TestInternalResizeWorks) { ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 30, 1, 0, 10); init_flags_ = VPX_CODEC_USE_PSNR; + change_config_ = false; // q picked such that initial keyframe on this clip is ~30dB PSNR cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = 48; @@ -261,6 +277,15 @@ TEST_P(ResizeInternalTest, TestInternalResizeWorks) { } } +TEST_P(ResizeInternalTest, TestInternalResizeChangeConfig) { + ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, + 30, 1, 0, 10); + cfg_.g_w = 352; + cfg_.g_h = 288; + change_config_ = true; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +} + class ResizeInternalRealtimeTest : public ::libvpx_test::EncoderTest, public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> { protected: diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 91e92ff24..eb0d3608f 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -1517,7 +1517,10 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { } if (cpi->initial_width) { - if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) { + int new_mi_size = 0; + vp9_set_mb_mi(cm, cm->width, cm->height); + new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows); + if (cm->mi_alloc_size < new_mi_size) { vp9_free_context_buffers(cm); alloc_compressor_data(cpi); realloc_segmentation_maps(cpi); @@ -4642,8 +4645,10 @@ int vp9_set_internal_size(VP9_COMP *cpi, // always go to the next whole number cm->width = (hs - 1 + cpi->oxcf.width * hr) / hs; cm->height = (vs - 1 + cpi->oxcf.height * vr) / vs; - assert(cm->width <= cpi->initial_width); - assert(cm->height <= cpi->initial_height); + if (cm->current_video_frame) { + assert(cm->width <= cpi->initial_width); + assert(cm->height <= cpi->initial_height); + } update_frame_size(cpi); |