[Mesa-dev] [PATCH 1/2] vl: Remove decode buffers
Maarten Lankhorst
m.b.lankhorst at gmail.com
Sat Dec 24 03:50:09 PST 2011
It's still a curiosity used by vl_mpeg12_bitstream only.
Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>
---
Version n+1: split up, and fixed to apply with new vl_vlc, although for testing
you might want to grab the 'vl: Fix inverted logic in vlc checks' first.
src/gallium/auxiliary/vl/vl_decoder.c | 13 ----
src/gallium/auxiliary/vl/vl_decoder.h | 6 --
src/gallium/auxiliary/vl/vl_idct.c | 14 ++---
src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c | 5 +-
src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h | 3 +
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 61 +++++++++-----------
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h | 45 ++++++++-------
src/gallium/drivers/nouveau/nouveau_video.c | 2 -
src/gallium/drivers/nvfx/nvfx_screen.c | 2 -
src/gallium/drivers/r300/r300_screen.c | 2 -
src/gallium/drivers/r600/r600_pipe.c | 2 -
src/gallium/drivers/softpipe/sp_screen.c | 2 -
src/gallium/include/pipe/p_video_decoder.h | 19 +-----
src/gallium/include/pipe/p_video_enums.h | 3 -
src/gallium/state_trackers/vdpau/decode.c | 60 +++++---------------
src/gallium/state_trackers/vdpau/vdpau_private.h | 3 -
src/gallium/state_trackers/xorg/xvmc/surface.c | 6 --
.../state_trackers/xorg/xvmc/xvmc_private.h | 1
18 files changed, 78 insertions(+), 171 deletions(-)
diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c
index 383e02d..da905a6 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_decoder.c
@@ -44,19 +44,6 @@ 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 a997516..a7abe9c 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_decoder.h
@@ -38,12 +38,6 @@ 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/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c
index a2b3537..8394542 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -614,9 +614,9 @@ init_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
}
static void
-cleanup_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_source(struct vl_idct_buffer *buffer)
{
- assert(idct && buffer);
+ assert(buffer);
pipe_surface_reference(&buffer->fb_state_mismatch.cbufs[0], NULL);
@@ -665,13 +665,13 @@ error_surfaces:
}
static void
-cleanup_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+cleanup_intermediate(struct vl_idct_buffer *buffer)
{
unsigned i;
- assert(idct && buffer);
+ assert(buffer);
- for(i = 0; i < idct->nr_of_render_targets; ++i)
+ for(i = 0; i < buffer->fb_state.nr_cbufs; ++i)
pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
@@ -823,8 +823,8 @@ vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer)
{
assert(buffer);
- cleanup_source(buffer->idct, buffer);
- cleanup_intermediate(buffer->idct, buffer);
+ cleanup_source(buffer);
+ cleanup_intermediate(buffer);
pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, NULL);
pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, NULL);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 7e20d71..559d6c7 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -958,11 +958,12 @@ vl_mpg12_bs_set_picture_desc(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_
}
void
-vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t *buffer)
+vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned n,
+ const unsigned *lens, const void* const*buffer)
{
assert(bs);
- vl_vlc_init(&bs->vlc, 1, (const void * const *)&buffer, &num_bytes);
+ vl_vlc_init(&bs->vlc, n, buffer, lens);
while (vl_vlc_bits_left(&bs->vlc) > 32) {
uint32_t code = vl_vlc_peekbits(&bs->vlc, 32);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h
index c3f14a1..16c99e4 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h
@@ -49,6 +49,7 @@ void
vl_mpg12_bs_set_picture_desc(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture);
void
-vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t *buffer);
+vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned n,
+ const unsigned *lens, const void* const*buffer);
#endif /* vl_mpeg12_bitstream_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 2442d78..0896270 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -48,6 +48,9 @@ struct format_config {
float mc_scale;
};
+static void
+vl_mpeg12_cleanup_buffer(struct pipe_video_decoder *decoder, void *buffer);
+
static const struct format_config bitstream_format_config[] = {
// { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
// { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
@@ -386,8 +389,11 @@ static void
vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
+ unsigned i;
assert(decoder);
+ for (i = 0; i < Elements(dec->buffers); ++i)
+ vl_mpeg12_cleanup_buffer(decoder, &dec->buffers[i]);
/* Asserted in softpipe_delete_fs_state() for some reason */
dec->base.context->bind_vs_state(dec->base.context, NULL);
@@ -423,17 +429,12 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
}
static void *
-vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
+vl_mpeg12_init_buffer(struct pipe_video_decoder *decoder, struct vl_mpeg12_buffer *buffer)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
- struct vl_mpeg12_buffer *buffer;
assert(dec);
- buffer = CALLOC_STRUCT(vl_mpeg12_buffer);
- if (buffer == NULL)
- return NULL;
-
if (!vl_vb_init(&buffer->vertex_stream, dec->base.context,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT))
@@ -465,12 +466,11 @@ error_mc:
vl_vb_cleanup(&buffer->vertex_stream);
error_vertex_buffer:
- FREE(buffer);
return NULL;
}
static void
-vl_mpeg12_destroy_buffer(struct pipe_video_decoder *decoder, void *buffer)
+vl_mpeg12_cleanup_buffer(struct pipe_video_decoder *decoder, void *buffer)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
struct vl_mpeg12_buffer *buf = buffer;
@@ -485,18 +485,6 @@ vl_mpeg12_destroy_buffer(struct pipe_video_decoder *decoder, void *buffer)
cleanup_mc_buffer(buf);
vl_vb_cleanup(&buf->vertex_stream);
-
- FREE(buf);
-}
-
-static void
-vl_mpeg12_set_decode_buffer(struct pipe_video_decoder *decoder, void *buffer)
-{
- struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
-
- assert(dec && buffer);
-
- dec->current_buffer = buffer;
}
static void
@@ -576,8 +564,8 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder)
assert(dec);
- buf = dec->current_buffer;
- assert(buf);
+ dec->current_buffer = (dec->current_buffer + 1) % Elements(dec->buffers);
+ buf = &dec->buffers[dec->current_buffer];
if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
dec->intra_matrix[0] = 1 << (7 - dec->picture_desc.intra_dc_precision);
@@ -635,8 +623,7 @@ vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
assert(dec && dec->current_buffer);
assert(macroblocks && macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
- buf = dec->current_buffer;
- assert(buf);
+ buf = &dec->buffers[dec->current_buffer];
for (; num_macroblocks > 0; --num_macroblocks) {
unsigned mb_addr = mb->y * dec->width_in_macroblocks + mb->x;
@@ -689,24 +676,23 @@ vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
}
static void
-vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder,
- unsigned num_bytes, const void *data)
+vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder, unsigned n,
+ const unsigned *lens, const void *const*data)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct vl_mpeg12_buffer *buf;
unsigned i;
- assert(dec && dec->current_buffer);
+ assert(dec);
- buf = dec->current_buffer;
- assert(buf);
+ buf = &dec->buffers[dec->current_buffer];
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], dec->picture_desc.alternate_scan ?
dec->zscan_alternate : dec->zscan_normal);
- vl_mpg12_bs_decode(&buf->bs, num_bytes, data);
+ vl_mpg12_bs_decode(&buf->bs, n, lens, data);
}
static void
@@ -722,7 +708,7 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
assert(dec && dec->current_buffer);
- buf = dec->current_buffer;
+ buf = &dec->buffers[dec->current_buffer];
vl_vb_unmap(&buf->vertex_stream, dec->base.context);
@@ -1039,6 +1025,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
{
const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT;
const struct format_config *format_config;
+ unsigned i = 0;
struct vl_mpeg12_decoder *dec;
assert(u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12);
@@ -1057,9 +1044,6 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
dec->base.max_references = max_references;
dec->base.destroy = vl_mpeg12_destroy;
- dec->base.create_buffer = vl_mpeg12_create_buffer;
- dec->base.destroy_buffer = vl_mpeg12_destroy_buffer;
- dec->base.set_decode_buffer = vl_mpeg12_set_decode_buffer;
dec->base.set_picture_parameters = vl_mpeg12_set_picture_parameters;
dec->base.set_quant_matrix = vl_mpeg12_set_quant_matrix;
dec->base.set_decode_target = vl_mpeg12_set_decode_target;
@@ -1152,9 +1136,16 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
memset(dec->intra_matrix, 0x10, 64);
memset(dec->non_intra_matrix, 0x10, 64);
-
+ for (i = 0; i < Elements(dec->buffers); ++i) {
+ if (!vl_mpeg12_init_buffer(&dec->base, &dec->buffers[i]))
+ goto error_cleanup_buffer;
+ }
return &dec->base;
+error_cleanup_buffer:
+ for (; i > 0; --i)
+ vl_mpeg12_cleanup_buffer(&dec->base, &dec->buffers[i-1]);
+
error_pipe_state:
vl_mc_cleanup(&dec->mc_c);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
index 817c1ff..c7fd3fc 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
@@ -41,6 +41,27 @@
struct pipe_screen;
struct pipe_context;
+struct vl_mpeg12_buffer
+{
+ struct vl_vertex_buffer vertex_stream;
+
+ unsigned block_num;
+ unsigned num_ycbcr_blocks[3];
+
+ struct pipe_sampler_view *zscan_source;
+
+ struct vl_mpg12_bs bs;
+ struct vl_zscan_buffer zscan[VL_MAX_PLANES];
+ struct vl_idct_buffer idct[VL_MAX_PLANES];
+ struct vl_mc_buffer mc[VL_MAX_PLANES];
+
+ struct pipe_transfer *tex_transfer;
+ short *texels;
+
+ struct vl_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
+ struct vl_motionvector *mv_stream[VL_MAX_REF_FRAMES];
+};
+
struct vl_mpeg12_decoder
{
struct pipe_video_decoder base;
@@ -74,7 +95,8 @@ struct vl_mpeg12_decoder
void *dsa;
- struct vl_mpeg12_buffer *current_buffer;
+ unsigned current_buffer;
+ struct vl_mpeg12_buffer buffers[4];
struct pipe_mpeg12_picture_desc picture_desc;
uint8_t intra_matrix[64];
uint8_t non_intra_matrix[64];
@@ -82,27 +104,6 @@ struct vl_mpeg12_decoder
struct pipe_surface *target_surfaces[VL_MAX_PLANES];
};
-struct vl_mpeg12_buffer
-{
- struct vl_vertex_buffer vertex_stream;
-
- unsigned block_num;
- unsigned num_ycbcr_blocks[3];
-
- struct pipe_sampler_view *zscan_source;
-
- struct vl_mpg12_bs bs;
- struct vl_zscan_buffer zscan[VL_MAX_PLANES];
- struct vl_idct_buffer idct[VL_MAX_PLANES];
- struct vl_mc_buffer mc[VL_MAX_PLANES];
-
- struct pipe_transfer *tex_transfer;
- short *texels;
-
- struct vl_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
- struct vl_motionvector *mv_stream[VL_MAX_REF_FRAMES];
-};
-
/**
* creates a shader based mpeg12 decoder
*/
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
index a442537..3345f82 100644
--- a/src/gallium/drivers/nouveau/nouveau_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_video.c
@@ -851,8 +851,6 @@ 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 960cd88..abf4937 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -226,8 +226,6 @@ 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 d1b8031..9ca5420 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -308,8 +308,6 @@ 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 036f18f..f13c9e5 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -542,8 +542,6 @@ 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 49e8626..b7e58b3 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -188,8 +188,6 @@ 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_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
index 40b7dcd..847f20f 100644
--- a/src/gallium/include/pipe/p_video_decoder.h
+++ b/src/gallium/include/pipe/p_video_decoder.h
@@ -60,21 +60,6 @@ struct pipe_video_decoder
void (*destroy)(struct pipe_video_decoder *decoder);
/**
- * Creates a decoder buffer
- */
- void *(*create_buffer)(struct pipe_video_decoder *decoder);
-
- /**
- * Destroys a decoder buffer
- */
- void (*destroy_buffer)(struct pipe_video_decoder *decoder, void *buffer);
-
- /**
- * set the current decoder buffer
- */
- void (*set_decode_buffer)(struct pipe_video_decoder *decoder, void *buffer);
-
- /**
* set the picture parameters for the next frame
* only used for bitstream decoding
*/
@@ -115,8 +100,8 @@ struct pipe_video_decoder
/**
* decode a bitstream
*/
- void (*decode_bitstream)(struct pipe_video_decoder *decoder,
- unsigned num_bytes, const void *data);
+ void (*decode_bitstream)(struct pipe_video_decoder *decoder, unsigned num_buffers,
+ unsigned const *num_bytes, const void *const *data);
/**
* end decoding of the current frame
diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h
index ea25a25..1378606 100644
--- a/src/gallium/include/pipe/p_video_enums.h
+++ b/src/gallium/include/pipe/p_video_enums.h
@@ -50,8 +50,7 @@ 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_NUM_BUFFERS_DESIRED = 4
+ PIPE_VIDEO_CAP_MAX_HEIGHT = 3
};
enum pipe_video_codec
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 47212e3..5fff85d 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -48,7 +48,6 @@ vlVdpDecoderCreate(VdpDevice device,
vlVdpDevice *dev;
vlVdpDecoder *vldecoder;
VdpStatus ret;
- unsigned i;
bool supported;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating decoder\n");
@@ -98,25 +97,6 @@ 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;
-
- 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_create_buffers;
- }
- }
-
*decoder = vlAddDataHTAB(vldecoder);
if (*decoder == 0) {
ret = VDP_STATUS_ERROR;
@@ -128,16 +108,6 @@ vlVdpDecoderCreate(VdpDevice device,
return VDP_STATUS_OK;
error_handle:
-error_create_buffers:
-
- 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);
error_decoder:
@@ -152,7 +122,6 @@ VdpStatus
vlVdpDecoderDestroy(VdpDecoder decoder)
{
vlVdpDecoder *vldecoder;
- unsigned i;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying decoder\n");
@@ -160,12 +129,6 @@ vlVdpDecoderDestroy(VdpDecoder decoder)
if (!vldecoder)
return VDP_STATUS_INVALID_HANDLE;
- 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);
FREE(vldecoder);
@@ -412,10 +375,6 @@ vlVdpDecoderRender(VdpDecoder decoder,
// TODO: Recreate decoder with correct chroma
return VDP_STATUS_INVALID_CHROMA_TYPE;
- ++vldecoder->cur_buffer;
- vldecoder->cur_buffer %= vldecoder->num_buffers;
-
- dec->set_decode_buffer(dec, vldecoder->buffers[vldecoder->cur_buffer]);
dec->set_decode_target(dec, vlsurf->video_buffer);
switch (u_reduce_video_profile(dec->profile)) {
@@ -434,10 +393,19 @@ vlVdpDecoderRender(VdpDecoder decoder,
if (ret != VDP_STATUS_OK)
return ret;
- dec->begin_frame(dec);
- for (i = 0; i < bitstream_buffer_count; ++i)
- dec->decode_bitstream(dec, bitstream_buffers[i].bitstream_bytes,
- bitstream_buffers[i].bitstream);
- dec->end_frame(dec);
+ if (bitstream_buffer_count) {
+ void const *data[bitstream_buffer_count];
+ uint32_t sizes[bitstream_buffer_count];
+ for (i = 0; i < bitstream_buffer_count; ++i) {
+ data[i] = bitstream_buffers[i].bitstream;
+ sizes[i] = bitstream_buffers[i].bitstream_bytes;
+ }
+ dec->begin_frame(dec);
+ dec->decode_bitstream(dec,
+ bitstream_buffer_count,
+ sizes, data);
+ dec->end_frame(dec);
+ } else
+ return VDP_STATUS_INVALID_VALUE;
return ret;
}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 84c5b82..1bbbaa9 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -335,9 +335,6 @@ typedef struct
{
vlVdpDevice *device;
struct pipe_video_decoder *decoder;
- unsigned num_buffers;
- void **buffers;
- unsigned cur_buffer;
} vlVdpDecoder;
typedef uint32_t vlHandle;
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index bb7ba1e..b4447c4 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -114,8 +114,6 @@ SetDecoderStatus(XvMCSurfacePrivate *surface)
context_priv = surface->context->privData;
decoder = context_priv->decoder;
- if (surface->decode_buffer)
- decoder->set_decode_buffer(decoder, surface->decode_buffer);
decoder->set_decode_target(decoder, surface->video_buffer);
for (i = 0; i < 2; ++i) {
@@ -186,8 +184,6 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
if (!surface_priv)
return BadAlloc;
- if (context_priv->decoder->create_buffer)
- surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder);
surface_priv->video_buffer = pipe->create_video_buffer
(
pipe, PIPE_FORMAT_NV12, context_priv->decoder->chroma_format,
@@ -504,8 +500,6 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
SetDecoderStatus(surface_priv);
context_priv->decoder->end_frame(context_priv->decoder);
}
- if (surface_priv->decode_buffer)
- context_priv->decoder->destroy_buffer(context_priv->decoder, surface_priv->decode_buffer);
surface_priv->video_buffer->destroy(surface_priv->video_buffer);
FREE(surface_priv);
surface->privData = NULL;
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
index 5656c65..daddba5 100644
--- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
+++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
@@ -71,7 +71,6 @@ typedef struct
typedef struct
{
- void *decode_buffer;
struct pipe_video_buffer *video_buffer;
/* nonzero if this picture is already being decoded */
More information about the mesa-dev
mailing list