fix[h265d]: Fix conformance window offsets for chroma formats

- Correctly apply conformance window offsets based on chroma_format_idc
- For YUV 4:0:0 (chroma_format_idc == 0), no offset scaling is needed
  as there is no chroma component
- For YUV 4:2:0 (chroma_format_idc == 1), apply * 2 to both horizontal
  and vertical offsets
- For YUV 4:2:2 (chroma_format_idc == 2), apply * 2 only to horizontal
  offsets
- For YUV 4:4:4 (chroma_format_idc == 3), no offset scaling is needed
- Ensured the output window accurately reflects the cropping adjustments
  for different chroma subsampling formats

Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
Change-Id: I90c7e61487a1638d5ba296f1d95de4792fcb2104
This commit is contained in:
Rimon Xu 2024-09-18 15:32:38 +08:00
parent fdb674ab01
commit 5acf49c633

View File

@ -1238,18 +1238,21 @@ static RK_S32 decode_vui(HEVCContext *s, HEVCSPS *sps)
READ_ONEBIT(gb, &vui->default_display_window_flag);
if (vui->default_display_window_flag) {
//TODO: * 2 is only valid for 420
READ_UE(gb, &vui->def_disp_win.left_offset);
vui->def_disp_win.left_offset = vui->def_disp_win.left_offset * 2;
READ_UE(gb, &vui->def_disp_win.right_offset);
vui->def_disp_win.right_offset = vui->def_disp_win.right_offset * 2;
READ_UE(gb, &vui->def_disp_win.right_offset);
vui->def_disp_win.top_offset = vui->def_disp_win.top_offset * 2;
READ_UE(gb, &vui->def_disp_win.right_offset);
vui->def_disp_win.bottom_offset = vui->def_disp_win.bottom_offset * 2;
READ_UE(gb, &vui->def_disp_win.top_offset);
READ_UE(gb, &vui->def_disp_win.bottom_offset);
if (sps) {
if (sps->chroma_format_idc == H265_CHROMA_420) {
vui->def_disp_win.left_offset *= 2;
vui->def_disp_win.right_offset *= 2;
vui->def_disp_win.top_offset *= 2;
vui->def_disp_win.bottom_offset *= 2;
} else if (sps->chroma_format_idc == H265_CHROMA_422) {
vui->def_disp_win.left_offset *= 2;
vui->def_disp_win.right_offset *= 2;
}
}
#if 0
if (s->apply_defdispwin &&
@ -1471,15 +1474,19 @@ RK_S32 mpp_hevc_decode_nal_sps(HEVCContext *s)
READ_ONEBIT(gb, &value);
if (value) { // pic_conformance_flag
//TODO: * 2 is only valid for 420
READ_UE(gb, &sps->pic_conf_win.left_offset);
sps->pic_conf_win.left_offset = sps->pic_conf_win.left_offset * 2;
READ_UE(gb, &sps->pic_conf_win.right_offset);
sps->pic_conf_win.right_offset = sps->pic_conf_win.right_offset * 2;
READ_UE(gb, &sps->pic_conf_win.top_offset);
sps->pic_conf_win.top_offset = sps->pic_conf_win.top_offset * 2;
READ_UE(gb, &sps->pic_conf_win.bottom_offset);
sps->pic_conf_win.bottom_offset = sps->pic_conf_win.bottom_offset * 2;
if (sps->chroma_format_idc == H265_CHROMA_420) {
sps->pic_conf_win.left_offset *= 2;
sps->pic_conf_win.right_offset *= 2;
sps->pic_conf_win.top_offset *= 2;
sps->pic_conf_win.bottom_offset *= 2;
} else if (sps->chroma_format_idc == H265_CHROMA_422) {
sps->pic_conf_win.left_offset *= 2;
sps->pic_conf_win.right_offset *= 2;
}
sps->output_window = sps->pic_conf_win;
}