diff options
Diffstat (limited to 'test/encode_test_driver.cc')
-rw-r--r-- | test/encode_test_driver.cc | 85 |
1 files changed, 34 insertions, 51 deletions
diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index e189d8f04..6154d3ead 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -30,8 +30,7 @@ void Encoder::InitEncoder(VideoSource *video) { cfg_.g_timebase = video->timebase(); cfg_.rc_twopass_stats_in = stats_->buf(); - res = vpx_codec_enc_init(&encoder_, CodecInterface(), &cfg_, - init_flags_); + res = vpx_codec_enc_init(&encoder_, CodecInterface(), &cfg_, init_flags_); ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); #if CONFIG_VP9_ENCODER @@ -62,8 +61,7 @@ void Encoder::EncodeFrame(VideoSource *video, const unsigned long frame_flags) { CxDataIterator iter = GetCxData(); while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) { - if (pkt->kind != VPX_CODEC_STATS_PKT) - continue; + if (pkt->kind != VPX_CODEC_STATS_PKT) continue; stats_->Append(*pkt); } @@ -83,15 +81,15 @@ void Encoder::EncodeFrameInternal(const VideoSource &video, } // Encode the frame - API_REGISTER_STATE_CHECK( - res = vpx_codec_encode(&encoder_, img, video.pts(), video.duration(), - frame_flags, deadline_)); + API_REGISTER_STATE_CHECK(res = vpx_codec_encode(&encoder_, img, video.pts(), + video.duration(), frame_flags, + deadline_)); ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); } void Encoder::Flush() { - const vpx_codec_err_t res = vpx_codec_encode(&encoder_, NULL, 0, 0, 0, - deadline_); + const vpx_codec_err_t res = + vpx_codec_encode(&encoder_, NULL, 0, 0, 0, deadline_); if (!encoder_.priv) ASSERT_EQ(VPX_CODEC_ERROR, res) << EncoderError(); else @@ -106,22 +104,15 @@ void EncoderTest::InitializeConfig() { void EncoderTest::SetMode(TestMode mode) { switch (mode) { - case kRealTime: - deadline_ = VPX_DL_REALTIME; - break; + case kRealTime: deadline_ = VPX_DL_REALTIME; break; case kOnePassGood: - case kTwoPassGood: - deadline_ = VPX_DL_GOOD_QUALITY; - break; + case kTwoPassGood: deadline_ = VPX_DL_GOOD_QUALITY; break; case kOnePassBest: - case kTwoPassBest: - deadline_ = VPX_DL_BEST_QUALITY; - break; + case kTwoPassBest: deadline_ = VPX_DL_BEST_QUALITY; break; - default: - ASSERT_TRUE(false) << "Unexpected mode " << mode; + default: ASSERT_TRUE(false) << "Unexpected mode " << mode; } if (mode == kTwoPassGood || mode == kTwoPassBest) @@ -131,35 +122,35 @@ void EncoderTest::SetMode(TestMode mode) { } // The function should return "true" most of the time, therefore no early // break-out is implemented within the match checking process. -static bool compare_img(const vpx_image_t *img1, - const vpx_image_t *img2) { - bool match = (img1->fmt == img2->fmt) && - (img1->cs == img2->cs) && - (img1->d_w == img2->d_w) && - (img1->d_h == img2->d_h); - - const unsigned int width_y = img1->d_w; +static bool compare_img(const vpx_image_t *img1, const vpx_image_t *img2) { + bool match = (img1->fmt == img2->fmt) && (img1->cs == img2->cs) && + (img1->d_w == img2->d_w) && (img1->d_h == img2->d_h); + + const unsigned int width_y = img1->d_w; const unsigned int height_y = img1->d_h; unsigned int i; for (i = 0; i < height_y; ++i) match = (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y], img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y], - width_y) == 0) && match; - const unsigned int width_uv = (img1->d_w + 1) >> 1; + width_y) == 0) && + match; + const unsigned int width_uv = (img1->d_w + 1) >> 1; const unsigned int height_uv = (img1->d_h + 1) >> 1; - for (i = 0; i < height_uv; ++i) + for (i = 0; i < height_uv; ++i) match = (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U], img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U], - width_uv) == 0) && match; + width_uv) == 0) && + match; for (i = 0; i < height_uv; ++i) match = (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_V], img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_V], - width_uv) == 0) && match; + width_uv) == 0) && + match; return match; } -void EncoderTest::MismatchHook(const vpx_image_t* /*img1*/, - const vpx_image_t* /*img2*/) { +void EncoderTest::MismatchHook(const vpx_image_t * /*img1*/, + const vpx_image_t * /*img2*/) { ASSERT_TRUE(0) << "Encode/Decode mismatch found"; } @@ -215,10 +206,9 @@ void EncoderTest::RunLoop(VideoSource *video) { has_cxdata = true; if (decoder.get() != NULL && DoDecode()) { vpx_codec_err_t res_dec = decoder->DecodeFrame( - (const uint8_t*)pkt->data.frame.buf, pkt->data.frame.sz); + (const uint8_t *)pkt->data.frame.buf, pkt->data.frame.sz); - if (!HandleDecodeResult(res_dec, *video, decoder.get())) - break; + if (!HandleDecodeResult(res_dec, *video, decoder.get())) break; has_dxdata = true; } @@ -227,20 +217,16 @@ void EncoderTest::RunLoop(VideoSource *video) { FramePktHook(pkt); break; - case VPX_CODEC_PSNR_PKT: - PSNRPktHook(pkt); - break; + case VPX_CODEC_PSNR_PKT: PSNRPktHook(pkt); break; - default: - break; + default: break; } } // 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.get())) - break; + if (!HandleDecodeResult(res_dec, *video, decoder.get())) break; } if (has_dxdata && has_cxdata) { @@ -253,17 +239,14 @@ void EncoderTest::RunLoop(VideoSource *video) { MismatchHook(img_enc, img_dec); } } - if (img_dec) - DecompressedFrameHook(*img_dec, video->pts()); + if (img_dec) DecompressedFrameHook(*img_dec, video->pts()); } - if (!Continue()) - break; + if (!Continue()) break; } EndPassHook(); - if (!Continue()) - break; + if (!Continue()) break; } } |