[PATCH 5/6] g3dvl: Rework the decoder interface part 5/6

Christian König deathsimple at vodafone.de
Fri Aug 12 04:29:00 PDT 2011


Make setting the quant matrixes a generic interface.
Also removes setting the quant matrix from the XvMC interface
---
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c   |   15 +++++++++++----
 src/gallium/include/pipe/p_video_decoder.h     |    3 +--
 src/gallium/include/pipe/p_video_state.h       |   14 ++++++++++++++
 src/gallium/state_trackers/vdpau/decode.c      |   12 ++++++++----
 src/gallium/state_trackers/xorg/xvmc/surface.c |   12 ------------
 5 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 97eee95..709939f 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -506,15 +506,16 @@ vl_mpeg12_set_picture_parameters(struct pipe_video_decoder *decoder,
 
 static void
 vl_mpeg12_set_quant_matrix(struct pipe_video_decoder *decoder,
-                           const uint8_t intra_matrix[64],
-                           const uint8_t non_intra_matrix[64])
+                           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);
 
-   memcpy(dec->intra_matrix, intra_matrix, 64);
-   memcpy(dec->non_intra_matrix, non_intra_matrix, 64);
+   memcpy(dec->intra_matrix, m->intra_matrix, 64);
+   memcpy(dec->non_intra_matrix, m->non_intra_matrix, 64);
 }
 
 static void
@@ -569,6 +570,9 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder)
    buf = dec->current_buffer;
    assert(buf);
 
+   if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
+      dec->intra_matrix[0] = 1 << (7 - dec->picture_desc.intra_dc_precision);
+
    for (i = 0; i < VL_MAX_PLANES; ++i) {
       vl_zscan_upload_quant(&buf->zscan[i], dec->intra_matrix, true);
       vl_zscan_upload_quant(&buf->zscan[i], dec->non_intra_matrix, false);
@@ -1111,6 +1115,9 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
    if (!init_pipe_state(dec))
       goto error_pipe_state;
 
+   memset(dec->intra_matrix, 0x10, 64);
+   memset(dec->non_intra_matrix, 0x10, 64);
+
    return &dec->base;
 
 error_pipe_state:
diff --git a/src/gallium/include/pipe/p_video_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
index 0ffb32c..06b6803 100644
--- a/src/gallium/include/pipe/p_video_decoder.h
+++ b/src/gallium/include/pipe/p_video_decoder.h
@@ -84,8 +84,7 @@ struct pipe_video_decoder
     * set the quantification matrixes
     */
    void (*set_quant_matrix)(struct pipe_video_decoder *decoder,
-                            const uint8_t intra_matrix[64],
-                            const uint8_t non_intra_matrix[64]);
+                            const struct pipe_quant_matrix *matrix);
 
    /**
     * set target where video data is decoded to
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index df021ee..f2d3446 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -99,6 +99,11 @@ struct pipe_picture_desc
    enum pipe_video_profile profile;
 };
 
+struct pipe_quant_matrix
+{
+   enum pipe_video_codec codec;
+};
+
 struct pipe_macroblock
 {
    enum pipe_video_codec codec;
@@ -115,9 +120,18 @@ struct pipe_mpeg12_picture_desc
    unsigned alternate_scan;
    unsigned intra_vlc_format;
    unsigned concealment_motion_vectors;
+   unsigned intra_dc_precision;
    unsigned f_code[2][2];
 };
 
+struct pipe_mpeg12_quant_matrix
+{
+   struct pipe_quant_matrix base;
+
+   const uint8_t *intra_matrix;
+   const uint8_t *non_intra_matrix;
+};
+
 struct pipe_mpeg12_macroblock
 {
    struct pipe_macroblock base;
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 5ca40f7..50d63ea 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -182,8 +182,8 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
                          VdpBitstreamBuffer const *bitstream_buffers)
 {
    struct pipe_mpeg12_picture_desc picture;
+   struct pipe_mpeg12_quant_matrix quant;
    struct pipe_video_buffer *ref_frames[2];
-   uint8_t intra_quantizer_matrix[64];
    unsigned i;
 
    VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG2\n");
@@ -216,6 +216,7 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
    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;
@@ -223,9 +224,12 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
 
    decoder->set_picture_parameters(decoder, &picture.base);
 
-   memcpy(intra_quantizer_matrix, picture_info->intra_quantizer_matrix, sizeof(intra_quantizer_matrix));
-   intra_quantizer_matrix[0] = 1 << (7 - picture_info->intra_dc_precision);
-   decoder->set_quant_matrix(decoder, intra_quantizer_matrix, picture_info->non_intra_quantizer_matrix);
+   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);
 
    decoder->begin_frame(decoder);
 
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index 35a1dcd..9743893 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -161,17 +161,6 @@ RecursiveEndFrame(XvMCSurfacePrivate *surface)
 PUBLIC
 Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
 {
-   static const uint8_t dummy_quant[64] = {
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
-   };
-
    XvMCContextPrivate *context_priv;
    struct pipe_context *pipe;
    XvMCSurfacePrivate *surface_priv;
@@ -193,7 +182,6 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
       return BadAlloc;
 
    surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder);
-   context_priv->decoder->set_quant_matrix(context_priv->decoder, dummy_quant, dummy_quant);
    surface_priv->video_buffer = pipe->create_video_buffer
    (
       pipe, PIPE_FORMAT_NV12, context_priv->decoder->chroma_format,
-- 
1.7.4.1


--=-E2LaaR1qGLHh7xkpYB8v
Content-Disposition: attachment; filename="0006-g3dvl-Rework-the-decoder-interface-part-6-6.patch"
Content-Type: text/x-patch; name="0006-g3dvl-Rework-the-decoder-interface-part-6-6.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit



More information about the mesa-dev mailing list