OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "test/decode_test_driver.h" | 10 #include "test/decode_test_driver.h" |
11 #include "third_party/googletest/src/include/gtest/gtest.h" | 11 #include "third_party/googletest/src/include/gtest/gtest.h" |
12 #include "test/register_state_check.h" | 12 #include "test/register_state_check.h" |
13 #include "test/video_source.h" | 13 #include "test/video_source.h" |
14 | 14 |
15 namespace libvpx_test { | 15 namespace libvpx_test { |
16 #if CONFIG_VP8_DECODER | 16 #if CONFIG_VP8_DECODER |
17 void Decoder::DecodeFrame(const uint8_t *cxdata, int size) { | |
18 if (!decoder_.priv) { | |
19 const vpx_codec_err_t res_init = vpx_codec_dec_init(&decoder_, | |
20 &vpx_codec_vp8_dx_algo, | |
21 &cfg_, 0); | |
22 ASSERT_EQ(VPX_CODEC_OK, res_init) << DecodeError(); | |
23 } | |
24 | 17 |
| 18 vpx_codec_err_t Decoder::DecodeFrame(const uint8_t *cxdata, int size) { |
25 vpx_codec_err_t res_dec; | 19 vpx_codec_err_t res_dec; |
26 REGISTER_STATE_CHECK(res_dec = vpx_codec_decode(&decoder_, | 20 REGISTER_STATE_CHECK(res_dec = vpx_codec_decode(&decoder_, |
27 cxdata, size, NULL, 0)); | 21 cxdata, size, NULL, 0)); |
28 ASSERT_EQ(VPX_CODEC_OK, res_dec) << DecodeError(); | 22 return res_dec; |
29 } | 23 } |
30 | 24 |
31 void DecoderTest::RunLoop(CompressedVideoSource *video) { | 25 void DecoderTest::RunLoop(CompressedVideoSource *video) { |
32 vpx_codec_dec_cfg_t dec_cfg = {0}; | 26 vpx_codec_dec_cfg_t dec_cfg = {0}; |
33 Decoder decoder(dec_cfg, 0); | 27 Decoder decoder(dec_cfg, 0); |
34 | 28 |
35 // Decode frames. | 29 // Decode frames. |
36 for (video->Begin(); video->cxdata(); video->Next()) { | 30 for (video->Begin(); video->cxdata(); video->Next()) { |
37 decoder.DecodeFrame(video->cxdata(), video->frame_size()); | 31 vpx_codec_err_t res_dec = decoder.DecodeFrame(video->cxdata(), |
| 32 video->frame_size()); |
| 33 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder.DecodeError(); |
38 | 34 |
39 DxDataIterator dec_iter = decoder.GetDxData(); | 35 DxDataIterator dec_iter = decoder.GetDxData(); |
40 const vpx_image_t *img = NULL; | 36 const vpx_image_t *img = NULL; |
41 | 37 |
42 // Get decompressed data | 38 // Get decompressed data |
43 while ((img = dec_iter.Next())) | 39 while ((img = dec_iter.Next())) |
44 DecompressedFrameHook(*img, video->frame_number()); | 40 DecompressedFrameHook(*img, video->frame_number()); |
45 } | 41 } |
46 } | 42 } |
47 #endif | 43 #endif |
48 } // namespace libvpx_test | 44 } // namespace libvpx_test |
OLD | NEW |