From 2d4a36ce64791971c2abe0280778a7d7555bb273 Mon Sep 17 00:00:00 2001 From: Thong Thai Date: Tue, 6 Dec 2022 16:02:42 -0500 Subject: [PATCH] gallium: add new variable for video frame statistics Video encoder previously reuses the associated_data variable to output encoding statistics, but it ended up breaking when transcoding. This commit adds a new variable just for statistics. Fixes: 2d1bd619dfd ("frontends/va: add ability for encoder to output statistics") Signed-off-by: Thong Thai Reviewed-by: Boyuan Zhang Part-of: --- src/gallium/drivers/radeonsi/radeon_vcn_enc.c | 6 +++--- src/gallium/frontends/va/picture.c | 2 +- src/gallium/include/pipe/p_video_codec.h | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c index 6c53d9ba512..67fb349d9fe 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c @@ -620,13 +620,13 @@ static void radeon_enc_encode_bitstream(struct pipe_video_codec *encoder, return; } - if (vid_buf->base.associated_data) { - enc->get_buffer(vid_buf->base.associated_data, &enc->stats, NULL); + if (vid_buf->base.statistics_data) { + enc->get_buffer(vid_buf->base.statistics_data, &enc->stats, NULL); if (enc->stats->size < sizeof(rvcn_encode_stats_type_0_t)) { RVID_ERR("Encoder statistics output buffer is too small.\n"); enc->stats = NULL; } - vid_buf->base.associated_data = NULL; + vid_buf->base.statistics_data = NULL; } else enc->stats = NULL; diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index 4d66431eab3..b19690603f1 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -702,7 +702,7 @@ handleVAStatsStatisticsBufferType(VADriverContextP ctx, vlVaContext *context, vl buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM, buf->size); - context->target->associated_data = buf->derived_surface.resource; + context->target->statistics_data = buf->derived_surface.resource; return VA_STATUS_SUCCESS; } diff --git a/src/gallium/include/pipe/p_video_codec.h b/src/gallium/include/pipe/p_video_codec.h index 3a8a9604b09..e13dc5d4786 100644 --- a/src/gallium/include/pipe/p_video_codec.h +++ b/src/gallium/include/pipe/p_video_codec.h @@ -168,6 +168,11 @@ struct pipe_video_buffer * destroy the associated data */ void (*destroy_associated_data)(void *associated_data); + + /* + * encoded frame statistics for this particular picture + */ + void *statistics_data; }; #ifdef __cplusplus