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 */ |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 encoder_params.sSpatialLayers[0].iVideoHeight = encoder_params.iPicHeight; | 442 encoder_params.sSpatialLayers[0].iVideoHeight = encoder_params.iPicHeight; |
443 encoder_params.sSpatialLayers[0].fFrameRate = encoder_params.fMaxFrameRate; | 443 encoder_params.sSpatialLayers[0].fFrameRate = encoder_params.fMaxFrameRate; |
444 encoder_params.sSpatialLayers[0].iSpatialBitrate = | 444 encoder_params.sSpatialLayers[0].iSpatialBitrate = |
445 encoder_params.iTargetBitrate; | 445 encoder_params.iTargetBitrate; |
446 encoder_params.sSpatialLayers[0].iMaxSpatialBitrate = | 446 encoder_params.sSpatialLayers[0].iMaxSpatialBitrate = |
447 encoder_params.iMaxBitrate; | 447 encoder_params.iMaxBitrate; |
448 LOG(INFO) << "OpenH264 version is " << OPENH264_MAJOR << "." | 448 LOG(INFO) << "OpenH264 version is " << OPENH264_MAJOR << "." |
449 << OPENH264_MINOR; | 449 << OPENH264_MINOR; |
450 switch (packetization_mode_) { | 450 switch (packetization_mode_) { |
451 case H264PacketizationMode::SingleNalUnit: | 451 case H264PacketizationMode::SingleNalUnit: |
452 // Limit the size of the packets produced. | 452 // Limit the size of the packets produced. |
453 #if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5) | |
454 encoder_params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_DYN_SLICE; | |
455 // The slice size is max payload size - room for a NAL header. | |
456 // The constant 50 is NAL_HEADER_ADD_0X30BYTES in openh264 source, | |
457 // but is not exported. | |
458 const kNalHeaderSizeAllocation = 50; | |
459 encoder_params.sSpatialLayers[0] | |
460 .sSliceCfg.sSliceArgument.uiSliceSizeConstraint = | |
461 static_cast<unsigned int>(max_payload_size_ - | |
462 kNalHeaderSizeAllocation); | |
463 encoder_params.uiMaxNalSize = | |
464 static_cast<unsigned int>(max_payload_size_); | |
465 #else | |
466 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceNum = 1; | 453 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceNum = 1; |
467 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = | 454 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = |
468 SM_SIZELIMITED_SLICE; | 455 SM_SIZELIMITED_SLICE; |
469 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = | 456 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = |
470 static_cast<unsigned int>(max_payload_size_); | 457 static_cast<unsigned int>(max_payload_size_); |
471 #endif | |
472 break; | 458 break; |
473 case H264PacketizationMode::NonInterleaved: | 459 case H264PacketizationMode::NonInterleaved: |
474 #if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5) | |
475 // Slice num according to number of threads. | |
476 encoder_params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_AUTO_SLICE; | |
477 #else | |
478 // When uiSliceMode = SM_FIXEDSLCNUM_SLICE, uiSliceNum = 0 means auto | 460 // When uiSliceMode = SM_FIXEDSLCNUM_SLICE, uiSliceNum = 0 means auto |
479 // design it with cpu core number. | 461 // design it with cpu core number. |
480 // TODO(sprang): Set to 0 when we understand why the rate controller borks | 462 // TODO(sprang): Set to 0 when we understand why the rate controller borks |
481 // when uiSliceNum > 1. | 463 // when uiSliceNum > 1. |
482 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceNum = 1; | 464 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceNum = 1; |
483 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = | 465 encoder_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = |
484 SM_FIXEDSLCNUM_SLICE; | 466 SM_FIXEDSLCNUM_SLICE; |
485 #endif | |
486 break; | 467 break; |
487 } | 468 } |
488 return encoder_params; | 469 return encoder_params; |
489 } | 470 } |
490 | 471 |
491 void H264EncoderImpl::ReportInit() { | 472 void H264EncoderImpl::ReportInit() { |
492 if (has_reported_init_) | 473 if (has_reported_init_) |
493 return; | 474 return; |
494 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", | 475 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", |
495 kH264EncoderEventInit, | 476 kH264EncoderEventInit, |
(...skipping 17 matching lines...) Expand all Loading... |
513 | 494 |
514 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { | 495 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { |
515 return WEBRTC_VIDEO_CODEC_OK; | 496 return WEBRTC_VIDEO_CODEC_OK; |
516 } | 497 } |
517 | 498 |
518 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const { | 499 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const { |
519 return VideoEncoder::ScalingSettings(true); | 500 return VideoEncoder::ScalingSettings(true); |
520 } | 501 } |
521 | 502 |
522 } // namespace webrtc | 503 } // namespace webrtc |
OLD | NEW |