Chromium Code Reviews

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: Fixing unit tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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 if (inst->codecSpecific.VP9.numberOfSpatialLayers > 2) {
sprang_webrtc 2015/08/13 13:52:07 Add comment that libvpx currently only supports tw
ivica 2015/08/13 15:20:30 Done.
216 if (inst->codecSpecific.VP9.numberOfSpatialLayers != 1) {
217 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 216 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
218 } 217 }
219 int retVal = Release(); 218 int retVal = Release();
220 if (retVal < 0) { 219 if (retVal < 0) {
221 return retVal; 220 return retVal;
222 } 221 }
223 if (encoder_ == NULL) { 222 if (encoder_ == NULL) {
224 encoder_ = new vpx_codec_ctx_t; 223 encoder_ = new vpx_codec_ctx_t;
225 } 224 }
226 if (config_ == NULL) { 225 if (config_ == NULL) {
(...skipping 117 matching lines...)
344 return 4; 343 return 4;
345 } else if (width * height >= 640 * 480 && number_of_cores > 2) { 344 } else if (width * height >= 640 * 480 && number_of_cores > 2) {
346 return 2; 345 return 2;
347 } else { 346 } else {
348 // 1 thread less than VGA. 347 // 1 thread less than VGA.
349 return 1; 348 return 1;
350 } 349 }
351 } 350 }
352 351
353 int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) { 352 int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) {
354
355 config_->ss_number_layers = num_spatial_layers_; 353 config_->ss_number_layers = num_spatial_layers_;
356 354
357 if (num_spatial_layers_ > 1) { 355 if (num_spatial_layers_ > 1) {
358 config_->rc_min_quantizer = 0; 356 config_->rc_min_quantizer = 0;
359 config_->rc_max_quantizer = 63; 357 config_->rc_max_quantizer = 52;
360 } 358 }
361 int scaling_factor_num = 256; 359 int scaling_factor_num = 256;
362 for (int i = num_spatial_layers_ - 1; i >= 0; --i) { 360 for (int i = num_spatial_layers_ - 1; i >= 0; --i) {
363 svc_internal_.svc_params.max_quantizers[i] = config_->rc_max_quantizer; 361 svc_internal_.svc_params.max_quantizers[i] = config_->rc_max_quantizer;
364 svc_internal_.svc_params.min_quantizers[i] = config_->rc_min_quantizer; 362 svc_internal_.svc_params.min_quantizers[i] = config_->rc_min_quantizer;
365 // 1:2 scaling in each dimension. 363 // 1:2 scaling in each dimension.
366 svc_internal_.svc_params.scaling_factor_num[i] = scaling_factor_num; 364 svc_internal_.svc_params.scaling_factor_num[i] = scaling_factor_num;
367 svc_internal_.svc_params.scaling_factor_den[i] = 256; 365 svc_internal_.svc_params.scaling_factor_den[i] = 256;
368 scaling_factor_num /= 2; 366 scaling_factor_num /= 2;
369 } 367 }
(...skipping 27 matching lines...)
397 // log2 unit: e.g., 0 = 1 tile column, 1 = 2 tile columns, 2 = 4 tile columns. 395 // 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 396 // 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). 397 // (minimum width of tile column is 256 pixels, maximum is 4096).
400 vpx_codec_control(encoder_, VP9E_SET_TILE_COLUMNS, (config_->g_threads >> 1)); 398 vpx_codec_control(encoder_, VP9E_SET_TILE_COLUMNS, (config_->g_threads >> 1));
401 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) 399 #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64)
402 // Note denoiser is still off by default until further testing/optimization, 400 // Note denoiser is still off by default until further testing/optimization,
403 // i.e., codecSpecific.VP9.denoisingOn == 0. 401 // i.e., codecSpecific.VP9.denoisingOn == 0.
404 vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY, 402 vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY,
405 inst->codecSpecific.VP9.denoisingOn ? 1 : 0); 403 inst->codecSpecific.VP9.denoisingOn ? 1 : 0);
406 #endif 404 #endif
405 if (codec_.mode == kScreensharing) {
406 vpx_codec_control(encoder_, VP9E_SET_TUNE_CONTENT, 1);
407 }
408 vpx_codec_control(encoder_, VP8E_SET_STATIC_THRESHOLD, 1);
407 inited_ = true; 409 inited_ = true;
408 return WEBRTC_VIDEO_CODEC_OK; 410 return WEBRTC_VIDEO_CODEC_OK;
409 } 411 }
410 412
411 uint32_t VP9EncoderImpl::MaxIntraTarget(uint32_t optimal_buffer_size) { 413 uint32_t VP9EncoderImpl::MaxIntraTarget(uint32_t optimal_buffer_size) {
412 // Set max to the optimal buffer level (normalized by target BR), 414 // Set max to the optimal buffer level (normalized by target BR),
413 // and scaled by a scale_par. 415 // and scaled by a scale_par.
414 // Max target size = scale_par * optimal_buffer_size * targetBR[Kbps]. 416 // Max target size = scale_par * optimal_buffer_size * targetBR[Kbps].
415 // This value is presented in percentage of perFrameBw: 417 // This value is presented in percentage of perFrameBw:
416 // perFrameBw = targetBR[Kbps] * 1000 / framerate. 418 // perFrameBw = targetBR[Kbps] * 1000 / framerate.
(...skipping 116 matching lines...)
533 535
534 vp9_info->picture_id = picture_id_; 536 vp9_info->picture_id = picture_id_;
535 537
536 if (!vp9_info->flexible_mode) { 538 if (!vp9_info->flexible_mode) {
537 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) { 539 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) {
538 tl0_pic_idx_++; 540 tl0_pic_idx_++;
539 } 541 }
540 vp9_info->tl0_pic_idx = tl0_pic_idx_; 542 vp9_info->tl0_pic_idx = tl0_pic_idx_;
541 } 543 }
542 544
545 // Always populate this, so that packetizer can properly set the marker bit.
546 vp9_info->num_spatial_layers = num_spatial_layers_;
543 if (vp9_info->ss_data_available) { 547 if (vp9_info->ss_data_available) {
544 vp9_info->num_spatial_layers = num_spatial_layers_;
545 vp9_info->spatial_layer_resolution_present = true; 548 vp9_info->spatial_layer_resolution_present = true;
546 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { 549 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) {
547 vp9_info->width[i] = codec_.width * 550 vp9_info->width[i] = codec_.width *
548 svc_internal_.svc_params.scaling_factor_num[i] / 551 svc_internal_.svc_params.scaling_factor_num[i] /
549 svc_internal_.svc_params.scaling_factor_den[i]; 552 svc_internal_.svc_params.scaling_factor_den[i];
550 vp9_info->height[i] = codec_.height * 553 vp9_info->height[i] = codec_.height *
551 svc_internal_.svc_params.scaling_factor_num[i] / 554 svc_internal_.svc_params.scaling_factor_num[i] /
552 svc_internal_.svc_params.scaling_factor_den[i]; 555 svc_internal_.svc_params.scaling_factor_den[i];
553 } 556 }
554 if (!vp9_info->flexible_mode) { 557 if (!vp9_info->flexible_mode) {
(...skipping 220 matching lines...)
775 decoder_ = NULL; 778 decoder_ = NULL;
776 } 779 }
777 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers 780 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers
778 // still referenced externally are deleted once fully released, not returning 781 // still referenced externally are deleted once fully released, not returning
779 // to the pool. 782 // to the pool.
780 frame_buffer_pool_.ClearPool(); 783 frame_buffer_pool_.ClearPool();
781 inited_ = false; 784 inited_ = false;
782 return WEBRTC_VIDEO_CODEC_OK; 785 return WEBRTC_VIDEO_CODEC_OK;
783 } 786 }
784 } // namespace webrtc 787 } // namespace webrtc
OLDNEW

Powered by Google App Engine