summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@hotmail.com>2020-05-29 16:40:20 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-06-05 08:42:35 +0000
commit5c67bdaf63edd6451dafd1c4bf946a825b099fa1 (patch)
treefacb6e925f0795b4540d06b5f0ad67e66581a335 /gst-libs
parenta2063083a5fc7ce998b06fb876e1b780214cac8a (diff)
libs: encoder: h265: Use correct index for SubWidthC and SubHeightC.
We need to use the chroma_format_idc as the index for getting the SubWidthC and SubHeightC values as the spec 6.1(table 6-1) defines. The wrong SubWidthC or SubHeightC make us calculate a wrong right or bottom offset for crop size and generate garbage in output. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_h265.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
index bee501f2..dd785f4c 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ -2712,17 +2712,22 @@ gst_vaapi_encoder_h265_reconfigure (GstVaapiEncoder * base_encoder)
/* Frame Cropping */
if ((GST_VAAPI_ENCODER_WIDTH (encoder) & 15) ||
(GST_VAAPI_ENCODER_HEIGHT (encoder) & 15)) {
+ /* 6.1, Table 6-1 */
static const guint SubWidthC[] = { 1, 2, 2, 1 };
static const guint SubHeightC[] = { 1, 2, 1, 1 };
+ guint index = gst_vaapi_utils_h265_get_chroma_format_idc
+ (gst_vaapi_video_format_get_chroma_type (GST_VIDEO_INFO_FORMAT
+ (GST_VAAPI_ENCODER_VIDEO_INFO (encoder))));
+
encoder->conformance_window_flag = 1;
encoder->conf_win_left_offset = 0;
encoder->conf_win_right_offset =
(encoder->luma_width -
- GST_VAAPI_ENCODER_WIDTH (encoder)) / SubWidthC[1];
+ GST_VAAPI_ENCODER_WIDTH (encoder)) / SubWidthC[index];
encoder->conf_win_top_offset = 0;
encoder->conf_win_bottom_offset =
(encoder->luma_height -
- GST_VAAPI_ENCODER_HEIGHT (encoder)) / SubHeightC[1];
+ GST_VAAPI_ENCODER_HEIGHT (encoder)) / SubHeightC[index];
}
}