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 } // namespace | 124 } // namespace |
125 | 125 |
126 VP8Encoder* VP8Encoder::Create() { | 126 VP8Encoder* VP8Encoder::Create() { |
127 return new VP8EncoderImpl(); | 127 return new VP8EncoderImpl(); |
128 } | 128 } |
129 | 129 |
130 VP8Decoder* VP8Decoder::Create() { | 130 VP8Decoder* VP8Decoder::Create() { |
131 return new VP8DecoderImpl(); | 131 return new VP8DecoderImpl(); |
132 } | 132 } |
133 | 133 |
| 134 int VP8EncoderImpl::EncodeFlags(TemporalReferences references) { |
| 135 RTC_DCHECK(!references.drop_frame); |
| 136 |
| 137 int flags = 0; |
| 138 |
| 139 if ((references.last_buffer_flags & kReference) == 0) |
| 140 flags |= VP8_EFLAG_NO_REF_LAST; |
| 141 if ((references.last_buffer_flags & kUpdate) == 0) |
| 142 flags |= VP8_EFLAG_NO_UPD_LAST; |
| 143 if ((references.golden_buffer_flags & kReference) == 0) |
| 144 flags |= VP8_EFLAG_NO_REF_GF; |
| 145 if ((references.golden_buffer_flags & kUpdate) == 0) |
| 146 flags |= VP8_EFLAG_NO_UPD_GF; |
| 147 if ((references.arf_buffer_flags & kReference) == 0) |
| 148 flags |= VP8_EFLAG_NO_REF_ARF; |
| 149 if ((references.arf_buffer_flags & kUpdate) == 0) |
| 150 flags |= VP8_EFLAG_NO_UPD_ARF; |
| 151 if (references.freeze_entropy) |
| 152 flags |= VP8_EFLAG_NO_UPD_ENTROPY; |
| 153 |
| 154 return flags; |
| 155 } |
| 156 |
134 VP8EncoderImpl::VP8EncoderImpl() | 157 VP8EncoderImpl::VP8EncoderImpl() |
135 : use_gf_boost_(webrtc::field_trial::IsEnabled(kVp8GfBoostFieldTrial)), | 158 : use_gf_boost_(webrtc::field_trial::IsEnabled(kVp8GfBoostFieldTrial)), |
136 encoded_complete_callback_(nullptr), | 159 encoded_complete_callback_(nullptr), |
137 inited_(false), | 160 inited_(false), |
138 timestamp_(0), | 161 timestamp_(0), |
139 qp_max_(56), // Setting for max quantizer. | 162 qp_max_(56), // Setting for max quantizer. |
140 cpu_speed_default_(-6), | 163 cpu_speed_default_(-6), |
141 number_of_cores_(0), | 164 number_of_cores_(0), |
142 rc_max_intra_target_(0), | 165 rc_max_intra_target_(0), |
143 key_frame_request_(kMaxSimulcastStreams, false) { | 166 key_frame_request_(kMaxSimulcastStreams, false) { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 raw_images_[i - 1].planes[VPX_PLANE_V], | 700 raw_images_[i - 1].planes[VPX_PLANE_V], |
678 raw_images_[i - 1].stride[VPX_PLANE_V], raw_images_[i - 1].d_w, | 701 raw_images_[i - 1].stride[VPX_PLANE_V], raw_images_[i - 1].d_w, |
679 raw_images_[i - 1].d_h, raw_images_[i].planes[VPX_PLANE_Y], | 702 raw_images_[i - 1].d_h, raw_images_[i].planes[VPX_PLANE_Y], |
680 raw_images_[i].stride[VPX_PLANE_Y], raw_images_[i].planes[VPX_PLANE_U], | 703 raw_images_[i].stride[VPX_PLANE_Y], raw_images_[i].planes[VPX_PLANE_U], |
681 raw_images_[i].stride[VPX_PLANE_U], raw_images_[i].planes[VPX_PLANE_V], | 704 raw_images_[i].stride[VPX_PLANE_U], raw_images_[i].planes[VPX_PLANE_V], |
682 raw_images_[i].stride[VPX_PLANE_V], raw_images_[i].d_w, | 705 raw_images_[i].stride[VPX_PLANE_V], raw_images_[i].d_w, |
683 raw_images_[i].d_h, libyuv::kFilterBilinear); | 706 raw_images_[i].d_h, libyuv::kFilterBilinear); |
684 } | 707 } |
685 vpx_enc_frame_flags_t flags[kMaxSimulcastStreams]; | 708 vpx_enc_frame_flags_t flags[kMaxSimulcastStreams]; |
686 for (size_t i = 0; i < encoders_.size(); ++i) { | 709 for (size_t i = 0; i < encoders_.size(); ++i) { |
687 int ret = temporal_layers_[i]->EncodeFlags(frame.timestamp()); | 710 TemporalReferences tl_config = |
688 if (ret < 0) { | 711 temporal_layers_[i]->UpdateLayerConfig(frame.timestamp()); |
| 712 |
| 713 if (tl_config.drop_frame) { |
689 // Drop this frame. | 714 // Drop this frame. |
690 return WEBRTC_VIDEO_CODEC_OK; | 715 return WEBRTC_VIDEO_CODEC_OK; |
691 } | 716 } |
692 flags[i] = ret; | 717 flags[i] = EncodeFlags(tl_config); |
693 } | 718 } |
694 bool send_key_frame = false; | 719 bool send_key_frame = false; |
695 for (size_t i = 0; i < key_frame_request_.size() && i < send_stream_.size(); | 720 for (size_t i = 0; i < key_frame_request_.size() && i < send_stream_.size(); |
696 ++i) { | 721 ++i) { |
697 if (key_frame_request_[i] && send_stream_[i]) { | 722 if (key_frame_request_[i] && send_stream_[i]) { |
698 send_key_frame = true; | 723 send_key_frame = true; |
699 break; | 724 break; |
700 } | 725 } |
701 } | 726 } |
702 if (!send_key_frame && frame_types) { | 727 if (!send_key_frame && frame_types) { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 buffer_pool_.Release(); | 1177 buffer_pool_.Release(); |
1153 inited_ = false; | 1178 inited_ = false; |
1154 return WEBRTC_VIDEO_CODEC_OK; | 1179 return WEBRTC_VIDEO_CODEC_OK; |
1155 } | 1180 } |
1156 | 1181 |
1157 const char* VP8DecoderImpl::ImplementationName() const { | 1182 const char* VP8DecoderImpl::ImplementationName() const { |
1158 return "libvpx"; | 1183 return "libvpx"; |
1159 } | 1184 } |
1160 | 1185 |
1161 } // namespace webrtc | 1186 } // namespace webrtc |
OLD | NEW |