OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 */ |
11 | 11 |
12 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" | 12 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" |
13 | 13 |
14 #include <limits> | 14 #include <limits> |
15 | 15 |
16 #include "third_party/openh264/src/codec/api/svc/codec_api.h" | 16 #include "third_party/openh264/src/codec/api/svc/codec_api.h" |
17 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" | 17 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" |
18 #include "third_party/openh264/src/codec/api/svc/codec_def.h" | 18 #include "third_party/openh264/src/codec/api/svc/codec_def.h" |
19 | 19 |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
23 #include "webrtc/system_wrappers/include/metrics.h" | 23 #include "webrtc/system_wrappers/include/metrics.h" |
24 | 24 |
25 namespace webrtc { | 25 namespace webrtc { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const int kLowH264QpThreshold = 24; | |
pbos-webrtc
2016/09/12 19:51:49
I want these to be declared in one place for this
| |
30 const int kHighH264QpThreshold = 37; | |
29 const bool kOpenH264EncoderDetailedLogging = false; | 31 const bool kOpenH264EncoderDetailedLogging = false; |
30 | 32 |
31 // Used by histograms. Values of entries should not be changed. | 33 // Used by histograms. Values of entries should not be changed. |
32 enum H264EncoderImplEvent { | 34 enum H264EncoderImplEvent { |
33 kH264EncoderEventInit = 0, | 35 kH264EncoderEventInit = 0, |
34 kH264EncoderEventError = 1, | 36 kH264EncoderEventError = 1, |
35 kH264EncoderEventMax = 16, | 37 kH264EncoderEventMax = 16, |
36 }; | 38 }; |
37 | 39 |
38 int NumberOfThreads(int width, int height, int number_of_cores) { | 40 int NumberOfThreads(int width, int height, int number_of_cores) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 | 208 |
207 SEncParamExt encoder_params = CreateEncoderParams(); | 209 SEncParamExt encoder_params = CreateEncoderParams(); |
208 // Initialize. | 210 // Initialize. |
209 if (openh264_encoder_->InitializeExt(&encoder_params) != 0) { | 211 if (openh264_encoder_->InitializeExt(&encoder_params) != 0) { |
210 LOG(LS_ERROR) << "Failed to initialize OpenH264 encoder"; | 212 LOG(LS_ERROR) << "Failed to initialize OpenH264 encoder"; |
211 Release(); | 213 Release(); |
212 ReportError(); | 214 ReportError(); |
213 return WEBRTC_VIDEO_CODEC_ERROR; | 215 return WEBRTC_VIDEO_CODEC_ERROR; |
214 } | 216 } |
215 // TODO(pbos): Base init params on these values before submitting. | 217 // TODO(pbos): Base init params on these values before submitting. |
216 quality_scaler_.Init(QualityScaler::kLowH264QpThreshold, | 218 quality_scaler_.Init(kLowH264QpThreshold, |
217 QualityScaler::kBadH264QpThreshold, | 219 kHighH264QpThreshold, |
218 codec_settings_.startBitrate, codec_settings_.width, | 220 codec_settings_.startBitrate, codec_settings_.width, |
219 codec_settings_.height, codec_settings_.maxFramerate); | 221 codec_settings_.height, codec_settings_.maxFramerate); |
220 int video_format = EVideoFormatType::videoFormatI420; | 222 int video_format = EVideoFormatType::videoFormatI420; |
221 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, | 223 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, |
222 &video_format); | 224 &video_format); |
223 | 225 |
224 // Initialize encoded image. Default buffer size: size of unencoded data. | 226 // Initialize encoded image. Default buffer size: size of unencoded data. |
225 encoded_image_._size = CalcBufferSize( | 227 encoded_image_._size = CalcBufferSize( |
226 kI420, codec_settings_.width, codec_settings_.height); | 228 kI420, codec_settings_.width, codec_settings_.height); |
227 encoded_image_._buffer = new uint8_t[encoded_image_._size]; | 229 encoded_image_._buffer = new uint8_t[encoded_image_._size]; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 | 472 |
471 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { | 473 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { |
472 return WEBRTC_VIDEO_CODEC_OK; | 474 return WEBRTC_VIDEO_CODEC_OK; |
473 } | 475 } |
474 | 476 |
475 void H264EncoderImpl::OnDroppedFrame() { | 477 void H264EncoderImpl::OnDroppedFrame() { |
476 quality_scaler_.ReportDroppedFrame(); | 478 quality_scaler_.ReportDroppedFrame(); |
477 } | 479 } |
478 | 480 |
479 } // namespace webrtc | 481 } // namespace webrtc |
OLD | NEW |