[Mesa-dev] [PATCH 4/6] xorg/xvmc: Remove recursion from RecursiveEndFrame

Maarten Lankhorst m.b.lankhorst at gmail.com
Wed Nov 16 02:50:33 PST 2011


There should be no way for endframe to ever need recursion..

Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>
---
 src/gallium/state_trackers/xorg/xvmc/surface.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index ffdac3d..3025f0e 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -122,7 +122,7 @@ SetDecoderStatus(XvMCSurfacePrivate *surface)
 }
 
 static void
-RecursiveEndFrame(XvMCSurfacePrivate *surface)
+EndFrame(XvMCSurfacePrivate *surface)
 {
    XvMCContextPrivate *context_priv;
    unsigned i;
@@ -134,12 +134,11 @@ RecursiveEndFrame(XvMCSurfacePrivate *surface)
    for ( i = 0; i < 2; ++i ) {
       if (surface->ref[i]) {
          XvMCSurface *ref = surface->ref[i];
+         XvMCSurfacePrivate *refpriv;
 
-         assert(ref);
-
-         surface->ref[i] = NULL;
-         RecursiveEndFrame(ref->privData);
-         surface->ref[i] = ref;
+         assert(ref && ref->privData);
+         refpriv = ref->privData;
+         assert(!refpriv->picture_structure); // There's just no sane way this can happen..
       }
    }
 
@@ -260,10 +259,10 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
 
    // call end frame on all referenced frames
    if (past_surface)
-      RecursiveEndFrame(past_surface->privData);
+      EndFrame(past_surface->privData);
 
    if (future_surface)
-      RecursiveEndFrame(future_surface->privData);
+      EndFrame(future_surface->privData);
 
    xvmc_mb = macroblocks->macro_blocks + first_macroblock;
 
@@ -275,7 +274,7 @@ 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);
+      EndFrame(target_surface_priv);
    }
 
    target_surface_priv->ref[0] = past_surface;
@@ -390,7 +389,11 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    assert(desty + desth - 1 < drawable_surface->height);
     */
 
-   RecursiveEndFrame(surface_priv);
+   if (surface_priv->ref[0])
+      EndFrame(surface_priv->ref[0]->privData);
+   if (surface_priv->ref[1])
+      EndFrame(surface_priv->ref[1]->privData);
+   EndFrame(surface_priv);
 
    context_priv->decoder->flush(context_priv->decoder);
 
-- 
1.7.7.1




More information about the mesa-dev mailing list