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