]> git.sesse.net Git - vlc/blobdiff - src/video_decoder/video_decoder.c
The motion compensation routines are now modules as well ; choose your
[vlc] / src / video_decoder / video_decoder.c
index a94dd6e287518bec08c9a269915cbd83d8246559..e14c23f2c685dc33ef5b9ac14e7f73ce59ce1860 100644 (file)
@@ -2,6 +2,7 @@
  * video_decoder.c : video decoder thread
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: video_decoder.c,v 1.45 2001/01/18 05:13:23 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          GaĆ«l Hendryckx <jimmy@via.ecp.fr>
@@ -28,8 +29,7 @@
 
 #include <stdlib.h>                                                /* free() */
 #include <unistd.h>                                              /* getpid() */
-#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
-#include <sys/uio.h>                                          /* for input.h */
+#include <errno.h>                                                  /* errno */
 
 #include "config.h"
 #include "common.h"
 
 #include "intf_msg.h"
 
-#include "input.h"
-#include "decoder_fifo.h"
+#include "stream_control.h"
+#include "input_ext-dec.h"
+
 #include "video.h"
 #include "video_output.h"
 
+#include "vdec_motion.h"
 #include "vdec_idct.h"
 #include "video_decoder.h"
-#include "vdec_motion.h"
 
 #include "vpar_blocks.h"
 #include "vpar_headers.h"
  */
 #ifdef VDEC_SMP
 static int      vdec_InitThread     ( vdec_thread_t *p_vdec );
-static void     vdec_DecodeMacroblockC  ( vdec_thread_t *p_vdec,
-                                          macroblock_t * p_mb );
-static void     vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec,
-                                          macroblock_t * p_mb );
 #endif
 static void     RunThread           ( vdec_thread_t *p_vdec );
 static void     ErrorThread         ( vdec_thread_t *p_vdec );
@@ -80,12 +77,12 @@ vdec_thread_t * vdec_CreateThread( vpar_thread_t *p_vpar /*, int *pi_status */ )
 {
     vdec_thread_t *     p_vdec;
 
-    intf_DbgMsg("vdec debug: creating video decoder thread\n");
+    intf_DbgMsg("vdec debug: creating video decoder thread");
 
     /* Allocate the memory needed to store the thread's structure */
     if ( (p_vdec = (vdec_thread_t *)malloc( sizeof(vdec_thread_t) )) == NULL )
     {
-        intf_ErrMsg("vdec error: not enough memory for vdec_CreateThread() to create the new thread\n");
+        intf_ErrMsg("vdec error: not enough memory for vdec_CreateThread() to create the new thread");
         return( NULL );
     }
 
@@ -104,12 +101,12 @@ vdec_thread_t * vdec_CreateThread( vpar_thread_t *p_vpar /*, int *pi_status */ )
     if ( vlc_thread_create(&p_vdec->thread_id, "video decoder",
          (vlc_thread_func_t)RunThread, (void *)p_vdec) )
     {
-        intf_ErrMsg("vdec error: can't spawn video decoder thread\n");
+        intf_ErrMsg("vdec error: can't spawn video decoder thread");
         free( p_vdec );
         return( NULL );
     }
 
-    intf_DbgMsg("vdec debug: video decoder thread (%p) created\n", p_vdec);
+    intf_DbgMsg("vdec debug: video decoder thread (%p) created", p_vdec);
     return( p_vdec );
 }
 
@@ -122,7 +119,7 @@ vdec_thread_t * vdec_CreateThread( vpar_thread_t *p_vpar /*, int *pi_status */ )
  *****************************************************************************/
 void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
 {
-    intf_DbgMsg("vdec debug: requesting termination of video decoder thread %p\n", p_vdec);
+    intf_DbgMsg("vdec debug: requesting termination of video decoder thread %p", p_vdec);
 
     /* Ask thread to kill itself */
     p_vdec->b_die = 1;
@@ -154,20 +151,13 @@ static int vdec_InitThread( vdec_thread_t *p_vdec )
 int vdec_InitThread( vdec_thread_t *p_vdec )
 #endif
 {
+#ifndef HAVE_MMX
     int i_dummy;
-
-    intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec);
-
-    /* Initialize other properties */
-#ifdef STATS
-    p_vdec->c_loops = 0;
-    p_vdec->c_idle_loops = 0;
-    p_vdec->c_decoded_pictures = 0;
-    p_vdec->c_decoded_i_pictures = 0;
-    p_vdec->c_decoded_p_pictures = 0;
-    p_vdec->c_decoded_b_pictures = 0;
 #endif
 
+    intf_DbgMsg("vdec debug: initializing video decoder thread %p", p_vdec);
+
+#ifndef HAVE_MMX
     /* Init crop table */
     p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
     for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
@@ -182,9 +172,19 @@ int vdec_InitThread( vdec_thread_t *p_vdec )
     {
         p_vdec->pi_crop[i_dummy] = 255;
     }
+#endif
+
+#ifdef VDEC_SMP
+    /* Re-nice ourself */
+    if( nice(VDEC_NICE) == -1 )
+    {
+        intf_WarnMsg( 2, "vdec warning : couldn't nice() (%s)",
+                      strerror(errno) );
+    }
+#endif
 
     /* Mark thread as running and return */
-    intf_DbgMsg("vdec debug: InitThread(%p) succeeded\n", p_vdec);
+    intf_DbgMsg("vdec debug: InitThread(%p) succeeded", p_vdec);
     return( 0 );
 }
 
@@ -215,7 +215,7 @@ static void ErrorThread( vdec_thread_t *p_vdec )
  *****************************************************************************/
 static void EndThread( vdec_thread_t *p_vdec )
 {
-    intf_DbgMsg("vdec debug: EndThread(%p)\n", p_vdec);
+    intf_DbgMsg("vdec debug: EndThread(%p)", p_vdec);
 }
 
 /*****************************************************************************
@@ -474,11 +474,7 @@ static  __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
     }                                                                   \
 }
 
-#ifdef VDEC_SMP
-static __inline__ void vdec_DecodeMacroblockC ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
-#else
 void vdec_DecodeMacroblockC ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
-#endif
 {
     if( !(p_mb->i_mb_type & MB_INTRA) )
     {
@@ -487,7 +483,7 @@ void vdec_DecodeMacroblockC ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
          */
         if( p_mb->pf_motion == 0 )
         {
-            intf_ErrMsg( "vdec error: pf_motion set to NULL\n" );
+            intf_ErrMsg( "vdec error: pf_motion set to NULL" );
         }
         else
         {
@@ -508,11 +504,7 @@ void vdec_DecodeMacroblockC ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
     vpar_ReleaseMacroblock( &p_vdec->p_vpar->vfifo, p_mb );
 }
 
-#ifdef VDEC_SMP
-static __inline__ void vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
-#else
 void vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
-#endif
 {
     if( !(p_mb->i_mb_type & MB_INTRA) )
     {
@@ -521,7 +513,7 @@ void vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
          */
         if( p_mb->pf_motion == 0 )
         {
-            intf_ErrMsg( "vdec error: pf_motion set to NULL\n" );
+            intf_ErrMsg( "vdec error: pf_motion set to NULL" );
         }
         else
         {
@@ -552,7 +544,7 @@ void vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
  *****************************************************************************/
 static void RunThread( vdec_thread_t *p_vdec )
 {
-    intf_DbgMsg("vdec debug: running video decoder thread (%p) (pid == %i)\n",
+    intf_DbgMsg("vdec debug: running video decoder thread (%p) (pid == %i)",
                 p_vdec, getpid());
 
     /*
@@ -575,7 +567,7 @@ static void RunThread( vdec_thread_t *p_vdec )
 
         if( (p_mb = vpar_GetMacroblock( &p_vdec->p_vpar->vfifo )) != NULL )
         {
-            p_vdec->p_vpar->p_vout->vdec_DecodeMacroblock ( p_vdec, p_mb );
+            vdec_DecodeMacroblockC ( p_vdec, p_mb );
         }
     }