| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 CodecTypeToPayloadName(codec_settings.codecType).value_or("Unknown")); | 52 CodecTypeToPayloadName(codec_settings.codecType).value_or("Unknown")); |
| 53 printf(" Start bitrate : %d kbps\n", codec_settings.startBitrate); | 53 printf(" Start bitrate : %d kbps\n", codec_settings.startBitrate); |
| 54 printf(" Max bitrate : %d kbps\n", codec_settings.maxBitrate); | 54 printf(" Max bitrate : %d kbps\n", codec_settings.maxBitrate); |
| 55 printf(" Min bitrate : %d kbps\n", codec_settings.minBitrate); | 55 printf(" Min bitrate : %d kbps\n", codec_settings.minBitrate); |
| 56 printf(" Width : %d\n", codec_settings.width); | 56 printf(" Width : %d\n", codec_settings.width); |
| 57 printf(" Height : %d\n", codec_settings.height); | 57 printf(" Height : %d\n", codec_settings.height); |
| 58 printf(" Max frame rate : %d\n", codec_settings.maxFramerate); | 58 printf(" Max frame rate : %d\n", codec_settings.maxFramerate); |
| 59 printf(" QPmax : %d\n", codec_settings.qpMax); | 59 printf(" QPmax : %d\n", codec_settings.qpMax); |
| 60 if (codec_settings.codecType == kVideoCodecVP8) { | 60 if (codec_settings.codecType == kVideoCodecVP8) { |
| 61 printf(" Complexity : %d\n", codec_settings.VP8().complexity); | 61 printf(" Complexity : %d\n", codec_settings.VP8().complexity); |
| 62 printf(" Resilience : %d\n", codec_settings.VP8().resilience); |
| 63 printf(" # temporal layers : %d\n", |
| 64 codec_settings.VP8().numberOfTemporalLayers); |
| 62 printf(" Denoising : %d\n", codec_settings.VP8().denoisingOn); | 65 printf(" Denoising : %d\n", codec_settings.VP8().denoisingOn); |
| 63 printf(" Error concealment : %d\n", | 66 printf(" Error concealment : %d\n", |
| 64 codec_settings.VP8().errorConcealmentOn); | 67 codec_settings.VP8().errorConcealmentOn); |
| 68 printf(" Automatic resize : %d\n", |
| 69 codec_settings.VP8().automaticResizeOn); |
| 65 printf(" Frame dropping : %d\n", codec_settings.VP8().frameDroppingOn); | 70 printf(" Frame dropping : %d\n", codec_settings.VP8().frameDroppingOn); |
| 66 printf(" Resilience : %d\n", codec_settings.VP8().resilience); | |
| 67 printf(" Key frame interval: %d\n", codec_settings.VP8().keyFrameInterval); | 71 printf(" Key frame interval: %d\n", codec_settings.VP8().keyFrameInterval); |
| 68 } else if (codec_settings.codecType == kVideoCodecVP9) { | 72 } else if (codec_settings.codecType == kVideoCodecVP9) { |
| 69 printf(" Complexity : %d\n", codec_settings.VP9().complexity); | 73 printf(" Complexity : %d\n", codec_settings.VP9().complexity); |
| 74 printf(" Resilience : %d\n", codec_settings.VP9().resilienceOn); |
| 75 printf(" # temporal layers : %d\n", |
| 76 codec_settings.VP9().numberOfTemporalLayers); |
| 70 printf(" Denoising : %d\n", codec_settings.VP9().denoisingOn); | 77 printf(" Denoising : %d\n", codec_settings.VP9().denoisingOn); |
| 71 printf(" Frame dropping : %d\n", codec_settings.VP9().frameDroppingOn); | 78 printf(" Frame dropping : %d\n", codec_settings.VP9().frameDroppingOn); |
| 72 printf(" Resilience : %d\n", codec_settings.VP9().resilienceOn); | |
| 73 printf(" Key frame interval: %d\n", codec_settings.VP9().keyFrameInterval); | 79 printf(" Key frame interval: %d\n", codec_settings.VP9().keyFrameInterval); |
| 74 printf(" Adaptive QP mode : %d\n", codec_settings.VP9().adaptiveQpMode); | 80 printf(" Adaptive QP mode : %d\n", codec_settings.VP9().adaptiveQpMode); |
| 81 printf(" Automatic resize : %d\n", |
| 82 codec_settings.VP9().automaticResizeOn); |
| 83 printf(" # spatial layers : %d\n", |
| 84 codec_settings.VP9().numberOfSpatialLayers); |
| 85 printf(" Flexible mode : %d\n", codec_settings.VP9().flexibleMode); |
| 75 } else if (codec_settings.codecType == kVideoCodecH264) { | 86 } else if (codec_settings.codecType == kVideoCodecH264) { |
| 76 printf(" Frame dropping : %d\n", codec_settings.H264().frameDroppingOn); | 87 printf(" Frame dropping : %d\n", codec_settings.H264().frameDroppingOn); |
| 77 printf(" Key frame interval: %d\n", | 88 printf(" Key frame interval: %d\n", |
| 78 codec_settings.H264().keyFrameInterval); | 89 codec_settings.H264().keyFrameInterval); |
| 79 printf(" Profile : %d\n", codec_settings.H264().profile); | 90 printf(" Profile : %d\n", codec_settings.H264().profile); |
| 80 } | 91 } |
| 81 } | 92 } |
| 82 | 93 |
| 83 int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) { | 94 int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) { |
| 84 int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec; | 95 int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 107 FrameWriter* analysis_frame_writer, | 118 FrameWriter* analysis_frame_writer, |
| 108 PacketManipulator* packet_manipulator, | 119 PacketManipulator* packet_manipulator, |
| 109 const TestConfig& config, | 120 const TestConfig& config, |
| 110 Stats* stats, | 121 Stats* stats, |
| 111 IvfFileWriter* encoded_frame_writer, | 122 IvfFileWriter* encoded_frame_writer, |
| 112 FrameWriter* decoded_frame_writer) | 123 FrameWriter* decoded_frame_writer) |
| 113 : config_(config), | 124 : config_(config), |
| 114 encoder_(encoder), | 125 encoder_(encoder), |
| 115 decoder_(decoder), | 126 decoder_(decoder), |
| 116 bitrate_allocator_(CreateBitrateAllocator(&config_)), | 127 bitrate_allocator_(CreateBitrateAllocator(&config_)), |
| 117 encode_callback_(new VideoProcessorEncodeCompleteCallback(this)), | 128 encode_callback_(this), |
| 118 decode_callback_(new VideoProcessorDecodeCompleteCallback(this)), | 129 decode_callback_(this), |
| 119 packet_manipulator_(packet_manipulator), | 130 packet_manipulator_(packet_manipulator), |
| 120 analysis_frame_reader_(analysis_frame_reader), | 131 analysis_frame_reader_(analysis_frame_reader), |
| 121 analysis_frame_writer_(analysis_frame_writer), | 132 analysis_frame_writer_(analysis_frame_writer), |
| 122 encoded_frame_writer_(encoded_frame_writer), | 133 encoded_frame_writer_(encoded_frame_writer), |
| 123 decoded_frame_writer_(decoded_frame_writer), | 134 decoded_frame_writer_(decoded_frame_writer), |
| 124 initialized_(false), | 135 initialized_(false), |
| 125 last_encoded_frame_num_(-1), | 136 last_encoded_frame_num_(-1), |
| 126 last_decoded_frame_num_(-1), | 137 last_decoded_frame_num_(-1), |
| 127 first_key_frame_has_been_excluded_(false), | 138 first_key_frame_has_been_excluded_(false), |
| 128 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()), | 139 last_decoded_frame_buffer_(analysis_frame_reader->FrameLength()), |
| 129 stats_(stats), | 140 stats_(stats), |
| 130 num_dropped_frames_(0), | 141 num_dropped_frames_(0), |
| 131 num_spatial_resizes_(0) { | 142 num_spatial_resizes_(0) { |
| 132 RTC_DCHECK(encoder); | 143 RTC_DCHECK(encoder); |
| 133 RTC_DCHECK(decoder); | 144 RTC_DCHECK(decoder); |
| 134 RTC_DCHECK(packet_manipulator); | 145 RTC_DCHECK(packet_manipulator); |
| 135 RTC_DCHECK(analysis_frame_reader); | 146 RTC_DCHECK(analysis_frame_reader); |
| 136 RTC_DCHECK(analysis_frame_writer); | 147 RTC_DCHECK(analysis_frame_writer); |
| 137 RTC_DCHECK(stats); | 148 RTC_DCHECK(stats); |
| 138 frame_infos_.reserve(analysis_frame_reader->NumberOfFrames()); | 149 frame_infos_.reserve(analysis_frame_reader->NumberOfFrames()); |
| 139 } | 150 } |
| 140 | 151 |
| 141 VideoProcessor::~VideoProcessor() = default; | 152 VideoProcessor::~VideoProcessor() = default; |
| 142 | 153 |
| 143 void VideoProcessor::Init() { | 154 void VideoProcessor::Init() { |
| 144 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; | 155 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; |
| 145 initialized_ = true; | 156 initialized_ = true; |
| 146 | 157 |
| 147 // Setup required callbacks for the encoder and decoder. | 158 // Setup required callbacks for the encoder and decoder. |
| 148 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), | 159 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(&encode_callback_), |
| 149 WEBRTC_VIDEO_CODEC_OK) | 160 WEBRTC_VIDEO_CODEC_OK) |
| 150 << "Failed to register encode complete callback"; | 161 << "Failed to register encode complete callback"; |
| 151 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(decode_callback_.get()), | 162 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(&decode_callback_), |
| 152 WEBRTC_VIDEO_CODEC_OK) | 163 WEBRTC_VIDEO_CODEC_OK) |
| 153 << "Failed to register decode complete callback"; | 164 << "Failed to register decode complete callback"; |
| 154 | 165 |
| 155 // Initialize the encoder and decoder. | 166 // Initialize the encoder and decoder. |
| 156 uint32_t num_cores = | 167 uint32_t num_cores = |
| 157 config_.use_single_core ? 1 : CpuInfo::DetectNumberOfCores(); | 168 config_.use_single_core ? 1 : CpuInfo::DetectNumberOfCores(); |
| 158 RTC_CHECK_EQ( | 169 RTC_CHECK_EQ( |
| 159 encoder_->InitEncode(&config_.codec_settings, num_cores, | 170 encoder_->InitEncode(&config_.codec_settings, num_cores, |
| 160 config_.networking_config.max_payload_size_in_bytes), | 171 config_.networking_config.max_payload_size_in_bytes), |
| 161 WEBRTC_VIDEO_CODEC_OK) | 172 WEBRTC_VIDEO_CODEC_OK) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 180 CodecTypeToPayloadName(config_.codec_settings.codecType) | 191 CodecTypeToPayloadName(config_.codec_settings.codecType) |
| 181 .value_or("Unknown"), | 192 .value_or("Unknown"), |
| 182 encoder_->ImplementationName()); | 193 encoder_->ImplementationName()); |
| 183 } | 194 } |
| 184 PrintCodecSettings(config_.codec_settings); | 195 PrintCodecSettings(config_.codec_settings); |
| 185 printf("\n"); | 196 printf("\n"); |
| 186 } | 197 } |
| 187 } | 198 } |
| 188 | 199 |
| 189 void VideoProcessor::Release() { | 200 void VideoProcessor::Release() { |
| 201 RTC_CHECK_EQ(encoder_->Release(), WEBRTC_VIDEO_CODEC_OK); |
| 202 RTC_CHECK_EQ(decoder_->Release(), WEBRTC_VIDEO_CODEC_OK); |
| 203 |
| 190 encoder_->RegisterEncodeCompleteCallback(nullptr); | 204 encoder_->RegisterEncodeCompleteCallback(nullptr); |
| 191 decoder_->RegisterDecodeCompleteCallback(nullptr); | 205 decoder_->RegisterDecodeCompleteCallback(nullptr); |
| 192 | 206 |
| 193 RTC_CHECK_EQ(encoder_->Release(), WEBRTC_VIDEO_CODEC_OK); | |
| 194 RTC_CHECK_EQ(decoder_->Release(), WEBRTC_VIDEO_CODEC_OK); | |
| 195 | |
| 196 initialized_ = false; | 207 initialized_ = false; |
| 197 } | 208 } |
| 198 | 209 |
| 199 bool VideoProcessor::ProcessFrame(int frame_number) { | 210 void VideoProcessor::ProcessFrame(int frame_number) { |
| 200 RTC_DCHECK_GE(frame_number, 0); | 211 RTC_DCHECK_EQ(frame_number, frame_infos_.size()) |
| 201 RTC_DCHECK_LE(frame_number, frame_infos_.size()) | 212 << "Must process frames in sequence."; |
| 202 << "Must process frames without gaps."; | |
| 203 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; | 213 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; |
| 204 | 214 |
| 215 // Get frame from file. |
| 205 rtc::scoped_refptr<I420BufferInterface> buffer( | 216 rtc::scoped_refptr<I420BufferInterface> buffer( |
| 206 analysis_frame_reader_->ReadFrame()); | 217 analysis_frame_reader_->ReadFrame()); |
| 207 | 218 RTC_CHECK(buffer) << "Tried to read too many frames from the file."; |
| 208 if (!buffer) { | 219 const int64_t kNoRenderTime = 0; |
| 209 // Last frame has been reached. | 220 VideoFrame source_frame(buffer, FrameNumberToTimestamp(frame_number), |
| 210 return false; | 221 kNoRenderTime, webrtc::kVideoRotation_0); |
| 211 } | |
| 212 | |
| 213 uint32_t timestamp = FrameNumberToTimestamp(frame_number); | |
| 214 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); | |
| 215 | |
| 216 // Store frame information during the different stages of encode and decode. | |
| 217 frame_infos_.emplace_back(); | |
| 218 FrameInfo* frame_info = &frame_infos_.back(); | |
| 219 frame_info->timestamp = timestamp; | |
| 220 | 222 |
| 221 // Decide if we are going to force a keyframe. | 223 // Decide if we are going to force a keyframe. |
| 222 std::vector<FrameType> frame_types(1, kVideoFrameDelta); | 224 std::vector<FrameType> frame_types(1, kVideoFrameDelta); |
| 223 if (config_.keyframe_interval > 0 && | 225 if (config_.keyframe_interval > 0 && |
| 224 frame_number % config_.keyframe_interval == 0) { | 226 frame_number % config_.keyframe_interval == 0) { |
| 225 frame_types[0] = kVideoFrameKey; | 227 frame_types[0] = kVideoFrameKey; |
| 226 } | 228 } |
| 227 | 229 |
| 230 // Store frame information during the different stages of encode and decode. |
| 231 frame_infos_.emplace_back(); |
| 232 FrameInfo* frame_info = &frame_infos_.back(); |
| 233 |
| 228 // Create frame statistics object used for aggregation at end of test run. | 234 // Create frame statistics object used for aggregation at end of test run. |
| 229 FrameStatistic* frame_stat = &stats_->NewFrame(frame_number); | 235 FrameStatistic* frame_stat = &stats_->NewFrame(frame_number); |
| 230 | 236 |
| 231 // For the highest measurement accuracy of the encode time, the start/stop | 237 // For the highest measurement accuracy of the encode time, the start/stop |
| 232 // time recordings should wrap the Encode call as tightly as possible. | 238 // time recordings should wrap the Encode call as tightly as possible. |
| 233 frame_info->encode_start_ns = rtc::TimeNanos(); | 239 frame_info->encode_start_ns = rtc::TimeNanos(); |
| 234 frame_stat->encode_return_code = | 240 frame_stat->encode_return_code = |
| 235 encoder_->Encode(source_frame, nullptr, &frame_types); | 241 encoder_->Encode(source_frame, nullptr, &frame_types); |
| 236 | 242 |
| 237 if (frame_stat->encode_return_code != WEBRTC_VIDEO_CODEC_OK) { | 243 if (frame_stat->encode_return_code != WEBRTC_VIDEO_CODEC_OK) { |
| 238 LOG(LS_WARNING) << "Failed to encode frame " << frame_number | 244 LOG(LS_WARNING) << "Failed to encode frame " << frame_number |
| 239 << ", return code: " << frame_stat->encode_return_code | 245 << ", return code: " << frame_stat->encode_return_code |
| 240 << "."; | 246 << "."; |
| 241 } | 247 } |
| 242 | |
| 243 return true; | |
| 244 } | 248 } |
| 245 | 249 |
| 246 void VideoProcessor::SetRates(int bit_rate, int frame_rate) { | 250 void VideoProcessor::SetRates(int bitrate_kbps, int framerate_fps) { |
| 247 config_.codec_settings.maxFramerate = frame_rate; | 251 config_.codec_settings.maxFramerate = framerate_fps; |
| 248 int set_rates_result = encoder_->SetRateAllocation( | 252 int set_rates_result = encoder_->SetRateAllocation( |
| 249 bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate), | 253 bitrate_allocator_->GetAllocation(bitrate_kbps * 1000, framerate_fps), |
| 250 frame_rate); | 254 framerate_fps); |
| 251 RTC_DCHECK_GE(set_rates_result, 0) | 255 RTC_DCHECK_GE(set_rates_result, 0) |
| 252 << "Failed to update encoder with new rate " << bit_rate; | 256 << "Failed to update encoder with new rate " << bitrate_kbps << "."; |
| 253 num_dropped_frames_ = 0; | 257 num_dropped_frames_ = 0; |
| 254 num_spatial_resizes_ = 0; | 258 num_spatial_resizes_ = 0; |
| 255 } | 259 } |
| 256 | 260 |
| 257 size_t VideoProcessor::EncodedFrameSize(int frame_number) { | 261 int VideoProcessor::GetQpFromEncoder(int frame_number) const { |
| 258 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 262 RTC_CHECK_LT(frame_number, frame_infos_.size()); |
| 259 return frame_infos_[frame_number].encoded_frame_size; | |
| 260 } | |
| 261 | |
| 262 FrameType VideoProcessor::EncodedFrameType(int frame_number) { | |
| 263 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | |
| 264 return frame_infos_[frame_number].encoded_frame_type; | |
| 265 } | |
| 266 | |
| 267 int VideoProcessor::GetQpFromEncoder(int frame_number) { | |
| 268 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | |
| 269 return frame_infos_[frame_number].qp_encoder; | 263 return frame_infos_[frame_number].qp_encoder; |
| 270 } | 264 } |
| 271 | 265 |
| 272 int VideoProcessor::GetQpFromBitstream(int frame_number) { | 266 int VideoProcessor::GetQpFromBitstream(int frame_number) const { |
| 273 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 267 RTC_CHECK_LT(frame_number, frame_infos_.size()); |
| 274 return frame_infos_[frame_number].qp_bitstream; | 268 return frame_infos_[frame_number].qp_bitstream; |
| 275 } | 269 } |
| 276 | 270 |
| 277 int VideoProcessor::NumberDroppedFrames() { | 271 int VideoProcessor::NumberDroppedFrames() { |
| 278 return num_dropped_frames_; | 272 return num_dropped_frames_; |
| 279 } | 273 } |
| 280 | 274 |
| 281 int VideoProcessor::NumberSpatialResizes() { | 275 int VideoProcessor::NumberSpatialResizes() { |
| 282 return num_spatial_resizes_; | 276 return num_spatial_resizes_; |
| 283 } | 277 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 316 } |
| 323 | 317 |
| 324 last_frame_missing = | 318 last_frame_missing = |
| 325 (frame_infos_[last_encoded_frame_num_].manipulated_length == 0); | 319 (frame_infos_[last_encoded_frame_num_].manipulated_length == 0); |
| 326 } | 320 } |
| 327 // Ensure strict monotonicity. | 321 // Ensure strict monotonicity. |
| 328 RTC_CHECK_GT(frame_number, last_encoded_frame_num_); | 322 RTC_CHECK_GT(frame_number, last_encoded_frame_num_); |
| 329 last_encoded_frame_num_ = frame_number; | 323 last_encoded_frame_num_ = frame_number; |
| 330 | 324 |
| 331 // Frame is not dropped, so update frame information and statistics. | 325 // Frame is not dropped, so update frame information and statistics. |
| 332 RTC_DCHECK_LT(frame_number, frame_infos_.size()); | 326 RTC_CHECK_LT(frame_number, frame_infos_.size()); |
| 333 FrameInfo* frame_info = &frame_infos_[frame_number]; | 327 FrameInfo* frame_info = &frame_infos_[frame_number]; |
| 334 frame_info->encoded_frame_size = encoded_image._length; | |
| 335 frame_info->encoded_frame_type = encoded_image._frameType; | |
| 336 frame_info->qp_encoder = encoded_image.qp_; | 328 frame_info->qp_encoder = encoded_image.qp_; |
| 337 if (codec == kVideoCodecVP8) { | 329 if (codec == kVideoCodecVP8) { |
| 338 vp8::GetQp(encoded_image._buffer, encoded_image._length, | 330 vp8::GetQp(encoded_image._buffer, encoded_image._length, |
| 339 &frame_info->qp_bitstream); | 331 &frame_info->qp_bitstream); |
| 340 } else if (codec == kVideoCodecVP9) { | 332 } else if (codec == kVideoCodecVP9) { |
| 341 vp9::GetQp(encoded_image._buffer, encoded_image._length, | 333 vp9::GetQp(encoded_image._buffer, encoded_image._length, |
| 342 &frame_info->qp_bitstream); | 334 &frame_info->qp_bitstream); |
| 343 } | 335 } |
| 344 FrameStatistic* frame_stat = &stats_->stats_[frame_number]; | 336 FrameStatistic* frame_stat = &stats_->stats_[frame_number]; |
| 345 frame_stat->encode_time_in_us = | 337 frame_stat->encode_time_in_us = |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); | 471 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); |
| 480 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); | 472 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); |
| 481 if (decoded_frame_writer_) { | 473 if (decoded_frame_writer_) { |
| 482 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); | 474 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); |
| 483 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); | 475 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); |
| 484 } | 476 } |
| 485 | 477 |
| 486 last_decoded_frame_buffer_ = std::move(extracted_buffer); | 478 last_decoded_frame_buffer_ = std::move(extracted_buffer); |
| 487 } | 479 } |
| 488 | 480 |
| 489 uint32_t VideoProcessor::FrameNumberToTimestamp(int frame_number) { | 481 uint32_t VideoProcessor::FrameNumberToTimestamp(int frame_number) const { |
| 490 RTC_DCHECK_GE(frame_number, 0); | 482 RTC_DCHECK_GE(frame_number, 0); |
| 491 const int ticks_per_frame = | 483 const int ticks_per_frame = |
| 492 kRtpClockRateHz / config_.codec_settings.maxFramerate; | 484 kRtpClockRateHz / config_.codec_settings.maxFramerate; |
| 493 return (frame_number + 1) * ticks_per_frame; | 485 return (frame_number + 1) * ticks_per_frame; |
| 494 } | 486 } |
| 495 | 487 |
| 496 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) { | 488 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) const { |
| 497 RTC_DCHECK_GT(timestamp, 0); | 489 RTC_DCHECK_GT(timestamp, 0); |
| 498 const int ticks_per_frame = | 490 const int ticks_per_frame = |
| 499 kRtpClockRateHz / config_.codec_settings.maxFramerate; | 491 kRtpClockRateHz / config_.codec_settings.maxFramerate; |
| 500 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0); | 492 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0); |
| 501 return (timestamp / ticks_per_frame) - 1; | 493 return (timestamp / ticks_per_frame) - 1; |
| 502 } | 494 } |
| 503 | 495 |
| 504 } // namespace test | 496 } // namespace test |
| 505 } // namespace webrtc | 497 } // namespace webrtc |
| OLD | NEW |