diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index 753a7e41d..57b1c85a1 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -277,11 +277,11 @@ void EncoderTest::RunLoop(VideoSource *video) { cfg_.g_pass = VPX_RC_LAST_PASS; BeginPassHook(pass); - Encoder* const encoder = codec_->CreateEncoder(cfg_, deadline_, init_flags_, - &stats_); - ASSERT_TRUE(encoder != NULL); + testing::internal::scoped_ptr encoder( + codec_->CreateEncoder(cfg_, deadline_, init_flags_, &stats_)); + ASSERT_TRUE(encoder.get() != NULL); - video->Begin(); + ASSERT_NO_FATAL_FAILURE(video->Begin()); encoder->InitEncoder(video); ASSERT_FALSE(::testing::Test::HasFatalFailure()); @@ -290,7 +290,8 @@ void EncoderTest::RunLoop(VideoSource *video) { // NOTE: fragment decoder and partition encoder are only supported by VP8. if (init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) dec_init_flags |= VPX_CODEC_USE_INPUT_FRAGMENTS; - Decoder* const decoder = codec_->CreateDecoder(dec_cfg, dec_init_flags, 0); + testing::internal::scoped_ptr decoder( + codec_->CreateDecoder(dec_cfg, dec_init_flags, 0)); #if CONFIG_VP10 && CONFIG_EXT_TILE if (decoder->IsVP10()) { // Set dec_cfg.tile_row = -1 and dec_cfg.tile_col = -1 so that the whole @@ -305,7 +306,7 @@ void EncoderTest::RunLoop(VideoSource *video) { again = (video->img() != NULL); PreEncodeFrameHook(video); - PreEncodeFrameHook(video, encoder); + PreEncodeFrameHook(video, encoder.get()); encoder->EncodeFrame(video, frame_flags_); CxDataIterator iter = encoder->GetCxData(); @@ -318,11 +319,11 @@ void EncoderTest::RunLoop(VideoSource *video) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: has_cxdata = true; - if (decoder && DoDecode()) { + if (decoder.get() != NULL && DoDecode()) { vpx_codec_err_t res_dec = decoder->DecodeFrame( (const uint8_t*)pkt->data.frame.buf, pkt->data.frame.sz); - if (!HandleDecodeResult(res_dec, *video, decoder)) + if (!HandleDecodeResult(res_dec, *video, decoder.get())) break; has_dxdata = true; @@ -344,7 +345,7 @@ void EncoderTest::RunLoop(VideoSource *video) { // Flush the decoder when there are no more fragments. if ((init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) && has_dxdata) { const vpx_codec_err_t res_dec = decoder->DecodeFrame(NULL, 0); - if (!HandleDecodeResult(res_dec, *video, decoder)) + if (!HandleDecodeResult(res_dec, *video, decoder.get())) break; } @@ -368,10 +369,6 @@ void EncoderTest::RunLoop(VideoSource *video) { EndPassHook(); - if (decoder) - delete decoder; - delete encoder; - if (!Continue()) break; }