Commit ebff6022 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

Reland "media/gpu/vaapi: Fill min and max qp in VAEncMiscParameterRateControl"

This is a reland of f20690e8

Original change's description:
> media/gpu/vaapi: Fill min and max qp in VAEncMiscParameterRateControl
>
> VAEncMiscParameterRateControl has parameters about minimum and
> maximum of quantization values. These values should be filled.
>
> Bug: 1034382
> Test: VEA test on atlas
> Change-Id: I185b3e710c05095313aa71bc9fe90b23c8885345
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969196
> Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Miguel Casas <mcasas@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#726700}

Bug: 1034382, b:146838257
Test: android.media.cts.MediaRecorderTest#testProfileAvcBaselineLevel1
Test: video.EncodeAccel.h264_180p_i420 and video.EncodeAccel.h264_1080p_i420
Change-Id: Ibeb8310d1f260353fcf9593e7a40e62a19bc119a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1982336
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarChih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727447}
parent 54ff3cc0
......@@ -17,7 +17,13 @@ constexpr int kIDRPeriod = 2048;
constexpr int kIPeriod = 0;
constexpr int kIPPeriod = 1;
// The qp range is 0-51 in H264. Select 26 because of the center value.
constexpr int kDefaultQP = 26;
// Note: Webrtc default values are 24 and 37 respectively, see
// h264_encoder_impl.cc.
// These values are selected to make our VEA tests pass.
constexpr int kMinQP = 24;
constexpr int kMaxQP = 42;
// Subjectively chosen bitrate window size for rate control, in ms.
constexpr int kCPBWindowSizeMs = 1500;
......@@ -43,7 +49,9 @@ H264Encoder::EncodeParams::EncodeParams()
framerate(0),
cpb_window_size_ms(kCPBWindowSizeMs),
cpb_size_bits(0),
qp(kDefaultQP),
initial_qp(kDefaultQP),
min_qp(kMinQP),
max_qp(kMaxQP),
max_num_ref_frames(kMaxNumReferenceFrames),
max_ref_pic_list0_size(kMaxRefIdxL0Size),
max_ref_pic_list1_size(kMaxRefIdxL1Size) {}
......@@ -376,8 +384,8 @@ void H264Encoder::UpdatePPS() {
curr_params_.max_ref_pic_list1_size > 0
? curr_params_.max_ref_pic_list1_size - 1
: curr_params_.max_ref_pic_list1_size;
DCHECK_LE(curr_params_.qp, 51);
current_pps_.pic_init_qp_minus26 = curr_params_.qp - 26;
DCHECK_LE(curr_params_.initial_qp, 51);
current_pps_.pic_init_qp_minus26 = curr_params_.initial_qp - 26;
current_pps_.deblocking_filter_control_present_flag = true;
current_pps_.transform_8x8_mode_flag =
(current_sps_.profile_idc == H264SPS::kProfileIDCHigh);
......
......@@ -54,7 +54,9 @@ class H264Encoder : public AcceleratedVideoEncoder {
unsigned int cpb_size_bits;
// Quantization parameter.
int qp;
int initial_qp;
int min_qp;
int max_qp;
// Maxium Number of Reference frames.
size_t max_num_ref_frames;
......
......@@ -1075,6 +1075,8 @@ bool VaapiVideoEncodeAccelerator::H264Accelerator::SubmitFrameParameters(
rate_control_param.target_percentage = kTargetBitratePercentage;
rate_control_param.window_size = encode_params.cpb_window_size_ms;
rate_control_param.initial_qp = pic_param.pic_init_qp;
rate_control_param.min_qp = encode_params.min_qp;
rate_control_param.max_qp = encode_params.max_qp;
rate_control_param.rc_flags.bits.disable_frame_skip = true;
VAEncMiscParameterFrameRate framerate_param = {};
......@@ -1285,6 +1287,8 @@ bool VaapiVideoEncodeAccelerator::VP8Accelerator::SubmitFrameParameters(
rate_control_param.target_percentage = kTargetBitratePercentage;
rate_control_param.window_size = encode_params.cpb_window_size_ms;
rate_control_param.initial_qp = encode_params.initial_qp;
rate_control_param.min_qp = encode_params.min_qp;
rate_control_param.max_qp = encode_params.max_qp;
rate_control_param.rc_flags.bits.disable_frame_skip = true;
VAEncMiscParameterFrameRate framerate_param = {};
......@@ -1421,6 +1425,8 @@ bool VaapiVideoEncodeAccelerator::VP9Accelerator::SubmitFrameParameters(
rate_control_param.target_percentage = kTargetBitratePercentage;
rate_control_param.window_size = encode_params.cpb_window_size_ms;
rate_control_param.initial_qp = encode_params.initial_qp;
rate_control_param.min_qp = encode_params.min_qp;
rate_control_param.max_qp = encode_params.max_qp;
rate_control_param.rc_flags.bits.disable_frame_skip = true;
VAEncMiscParameterFrameRate framerate_param = {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment