mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 23:08:18 +02:00
radeonsi: fix conformance window emission in the SPS
If the vaapi application submits SPS with pic_width_in_luma_samples not aligned to be divisible by 64, the driver overwrites it to an aligned value. But if it does so, then it should also recalculate the conformance window. Example from real life: gstreamer vah265enc built with libva < 1.21 or vaapih265enc transcoding a video of width == 854 gst-launch-1.0 uridecodebin uri=https://media.w3.org/2010/05/sintel/trailer.mp4 ! vaapih265enc ! filesink location=out.h265 The code uploads an SPS with pic_width_in_luma_samples == 864, and the driver overwrites it to 896. The conformance window provided in the SPS was 10 : 864 - 10 = 854. So after encoding the output width results in a wrong value: 896 - 10 = 886 Reviewed-by: David Rosca <david.rosca@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41997>
This commit is contained in:
parent
e984014d56
commit
7e040483ec
1 changed files with 24 additions and 2 deletions
|
|
@ -203,8 +203,30 @@ unsigned int radeon_enc_write_sps(struct radeon_encoder *enc, uint8_t nal_byte,
|
|||
unsigned int radeon_enc_write_sps_hevc(struct radeon_encoder *enc, uint8_t *out)
|
||||
{
|
||||
struct pipe_h265_enc_seq_param sps = enc->enc_pic.hevc.desc->seq;
|
||||
sps.pic_width_in_luma_samples = enc->enc_pic.session_init.aligned_picture_width;
|
||||
sps.pic_height_in_luma_samples = enc->enc_pic.session_init.aligned_picture_height;
|
||||
|
||||
int width_correction = enc->enc_pic.session_init.aligned_picture_width - sps.pic_width_in_luma_samples;
|
||||
int height_correction = enc->enc_pic.session_init.aligned_picture_height - sps.pic_height_in_luma_samples;
|
||||
sps.pic_width_in_luma_samples += width_correction;
|
||||
sps.pic_height_in_luma_samples += height_correction;
|
||||
|
||||
if (width_correction != 0 ||
|
||||
height_correction != 0) {
|
||||
const int chroma_idc_div = 2;
|
||||
int wcrop_correction = width_correction / chroma_idc_div;
|
||||
int hcrop_correction = height_correction / chroma_idc_div;
|
||||
|
||||
if (sps.conformance_window_flag) {
|
||||
sps.conf_win_right_offset += wcrop_correction;
|
||||
sps.conf_win_bottom_offset += hcrop_correction;
|
||||
} else {
|
||||
sps.conformance_window_flag = 1;
|
||||
sps.conf_win_left_offset = 0;
|
||||
sps.conf_win_right_offset = wcrop_correction;
|
||||
sps.conf_win_top_offset = 0;
|
||||
sps.conf_win_bottom_offset = hcrop_correction;
|
||||
}
|
||||
}
|
||||
|
||||
sps.log2_min_luma_coding_block_size_minus3 =
|
||||
enc->enc_pic.hevc_spec_misc.log2_min_luma_coding_block_size_minus3;
|
||||
sps.log2_diff_max_min_luma_coding_block_size = 6 - (sps.log2_min_luma_coding_block_size_minus3 + 3);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue