vlVdpDevice *dev;
vlVdpDecoder *vldecoder;
VdpStatus ret;
+ unsigned i;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating decoder\n");
goto error_decoder;
}
- vldecoder->buffer = vldecoder->decoder->create_buffer(vldecoder->decoder);
- if (!vldecoder->buffer) {
- ret = VDP_STATUS_ERROR;
- goto error_buffer;
+ 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]) {
+ ret = VDP_STATUS_ERROR;
+ goto error_buffer;
+ }
}
*decoder = vlAddDataHTAB(vldecoder);
return VDP_STATUS_OK;
error_handle:
- vldecoder->buffer->destroy(vldecoder->buffer);
-
error_buffer:
+
+ for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
+ if (vldecoder->buffer[i])
+ vldecoder->buffer[i]->destroy(vldecoder->buffer[i]);
+
vldecoder->decoder->destroy(vldecoder->decoder);
error_decoder:
vlVdpDecoderDestroy(VdpDecoder decoder)
{
vlVdpDecoder *vldecoder;
+ unsigned i;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying decoder\n");
if (!vldecoder)
return VDP_STATUS_INVALID_HANDLE;
- vldecoder->buffer->destroy(vldecoder->buffer);
+ for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
+ if (vldecoder->buffer[i])
+ vldecoder->buffer[i]->destroy(vldecoder->buffer[i]);
+
vldecoder->decoder->destroy(vldecoder->decoder);
FREE(vldecoder);
switch (vldecoder->decoder->profile) {
case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
- return vlVdpDecoderRenderMpeg2(vldecoder->decoder, vldecoder->buffer, vlsurf->video_buffer,
+ ++vldecoder->cur_buffer;
+ vldecoder->cur_buffer %= VL_NUM_DECODE_BUFFERS;
+ return vlVdpDecoderRenderMpeg2(vldecoder->decoder,
+ vldecoder->buffer[vldecoder->cur_buffer],
+ vlsurf->video_buffer,
(VdpPictureInfoMPEG1Or2 *)picture_info,
bitstream_buffer_count,bitstream_buffers);
break;
#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)
{
vlVdpDevice *device;
struct pipe_video_decoder *decoder;
- struct pipe_video_decode_buffer *buffer;
+ struct pipe_video_decode_buffer *buffer[VL_NUM_DECODE_BUFFERS];
+ unsigned cur_buffer;
} vlVdpDecoder;
typedef uint32_t vlHandle;