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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 timestamp_(0), | 138 timestamp_(0), |
139 qp_max_(56), // Setting for max quantizer. | 139 qp_max_(56), // Setting for max quantizer. |
140 cpu_speed_default_(-6), | 140 cpu_speed_default_(-6), |
141 number_of_cores_(0), | 141 number_of_cores_(0), |
142 rc_max_intra_target_(0), | 142 rc_max_intra_target_(0), |
143 key_frame_request_(kMaxSimulcastStreams, false) { | 143 key_frame_request_(kMaxSimulcastStreams, false) { |
144 uint32_t seed = rtc::Time32(); | 144 uint32_t seed = rtc::Time32(); |
145 srand(seed); | 145 srand(seed); |
146 | 146 |
147 picture_id_.reserve(kMaxSimulcastStreams); | 147 picture_id_.reserve(kMaxSimulcastStreams); |
148 last_key_frame_picture_id_.reserve(kMaxSimulcastStreams); | |
149 temporal_layers_.reserve(kMaxSimulcastStreams); | 148 temporal_layers_.reserve(kMaxSimulcastStreams); |
150 raw_images_.reserve(kMaxSimulcastStreams); | 149 raw_images_.reserve(kMaxSimulcastStreams); |
151 encoded_images_.reserve(kMaxSimulcastStreams); | 150 encoded_images_.reserve(kMaxSimulcastStreams); |
152 send_stream_.reserve(kMaxSimulcastStreams); | 151 send_stream_.reserve(kMaxSimulcastStreams); |
153 cpu_speed_.assign(kMaxSimulcastStreams, cpu_speed_default_); | 152 cpu_speed_.assign(kMaxSimulcastStreams, cpu_speed_default_); |
154 encoders_.reserve(kMaxSimulcastStreams); | 153 encoders_.reserve(kMaxSimulcastStreams); |
155 configurations_.reserve(kMaxSimulcastStreams); | 154 configurations_.reserve(kMaxSimulcastStreams); |
156 downsampling_factors_.reserve(kMaxSimulcastStreams); | 155 downsampling_factors_.reserve(kMaxSimulcastStreams); |
157 } | 156 } |
158 | 157 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 codec_ = *inst; | 327 codec_ = *inst; |
329 | 328 |
330 // Code expects simulcastStream resolutions to be correct, make sure they are | 329 // Code expects simulcastStream resolutions to be correct, make sure they are |
331 // filled even when there are no simulcast layers. | 330 // filled even when there are no simulcast layers. |
332 if (codec_.numberOfSimulcastStreams == 0) { | 331 if (codec_.numberOfSimulcastStreams == 0) { |
333 codec_.simulcastStream[0].width = codec_.width; | 332 codec_.simulcastStream[0].width = codec_.width; |
334 codec_.simulcastStream[0].height = codec_.height; | 333 codec_.simulcastStream[0].height = codec_.height; |
335 } | 334 } |
336 | 335 |
337 picture_id_.resize(number_of_streams); | 336 picture_id_.resize(number_of_streams); |
338 last_key_frame_picture_id_.resize(number_of_streams); | |
339 encoded_images_.resize(number_of_streams); | 337 encoded_images_.resize(number_of_streams); |
340 encoders_.resize(number_of_streams); | 338 encoders_.resize(number_of_streams); |
341 configurations_.resize(number_of_streams); | 339 configurations_.resize(number_of_streams); |
342 downsampling_factors_.resize(number_of_streams); | 340 downsampling_factors_.resize(number_of_streams); |
343 raw_images_.resize(number_of_streams); | 341 raw_images_.resize(number_of_streams); |
344 send_stream_.resize(number_of_streams); | 342 send_stream_.resize(number_of_streams); |
345 send_stream_[0] = true; // For non-simulcast case. | 343 send_stream_[0] = true; // For non-simulcast case. |
346 cpu_speed_.resize(number_of_streams); | 344 cpu_speed_.resize(number_of_streams); |
347 std::fill(key_frame_request_.begin(), key_frame_request_.end(), false); | 345 std::fill(key_frame_request_.begin(), key_frame_request_.end(), false); |
348 | 346 |
349 int idx = number_of_streams - 1; | 347 int idx = number_of_streams - 1; |
350 for (int i = 0; i < (number_of_streams - 1); ++i, --idx) { | 348 for (int i = 0; i < (number_of_streams - 1); ++i, --idx) { |
351 int gcd = GCD(inst->simulcastStream[idx].width, | 349 int gcd = GCD(inst->simulcastStream[idx].width, |
352 inst->simulcastStream[idx - 1].width); | 350 inst->simulcastStream[idx - 1].width); |
353 downsampling_factors_[i].num = inst->simulcastStream[idx].width / gcd; | 351 downsampling_factors_[i].num = inst->simulcastStream[idx].width / gcd; |
354 downsampling_factors_[i].den = inst->simulcastStream[idx - 1].width / gcd; | 352 downsampling_factors_[i].den = inst->simulcastStream[idx - 1].width / gcd; |
355 send_stream_[i] = false; | 353 send_stream_[i] = false; |
356 } | 354 } |
357 if (number_of_streams > 1) { | 355 if (number_of_streams > 1) { |
358 send_stream_[number_of_streams - 1] = false; | 356 send_stream_[number_of_streams - 1] = false; |
359 downsampling_factors_[number_of_streams - 1].num = 1; | 357 downsampling_factors_[number_of_streams - 1].num = 1; |
360 downsampling_factors_[number_of_streams - 1].den = 1; | 358 downsampling_factors_[number_of_streams - 1].den = 1; |
361 } | 359 } |
362 for (int i = 0; i < number_of_streams; ++i) { | 360 for (int i = 0; i < number_of_streams; ++i) { |
363 // Random start, 16 bits is enough. | 361 // Random start, 16 bits is enough. |
364 picture_id_[i] = static_cast<uint16_t>(rand()) & 0x7FFF; // NOLINT | 362 picture_id_[i] = static_cast<uint16_t>(rand()) & 0x7FFF; // NOLINT |
365 last_key_frame_picture_id_[i] = -1; | |
366 // allocate memory for encoded image | 363 // allocate memory for encoded image |
367 if (encoded_images_[i]._buffer != NULL) { | 364 if (encoded_images_[i]._buffer != NULL) { |
368 delete[] encoded_images_[i]._buffer; | 365 delete[] encoded_images_[i]._buffer; |
369 } | 366 } |
370 encoded_images_[i]._size = | 367 encoded_images_[i]._size = |
371 CalcBufferSize(kI420, codec_.width, codec_.height); | 368 CalcBufferSize(kI420, codec_.width, codec_.height); |
372 encoded_images_[i]._buffer = new uint8_t[encoded_images_[i]._size]; | 369 encoded_images_[i]._buffer = new uint8_t[encoded_images_[i]._size]; |
373 encoded_images_[i]._completeFrame = true; | 370 encoded_images_[i]._completeFrame = true; |
374 } | 371 } |
375 // populate encoder configuration with default values | 372 // populate encoder configuration with default values |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 void VP8EncoderImpl::PopulateCodecSpecific( | 797 void VP8EncoderImpl::PopulateCodecSpecific( |
801 CodecSpecificInfo* codec_specific, | 798 CodecSpecificInfo* codec_specific, |
802 const vpx_codec_cx_pkt_t& pkt, | 799 const vpx_codec_cx_pkt_t& pkt, |
803 int stream_idx, | 800 int stream_idx, |
804 uint32_t timestamp) { | 801 uint32_t timestamp) { |
805 assert(codec_specific != NULL); | 802 assert(codec_specific != NULL); |
806 codec_specific->codecType = kVideoCodecVP8; | 803 codec_specific->codecType = kVideoCodecVP8; |
807 codec_specific->codec_name = ImplementationName(); | 804 codec_specific->codec_name = ImplementationName(); |
808 CodecSpecificInfoVP8* vp8Info = &(codec_specific->codecSpecific.VP8); | 805 CodecSpecificInfoVP8* vp8Info = &(codec_specific->codecSpecific.VP8); |
809 vp8Info->pictureId = picture_id_[stream_idx]; | 806 vp8Info->pictureId = picture_id_[stream_idx]; |
810 if (pkt.data.frame.flags & VPX_FRAME_IS_KEY) { | |
811 last_key_frame_picture_id_[stream_idx] = picture_id_[stream_idx]; | |
812 } | |
813 vp8Info->simulcastIdx = stream_idx; | 807 vp8Info->simulcastIdx = stream_idx; |
814 vp8Info->keyIdx = kNoKeyIdx; // TODO(hlundin) populate this | 808 vp8Info->keyIdx = kNoKeyIdx; // TODO(hlundin) populate this |
815 vp8Info->nonReference = (pkt.data.frame.flags & VPX_FRAME_IS_DROPPABLE) != 0; | 809 vp8Info->nonReference = (pkt.data.frame.flags & VPX_FRAME_IS_DROPPABLE) != 0; |
816 temporal_layers_[stream_idx]->PopulateCodecSpecific( | 810 temporal_layers_[stream_idx]->PopulateCodecSpecific( |
817 (pkt.data.frame.flags & VPX_FRAME_IS_KEY) != 0, vp8Info, timestamp); | 811 (pkt.data.frame.flags & VPX_FRAME_IS_KEY) != 0, vp8Info, timestamp); |
818 // Prepare next. | 812 // Prepare next. |
819 picture_id_[stream_idx] = (picture_id_[stream_idx] + 1) & 0x7FFF; | 813 picture_id_[stream_idx] = (picture_id_[stream_idx] + 1) & 0x7FFF; |
820 } | 814 } |
821 | 815 |
822 int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image) { | 816 int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image) { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 buffer_pool_.Release(); | 1143 buffer_pool_.Release(); |
1150 inited_ = false; | 1144 inited_ = false; |
1151 return WEBRTC_VIDEO_CODEC_OK; | 1145 return WEBRTC_VIDEO_CODEC_OK; |
1152 } | 1146 } |
1153 | 1147 |
1154 const char* VP8DecoderImpl::ImplementationName() const { | 1148 const char* VP8DecoderImpl::ImplementationName() const { |
1155 return "libvpx"; | 1149 return "libvpx"; |
1156 } | 1150 } |
1157 | 1151 |
1158 } // namespace webrtc | 1152 } // namespace webrtc |
OLD | NEW |