Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc

Issue 1287643002: Enabling spatial layers in VP9Impl. Filter layers in the loopback test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase master + fixing the comment Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 if (inst->width < 1 || inst->height < 1) { 206 if (inst->width < 1 || inst->height < 1) {
207 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 207 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
208 } 208 }
209 if (number_of_cores < 1) { 209 if (number_of_cores < 1) {
210 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 210 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
211 } 211 }
212 if (inst->codecSpecific.VP9.numberOfTemporalLayers > 3) { 212 if (inst->codecSpecific.VP9.numberOfTemporalLayers > 3) {
213 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 213 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
214 } 214 }
215 // For now, only support one spatial layer. 215 // libvpx currently supports only one or two spatial layers.
216 if (inst->codecSpecific.VP9.numberOfSpatialLayers != 1) { 216 if (inst->codecSpecific.VP9.numberOfSpatialLayers > 2) {
217 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 217 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
218 } 218 }
219 int retVal = Release(); 219 int retVal = Release();
220 if (retVal < 0) { 220 if (retVal < 0) {
221 return retVal; 221 return retVal;
222 } 222 }
223 if (encoder_ == NULL) { 223 if (encoder_ == NULL) {
224 encoder_ = new vpx_codec_ctx_t; 224 encoder_ = new vpx_codec_ctx_t;
225 } 225 }
226 if (config_ == NULL) { 226 if (config_ == NULL) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return 4; 344 return 4;
345 } else if (width * height >= 640 * 480 && number_of_cores > 2) { 345 } else if (width * height >= 640 * 480 && number_of_cores > 2) {
346 return 2; 346 return 2;
347 } else { 347 } else {
348 // 1 thread less than VGA. 348 // 1 thread less than VGA.
349 return 1; 349 return 1;
350 } 350 }
351 } 351 }
352 352
353 int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) { 353 int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) {
354
355 config_->ss_number_layers = num_spatial_layers_; 354 config_->ss_number_layers = num_spatial_layers_;
356 355
357 if (num_spatial_layers_ > 1) {
358 config_->rc_min_quantizer = 0;
359 config_->rc_max_quantizer = 63;
360 }
361 int scaling_factor_num = 256; 356 int scaling_factor_num = 256;
362 for (int i = num_spatial_layers_ - 1; i >= 0; --i) { 357 for (int i = num_spatial_layers_ - 1; i >= 0; --i) {
363 svc_internal_.svc_params.max_quantizers[i] = config_->rc_max_quantizer; 358 svc_internal_.svc_params.max_quantizers[i] = config_->rc_max_quantizer;
364 svc_internal_.svc_params.min_quantizers[i] = config_->rc_min_quantizer; 359 svc_internal_.svc_params.min_quantizers[i] = config_->rc_min_quantizer;
365 // 1:2 scaling in each dimension. 360 // 1:2 scaling in each dimension.
366 svc_internal_.svc_params.scaling_factor_num[i] = scaling_factor_num; 361 svc_internal_.svc_params.scaling_factor_num[i] = scaling_factor_num;
367 svc_internal_.svc_params.scaling_factor_den[i] = 256; 362 svc_internal_.svc_params.scaling_factor_den[i] = 256;
368 scaling_factor_num /= 2; 363 scaling_factor_num /= 2;
369 } 364 }
370 365
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 537
543 vp9_info->picture_id = picture_id_; 538 vp9_info->picture_id = picture_id_;
544 539
545 if (!vp9_info->flexible_mode) { 540 if (!vp9_info->flexible_mode) {
546 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) { 541 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) {
547 tl0_pic_idx_++; 542 tl0_pic_idx_++;
548 } 543 }
549 vp9_info->tl0_pic_idx = tl0_pic_idx_; 544 vp9_info->tl0_pic_idx = tl0_pic_idx_;
550 } 545 }
551 546
547 // Always populate this, so that the packetizer can properly set the marker
548 // bit.
549 vp9_info->num_spatial_layers = num_spatial_layers_;
552 if (vp9_info->ss_data_available) { 550 if (vp9_info->ss_data_available) {
553 vp9_info->num_spatial_layers = num_spatial_layers_;
554 vp9_info->spatial_layer_resolution_present = true; 551 vp9_info->spatial_layer_resolution_present = true;
555 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { 552 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) {
556 vp9_info->width[i] = codec_.width * 553 vp9_info->width[i] = codec_.width *
557 svc_internal_.svc_params.scaling_factor_num[i] / 554 svc_internal_.svc_params.scaling_factor_num[i] /
558 svc_internal_.svc_params.scaling_factor_den[i]; 555 svc_internal_.svc_params.scaling_factor_den[i];
559 vp9_info->height[i] = codec_.height * 556 vp9_info->height[i] = codec_.height *
560 svc_internal_.svc_params.scaling_factor_num[i] / 557 svc_internal_.svc_params.scaling_factor_num[i] /
561 svc_internal_.svc_params.scaling_factor_den[i]; 558 svc_internal_.svc_params.scaling_factor_den[i];
562 } 559 }
563 if (!vp9_info->flexible_mode) { 560 if (!vp9_info->flexible_mode) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 decoder_ = NULL; 780 decoder_ = NULL;
784 } 781 }
785 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers 782 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers
786 // still referenced externally are deleted once fully released, not returning 783 // still referenced externally are deleted once fully released, not returning
787 // to the pool. 784 // to the pool.
788 frame_buffer_pool_.ClearPool(); 785 frame_buffer_pool_.ClearPool();
789 inited_ = false; 786 inited_ = false;
790 return WEBRTC_VIDEO_CODEC_OK; 787 return WEBRTC_VIDEO_CODEC_OK;
791 } 788 }
792 } // namespace webrtc 789 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698