gallium: add new variable for video frame statistics
authorThong Thai <thong.thai@amd.com>
Tue, 6 Dec 2022 21:02:42 +0000 (16:02 -0500)
committerThong Thai <thong.thai@amd.com>
Fri, 9 Dec 2022 18:37:00 +0000 (13:37 -0500)
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 <thong.thai@amd.com>
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20190>

src/gallium/drivers/radeonsi/radeon_vcn_enc.c
src/gallium/frontends/va/picture.c
src/gallium/include/pipe/p_video_codec.h

index 6c53d9b..67fb349 100644 (file)
@@ -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;
index 4d66431..b196906 100644 (file)
@@ -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;
 }
index 3a8a960..e13dc5d 100644 (file)
@@ -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