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 #include "third_party/openh264/src/codec/api/svc/codec_ver.h" | |
19 | 20 |
20 #include "webrtc/base/checks.h" | 21 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 23 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
23 #include "webrtc/system_wrappers/include/metrics.h" | 24 #include "webrtc/system_wrappers/include/metrics.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 // Copy the entire layer's data (including start codes). | 143 // Copy the entire layer's data (including start codes). |
143 memcpy(encoded_image->_buffer + encoded_image->_length, | 144 memcpy(encoded_image->_buffer + encoded_image->_length, |
144 layerInfo.pBsBuf, | 145 layerInfo.pBsBuf, |
145 layer_len); | 146 layer_len); |
146 encoded_image->_length += layer_len; | 147 encoded_image->_length += layer_len; |
147 } | 148 } |
148 } | 149 } |
149 | 150 |
150 H264EncoderImpl::H264EncoderImpl() | 151 H264EncoderImpl::H264EncoderImpl() |
151 : openh264_encoder_(nullptr), | 152 : openh264_encoder_(nullptr), |
153 number_of_cores_(0), | |
152 encoded_image_callback_(nullptr), | 154 encoded_image_callback_(nullptr), |
153 has_reported_init_(false), | 155 has_reported_init_(false), |
154 has_reported_error_(false) { | 156 has_reported_error_(false) { |
155 } | 157 } |
156 | 158 |
157 H264EncoderImpl::~H264EncoderImpl() { | 159 H264EncoderImpl::~H264EncoderImpl() { |
158 Release(); | 160 Release(); |
159 } | 161 } |
160 | 162 |
161 int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, | 163 int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 encoder_params.iPicWidth, encoder_params.iPicHeight, number_of_cores_); | 434 encoder_params.iPicWidth, encoder_params.iPicHeight, number_of_cores_); |
433 // The base spatial layer 0 is the only one we use. | 435 // The base spatial layer 0 is the only one we use. |
434 encoder_params.sSpatialLayers[0].iVideoWidth = encoder_params.iPicWidth; | 436 encoder_params.sSpatialLayers[0].iVideoWidth = encoder_params.iPicWidth; |
435 encoder_params.sSpatialLayers[0].iVideoHeight = encoder_params.iPicHeight; | 437 encoder_params.sSpatialLayers[0].iVideoHeight = encoder_params.iPicHeight; |
436 encoder_params.sSpatialLayers[0].fFrameRate = encoder_params.fMaxFrameRate; | 438 encoder_params.sSpatialLayers[0].fFrameRate = encoder_params.fMaxFrameRate; |
437 encoder_params.sSpatialLayers[0].iSpatialBitrate = | 439 encoder_params.sSpatialLayers[0].iSpatialBitrate = |
438 encoder_params.iTargetBitrate; | 440 encoder_params.iTargetBitrate; |
439 encoder_params.sSpatialLayers[0].iMaxSpatialBitrate = | 441 encoder_params.sSpatialLayers[0].iMaxSpatialBitrate = |
440 encoder_params.iMaxBitrate; | 442 encoder_params.iMaxBitrate; |
441 // Slice num according to number of threads. | 443 // Slice num according to number of threads. |
444 #if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5) | |
442 encoder_params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_AUTO_SLICE; | 445 encoder_params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_AUTO_SLICE; |
446 #else | |
447 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = | |
448 SM_FIXEDSLCNUM_SLICE; | |
stefan-webrtc
2016/10/24 10:42:02
Maybe comment on what this means? Reading the head
sprang_webrtc
2016/10/24 11:28:19
Comment above still says "// Slice num according t
hbos_chromium
2016/10/24 14:10:37
According to the link, SM_FIXEDSLCNUM_SLICE sets i
| |
449 #endif | |
443 | 450 |
444 return encoder_params; | 451 return encoder_params; |
445 } | 452 } |
446 | 453 |
447 void H264EncoderImpl::ReportInit() { | 454 void H264EncoderImpl::ReportInit() { |
448 if (has_reported_init_) | 455 if (has_reported_init_) |
449 return; | 456 return; |
450 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", | 457 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", |
451 kH264EncoderEventInit, | 458 kH264EncoderEventInit, |
452 kH264EncoderEventMax); | 459 kH264EncoderEventMax); |
(...skipping 16 matching lines...) Expand all Loading... | |
469 | 476 |
470 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { | 477 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { |
471 return WEBRTC_VIDEO_CODEC_OK; | 478 return WEBRTC_VIDEO_CODEC_OK; |
472 } | 479 } |
473 | 480 |
474 void H264EncoderImpl::OnDroppedFrame() { | 481 void H264EncoderImpl::OnDroppedFrame() { |
475 quality_scaler_.ReportDroppedFrame(); | 482 quality_scaler_.ReportDroppedFrame(); |
476 } | 483 } |
477 | 484 |
478 } // namespace webrtc | 485 } // namespace webrtc |
OLD | NEW |