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 13 matching lines...) Expand all Loading... | |
24 #include "webrtc/base/trace_event.h" | 24 #include "webrtc/base/trace_event.h" |
25 #include "webrtc/common_types.h" | 25 #include "webrtc/common_types.h" |
26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
27 #include "webrtc/modules/include/module_common_types.h" | 27 #include "webrtc/modules/include/module_common_types.h" |
28 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 28 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
29 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | 29 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
30 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" | 30 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" |
31 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 31 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
32 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" | 32 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" |
33 #include "webrtc/system_wrappers/include/clock.h" | 33 #include "webrtc/system_wrappers/include/clock.h" |
34 #include "webrtc/system_wrappers/include/field_trial.h" | |
34 #include "webrtc/system_wrappers/include/metrics.h" | 35 #include "webrtc/system_wrappers/include/metrics.h" |
35 | 36 |
36 namespace webrtc { | 37 namespace webrtc { |
37 namespace { | 38 namespace { |
38 | 39 |
40 const char kVp8PostProcArmFieldTrial[] = "WebRTC-VP8-Postproc-Arm"; | |
41 | |
39 enum { kVp8ErrorPropagationTh = 30 }; | 42 enum { kVp8ErrorPropagationTh = 30 }; |
40 enum { kVp832ByteAlign = 32 }; | 43 enum { kVp832ByteAlign = 32 }; |
41 | 44 |
42 // VP8 denoiser states. | 45 // VP8 denoiser states. |
43 enum denoiserState { | 46 enum denoiserState { |
44 kDenoiserOff, | 47 kDenoiserOff, |
45 kDenoiserOnYOnly, | 48 kDenoiserOnYOnly, |
46 kDenoiserOnYUV, | 49 kDenoiserOnYUV, |
47 kDenoiserOnYUVAggressive, | 50 kDenoiserOnYUVAggressive, |
48 // Adaptive mode defaults to kDenoiserOnYUV on key frame, but may switch | 51 // Adaptive mode defaults to kDenoiserOnYUV on key frame, but may switch |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
999 : buffer_pool_(false, 300 /* max_number_of_buffers*/), | 1002 : buffer_pool_(false, 300 /* max_number_of_buffers*/), |
1000 decode_complete_callback_(NULL), | 1003 decode_complete_callback_(NULL), |
1001 inited_(false), | 1004 inited_(false), |
1002 feedback_mode_(false), | 1005 feedback_mode_(false), |
1003 decoder_(NULL), | 1006 decoder_(NULL), |
1004 image_format_(VPX_IMG_FMT_NONE), | 1007 image_format_(VPX_IMG_FMT_NONE), |
1005 ref_frame_(NULL), | 1008 ref_frame_(NULL), |
1006 propagation_cnt_(-1), | 1009 propagation_cnt_(-1), |
1007 last_frame_width_(0), | 1010 last_frame_width_(0), |
1008 last_frame_height_(0), | 1011 last_frame_height_(0), |
1009 key_frame_required_(true) {} | 1012 key_frame_required_(true), |
1013 use_postproc_arm_(webrtc::field_trial::FindFullName( | |
1014 kVp8PostProcArmFieldTrial) == "Enabled") {} | |
1010 | 1015 |
1011 VP8DecoderImpl::~VP8DecoderImpl() { | 1016 VP8DecoderImpl::~VP8DecoderImpl() { |
1012 inited_ = true; // in order to do the actual release | 1017 inited_ = true; // in order to do the actual release |
1013 Release(); | 1018 Release(); |
1014 } | 1019 } |
1015 | 1020 |
1016 int VP8DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) { | 1021 int VP8DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) { |
1017 int ret_val = Release(); | 1022 int ret_val = Release(); |
1018 if (ret_val < 0) { | 1023 if (ret_val < 0) { |
1019 return ret_val; | 1024 return ret_val; |
1020 } | 1025 } |
1021 if (decoder_ == NULL) { | 1026 if (decoder_ == NULL) { |
1022 decoder_ = new vpx_codec_ctx_t; | 1027 decoder_ = new vpx_codec_ctx_t; |
1023 memset(decoder_, 0, sizeof(*decoder_)); | 1028 memset(decoder_, 0, sizeof(*decoder_)); |
1024 } | 1029 } |
1025 if (inst && inst->codecType == kVideoCodecVP8) { | 1030 if (inst && inst->codecType == kVideoCodecVP8) { |
1026 feedback_mode_ = inst->VP8().feedbackModeOn; | 1031 feedback_mode_ = inst->VP8().feedbackModeOn; |
1027 } | 1032 } |
1028 vpx_codec_dec_cfg_t cfg; | 1033 vpx_codec_dec_cfg_t cfg; |
1029 // Setting number of threads to a constant value (1) | 1034 // Setting number of threads to a constant value (1) |
1030 cfg.threads = 1; | 1035 cfg.threads = 1; |
1031 cfg.h = cfg.w = 0; // set after decode | 1036 cfg.h = cfg.w = 0; // set after decode |
1032 | 1037 |
1033 vpx_codec_flags_t flags = 0; | 1038 vpx_codec_flags_t flags = 0; |
1034 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \ | 1039 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) |
1035 !defined(ANDROID) | 1040 if (use_postproc_arm_) |
1041 flags = VPX_CODEC_USE_POSTPROC; | |
brandtr
2017/02/27 22:12:17
This file seems to use a mix of {}-style, but here
åsapersson
2017/02/28 13:36:38
Done.
| |
1042 #else | |
1036 flags = VPX_CODEC_USE_POSTPROC; | 1043 flags = VPX_CODEC_USE_POSTPROC; |
1037 #endif | 1044 #endif |
1038 | 1045 |
1039 if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) { | 1046 if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) { |
1040 delete decoder_; | 1047 delete decoder_; |
1041 decoder_ = nullptr; | 1048 decoder_ = nullptr; |
1042 return WEBRTC_VIDEO_CODEC_MEMORY; | 1049 return WEBRTC_VIDEO_CODEC_MEMORY; |
1043 } | 1050 } |
1044 | 1051 |
1045 // Save VideoCodec instance for later; mainly for duplicating the decoder. | 1052 // Save VideoCodec instance for later; mainly for duplicating the decoder. |
(...skipping 19 matching lines...) Expand all Loading... | |
1065 if (decode_complete_callback_ == NULL) { | 1072 if (decode_complete_callback_ == NULL) { |
1066 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 1073 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
1067 } | 1074 } |
1068 if (input_image._buffer == NULL && input_image._length > 0) { | 1075 if (input_image._buffer == NULL && input_image._length > 0) { |
1069 // Reset to avoid requesting key frames too often. | 1076 // Reset to avoid requesting key frames too often. |
1070 if (propagation_cnt_ > 0) | 1077 if (propagation_cnt_ > 0) |
1071 propagation_cnt_ = 0; | 1078 propagation_cnt_ = 0; |
1072 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 1079 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
1073 } | 1080 } |
1074 | 1081 |
1075 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \ | 1082 // Post process configurations. |
1076 !defined(ANDROID) | 1083 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) |
1084 if (use_postproc_arm_) { | |
1085 vp8_postproc_cfg_t ppcfg; | |
1086 ppcfg.deblocking_level = 3; | |
marpan
2017/02/27 17:43:14
can remove this setting, as its set below (line 10
åsapersson
2017/02/28 13:36:38
Done.
| |
1087 ppcfg.post_proc_flag = VP8_MFQE; | |
1088 // For low resolutions, use stronger deblocking filter and enable the | |
1089 // deblock and demacroblocker. | |
1090 if (last_frame_width_ * last_frame_height_ <= 320 * 240) { | |
brandtr
2017/02/27 22:12:17
Should we check the current frame size here, rathe
åsapersson
2017/02/28 13:36:38
The current frame size is known after decode. Adde
| |
1091 ppcfg.deblocking_level = 6; | |
1092 ppcfg.post_proc_flag |= VP8_DEBLOCK | VP8_DEMACROBLOCK; | |
1093 } | |
1094 vpx_codec_control(decoder_, VP8_SET_POSTPROC, &ppcfg); | |
1095 } | |
1096 #else | |
1077 vp8_postproc_cfg_t ppcfg; | 1097 vp8_postproc_cfg_t ppcfg; |
1078 // MFQE enabled to reduce key frame popping. | 1098 // MFQE enabled to reduce key frame popping. |
1079 ppcfg.post_proc_flag = VP8_MFQE | VP8_DEBLOCK; | 1099 ppcfg.post_proc_flag = VP8_MFQE | VP8_DEBLOCK; |
1080 // For VGA resolutions and lower, enable the demacroblocker postproc. | 1100 // For VGA resolutions and lower, enable the demacroblocker postproc. |
1081 if (last_frame_width_ * last_frame_height_ <= 640 * 360) { | 1101 if (last_frame_width_ * last_frame_height_ <= 640 * 360) { |
1082 ppcfg.post_proc_flag |= VP8_DEMACROBLOCK; | 1102 ppcfg.post_proc_flag |= VP8_DEMACROBLOCK; |
1083 } | 1103 } |
1084 // Strength of deblocking filter. Valid range:[0,16] | 1104 // Strength of deblocking filter. Valid range:[0,16] |
1085 ppcfg.deblocking_level = 3; | 1105 ppcfg.deblocking_level = 3; |
1086 vpx_codec_control(decoder_, VP8_SET_POSTPROC, &ppcfg); | 1106 vpx_codec_control(decoder_, VP8_SET_POSTPROC, &ppcfg); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1281 return -1; | 1301 return -1; |
1282 } | 1302 } |
1283 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != | 1303 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != |
1284 VPX_CODEC_OK) { | 1304 VPX_CODEC_OK) { |
1285 return -1; | 1305 return -1; |
1286 } | 1306 } |
1287 return 0; | 1307 return 0; |
1288 } | 1308 } |
1289 | 1309 |
1290 } // namespace webrtc | 1310 } // namespace webrtc |
OLD | NEW |