[Mesa-dev] [PATCH 3/3] vl: replace decode_buffers with auxiliary data field

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


Based on patches from Maarten Lankhorst <m.b.lankhorst at gmail.com>

Signed-off-by: Christian König <deathsimple at vodafone.de>
---
 src/gallium/auxiliary/vl/vl_decoder.c              |   20 +---
 src/gallium/auxiliary/vl/vl_decoder.h              |    9 +--
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c       |  100 ++++++++++----------
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.h       |   10 ++-
 src/gallium/auxiliary/vl/vl_video_buffer.c         |   29 ++++++
 src/gallium/auxiliary/vl/vl_video_buffer.h         |   16 +++
 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_context.h               |    3 +-
 src/gallium/include/pipe/p_video_decoder.h         |   30 +++---
 src/gallium/include/pipe/p_video_enums.h           |    3 +-
 src/gallium/state_trackers/vdpau/decode.c          |   43 +--------
 src/gallium/state_trackers/vdpau/vdpau_private.h   |    3 -
 src/gallium/state_trackers/xorg/xvmc/context.c     |    3 +-
 src/gallium/state_trackers/xorg/xvmc/surface.c     |    6 -
 .../state_trackers/xorg/xvmc/xvmc_private.h        |    1 -
 19 files changed, 134 insertions(+), 152 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c
index 383e02d..a88347f 100644
--- a/src/gallium/auxiliary/vl/vl_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_decoder.c
@@ -44,25 +44,13 @@ 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,
                   enum pipe_video_entrypoint entrypoint,
                   enum pipe_video_chroma_format chroma_format,
-                  unsigned width, unsigned height, unsigned max_references)
+                  unsigned width, unsigned height, unsigned max_references,
+                  bool expect_chunked_decode)
 {
    unsigned buffer_width, buffer_height;
    bool pot_buffers;
@@ -82,7 +70,9 @@ vl_create_decoder(struct pipe_context *pipe,
 
    switch (u_reduce_video_profile(profile)) {
       case PIPE_VIDEO_CODEC_MPEG12:
-         return vl_create_mpeg12_decoder(pipe, profile, entrypoint, chroma_format, buffer_width, buffer_height, max_references);
+         return vl_create_mpeg12_decoder(pipe, profile, entrypoint, chroma_format,
+                                         buffer_width, buffer_height, max_references,
+                                         expect_chunked_decode);
       default:
          return NULL;
    }
diff --git a/src/gallium/auxiliary/vl/vl_decoder.h b/src/gallium/auxiliary/vl/vl_decoder.h
index a997516..8fa6527 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 *
@@ -51,6 +45,7 @@ vl_create_decoder(struct pipe_context *pipe,
                   enum pipe_video_profile profile,
                   enum pipe_video_entrypoint entrypoint,
                   enum pipe_video_chroma_format chroma_format,
-                  unsigned width, unsigned height, unsigned max_references);
+                  unsigned width, unsigned height, unsigned max_references,
+                  bool expect_chunked_decode);
 
 #endif /* vl_decoder_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 04253ef..00d9694 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -383,9 +383,25 @@ UploadYcbcrBlocks(struct vl_mpeg12_decoder *dec,
 }
 
 static void
+vl_mpeg12_destroy_buffer(void *buffer)
+{
+   struct vl_mpeg12_buffer *buf = buffer;
+
+   assert(buf);
+
+   cleanup_zscan_buffer(buf);
+   cleanup_idct_buffer(buf);
+   cleanup_mc_buffer(buf);
+   vl_vb_cleanup(&buf->vertex_stream);
+
+   FREE(buf);
+}
+
+static void
 vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
 {
    struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
+   unsigned i;
 
    assert(decoder);
 
@@ -419,17 +435,28 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
    pipe_sampler_view_reference(&dec->zscan_normal, NULL);
    pipe_sampler_view_reference(&dec->zscan_alternate, NULL);
 
+   for (i = 0; i < 4; ++i)
+      if (dec->dec_buffers[i])
+         vl_mpeg12_destroy_buffer(dec->dec_buffers[i]);
+
    FREE(dec);
 }
 
-static void *
-vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
+static struct vl_mpeg12_buffer *
+vl_mpeg12_get_decode_buffer(struct vl_mpeg12_decoder *dec)
 {
-   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
    struct vl_mpeg12_buffer *buffer;
 
    assert(dec);
 
+   buffer = vl_video_buffer_get_associated_data(dec->target, &dec->base);
+   if (buffer)
+      return buffer;
+
+   buffer = dec->dec_buffers[dec->current_buffer];
+   if (buffer)
+      return buffer;
+
    buffer = CALLOC_STRUCT(vl_mpeg12_buffer);
    if (buffer == NULL)
       return NULL;
@@ -450,13 +477,18 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
       goto error_zscan;
 
    if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
-      vl_mpg12_bs_init(&buffer->bs, decoder);
+      vl_mpg12_bs_init(&buffer->bs, &dec->base);
+
+   if (dec->expect_chunked_decode)
+      vl_video_buffer_set_associated_data(dec->target, &dec->base,
+                                          buffer, vl_mpeg12_destroy_buffer);
+   else
+      dec->dec_buffers[dec->current_buffer] = buffer;
 
    return buffer;
 
 error_zscan:
-   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
-      cleanup_idct_buffer(buffer);
+   cleanup_idct_buffer(buffer);
 
 error_idct:
    cleanup_mc_buffer(buffer);
@@ -470,36 +502,6 @@ error_vertex_buffer:
 }
 
 static void
-vl_mpeg12_destroy_buffer(struct pipe_video_decoder *decoder, void *buffer)
-{
-   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
-   struct vl_mpeg12_buffer *buf = buffer;
-
-   assert(dec && buf);
-
-   cleanup_zscan_buffer(buf);
-
-   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
-      cleanup_idct_buffer(buf);
-
-   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
 vl_mpeg12_set_picture_parameters(struct pipe_video_decoder *decoder,
                                  struct pipe_picture_desc *picture)
 {
@@ -535,6 +537,7 @@ vl_mpeg12_set_decode_target(struct pipe_video_decoder *decoder,
 
    assert(dec);
 
+   dec->target = target;
    surfaces = target->get_surfaces(target);
    for (i = 0; i < VL_MAX_PLANES; ++i)
       pipe_surface_reference(&dec->target_surfaces[i], surfaces[i]);
@@ -574,9 +577,9 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder)
 
    unsigned i;
 
-   assert(dec);
+   assert(dec && dec->target);
 
-   buf = dec->current_buffer;
+   buf = vl_mpeg12_get_decode_buffer(dec);
    assert(buf);
 
    if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
@@ -633,10 +636,10 @@ vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
 
    unsigned i, j, mv_weights[2];
 
-   assert(dec && dec->current_buffer);
+   assert(dec && dec->target);
    assert(macroblocks && macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
 
-   buf = dec->current_buffer;
+   buf = vl_mpeg12_get_decode_buffer(dec);
    assert(buf);
 
    for (; num_macroblocks > 0; --num_macroblocks) {
@@ -700,9 +703,9 @@ vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder,
    
    unsigned i;
 
-   assert(dec && dec->current_buffer);
+   assert(dec && dec->target);
 
-   buf = dec->current_buffer;
+   buf = vl_mpeg12_get_decode_buffer(dec);
    assert(buf);
 
    for (i = 0; i < VL_MAX_PLANES; ++i)
@@ -723,9 +726,9 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
    unsigned i, j, component;
    unsigned nr_components;
 
-   assert(dec && dec->current_buffer);
+   assert(dec && dec->target);
 
-   buf = dec->current_buffer;
+   buf = vl_mpeg12_get_decode_buffer(dec);
 
    vl_vb_unmap(&buf->vertex_stream, dec->base.context);
 
@@ -784,6 +787,8 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
          vl_mc_render_ycbcr(i ? &dec->mc_c : &dec->mc_y, &buf->mc[i], j, buf->num_ycbcr_blocks[component]);
       }
    }
+   ++dec->current_buffer;
+   dec->current_buffer %= 4;
 }
 
 static void
@@ -1038,7 +1043,8 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
                          enum pipe_video_profile profile,
                          enum pipe_video_entrypoint entrypoint,
                          enum pipe_video_chroma_format chroma_format,
-                         unsigned width, unsigned height, unsigned max_references)
+                         unsigned width, unsigned height, unsigned max_references,
+                         bool expect_chunked_decode)
 {
    const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT;
    const struct format_config *format_config;
@@ -1060,9 +1066,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;
@@ -1076,6 +1079,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
    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;
    dec->width_in_macroblocks = align(dec->base.width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
+   dec->expect_chunked_decode = expect_chunked_decode;
 
    /* TODO: Implement 422, 444 */
    assert(dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
index 817c1ff..c5dff49 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
@@ -50,6 +50,7 @@ struct vl_mpeg12_decoder
    unsigned blocks_per_line;
    unsigned num_blocks;
    unsigned width_in_macroblocks;
+   bool expect_chunked_decode;
 
    enum pipe_format zscan_source_format;
 
@@ -74,11 +75,15 @@ struct vl_mpeg12_decoder
 
    void *dsa;
 
-   struct vl_mpeg12_buffer *current_buffer;
+   unsigned current_buffer;
+   struct vl_mpeg12_buffer *dec_buffers[4];
+
    struct pipe_mpeg12_picture_desc picture_desc;
    uint8_t intra_matrix[64];
    uint8_t non_intra_matrix[64];
    struct pipe_sampler_view *ref_frames[VL_MAX_REF_FRAMES][VL_MAX_PLANES];
+
+   struct pipe_video_buffer *target;
    struct pipe_surface *target_surfaces[VL_MAX_PLANES];
 };
 
@@ -111,6 +116,7 @@ vl_create_mpeg12_decoder(struct pipe_context *pipe,
                          enum pipe_video_profile profile,
                          enum pipe_video_entrypoint entrypoint,
                          enum pipe_video_chroma_format chroma_format,
-                         unsigned width, unsigned height, unsigned max_references);
+                         unsigned width, unsigned height, unsigned max_references,
+                         bool expect_chunked_decode);
 
 #endif /* vl_mpeg12_decoder_h */
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
index 6d714d4..8ceb713 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -98,6 +98,34 @@ vl_video_buffer_max_size(struct pipe_screen *screen)
    return 1 << (max_2d_texture_level-1);
 }
 
+void
+vl_video_buffer_set_associated_data(struct pipe_video_buffer *vbuf,
+                                    struct pipe_video_decoder *vdec,
+                                    void *associated_data,
+                                    void (*destroy_associated_data)(void *))
+{
+   vbuf->decoder = vdec;
+
+   if (vbuf->associated_data == associated_data)
+      return;
+
+   if (vbuf->associated_data)
+      vbuf->destroy_associated_data(vbuf->associated_data);
+
+   vbuf->associated_data = associated_data;
+   vbuf->destroy_associated_data = destroy_associated_data;
+}
+
+void *
+vl_video_buffer_get_associated_data(struct pipe_video_buffer *vbuf,
+                                    struct pipe_video_decoder *vdec)
+{
+   if (vbuf->decoder == vdec)
+      return vbuf->associated_data;
+   else
+      return NULL;
+}
+
 static void
 vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
 {
@@ -112,6 +140,7 @@ vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
       pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
       pipe_resource_reference(&buf->resources[i], NULL);
    }
+   vl_video_buffer_set_associated_data(buffer, NULL, NULL, NULL);
 
    FREE(buffer);
 }
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h
index 8c80b36..e096ccd 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.h
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.h
@@ -69,6 +69,22 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen,
                                     enum pipe_format format,
                                     enum pipe_video_profile profile);
 
+/*
+ * set the associated data for the given video buffer
+ */
+void
+vl_video_buffer_set_associated_data(struct pipe_video_buffer *vbuf,
+                                    struct pipe_video_decoder *vdec,
+                                    void *associated_data,
+                                    void (*destroy_associated_data)(void *));
+
+/*
+ * get the associated data for the given video buffer
+ */
+void *
+vl_video_buffer_get_associated_data(struct pipe_video_buffer *vbuf,
+                                    struct pipe_video_decoder *vdec);
+
 /**
  * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer
  */
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 eb75a53..d79ed99 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -307,8 +307,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 7f62e0e..cb661a6 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -541,8 +541,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_context.h b/src/gallium/include/pipe/p_context.h
index de79a9b..f7ee522 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -410,7 +410,8 @@ struct pipe_context {
                                                        enum pipe_video_profile profile,
                                                        enum pipe_video_entrypoint entrypoint,
                                                        enum pipe_video_chroma_format chroma_format,
-                                                       unsigned width, unsigned height, unsigned max_references );
+                                                       unsigned width, unsigned height, unsigned max_references,
+                                                       bool expect_chunked_decode);
 
    /**
     * Creates a video buffer as decoding target
diff --git a/src/gallium/include/pipe/p_video_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
index aa53589..69e59a6 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
     */
@@ -163,6 +148,21 @@ struct pipe_video_buffer
     * get a individual surfaces for each plane
     */
    struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
+
+   /*
+    * auxiliary associated data
+    */
+   void *associated_data;
+
+   /*
+    * decoder where the associated data came from
+    */
+   struct pipe_video_decoder *decoder;
+
+   /*
+    * destroy the associated data
+    */
+   void (*destroy_associated_data)(void *associated_data);
 };
 
 #ifdef __cplusplus
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 a5a01fb..ab7bf11 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");
@@ -90,7 +89,8 @@ vlVdpDecoderCreate(VdpDevice device,
       pipe, p_profile,
       PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
       PIPE_VIDEO_CHROMA_FORMAT_420,
-      width, height, max_references
+      width, height, max_references,
+      false
    );
 
    if (!vldecoder->decoder) {
@@ -98,25 +98,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,15 +109,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);
 
@@ -152,7 +124,6 @@ VdpStatus
 vlVdpDecoderDestroy(VdpDecoder decoder)
 {
    vlVdpDecoder *vldecoder;
-   unsigned i;
 
    VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying decoder\n");
 
@@ -160,12 +131,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);
@@ -413,10 +378,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)) {
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/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c
index 848da40..b11f10f 100644
--- a/src/gallium/state_trackers/xorg/xvmc/context.c
+++ b/src/gallium/state_trackers/xorg/xvmc/context.c
@@ -250,7 +250,8 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
       ProfileToPipe(mc_type),
       (mc_type & XVMC_IDCT) ? PIPE_VIDEO_ENTRYPOINT_IDCT : PIPE_VIDEO_ENTRYPOINT_MC,
       FormatToPipe(chroma_format),
-      width, height, 2
+      width, height, 2,
+      true
    );
 
    if (!context_priv->decoder) {
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 */
-- 
1.7.5.4



More information about the mesa-dev mailing list