OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 FrameWriter* analysis_frame_writer, | 122 FrameWriter* analysis_frame_writer, |
123 PacketManipulator* packet_manipulator, | 123 PacketManipulator* packet_manipulator, |
124 const TestConfig& config, | 124 const TestConfig& config, |
125 Stats* stats, | 125 Stats* stats, |
126 FrameWriter* source_frame_writer, | 126 FrameWriter* source_frame_writer, |
127 IvfFileWriter* encoded_frame_writer, | 127 IvfFileWriter* encoded_frame_writer, |
128 FrameWriter* decoded_frame_writer) | 128 FrameWriter* decoded_frame_writer) |
129 : encoder_(encoder), | 129 : encoder_(encoder), |
130 decoder_(decoder), | 130 decoder_(decoder), |
131 bitrate_allocator_(CreateBitrateAllocator(config)), | 131 bitrate_allocator_(CreateBitrateAllocator(config)), |
132 encode_callback_(new VideoProcessorEncodeCompleteCallback(this)), | |
133 decode_callback_(new VideoProcessorDecodeCompleteCallback(this)), | |
134 packet_manipulator_(packet_manipulator), | 132 packet_manipulator_(packet_manipulator), |
135 config_(config), | 133 config_(config), |
136 analysis_frame_reader_(analysis_frame_reader), | 134 analysis_frame_reader_(analysis_frame_reader), |
137 analysis_frame_writer_(analysis_frame_writer), | 135 analysis_frame_writer_(analysis_frame_writer), |
| 136 num_frames_(analysis_frame_reader->NumberOfFrames()), |
138 source_frame_writer_(source_frame_writer), | 137 source_frame_writer_(source_frame_writer), |
139 encoded_frame_writer_(encoded_frame_writer), | 138 encoded_frame_writer_(encoded_frame_writer), |
140 decoded_frame_writer_(decoded_frame_writer), | 139 decoded_frame_writer_(decoded_frame_writer), |
141 initialized_(false), | 140 initialized_(false), |
| 141 frame_infos_(num_frames_), |
| 142 last_inputed_frame_num_(-1), |
142 last_encoded_frame_num_(-1), | 143 last_encoded_frame_num_(-1), |
143 last_decoded_frame_num_(-1), | 144 last_decoded_frame_num_(-1), |
144 first_key_frame_has_been_excluded_(false), | 145 first_key_frame_has_been_excluded_(false), |
145 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()), | 146 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()), |
146 stats_(stats), | 147 stats_(stats), |
147 num_dropped_frames_(0), | 148 num_dropped_frames_(0), |
148 num_spatial_resizes_(0) { | 149 num_spatial_resizes_(0) { |
149 RTC_DCHECK(encoder); | 150 RTC_DCHECK(encoder); |
150 RTC_DCHECK(decoder); | 151 RTC_DCHECK(decoder); |
151 RTC_DCHECK(packet_manipulator); | 152 RTC_DCHECK(packet_manipulator); |
152 RTC_DCHECK(analysis_frame_reader); | 153 RTC_DCHECK(analysis_frame_reader); |
153 RTC_DCHECK(analysis_frame_writer); | 154 RTC_DCHECK(analysis_frame_writer); |
154 RTC_DCHECK(stats); | 155 RTC_DCHECK(stats); |
155 frame_infos_.reserve(analysis_frame_reader->NumberOfFrames()); | 156 |
| 157 task_checker_.Detach(); |
156 } | 158 } |
157 | 159 |
| 160 VideoProcessorImpl::~VideoProcessorImpl() {} |
| 161 |
158 void VideoProcessorImpl::Init() { | 162 void VideoProcessorImpl::Init() { |
| 163 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
159 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; | 164 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; |
160 initialized_ = true; | 165 initialized_ = true; |
161 | 166 |
162 // Setup required callbacks for the encoder/decoder. | 167 // Setup required callbacks for the encoder/decoder. |
| 168 encode_callback_.reset(new VideoProcessorEncodeCompleteCallback(this)); |
163 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), | 169 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), |
164 WEBRTC_VIDEO_CODEC_OK) | 170 WEBRTC_VIDEO_CODEC_OK) |
165 << "Failed to register encode complete callback"; | 171 << "Failed to register encode complete callback"; |
| 172 decode_callback_.reset(new VideoProcessorDecodeCompleteCallback(this)); |
166 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(decode_callback_.get()), | 173 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(decode_callback_.get()), |
167 WEBRTC_VIDEO_CODEC_OK) | 174 WEBRTC_VIDEO_CODEC_OK) |
168 << "Failed to register decode complete callback"; | 175 << "Failed to register decode complete callback"; |
169 | 176 |
170 // Initialize the encoder and decoder. | 177 // Initialize the encoder and decoder. |
171 uint32_t num_cores = | 178 uint32_t num_cores = |
172 config_.use_single_core ? 1 : CpuInfo::DetectNumberOfCores(); | 179 config_.use_single_core ? 1 : CpuInfo::DetectNumberOfCores(); |
173 RTC_CHECK_EQ( | 180 RTC_CHECK_EQ( |
174 encoder_->InitEncode(config_.codec_settings, num_cores, | 181 encoder_->InitEncode(config_.codec_settings, num_cores, |
175 config_.networking_config.max_payload_size_in_bytes), | 182 config_.networking_config.max_payload_size_in_bytes), |
176 WEBRTC_VIDEO_CODEC_OK) | 183 WEBRTC_VIDEO_CODEC_OK) |
177 << "Failed to initialize VideoEncoder"; | 184 << "Failed to initialize VideoEncoder"; |
178 | 185 |
179 RTC_CHECK_EQ(decoder_->InitDecode(config_.codec_settings, num_cores), | 186 RTC_CHECK_EQ(decoder_->InitDecode(config_.codec_settings, num_cores), |
180 WEBRTC_VIDEO_CODEC_OK) | 187 WEBRTC_VIDEO_CODEC_OK) |
181 << "Failed to initialize VideoDecoder"; | 188 << "Failed to initialize VideoDecoder"; |
182 | 189 |
183 if (config_.verbose) { | 190 if (config_.verbose) { |
184 printf("Video Processor:\n"); | 191 printf("Video Processor:\n"); |
185 printf(" #CPU cores used : %d\n", num_cores); | 192 printf(" #CPU cores used : %d\n", num_cores); |
186 printf(" Total # of frames: %d\n", | 193 printf(" Total # of frames: %d\n", num_frames_); |
187 analysis_frame_reader_->NumberOfFrames()); | |
188 printf(" Codec settings:\n"); | 194 printf(" Codec settings:\n"); |
189 printf(" Encoder implementation name: %s\n", | 195 printf(" Encoder implementation name: %s\n", |
190 encoder_->ImplementationName()); | 196 encoder_->ImplementationName()); |
191 printf(" Decoder implementation name: %s\n", | 197 printf(" Decoder implementation name: %s\n", |
192 decoder_->ImplementationName()); | 198 decoder_->ImplementationName()); |
193 if (strcmp(encoder_->ImplementationName(), | 199 if (strcmp(encoder_->ImplementationName(), |
194 decoder_->ImplementationName()) == 0) { | 200 decoder_->ImplementationName()) == 0) { |
195 printf(" Codec implementation name: %s_%s\n", | 201 printf(" Codec implementation name: %s_%s\n", |
196 CodecTypeToPayloadName(config_.codec_settings->codecType) | 202 CodecTypeToPayloadName(config_.codec_settings->codecType) |
197 .value_or("Unknown"), | 203 .value_or("Unknown"), |
198 encoder_->ImplementationName()); | 204 encoder_->ImplementationName()); |
199 } | 205 } |
200 PrintCodecSettings(config_.codec_settings); | 206 PrintCodecSettings(config_.codec_settings); |
201 } | 207 } |
202 } | 208 } |
203 | 209 |
204 VideoProcessorImpl::~VideoProcessorImpl() { | 210 void VideoProcessorImpl::Release() { |
| 211 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
| 212 RTC_DCHECK(initialized_) << "VideoProcessor is not initialized."; |
| 213 initialized_ = false; |
| 214 |
205 encoder_->RegisterEncodeCompleteCallback(nullptr); | 215 encoder_->RegisterEncodeCompleteCallback(nullptr); |
206 decoder_->RegisterDecodeCompleteCallback(nullptr); | 216 decoder_->RegisterDecodeCompleteCallback(nullptr); |
| 217 |
| 218 RTC_DCHECK_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
| 219 RTC_DCHECK_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
207 } | 220 } |
208 | 221 |
209 void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) { | 222 void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) { |
| 223 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
210 int set_rates_result = encoder_->SetRateAllocation( | 224 int set_rates_result = encoder_->SetRateAllocation( |
211 bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate), | 225 bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate), |
212 frame_rate); | 226 frame_rate); |
213 RTC_DCHECK_GE(set_rates_result, 0) | 227 RTC_DCHECK_GE(set_rates_result, 0) |
214 << "Failed to update encoder with new rate " << bit_rate; | 228 << "Failed to update encoder with new rate " << bit_rate; |
215 num_dropped_frames_ = 0; | 229 num_dropped_frames_ = 0; |
216 num_spatial_resizes_ = 0; | 230 num_spatial_resizes_ = 0; |
217 } | 231 } |
218 | 232 |
219 size_t VideoProcessorImpl::EncodedFrameSize(int frame_number) { | 233 size_t VideoProcessorImpl::EncodedFrameSize(int frame_number) { |
| 234 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
220 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 235 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
221 return frame_infos_[frame_number].encoded_frame_size; | 236 return frame_infos_[frame_number].encoded_frame_size; |
222 } | 237 } |
223 | 238 |
224 FrameType VideoProcessorImpl::EncodedFrameType(int frame_number) { | 239 FrameType VideoProcessorImpl::EncodedFrameType(int frame_number) { |
| 240 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
225 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 241 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
226 return frame_infos_[frame_number].encoded_frame_type; | 242 return frame_infos_[frame_number].encoded_frame_type; |
227 } | 243 } |
228 | 244 |
229 int VideoProcessorImpl::GetQpFromEncoder(int frame_number) { | 245 int VideoProcessorImpl::GetQpFromEncoder(int frame_number) { |
| 246 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
230 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 247 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
231 return frame_infos_[frame_number].qp_encoder; | 248 return frame_infos_[frame_number].qp_encoder; |
232 } | 249 } |
233 | 250 |
234 int VideoProcessorImpl::GetQpFromBitstream(int frame_number) { | 251 int VideoProcessorImpl::GetQpFromBitstream(int frame_number) { |
| 252 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
235 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 253 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
236 return frame_infos_[frame_number].qp_bitstream; | 254 return frame_infos_[frame_number].qp_bitstream; |
237 } | 255 } |
238 | 256 |
239 int VideoProcessorImpl::NumberDroppedFrames() { | 257 int VideoProcessorImpl::NumberDroppedFrames() { |
| 258 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
240 return num_dropped_frames_; | 259 return num_dropped_frames_; |
241 } | 260 } |
242 | 261 |
243 int VideoProcessorImpl::NumberSpatialResizes() { | 262 int VideoProcessorImpl::NumberSpatialResizes() { |
| 263 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
244 return num_spatial_resizes_; | 264 return num_spatial_resizes_; |
245 } | 265 } |
246 | 266 |
247 bool VideoProcessorImpl::ProcessFrame(int frame_number) { | 267 bool VideoProcessorImpl::ProcessFrame(int frame_number) { |
| 268 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
248 RTC_DCHECK_GE(frame_number, 0); | 269 RTC_DCHECK_GE(frame_number, 0); |
249 RTC_DCHECK_LE(frame_number, frame_infos_.size()) | 270 RTC_DCHECK_EQ(frame_number, ++last_inputed_frame_num_) |
250 << "Must process frames without gaps."; | 271 << "Must process frames without gaps."; |
251 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; | 272 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; |
252 | 273 |
253 rtc::scoped_refptr<I420BufferInterface> buffer( | 274 rtc::scoped_refptr<I420BufferInterface> buffer( |
254 analysis_frame_reader_->ReadFrame()); | 275 analysis_frame_reader_->ReadFrame()); |
255 | 276 |
256 if (!buffer) { | 277 if (!buffer) { |
257 // Last frame has been reached. | 278 // Last frame has been reached. |
258 return false; | 279 return false; |
259 } | 280 } |
260 | 281 |
261 if (source_frame_writer_) { | 282 if (source_frame_writer_) { |
262 size_t length = | 283 size_t length = |
263 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height()); | 284 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height()); |
264 rtc::Buffer extracted_buffer(length); | 285 rtc::Buffer extracted_buffer(length); |
265 int extracted_length = | 286 int extracted_length = |
266 ExtractBuffer(buffer, length, extracted_buffer.data()); | 287 ExtractBuffer(buffer, length, extracted_buffer.data()); |
267 RTC_DCHECK_EQ(extracted_length, source_frame_writer_->FrameLength()); | 288 RTC_DCHECK_EQ(extracted_length, source_frame_writer_->FrameLength()); |
268 RTC_CHECK(source_frame_writer_->WriteFrame(extracted_buffer.data())); | 289 RTC_CHECK(source_frame_writer_->WriteFrame(extracted_buffer.data())); |
269 } | 290 } |
270 | 291 |
271 uint32_t timestamp = FrameNumberToTimestamp(frame_number); | 292 uint32_t timestamp = FrameNumberToTimestamp(frame_number); |
272 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); | 293 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); |
273 | 294 |
274 // Store frame information during the different stages of encode and decode. | |
275 frame_infos_.emplace_back(); | |
276 FrameInfo* frame_info = &frame_infos_.back(); | |
277 frame_info->timestamp = timestamp; | |
278 | |
279 // Decide if we are going to force a keyframe. | 295 // Decide if we are going to force a keyframe. |
280 std::vector<FrameType> frame_types(1, kVideoFrameDelta); | 296 std::vector<FrameType> frame_types(1, kVideoFrameDelta); |
281 if (config_.keyframe_interval > 0 && | 297 if (config_.keyframe_interval > 0 && |
282 frame_number % config_.keyframe_interval == 0) { | 298 frame_number % config_.keyframe_interval == 0) { |
283 frame_types[0] = kVideoFrameKey; | 299 frame_types[0] = kVideoFrameKey; |
284 } | 300 } |
285 | 301 |
| 302 // Store frame information during the different stages of encode and decode. |
| 303 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
| 304 FrameInfo* frame_info = &frame_infos_[frame_number]; |
| 305 |
286 // Create frame statistics object used for aggregation at end of test run. | 306 // Create frame statistics object used for aggregation at end of test run. |
287 FrameStatistic* frame_stat = &stats_->NewFrame(frame_number); | 307 FrameStatistic* frame_stat = &stats_->NewFrame(frame_number); |
288 | 308 |
289 // For the highest measurement accuracy of the encode time, the start/stop | 309 // For the highest measurement accuracy of the encode time, the start/stop |
290 // time recordings should wrap the Encode call as tightly as possible. | 310 // time recordings should wrap the Encode call as tightly as possible. |
291 frame_info->encode_start_ns = rtc::TimeNanos(); | 311 frame_info->encode_start_ns = rtc::TimeNanos(); |
292 frame_stat->encode_return_code = | 312 frame_stat->encode_return_code = |
293 encoder_->Encode(source_frame, nullptr, &frame_types); | 313 encoder_->Encode(source_frame, nullptr, &frame_types); |
294 | 314 |
295 if (frame_stat->encode_return_code != WEBRTC_VIDEO_CODEC_OK) { | 315 if (frame_stat->encode_return_code != WEBRTC_VIDEO_CODEC_OK) { |
296 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", | 316 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", |
297 frame_number, frame_stat->encode_return_code); | 317 frame_number, frame_stat->encode_return_code); |
298 } | 318 } |
299 | 319 |
300 return true; | 320 return true; |
301 } | 321 } |
302 | 322 |
303 void VideoProcessorImpl::FrameEncoded( | 323 void VideoProcessorImpl::FrameEncoded( |
304 webrtc::VideoCodecType codec, | 324 webrtc::VideoCodecType codec, |
305 const EncodedImage& encoded_image, | 325 const EncodedImage& encoded_image, |
306 const webrtc::RTPFragmentationHeader* fragmentation) { | 326 const webrtc::RTPFragmentationHeader* fragmentation) { |
| 327 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
| 328 |
307 // For the highest measurement accuracy of the encode time, the start/stop | 329 // For the highest measurement accuracy of the encode time, the start/stop |
308 // time recordings should wrap the Encode call as tightly as possible. | 330 // time recordings should wrap the Encode call as tightly as possible. |
| 331 // TODO(brandtr): Consider moving this measurement into the callback wrapper |
| 332 // class. |
309 int64_t encode_stop_ns = rtc::TimeNanos(); | 333 int64_t encode_stop_ns = rtc::TimeNanos(); |
310 | 334 |
311 if (encoded_frame_writer_) { | 335 if (encoded_frame_writer_) { |
312 RTC_CHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec)); | 336 RTC_CHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec)); |
313 } | 337 } |
314 | 338 |
315 // Timestamp is proportional to frame number, so this gives us number of | 339 // Timestamp is proportional to frame number, so this gives us number of |
316 // dropped frames. | 340 // dropped frames. |
317 int frame_number = TimestampToFrameNumber(encoded_image._timeStamp); | 341 int frame_number = TimestampToFrameNumber(encoded_image._timeStamp); |
318 bool last_frame_missing = false; | 342 bool last_frame_missing = false; |
(...skipping 13 matching lines...) Expand all Loading... |
332 last_decoded_frame_buffer_.data())); | 356 last_decoded_frame_buffer_.data())); |
333 if (decoded_frame_writer_) { | 357 if (decoded_frame_writer_) { |
334 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(), | 358 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(), |
335 decoded_frame_writer_->FrameLength()); | 359 decoded_frame_writer_->FrameLength()); |
336 RTC_CHECK(decoded_frame_writer_->WriteFrame( | 360 RTC_CHECK(decoded_frame_writer_->WriteFrame( |
337 last_decoded_frame_buffer_.data())); | 361 last_decoded_frame_buffer_.data())); |
338 } | 362 } |
339 } | 363 } |
340 } | 364 } |
341 | 365 |
| 366 RTC_DCHECK_LT(last_encoded_frame_num_, frame_infos_.size()); |
342 last_frame_missing = | 367 last_frame_missing = |
343 (frame_infos_[last_encoded_frame_num_].manipulated_length == 0); | 368 (frame_infos_[last_encoded_frame_num_].manipulated_length == 0); |
344 } | 369 } |
345 // Ensure strict monotonicity. | 370 // Ensure strict monotonicity. |
346 RTC_CHECK_GT(frame_number, last_encoded_frame_num_); | 371 RTC_CHECK_GT(frame_number, last_encoded_frame_num_); |
347 last_encoded_frame_num_ = frame_number; | 372 last_encoded_frame_num_ = frame_number; |
348 | 373 |
349 // Frame is not dropped, so update frame information and statistics. | 374 // Frame is not dropped, so update frame information and statistics. |
350 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 375 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
351 FrameInfo* frame_info = &frame_infos_[frame_number]; | 376 FrameInfo* frame_info = &frame_infos_[frame_number]; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (decoded_frame_writer_) { | 455 if (decoded_frame_writer_) { |
431 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(), | 456 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(), |
432 decoded_frame_writer_->FrameLength()); | 457 decoded_frame_writer_->FrameLength()); |
433 RTC_CHECK( | 458 RTC_CHECK( |
434 decoded_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data())); | 459 decoded_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data())); |
435 } | 460 } |
436 } | 461 } |
437 } | 462 } |
438 | 463 |
439 void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) { | 464 void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) { |
| 465 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
| 466 |
440 // For the highest measurement accuracy of the decode time, the start/stop | 467 // For the highest measurement accuracy of the decode time, the start/stop |
441 // time recordings should wrap the Decode call as tightly as possible. | 468 // time recordings should wrap the Decode call as tightly as possible. |
| 469 // TODO(brandtr): Consider moving this measurement into the callback wrapper |
| 470 // class. |
442 int64_t decode_stop_ns = rtc::TimeNanos(); | 471 int64_t decode_stop_ns = rtc::TimeNanos(); |
443 | 472 |
444 // Update frame information and statistics. | 473 // Update frame information and statistics. |
445 int frame_number = TimestampToFrameNumber(image.timestamp()); | 474 int frame_number = TimestampToFrameNumber(image.timestamp()); |
446 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 475 RTC_DCHECK_LT(frame_number, frame_infos_.size()); |
447 FrameInfo* frame_info = &frame_infos_[frame_number]; | 476 FrameInfo* frame_info = &frame_infos_[frame_number]; |
448 frame_info->decoded_width = image.width(); | 477 frame_info->decoded_width = image.width(); |
449 frame_info->decoded_height = image.height(); | 478 frame_info->decoded_height = image.height(); |
450 FrameStatistic* frame_stat = &stats_->stats_[frame_number]; | 479 FrameStatistic* frame_stat = &stats_->stats_[frame_number]; |
451 frame_stat->decode_time_in_us = | 480 frame_stat->decode_time_in_us = |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (decoded_frame_writer_) { | 528 if (decoded_frame_writer_) { |
500 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); | 529 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); |
501 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); | 530 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); |
502 } | 531 } |
503 | 532 |
504 last_decoded_frame_buffer_ = std::move(extracted_buffer); | 533 last_decoded_frame_buffer_ = std::move(extracted_buffer); |
505 } | 534 } |
506 | 535 |
507 } // namespace test | 536 } // namespace test |
508 } // namespace webrtc | 537 } // namespace webrtc |
OLD | NEW |