Mesa (staging/20.1): gallium/vl: add chroma_format arg to vl_video_buffer functions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 29 20:13:00 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 71b3582ec157e7855d20cebf20014e1afe54ece6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=71b3582ec157e7855d20cebf20014e1afe54ece6

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Tue Sep 22 14:32:13 2020 +0200

gallium/vl: add chroma_format arg to vl_video_buffer functions

vl_mpeg12_decoder needs to override the chroma_format value to get the
correct size calculated (chroma_format is used by vl_video_buffer_adjust_size).

I'm not sure why it's needed, but this is needed to get correct mpeg decode.

Fixes: 24f2b0a8560 ("gallium/video: remove pipe_video_buffer.chroma_format")
Acked-by: Leo Liu <leo.liu at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6817>
(cherry picked from commit 2584d48b2cf13ea50b4e6177f32bacf0c7027e79)

---

 .pick_status.json                            |  2 +-
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 13 +++++++------
 src/gallium/auxiliary/vl/vl_stubs.c          |  3 ++-
 src/gallium/auxiliary/vl/vl_video_buffer.c   | 20 +++++++++++++-------
 src/gallium/auxiliary/vl/vl_video_buffer.h   |  6 ++++--
 src/gallium/drivers/r600/r600_uvd.c          | 11 ++++++++---
 6 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 889100f7c9d..a734fabb12d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -22,7 +22,7 @@
         "description": "gallium/vl: add chroma_format arg to vl_video_buffer functions",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "24f2b0a8560f34745854bf8263fa7c2d0f95f2bc"
     },
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index c522498c3e7..d64f2cba143 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -983,28 +983,28 @@ init_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_conf
       nr_of_idct_render_targets = 1;
 
    formats[0] = formats[1] = formats[2] = format_config->idct_source_format;
-   assert(pipe_format_to_chroma_format(formats[0]) == dec->base.chroma_format);
    memset(&templat, 0, sizeof(templat));
    templat.width = dec->base.width / 4;
    templat.height = dec->base.height;
    dec->idct_source = vl_video_buffer_create_ex
    (
       dec->context, &templat,
-      formats, 1, 1, PIPE_USAGE_DEFAULT
+      formats, 1, 1, PIPE_USAGE_DEFAULT,
+      PIPE_VIDEO_CHROMA_FORMAT_420
    );
 
    if (!dec->idct_source)
       goto error_idct_source;
 
    formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
-   assert(pipe_format_to_chroma_format(formats[0]) == dec->base.chroma_format);
    memset(&templat, 0, sizeof(templat));
    templat.width = dec->base.width / nr_of_idct_render_targets;
    templat.height = dec->base.height / 4;
    dec->mc_source = vl_video_buffer_create_ex
    (
       dec->context, &templat,
-      formats, nr_of_idct_render_targets, 1, PIPE_USAGE_DEFAULT
+      formats, nr_of_idct_render_targets, 1, PIPE_USAGE_DEFAULT,
+      PIPE_VIDEO_CHROMA_FORMAT_420
    );
 
    if (!dec->mc_source)
@@ -1055,9 +1055,10 @@ init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_
    dec->mc_source = vl_video_buffer_create_ex
    (
       dec->context, &templat,
-      formats, 1, 1, PIPE_USAGE_DEFAULT
+      formats, 1, 1, PIPE_USAGE_DEFAULT,
+      PIPE_VIDEO_CHROMA_FORMAT_420
    );
-      
+
    return dec->mc_source != NULL;
 }
 
diff --git a/src/gallium/auxiliary/vl/vl_stubs.c b/src/gallium/auxiliary/vl/vl_stubs.c
index befd2468f49..02568ac2843 100644
--- a/src/gallium/auxiliary/vl/vl_stubs.c
+++ b/src/gallium/auxiliary/vl/vl_stubs.c
@@ -85,7 +85,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
                          const struct pipe_video_buffer *tmpl,
                          enum pipe_format resource_format,
                          unsigned depth, unsigned array_size,
-                         unsigned usage, unsigned plane)
+                         unsigned usage, unsigned plane,
+                         enum pipe_video_chroma_format chroma_format)
 {
    assert(0);
 }
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
index f4fac6ca0bc..54cc0c52909 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -169,7 +169,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
                          const struct pipe_video_buffer *tmpl,
                          enum pipe_format resource_format,
                          unsigned depth, unsigned array_size,
-                         unsigned usage, unsigned plane)
+                         unsigned usage, unsigned plane,
+                         enum pipe_video_chroma_format chroma_format)
 {
    unsigned height = tmpl->height;
 
@@ -188,7 +189,7 @@ vl_video_buffer_template(struct pipe_resource *templ,
    templ->usage = usage;
 
    vl_video_buffer_adjust_size(&templ->width0, &height, plane,
-                               pipe_format_to_chroma_format(tmpl->buffer_format), false);
+                               chroma_format, false);
    templ->height0 = height;
 }
 
@@ -372,7 +373,8 @@ vl_video_buffer_create(struct pipe_context *pipe,
    result = vl_video_buffer_create_ex
    (
       pipe, &templat, resource_formats,
-      1, tmpl->interlaced ? 2 : 1, PIPE_USAGE_DEFAULT
+      1, tmpl->interlaced ? 2 : 1, PIPE_USAGE_DEFAULT,
+      pipe_format_to_chroma_format(templat.buffer_format)
    );
 
 
@@ -386,7 +388,8 @@ struct pipe_video_buffer *
 vl_video_buffer_create_ex(struct pipe_context *pipe,
                           const struct pipe_video_buffer *tmpl,
                           const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
-                          unsigned depth, unsigned array_size, unsigned usage)
+                          unsigned depth, unsigned array_size, unsigned usage,
+                          enum pipe_video_chroma_format chroma_format)
 {
    struct pipe_resource res_tmpl;
    struct pipe_resource *resources[VL_NUM_COMPONENTS];
@@ -396,7 +399,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
 
    memset(resources, 0, sizeof resources);
 
-   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[0], depth, array_size, usage, 0);
+   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[0], depth, array_size,
+                            usage, 0, chroma_format);
    resources[0] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[0])
       goto error;
@@ -406,7 +410,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
       return vl_video_buffer_create_ex2(pipe, tmpl, resources);
    }
 
-   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[1], depth, array_size, usage, 1);
+   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[1], depth, array_size,
+                            usage, 1, chroma_format);
    resources[1] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[1])
       goto error;
@@ -414,7 +419,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
    if (resource_formats[2] == PIPE_FORMAT_NONE)
       return vl_video_buffer_create_ex2(pipe, tmpl, resources);
 
-   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[2], depth, array_size, usage, 2);
+   vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[2], depth, array_size,
+                            usage, 2, chroma_format);
    resources[2] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[2])
       goto error;
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h
index ee8b5f14698..15f0ecbaa50 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.h
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.h
@@ -119,7 +119,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
                          const struct pipe_video_buffer *templat,
                          enum pipe_format resource_format,
                          unsigned depth, unsigned array_size,
-                         unsigned usage, unsigned plane);
+                         unsigned usage, unsigned plane,
+                         enum pipe_video_chroma_format chroma_format);
 
 /**
  * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer
@@ -135,7 +136,8 @@ struct pipe_video_buffer *
 vl_video_buffer_create_ex(struct pipe_context *pipe,
                           const struct pipe_video_buffer *templat,
                           const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
-                          unsigned depth, unsigned array_size, unsigned usage);
+                          unsigned depth, unsigned array_size, unsigned usage,
+                          enum pipe_video_chroma_format chroma_format);
 
 /**
  * even more extended create function, provide the pipe_resource for each plane
diff --git a/src/gallium/drivers/r600/r600_uvd.c b/src/gallium/drivers/r600/r600_uvd.c
index 2e7d7ee4d40..18ac073da36 100644
--- a/src/gallium/drivers/r600/r600_uvd.c
+++ b/src/gallium/drivers/r600/r600_uvd.c
@@ -66,6 +66,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
 	struct pipe_video_buffer template;
 	struct pipe_resource templ;
 	unsigned i, array_size;
+	enum pipe_video_chroma_format chroma_format =
+		pipe_format_to_chroma_format(tmpl->buffer_format);
 
 	assert(pipe);
 
@@ -77,7 +79,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
 	template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH);
 	template.height = align(tmpl->height / array_size, VL_MACROBLOCK_HEIGHT);
 
-	vl_video_buffer_template(&templ, &template, resource_formats[0], 1, array_size, PIPE_USAGE_DEFAULT, 0);
+	vl_video_buffer_template(&templ, &template, resource_formats[0], 1, array_size,
+									 PIPE_USAGE_DEFAULT, 0, chroma_format);
 	if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
 		templ.bind = PIPE_BIND_LINEAR;
 	resources[0] = (struct r600_texture *)
@@ -86,7 +89,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
 		goto error;
 
 	if (resource_formats[1] != PIPE_FORMAT_NONE) {
-		vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size, PIPE_USAGE_DEFAULT, 1);
+		vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size,
+										 PIPE_USAGE_DEFAULT, 1, chroma_format);
 		if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
 			templ.bind = PIPE_BIND_LINEAR;
 		resources[1] = (struct r600_texture *)
@@ -96,7 +100,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
 	}
 
 	if (resource_formats[2] != PIPE_FORMAT_NONE) {
-		vl_video_buffer_template(&templ, &template, resource_formats[2], 1, array_size, PIPE_USAGE_DEFAULT, 2);
+		vl_video_buffer_template(&templ, &template, resource_formats[2], 1, array_size,
+										 PIPE_USAGE_DEFAULT, 2, chroma_format);
 		if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
 			templ.bind = PIPE_BIND_LINEAR;
 		resources[2] = (struct r600_texture *)



More information about the mesa-commit mailing list