frontends/va: add num_temporal_layers check
authorBoyuan Zhang <boyuan.zhang@amd.com>
Thu, 19 Aug 2021 02:47:05 +0000 (22:47 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Aug 2021 14:25:09 +0000 (14:25 +0000)
Fixes: 51935d59

temporal_id check is valid only if the num_temporal_layers is set (>0).
When num_temporal_layers is 0, we shouldn't check temporal_id and return
error.

Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12463>

src/gallium/frontends/va/picture_h264_enc.c

index 18890ae..466b920 100644 (file)
@@ -157,7 +157,8 @@ vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscP
       context->desc.h264enc.rate_ctrl[temporal_id].target_bitrate =
          rc->bits_per_second * (rc->target_percentage / 100.0);
 
-   if (temporal_id >= context->desc.h264enc.num_temporal_layers)
+   if (context->desc.h264enc.num_temporal_layers > 0 &&
+       temporal_id >= context->desc.h264enc.num_temporal_layers)
       return VA_STATUS_ERROR_INVALID_PARAMETER;
 
    context->desc.h264enc.rate_ctrl[temporal_id].peak_bitrate = rc->bits_per_second;