summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2013-07-15 01:50:24 -0600
committerChristian König <christian.koenig@amd.com>2013-08-19 10:21:14 +0200
commit53e20b8b418cc85e13d70f41ce160e17847a5096 (patch)
treefab98050b72995f12e7126c3df148d5aaab77415 /src/gallium/drivers
parentd13003f544417db6de44c65a0c118bd2b189458a (diff)
vl: use a template for create_video_decoder
Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/ilo/ilo_video.c9
-rw-r--r--src/gallium/drivers/nouveau/nouveau_video.c36
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h14
-rw-r--r--src/gallium/drivers/nv50/nv84_video.c40
-rw-r--r--src/gallium/drivers/nv50/nv98_video.c45
-rw-r--r--src/gallium/drivers/nvc0/nvc0_context.h7
-rw-r--r--src/gallium/drivers/nvc0/nvc0_video.c45
-rw-r--r--src/gallium/drivers/r600/r600_pipe.h6
-rw-r--r--src/gallium/drivers/r600/r600_uvd.c10
-rw-r--r--src/gallium/drivers/radeon/radeon_uvd.c35
-rw-r--r--src/gallium/drivers/radeon/radeon_uvd.h6
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_pipe.h6
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_uvd.c10
13 files changed, 83 insertions, 186 deletions
diff --git a/src/gallium/drivers/ilo/ilo_video.c b/src/gallium/drivers/ilo/ilo_video.c
index 6d3d0a1797a..95305db37b1 100644
--- a/src/gallium/drivers/ilo/ilo_video.c
+++ b/src/gallium/drivers/ilo/ilo_video.c
@@ -37,14 +37,9 @@
static struct pipe_video_decoder *
ilo_create_video_decoder(struct pipe_context *pipe,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height, unsigned max_references,
- bool expect_chunked_decode)
+ const struct pipe_video_decoder *templ)
{
- return vl_create_decoder(pipe, profile, entrypoint, chroma_format,
- width, height, max_references, expect_chunked_decode);
+ return vl_create_decoder(pipe, templ);
}
static struct pipe_video_buffer *
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
index 0fdc3cefa1d..d6ca13f9d90 100644
--- a/src/gallium/drivers/nouveau/nouveau_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_video.c
@@ -499,26 +499,23 @@ nouveau_decoder_destroy(struct pipe_video_decoder *decoder)
static struct pipe_video_decoder *
nouveau_create_decoder(struct pipe_context *context,
- struct nouveau_screen *screen,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode)
+ const struct pipe_video_decoder *templ,
+ struct nouveau_screen *screen)
{
struct nv04_fifo nv04_data = { .vram = 0xbeef0201, .gart = 0xbeef0202 };
+ unsigned width = templ->width, height = templ->height;
struct nouveau_object *mpeg = NULL;
struct nouveau_decoder *dec;
struct nouveau_pushbuf *push;
int ret;
bool is8274 = screen->device->chipset > 0x80;
- debug_printf("Acceleration level: %s\n", entrypoint <= PIPE_VIDEO_ENTRYPOINT_BITSTREAM ? "bit":
- entrypoint == PIPE_VIDEO_ENTRYPOINT_IDCT ? "IDCT" : "MC");
+ debug_printf("Acceleration level: %s\n", templ->entrypoint <= PIPE_VIDEO_ENTRYPOINT_BITSTREAM ? "bit":
+ templ->entrypoint == PIPE_VIDEO_ENTRYPOINT_IDCT ? "IDCT" : "MC");
if (getenv("XVMC_VL"))
goto vl;
- if (u_reduce_video_profile(profile) != PIPE_VIDEO_CODEC_MPEG12)
+ if (u_reduce_video_profile(templ->profile) != PIPE_VIDEO_CODEC_MPEG12)
goto vl;
if (screen->device->chipset >= 0x98 && screen->device->chipset != 0xa0)
goto vl;
@@ -560,13 +557,10 @@ nouveau_create_decoder(struct pipe_context *context,
}
dec->mpeg = mpeg;
+ dec->base = *templ;
dec->base.context = context;
- dec->base.profile = profile;
- dec->base.entrypoint = entrypoint;
- dec->base.chroma_format = chroma_format;
dec->base.width = width;
dec->base.height = height;
- dec->base.max_references = max_references;
dec->base.destroy = nouveau_decoder_destroy;
dec->base.begin_frame = nouveau_decoder_begin_frame;
dec->base.decode_macroblock = nouveau_decoder_decode_macroblock;
@@ -616,7 +610,7 @@ nouveau_create_decoder(struct pipe_context *context,
BEGIN_NV04(push, NV31_MPEG(FORMAT), 2);
PUSH_DATA (push, 0);
- switch (entrypoint) {
+ switch (templ->entrypoint) {
case PIPE_VIDEO_ENTRYPOINT_BITSTREAM: PUSH_DATA (push, 0x100); break;
case PIPE_VIDEO_ENTRYPOINT_IDCT: PUSH_DATA (push, 1); break;
case PIPE_VIDEO_ENTRYPOINT_MC: PUSH_DATA (push, 0); break;
@@ -645,9 +639,7 @@ fail:
vl:
debug_printf("Using g3dvl renderer\n");
- return vl_create_decoder(context, profile, entrypoint,
- chroma_format, width, height,
- max_references, expect_chunked_decode);
+ return vl_create_decoder(context, templ);
}
static struct pipe_sampler_view **
@@ -877,16 +869,10 @@ nouveau_screen_init_vdec(struct nouveau_screen *screen)
static struct pipe_video_decoder *
nouveau_context_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode)
+ const struct pipe_video_decoder *templ)
{
struct nouveau_screen *screen = nouveau_context(context)->screen;
- return nouveau_create_decoder(context, screen, profile, entrypoint,
- chroma_format, width, height,
- max_references, expect_chunked_decode);
+ return nouveau_create_decoder(context, templ, screen);
}
static struct pipe_video_buffer *
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index 52a1aa5147d..3c24546beef 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -292,12 +292,7 @@ void nv50_push_vbo(struct nv50_context *, const struct pipe_draw_info *);
/* nv84_video.c */
struct pipe_video_decoder *
nv84_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references,
- bool expect_chunked_decode);
+ const struct pipe_video_decoder *templ);
struct pipe_video_buffer *
nv84_video_buffer_create(struct pipe_context *pipe,
@@ -316,12 +311,7 @@ nv84_screen_video_supported(struct pipe_screen *screen,
/* nv98_video.c */
struct pipe_video_decoder *
nv98_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references,
- bool expect_chunked_decode);
+ const struct pipe_video_decoder *templ);
struct pipe_video_buffer *
nv98_video_buffer_create(struct pipe_context *pipe,
diff --git a/src/gallium/drivers/nv50/nv84_video.c b/src/gallium/drivers/nv50/nv84_video.c
index 8c3c3b796c3..aedb9efc149 100644
--- a/src/gallium/drivers/nv50/nv84_video.c
+++ b/src/gallium/drivers/nv50/nv84_video.c
@@ -263,12 +263,7 @@ nv84_decoder_destroy(struct pipe_video_decoder *decoder)
struct pipe_video_decoder *
nv84_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references,
- bool chunked_decode)
+ const struct pipe_video_decoder *templ)
{
struct nv50_context *nv50 = (struct nv50_context *)context;
struct nouveau_screen *screen = &nv50->screen->base;
@@ -279,22 +274,20 @@ nv84_create_decoder(struct pipe_context *context,
union pipe_color_union color;
struct nv04_fifo nv04_data = { .vram = 0xbeef0201, .gart = 0xbeef0202 };
int ret, i;
- int is_h264 = u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG4_AVC;
- int is_mpeg12 = u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12;
+ int is_h264 = u_reduce_video_profile(templ->profile) == PIPE_VIDEO_CODEC_MPEG4_AVC;
+ int is_mpeg12 = u_reduce_video_profile(templ->profile) == PIPE_VIDEO_CODEC_MPEG12;
if (getenv("XVMC_VL"))
- return vl_create_decoder(context, profile, entrypoint,
- chroma_format, width, height,
- max_references, chunked_decode);
+ return vl_create_decoder(context, templ);
- if ((is_h264 && entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
- (is_mpeg12 && entrypoint > PIPE_VIDEO_ENTRYPOINT_IDCT)) {
- debug_printf("%x\n", entrypoint);
+ if ((is_h264 && templ->entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
+ (is_mpeg12 && templ->entrypoint > PIPE_VIDEO_ENTRYPOINT_IDCT)) {
+ debug_printf("%x\n", templ->entrypoint);
return NULL;
}
if (!is_h264 && !is_mpeg12) {
- debug_printf("invalid profile: %x\n", profile);
+ debug_printf("invalid profile: %x\n", templ->profile);
return NULL;
}
@@ -302,13 +295,8 @@ nv84_create_decoder(struct pipe_context *context,
if (!dec)
return NULL;
+ dec->base = *templ;
dec->base.context = context;
- dec->base.profile = profile;
- dec->base.entrypoint = entrypoint;
- dec->base.chroma_format = chroma_format;
- dec->base.width = width;
- dec->base.height = height;
- dec->base.max_references = max_references;
dec->base.destroy = nv84_decoder_destroy;
dec->base.flush = nv84_decoder_flush;
if (is_h264) {
@@ -326,7 +314,7 @@ nv84_create_decoder(struct pipe_context *context,
dec->base.begin_frame = nv84_decoder_begin_frame_mpeg12;
dec->base.end_frame = nv84_decoder_end_frame_mpeg12;
- if (entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+ if (templ->entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
dec->mpeg12_bs = CALLOC_STRUCT(vl_mpg12_bs);
if (!dec->mpeg12_bs)
goto fail;
@@ -409,7 +397,7 @@ nv84_create_decoder(struct pipe_context *context,
goto fail;
ret = nouveau_bo_new(screen->device, NOUVEAU_BO_VRAM | NOUVEAU_BO_NOSNOOP,
0,
- (max_references + 1) * dec->frame_mbs * 0x40 +
+ (templ->max_references + 1) * dec->frame_mbs * 0x40 +
dec->frame_size + 0x2000,
NULL, &dec->mbring);
if (ret)
@@ -433,8 +421,8 @@ nv84_create_decoder(struct pipe_context *context,
if (is_mpeg12) {
ret = nouveau_bo_new(screen->device, NOUVEAU_BO_GART,
0,
- align(0x20 * mb(width) * mb(height), 0x100) +
- (6 * 64 * 8) * mb(width) * mb(height) + 0x100,
+ align(0x20 * mb(templ->width) * mb(templ->height), 0x100) +
+ (6 * 64 * 8) * mb(templ->width) * mb(templ->height) + 0x100,
NULL, &dec->mpeg12_bo);
if (ret)
goto fail;
@@ -485,7 +473,7 @@ nv84_create_decoder(struct pipe_context *context,
color.f[0] = color.f[1] = color.f[2] = color.f[3] = 0;
surf.offset = dec->frame_size;
surf.width = 64;
- surf.height = (max_references + 1) * dec->frame_mbs / 4;
+ surf.height = (templ->max_references + 1) * dec->frame_mbs / 4;
surf.depth = 1;
surf.base.format = PIPE_FORMAT_B8G8R8A8_UNORM;
surf.base.u.tex.level = 0;
diff --git a/src/gallium/drivers/nv50/nv98_video.c b/src/gallium/drivers/nv50/nv98_video.c
index f16fbd07a9d..60bc79b222c 100644
--- a/src/gallium/drivers/nv50/nv98_video.c
+++ b/src/gallium/drivers/nv50/nv98_video.c
@@ -58,11 +58,7 @@ nv98_decoder_decode_bitstream(struct pipe_video_decoder *decoder,
struct pipe_video_decoder *
nv98_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height, unsigned max_references,
- bool chunked_decode)
+ const struct pipe_video_decoder *templ)
{
struct nouveau_screen *screen = &((struct nv50_context *)context)->screen->base;
struct nouveau_vp3_decoder *dec;
@@ -79,12 +75,10 @@ nv98_create_decoder(struct pipe_context *context,
u32 tmp_size = 0;
if (getenv("XVMC_VL"))
- return vl_create_decoder(context, profile, entrypoint,
- chroma_format, width, height,
- max_references, chunked_decode);
+ return vl_create_decoder(context, templ);
- if (entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
- debug_printf("%x\n", entrypoint);
+ if (templ->entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+ debug_printf("%x\n", templ->entrypoint);
return NULL;
}
@@ -142,13 +136,8 @@ nv98_create_decoder(struct pipe_context *context,
for (i = 0; i < 5; i++)
PUSH_DATA (push[2], nv04_data.vram);
+ dec->base = *templ;
dec->base.context = context;
- dec->base.profile = profile;
- dec->base.entrypoint = entrypoint;
- dec->base.chroma_format = chroma_format;
- dec->base.width = width;
- dec->base.height = height;
- dec->base.max_references = max_references;
dec->base.decode_bitstream = nv98_decoder_decode_bitstream;
for (i = 0; i < NOUVEAU_VP3_VIDEO_QDEPTH && !ret; ++i)
@@ -162,29 +151,29 @@ nv98_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- switch (u_reduce_video_profile(profile)) {
+ switch (u_reduce_video_profile(templ->profile)) {
case PIPE_VIDEO_CODEC_MPEG12: {
codec = 1;
- assert(max_references <= 2);
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_MPEG4: {
codec = 4;
- tmp_size = mb(height)*16 * mb(width)*16;
- assert(max_references <= 2);
+ tmp_size = mb(templ->height)*16 * mb(templ->width)*16;
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_VC1: {
ppp_codec = codec = 2;
- tmp_size = mb(height)*16 * mb(width)*16;
- assert(max_references <= 2);
+ tmp_size = mb(templ->height)*16 * mb(templ->width)*16;
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_MPEG4_AVC: {
codec = 3;
- dec->tmp_stride = 16 * mb_half(width) * nouveau_vp3_video_align(height) * 3 / 2;
- tmp_size = dec->tmp_stride * (max_references + 1);
- assert(max_references <= 16);
+ dec->tmp_stride = 16 * mb_half(templ->width) * nouveau_vp3_video_align(templ->height) * 3 / 2;
+ tmp_size = dec->tmp_stride * (templ->max_references + 1);
+ assert(templ->max_references <= 16);
break;
}
default:
@@ -197,7 +186,7 @@ nv98_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- ret = nouveau_vp3_load_firmware(dec, profile, screen->device->chipset);
+ ret = nouveau_vp3_load_firmware(dec, templ->profile, screen->device->chipset);
if (ret)
goto fw_fail;
@@ -208,9 +197,9 @@ nv98_create_decoder(struct pipe_context *context,
goto fail;
}
- dec->ref_stride = mb(width)*16 * (mb_half(height)*32 + nouveau_vp3_video_align(height)/2);
+ dec->ref_stride = mb(templ->width)*16 * (mb_half(templ->height)*32 + nouveau_vp3_video_align(templ->height)/2);
ret = nouveau_bo_new(screen->device, NOUVEAU_BO_VRAM, 0,
- dec->ref_stride * (max_references+2) + tmp_size,
+ dec->ref_stride * (templ->max_references+2) + tmp_size,
&cfg, &dec->ref_bo);
if (ret)
goto fail;
diff --git a/src/gallium/drivers/nvc0/nvc0_context.h b/src/gallium/drivers/nvc0/nvc0_context.h
index db6bb10182c..d976de6fd91 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nvc0/nvc0_context.h
@@ -335,12 +335,7 @@ void nvc0_idxbuf_validate(struct nvc0_context *);
/* nvc0_video.c */
struct pipe_video_decoder *
nvc0_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references,
- bool expect_chunked_decode);
+ const struct pipe_video_decoder *templ);
struct pipe_video_buffer *
nvc0_video_buffer_create(struct pipe_context *pipe,
diff --git a/src/gallium/drivers/nvc0/nvc0_video.c b/src/gallium/drivers/nvc0/nvc0_video.c
index 5891f0909d6..1b2dcd18ffc 100644
--- a/src/gallium/drivers/nvc0/nvc0_video.c
+++ b/src/gallium/drivers/nvc0/nvc0_video.c
@@ -58,11 +58,7 @@ nvc0_decoder_decode_bitstream(struct pipe_video_decoder *decoder,
struct pipe_video_decoder *
nvc0_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height, unsigned max_references,
- bool chunked_decode)
+ const struct pipe_video_decoder *templ)
{
struct nouveau_screen *screen = &((struct nvc0_context *)context)->screen->base;
struct nouveau_vp3_decoder *dec;
@@ -79,12 +75,10 @@ nvc0_create_decoder(struct pipe_context *context,
u32 tmp_size = 0;
if (getenv("XVMC_VL"))
- return vl_create_decoder(context, profile, entrypoint,
- chroma_format, width, height,
- max_references, chunked_decode);
+ return vl_create_decoder(context, templ);
- if (entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
- debug_printf("%x\n", entrypoint);
+ if (templ->entrypoint != PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+ debug_printf("%x\n", templ->entrypoint);
return NULL;
}
@@ -168,13 +162,8 @@ nvc0_create_decoder(struct pipe_context *context,
BEGIN_NVC0(push[2], SUBC_PPP(NV01_SUBCHAN_OBJECT), 1);
PUSH_DATA (push[2], dec->ppp->handle);
+ dec->base = *templ;
dec->base.context = context;
- dec->base.profile = profile;
- dec->base.entrypoint = entrypoint;
- dec->base.chroma_format = chroma_format;
- dec->base.width = width;
- dec->base.height = height;
- dec->base.max_references = max_references;
dec->base.decode_bitstream = nvc0_decoder_decode_bitstream;
for (i = 0; i < NOUVEAU_VP3_VIDEO_QDEPTH && !ret; ++i)
@@ -194,29 +183,29 @@ nvc0_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- switch (u_reduce_video_profile(profile)) {
+ switch (u_reduce_video_profile(templ->profile)) {
case PIPE_VIDEO_CODEC_MPEG12: {
codec = 1;
- assert(max_references <= 2);
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_MPEG4: {
codec = 4;
- tmp_size = mb(height)*16 * mb(width)*16;
- assert(max_references <= 2);
+ tmp_size = mb(templ->height)*16 * mb(templ->width)*16;
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_VC1: {
ppp_codec = codec = 2;
- tmp_size = mb(height)*16 * mb(width)*16;
- assert(max_references <= 2);
+ tmp_size = mb(templ->height)*16 * mb(templ->width)*16;
+ assert(templ->max_references <= 2);
break;
}
case PIPE_VIDEO_CODEC_MPEG4_AVC: {
codec = 3;
- dec->tmp_stride = 16 * mb_half(width) * nouveau_vp3_video_align(height) * 3 / 2;
- tmp_size = dec->tmp_stride * (max_references + 1);
- assert(max_references <= 16);
+ dec->tmp_stride = 16 * mb_half(templ->width) * nouveau_vp3_video_align(templ->height) * 3 / 2;
+ tmp_size = dec->tmp_stride * (templ->max_references + 1);
+ assert(templ->max_references <= 16);
break;
}
default:
@@ -230,7 +219,7 @@ nvc0_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- ret = nouveau_vp3_load_firmware(dec, profile, screen->device->chipset);
+ ret = nouveau_vp3_load_firmware(dec, templ->profile, screen->device->chipset);
if (ret)
goto fw_fail;
}
@@ -242,9 +231,9 @@ nvc0_create_decoder(struct pipe_context *context,
goto fail;
}
- dec->ref_stride = mb(width)*16 * (mb_half(height)*32 + nouveau_vp3_video_align(height)/2);
+ dec->ref_stride = mb(templ->width)*16 * (mb_half(templ->height)*32 + nouveau_vp3_video_align(templ->height)/2);
ret = nouveau_bo_new(screen->device, NOUVEAU_BO_VRAM, 0,
- dec->ref_stride * (max_references+2) + tmp_size,
+ dec->ref_stride * (templ->max_references+2) + tmp_size,
&cfg, &dec->ref_bo);
if (ret)
goto fail;
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 349a6cb6cfb..eaef920b156 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -891,11 +891,7 @@ bool sampler_state_needs_border_color(const struct pipe_sampler_state *state);
/* r600_uvd.c */
struct pipe_video_decoder *r600_uvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode);
+ const struct pipe_video_decoder *decoder);
struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl);
diff --git a/src/gallium/drivers/r600/r600_uvd.c b/src/gallium/drivers/r600/r600_uvd.c
index 3b4aa843808..62c8e525e12 100644
--- a/src/gallium/drivers/r600/r600_uvd.c
+++ b/src/gallium/drivers/r600/r600_uvd.c
@@ -165,17 +165,11 @@ static struct radeon_winsys_cs_handle* r600_uvd_set_dtb(struct ruvd_msg *msg, st
/* create decoder */
struct pipe_video_decoder *r600_uvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode)
+ const struct pipe_video_decoder *templat)
{
struct r600_context *ctx = (struct r600_context *)context;
- return ruvd_create_decoder(context, profile, entrypoint, chroma_format,
- width, height, max_references, expect_chunked_decode,
- ctx->ws, r600_uvd_set_dtb);
+ return ruvd_create_decoder(context, templat, ctx->ws, r600_uvd_set_dtb);
}
int r600_uvd_get_video_param(struct pipe_screen *screen,
diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c
index e3c3dd63d4f..55aca415045 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -262,18 +262,16 @@ static uint32_t profile2stream_type(enum pipe_video_profile profile)
}
/* calculate size of reference picture buffer */
-static unsigned calc_dpb_size(enum pipe_video_profile profile,
- unsigned width, unsigned height,
- unsigned max_references)
+static unsigned calc_dpb_size(const struct pipe_video_decoder *templ)
{
unsigned width_in_mb, height_in_mb, image_size, dpb_size;
// always align them to MB size for dpb calculation
- width = align(width, VL_MACROBLOCK_WIDTH);
- height = align(height, VL_MACROBLOCK_HEIGHT);
+ unsigned width = align(templ->width, VL_MACROBLOCK_WIDTH);
+ unsigned height = align(templ->height, VL_MACROBLOCK_HEIGHT);
// always one more for currently decoded picture
- max_references += 1;
+ unsigned max_references = templ->max_references + 1;
// aligned size of a single frame
image_size = width * height;
@@ -284,7 +282,7 @@ static unsigned calc_dpb_size(enum pipe_video_profile profile,
width_in_mb = width / VL_MACROBLOCK_WIDTH;
height_in_mb = align(height / VL_MACROBLOCK_HEIGHT, 2);
- switch (u_reduce_video_profile(profile)) {
+ switch (u_reduce_video_profile(templ->profile)) {
case PIPE_VIDEO_CODEC_MPEG4_AVC:
// the firmware seems to allways assume a minimum of ref frames
max_references = MAX2(NUM_H264_REFS, max_references);
@@ -819,15 +817,12 @@ static void ruvd_flush(struct pipe_video_decoder *decoder)
* create and UVD decoder
*/
struct pipe_video_decoder *ruvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode,
+ const struct pipe_video_decoder *templ,
struct radeon_winsys* ws,
ruvd_set_dtb set_dtb)
{
- unsigned dpb_size = calc_dpb_size(profile, width, height, max_references);
+ unsigned dpb_size = calc_dpb_size(templ);
+ unsigned width = templ->width, height = templ->height;
struct radeon_info info;
struct ruvd_decoder *dec;
struct ruvd_msg msg;
@@ -835,12 +830,10 @@ struct pipe_video_decoder *ruvd_create_decoder(struct pipe_context *context,
ws->query_info(ws, &info);
- switch(u_reduce_video_profile(profile)) {
+ switch(u_reduce_video_profile(templ->profile)) {
case PIPE_VIDEO_CODEC_MPEG12:
- if (entrypoint > PIPE_VIDEO_ENTRYPOINT_BITSTREAM || info.family < CHIP_PALM)
- return vl_create_mpeg12_decoder(context, profile, entrypoint,
- chroma_format, width,
- height, max_references, expect_chunked_decode);
+ if (templ->entrypoint > PIPE_VIDEO_ENTRYPOINT_BITSTREAM || info.family < CHIP_PALM)
+ return vl_create_mpeg12_decoder(context, templ);
/* fall through */
case PIPE_VIDEO_CODEC_MPEG4:
@@ -859,12 +852,8 @@ struct pipe_video_decoder *ruvd_create_decoder(struct pipe_context *context,
if (!dec)
return NULL;
+ dec->base = *templ;
dec->base.context = context;
- dec->base.profile = profile;
- dec->base.entrypoint = entrypoint;
- dec->base.chroma_format = chroma_format;
- dec->base.width = width;
- dec->base.height = height;
dec->base.destroy = ruvd_destroy;
dec->base.begin_frame = ruvd_begin_frame;
diff --git a/src/gallium/drivers/radeon/radeon_uvd.h b/src/gallium/drivers/radeon/radeon_uvd.h
index 1e9742554ea..82fbda4d1ee 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.h
+++ b/src/gallium/drivers/radeon/radeon_uvd.h
@@ -346,11 +346,7 @@ typedef struct radeon_winsys_cs_handle* (*ruvd_set_dtb)
/* create an UVD decode */
struct pipe_video_decoder *ruvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode,
+ const struct pipe_video_decoder *templat,
struct radeon_winsys* ws,
ruvd_set_dtb set_dtb);
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index e1c6f30b3d7..cbfd7dae4be 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -278,11 +278,7 @@ void si_init_compute_functions(struct r600_context *rctx);
/* radeonsi_uvd.c */
struct pipe_video_decoder *radeonsi_uvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode);
+ const struct pipe_video_decoder *templ);
struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl);
diff --git a/src/gallium/drivers/radeonsi/radeonsi_uvd.c b/src/gallium/drivers/radeonsi/radeonsi_uvd.c
index 015445ee3f2..d19bf3382a0 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_uvd.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_uvd.c
@@ -147,15 +147,9 @@ static struct radeon_winsys_cs_handle* radeonsi_uvd_set_dtb(struct ruvd_msg *msg
* creates an UVD compatible decoder
*/
struct pipe_video_decoder *radeonsi_uvd_create_decoder(struct pipe_context *context,
- enum pipe_video_profile profile,
- enum pipe_video_entrypoint entrypoint,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height,
- unsigned max_references, bool expect_chunked_decode)
+ const struct pipe_video_decoder *templ)
{
struct r600_context *ctx = (struct r600_context *)context;
- return ruvd_create_decoder(context, profile, entrypoint, chroma_format,
- width, height, max_references, expect_chunked_decode,
- ctx->ws, radeonsi_uvd_set_dtb);
+ return ruvd_create_decoder(context, templ, ctx->ws, radeonsi_uvd_set_dtb);
}