]> git.sesse.net Git - vlc/blobdiff - include/video_fifo.h
* Added more stats
[vlc] / include / video_fifo.h
index 4d30ba64f5895ea62d8367ead1a3c15449fc6657..8d4f02a214400c1f48ddddbf05455c747128c51a 100644 (file)
@@ -1,12 +1,30 @@
 /*****************************************************************************
  * video_fifo.h : FIFO for the pool of video_decoders
- * (c)1999 VideoLAN
- *****************************************************************************
  *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+/*****************************************************************************
  * Requires:
  *  "config.h"
  *  "common.h"
- *  "vlc_thread.h"
+ *  "threads.h"
  *  "video_parser.h"
  *  "undec_picture.h"
  *****************************************************************************/
  *****************************************************************************/
 
 #ifdef VDEC_SMP
-/* ?? move to inline functions */
+/* FIXME: move to inline functions ??*/
 #define VIDEO_FIFO_ISEMPTY( fifo )    ( (fifo).i_start == (fifo).i_end )
-#define VIDEO_FIFO_ISFULL( fifo )     ( ( ( (fifo).i_end + 1 - (fifo).i_start ) \
+#define VIDEO_FIFO_ISFULL( fifo )     ( ( ( (fifo).i_end + 1 - (fifo).i_start )\
                                           & VFIFO_SIZE ) == 0 )
 #define VIDEO_FIFO_START( fifo )      ( (fifo).buffer[ (fifo).i_start ] )
 #define VIDEO_FIFO_INCSTART( fifo )   ( (fifo).i_start = ((fifo).i_start + 1) \
-                                                           & VFIFO_SIZE ) 
+                                                           & VFIFO_SIZE )
 #define VIDEO_FIFO_END( fifo )        ( (fifo).buffer[ (fifo).i_end ] )
 #define VIDEO_FIFO_INCEND( fifo )     ( (fifo).i_end = ((fifo).i_end + 1) \
                                                          & VFIFO_SIZE )
@@ -46,12 +64,12 @@ static __inline__ macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo )
             return( NULL );
         }
     }
-    
+
     p_mb = VIDEO_FIFO_START( *p_fifo );
     VIDEO_FIFO_INCSTART( *p_fifo );
 
     vlc_mutex_unlock( &p_fifo->lock );
-    
+
     return( p_mb );
 #else
     /* Shouldn't normally be used without SMP. */
@@ -74,6 +92,10 @@ static __inline__ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
         /* No more structures available. This should not happen ! */
         intf_DbgMsg("vpar debug: macroblock list is empty, delaying\n");
         vlc_mutex_unlock( &P_buffer.lock );
+        if( p_fifo->p_vpar->b_die )
+        {
+            return( NULL );
+        }
         msleep(VPAR_OUTMEM_SLEEP);
         vlc_mutex_lock( &P_buffer.lock );
     }
@@ -97,14 +119,16 @@ static __inline__ void vpar_DecodeMacroblock( video_fifo_t * p_fifo,
 #ifdef VDEC_SMP
     /* Place picture in the video FIFO */
     vlc_mutex_lock( &p_fifo->lock );
-        
+
     /* By construction, the video FIFO cannot be full */
     VIDEO_FIFO_END( *p_fifo ) = p_mb;
     VIDEO_FIFO_INCEND( *p_fifo );
 
     vlc_mutex_unlock( &p_fifo->lock );
+#else
+    p_fifo->p_vpar->p_vout->vdec_DecodeMacroblock(
+            p_fifo->p_vpar->pp_vdec[0], p_mb );
 #endif
-    /* Shouldn't normally be used without SMP. */
 }
 
 /*****************************************************************************
@@ -122,21 +146,21 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo,
     p_mb->p_picture->i_deccount--;
     b_finished = (p_mb->p_picture->i_deccount == 1);
     vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
-//fprintf(stderr, "%d ", p_mb->p_picture->i_deccount);
+//intf_DbgMsg( "%d ", p_mb->p_picture->i_deccount );
     /* Test if it was the last block of the picture */
     if( b_finished )
     {
-//fprintf(stderr, "Image decodee\n");
+//intf_DbgMsg( "Image decodee\n" );
         /* Mark the picture to be displayed */
         vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
-     
+        vpar_SynchroEnd( p_fifo->p_vpar, 0 );
+
         /* Unlink referenced pictures */
         if( p_mb->p_forward != NULL )
         {
-               vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forward );
+            vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forward );
         }
         if( p_mb->p_backward != NULL )
         {
@@ -159,7 +183,7 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo,
         vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 0 );
     }
 #endif
 }
@@ -182,12 +206,12 @@ static __inline__ void vpar_DestroyMacroblock( video_fifo_t * p_fifo,
     /* Test if it was the last block of the picture */
     if( b_finished )
     {
-fprintf(stderr, "Image trashee\n");
+        intf_DbgMsg( "Image trashee\n" );
         /* Mark the picture to be trashed */
         vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 1 );
 
         /* Unlink referenced pictures */
         if( p_mb->p_forward != NULL )
@@ -215,7 +239,7 @@ fprintf(stderr, "Image trashee\n");
         vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 1 );
     }
 #endif
 }