summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/vl/vl_decoder.c13
-rw-r--r--src/gallium/auxiliary/vl/vl_decoder.h6
-rw-r--r--src/gallium/drivers/nouveau/nouveau_video.c2
-rw-r--r--src/gallium/drivers/nvfx/nvfx_screen.c2
-rw-r--r--src/gallium/drivers/r300/r300_screen.c2
-rw-r--r--src/gallium/drivers/r600/r600_pipe.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/include/pipe/p_video_enums.h3
-rw-r--r--src/gallium/state_trackers/vdpau/decode.c41
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h4
10 files changed, 61 insertions, 16 deletions
diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c
index fac03359a0f..b23827d300a 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_decoder.c
@@ -44,6 +44,19 @@ vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile
}
}
+unsigned
+vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile profile)
+{
+ assert(screen);
+ switch (u_reduce_video_profile(profile)) {
+ case PIPE_VIDEO_CODEC_MPEG12:
+ return 4;
+
+ default:
+ return 1;
+ }
+}
+
struct pipe_video_decoder *
vl_create_decoder(struct pipe_context *pipe,
enum pipe_video_profile profile,
diff --git a/src/gallium/auxiliary/vl/vl_decoder.h b/src/gallium/auxiliary/vl/vl_decoder.h
index 0e9280dbfa2..fed529c9bc7 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_decoder.h
@@ -38,6 +38,12 @@ bool
vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile);
/**
+ * the desired number of buffers for optimal operation
+ */
+unsigned
+vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile profile);
+
+/**
* standard implementation of pipe->create_video_decoder
*/
struct pipe_video_decoder *
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
index 32f038dae61..620c030e112 100644
--- a/src/gallium/drivers/nouveau/nouveau_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_video.c
@@ -18,6 +18,8 @@ nouveau_screen_get_video_param(struct pipe_screen *pscreen,
case PIPE_VIDEO_CAP_MAX_WIDTH:
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return vl_video_buffer_max_size(pscreen);
+ case PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED:
+ return vl_num_buffers_desired(pscreen, profile);
default:
debug_printf("unknown video param: %d\n", param);
return 0;
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
index 0e8f96772c6..3b77c9600c6 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -226,6 +226,8 @@ nvfx_screen_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_MAX_WIDTH:
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return vl_video_buffer_max_size(screen);
+ case PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED:
+ return vl_num_buffers_desired(screen, profile);
default:
return 0;
}
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 13d25ba7dba..8c0500c7dfd 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -313,6 +313,8 @@ static int r300_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_MAX_WIDTH:
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return vl_video_buffer_max_size(screen);
+ case PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED:
+ return vl_num_buffers_desired(screen, profile);
default:
return 0;
}
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index d180e36aa16..ceaebbb4431 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -505,6 +505,8 @@ static int r600_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_MAX_WIDTH:
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return vl_video_buffer_max_size(screen);
+ case PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED:
+ return vl_num_buffers_desired(screen, profile);
default:
return 0;
}
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 1e58d27be88..960ab8c96ae 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -185,6 +185,8 @@ softpipe_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_MAX_WIDTH:
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return vl_video_buffer_max_size(screen);
+ case PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED:
+ return vl_num_buffers_desired(screen, profile);
default:
return 0;
}
diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h
index 13786067d53..ea25a25883d 100644
--- a/src/gallium/include/pipe/p_video_enums.h
+++ b/src/gallium/include/pipe/p_video_enums.h
@@ -50,7 +50,8 @@ enum pipe_video_cap
PIPE_VIDEO_CAP_SUPPORTED = 0,
PIPE_VIDEO_CAP_NPOT_TEXTURES = 1,
PIPE_VIDEO_CAP_MAX_WIDTH = 2,
- PIPE_VIDEO_CAP_MAX_HEIGHT = 3
+ PIPE_VIDEO_CAP_MAX_HEIGHT = 3,
+ PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED = 4
};
enum pipe_video_codec
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 3bf05bea21f..3527f733809 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -82,13 +82,22 @@ vlVdpDecoderCreate(VdpDevice device,
goto error_decoder;
}
+ vldecoder->num_buffers = pipe->screen->get_video_param
+ (
+ pipe->screen, p_profile,
+ PIPE_VIDEO_CAP_NUM_BUFFERS_DESIRED
+ );
vldecoder->cur_buffer = 0;
- for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i) {
- vldecoder->buffer[i] = vldecoder->decoder->create_buffer(vldecoder->decoder);
- if (!vldecoder->buffer[i]) {
+ vldecoder->buffers = CALLOC(vldecoder->num_buffers, sizeof(void*));
+ if (!vldecoder->buffers)
+ goto error_alloc_buffers;
+
+ for (i = 0; i < vldecoder->num_buffers; ++i) {
+ vldecoder->buffers[i] = vldecoder->decoder->create_buffer(vldecoder->decoder);
+ if (!vldecoder->buffers[i]) {
ret = VDP_STATUS_ERROR;
- goto error_buffer;
+ goto error_create_buffers;
}
}
@@ -103,11 +112,15 @@ vlVdpDecoderCreate(VdpDevice device,
return VDP_STATUS_OK;
error_handle:
-error_buffer:
+error_create_buffers:
- for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
- if (vldecoder->buffer[i])
- vldecoder->decoder->destroy_buffer(vldecoder->decoder, vldecoder->buffer[i]);
+ for (i = 0; i < vldecoder->num_buffers; ++i)
+ if (vldecoder->buffers[i])
+ vldecoder->decoder->destroy_buffer(vldecoder->decoder, vldecoder->buffers[i]);
+
+ FREE(vldecoder->buffers);
+
+error_alloc_buffers:
vldecoder->decoder->destroy(vldecoder->decoder);
@@ -128,9 +141,11 @@ vlVdpDecoderDestroy(VdpDecoder decoder)
if (!vldecoder)
return VDP_STATUS_INVALID_HANDLE;
- for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
- if (vldecoder->buffer[i])
- vldecoder->decoder->destroy_buffer(vldecoder->decoder, vldecoder->buffer[i]);
+ for (i = 0; i < vldecoder->num_buffers; ++i)
+ if (vldecoder->buffers[i])
+ vldecoder->decoder->destroy_buffer(vldecoder->decoder, vldecoder->buffers[i]);
+
+ FREE(vldecoder->buffers);
vldecoder->decoder->destroy(vldecoder->decoder);
@@ -260,9 +275,9 @@ vlVdpDecoderRender(VdpDecoder decoder,
case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
++vldecoder->cur_buffer;
- vldecoder->cur_buffer %= VL_NUM_DECODE_BUFFERS;
+ vldecoder->cur_buffer %= vldecoder->num_buffers;
- vldecoder->decoder->set_decode_buffer(vldecoder->decoder, vldecoder->buffer[vldecoder->cur_buffer]);
+ vldecoder->decoder->set_decode_buffer(vldecoder->decoder, vldecoder->buffers[vldecoder->cur_buffer]);
vldecoder->decoder->set_decode_target(vldecoder->decoder, vlsurf->video_buffer);
return vlVdpDecoderRenderMpeg12(vldecoder->decoder, (VdpPictureInfoMPEG1Or2 *)picture_info,
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 5c68cd7c47a..5482eff0630 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -46,7 +46,6 @@
#define TOSTRING(x) QUOTEME(x)
#define INFORMATION_STRING TOSTRING(INFORMATION)
#define VL_HANDLES
-#define VL_NUM_DECODE_BUFFERS 4
static inline enum pipe_video_chroma_format
ChromaToPipe(VdpChromaType vdpau_type)
@@ -256,7 +255,8 @@ typedef struct
{
vlVdpDevice *device;
struct pipe_video_decoder *decoder;
- void *buffer[VL_NUM_DECODE_BUFFERS];
+ unsigned num_buffers;
+ void **buffers;
unsigned cur_buffer;
} vlVdpDecoder;