[Mesa-dev] [PATCH 1/3] vl: call decode_bitstream only once

Christian König deathsimple at vodafone.de
Mon Dec 26 05:00:44 PST 2011


Submit all bitstreams at once to decode_bitstream.

Signed-off-by: Christian König <deathsimple at vodafone.de>
---
 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   |    6 ++++--
 src/gallium/include/pipe/p_video_decoder.h     |    4 +++-
 src/gallium/state_trackers/vdpau/decode.c      |   11 +++++++----
 5 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
index 7e20d71..bd1f091 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 num_buffers,
+                   const void * const *buffers, const unsigned *sizes)
 {
    assert(bs);
 
-   vl_vlc_init(&bs->vlc, 1, (const void * const *)&buffer, &num_bytes);
+   vl_vlc_init(&bs->vlc, num_buffers, buffers, sizes);
    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..0ba7f43 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 num_buffers,
+                   const void * const *buffers, const unsigned *sizes);
 
 #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..e502fc6 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -690,7 +690,9 @@ 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)
+                           unsigned num_buffers,
+                           const void * const *buffers,
+                           const unsigned *sizes)
 {
    struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
    struct vl_mpeg12_buffer *buf;
@@ -706,7 +708,7 @@ vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder,
       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, num_buffers, buffers, sizes);
 }
 
 static void
diff --git a/src/gallium/include/pipe/p_video_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
index 40b7dcd..aa53589 100644
--- a/src/gallium/include/pipe/p_video_decoder.h
+++ b/src/gallium/include/pipe/p_video_decoder.h
@@ -116,7 +116,9 @@ struct pipe_video_decoder
     * decode a bitstream
     */
    void (*decode_bitstream)(struct pipe_video_decoder *decoder,
-                            unsigned num_bytes, const void *data);
+                            unsigned num_buffers,
+                            const void * const *buffers,
+                            const unsigned *sizes);
 
    /**
     * end decoding of the current frame
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 47212e3..a5a01fb 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -322,7 +322,6 @@ vlVdpDecoderRenderVC1(struct pipe_video_decoder *decoder,
 {
    struct pipe_vc1_picture_desc picture;
    struct pipe_video_buffer *ref_frames[2] = {};
-   unsigned i;
 
    VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
 
@@ -385,6 +384,8 @@ vlVdpDecoderRender(VdpDecoder decoder,
                    uint32_t bitstream_buffer_count,
                    VdpBitstreamBuffer const *bitstream_buffers)
 {
+   const void * buffers[bitstream_buffer_count];
+   unsigned sizes[bitstream_buffer_count];
    vlVdpDecoder *vldecoder;
    vlVdpSurface *vlsurf;
    VdpStatus ret;
@@ -435,9 +436,11 @@ vlVdpDecoderRender(VdpDecoder decoder,
       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);
+   for (i = 0; i < bitstream_buffer_count; ++i) {
+      buffers[i] = bitstream_buffers[i].bitstream;
+      sizes[i] = bitstream_buffers[i].bitstream_bytes;
+   }
+   dec->decode_bitstream(dec, bitstream_buffer_count, buffers, sizes);
    dec->end_frame(dec);
    return ret;
 }
-- 
1.7.5.4



More information about the mesa-dev mailing list