]> git.sesse.net Git - vlc/commitdiff
* vlc.init becomes ~/.vlcrc
authorSam Hocevar <sam@videolan.org>
Mon, 7 Aug 2000 22:18:24 +0000 (22:18 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 7 Aug 2000 22:18:24 +0000 (22:18 +0000)
  * removed float operations in the video decoder, and all emms asm functions
  * borrowed linuxvideo's MMX motion compensation
  * fixed an undefined symbol in the MMX YUV plugin

Meuuh & Sam.

16 files changed:
AUTHORS
ChangeLog
Makefile.in
include/config.h.in
include/vpar_blocks.h
include/vpar_headers.h
include/vpar_synchro.h
plugins/yuvmmx/video_yuv.c
plugins/yuvmmx/video_yuv.h
src/interface/intf_cmd.c
src/video_decoder/video_decoder.c
src/video_output/video_output.c
src/video_parser/video_parser.c
src/video_parser/vpar_blocks.c
src/video_parser/vpar_headers.c
src/video_parser/vpar_synchro.c

diff --git a/AUTHORS b/AUTHORS
index 1bd31b4166dfddfa96d2106abd51da611910cabb..ae27f66211229cd174fbce16aae38d2d81608ce0 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,8 +2,7 @@
   Régis Duchesne <regis@via.ecp.fr>
   Michel Lespinasse <walken@wrs.com>
 
-  Olivier Baxa <oli@via.ecp.fr>
-  Eric Estievenart <eric@via.ecp.fr>
+  Olivier Pomel <pomel@via.ecp.fr>
 
   Jean-Philippe Grimaldi <jeanphi@via.ecp.fr>
   Andres Krapf <dae@via.ecp.fr>
   Jean-Marc Dressler <polux@via.ecp.fr>
   Gaël Hendryckx <jimmy@via.ecp.fr>
   Samuel Hocevar <sam@via.ecp.fr>
+  Brieuc Jeunhomme <bbp@via.ecp.fr>
   Michel Kaempf <maxx@via.ecp.fr>
 
   Stéphane Borel <stef@via.ecp.fr>
   Renaud Dartus <reno@via.ecp.fr>
-  Henri Fallon <henri@via.ecp.fr>
 
-  Contributors include Aaron Holtzman for his ac3dec decoder, and the
-  LiViD team for a few lines of code we borrowed here and there.
index 6cabbeb3e717b4aafcbb1169ccd9937a6720be75..76e794a057be5d168b9d583ac3f90ba5a44076c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
   * "gvlc", "fbvlc", "ggivlc" aliases now work
   * fixed functions that weren't properly inlined
   * removed bloat from the MMX YUV plugin
+  * vlc.init becomes ~/.vlcrc
+  * removed float operations in the video decoder, and all emms asm functions
+  * borrowed linuxvideo's MMX motion compensation
+  * fixed an undefined symbol in the MMX YUV plugin
 
 Thu Jul 20 15:14:06 CEST 2000
 0.1.99e :
index e1d3a5fdccc6ee72f65e169aedec16e2581048e3..706e8da3fbdd32c78e27552ad030d65395409d64 100644 (file)
@@ -156,69 +156,75 @@ endif
 #
 # C Objects
 # 
-interface_obj =                interface/main.o \
-                                               interface/interface.o \
-                                               interface/intf_msg.o \
-                                               interface/intf_cmd.o \
-                                               interface/intf_ctrl.o \
-                                               interface/intf_console.o
-
-input_obj =                    input/input_vlan.o \
-                                               input/input_file.o \
-                                               input/input_netlist.o \
-                                               input/input_network.o \
-                                               input/input_ctrl.o \
-                                               input/input_pcr.o \
-                                               input/input_psi.o \
-                                               input/input.o
-
-audio_output_obj =             audio_output/audio_output.o
-
-video_output_obj =             video_output/video_output.o \
-                                               video_output/video_text.o \
-                                               video_output/video_spu.o \
-                                               video_output/video_yuv.o
-
-ac3_decoder_obj =              ac3_decoder/ac3_decoder_thread.o \
-                                               ac3_decoder/ac3_decoder.o \
-                                               ac3_decoder/ac3_parse.o \
-                                               ac3_decoder/ac3_exponent.o \
-                                               ac3_decoder/ac3_bit_allocate.o \
-                                               ac3_decoder/ac3_mantissa.o \
-                                               ac3_decoder/ac3_rematrix.o \
-                                               ac3_decoder/ac3_imdct.o \
-                                               ac3_decoder/ac3_downmix.o
+interface_obj =        interface/main.o \
+                               interface/interface.o \
+                               interface/intf_msg.o \
+                               interface/intf_cmd.o \
+                               interface/intf_ctrl.o \
+                               interface/intf_console.o
+
+input_obj =            input/input_vlan.o \
+                               input/input_file.o \
+                               input/input_netlist.o \
+                               input/input_network.o \
+                               input/input_ctrl.o \
+                               input/input_pcr.o \
+                               input/input_psi.o \
+                               input/input.o
+
+audio_output_obj =     audio_output/audio_output.o
+
+video_output_obj =     video_output/video_output.o \
+                               video_output/video_text.o \
+                               video_output/video_spu.o \
+                               video_output/video_yuv.o
+
+ac3_decoder_obj =      ac3_decoder/ac3_decoder_thread.o \
+                               ac3_decoder/ac3_decoder.o \
+                               ac3_decoder/ac3_parse.o \
+                               ac3_decoder/ac3_exponent.o \
+                               ac3_decoder/ac3_bit_allocate.o \
+                               ac3_decoder/ac3_mantissa.o \
+                               ac3_decoder/ac3_rematrix.o \
+                               ac3_decoder/ac3_imdct.o \
+                               ac3_decoder/ac3_downmix.o
                                                
-lpcm_decoder_obj =             lpcm_decoder/lpcm_decoder_thread.o \
-                                               lpcm_decoder/lpcm_decoder.o
+lpcm_decoder_obj =     lpcm_decoder/lpcm_decoder_thread.o \
+                               lpcm_decoder/lpcm_decoder.o
 
-audio_decoder_obj =            audio_decoder/audio_decoder_thread.o \
-                                               audio_decoder/audio_decoder.o \
-                                               audio_decoder/audio_math.o
+audio_decoder_obj =    audio_decoder/audio_decoder_thread.o \
+                               audio_decoder/audio_decoder.o \
+                               audio_decoder/audio_math.o
 
-spu_decoder_obj =              spu_decoder/spu_decoder.o
+spu_decoder_obj =      spu_decoder/spu_decoder.o
 
 #??generic_decoder_obj =               generic_decoder/generic_decoder.o
 # remeber to add it to OBJ 
 
-video_parser_obj =             video_parser/video_parser.o \
-                                               video_parser/vpar_headers.o \
-                                               video_parser/vpar_blocks.o \
-                                               video_parser/vpar_synchro.o \
-                                               video_parser/video_fifo.o
-
-video_decoder_obj =            video_decoder/video_decoder.o \
-                                               video_decoder/vdec_motion.o \
-                                               video_decoder/vdec_motion_inner.o \
-                                               video_decoder/vdec_idct.o
-
-misc_obj =                     misc/mtime.o \
-                                               misc/tests.o \
-                                               misc/rsc_files.o \
-                                               misc/netutils.o \
-                                               misc/playlist.o \
-                                               misc/plugins.o \
-                                               misc/decoder_fifo.o
+video_parser_obj =     video_parser/video_parser.o \
+                               video_parser/vpar_headers.o \
+                               video_parser/vpar_blocks.o \
+                               video_parser/vpar_synchro.o \
+                               video_parser/video_fifo.o
+
+ifneq (,$(findstring mmx,$(ARCH)))
+       vdec_motion_inner = video_decoder/vdec_motion_inner_mmx.o
+else
+       vdec_motion_inner = video_decoder/vdec_motion_inner.o
+endif
+
+video_decoder_obj =    video_decoder/video_decoder.o \
+                               video_decoder/vdec_motion.o \
+                               video_decoder/vdec_idct.o \
+                               $(vdec_motion_inner)
+
+misc_obj =             misc/mtime.o \
+                               misc/tests.o \
+                               misc/rsc_files.o \
+                               misc/netutils.o \
+                               misc/playlist.o \
+                               misc/plugins.o \
+                               misc/decoder_fifo.o
 
 
 C_OBJ = $(interface_obj) \
index 24c9aafb51a2303a9f331b68234c15b67dbf0b8a..cdeeadfecee8ec30177c076d5292436cf5440cd8 100644 (file)
  *****************************************************************************/
 
 /* Environment variable used to store startup script name and default value */
-#define INTF_INIT_SCRIPT_VAR            "vlc_init"
-#define INTF_INIT_SCRIPT_DEFAULT        "vlc.init"
+#define INTF_INIT_SCRIPT_VAR            "vlcrc"
+#define INTF_INIT_SCRIPT_DEFAULT        ".vlcrc"
 
 /* Environment variable used to store channels file and default value */
 #define INTF_CHANNELS_VAR               "vlc_channels"
  * Synchro configuration
  *****************************************************************************/
 
-#define VOUT_SYNCHRO_LEVEL_START        5
-#define VOUT_SYNCHRO_LEVEL_MAX          15
+#define VOUT_SYNCHRO_LEVEL_START        5 << 10
+#define VOUT_SYNCHRO_LEVEL_MAX          15 << 10
 #define VOUT_SYNCHRO_HEAP_IDEAL_SIZE    5
+
index d757f5ac931924efca23f7e03138f4df52f31a06..1d6ef17bf094dc3ff655d9c4e36c292a35dab6cb 100644 (file)
@@ -166,17 +166,4 @@ void vpar_InitPMBType( struct vpar_thread_s * p_vpar );
 void vpar_InitBMBType( struct vpar_thread_s * p_vpar );
 void vpar_InitCodedPattern( struct vpar_thread_s * p_vpar );
 void vpar_InitDCTTables( struct vpar_thread_s * p_vpar );
-void vpar_PictureDataGENERIC( struct vpar_thread_s * p_vpar, int i_mb_base );
-#if (VPAR_OPTIM_LEVEL > 0)
-void vpar_PictureData2I420F0( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2P420F0( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2B420F0( struct vpar_thread_s * p_vpar, int i_mb_base );
-#endif
-#if (VPAR_OPTIM_LEVEL > 1)
-void vpar_PictureData2I420TZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2P420TZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2B420TZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2I420BZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2P420BZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-void vpar_PictureData2B420BZ( struct vpar_thread_s * p_vpar, int i_mb_base );
-#endif
+void vpar_PictureData( struct vpar_thread_s * p_vpar, int i_mb_base );
index 6b27a1f1af8cd268f608c1c9ee5fef76516923cd..72ed0e6301c10948e2c578d6d090f35ec7f0b3b2 100644 (file)
@@ -58,7 +58,7 @@ typedef struct sequence_s
                                             /* the same, in macroblock units */
     unsigned int        i_aspect_ratio;        /* height/width display ratio */
     unsigned int        i_matrix_coefficients;/* coeffs of the YUV transform */
-    float               r_frame_rate;       /* theoritical frame rate in fps */
+    int                 i_frame_rate;  /* theoritical frame rate in fps*1001 */
     boolean_t           b_mpeg2;                                    /* guess */
     boolean_t           b_progressive;              /* progressive (ie.
                                                      * non-interlaced) frame */
index 6f7bdfc441088c77b606df7a9ebb420872569f86..151531053cdd2a376f86f3cfd5d84debbe7fffab 100644 (file)
@@ -67,9 +67,9 @@ typedef struct video_synchro_s
     /* can we display pictures ? */
     boolean_t     b_all_I;
     boolean_t     b_all_P;
-    double        displayable_p;
+    int           displayable_p;
     boolean_t     b_all_B;
-    double        displayable_b;
+    int           displayable_b;
 
 } video_synchro_t;
 
@@ -100,7 +100,7 @@ typedef struct video_synchro_s
     /* Date Section */
 
     /* Dates needed to compute the date of the current frame
-     * We also use the stream frame rate (sequence.r_frame_rate) */
+     * We also use the stream frame rate (sequence.i_frame_rate) */
     mtime_t     i_current_frame_date;
     mtime_t     i_backward_frame_date;
 
index e8087038cf09108e6890583a34ef9c496e161882..69840ff4728ab54c866f8698c0583aaba32ff196 100644 (file)
@@ -131,12 +131,8 @@ int yuv_MMXReset( vout_thread_t *p_vout )
 + *****************************************************************************/
 void SetYUV( vout_thread_t *p_vout )
 {
-    int         pi_gamma[256];                                /* gamma table */
     int         i_index;                                  /* index in tables */
 
-    /* Build gamma table */
-    SetGammaTable( pi_gamma, p_vout->f_gamma );
-
     /*
      * Set pointers and build YUV tables
      */
index 4e0673bb3b79738b5c3cdd924f8cba7ac3707687..a2771b995a7b876d66bf7e575e424efb9166fb7a 100644 (file)
@@ -53,7 +53,6 @@ int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-void SetGammaTable        ( int *pi_table, double f_gamma );
 void SetYUV               ( vout_thread_t *p_vout );
 void SetOffset            ( int i_width, int i_height, int i_pic_width,
                             int i_pic_height, boolean_t *pb_h_scaling,
index 5f89ce9563b5cca24b277ae2d5cee711a2c36dba..d5933b76818cc768f896f7f7cde92735fad47355 100644 (file)
@@ -158,14 +158,23 @@ int intf_ExecScript( char *psz_filename )
     FILE *  p_file;                                                  /* file */
     char    psz_line[INTF_MAX_CMD_SIZE];                             /* line */
     char *  psz_index;                                    /* index in string */
+    char *  psz_vlcrc;                                 /* full path to vlcrc */
     int     i_err;                                        /* error indicator */
 
     /* Open file */
     i_err = 0;
-    p_file = fopen( psz_filename, "r" );
+
+    if( !( psz_index = getenv("HOME") ) )
+    {
+        psz_index = "/";
+    }
+    psz_vlcrc = malloc( strlen( psz_index ) + 1 + strlen( psz_filename ) + 1 );
+    sprintf( psz_vlcrc, "%s/%s", psz_index, psz_filename );
+    
+    p_file = fopen( psz_vlcrc, "r" );
     if( p_file == NULL )
     {
-        intf_DbgMsg("intf warning: %s: %s\n", psz_filename, strerror(errno));
+        intf_DbgMsg("intf warning: %s: %s\n", psz_vlcrc, strerror(errno));
         return( -1 );
     }
 
@@ -194,7 +203,7 @@ int intf_ExecScript( char *psz_filename )
     }
     if( !feof( p_file ) )
     {
-        intf_ErrMsg("error: %s: %s\n", psz_filename, strerror(errno));
+        intf_ErrMsg("error: %s: %s\n", psz_vlcrc, strerror(errno));
         return( -1 );
     }
 
index 5e40392f883621f5cc101e24fbaf435ca9422c3e..acca7dad72d7b5d1631a9d21cd2c00375381d448 100644 (file)
@@ -322,8 +322,8 @@ static __inline__ void AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
             "packuswb   %%mm1,%%mm2\n\t"
             "movq       %%mm2,(%0)\n\t"
 
-            "emms"
-             :"+r" (p_data): "r" (p_block),"r" (i_incr+8));
+            //"emms"
+            :"+r" (p_data): "r" (p_block),"r" (i_incr+8));
 }
 #endif
 
@@ -389,7 +389,7 @@ static  __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
             "movq        112(%1),%%mm0\n\t"
             "packuswb   120(%1),%%mm0\n\t"
             "movq        %%mm0,(%0)\n\t"
-            "emms"
+            //"emms"
             :"+r" (p_data): "r" (p_block),"r" (i_incr+8));
 }
 #endif
index 86a0a779be5e84c4ae6153f283e1a7d3d9bd940b..49415559730dd030cc6437cbc2201371b4942101 100644 (file)
@@ -1691,7 +1691,7 @@ static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
      */
     if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
     {
-        sprintf( psz_buffer, "%.2f fps", (double) VOUT_FPS_SAMPLES * 1000000 /
+        sprintf( psz_buffer, "%.2f fps/10", VOUT_FPS_SAMPLES * 1000000 * 10 /
                  ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1) % VOUT_FPS_SAMPLES ] -
                    p_vout->p_fps_sample[ p_vout->c_fps_samples % VOUT_FPS_SAMPLES ] ) );
         Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
@@ -1939,7 +1939,7 @@ static void Synchronize( vout_thread_t *p_vout, s64 i_delay )
     /* XXX?? gore following */
     static int i_panic_count = 0;
     static int i_last_synchro_inc = 0;
-    static float r_synchro_level = VOUT_SYNCHRO_LEVEL_START;
+    static int i_synchro_level = VOUT_SYNCHRO_LEVEL_START;
     static int i_truc = 10;
 
     if( i_delay < 0 )
@@ -1965,7 +1965,7 @@ static void Synchronize( vout_thread_t *p_vout, s64 i_delay )
         }
     }
 
-    if( i_truc > VOUT_SYNCHRO_LEVEL_MAX*2*2*2*2*2 ||
+    if( i_truc > VOUT_SYNCHRO_LEVEL_MAX >> 5 ||
         i_synchro_inc*i_last_synchro_inc < 0 )
     {
         i_truc = 32;
@@ -1985,17 +1985,17 @@ static void Synchronize( vout_thread_t *p_vout, s64 i_delay )
     }
     else if( i_delay > 100000 )
     {
-        r_synchro_level += 1;
+        i_synchro_level += 1 << 10;
         if( i_delay > 130000 )
-            r_synchro_level += 1;
+            i_synchro_level += 1 << 10;
     }
 
-    r_synchro_level += (float)i_synchro_inc / i_truc;
-    p_vout->i_synchro_level = (int)(r_synchro_level+0.5);
+    i_synchro_level += ( i_synchro_inc << 10 ) / i_truc;
+    p_vout->i_synchro_level = ( i_synchro_level + (1 << 9) );
 
-    if( r_synchro_level > VOUT_SYNCHRO_LEVEL_MAX )
+    if( i_synchro_level > VOUT_SYNCHRO_LEVEL_MAX )
     {
-        r_synchro_level = VOUT_SYNCHRO_LEVEL_MAX;
+        i_synchro_level = VOUT_SYNCHRO_LEVEL_MAX;
     }
 
     //fprintf( stderr, "synchro level : %d, heap : %d (%d, %d) (%d, %f) - %Ld\n", p_vout->i_synchro_level,
index 45abb382d697b3cf399efe0550a65101b5f6cc62..aaa559d31bdd2c0c8c85ca1f4edb52877047fdc5 100644 (file)
@@ -291,14 +291,14 @@ static int InitThread( vpar_thread_t *p_vpar )
     p_vpar->synchro.i_delay            = 200000;
     p_vpar->synchro.i_theorical_delay  = 40000; /* 25 fps */
     /* assume we can display all Is and 2 Ps */
-    p_vpar->synchro.b_all_I = 1;
+    p_vpar->synchro.b_all_I = 1 << 10;
     p_vpar->synchro.b_all_P = 0;
-    p_vpar->synchro.displayable_p = 2;
+    p_vpar->synchro.displayable_p = 2 << 10;
     p_vpar->synchro.b_all_B = 0;
     p_vpar->synchro.displayable_b = 0;
     /* assume there were about 3 P and 6 B images between I's */
-    p_vpar->synchro.i_P_seen = p_vpar->synchro.i_P_kept = 1;
-    p_vpar->synchro.i_B_seen = p_vpar->synchro.i_B_kept = 1;
+    p_vpar->synchro.i_P_seen = p_vpar->synchro.i_P_kept = 1 << 10;
+    p_vpar->synchro.i_B_seen = p_vpar->synchro.i_B_kept = 1 << 10;
 #endif
 
 #ifdef MEUUH_SYNCHRO
index c8386d74a1257f53478269c857df6ee42ffede44..d6dbbe654b2da6c50a669fb82220b575b703740c 100644 (file)
@@ -618,7 +618,7 @@ void vpar_InitDCTTables( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * DecodeMPEG1NonIntra : decode MPEG-1 non-intra blocks
  *****************************************************************************/
-static void DecodeMPEG1NonIntra( vpar_thread_t * p_vpar,
+static __inline__ void DecodeMPEG1NonIntra( vpar_thread_t * p_vpar,
                                             macroblock_t * p_mb, int i_b,
                                             int i_chroma_format )
 {
@@ -729,7 +729,7 @@ static void DecodeMPEG1NonIntra( vpar_thread_t * p_vpar,
 /*****************************************************************************
  * DecodeMPEG1Intra : decode MPEG-1 intra blocks
  *****************************************************************************/
-static void DecodeMPEG1Intra( vpar_thread_t * p_vpar,
+static __inline__ void DecodeMPEG1Intra( vpar_thread_t * p_vpar,
                                          macroblock_t * p_mb, int i_b ,
                                          int i_chroma_format )
 {
@@ -876,7 +876,7 @@ static void DecodeMPEG1Intra( vpar_thread_t * p_vpar,
 /*****************************************************************************
  * DecodeMPEG2NonIntra : decode MPEG-2 non-intra blocks
  *****************************************************************************/
-static void DecodeMPEG2NonIntra( vpar_thread_t * p_vpar,
+static __inline__ void DecodeMPEG2NonIntra( vpar_thread_t * p_vpar,
                                             macroblock_t * p_mb, int i_b,
                                             int i_chroma_format )
 {
@@ -985,7 +985,7 @@ static void DecodeMPEG2NonIntra( vpar_thread_t * p_vpar,
 /*****************************************************************************
  * DecodeMPEG2Intra : decode MPEG-2 intra blocks
  *****************************************************************************/
-static void DecodeMPEG2Intra( vpar_thread_t * p_vpar,
+static __inline__ void DecodeMPEG2Intra( vpar_thread_t * p_vpar,
                                          macroblock_t * p_mb, int i_b,
                                          int i_chroma_format )
 {
@@ -1135,7 +1135,7 @@ static void DecodeMPEG2Intra( vpar_thread_t * p_vpar,
 /****************************************************************************
  * MotionCode : Parse the next motion code
  ****************************************************************************/
-static int MotionCode( vpar_thread_t * p_vpar )
+static __inline__ int MotionCode( vpar_thread_t * p_vpar )
 {
     int i_code;
     static lookup_t pl_mv_tab0[8] =
@@ -1184,7 +1184,7 @@ static int MotionCode( vpar_thread_t * p_vpar )
 /****************************************************************************
  * DecodeMotionVector : Decode a motion_vector
  ****************************************************************************/
-static void DecodeMotionVector( int * pi_prediction, int i_r_size,
+static __inline__ void DecodeMotionVector( int * pi_prediction, int i_r_size,
         int i_motion_code, int i_motion_residual, int i_full_pel )
 {
     int i_limit, i_vector;
@@ -1211,7 +1211,7 @@ static void DecodeMotionVector( int * pi_prediction, int i_r_size,
 /****************************************************************************
  * MotionVector : Parse the next motion_vector field
  ****************************************************************************/
-static void MotionVector( vpar_thread_t * p_vpar,
+static __inline__ void MotionVector( vpar_thread_t * p_vpar,
                                      macroblock_t * p_mb, int i_r,
                                      int i_s, int i_full_pel, int i_structure )
 {
@@ -1321,7 +1321,7 @@ static void MotionVector( vpar_thread_t * p_vpar,
  * DecodeMVMPEG1 : Parse the next MPEG-1 motion vectors
  *****************************************************************************/
 static void DecodeMVMPEG1( vpar_thread_t * p_vpar,
-                            macroblock_t * p_mb, int i_s, int i_structure )
+                           macroblock_t * p_mb, int i_s, int i_structure )
 {
     MotionVector( p_vpar, p_mb, 0, i_s,
                   p_vpar->picture.pb_full_pel_vector[i_s], i_structure );
@@ -1331,7 +1331,7 @@ static void DecodeMVMPEG1( vpar_thread_t * p_vpar,
  * DecodeMVMPEG2 : Parse the next MPEG-2 motion_vectors field
  *****************************************************************************/
 static void DecodeMVMPEG2( vpar_thread_t * p_vpar,
-                            macroblock_t * p_mb, int i_s, int i_structure )
+                           macroblock_t * p_mb, int i_s, int i_structure )
 {
     if( p_vpar->mb.i_mv_count == 1 )
     {
@@ -1389,7 +1389,7 @@ static int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * IMBType : macroblock_type in I pictures
  *****************************************************************************/
-static int IMBType( vpar_thread_t * p_vpar )
+static __inline__ int IMBType( vpar_thread_t * p_vpar )
 {
     /* Take two bits for testing */
     int                 i_type = ShowBits( &p_vpar->bit_stream, 2 );
@@ -1407,7 +1407,7 @@ static int IMBType( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * PMBType : macroblock_type in P pictures
  *****************************************************************************/
-static int PMBType( vpar_thread_t * p_vpar )
+static __inline__ int PMBType( vpar_thread_t * p_vpar )
 {
     /* Testing on 6 bits */
     int                i_type = ShowBits( &p_vpar->bit_stream, 6 );
@@ -1421,7 +1421,7 @@ static int PMBType( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * BMBType : macroblock_type in B pictures
  *****************************************************************************/
-static int BMBType( vpar_thread_t * p_vpar )
+static __inline__ int BMBType( vpar_thread_t * p_vpar )
 {
      /* Testing on 6 bits */
     int                i_type = ShowBits( &p_vpar->bit_stream, 6 );
@@ -1436,7 +1436,7 @@ static int BMBType( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * DMBType : macroblock_type in D pictures
  *****************************************************************************/
-static int DMBType( vpar_thread_t * p_vpar )
+static __inline__ int DMBType( vpar_thread_t * p_vpar )
 {
     return GetBits( &p_vpar->bit_stream, 1 );
 }
@@ -1444,7 +1444,7 @@ static int DMBType( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * CodedPattern420 : coded_block_pattern with 4:2:0 chroma
  *****************************************************************************/
-static int CodedPattern420( vpar_thread_t * p_vpar )
+static __inline__ int CodedPattern420( vpar_thread_t * p_vpar )
 {
     /* Take the max 9 bits length vlc code for testing */
     int      i_vlc = ShowBits( &p_vpar->bit_stream, 9 );
@@ -1459,7 +1459,7 @@ static int CodedPattern420( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * CodedPattern422 : coded_block_pattern with 4:2:2 chroma
  *****************************************************************************/
-static int CodedPattern422( vpar_thread_t * p_vpar )
+static __inline__ int CodedPattern422( vpar_thread_t * p_vpar )
 {
     int      i_vlc = ShowBits( &p_vpar->bit_stream, 9 );
 
@@ -1473,7 +1473,7 @@ static int CodedPattern422( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * CodedPattern444 : coded_block_pattern with 4:4:4 chroma
  *****************************************************************************/
-static int CodedPattern444( vpar_thread_t * p_vpar )
+static __inline__ int CodedPattern444( vpar_thread_t * p_vpar )
 {
     int      i_vlc = ShowBits( &p_vpar->bit_stream, 9 );
 
@@ -1486,7 +1486,7 @@ static int CodedPattern444( vpar_thread_t * p_vpar )
 /*****************************************************************************
  * InitMacroblock : Initialize macroblock values
  *****************************************************************************/
-static void InitMacroblock( vpar_thread_t * p_vpar,
+static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
                                        macroblock_t * p_mb, int i_coding_type,
                                        int i_chroma_format,
                                        int i_structure,
@@ -1521,7 +1521,7 @@ static void InitMacroblock( vpar_thread_t * p_vpar,
 /*****************************************************************************
  * UpdateContext : Update the p_vpar contextual values
  *****************************************************************************/
-static void UpdateContext( vpar_thread_t * p_vpar, int i_structure )
+static __inline__ void UpdateContext( vpar_thread_t * p_vpar, int i_structure )
 {
     /* Update macroblock real position. */
     p_vpar->mb.i_l_x += 16;
@@ -1539,7 +1539,7 @@ static void UpdateContext( vpar_thread_t * p_vpar, int i_structure )
 /*****************************************************************************
  * SkippedMacroblock : Generate a skipped macroblock with NULL motion vector
  *****************************************************************************/
-static void SkippedMacroblock( vpar_thread_t * p_vpar, int i_mb,
+static __inline__ void SkippedMacroblock( vpar_thread_t * p_vpar, int i_mb,
                                           int i_mb_base, int i_coding_type,
                                           int i_chroma_format,
                                           int i_structure,
@@ -1599,7 +1599,7 @@ static void SkippedMacroblock( vpar_thread_t * p_vpar, int i_mb,
 /*****************************************************************************
  * MacroblockModes : Get the macroblock_modes structure
  *****************************************************************************/
-static void MacroblockModes( vpar_thread_t * p_vpar,
+static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
                                         macroblock_t * p_mb,
                                         int i_chroma_format,
                                         int i_coding_type,
@@ -1683,7 +1683,6 @@ if( p_vpar->picture.b_error )                                           \
     return;                                                             \
 }
 
-
 #define PARSEBLOCKS( MPEG1FUNC, MPEG2FUNC )                             \
 {                                                                       \
     i_mask = 1 << (3 + (1 << i_chroma_format));                         \
@@ -1746,7 +1745,7 @@ if( p_vpar->picture.b_error )                                           \
     }                                                                   \
 }
 
-static void ParseMacroblock(
+static __inline__ void ParseMacroblock(
                            vpar_thread_t * p_vpar,
                            int * pi_mb_address,     /* previous address to be
                                                      * used for mb_addr_incr */
@@ -1977,10 +1976,137 @@ i_count++;
  * Picture data parsing management
  */
 
+/*****************************************************************************
+ * ParseMacroblockVWXYZ : Parse the next macroblock ; specific functions
+ *****************************************************************************
+ * V = MPEG2 ?
+ * W = coding type ?
+ * X = chroma format ?
+ * Y = structure ?
+ * Z = second field ?
+ *****************************************************************************/
+void ParseMacroblockGENERIC( vpar_thread_t * p_vpar, int * pi_mb_address,
+                             int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+/*    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     b_mpeg2, i_coding_type, i_chroma_format,
+                     i_structure, b_second_field );*/
+}
+
+#if (VPAR_OPTIM_LEVEL > 0)
+/* Optimizations for frame pictures */
+void ParseMacroblock2I420F0( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, I_CODING_TYPE, CHROMA_420,
+                     FRAME_STRUCTURE, 0 );
+}
+
+void ParseMacroblock2P420F0( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, P_CODING_TYPE, CHROMA_420,
+                     FRAME_STRUCTURE, 0 );
+}
+
+void ParseMacroblock2B420F0( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, B_CODING_TYPE, CHROMA_420,
+                     FRAME_STRUCTURE, 0 );
+}
+#endif
+
+#if (VPAR_OPTIM_LEVEL > 1)
+/* Optimizations for field pictures */
+void ParseMacroblock2I420TZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, I_CODING_TYPE, CHROMA_420,
+                     TOP_FIELD, (p_vpar->picture.i_structure !=
+                                 p_vpar->picture.i_current_structure) );
+}
+
+void ParseMacroblock2P420TZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, P_CODING_TYPE, CHROMA_420,
+                     TOP_FIELD, (p_vpar->picture.i_structure !=
+                                 p_vpar->picture.i_current_structure) );
+}
+
+void ParseMacroblock2B420TZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, B_CODING_TYPE, CHROMA_420,
+                     TOP_FIELD, (p_vpar->picture.i_structure !=
+                                 p_vpar->picture.i_current_structure) );
+}
+
+void ParseMacroblock2I420BZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, I_CODING_TYPE, CHROMA_420,
+                     BOTTOM_FIELD, (p_vpar->picture.i_structure !=
+                                    p_vpar->picture.i_current_structure) );
+}
+
+void ParseMacroblock2P420BZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, P_CODING_TYPE, CHROMA_420,
+                     BOTTOM_FIELD, (p_vpar->picture.i_structure !=
+                                    p_vpar->picture.i_current_structure) );
+}
+
+void ParseMacroblock2B420BZ( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                             boolean_t b_mpeg2, int i_coding_type,
+                             int i_chroma_format, int i_structure,
+                             boolean_t b_second_field )
+{
+    ParseMacroblock( p_vpar, pi_mb_address, i_mb_previous, i_mb_base,
+                     1, B_CODING_TYPE, CHROMA_420,
+                     BOTTOM_FIELD, (p_vpar->picture.i_structure !=
+                                    p_vpar->picture.i_current_structure) );
+}
+#endif
+
 /*****************************************************************************
  * SliceHeader : Parse the next slice structure
  *****************************************************************************/
-static void SliceHeader( vpar_thread_t * p_vpar,
+typedef void    (*f_parse_mb_t)( vpar_thread_t * p_vpar, int * pi_mb_address,                                    int i_mb_previous, int i_mb_base,
+                                 boolean_t b_mpeg2, int i_coding_type,
+                                 int i_chroma_format, int i_structure,
+                                 boolean_t b_second_field );
+
+static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
                                     int * pi_mb_address, int i_mb_base,
                                     u32 i_vert_code, boolean_t b_high,
                                     boolean_t b_dp_scalable,
@@ -1988,6 +2114,43 @@ static void SliceHeader( vpar_thread_t * p_vpar,
                                     int i_chroma_format, int i_structure,
                                     boolean_t b_second_field )
 {
+    static f_parse_mb_t ppf_parse_mb[4][4] =
+    {
+        {
+            NULL, NULL, NULL, NULL
+        },
+        {
+            /* TOP_FIELD */
+#if (VPAR_OPTIM_LEVEL > 1)
+            NULL, ParseMacroblock2I420TZ, ParseMacroblock2P420TZ,
+            ParseMacroblock2B420TZ
+#else
+            NULL, ParseMacroblockGENERIC, ParseMacroblockGENERIC,
+            ParseMacroblockGENERIC
+#endif
+        },
+        {
+            /* BOTTOM_FIELD */
+#if (VPAR_OPTIM_LEVEL > 1)
+            NULL, ParseMacroblock2I420BZ, ParseMacroblock2P420BZ,
+            ParseMacroblock2B420BZ
+#else
+            NULL, ParseMacroblockGENERIC, ParseMacroblockGENERIC,
+            ParseMacroblockGENERIC
+#endif
+        },
+        {
+            /* FRAME_PICTURE */
+#if (VPAR_OPTIM_LEVEL > 0)
+            NULL, ParseMacroblock2I420F0, ParseMacroblock2P420F0,
+            ParseMacroblock2B420F0
+#else
+            NULL, ParseMacroblockGENERIC, ParseMacroblockGENERIC,
+            ParseMacroblockGENERIC
+#endif
+        }
+    };
+
     int                     i_mb_address_save = *pi_mb_address;
 
     p_vpar->picture.b_error = 0;
@@ -2039,10 +2202,37 @@ static void SliceHeader( vpar_thread_t * p_vpar,
             p_vpar->picture.b_error = 1;
             return;
         }
-        ParseMacroblock( p_vpar, pi_mb_address, i_mb_address_save,
+
+        if( p_vpar->sequence.i_chroma_format != CHROMA_420
+            || !p_vpar->sequence.b_mpeg2 || p_vpar->sequence.i_height > 2800
+            || p_vpar->sequence.i_scalable_mode == SC_DP )
+        {
+            /* Weird stream. Use the slower generic function. */
+            ParseMacroblockGENERIC( p_vpar, pi_mb_address, i_mb_address_save,
+                         i_mb_base, b_mpeg2, i_coding_type,
+                         i_chroma_format, i_structure,
+                         b_second_field );
+        }
+        else
+        {
+            /* Try to find an optimized function. */
+            if( ppf_parse_mb[p_vpar->picture.i_structure]
+                            [p_vpar->picture.i_coding_type] == NULL )
+            {
+                intf_ErrMsg( "vpar error: bad ppf_parse_mb function pointer (struct:%d, coding type:%d)\n",
+                         p_vpar->picture.i_structure, p_vpar->picture.i_coding_type );
+            }
+            else
+            {
+                ppf_parse_mb[p_vpar->picture.i_structure]
+                            [p_vpar->picture.i_coding_type]
+                       ( p_vpar, pi_mb_address, i_mb_address_save,
                          i_mb_base, b_mpeg2, i_coding_type,
                          i_chroma_format, i_structure,
                          b_second_field );
+            }
+        }
+
         i_mb_address_save = *pi_mb_address;
         if( p_vpar->picture.b_error )
         {
@@ -2056,17 +2246,14 @@ static void SliceHeader( vpar_thread_t * p_vpar,
 /*****************************************************************************
  * PictureData : Parse off all macroblocks (ISO/IEC 13818-2 6.2.3.7)
  *****************************************************************************/
-static void PictureData( vpar_thread_t * p_vpar, int i_mb_base,
-                                    boolean_t b_high, boolean_t b_dp_scalable,
-                                    boolean_t b_mpeg2, int i_coding_type,
-                                    int i_chroma_format, int i_structure,
-                                    boolean_t b_second_field )
+void vpar_PictureData( vpar_thread_t * p_vpar, int i_mb_base )
 {
     int         i_mb_address = 0;
     u32         i_dummy;
 
     NextStartCode( p_vpar );
-    while( ((i_coding_type != I_CODING_TYPE && i_coding_type != D_CODING_TYPE)
+    while( ((p_vpar->picture.i_coding_type != I_CODING_TYPE
+                    && p_vpar->picture.i_coding_type != D_CODING_TYPE)
              || !p_vpar->picture.b_error)
            && i_mb_address+i_mb_base < p_vpar->sequence.i_mb_size
            && !p_vpar->b_die )
@@ -2083,17 +2270,23 @@ static void PictureData( vpar_thread_t * p_vpar, int i_mb_base,
 
         /* Decode slice data. */
         SliceHeader( p_vpar, &i_mb_address, i_mb_base, i_dummy & 255,
-                     b_high, b_dp_scalable, b_mpeg2, i_coding_type,
-                     i_chroma_format, i_structure, b_second_field );
+                     (p_vpar->sequence.i_height > 2800),
+                     (p_vpar->sequence.i_scalable_mode == SC_DP),
+                     p_vpar->sequence.b_mpeg2, p_vpar->picture.i_coding_type,
+                     p_vpar->sequence.i_chroma_format,
+                     p_vpar->picture.i_structure,
+                     (p_vpar->picture.i_structure !=
+                        p_vpar->picture.i_current_structure) );
     }
 
     /* Try to recover from error. If we missed less than half the
      * number of macroblocks of the picture, mark the missed ones
      * as skipped. */
-    if( (i_coding_type == P_CODING_TYPE || i_coding_type == B_CODING_TYPE)
+    if( (p_vpar->picture.i_coding_type == P_CODING_TYPE
+                || p_vpar->picture.i_coding_type == B_CODING_TYPE)
         && p_vpar->picture.b_error &&
         ( (i_mb_address-i_mb_base) > (p_vpar->sequence.i_mb_size >> 1)
-           || (i_structure != FRAME_STRUCTURE
+           || (p_vpar->picture.i_structure != FRAME_STRUCTURE
                && (i_mb_address-i_mb_base) > (p_vpar->sequence.i_mb_size >> 2) ) ) )
     {
         int         i_mb;
@@ -2101,97 +2294,16 @@ static void PictureData( vpar_thread_t * p_vpar, int i_mb_base,
         p_vpar->picture.b_error = 0;
         for( i_mb = i_mb_address + 1;
              i_mb < (p_vpar->sequence.i_mb_size
-                     << (i_structure != FRAME_STRUCTURE));
+                     << (p_vpar->picture.i_structure != FRAME_STRUCTURE));
              i_mb++ )
         {
-            SkippedMacroblock( p_vpar, i_mb, i_mb_base, i_coding_type,
-                               i_chroma_format, i_structure, b_second_field );
+            SkippedMacroblock( p_vpar, i_mb, i_mb_base,
+                               p_vpar->picture.i_coding_type,
+                               p_vpar->sequence.i_chroma_format,
+                               p_vpar->picture.i_structure,
+                               (p_vpar->picture.i_structure !=
+                                p_vpar->picture.i_current_structure) );
         }
     }
 }
 
-/*****************************************************************************
- * vpar_PictureDataVWXYZ : Parse the next macroblock ; specific functions
- *****************************************************************************
- * V = MPEG2 ?
- * W = coding type ?
- * X = chroma format ?
- * Y = structure ?
- * Z = second field ?
- *****************************************************************************/
-void vpar_PictureDataGENERIC( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, (p_vpar->sequence.i_height > 2800),
-                 (p_vpar->sequence.i_scalable_mode == SC_DP),
-                 p_vpar->sequence.b_mpeg2, p_vpar->picture.i_coding_type,
-                 p_vpar->sequence.i_chroma_format,
-                 p_vpar->picture.i_structure,
-                 (p_vpar->picture.i_structure !=
-                    p_vpar->picture.i_current_structure) );
-}
-
-#if (VPAR_OPTIM_LEVEL > 0)
-/* Optimizations for frame pictures */
-void vpar_PictureData2I420F0( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, 0, 0, 0, 1, I_CODING_TYPE, CHROMA_420,
-                 FRAME_STRUCTURE, 0 );
-}
-
-void vpar_PictureData2P420F0( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, 0, 0, 0, 1, P_CODING_TYPE, CHROMA_420,
-                 FRAME_STRUCTURE, 0 );
-}
-
-void vpar_PictureData2B420F0( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, 0, 0, 0, 1, B_CODING_TYPE, CHROMA_420,
-                 FRAME_STRUCTURE, 0 );
-}
-#endif
-
-#if (VPAR_OPTIM_LEVEL > 1)
-/* Optimizations for field pictures */
-void vpar_PictureData2I420TZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, I_CODING_TYPE, CHROMA_420,
-                 TOP_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-
-void vpar_PictureData2P420TZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, P_CODING_TYPE, CHROMA_420,
-                 TOP_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-
-void vpar_PictureData2B420TZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, B_CODING_TYPE, CHROMA_420,
-                 TOP_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-
-void vpar_PictureData2I420BZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, I_CODING_TYPE, CHROMA_420,
-                 BOTTOM_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-
-void vpar_PictureData2P420BZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, P_CODING_TYPE, CHROMA_420,
-                 BOTTOM_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-
-void vpar_PictureData2B420BZ( vpar_thread_t * p_vpar, int i_mb_base )
-{
-    PictureData( p_vpar, i_mb_base, 0, 0, 1, B_CODING_TYPE, CHROMA_420,
-                 BOTTOM_FIELD, (p_vpar->picture.i_structure !=
-                                p_vpar->picture.i_current_structure) );
-}
-#endif
index 92106369c35b76f6b09dfb8f5eff68026ca5da6c..1859f528396624e316f12f4f577824d695cc2dfb 100644 (file)
 #include "video_parser.h"
 #include "video_fifo.h"
 
-/*
- * Function pointer
- */
-typedef void    (*f_picture_data_t)( vpar_thread_t*, int );
-
 /*
  * Local prototypes
  */
@@ -334,17 +329,17 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
 static void SequenceHeader( vpar_thread_t * p_vpar )
 {
 #define RESERVED    -1
-    static float r_frame_rate_table[16] =
-    {
-        0.0,
-        ((23.0*1000.0)/1001.0),
-        24.0,
-        25.0,
-        ((30.0*1000.0)/1001.0),
-        30.0,
-        50.0,
-        ((60.0*1000.0)/1001.0),
-        60.0,
+    static int i_frame_rate_table[16] =
+    {
+        0,
+        23 * 1000,
+        24 * 1001,
+        25 * 1001,
+        30 * 1000,
+        30 * 1001,
+        50 * 1001,
+        60 * 1000,
+        60 * 1001,
         RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED
     };
 #undef RESERVED
@@ -357,8 +352,8 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
     p_vpar->sequence.i_width = GetBits( &p_vpar->bit_stream, 12 );
     p_vpar->sequence.i_height = GetBits( &p_vpar->bit_stream, 12 );
     p_vpar->sequence.i_aspect_ratio = GetBits( &p_vpar->bit_stream, 4 );
-    p_vpar->sequence.r_frame_rate =
-            r_frame_rate_table[ GetBits( &p_vpar->bit_stream, 4 ) ];
+    p_vpar->sequence.i_frame_rate =
+            i_frame_rate_table[ GetBits( &p_vpar->bit_stream, 4 ) ];
 
     /* We don't need bit_rate_value, marker_bit, vbv_buffer_size,
      * constrained_parameters_flag */
@@ -418,7 +413,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
         /* frame_rate_extension_n */
         i_dummy = GetBits( &p_vpar->bit_stream, 2 );
         /* frame_rate_extension_d */
-        p_vpar->sequence.r_frame_rate *= (i_dummy + 1)
+        p_vpar->sequence.i_frame_rate *= (i_dummy + 1)
                                   / (GetBits( &p_vpar->bit_stream, 5 ) + 1);
     }
     else
@@ -496,44 +491,6 @@ static void GroupHeader( vpar_thread_t * p_vpar )
  *****************************************************************************/
 static void PictureHeader( vpar_thread_t * p_vpar )
 {
-    /* Table of optimized PictureData functions. */
-    static f_picture_data_t ppf_picture_data[4][4] =
-    {
-        {
-            NULL, NULL, NULL, NULL
-        },
-        {
-            /* TOP_FIELD */
-#if (VPAR_OPTIM_LEVEL > 1)
-            NULL, vpar_PictureData2I420TZ, vpar_PictureData2P420TZ,
-            vpar_PictureData2B420TZ
-#else
-            NULL, vpar_PictureDataGENERIC, vpar_PictureDataGENERIC,
-            vpar_PictureDataGENERIC
-#endif
-        },
-        {
-            /* BOTTOM_FIELD */
-#if (VPAR_OPTIM_LEVEL > 1)
-            NULL, vpar_PictureData2I420BZ, vpar_PictureData2P420BZ,
-            vpar_PictureData2B420BZ
-#else
-            NULL, vpar_PictureDataGENERIC, vpar_PictureDataGENERIC,
-            vpar_PictureDataGENERIC
-#endif
-        },
-        {
-            /* FRAME_PICTURE */
-#if (VPAR_OPTIM_LEVEL > 0)
-            NULL, vpar_PictureData2I420F0, vpar_PictureData2P420F0,
-            vpar_PictureData2B420F0
-#else
-            NULL, vpar_PictureDataGENERIC, vpar_PictureDataGENERIC,
-            vpar_PictureDataGENERIC
-#endif
-        }
-    };
-
     int                 i_structure;
     int                 i_mb_base;
     boolean_t           b_parsable;
@@ -764,28 +721,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
     /* Extension and User data. */
     ExtensionAndUserData( p_vpar );
 
-    /* Picture data (ISO/IEC 13818-2 6.2.3.7). */
-    if( p_vpar->sequence.i_chroma_format != CHROMA_420
-        || !p_vpar->sequence.b_mpeg2 || p_vpar->sequence.i_height > 2800
-        || p_vpar->sequence.i_scalable_mode == SC_DP )
-    {
-        /* Weird stream. Use the slower generic function. */
-        vpar_PictureDataGENERIC( p_vpar, i_mb_base );
-    }
-    else
-    {
-        /* Try to find an optimized function. */
-        if( ppf_picture_data[p_vpar->picture.i_structure][p_vpar->picture.i_coding_type] == NULL )
-        {
-            intf_ErrMsg( "vpar error: bad ppf_picture_data function pointer (struct:%d, coding type:%d)\n",
-                     p_vpar->picture.i_structure, p_vpar->picture.i_coding_type );
-        }
-        else
-        {
-            ppf_picture_data[p_vpar->picture.i_structure]
-                            [p_vpar->picture.i_coding_type]( p_vpar, i_mb_base );
-        }
-    }
+    vpar_PictureData( p_vpar, i_mb_base );
 
     if( p_vpar->b_die || p_vpar->b_error )
     {
index fe813eeada747af39072edaab7b500e57867be7a..49f8849b11381e4ce05e575acc648be28fd772de 100644 (file)
@@ -65,7 +65,7 @@
 void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
                                    int i_coding_type, boolean_t b_kept )
 {
-    double          i_can_display;
+    int             i_can_display;
     mtime_t         i_pts;
     pes_packet_t *  p_pes = p_vpar->bit_stream.p_decoder_fifo->buffer[
                                p_vpar->bit_stream.p_decoder_fifo->i_start ];
@@ -100,13 +100,13 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
     {
         case P_CODING_TYPE:
 
-            p_vpar->synchro.i_P_seen++;
-            if( b_kept ) p_vpar->synchro.i_P_kept++;
+            p_vpar->synchro.i_P_seen += 1024;
+            if( b_kept ) p_vpar->synchro.i_P_kept += 1024;
             break;
 
         case B_CODING_TYPE:
-            p_vpar->synchro.i_B_seen++;
-            if( b_kept ) p_vpar->synchro.i_B_kept++;
+            p_vpar->synchro.i_B_seen += 1024;
+            if( b_kept ) p_vpar->synchro.i_B_kept += 1024;
             break;
 
         case I_CODING_TYPE:
@@ -118,8 +118,8 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
                 if ( p_vpar->synchro.i_last_seen_I_pts )
                 {
                     p_vpar->synchro.i_theorical_delay =
-                            ( i_pts - p_vpar->synchro.i_last_seen_I_pts )
-                          / ( 1 + p_vpar->synchro.i_B_seen
+                      1024 * ( i_pts - p_vpar->synchro.i_last_seen_I_pts )
+                          / ( 1024 + p_vpar->synchro.i_B_seen
                                 + p_vpar->synchro.i_P_seen);
                 }
                 p_vpar->synchro.i_last_seen_I_pts = i_pts;
@@ -127,7 +127,8 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
 
             /* now we calculated all statistics, it's time to
              * decide what we have the time to display */
-            i_can_display = (float)(i_pts - p_vpar->synchro.i_last_kept_I_pts)
+            i_can_display = 
+                ( (i_pts - p_vpar->synchro.i_last_kept_I_pts) << 10 )
                                 / p_vpar->synchro.i_delay;
 
             p_vpar->synchro.b_all_I = 0;
@@ -136,9 +137,9 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
             p_vpar->synchro.displayable_p = 0;
             p_vpar->synchro.displayable_b = 0;
 
-            if( ( p_vpar->synchro.b_all_I = ( i_can_display > 1 ) ) )
+            if( ( p_vpar->synchro.b_all_I = ( i_can_display >= 1024 ) ) )
             {
-                i_can_display -= 1;
+                i_can_display -= 1024;
 
                 if( !( p_vpar->synchro.b_all_P
                         = ( i_can_display > p_vpar->synchro.i_P_seen ) ) )
@@ -159,20 +160,21 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
 
 #if 1
             if( p_vpar->synchro.b_all_I )
-                intf_ErrMsg( " I: 1/1  " );
+                intf_ErrMsg( " I: 1024/1024  " );
             if( p_vpar->synchro.b_all_P )
                 intf_ErrMsg( "P: %i/%i  ", p_vpar->synchro.i_P_seen,
                                            p_vpar->synchro.i_P_seen );
             else if( p_vpar->synchro.displayable_p > 0 )
-                intf_ErrMsg( "P: %.2f/%i  ", p_vpar->synchro.displayable_p,
+                intf_ErrMsg( "P: %i/%i  ", p_vpar->synchro.displayable_p,
                                              p_vpar->synchro.i_P_seen );
             if( p_vpar->synchro.b_all_B )
                 intf_ErrMsg( "B: %i/%i", p_vpar->synchro.i_B_seen,
                                          p_vpar->synchro.i_B_seen );
             else if( p_vpar->synchro.displayable_b > 0 )
-                intf_ErrMsg( "B: %.2f/%i", p_vpar->synchro.displayable_b,
+                intf_ErrMsg( "B: %i/%i", p_vpar->synchro.displayable_b,
                                            p_vpar->synchro.i_B_seen );
-            intf_ErrMsg( "                    \r" );
+//            intf_ErrMsg( "                             \r" );
+            intf_ErrMsg( "\n" );
 #endif
             p_vpar->synchro.i_P_seen = 0;
             p_vpar->synchro.i_B_seen = 0;
@@ -197,8 +199,6 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
 {
     mtime_t i_delay = p_vpar->synchro.i_last_pts - mdate();
 
-    //return (i_coding_type == I_CODING_TYPE);
-
     switch( i_coding_type )
     {
         case I_CODING_TYPE:
@@ -407,7 +407,8 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
 mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
 {
     return( p_vpar->synchro.kludge_date
-            + p_vpar->synchro.kludge_nbframes*1000000/(p_vpar->sequence.r_frame_rate ) );
+            + p_vpar->synchro.kludge_nbframes * 1000000
+                / (p_vpar->sequence.i_frame_rate ) * 1001 );
 }
 
 void vpar_SynchroEnd( vpar_thread_t * p_vpar )
@@ -481,7 +482,7 @@ void vpar_SynchroSetCurrentDate( vpar_thread_t * p_vpar, int i_coding_type )
         }
         else
         {
-            p_vpar->synchro.i_current_frame_date += 1000000/(p_vpar->sequence.r_frame_rate);
+            p_vpar->synchro.i_current_frame_date += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
         }
         break;
 
@@ -489,7 +490,7 @@ void vpar_SynchroSetCurrentDate( vpar_thread_t * p_vpar, int i_coding_type )
 
         if( p_vpar->synchro.i_backward_frame_date == 0 )
         {
-            p_vpar->synchro.i_current_frame_date += 1000000/(p_vpar->sequence.r_frame_rate);
+            p_vpar->synchro.i_current_frame_date += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
         }
         else
         {