]> git.sesse.net Git - vlc/commitdiff
Modification de decoder_fifo.h : le cas ou on passe d'un buffer a l'autre
authorMichel Lespinasse <walken@videolan.org>
Thu, 17 Feb 2000 19:28:00 +0000 (19:28 +0000)
committerMichel Lespinasse <walken@videolan.org>
Thu, 17 Feb 2000 19:28:00 +0000 (19:28 +0000)
lors de la lecture d'un octet n'est plus inline. Precedemment le code etait
inclus a chaque invocation de NeedBits ou GetBits...

Vu l'etat de la synchro je n'ai pas pu mesurer d'impact precis sur les fps
mais je ne m'attends pas a ce qu'il soit mesurable de toute facon : on troque
un apel de fonction contre un meilleur comportement du cache code...

Premier checkin de ma part, mais il devrait en venir d'autres.

Makefile
include/decoder_fifo.h
src/misc/decoder_fifo.c [new file with mode: 0644]

index 33e03e9f2bf60cd65ce45b60ae3dd44de8588313..0bdf77fb6f29e952544ac531249867c45d8f8746 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,8 +10,8 @@
 ################################################################################
 
 # Environment
-#CC=gcc
-#SHELL=/bin/sh
+CC=egcc
+SHELL=/bin/sh
 
 # Audio output settings
 AUDIO = dsp
@@ -21,7 +21,8 @@ AUDIO = dsp
 AUDIO += dummy
 
 # Video output settings
-VIDEO = x11 fb
+VIDEO = x11
+#VIDEO += fb
 #VIDEO += ggi
 #VIDEO += glide
 # Not yet supported
@@ -269,7 +270,8 @@ endif
 
 misc_obj =                     misc/mtime.o \
                                                misc/rsc_files.o \
-                                               misc/netutils.o
+                                               misc/netutils.o \
+                                               misc/decoder_fifo.o
 
 C_OBJ = $(interface_obj) \
                $(input_obj) \
index c72fbbfa92556f9ede201ccb1ff844f39238521b..2e0fadf5187527cd0ecda87dfe3b190887558d87 100644 (file)
@@ -91,76 +91,20 @@ typedef struct bit_stream_s
 } bit_stream_t;
 
 
+void decoder_fifo_next( bit_stream_t * p_bit_stream );
 /*****************************************************************************
  * GetByte : reads the next byte in the input stream
  *****************************************************************************/
 static __inline__ byte_t GetByte( bit_stream_t * p_bit_stream )
 {
     /* Are there some bytes left in the current TS packet ? */
-    if ( p_bit_stream->i_byte < p_bit_stream->p_ts->i_payload_end )
+    if ( p_bit_stream->i_byte >= p_bit_stream->p_ts->i_payload_end )
     {
-        return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
+       /* no, switch to next TS packet */
+       decoder_fifo_next( p_bit_stream );
     }
-    else
-    {
-        /* We are looking for the next TS packet that contains real data,
-         * and not just a PES header */
-        do
-        {
-            /* We were reading the last TS packet of this PES packet... It's
-             * time to jump to the next PES packet */
-            if ( p_bit_stream->p_ts->p_next_ts == NULL )
-            {
-                /* We are going to read/write the start and end indexes of the
-                 * decoder fifo and to use the fifo's conditional variable,
-                 * that's why we need to take the lock before */
-                vlc_mutex_lock( &p_bit_stream->p_decoder_fifo->data_lock );
-
-                /* Is the input thread dying ? */
-                if ( p_bit_stream->p_input->b_die )
-                {
-                    vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
-                    return( 0 );
-                }
-
-                /* We should increase the start index of the decoder fifo, but
-                 * if we do this now, the input thread could overwrite the
-                 * pointer to the current PES packet, and we weren't able to
-                 * give it back to the netlist. That's why we free the PES
-                 * packet first. */
-                input_NetlistFreePES( p_bit_stream->p_input, DECODER_FIFO_START(*p_bit_stream->p_decoder_fifo) );
-                DECODER_FIFO_INCSTART( *p_bit_stream->p_decoder_fifo );
-
-                while ( DECODER_FIFO_ISEMPTY(*p_bit_stream->p_decoder_fifo) )
-                {
-                    vlc_cond_wait( &p_bit_stream->p_decoder_fifo->data_wait, &p_bit_stream->p_decoder_fifo->data_lock );
-                    if ( p_bit_stream->p_input->b_die )
-                    {
-                        vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
-                        return( 0 );
-                    }
-                }
 
-                /* The next byte could be found in the next PES packet */
-                p_bit_stream->p_ts = DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->p_first_ts;
-
-                /* We can release the fifo's data lock */
-                vlc_mutex_unlock( &p_bit_stream->p_decoder_fifo->data_lock );
-            }
-            /* Perhaps the next TS packet of the current PES packet contains
-             * real data (ie its payload's size is greater than 0) */
-            else
-            {
-                p_bit_stream->p_ts = p_bit_stream->p_ts->p_next_ts;
-            }
-        } while ( p_bit_stream->p_ts->i_payload_start == p_bit_stream->p_ts->i_payload_end );
-
-        /* We've found a TS packet which contains interesting data... As we
-         * return the payload's first byte, we set i_byte to the following
-         * one */
-        p_bit_stream->i_byte = p_bit_stream->p_ts->i_payload_start;
-        return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
-    }
+    return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
 }
 
 /*****************************************************************************
diff --git a/src/misc/decoder_fifo.c b/src/misc/decoder_fifo.c
new file mode 100644 (file)
index 0000000..24c6a8c
--- /dev/null
@@ -0,0 +1,75 @@
+/***************************************************************************** 
+ * decoder_fifo.c: auxiliaries functions used in decoder_fifo.h
+ * (c)1998 VideoLAN 
+ *****************************************************************************/
+
+#include <sys/uio.h>
+
+#include "config.h"
+#include "common.h"
+#include "mtime.h"
+#include "vlc_thread.h"
+
+#include "debug.h"                    /* ?? temporaire, requis par netlist.h */
+
+#include "input.h"
+#include "input_netlist.h"
+#include "decoder_fifo.h"
+
+void decoder_fifo_next( bit_stream_t * p_bit_stream )
+{
+    /* We are looking for the next TS packet that contains real data,
+     * and not just a PES header */
+    do
+    {
+       /* We were reading the last TS packet of this PES packet... It's
+        * time to jump to the next PES packet */
+       if ( p_bit_stream->p_ts->p_next_ts == NULL )
+       {
+           /* We are going to read/write the start and end indexes of the
+            * decoder fifo and to use the fifo's conditional variable,
+                    * that's why we need to take the lock before */
+           vlc_mutex_lock( &p_bit_stream->p_decoder_fifo->data_lock );
+
+           /* Is the input thread dying ? */
+           if ( p_bit_stream->p_input->b_die )
+           {
+               vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
+               return;
+           }
+
+           /* We should increase the start index of the decoder fifo, but
+            * if we do this now, the input thread could overwrite the
+            * pointer to the current PES packet, and we weren't able to
+            * give it back to the netlist. That's why we free the PES
+            * packet first. */
+           input_NetlistFreePES( p_bit_stream->p_input, DECODER_FIFO_START(*p_bit_stream->p_decoder_fifo) );
+           DECODER_FIFO_INCSTART( *p_bit_stream->p_decoder_fifo );
+
+           while ( DECODER_FIFO_ISEMPTY(*p_bit_stream->p_decoder_fifo) )
+           {
+               vlc_cond_wait( &p_bit_stream->p_decoder_fifo->data_wait, &p_bit_stream->p_decoder_fifo->data_lock );
+               if ( p_bit_stream->p_input->b_die )
+               {
+                   vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
+                   return;
+               }
+           }
+
+           /* The next byte could be found in the next PES packet */
+           p_bit_stream->p_ts = DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->p_first_ts;
+
+           /* We can release the fifo's data lock */
+           vlc_mutex_unlock( &p_bit_stream->p_decoder_fifo->data_lock );
+       }
+       /* Perhaps the next TS packet of the current PES packet contains
+        * real data (ie its payload's size is greater than 0) */
+       else
+       {
+           p_bit_stream->p_ts = p_bit_stream->p_ts->p_next_ts;
+       }
+    } while ( p_bit_stream->p_ts->i_payload_start == p_bit_stream->p_ts->i_payload_end );
+
+    /* We've found a TS packet which contains interesting data... */
+    p_bit_stream->i_byte = p_bit_stream->p_ts->i_payload_start;
+}