| 149 | } |
| 150 | } |
| 151 | bool BaseDecoderTest::DecodeFile (const char* fileName, Callback* cbk) { |
| 152 | std::ifstream file (fileName, std::ios::in | std::ios::binary); |
| 153 | if (!file.is_open()) |
| 154 | return false; |
| 155 | |
| 156 | BufferedData buf; |
| 157 | while (true) { |
| 158 | if (false == ReadFrame(&file, &buf)) |
| 159 | return false; |
| 160 | if (::testing::Test::HasFatalFailure()) { |
| 161 | return false; |
| 162 | } |
| 163 | if (buf.Length() == 0) { |
| 164 | break; |
| 165 | } |
| 166 | DecodeFrame (buf.data(), buf.Length(), cbk); |
| 167 | if (::testing::Test::HasFatalFailure()) { |
| 168 | return false; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | int32_t iEndOfStreamFlag = 1; |
| 173 | decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag); |
| 174 | |
| 175 | // Get pending last frame |
| 176 | DecodeFrame (NULL, 0, cbk); |
| 177 | // Flush out last frames in decoder buffer |
| 178 | int32_t num_of_frames_in_buffer = 0; |
| 179 | decoder_->GetOption (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, &num_of_frames_in_buffer); |
| 180 | for (int32_t i = 0; i < num_of_frames_in_buffer; ++i) { |
| 181 | FlushFrame (cbk); |
| 182 | } |
| 183 | return true; |
| 184 | } |
| 185 | |
| 186 | bool BaseDecoderTest::Open (const char* fileName) { |
| 187 | if (decodeStatus_ == OpenFile) { |