Make test encoder test driver less likely to leak on failure.

Individual tests still need to be updated.

Change-Id: Ic433d0f742e13560b136f136b72b2a9973970d78
This commit is contained in:
Alex Converse 2016-07-21 11:36:41 -07:00 коммит произвёл Yaowu Xu
Родитель e0c265e4cb
Коммит 1c1bc94899
1 изменённых файлов: 10 добавлений и 13 удалений

Просмотреть файл

@ -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> 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> 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;
}