radeonsi/vcn: remove extra zero bytes from bitstream
authorRuijing Dong <ruijing.dong@amd.com>
Wed, 19 Apr 2023 01:19:35 +0000 (21:19 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 27 Apr 2023 15:11:35 +0000 (15:11 +0000)
reason:
   extra bytes are not needed and not necessary
   in h264/h265 bitstreams, because they are in
   between NALs, the only problem is they consumed
   extra bits. And for av1 streams, that could be
   explained to something else, especially in
   multi-layer cases, that can cause syntax errors.

   ptr[6] represents the bitstream size,
   ptr[8] represents the extra zero bytes.

   The total number of bytes of the output
   should be ptr[6] - ptr[8]

Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Signed-off-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22585>

src/gallium/drivers/radeonsi/radeon_vcn_enc.c

index 63af54a..95c9364 100644 (file)
@@ -734,7 +734,7 @@ static void radeon_enc_get_feedback(struct pipe_video_codec *encoder, void *feed
       uint32_t *ptr = enc->ws->buffer_map(enc->ws, fb->res->buf, &enc->cs,
                                           PIPE_MAP_READ_WRITE | RADEON_MAP_TEMPORARY);
       if (ptr[1])
-         *size = ptr[6];
+         *size = ptr[6] - ptr[8];
       else
          *size = 0;
       enc->ws->buffer_unmap(enc->ws, fb->res->buf);