OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Provides a minimal wrapping of the Blink image decoders. Used to perform | 5 // Provides a minimal wrapping of the Blink image decoders. Used to perform |
6 // a non-threaded, memory-to-memory image decode using micro second accuracy | 6 // a non-threaded, memory-to-memory image decode using micro second accuracy |
7 // clocks to measure image decode time. Optionally applies color correction | 7 // clocks to measure image decode time. Optionally applies color correction |
8 // during image decoding on supported platforms (default off). Usage: | 8 // during image decoding on supported platforms (default off). Usage: |
9 // | 9 // |
10 // % ninja -C out/Release image_decode_bench && | 10 // % ninja -C out/Release image_decode_bench && |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 for (int i = 0; i < frame_count; ++i) { | 219 for (int i = 0; i < frame_count; ++i) { |
220 if (!decoder->FrameBufferAtIndex(i)) | 220 if (!decoder->FrameBufferAtIndex(i)) |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 return !decoder->Failed(); | 224 return !decoder->Failed(); |
225 } | 225 } |
226 | 226 |
227 RefPtr<SharedBuffer> packet_data = SharedBuffer::Create(); | 227 RefPtr<SharedBuffer> packet_data = SharedBuffer::Create(); |
228 size_t position = 0; | 228 size_t position = 0; |
229 size_t next_frame_to_decode = 0; | |
229 while (true) { | 230 while (true) { |
230 const char* packet; | 231 const char* packet; |
231 size_t length = data->GetSomeData(packet, position); | 232 size_t length = data->GetSomeData(packet, position); |
232 | 233 |
233 length = std::min(length, packet_size); | 234 length = std::min(length, packet_size); |
234 packet_data->Append(packet, length); | 235 packet_data->Append(packet, length); |
235 position += length; | 236 position += length; |
236 | 237 |
237 bool all_data_received = position == data->size(); | 238 bool all_data_received = position == data->size(); |
238 decoder->SetData(packet_data.Get(), all_data_received); | 239 size_t frame_count = decoder->FrameCount(); |
239 | 240 for (; next_frame_to_decode < frame_count; ++next_frame_to_decode) { |
240 int frame_count = decoder->FrameCount(); | 241 decoder->SetData(packet_data.Get(), all_data_received); |
241 for (int i = 0; i < frame_count; ++i) { | 242 ImageFrame* frame = decoder->FrameBufferAtIndex(next_frame_to_decode); |
242 if (!decoder->FrameBufferAtIndex(i)) | 243 if (frame->GetStatus() != ImageFrame::kFrameComplete) |
scroggo_chromium
2017/05/15 12:48:28
I think this belongs at the end of the loop. Notic
cblume
2017/05/15 20:55:09
This is effectively done now that the SetData rese
| |
243 break; | 244 break; |
245 decoder->SetData(PassRefPtr<SegmentReader>(nullptr), false); | |
246 decoder->ClearCacheExceptFrame(next_frame_to_decode); | |
scroggo_chromium
2017/05/15 12:48:28
I'm ambivalent about adding ClearCacheExceptFrame
cblume
2017/05/15 17:39:11
I agree with you. This runs the risk of becoming o
scroggo_chromium
2017/05/15 18:09:22
Where is the integration test?
FWIW, I added the
| |
244 } | 247 } |
245 | 248 |
246 if (all_data_received || decoder->Failed()) | 249 if (all_data_received || decoder->Failed()) |
247 break; | 250 break; |
248 } | 251 } |
249 | 252 |
250 return !decoder->Failed(); | 253 return !decoder->Failed(); |
251 } | 254 } |
252 | 255 |
253 } // namespace | 256 } // namespace |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 double average_time = total_time / static_cast<double>(iterations); | 350 double average_time = total_time / static_cast<double>(iterations); |
348 printf("%f %f\n", total_time, average_time); | 351 printf("%f %f\n", total_time, average_time); |
349 return 0; | 352 return 0; |
350 } | 353 } |
351 | 354 |
352 } // namespace blink | 355 } // namespace blink |
353 | 356 |
354 int main(int argc, char* argv[]) { | 357 int main(int argc, char* argv[]) { |
355 return blink::Main(argc, argv); | 358 return blink::Main(argc, argv); |
356 } | 359 } |
OLD | NEW |