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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc

Issue 1888843002: Use bitstream-level QP for libvpx VP8 quality. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: add comment Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 configurations_[i].rc_target_bitrate = stream_bitrates[stream_idx]; 593 configurations_[i].rc_target_bitrate = stream_bitrates[stream_idx];
594 temporal_layers_[stream_idx]->ConfigureBitrates( 594 temporal_layers_[stream_idx]->ConfigureBitrates(
595 stream_bitrates[stream_idx], inst->maxBitrate, inst->maxFramerate, 595 stream_bitrates[stream_idx], inst->maxBitrate, inst->maxFramerate,
596 &configurations_[i]); 596 &configurations_[i]);
597 } 597 }
598 } 598 }
599 599
600 rps_.Init(); 600 rps_.Init();
601 // Disable both high-QP limits and framedropping. Both are handled by libvpx 601 // Disable both high-QP limits and framedropping. Both are handled by libvpx
602 // internally. 602 // internally.
603 const int kLowQpThreshold = 18; 603 // QP thresholds are chosen to be high enough to be hit in practice when
604 const int kDisabledBadQpThreshold = 64; 604 // quality is good, but also low enough to not cause a flip-flop behavior
605 // (e.g. going up in resolution shouldn't give so bad quality that we should
606 // go back down).
607 const int kLowQpThreshold = 23;
608 const int kDisabledBadQpThreshold = 128;
605 // TODO(glaznev/sprang): consider passing codec initial bitrate to quality 609 // TODO(glaznev/sprang): consider passing codec initial bitrate to quality
606 // scaler to avoid starting with HD for low initial bitrates. 610 // scaler to avoid starting with HD for low initial bitrates.
607 quality_scaler_.Init(kLowQpThreshold, kDisabledBadQpThreshold, false, 0, 0, 0, 611 quality_scaler_.Init(kLowQpThreshold, kDisabledBadQpThreshold, false, 0, 0, 0,
608 codec_.maxFramerate); 612 codec_.maxFramerate);
609 613
610 // Only apply scaling to improve for single-layer streams. The scaling metrics 614 // Only apply scaling to improve for single-layer streams. The scaling metrics
611 // use frame drops as a signal and is only applicable when we drop frames. 615 // use frame drops as a signal and is only applicable when we drop frames.
612 quality_scaler_enabled_ = encoders_.size() == 1 && 616 quality_scaler_enabled_ = encoders_.size() == 1 &&
613 configurations_[0].rc_dropframe_thresh > 0 && 617 configurations_[0].rc_dropframe_thresh > 0 &&
614 codec_.codecSpecific.VP8.automaticResizeOn; 618 codec_.codecSpecific.VP8.automaticResizeOn;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 encoded_images_[encoder_idx].qp_ = qp_128; 1050 encoded_images_[encoder_idx].qp_ = qp_128;
1047 encoded_complete_callback_->Encoded(encoded_images_[encoder_idx], 1051 encoded_complete_callback_->Encoded(encoded_images_[encoder_idx],
1048 &codec_specific, &frag_info); 1052 &codec_specific, &frag_info);
1049 } else if (codec_.mode == kScreensharing) { 1053 } else if (codec_.mode == kScreensharing) {
1050 result = WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT; 1054 result = WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT;
1051 } 1055 }
1052 } 1056 }
1053 } 1057 }
1054 if (encoders_.size() == 1 && send_stream_[0]) { 1058 if (encoders_.size() == 1 && send_stream_[0]) {
1055 if (encoded_images_[0]._length > 0) { 1059 if (encoded_images_[0]._length > 0) {
1056 int qp; 1060 int qp_128;
1057 vpx_codec_control(&encoders_[0], VP8E_GET_LAST_QUANTIZER_64, &qp); 1061 vpx_codec_control(&encoders_[0], VP8E_GET_LAST_QUANTIZER, &qp_128);
1058 quality_scaler_.ReportQP(qp); 1062 quality_scaler_.ReportQP(qp_128);
1059 } else { 1063 } else {
1060 quality_scaler_.ReportDroppedFrame(); 1064 quality_scaler_.ReportDroppedFrame();
1061 } 1065 }
1062 } 1066 }
1063 return result; 1067 return result;
1064 } 1068 }
1065 1069
1066 int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { 1070 int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int64_t rtt) {
1067 rps_.SetRtt(rtt); 1071 rps_.SetRtt(rtt);
1068 return WEBRTC_VIDEO_CODEC_OK; 1072 return WEBRTC_VIDEO_CODEC_OK;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 return -1; 1413 return -1;
1410 } 1414 }
1411 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != 1415 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) !=
1412 VPX_CODEC_OK) { 1416 VPX_CODEC_OK) {
1413 return -1; 1417 return -1;
1414 } 1418 }
1415 return 0; 1419 return 0;
1416 } 1420 }
1417 1421
1418 } // namespace webrtc 1422 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698