diff options
author | He Junyan <junyan.he@hotmail.com> | 2020-03-05 17:29:41 +0800 |
---|---|---|
committer | He Junyan <junyan.he@hotmail.com> | 2020-06-05 19:27:42 +0800 |
commit | 71db3572845a968151b55b79baaa7370b572b621 (patch) | |
tree | 15adf20c00e27d9d496799e6d1db6429bdd30dc8 /gst-libs | |
parent | 812c9fdea7f6f26e6ae5162d753dc0313e601ac5 (diff) |
libs: encoder: h265: promote level if tile is enabled.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder_h265.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c index 1e3d47eb..37143ea1 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c @@ -178,6 +178,12 @@ h265_get_slice_type (GstVaapiPictureType type) return -1; } +static gboolean +h265_is_tile_enabled (GstVaapiEncoderH265 * encoder) +{ + return encoder->num_tile_cols * encoder->num_tile_rows > 1; +} + /* Get log2_max_pic_order_cnt value for H.265 specification */ static guint h265_get_log2_max_pic_order_cnt (guint num) @@ -1148,6 +1154,7 @@ ensure_tier_level (GstVaapiEncoderH265 * encoder) guint i, num_limits, PicSizeInSamplesY; guint LumaSr; const GstVaapiH265LevelLimits *limits_table; + const GstVaapiH265LevelLimits *limits; PicSizeInSamplesY = encoder->luma_width * encoder->luma_height; LumaSr = @@ -1156,7 +1163,7 @@ ensure_tier_level (GstVaapiEncoderH265 * encoder) limits_table = gst_vaapi_utils_h265_get_level_limits_table (&num_limits); for (i = 0; i < num_limits; i++) { - const GstVaapiH265LevelLimits *const limits = &limits_table[i]; + limits = &limits_table[i]; /* Choose level by luma picture size and luma sample rate */ if (PicSizeInSamplesY <= limits->MaxLumaPs && LumaSr <= limits->MaxLumaSr) break; @@ -1165,6 +1172,19 @@ ensure_tier_level (GstVaapiEncoderH265 * encoder) if (i == num_limits) goto error_unsupported_level; + /* may need to promote the level by tile setting */ + if (h265_is_tile_enabled (encoder)) { + for (; i < num_limits; i++) { + limits = &limits_table[i]; + if (encoder->num_tile_cols <= limits->MaxTileColumns && + encoder->num_tile_rows <= limits->MaxTileRows) + break; + } + + if (i == num_limits) + goto error_promote_level; + } + if (bitrate <= limits_table[i].MaxBRTierMain) { encoder->tier = GST_VAAPI_TIER_H265_MAIN; } else { @@ -1185,6 +1205,12 @@ ensure_tier_level (GstVaapiEncoderH265 * encoder) return TRUE; /* ERRORS */ +error_promote_level: + { + GST_ERROR ("failed to promote level for num-tile-cols is %d," + " num-tile-rows %d", encoder->num_tile_cols, encoder->num_tile_rows); + return FALSE; + } error_unsupported_level: { GST_ERROR ("failed to find a suitable level matching codec config"); |