[Mesa-dev] [PATCH 2/2] vl: Merge remaining members
Maarten Lankhorst
m.b.lankhorst at gmail.com
Sat Dec 24 03:57:41 PST 2011
Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>
---
Flush explicitly ends the current frame so having a separate begin/endframe
is unneeded, and decode_bitstream always has to operate on a full picture.
src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c | 4
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 106 +++++------
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h | 3
src/gallium/drivers/nouveau/nouveau_video.c | 57 +-----
src/gallium/include/pipe/p_video_decoder.h | 46 +----
src/gallium/include/pipe/p_video_state.h | 15 --
src/gallium/state_trackers/vdpau/decode.c | 239 +++++++++++-------------
src/gallium/state_trackers/xorg/xvmc/surface.c | 102 +---------
8 files changed, 195 insertions(+), 377 deletions(-)
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 559d6c7..6130516 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
@@ -826,7 +826,7 @@ decode_slice(struct vl_mpg12_bs *bs)
inc += vl_vlc_get_vlclbf(&bs->vlc, tbl_B1, 11);
if (x != -1) {
mb.num_skipped_macroblocks = inc - 1;
- bs->decoder->decode_macroblock(bs->decoder, &mb.base, 1);
+ bs->decoder->decode_macroblock(bs->decoder, NULL, NULL, &mb.base, 1);
}
mb.x = x += inc;
@@ -930,7 +930,7 @@ decode_slice(struct vl_mpg12_bs *bs)
} while (vl_vlc_bits_left(&bs->vlc) && vl_vlc_peekbits(&bs->vlc, 23));
mb.num_skipped_macroblocks = 0;
- bs->decoder->decode_macroblock(bs->decoder, &mb.base, 1);
+ bs->decoder->decode_macroblock(bs->decoder, NULL, NULL, &mb.base, 1);
}
void
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 0896270..dbc07f5 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -51,6 +51,9 @@ struct format_config {
static void
vl_mpeg12_cleanup_buffer(struct pipe_video_decoder *decoder, void *buffer);
+static void
+vl_mpeg12_end_frame(struct pipe_video_decoder *decoder);
+
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 },
@@ -392,6 +395,7 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
unsigned i;
assert(decoder);
+ vl_mpeg12_end_frame(decoder);
for (i = 0; i < Elements(dec->buffers); ++i)
vl_mpeg12_cleanup_buffer(decoder, &dec->buffers[i]);
@@ -493,24 +497,31 @@ vl_mpeg12_set_picture_parameters(struct pipe_video_decoder *decoder,
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_mpeg12_picture_desc *pic = (struct pipe_mpeg12_picture_desc *)picture;
+ struct pipe_sampler_view **sv;
+ unsigned j;
assert(dec && pic);
dec->picture_desc = *pic;
-}
-
-static void
-vl_mpeg12_set_quant_matrix(struct pipe_video_decoder *decoder,
- const struct pipe_quant_matrix *matrix)
-{
- struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
- const struct pipe_mpeg12_quant_matrix *m = (const struct pipe_mpeg12_quant_matrix *)matrix;
-
- assert(dec);
- assert(matrix->codec == PIPE_VIDEO_CODEC_MPEG12);
+ if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+ memcpy(dec->intra_matrix, pic->intra_matrix, 64);
+ memcpy(dec->non_intra_matrix, pic->non_intra_matrix, 64);
+ }
+ if (pic->ref_forward) {
+ sv = pic->ref_forward->get_sampler_view_planes(pic->ref_forward);
+ for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[0][j], sv[j]);
+ } else
+ for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[0][j], NULL);
- memcpy(dec->intra_matrix, m->intra_matrix, 64);
- memcpy(dec->non_intra_matrix, m->non_intra_matrix, 64);
+ if (pic->ref_backward) {
+ sv = pic->ref_backward->get_sampler_view_planes(pic->ref_backward);
+ for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[1][j], sv[j]);
+ } else
+ for (j = 0; j < VL_MAX_PLANES; ++j)
+ pipe_sampler_view_reference(&dec->ref_frames[1][j], NULL);
}
static void
@@ -526,29 +537,7 @@ vl_mpeg12_set_decode_target(struct pipe_video_decoder *decoder,
surfaces = target->get_surfaces(target);
for (i = 0; i < VL_MAX_PLANES; ++i)
pipe_surface_reference(&dec->target_surfaces[i], surfaces[i]);
-}
-
-static void
-vl_mpeg12_set_reference_frames(struct pipe_video_decoder *decoder,
- struct pipe_video_buffer **ref_frames,
- unsigned num_ref_frames)
-{
- struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
- struct pipe_sampler_view **sv;
- unsigned i,j;
-
- assert(dec);
- assert(num_ref_frames <= VL_MAX_REF_FRAMES);
-
- for (i = 0; i < num_ref_frames; ++i) {
- sv = ref_frames[i]->get_sampler_view_planes(ref_frames[i]);
- for (j = 0; j < VL_MAX_PLANES; ++j)
- pipe_sampler_view_reference(&dec->ref_frames[i][j], sv[j]);
- }
-
- for (; i < VL_MAX_REF_FRAMES; ++i)
- for (j = 0; j < VL_MAX_PLANES; ++j)
- pipe_sampler_view_reference(&dec->ref_frames[i][j], NULL);
+ dec->last_target = (struct vl_video_buffer*)target;
}
static void
@@ -607,20 +596,30 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder)
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], dec->zscan_linear);
}
+ dec->started = 1;
}
static void
vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
+ struct pipe_video_buffer *target,
+ struct pipe_picture_desc *picture,
const struct pipe_macroblock *macroblocks,
unsigned num_macroblocks)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
const struct pipe_mpeg12_macroblock *mb = (const struct pipe_mpeg12_macroblock *)macroblocks;
struct vl_mpeg12_buffer *buf;
-
unsigned i, j, mv_weights[2];
- assert(dec && dec->current_buffer);
+ assert(dec);
+ if (picture)
+ vl_mpeg12_set_picture_parameters(decoder, picture);
+ if (target && (!dec->started || target != &dec->last_target->base)) {
+ vl_mpeg12_end_frame(decoder);
+ vl_mpeg12_set_decode_target(decoder, target);
+ vl_mpeg12_begin_frame(decoder);
+ }
+
assert(macroblocks && macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
buf = &dec->buffers[dec->current_buffer];
@@ -676,7 +675,10 @@ vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
}
static void
-vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder, unsigned n,
+vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder,
+ struct pipe_video_buffer *target,
+ struct pipe_picture_desc *picture,
+ unsigned n,
const unsigned *lens, const void *const*data)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
@@ -684,8 +686,11 @@ vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder, unsigned n,
unsigned i;
+ vl_mpeg12_set_picture_parameters(decoder, picture);
+ vl_mpeg12_set_decode_target(decoder, target);
assert(dec);
+ vl_mpeg12_begin_frame(decoder);
buf = &dec->buffers[dec->current_buffer];
for (i = 0; i < VL_MAX_PLANES; ++i)
@@ -693,6 +698,7 @@ vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder, unsigned n,
dec->zscan_alternate : dec->zscan_normal);
vl_mpg12_bs_decode(&buf->bs, n, lens, data);
+ vl_mpeg12_end_frame(decoder);
}
static void
@@ -702,11 +708,13 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
struct pipe_sampler_view **mc_source_sv;
struct pipe_vertex_buffer vb[3];
struct vl_mpeg12_buffer *buf;
-
unsigned i, j, component;
unsigned nr_components;
- assert(dec && dec->current_buffer);
+ assert(dec);
+ if (!dec->started)
+ return;
+ dec->started = 0;
buf = &dec->buffers[dec->current_buffer];
@@ -769,14 +777,6 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
}
}
-static void
-vl_mpeg12_flush(struct pipe_video_decoder *decoder)
-{
- assert(decoder);
-
- //Noop, for shaders it is much faster to flush everything in end_frame
-}
-
static bool
init_pipe_state(struct vl_mpeg12_decoder *dec)
{
@@ -1044,15 +1044,9 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
dec->base.max_references = max_references;
dec->base.destroy = vl_mpeg12_destroy;
- 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;
- dec->base.set_reference_frames = vl_mpeg12_set_reference_frames;
- dec->base.begin_frame = vl_mpeg12_begin_frame;
dec->base.decode_macroblock = vl_mpeg12_decode_macroblock;
dec->base.decode_bitstream = vl_mpeg12_decode_bitstream;
- dec->base.end_frame = vl_mpeg12_end_frame;
- dec->base.flush = vl_mpeg12_flush;
+ dec->base.flush = vl_mpeg12_end_frame;
dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
index c7fd3fc..20d3830 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
@@ -70,13 +70,14 @@ struct vl_mpeg12_decoder
unsigned blocks_per_line;
unsigned num_blocks;
- unsigned width_in_macroblocks;
+ unsigned width_in_macroblocks, started;
enum pipe_format zscan_source_format;
struct pipe_vertex_buffer quads;
struct pipe_vertex_buffer pos;
+ struct vl_video_buffer *last_target;
void *ves_ycbcr;
void *ves_mv;
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
index 3345f82..c0e65e4 100644
--- a/src/gallium/drivers/nouveau/nouveau_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_video.c
@@ -424,44 +424,26 @@ nouveau_decoder_surface_index(struct nouveau_decoder *dec,
}
static void
-nouveau_decoder_set_picture_parameters(struct pipe_video_decoder *decoder,
- struct pipe_picture_desc *picture_desc)
-{
- struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;
- struct pipe_mpeg12_picture_desc *desc;
- desc = (struct pipe_mpeg12_picture_desc *)picture_desc;
- dec->picture_structure = desc->picture_structure;
-}
-
-static void
-nouveau_decoder_set_reference_frames(struct pipe_video_decoder *decoder,
- struct pipe_video_buffer **buffers,
- unsigned count)
-{
- struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;
- if (count >= 1 && buffers[0])
- dec->past = nouveau_decoder_surface_index(dec, buffers[0]);
- if (count >= 2 && buffers[1])
- dec->future = nouveau_decoder_surface_index(dec, buffers[1]);
-}
-
-static void
-nouveau_decoder_set_decode_target(struct pipe_video_decoder *decoder,
- struct pipe_video_buffer *buffer)
-{
- struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;
- dec->current = nouveau_decoder_surface_index(dec, buffer);
-}
-
-static void
nouveau_decoder_decode_macroblock(struct pipe_video_decoder *decoder,
+ struct pipe_video_buffer *target,
+ struct pipe_picture_desc *picture,
const struct pipe_macroblock *pipe_mb,
unsigned num_macroblocks)
{
struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;
+ struct pipe_mpeg12_picture_desc *desc = (struct pipe_mpeg12_picture_desc*)picture;
const struct pipe_mpeg12_macroblock *mb;
unsigned i;
+ assert(target->width == decoder->width);
+ assert(target->height == decoder->height);
+
+ dec->current = nouveau_decoder_surface_index(dec, target);
assert(dec->current < 8);
+ dec->picture_structure = desc->picture_structure;
+ if (desc->ref_backward)
+ dec->future = nouveau_decoder_surface_index(dec, desc->ref_backward);
+ if (desc->ref_forward)
+ dec->past = nouveau_decoder_surface_index(dec, desc->ref_forward);
if (nouveau_vpe_init(dec)) return;
mb = (const struct pipe_mpeg12_macroblock *)pipe_mb;
@@ -511,16 +493,6 @@ nouveau_decoder_destroy(struct pipe_video_decoder *decoder)
FREE(dec);
}
-static void
-nouveau_decoder_begin_frame(struct pipe_video_decoder *decoder)
-{
-}
-
-static void
-nouveau_decoder_end_frame(struct pipe_video_decoder *decoder)
-{
-}
-
static struct pipe_video_decoder *
nouveau_create_decoder(struct pipe_context *context,
struct nouveau_screen *screen,
@@ -571,11 +543,6 @@ nouveau_create_decoder(struct pipe_context *context,
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.end_frame = nouveau_decoder_end_frame;
- dec->base.set_decode_target = nouveau_decoder_set_decode_target;
- dec->base.set_picture_parameters = nouveau_decoder_set_picture_parameters;
- dec->base.set_reference_frames = nouveau_decoder_set_reference_frames;
dec->base.decode_macroblock = nouveau_decoder_decode_macroblock;
dec->base.flush = nouveau_decoder_flush;
dec->screen = screen;
diff --git a/src/gallium/include/pipe/p_video_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
index 847f20f..3cf99cd 100644
--- a/src/gallium/include/pipe/p_video_decoder.h
+++ b/src/gallium/include/pipe/p_video_decoder.h
@@ -60,53 +60,23 @@ struct pipe_video_decoder
void (*destroy)(struct pipe_video_decoder *decoder);
/**
- * set the picture parameters for the next frame
- * only used for bitstream decoding
- */
- void (*set_picture_parameters)(struct pipe_video_decoder *decoder,
- struct pipe_picture_desc *picture);
-
- /**
- * set the quantification matrixes
- */
- void (*set_quant_matrix)(struct pipe_video_decoder *decoder,
- const struct pipe_quant_matrix *matrix);
-
- /**
- * set target where video data is decoded to
- */
- void (*set_decode_target)(struct pipe_video_decoder *decoder,
- struct pipe_video_buffer *target);
-
- /**
- * set reference frames for motion compensation
- */
- void (*set_reference_frames)(struct pipe_video_decoder *decoder,
- struct pipe_video_buffer **ref_frames,
- unsigned num_ref_frames);
-
- /**
- * start decoding of a new frame
- */
- void (*begin_frame)(struct pipe_video_decoder *decoder);
-
- /**
* decode a macroblock
*/
void (*decode_macroblock)(struct pipe_video_decoder *decoder,
+ struct pipe_video_buffer *target,
+ struct pipe_picture_desc *picture,
const struct pipe_macroblock *macroblocks,
unsigned num_macroblocks);
/**
* decode a bitstream
*/
- 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
- */
- void (*end_frame)(struct pipe_video_decoder *decoder);
+ void (*decode_bitstream)(struct pipe_video_decoder *decoder,
+ struct pipe_video_buffer *target,
+ struct pipe_picture_desc *picture,
+ unsigned num_buffers,
+ unsigned const *num_bytes,
+ const void *const *data);
/**
* flush any outstanding command buffers to the hardware
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index 9a70eb7..0650b19 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -124,6 +124,7 @@ struct pipe_macroblock
struct pipe_mpeg12_picture_desc
{
struct pipe_picture_desc base;
+ struct pipe_video_buffer *ref_forward, *ref_backward;
unsigned picture_coding_type;
unsigned picture_structure;
@@ -138,12 +139,6 @@ struct pipe_mpeg12_picture_desc
unsigned full_pel_forward_vector;
unsigned full_pel_backward_vector;
unsigned num_slices;
-};
-
-struct pipe_mpeg12_quant_matrix
-{
- struct pipe_quant_matrix base;
-
const uint8_t *intra_matrix;
const uint8_t *non_intra_matrix;
};
@@ -191,6 +186,7 @@ struct pipe_mpeg12_macroblock
struct pipe_mpeg4_picture_desc
{
struct pipe_picture_desc base;
+ struct pipe_video_buffer *ref_forward, *ref_backward;
int32_t trd[2];
int32_t trb[2];
uint16_t vop_time_increment_resolution;
@@ -205,12 +201,6 @@ struct pipe_mpeg4_picture_desc
uint8_t rounding_control;
uint8_t alternate_vertical_scan_flag;
uint8_t top_field_first;
-};
-
-struct pipe_mpeg4_quant_matrix
-{
- struct pipe_quant_matrix base;
-
const uint8_t *intra_matrix;
const uint8_t *non_intra_matrix;
};
@@ -218,6 +208,7 @@ struct pipe_mpeg4_quant_matrix
struct pipe_vc1_picture_desc
{
struct pipe_picture_desc base;
+ struct pipe_video_buffer *ref_forward, *ref_backward;
uint32_t slice_count;
uint8_t picture_type;
uint8_t frame_coding_mode;
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 5fff85d..7ff0f64 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -164,62 +164,46 @@ vlVdpDecoderGetParameters(VdpDecoder decoder,
* Decode a mpeg 1/2 video.
*/
static VdpStatus
-vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
+vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture,
VdpPictureInfoMPEG1Or2 *picture_info)
{
- struct pipe_mpeg12_picture_desc picture;
- struct pipe_mpeg12_quant_matrix quant;
- struct pipe_video_buffer *ref_frames[2];
- unsigned i;
-
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n");
- i = 0;
-
/* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
if (picture_info->forward_reference != VDP_INVALID_HANDLE) {
- ref_frames[i] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
- if (!ref_frames[i])
+ picture->ref_forward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
+ if (!picture->ref_forward)
return VDP_STATUS_INVALID_HANDLE;
- ++i;
}
+ else
+ picture->ref_forward = NULL;
if (picture_info->backward_reference != VDP_INVALID_HANDLE) {
- ref_frames[i] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
- if (!ref_frames[i])
+ picture->ref_backward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
+ if (!picture->ref_backward)
return VDP_STATUS_INVALID_HANDLE;
- ++i;
}
-
- decoder->set_reference_frames(decoder, ref_frames, i);
-
- memset(&picture, 0, sizeof(picture));
- picture.base.profile = decoder->profile;
- picture.picture_coding_type = picture_info->picture_coding_type;
- picture.picture_structure = picture_info->picture_structure;
- picture.frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
- picture.q_scale_type = picture_info->q_scale_type;
- picture.alternate_scan = picture_info->alternate_scan;
- picture.intra_vlc_format = picture_info->intra_vlc_format;
- picture.concealment_motion_vectors = picture_info->concealment_motion_vectors;
- picture.intra_dc_precision = picture_info->intra_dc_precision;
- picture.f_code[0][0] = picture_info->f_code[0][0] - 1;
- picture.f_code[0][1] = picture_info->f_code[0][1] - 1;
- picture.f_code[1][0] = picture_info->f_code[1][0] - 1;
- picture.f_code[1][1] = picture_info->f_code[1][1] - 1;
- picture.num_slices = picture_info->slice_count;
- picture.top_field_first = picture_info->top_field_first;
- picture.full_pel_forward_vector = picture_info->full_pel_forward_vector;
- picture.full_pel_backward_vector = picture_info->full_pel_backward_vector;
-
- decoder->set_picture_parameters(decoder, &picture.base);
-
- memset(&quant, 0, sizeof(quant));
- quant.base.codec = PIPE_VIDEO_CODEC_MPEG12;
- quant.intra_matrix = picture_info->intra_quantizer_matrix;
- quant.non_intra_matrix = picture_info->non_intra_quantizer_matrix;
-
- decoder->set_quant_matrix(decoder, &quant.base);
+ else
+ picture->ref_backward = NULL;
+
+ picture->picture_coding_type = picture_info->picture_coding_type;
+ picture->picture_structure = picture_info->picture_structure;
+ picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
+ picture->q_scale_type = picture_info->q_scale_type;
+ picture->alternate_scan = picture_info->alternate_scan;
+ picture->intra_vlc_format = picture_info->intra_vlc_format;
+ picture->concealment_motion_vectors = picture_info->concealment_motion_vectors;
+ picture->intra_dc_precision = picture_info->intra_dc_precision;
+ picture->f_code[0][0] = picture_info->f_code[0][0] - 1;
+ picture->f_code[0][1] = picture_info->f_code[0][1] - 1;
+ picture->f_code[1][0] = picture_info->f_code[1][0] - 1;
+ picture->f_code[1][1] = picture_info->f_code[1][1] - 1;
+ picture->num_slices = picture_info->slice_count;
+ picture->top_field_first = picture_info->top_field_first;
+ picture->full_pel_forward_vector = picture_info->full_pel_forward_vector;
+ picture->full_pel_backward_vector = picture_info->full_pel_backward_vector;
+ picture->intra_matrix = picture_info->intra_quantizer_matrix;
+ picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
return VDP_STATUS_OK;
}
@@ -227,114 +211,101 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
* Decode a mpeg 4 video.
*/
static VdpStatus
-vlVdpDecoderRenderMpeg4(struct pipe_video_decoder *decoder,
- VdpPictureInfoMPEG4Part2 *picture_info)
+vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture,
+ VdpPictureInfoMPEG4Part2 *picture_info)
{
- struct pipe_mpeg4_picture_desc picture;
- struct pipe_mpeg4_quant_matrix quant;
- struct pipe_video_buffer *ref_frames[2] = {};
unsigned i;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\n");
- /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
- if (picture_info->forward_reference != VDP_INVALID_HANDLE) {
- ref_frames[0] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
- if (!ref_frames[0])
+ if (picture_info->forward_reference != VDP_INVALID_HANDLE) {
+ picture->ref_forward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
+ if (!picture->ref_forward)
return VDP_STATUS_INVALID_HANDLE;
}
+ else
+ picture->ref_forward = NULL;
- if (picture_info->backward_reference != VDP_INVALID_HANDLE) {
- ref_frames[1] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
- if (!ref_frames[1])
+ if (picture_info->backward_reference != VDP_INVALID_HANDLE) {
+ picture->ref_backward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
+ if (!picture->ref_backward)
return VDP_STATUS_INVALID_HANDLE;
}
- decoder->set_reference_frames(decoder, ref_frames, 2);
+ else
+ picture->ref_backward = NULL;
- memset(&picture, 0, sizeof(picture));
- picture.base.profile = decoder->profile;
for (i = 0; i < 2; ++i) {
- picture.trd[i] = picture_info->trd[i];
- picture.trb[i] = picture_info->trb[i];
+ picture->trd[i] = picture_info->trd[i];
+ picture->trb[i] = picture_info->trb[i];
}
- picture.vop_time_increment_resolution = picture_info->vop_time_increment_resolution;
- picture.vop_coding_type = picture_info->vop_coding_type;
- picture.vop_fcode_forward = picture_info->vop_fcode_forward;
- picture.vop_fcode_backward = picture_info->vop_fcode_backward;
- picture.resync_marker_disable = picture_info->resync_marker_disable;
- picture.interlaced = picture_info->interlaced;
- picture.quant_type = picture_info->quant_type;
- picture.quarter_sample = picture_info->quarter_sample;
- picture.short_video_header = picture_info->short_video_header;
- picture.rounding_control = picture_info->rounding_control;
- picture.alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag;
- picture.top_field_first = picture_info->top_field_first;
- decoder->set_picture_parameters(decoder, &picture.base);
-
- memset(&quant, 0, sizeof(quant));
- quant.base.codec = PIPE_VIDEO_CODEC_MPEG4;
- quant.intra_matrix = picture_info->intra_quantizer_matrix;
- quant.non_intra_matrix = picture_info->non_intra_quantizer_matrix;
- decoder->set_quant_matrix(decoder, &quant.base);
+ picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution;
+ picture->vop_coding_type = picture_info->vop_coding_type;
+ picture->vop_fcode_forward = picture_info->vop_fcode_forward;
+ picture->vop_fcode_backward = picture_info->vop_fcode_backward;
+ picture->resync_marker_disable = picture_info->resync_marker_disable;
+ picture->interlaced = picture_info->interlaced;
+ picture->quant_type = picture_info->quant_type;
+ picture->quarter_sample = picture_info->quarter_sample;
+ picture->short_video_header = picture_info->short_video_header;
+ picture->rounding_control = picture_info->rounding_control;
+ picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag;
+ picture->top_field_first = picture_info->top_field_first;
+ picture->intra_matrix = picture_info->intra_quantizer_matrix;
+ picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
return VDP_STATUS_OK;
}
static VdpStatus
-vlVdpDecoderRenderVC1(struct pipe_video_decoder *decoder,
+vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture,
VdpPictureInfoVC1 *picture_info)
{
- struct pipe_vc1_picture_desc picture;
- struct pipe_video_buffer *ref_frames[2] = {};
- unsigned i;
-
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
- /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
if (picture_info->forward_reference != VDP_INVALID_HANDLE) {
- ref_frames[0] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
- if (!ref_frames[0])
+ picture->ref_forward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
+ if (!picture->ref_forward)
return VDP_STATUS_INVALID_HANDLE;
}
+ else
+ picture->ref_forward = NULL;
if (picture_info->backward_reference != VDP_INVALID_HANDLE) {
- ref_frames[1] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
- if (!ref_frames[1])
+ picture->ref_backward = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
+ if (!picture->ref_backward)
return VDP_STATUS_INVALID_HANDLE;
}
- decoder->set_reference_frames(decoder, ref_frames, 2);
-
- memset(&picture, 0, sizeof(picture));
- picture.base.profile = decoder->profile;
- picture.slice_count = picture_info->slice_count;
- picture.picture_type = picture_info->picture_type;
- picture.frame_coding_mode = picture_info->frame_coding_mode;
- picture.postprocflag = picture_info->postprocflag;
- picture.pulldown = picture_info->pulldown;
- picture.interlace = picture_info->interlace;
- picture.tfcntrflag = picture_info->tfcntrflag;
- picture.finterpflag = picture_info->finterpflag;
- picture.psf = picture_info->psf;
- picture.dquant = picture_info->dquant;
- picture.panscan_flag = picture_info->panscan_flag;
- picture.refdist_flag = picture_info->refdist_flag;
- picture.quantizer = picture_info->quantizer;
- picture.extended_mv = picture_info->extended_mv;
- picture.extended_dmv = picture_info->extended_dmv;
- picture.overlap = picture_info->overlap;
- picture.vstransform = picture_info->vstransform;
- picture.loopfilter = picture_info->loopfilter;
- picture.fastuvmc = picture_info->fastuvmc;
- picture.range_mapy_flag = picture_info->range_mapy_flag;
- picture.range_mapy = picture_info->range_mapy;
- picture.range_mapuv_flag = picture_info->range_mapuv_flag;
- picture.range_mapuv = picture_info->range_mapuv;
- picture.multires = picture_info->multires;
- picture.syncmarker = picture_info->syncmarker;
- picture.rangered = picture_info->rangered;
- picture.maxbframes = picture_info->maxbframes;
- picture.deblockEnable = picture_info->deblockEnable;
- picture.pquant = picture_info->pquant;
- decoder->set_picture_parameters(decoder, &picture.base);
+ else
+ picture->ref_backward = NULL;
+
+ picture->slice_count = picture_info->slice_count;
+ picture->picture_type = picture_info->picture_type;
+ picture->frame_coding_mode = picture_info->frame_coding_mode;
+ picture->postprocflag = picture_info->postprocflag;
+ picture->pulldown = picture_info->pulldown;
+ picture->interlace = picture_info->interlace;
+ picture->tfcntrflag = picture_info->tfcntrflag;
+ picture->finterpflag = picture_info->finterpflag;
+ picture->psf = picture_info->psf;
+ picture->dquant = picture_info->dquant;
+ picture->panscan_flag = picture_info->panscan_flag;
+ picture->refdist_flag = picture_info->refdist_flag;
+ picture->quantizer = picture_info->quantizer;
+ picture->extended_mv = picture_info->extended_mv;
+ picture->extended_dmv = picture_info->extended_dmv;
+ picture->overlap = picture_info->overlap;
+ picture->vstransform = picture_info->vstransform;
+ picture->loopfilter = picture_info->loopfilter;
+ picture->fastuvmc = picture_info->fastuvmc;
+ picture->range_mapy_flag = picture_info->range_mapy_flag;
+ picture->range_mapy = picture_info->range_mapy;
+ picture->range_mapuv_flag = picture_info->range_mapuv_flag;
+ picture->range_mapuv = picture_info->range_mapuv;
+ picture->multires = picture_info->multires;
+ picture->syncmarker = picture_info->syncmarker;
+ picture->rangered = picture_info->rangered;
+ picture->maxbframes = picture_info->maxbframes;
+ picture->deblockEnable = picture_info->deblockEnable;
+ picture->pquant = picture_info->pquant;
return VDP_STATUS_OK;
}
@@ -353,6 +324,12 @@ vlVdpDecoderRender(VdpDecoder decoder,
VdpStatus ret;
struct pipe_video_decoder *dec;
unsigned i;
+ union {
+ struct pipe_picture_desc base;
+ struct pipe_mpeg12_picture_desc mpeg12;
+ struct pipe_mpeg4_picture_desc mpeg4;
+ struct pipe_vc1_picture_desc vc1;
+ } desc;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding\n");
@@ -375,17 +352,17 @@ vlVdpDecoderRender(VdpDecoder decoder,
// TODO: Recreate decoder with correct chroma
return VDP_STATUS_INVALID_CHROMA_TYPE;
- dec->set_decode_target(dec, vlsurf->video_buffer);
-
+ memset(&desc, 0, sizeof(desc));
+ desc.base.profile = dec->profile;
switch (u_reduce_video_profile(dec->profile)) {
case PIPE_VIDEO_CODEC_MPEG12:
- ret = vlVdpDecoderRenderMpeg12(dec, (VdpPictureInfoMPEG1Or2 *)picture_info);
+ ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info);
break;
case PIPE_VIDEO_CODEC_MPEG4:
- ret = vlVdpDecoderRenderMpeg4(dec, (VdpPictureInfoMPEG4Part2 *)picture_info);
+ ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info);
break;
case PIPE_VIDEO_CODEC_VC1:
- ret = vlVdpDecoderRenderVC1(dec, (VdpPictureInfoVC1 *)picture_info);
+ ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info);
break;
default:
return VDP_STATUS_INVALID_DECODER_PROFILE;
@@ -400,11 +377,9 @@ vlVdpDecoderRender(VdpDecoder decoder,
data[i] = bitstream_buffers[i].bitstream;
sizes[i] = bitstream_buffers[i].bitstream_bytes;
}
- dec->begin_frame(dec);
- dec->decode_bitstream(dec,
+ dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base,
bitstream_buffer_count,
sizes, data);
- dec->end_frame(dec);
} else
return VDP_STATUS_INVALID_VALUE;
return ret;
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index b4447c4..93d9a16 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -96,71 +96,6 @@ MacroBlocksToPipe(XvMCContextPrivate *context,
}
}
-static void
-SetDecoderStatus(XvMCSurfacePrivate *surface)
-{
- struct pipe_video_decoder *decoder;
- struct pipe_video_buffer *ref_frames[2];
- struct pipe_mpeg12_picture_desc desc = { { PIPE_VIDEO_PROFILE_MPEG1} };
-
- XvMCContextPrivate *context_priv;
-
- unsigned i, num_refs = 0;
-
- desc.picture_structure = surface->picture_structure;
-
- assert(surface);
-
- context_priv = surface->context->privData;
- decoder = context_priv->decoder;
-
- decoder->set_decode_target(decoder, surface->video_buffer);
-
- for (i = 0; i < 2; ++i) {
- if (surface->ref[i]) {
- XvMCSurfacePrivate *ref = surface->ref[i]->privData;
-
- if (ref)
- ref_frames[num_refs++] = ref->video_buffer;
- }
- }
- decoder->set_reference_frames(decoder, ref_frames, num_refs);
- decoder->set_picture_parameters(context_priv->decoder, &desc.base);
-}
-
-static void
-RecursiveEndFrame(XvMCSurfacePrivate *surface)
-{
- XvMCContextPrivate *context_priv;
- unsigned i;
-
- assert(surface);
-
- context_priv = surface->context->privData;
-
- for ( i = 0; i < 2; ++i ) {
- if (surface->ref[i]) {
- XvMCSurface *ref = surface->ref[i];
-
- assert(ref);
-
- surface->ref[i] = NULL;
- RecursiveEndFrame(ref->privData);
- surface->ref[i] = ref;
- }
- }
-
- if (surface->picture_structure) {
- SetDecoderStatus(surface);
- surface->picture_structure = 0;
-
- for (i = 0; i < 2; ++i)
- surface->ref[i] = NULL;
-
- context_priv->decoder->end_frame(context_priv->decoder);
- }
-}
-
PUBLIC
Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
{
@@ -214,7 +149,7 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
)
{
struct pipe_mpeg12_macroblock mb[num_macroblocks];
- struct pipe_video_decoder *decoder;
+ struct pipe_mpeg12_picture_desc desc = { { PIPE_VIDEO_PROFILE_MPEG1} };
XvMCContextPrivate *context_priv;
XvMCSurfacePrivate *target_surface_priv;
@@ -253,7 +188,6 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
assert(flags == 0 || flags == XVMC_SECOND_FIELD);
context_priv = context->privData;
- decoder = context_priv->decoder;
target_surface_priv = target_surface->privData;
past_surface_priv = past_surface ? past_surface->privData : NULL;
@@ -264,12 +198,6 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
assert(!future_surface || future_surface_priv->context == context);
// call end frame on all referenced frames
- if (past_surface)
- RecursiveEndFrame(past_surface->privData);
-
- if (future_surface)
- RecursiveEndFrame(future_surface->privData);
-
xvmc_mb = macroblocks->macro_blocks + first_macroblock;
/* If the surface we're rendering hasn't changed the ref frames shouldn't change. */
@@ -280,24 +208,24 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
(xvmc_mb->x == 0 && xvmc_mb->y == 0))) {
// If they change anyway we must assume that the current frame is ended
- RecursiveEndFrame(target_surface_priv);
+ context_priv->decoder->flush(context_priv->decoder);
}
target_surface_priv->ref[0] = past_surface;
target_surface_priv->ref[1] = future_surface;
- if (target_surface_priv->picture_structure)
- SetDecoderStatus(target_surface_priv);
- else {
- target_surface_priv->picture_structure = picture_structure;
- SetDecoderStatus(target_surface_priv);
- decoder->begin_frame(decoder);
- }
+ target_surface_priv->picture_structure = picture_structure;
+
+ desc.picture_structure = picture_structure;
+ if (past_surface)
+ desc.ref_forward = ((XvMCSurfacePrivate*)past_surface->privData)->video_buffer;
+ if (future_surface)
+ desc.ref_backward = ((XvMCSurfacePrivate*)future_surface->privData)->video_buffer;
MacroBlocksToPipe(context_priv, target_surface_priv, picture_structure,
xvmc_mb, blocks, mb, num_macroblocks);
- context_priv->decoder->decode_macroblock(context_priv->decoder, &mb[0].base, num_macroblocks);
+ context_priv->decoder->decode_macroblock(context_priv->decoder, target_surface_priv->video_buffer, &desc.base, &mb[0].base, num_macroblocks);
XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for rendering.\n", target_surface);
@@ -361,6 +289,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
surface_priv = surface->privData;
context = surface_priv->context;
context_priv = context->privData;
+ context_priv->decoder->flush(context_priv->decoder);
assert(flags == XVMC_TOP_FIELD || flags == XVMC_BOTTOM_FIELD || flags == XVMC_FRAME_PICTURE);
assert(srcx + srcw - 1 < surface->width);
@@ -395,10 +324,6 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
assert(desty + desth - 1 < drawable_surface->height);
*/
- RecursiveEndFrame(surface_priv);
-
- context_priv->decoder->flush(context_priv->decoder);
-
vl_compositor_clear_layers(compositor);
vl_compositor_set_buffer_layer(compositor, 0, surface_priv->video_buffer, &src_rect, NULL);
@@ -495,11 +420,6 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
surface_priv = surface->privData;
context_priv = surface_priv->context->privData;
-
- if (surface_priv->picture_structure) {
- SetDecoderStatus(surface_priv);
- context_priv->decoder->end_frame(context_priv->decoder);
- }
surface_priv->video_buffer->destroy(surface_priv->video_buffer);
FREE(surface_priv);
surface->privData = NULL;
More information about the mesa-dev
mailing list