- if (!found_in_cache) {
- ++num_decoded;
- if (num_decoded % 1000 == 0) {
- fprintf(stderr, "Decoded %zu images, dropped %zu (%.2f%% dropped)\n",
- num_decoded, num_dropped, (100.0 * num_dropped) / (num_decoded + num_dropped));
+ shared_ptr<Frame> primary_frame, secondary_frame;
+ bool drop = false;
+ for (int subframe_idx = 0; subframe_idx < 2; ++subframe_idx) {
+ const FrameOnDisk &frame_spec = (subframe_idx == 0 ? decode.primary : decode.secondary);
+ if (frame_spec.pts == -1) {
+ // No secondary frame.
+ continue;
+ }
+
+ bool found_in_cache;
+ shared_ptr<Frame> frame = decode_jpeg_with_cache(frame_spec, cache_miss_behavior, &found_in_cache);
+
+ if (frame == nullptr) {
+ assert(cache_miss_behavior == RETURN_NULLPTR_IF_NOT_IN_CACHE);
+ drop = true;
+ break;
+ }
+
+ if (!found_in_cache) {
+ ++num_decoded;
+ if (num_decoded % 1000 == 0) {
+ fprintf(stderr, "Decoded %zu images, dropped %zu (%.2f%% dropped)\n",
+ num_decoded, num_dropped, (100.0 * num_dropped) / (num_decoded + num_dropped));
+ }
+ }
+ if (subframe_idx == 0) {
+ primary_frame = move(frame);
+ } else {
+ secondary_frame = move(frame);