Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 for (int i = 0; i < num_streams; ++i) { | 126 for (int i = 0; i < num_streams; ++i) { |
| 127 if (codec.width * codec.simulcastStream[i].height != | 127 if (codec.width * codec.simulcastStream[i].height != |
| 128 codec.height * codec.simulcastStream[i].width) { | 128 codec.height * codec.simulcastStream[i].width) { |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | |
| 135 int NumStreamsDisabled(std::vector<bool>& streams) { | |
| 136 int num_disabled = 0; | |
| 137 for (bool stream : streams) { | |
| 138 if (!stream) | |
| 139 ++num_disabled; | |
| 140 } | |
| 141 return num_disabled; | |
| 142 } | |
| 134 } // namespace | 143 } // namespace |
| 135 | 144 |
| 136 const float kTl1MaxTimeToDropFrames = 20.0f; | 145 const float kTl1MaxTimeToDropFrames = 20.0f; |
| 137 | 146 |
| 138 VP8EncoderImpl::VP8EncoderImpl() | 147 VP8EncoderImpl::VP8EncoderImpl() |
| 139 : encoded_complete_callback_(NULL), | 148 : encoded_complete_callback_(NULL), |
| 140 inited_(false), | 149 inited_(false), |
| 141 timestamp_(0), | 150 timestamp_(0), |
| 142 feedback_mode_(false), | 151 feedback_mode_(false), |
| 143 qp_max_(56), // Setting for max quantizer. | 152 qp_max_(56), // Setting for max quantizer. |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 only_predicting_from_key_frame; | 946 only_predicting_from_key_frame; |
| 938 temporal_layers_[stream_idx]->PopulateCodecSpecific(base_layer_sync_point, | 947 temporal_layers_[stream_idx]->PopulateCodecSpecific(base_layer_sync_point, |
| 939 vp8Info, | 948 vp8Info, |
| 940 timestamp); | 949 timestamp); |
| 941 // Prepare next. | 950 // Prepare next. |
| 942 picture_id_[stream_idx] = (picture_id_[stream_idx] + 1) & 0x7FFF; | 951 picture_id_[stream_idx] = (picture_id_[stream_idx] + 1) & 0x7FFF; |
| 943 } | 952 } |
| 944 | 953 |
| 945 int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image, | 954 int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image, |
| 946 bool only_predicting_from_key_frame) { | 955 bool only_predicting_from_key_frame) { |
| 956 int bw_resolutions_disabled = 0; | |
| 957 bool bw_available = encoders_.size() > 1; | |
| 958 if (bw_available) | |
|
pbos-webrtc
2015/09/28 15:34:38
int bw_resolutions_disabled = bw_available ? NumSt
åsapersson
2015/09/28 15:47:39
Done.
| |
| 959 bw_resolutions_disabled = NumStreamsDisabled(send_stream_); | |
| 960 | |
| 947 int stream_idx = static_cast<int>(encoders_.size()) - 1; | 961 int stream_idx = static_cast<int>(encoders_.size()) - 1; |
| 948 int result = WEBRTC_VIDEO_CODEC_OK; | 962 int result = WEBRTC_VIDEO_CODEC_OK; |
| 949 for (size_t encoder_idx = 0; encoder_idx < encoders_.size(); | 963 for (size_t encoder_idx = 0; encoder_idx < encoders_.size(); |
| 950 ++encoder_idx, --stream_idx) { | 964 ++encoder_idx, --stream_idx) { |
| 951 vpx_codec_iter_t iter = NULL; | 965 vpx_codec_iter_t iter = NULL; |
| 952 int part_idx = 0; | 966 int part_idx = 0; |
| 953 encoded_images_[encoder_idx]._length = 0; | 967 encoded_images_[encoder_idx]._length = 0; |
| 954 encoded_images_[encoder_idx]._frameType = kDeltaFrame; | 968 encoded_images_[encoder_idx]._frameType = kDeltaFrame; |
| 955 RTPFragmentationHeader frag_info; | 969 RTPFragmentationHeader frag_info; |
| 956 // token_partitions_ is number of bits used. | 970 // token_partitions_ is number of bits used. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 987 } | 1001 } |
| 988 PopulateCodecSpecific(&codec_specific, *pkt, stream_idx, | 1002 PopulateCodecSpecific(&codec_specific, *pkt, stream_idx, |
| 989 input_image.timestamp(), | 1003 input_image.timestamp(), |
| 990 only_predicting_from_key_frame); | 1004 only_predicting_from_key_frame); |
| 991 break; | 1005 break; |
| 992 } | 1006 } |
| 993 } | 1007 } |
| 994 encoded_images_[encoder_idx]._timeStamp = input_image.timestamp(); | 1008 encoded_images_[encoder_idx]._timeStamp = input_image.timestamp(); |
| 995 encoded_images_[encoder_idx].capture_time_ms_ = | 1009 encoded_images_[encoder_idx].capture_time_ms_ = |
| 996 input_image.render_time_ms(); | 1010 input_image.render_time_ms(); |
| 1011 encoded_images_[encoder_idx].adapt_reason_.bw_available = bw_available; | |
| 1012 encoded_images_[encoder_idx].adapt_reason_.bw_resolutions_disabled = | |
| 1013 bw_resolutions_disabled; | |
| 997 | 1014 |
| 998 int qp = -1; | 1015 int qp = -1; |
| 999 vpx_codec_control(&encoders_[encoder_idx], VP8E_GET_LAST_QUANTIZER_64, &qp); | 1016 vpx_codec_control(&encoders_[encoder_idx], VP8E_GET_LAST_QUANTIZER_64, &qp); |
| 1000 temporal_layers_[stream_idx]->FrameEncoded( | 1017 temporal_layers_[stream_idx]->FrameEncoded( |
| 1001 encoded_images_[encoder_idx]._length, | 1018 encoded_images_[encoder_idx]._length, |
| 1002 encoded_images_[encoder_idx]._timeStamp, qp); | 1019 encoded_images_[encoder_idx]._timeStamp, qp); |
| 1003 if (send_stream_[stream_idx]) { | 1020 if (send_stream_[stream_idx]) { |
| 1004 if (encoded_images_[encoder_idx]._length > 0) { | 1021 if (encoded_images_[encoder_idx]._length > 0) { |
| 1005 TRACE_COUNTER_ID1("webrtc", "EncodedFrameSize", encoder_idx, | 1022 TRACE_COUNTER_ID1("webrtc", "EncodedFrameSize", encoder_idx, |
| 1006 encoded_images_[encoder_idx]._length); | 1023 encoded_images_[encoder_idx]._length); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1393 return -1; | 1410 return -1; |
| 1394 } | 1411 } |
| 1395 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) | 1412 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) |
| 1396 != VPX_CODEC_OK) { | 1413 != VPX_CODEC_OK) { |
| 1397 return -1; | 1414 return -1; |
| 1398 } | 1415 } |
| 1399 return 0; | 1416 return 0; |
| 1400 } | 1417 } |
| 1401 | 1418 |
| 1402 } // namespace webrtc | 1419 } // namespace webrtc |
| OLD | NEW |