diff options
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/vdpau/decode.c | 41 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/vdpau_private.h | 4 |
2 files changed, 30 insertions, 15 deletions
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; |