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/codec_factory.h" | 10 #include "test/codec_factory.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 * data passed to it isn't a valid Vp9 chunk. */ | 60 * data passed to it isn't a valid Vp9 chunk. */ |
61 ASSERT_EQ(VPX_CODEC_OK, res_peek) << "Peek return failed: " | 61 ASSERT_EQ(VPX_CODEC_OK, res_peek) << "Peek return failed: " |
62 << vpx_codec_err_to_string(res_peek); | 62 << vpx_codec_err_to_string(res_peek); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void DecoderTest::RunLoop(CompressedVideoSource *video, | 66 void DecoderTest::RunLoop(CompressedVideoSource *video, |
67 const vpx_codec_dec_cfg_t &dec_cfg) { | 67 const vpx_codec_dec_cfg_t &dec_cfg) { |
68 Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0); | 68 Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0); |
69 ASSERT_TRUE(decoder != NULL); | 69 ASSERT_TRUE(decoder != NULL); |
| 70 bool end_of_file = false; |
70 | 71 |
71 // Decode frames. | 72 // Decode frames. |
72 for (video->Begin(); !::testing::Test::HasFailure() && video->cxdata(); | 73 for (video->Begin(); !::testing::Test::HasFailure() && !end_of_file; |
73 video->Next()) { | 74 video->Next()) { |
74 PreDecodeFrameHook(*video, decoder); | 75 PreDecodeFrameHook(*video, decoder); |
75 | 76 |
76 vpx_codec_stream_info_t stream_info; | 77 vpx_codec_stream_info_t stream_info; |
77 stream_info.sz = sizeof(stream_info); | 78 stream_info.sz = sizeof(stream_info); |
78 const vpx_codec_err_t res_peek = decoder->PeekStream(video->cxdata(), | |
79 video->frame_size(), | |
80 &stream_info); | |
81 HandlePeekResult(decoder, video, res_peek); | |
82 ASSERT_FALSE(::testing::Test::HasFailure()); | |
83 | 79 |
84 vpx_codec_err_t res_dec = decoder->DecodeFrame(video->cxdata(), | 80 if (video->cxdata() != NULL) { |
85 video->frame_size()); | 81 const vpx_codec_err_t res_peek = decoder->PeekStream(video->cxdata(), |
86 if (!HandleDecodeResult(res_dec, *video, decoder)) | 82 video->frame_size(), |
87 break; | 83 &stream_info); |
| 84 HandlePeekResult(decoder, video, res_peek); |
| 85 ASSERT_FALSE(::testing::Test::HasFailure()); |
| 86 |
| 87 vpx_codec_err_t res_dec = decoder->DecodeFrame(video->cxdata(), |
| 88 video->frame_size()); |
| 89 if (!HandleDecodeResult(res_dec, *video, decoder)) |
| 90 break; |
| 91 } else { |
| 92 // Signal end of the file to the decoder. |
| 93 const vpx_codec_err_t res_dec = decoder->DecodeFrame(NULL, 0); |
| 94 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError(); |
| 95 end_of_file = true; |
| 96 } |
88 | 97 |
89 DxDataIterator dec_iter = decoder->GetDxData(); | 98 DxDataIterator dec_iter = decoder->GetDxData(); |
90 const vpx_image_t *img = NULL; | 99 const vpx_image_t *img = NULL; |
91 | 100 |
92 // Get decompressed data | 101 // Get decompressed data |
93 while ((img = dec_iter.Next())) | 102 while ((img = dec_iter.Next())) |
94 DecompressedFrameHook(*img, video->frame_number()); | 103 DecompressedFrameHook(*img, video->frame_number()); |
95 } | 104 } |
96 delete decoder; | 105 delete decoder; |
97 } | 106 } |
98 | 107 |
99 void DecoderTest::RunLoop(CompressedVideoSource *video) { | 108 void DecoderTest::RunLoop(CompressedVideoSource *video) { |
100 vpx_codec_dec_cfg_t dec_cfg = {0}; | 109 vpx_codec_dec_cfg_t dec_cfg = {0}; |
101 RunLoop(video, dec_cfg); | 110 RunLoop(video, dec_cfg); |
102 } | 111 } |
103 | 112 |
104 } // namespace libvpx_test | 113 } // namespace libvpx_test |
OLD | NEW |