- vector<uint8_t> jpeg = encode_jpeg(
- (const uint8_t *)qf.resources.pbo_contents,
- (const uint8_t *)qf.resources.pbo_contents + 1280 * 720,
- (const uint8_t *)qf.resources.pbo_contents + 1280 * 720 + 640 * 720,
- 1280, 720);
+ const uint8_t *y = (const uint8_t *)qf.resources.pbo_contents;
+ const uint8_t *cb = (const uint8_t *)qf.resources.pbo_contents + 1280 * 720;
+ const uint8_t *cr = (const uint8_t *)qf.resources.pbo_contents + 1280 * 720 + 640 * 720;
+
+ // Send a copy of the frame on to display.
+ shared_ptr<Frame> frame(new Frame);
+ frame->y.reset(new uint8_t[1280 * 720]);
+ frame->cb.reset(new uint8_t[640 * 720]);
+ frame->cr.reset(new uint8_t[640 * 720]);
+ for (unsigned yy = 0; yy < 720; ++yy) {
+ memcpy(frame->y.get() + 1280 * yy, y + 1280 * (719 - yy), 1280);
+ memcpy(frame->cb.get() + 640 * yy, cb + 640 * (719 - yy), 640);
+ memcpy(frame->cr.get() + 640 * yy, cr + 640 * (719 - yy), 640);
+ }
+ frame->width = 1280;
+ frame->height = 720;
+ frame->chroma_subsampling_x = 2;
+ frame->chroma_subsampling_y = 1;
+ frame->pitch_y = 1280;
+ frame->pitch_chroma = 640;
+ JPEGFrameView::insert_interpolated_frame(qf.stream_idx, qf.output_pts, std::move(frame));
+
+ // Now JPEG encode it, and send it on to the stream.
+ vector<uint8_t> jpeg = encode_jpeg(y, cb, cr, 1280, 720);