| 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 26 matching lines...) Expand all Loading... |
| 37 std::unique_ptr<TemporalLayersFactory> tl_factory; | 37 std::unique_ptr<TemporalLayersFactory> tl_factory; |
| 38 if (config.codec_settings->codecType == VideoCodecType::kVideoCodecVP8) { | 38 if (config.codec_settings->codecType == VideoCodecType::kVideoCodecVP8) { |
| 39 tl_factory.reset(new TemporalLayersFactory()); | 39 tl_factory.reset(new TemporalLayersFactory()); |
| 40 config.codec_settings->VP8()->tl_factory = tl_factory.get(); | 40 config.codec_settings->VP8()->tl_factory = tl_factory.get(); |
| 41 } | 41 } |
| 42 return std::unique_ptr<VideoBitrateAllocator>( | 42 return std::unique_ptr<VideoBitrateAllocator>( |
| 43 VideoCodecInitializer::CreateBitrateAllocator(*config.codec_settings, | 43 VideoCodecInitializer::CreateBitrateAllocator(*config.codec_settings, |
| 44 std::move(tl_factory))); | 44 std::move(tl_factory))); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void PrintCodecSettings(const VideoCodec* config) { |
| 48 printf(" Start bitrate : %d kbps\n", config->startBitrate); |
| 49 printf(" Width : %d\n", config->width); |
| 50 printf(" Height : %d\n", config->height); |
| 51 printf(" Codec type : %s\n", |
| 52 CodecTypeToPayloadName(config->codecType).value_or("Unknown")); |
| 53 if (config->codecType == kVideoCodecVP8) { |
| 54 printf(" Denoising : %d\n", config->VP8().denoisingOn); |
| 55 printf(" Error concealment: %d\n", config->VP8().errorConcealmentOn); |
| 56 printf(" Frame dropping : %d\n", config->VP8().frameDroppingOn); |
| 57 printf(" Resilience : %d\n", config->VP8().resilience); |
| 58 } else if (config->codecType == kVideoCodecVP9) { |
| 59 printf(" Denoising : %d\n", config->VP9().denoisingOn); |
| 60 printf(" Frame dropping : %d\n", config->VP9().frameDroppingOn); |
| 61 printf(" Resilience : %d\n", config->VP9().resilience); |
| 62 } |
| 63 } |
| 64 |
| 65 int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) { |
| 66 int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec; |
| 67 RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min()); |
| 68 RTC_DCHECK_LE(diff_us, std::numeric_limits<int>::max()); |
| 69 return static_cast<int>(diff_us); |
| 70 } |
| 71 |
| 47 } // namespace | 72 } // namespace |
| 48 | 73 |
| 49 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) { | 74 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) { |
| 50 switch (e) { | 75 switch (e) { |
| 51 case kExcludeOnlyFirstKeyFrame: | 76 case kExcludeOnlyFirstKeyFrame: |
| 52 return "ExcludeOnlyFirstKeyFrame"; | 77 return "ExcludeOnlyFirstKeyFrame"; |
| 53 case kExcludeAllKeyFrames: | 78 case kExcludeAllKeyFrames: |
| 54 return "ExcludeAllKeyFrames"; | 79 return "ExcludeAllKeyFrames"; |
| 55 default: | 80 default: |
| 56 RTC_NOTREACHED(); | 81 RTC_NOTREACHED(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 RTC_CHECK_EQ(decoder_->InitDecode(config_.codec_settings, num_cores), | 177 RTC_CHECK_EQ(decoder_->InitDecode(config_.codec_settings, num_cores), |
| 153 WEBRTC_VIDEO_CODEC_OK) | 178 WEBRTC_VIDEO_CODEC_OK) |
| 154 << "Failed to initialize VideoDecoder"; | 179 << "Failed to initialize VideoDecoder"; |
| 155 | 180 |
| 156 if (config_.verbose) { | 181 if (config_.verbose) { |
| 157 printf("Video Processor:\n"); | 182 printf("Video Processor:\n"); |
| 158 printf(" #CPU cores used : %d\n", num_cores); | 183 printf(" #CPU cores used : %d\n", num_cores); |
| 159 printf(" Total # of frames: %d\n", | 184 printf(" Total # of frames: %d\n", |
| 160 analysis_frame_reader_->NumberOfFrames()); | 185 analysis_frame_reader_->NumberOfFrames()); |
| 161 printf(" Codec settings:\n"); | 186 printf(" Codec settings:\n"); |
| 162 printf(" Start bitrate : %d kbps\n", | |
| 163 config_.codec_settings->startBitrate); | |
| 164 printf(" Width : %d\n", config_.codec_settings->width); | |
| 165 printf(" Height : %d\n", config_.codec_settings->height); | |
| 166 printf(" Codec type : %s\n", | |
| 167 CodecTypeToPayloadName(config_.codec_settings->codecType) | |
| 168 .value_or("Unknown")); | |
| 169 printf(" Encoder implementation name: %s\n", | 187 printf(" Encoder implementation name: %s\n", |
| 170 encoder_->ImplementationName()); | 188 encoder_->ImplementationName()); |
| 171 printf(" Decoder implementation name: %s\n", | 189 printf(" Decoder implementation name: %s\n", |
| 172 decoder_->ImplementationName()); | 190 decoder_->ImplementationName()); |
| 173 if (config_.codec_settings->codecType == kVideoCodecVP8) { | 191 PrintCodecSettings(config_.codec_settings); |
| 174 printf(" Denoising : %d\n", | |
| 175 config_.codec_settings->VP8()->denoisingOn); | |
| 176 printf(" Error concealment: %d\n", | |
| 177 config_.codec_settings->VP8()->errorConcealmentOn); | |
| 178 printf(" Frame dropping : %d\n", | |
| 179 config_.codec_settings->VP8()->frameDroppingOn); | |
| 180 printf(" Resilience : %d\n", | |
| 181 config_.codec_settings->VP8()->resilience); | |
| 182 } else if (config_.codec_settings->codecType == kVideoCodecVP9) { | |
| 183 printf(" Resilience : %d\n", | |
| 184 config_.codec_settings->VP9()->resilience); | |
| 185 } | |
| 186 } | 192 } |
| 187 initialized_ = true; | 193 initialized_ = true; |
| 188 return true; | 194 return true; |
| 189 } | 195 } |
| 190 | 196 |
| 191 VideoProcessorImpl::~VideoProcessorImpl() { | 197 VideoProcessorImpl::~VideoProcessorImpl() { |
| 192 encoder_->RegisterEncodeCompleteCallback(nullptr); | 198 encoder_->RegisterEncodeCompleteCallback(nullptr); |
| 193 decoder_->RegisterDecodeCompleteCallback(nullptr); | 199 decoder_->RegisterDecodeCompleteCallback(nullptr); |
| 194 } | 200 } |
| 195 | 201 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(), | 462 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(), |
| 457 extracted_length); | 463 extracted_length); |
| 458 | 464 |
| 459 RTC_CHECK(analysis_frame_writer_->WriteFrame(image_buffer.get())); | 465 RTC_CHECK(analysis_frame_writer_->WriteFrame(image_buffer.get())); |
| 460 if (decoded_frame_writer_) { | 466 if (decoded_frame_writer_) { |
| 461 RTC_CHECK(decoded_frame_writer_->WriteFrame(image_buffer.get())); | 467 RTC_CHECK(decoded_frame_writer_->WriteFrame(image_buffer.get())); |
| 462 } | 468 } |
| 463 } | 469 } |
| 464 } | 470 } |
| 465 | 471 |
| 466 int VideoProcessorImpl::GetElapsedTimeMicroseconds(int64_t start, | |
| 467 int64_t stop) { | |
| 468 int64_t encode_time = (stop - start) / rtc::kNumNanosecsPerMicrosec; | |
| 469 RTC_DCHECK_GE(encode_time, std::numeric_limits<int>::min()); | |
| 470 RTC_DCHECK_LE(encode_time, std::numeric_limits<int>::max()); | |
| 471 return static_cast<int>(encode_time); | |
| 472 } | |
| 473 | |
| 474 } // namespace test | 472 } // namespace test |
| 475 } // namespace webrtc | 473 } // namespace webrtc |
| OLD | NEW |