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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 // Only apply scaling to improve for single-layer streams. The scaling metrics | 610 // Only apply scaling to improve for single-layer streams. The scaling metrics |
611 // use frame drops as a signal and is only applicable when we drop frames. | 611 // use frame drops as a signal and is only applicable when we drop frames. |
612 quality_scaler_enabled_ = encoders_.size() == 1 && | 612 quality_scaler_enabled_ = encoders_.size() == 1 && |
613 configurations_[0].rc_dropframe_thresh > 0 && | 613 configurations_[0].rc_dropframe_thresh > 0 && |
614 codec_.codecSpecific.VP8.automaticResizeOn; | 614 codec_.codecSpecific.VP8.automaticResizeOn; |
615 | 615 |
616 return InitAndSetControlSettings(); | 616 return InitAndSetControlSettings(); |
617 } | 617 } |
618 | 618 |
619 int VP8EncoderImpl::SetCpuSpeed(int width, int height) { | 619 int VP8EncoderImpl::SetCpuSpeed(int width, int height) { |
620 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) | 620 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) |
621 // On mobile platform, always set to -12 to leverage between cpu usage | 621 // On mobile platform, always set to -12 to leverage between cpu usage |
622 // and video quality. | 622 // and video quality. |
623 return -12; | 623 return -12; |
624 #else | 624 #else |
625 // For non-ARM, increase encoding complexity (i.e., use lower speed setting) | 625 // For non-ARM, increase encoding complexity (i.e., use lower speed setting) |
626 // if resolution is below CIF. Otherwise, keep the default/user setting | 626 // if resolution is below CIF. Otherwise, keep the default/user setting |
627 // (|cpu_speed_default_|) set on InitEncode via codecSpecific.VP8.complexity. | 627 // (|cpu_speed_default_|) set on InitEncode via codecSpecific.VP8.complexity. |
628 if (width * height < 352 * 288) | 628 if (width * height < 352 * 288) |
629 return (cpu_speed_default_ < -4) ? -4 : cpu_speed_default_; | 629 return (cpu_speed_default_ < -4) ? -4 : cpu_speed_default_; |
630 else | 630 else |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 665 } |
666 } | 666 } |
667 // Enable denoising for the highest resolution stream, and for | 667 // Enable denoising for the highest resolution stream, and for |
668 // the second highest resolution if we are doing more than 2 | 668 // the second highest resolution if we are doing more than 2 |
669 // spatial layers/streams. | 669 // spatial layers/streams. |
670 // TODO(holmer): Investigate possibility of adding a libvpx API | 670 // TODO(holmer): Investigate possibility of adding a libvpx API |
671 // for getting the denoised frame from the encoder and using that | 671 // for getting the denoised frame from the encoder and using that |
672 // when encoding lower resolution streams. Would it work with the | 672 // when encoding lower resolution streams. Would it work with the |
673 // multi-res encoding feature? | 673 // multi-res encoding feature? |
674 denoiserState denoiser_state = kDenoiserOnYOnly; | 674 denoiserState denoiser_state = kDenoiserOnYOnly; |
675 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) | 675 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) |
676 denoiser_state = kDenoiserOnYOnly; | 676 denoiser_state = kDenoiserOnYOnly; |
677 #else | 677 #else |
678 denoiser_state = kDenoiserOnAdaptive; | 678 denoiser_state = kDenoiserOnAdaptive; |
679 #endif | 679 #endif |
680 vpx_codec_control( | 680 vpx_codec_control( |
681 &encoders_[0], VP8E_SET_NOISE_SENSITIVITY, | 681 &encoders_[0], VP8E_SET_NOISE_SENSITIVITY, |
682 codec_.codecSpecific.VP8.denoisingOn ? denoiser_state : kDenoiserOff); | 682 codec_.codecSpecific.VP8.denoisingOn ? denoiser_state : kDenoiserOff); |
683 if (encoders_.size() > 2) { | 683 if (encoders_.size() > 2) { |
684 vpx_codec_control( | 684 vpx_codec_control( |
685 &encoders_[1], VP8E_SET_NOISE_SENSITIVITY, | 685 &encoders_[1], VP8E_SET_NOISE_SENSITIVITY, |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1098 } |
1099 if (inst && inst->codecType == kVideoCodecVP8) { | 1099 if (inst && inst->codecType == kVideoCodecVP8) { |
1100 feedback_mode_ = inst->codecSpecific.VP8.feedbackModeOn; | 1100 feedback_mode_ = inst->codecSpecific.VP8.feedbackModeOn; |
1101 } | 1101 } |
1102 vpx_codec_dec_cfg_t cfg; | 1102 vpx_codec_dec_cfg_t cfg; |
1103 // Setting number of threads to a constant value (1) | 1103 // Setting number of threads to a constant value (1) |
1104 cfg.threads = 1; | 1104 cfg.threads = 1; |
1105 cfg.h = cfg.w = 0; // set after decode | 1105 cfg.h = cfg.w = 0; // set after decode |
1106 | 1106 |
1107 vpx_codec_flags_t flags = 0; | 1107 vpx_codec_flags_t flags = 0; |
1108 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) | 1108 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \ |
| 1109 !defined(ANDROID) |
1109 flags = VPX_CODEC_USE_POSTPROC; | 1110 flags = VPX_CODEC_USE_POSTPROC; |
1110 #ifdef INDEPENDENT_PARTITIONS | 1111 #ifdef INDEPENDENT_PARTITIONS |
1111 flags |= VPX_CODEC_USE_INPUT_PARTITION; | 1112 flags |= VPX_CODEC_USE_INPUT_PARTITION; |
1112 #endif | 1113 #endif |
1113 #endif | 1114 #endif |
1114 | 1115 |
1115 if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) { | 1116 if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) { |
1116 return WEBRTC_VIDEO_CODEC_MEMORY; | 1117 return WEBRTC_VIDEO_CODEC_MEMORY; |
1117 } | 1118 } |
1118 | 1119 |
(...skipping 26 matching lines...) Expand all Loading... |
1145 propagation_cnt_ = 0; | 1146 propagation_cnt_ = 0; |
1146 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 1147 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
1147 } | 1148 } |
1148 | 1149 |
1149 #ifdef INDEPENDENT_PARTITIONS | 1150 #ifdef INDEPENDENT_PARTITIONS |
1150 if (fragmentation == NULL) { | 1151 if (fragmentation == NULL) { |
1151 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 1152 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
1152 } | 1153 } |
1153 #endif | 1154 #endif |
1154 | 1155 |
1155 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) | 1156 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \ |
| 1157 !defined(ANDROID) |
1156 vp8_postproc_cfg_t ppcfg; | 1158 vp8_postproc_cfg_t ppcfg; |
1157 // MFQE enabled to reduce key frame popping. | 1159 // MFQE enabled to reduce key frame popping. |
1158 ppcfg.post_proc_flag = VP8_MFQE | VP8_DEBLOCK; | 1160 ppcfg.post_proc_flag = VP8_MFQE | VP8_DEBLOCK; |
1159 // For VGA resolutions and lower, enable the demacroblocker postproc. | 1161 // For VGA resolutions and lower, enable the demacroblocker postproc. |
1160 if (last_frame_width_ * last_frame_height_ <= 640 * 360) { | 1162 if (last_frame_width_ * last_frame_height_ <= 640 * 360) { |
1161 ppcfg.post_proc_flag |= VP8_DEMACROBLOCK; | 1163 ppcfg.post_proc_flag |= VP8_DEMACROBLOCK; |
1162 } | 1164 } |
1163 // Strength of deblocking filter. Valid range:[0,16] | 1165 // Strength of deblocking filter. Valid range:[0,16] |
1164 ppcfg.deblocking_level = 3; | 1166 ppcfg.deblocking_level = 3; |
1165 vpx_codec_control(decoder_, VP8_SET_POSTPROC, &ppcfg); | 1167 vpx_codec_control(decoder_, VP8_SET_POSTPROC, &ppcfg); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 return -1; | 1405 return -1; |
1404 } | 1406 } |
1405 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != | 1407 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != |
1406 VPX_CODEC_OK) { | 1408 VPX_CODEC_OK) { |
1407 return -1; | 1409 return -1; |
1408 } | 1410 } |
1409 return 0; | 1411 return 0; |
1410 } | 1412 } |
1411 | 1413 |
1412 } // namespace webrtc | 1414 } // namespace webrtc |
OLD | NEW |