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

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: Updating flag descriptions 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 26 matching lines...) Expand all
397 // log2 unit: e.g., 0 = 1 tile column, 1 = 2 tile columns, 2 = 4 tile columns. 392 // log2 unit: e.g., 0 = 1 tile column, 1 = 2 tile columns, 2 = 4 tile columns.
398 // The number tile columns will be capped by the encoder based on image size 393 // The number tile columns will be capped by the encoder based on image size
399 // (minimum width of tile column is 256 pixels, maximum is 4096). 394 // (minimum width of tile column is 256 pixels, maximum is 4096).
400 vpx_codec_control(encoder_, VP9E_SET_TILE_COLUMNS, (config_->g_threads >> 1)); 395 vpx_codec_control(encoder_, VP9E_SET_TILE_COLUMNS, (config_->g_threads >> 1));
401 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) 396 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64)
402 // Note denoiser is still off by default until further testing/optimization, 397 // Note denoiser is still off by default until further testing/optimization,
403 // i.e., codecSpecific.VP9.denoisingOn == 0. 398 // i.e., codecSpecific.VP9.denoisingOn == 0.
404 vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY, 399 vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY,
405 inst->codecSpecific.VP9.denoisingOn ? 1 : 0); 400 inst->codecSpecific.VP9.denoisingOn ? 1 : 0);
406 #endif 401 #endif
402 if (codec_.mode == kScreensharing) {
403 vpx_codec_control(encoder_, VP9E_SET_TUNE_CONTENT, 1);
404 }
405 vpx_codec_control(encoder_, VP8E_SET_STATIC_THRESHOLD, 1);
407 inited_ = true; 406 inited_ = true;
408 return WEBRTC_VIDEO_CODEC_OK; 407 return WEBRTC_VIDEO_CODEC_OK;
409 } 408 }
410 409
411 uint32_t VP9EncoderImpl::MaxIntraTarget(uint32_t optimal_buffer_size) { 410 uint32_t VP9EncoderImpl::MaxIntraTarget(uint32_t optimal_buffer_size) {
412 // Set max to the optimal buffer level (normalized by target BR), 411 // Set max to the optimal buffer level (normalized by target BR),
413 // and scaled by a scale_par. 412 // and scaled by a scale_par.
414 // Max target size = scale_par * optimal_buffer_size * targetBR[Kbps]. 413 // Max target size = scale_par * optimal_buffer_size * targetBR[Kbps].
415 // This value is presented in percentage of perFrameBw: 414 // This value is presented in percentage of perFrameBw:
416 // perFrameBw = targetBR[Kbps] * 1000 / framerate. 415 // perFrameBw = targetBR[Kbps] * 1000 / framerate.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 532
534 vp9_info->picture_id = picture_id_; 533 vp9_info->picture_id = picture_id_;
535 534
536 if (!vp9_info->flexible_mode) { 535 if (!vp9_info->flexible_mode) {
537 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) { 536 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) {
538 tl0_pic_idx_++; 537 tl0_pic_idx_++;
539 } 538 }
540 vp9_info->tl0_pic_idx = tl0_pic_idx_; 539 vp9_info->tl0_pic_idx = tl0_pic_idx_;
541 } 540 }
542 541
542 // Always populate this, so that packetizer can properly set the marker bit.
543 vp9_info->num_spatial_layers = num_spatial_layers_;
543 if (vp9_info->ss_data_available) { 544 if (vp9_info->ss_data_available) {
544 vp9_info->num_spatial_layers = num_spatial_layers_;
545 vp9_info->spatial_layer_resolution_present = true; 545 vp9_info->spatial_layer_resolution_present = true;
546 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { 546 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) {
547 vp9_info->width[i] = codec_.width * 547 vp9_info->width[i] = codec_.width *
548 svc_internal_.svc_params.scaling_factor_num[i] / 548 svc_internal_.svc_params.scaling_factor_num[i] /
549 svc_internal_.svc_params.scaling_factor_den[i]; 549 svc_internal_.svc_params.scaling_factor_den[i];
550 vp9_info->height[i] = codec_.height * 550 vp9_info->height[i] = codec_.height *
551 svc_internal_.svc_params.scaling_factor_num[i] / 551 svc_internal_.svc_params.scaling_factor_num[i] /
552 svc_internal_.svc_params.scaling_factor_den[i]; 552 svc_internal_.svc_params.scaling_factor_den[i];
553 } 553 }
554 if (!vp9_info->flexible_mode) { 554 if (!vp9_info->flexible_mode) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 decoder_ = NULL; 775 decoder_ = NULL;
776 } 776 }
777 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers 777 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers
778 // still referenced externally are deleted once fully released, not returning 778 // still referenced externally are deleted once fully released, not returning
779 // to the pool. 779 // to the pool.
780 frame_buffer_pool_.ClearPool(); 780 frame_buffer_pool_.ClearPool();
781 inited_ = false; 781 inited_ = false;
782 return WEBRTC_VIDEO_CODEC_OK; 782 return WEBRTC_VIDEO_CODEC_OK;
783 } 783 }
784 } // namespace webrtc 784 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698