From 6531f060dd75efe830e07a8c1f54a07818abf49c Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 10 Oct 2025 09:26:31 +0200 Subject: [PATCH] frontends/va: Fix parsing VP9 frame header Fix parsing intra only frames with profile 0. Change type to signed int and initialize default values for ref_deltas and mode_deltas. Cc: mesa-stable Reviewed-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/picture_vp9.c | 17 ++++++++++++++--- src/gallium/include/pipe/p_video_state.h | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/va/picture_vp9.c b/src/gallium/frontends/va/picture_vp9.c index 11206f66851..09392bb4276 100644 --- a/src/gallium/frontends/va/picture_vp9.c +++ b/src/gallium/frontends/va/picture_vp9.c @@ -230,7 +230,7 @@ void vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf) { struct vl_vlc vlc; unsigned profile; - bool frame_type, show_frame, error_resilient_mode; + bool frame_type, show_frame, error_resilient_mode, intra_only = false; bool mode_ref_delta_enabled, mode_ref_delta_update = false; int i; @@ -265,7 +265,7 @@ void vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf) bitdepth_colorspace_sampling(&vlc, profile); frame_size(&vlc); } else { - bool intra_only, size_in_refs = false; + bool size_in_refs = false; intra_only = show_frame ? 0 : vp9_u(&vlc, 1); if (!error_resilient_mode) @@ -277,7 +277,8 @@ void vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf) if (vp9_u(&vlc, 24) != 0x498342) return; - bitdepth_colorspace_sampling(&vlc, profile); + if (profile > 0) + bitdepth_colorspace_sampling(&vlc, profile); /* refresh_frame_flags */ vp9_u(&vlc, 8); frame_size(&vlc); @@ -333,6 +334,16 @@ void vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf) /* sharpness_level */ vp9_u(&vlc, 3); + if (frame_type == 0 || intra_only || error_resilient_mode) { + context->desc.vp9.picture_parameter.ref_deltas[0] = 1; + context->desc.vp9.picture_parameter.ref_deltas[1] = 0; + context->desc.vp9.picture_parameter.ref_deltas[2] = -1; + context->desc.vp9.picture_parameter.ref_deltas[3] = -1; + + context->desc.vp9.picture_parameter.mode_deltas[0] = 0; + context->desc.vp9.picture_parameter.mode_deltas[1] = 0; + } + mode_ref_delta_enabled = vp9_u(&vlc, 1); if (mode_ref_delta_enabled) { mode_ref_delta_update = vp9_u(&vlc, 1); diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 59b68f7dbad..27d1e82dd8d 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -1965,8 +1965,8 @@ struct pipe_vp9_picture_desc int8_t uv_ac_delta_q; int8_t uv_dc_delta_q; uint8_t abs_delta; - uint8_t ref_deltas[4]; - uint8_t mode_deltas[2]; + int8_t ref_deltas[4]; + int8_t mode_deltas[2]; } picture_parameter; struct {