+ unsigned chroma_width = width / 2;
+
+ const uint8_t *y = (const uint8_t *)contents;
+ const uint8_t *cb = (const uint8_t *)contents + width * height;
+ const uint8_t *cr = (const uint8_t *)contents + width * height + chroma_width * height;
+ return encode_jpeg(y, cb, cr, width, height, move(exif_data));
+}
+
+VideoStream::VideoStream(AVFormatContext *file_avctx)
+ : avctx(file_avctx), output_fast_forward(file_avctx != nullptr)
+{
+ call_once(video_metrics_inited, [] {
+ vector<double> quantiles{ 0.01, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99 };
+ metric_jpeg_encode_time_seconds.init(quantiles, 60.0);
+ global_metrics.add("jpeg_encode_time_seconds", &metric_jpeg_encode_time_seconds);
+ metric_fade_fence_wait_time_seconds.init(quantiles, 60.0);
+ global_metrics.add("fade_fence_wait_time_seconds", &metric_fade_fence_wait_time_seconds);
+ metric_interpolation_fence_wait_time_seconds.init(quantiles, 60.0);
+ global_metrics.add("interpolation_fence_wait_time_seconds", &metric_interpolation_fence_wait_time_seconds);
+ metric_fade_latency_seconds.init(quantiles, 60.0);
+ global_metrics.add("fade_latency_seconds", &metric_fade_latency_seconds);
+ metric_interpolation_latency_seconds.init(quantiles, 60.0);
+ global_metrics.add("interpolation_latency_seconds", &metric_interpolation_latency_seconds);
+ });
+