Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc

Issue 2045813003: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" 5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const { 72 const {
73 DCHECK(CalledOnValidThread()); 73 DCHECK(CalledOnValidThread());
74 base::AutoLock lock(lock_); 74 base::AutoLock lock(lock_);
75 return decoder_status_; 75 return decoder_status_;
76 } 76 }
77 77
78 void VideoCaptureGpuJpegDecoder::DecodeCapturedData( 78 void VideoCaptureGpuJpegDecoder::DecodeCapturedData(
79 const uint8_t* data, 79 const uint8_t* data,
80 size_t in_buffer_size, 80 size_t in_buffer_size,
81 const media::VideoCaptureFormat& frame_format, 81 const media::VideoCaptureFormat& frame_format,
82 const base::TimeTicks& timestamp, 82 base::TimeTicks reference_time,
83 base::TimeDelta timestamp,
83 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> out_buffer) { 84 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> out_buffer) {
84 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
85 DCHECK(decoder_); 86 DCHECK(decoder_);
86 87
87 TRACE_EVENT_ASYNC_BEGIN0("jpeg", "VideoCaptureGpuJpegDecoder decoding", 88 TRACE_EVENT_ASYNC_BEGIN0("jpeg", "VideoCaptureGpuJpegDecoder decoding",
88 next_bitstream_buffer_id_); 89 next_bitstream_buffer_id_);
89 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::DecodeCapturedData"); 90 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::DecodeCapturedData");
90 91
91 // TODO(kcwu): enqueue decode requests in case decoding is not fast enough 92 // TODO(kcwu): enqueue decode requests in case decoding is not fast enough
92 // (say, if decoding time is longer than 16ms for 60fps 4k image) 93 // (say, if decoding time is longer than 16ms for 60fps 4k image)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 scoped_refptr<media::VideoFrame> out_frame = 127 scoped_refptr<media::VideoFrame> out_frame =
127 media::VideoFrame::WrapExternalSharedMemory( 128 media::VideoFrame::WrapExternalSharedMemory(
128 media::PIXEL_FORMAT_I420, // format 129 media::PIXEL_FORMAT_I420, // format
129 dimensions, // coded_size 130 dimensions, // coded_size
130 gfx::Rect(dimensions), // visible_rect 131 gfx::Rect(dimensions), // visible_rect
131 dimensions, // natural_size 132 dimensions, // natural_size
132 static_cast<uint8_t*>(out_buffer->data()), // data 133 static_cast<uint8_t*>(out_buffer->data()), // data
133 out_buffer->mapped_size(), // data_size 134 out_buffer->mapped_size(), // data_size
134 out_handle, // handle 135 out_handle, // handle
135 0, // shared_memory_offset 136 0, // shared_memory_offset
136 base::TimeDelta()); // timestamp 137 timestamp); // timestamp
137 if (!out_frame) { 138 if (!out_frame) {
138 base::AutoLock lock(lock_); 139 base::AutoLock lock(lock_);
139 decoder_status_ = FAILED; 140 decoder_status_ = FAILED;
140 LOG(ERROR) << "DecodeCapturedData: WrapExternalSharedMemory failed"; 141 LOG(ERROR) << "DecodeCapturedData: WrapExternalSharedMemory failed";
141 return; 142 return;
142 } 143 }
143 out_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, 144 out_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE,
144 frame_format.frame_rate); 145 frame_format.frame_rate);
145 146
147 out_frame->metadata()->SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME,
148 reference_time);
149
146 { 150 {
147 base::AutoLock lock(lock_); 151 base::AutoLock lock(lock_);
148 decode_done_closure_ = base::Bind( 152 decode_done_closure_ =
149 decode_done_cb_, base::Passed(&out_buffer), out_frame, timestamp); 153 base::Bind(decode_done_cb_, base::Passed(&out_buffer), out_frame);
150 } 154 }
151 decoder_->Decode(in_buffer, out_frame); 155 decoder_->Decode(in_buffer, out_frame);
152 #else 156 #else
153 NOTREACHED(); 157 NOTREACHED();
154 #endif 158 #endif
155 } 159 }
156 160
157 void VideoCaptureGpuJpegDecoder::VideoFrameReady(int32_t bitstream_buffer_id) { 161 void VideoCaptureGpuJpegDecoder::VideoFrameReady(int32_t bitstream_buffer_id) {
158 DCHECK_CURRENTLY_ON(BrowserThread::IO); 162 DCHECK_CURRENTLY_ON(BrowserThread::IO);
159 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::VideoFrameReady"); 163 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::VideoFrameReady");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 lock_.AssertAcquired(); 252 lock_.AssertAcquired();
249 return !decode_done_closure_.is_null(); 253 return !decode_done_closure_.is_null();
250 } 254 }
251 255
252 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { 256 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() {
253 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", 257 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess",
254 decoder_status_ == INIT_PASSED); 258 decoder_status_ == INIT_PASSED);
255 } 259 }
256 260
257 } // namespace content 261 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698