]> git.sesse.net Git - vlc/blobdiff - src/video_parser/vpar_blocks.c
D�but du portage BeOS. Beaucoup de fuchiers ont �t� modifi� car il a fallu
[vlc] / src / video_parser / vpar_blocks.c
index 395efb834376d7a121de1037618ffa06211045df..a0711fb3a54ede8832981e4403afdba926120322 100644 (file)
@@ -1,25 +1,40 @@
 /*****************************************************************************
  * vpar_blocks.c : blocks parsing
- * (c)1999 VideoLAN
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * 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-1307, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/uio.h>
+#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
+#include <sys/uio.h>                                            /* "input.h" */
 
+#include "threads.h"
 #include "config.h"
 #include "common.h"
 #include "mtime.h"
-#include "vlc_thread.h"
+#include "plugins.h"
 
 #include "intf_msg.h"
-#include "debug.h"                    /* ?? temporaire, requis par netlist.h */
+#include "debug.h"                 /* XXX?? temporaire, requis par netlist.h */
 
 #include "input.h"
 #include "input_netlist.h"
 #include "video_parser.h"
 #include "video_fifo.h"
 
-
-
-
-
-
-
 static int i_count = 0;
 
-
-
-
-
-
 /*
  * Welcome to vpar_blocks.c ! Here's where the heavy processor-critical parsing
  * task is done. This file is divided in several parts :
@@ -137,7 +141,7 @@ static lookup_t     pl_coded_pattern[512] =
      * Tables are cut in two parts to reduce memory occupation
      */
 
-    /* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
+    /* Table B-12, dct_dc_size_luminance, codes 00XXX ... 11110 */
 static lookup_t     pl_dct_dc_lum_init_table_1[32] =
     { {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
       {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
@@ -163,7 +167,7 @@ static lookup_t     pl_dct_dc_chrom_init_table_1[32] =
       {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {MB_ERROR, 0}
     };
 
-    /* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
+   /* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
 static lookup_t     pl_dct_dc_chrom_init_table_2[32] =
     { {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
       {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
@@ -543,11 +547,11 @@ void vpar_InitDCTTables( vpar_thread_t * p_vpar )
     p_vpar->pppl_dct_dc_size[1][0] = pl_dct_dc_chrom_init_table_1;
     p_vpar->pppl_dct_dc_size[1][1] = pl_dct_dc_chrom_init_table_2;
 
-    /* ??? MB_ERROR is replaced by 0 because if we use -1 we 
+    /* XXX?? MB_ERROR is replaced by 0 because if we use -1 we
      * can block in DecodeMPEG2Intra and others */
     memset( p_vpar->ppl_dct_coef[0], 0, 16 );
     memset( p_vpar->ppl_dct_coef[1], 0, 16 );
-    
+
     /* For table B14 & B15, we have a pointer to tables */
     /* We fill the table thanks to the fonction defined above */
     FillDCTTable( p_vpar->ppl_dct_coef[0], pl_DCT_tab0, 256, 60,  4 );
@@ -1485,7 +1489,7 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
             p_vpar->mb.i_motion_type = MOTION_FRAME;
         }
 
-        /* ???? */
+        /* XXX?? */
         p_vpar->mb.i_mv_count = ppi_mv_count[i_structure == FRAME_STRUCTURE]
                                             [p_vpar->mb.i_motion_type];
         p_vpar->mb.i_mv_format = ppi_mv_format[i_structure == FRAME_STRUCTURE]
@@ -1642,11 +1646,11 @@ i_count++;
 
     if( i_inc < 0 )
     {
-        fprintf( stderr, "vpar error: bad address increment (%d)\n", i_inc );
+        intf_ErrMsg( "vpar error: bad address increment (%d)\n", i_inc );
         p_vpar->picture.b_error = 1;
         return;
     }
-    
+
     if( *pi_mb_address - i_mb_previous - 1 )
     {
         /* Skipped macroblock (ISO/IEC 13818-2 7.6.6). */
@@ -1858,12 +1862,12 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
         {
             RemoveBits( &p_vpar->bit_stream, 8 );
         }
-    }    
+    }
     *pi_mb_address = (i_vert_code - 1)*p_vpar->sequence.i_mb_width;
 
     if( *pi_mb_address < i_mb_address_save )
     {
-        fprintf( stderr, "vpar error: slices do not follow, maybe a PES has been trashed\n" );
+        intf_ErrMsg( "vpar error: slices do not follow, maybe a PES has been trashed\n" );
         p_vpar->picture.b_error = 1;
         return;
     }
@@ -1878,6 +1882,11 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
 
     do
     {
+        if( i_mb_address_save >= p_vpar->sequence.i_mb_size )
+        {
+            p_vpar->picture.b_error = 1;
+            return;
+        }
         ParseMacroblock( p_vpar, pi_mb_address, i_mb_address_save,
                          i_mb_base, b_mpeg2, i_coding_type,
                          i_chroma_format, i_structure,