xvmc: Replace frame_started by picture_structure
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Fri, 2 Sep 2011 14:20:02 +0000 (16:20 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 4 Sep 2011 11:51:50 +0000 (13:51 +0200)
The preferred solution to keeping track of the picture structure
has been putting it in the state tracker, so use picture_structure
instead of frame_started to check if a frame needs to begin.

If picture_structure has been changed, end the frame and start again.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h

index 9a512c4367028a45abafb54a0c87e463ffc1100d..e6c5a898b052cb738af8c4b74cafa459de40bfae 100644 (file)
@@ -101,11 +101,14 @@ 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;
@@ -124,6 +127,7 @@ SetDecoderStatus(XvMCSurfacePrivate *surface)
       }
    }
    decoder->set_reference_frames(decoder, ref_frames, num_refs);
+   decoder->set_picture_parameters(context_priv->decoder, &desc.base);
 }
 
 static void
@@ -148,9 +152,9 @@ RecursiveEndFrame(XvMCSurfacePrivate *surface)
       }
    }
 
-   if (surface->frame_started) {
-      surface->frame_started = 0;
+   if (surface->picture_structure) {
       SetDecoderStatus(surface);
+      surface->picture_structure = 0;
 
       for (i = 0; i < 2; ++i)
          surface->ref[i] = NULL;
@@ -273,7 +277,8 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
    xvmc_mb = macroblocks->macro_blocks + first_macroblock;
 
    /* If the surface we're rendering hasn't changed the ref frames shouldn't change. */
-   if (target_surface_priv->frame_started && (
+   if (target_surface_priv->picture_structure > 0 && (
+       target_surface_priv->picture_structure != picture_structure ||
        target_surface_priv->ref[0] != past_surface ||
        target_surface_priv->ref[1] != future_surface ||
        (xvmc_mb->x == 0 && xvmc_mb->y == 0))) {
@@ -285,10 +290,11 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
    target_surface_priv->ref[0] = past_surface;
    target_surface_priv->ref[1] = future_surface;
 
-   SetDecoderStatus(target_surface_priv);
-
-   if (!target_surface_priv->frame_started) {
-      target_surface_priv->frame_started = 1;
+   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);
    }
 
@@ -494,7 +500,7 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
    surface_priv = surface->privData;
    context_priv = surface_priv->context->privData;
    
-   if (surface_priv->frame_started) {
+   if (surface_priv->picture_structure) {
       SetDecoderStatus(surface_priv);
       context_priv->decoder->end_frame(context_priv->decoder);
    }
index 43ae71713890e4e5412adfaac8a923c99ad0bc34..305e51fb4164988ab06c2d47010e6c7c2710e480 100644 (file)
@@ -72,8 +72,8 @@ typedef struct
    void *decode_buffer;
    struct pipe_video_buffer *video_buffer;
 
-   // have we allready told the decoder to start a frame
-   bool frame_started;
+   /* nonzero if this picture is already being decoded */
+   int picture_structure;
 
    XvMCSurface *ref[2];