]> git.sesse.net Git - vlc/blobdiff - include/vpar_blocks.h
The motion compensation routines are now modules as well ; choose your
[vlc] / include / vpar_blocks.h
index dcbc0fc61d15bca8d4f1ebb5ca13cee32c7aca63..a3efa11d898d359a7a64f0ef1f724f60188c3140 100644 (file)
@@ -1,13 +1,34 @@
 /*****************************************************************************
  * vpar_blocks.h : video parser blocks management
- * (c)1999 VideoLAN
- *****************************************************************************
  *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: vpar_blocks.h,v 1.32 2001/01/18 05:13:22 sam Exp $
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *          Jean-Marc Dressler <polux@via.ecp.fr>
+ *          Stéphane Borel <stef@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"
  *  "mtime.h"
- *  "vlc_thread.h"
+ *  "threads.h"
  *  "input.h"
  *  "video.h"
  *  "video_output.h"
  *****************************************************************************/
 
 /*****************************************************************************
- * macroblock_t : information on a macroblock
+ * macroblock_t : information on a macroblock passed to the video_decoder
+ *                thread
  *****************************************************************************/
 typedef struct macroblock_s
 {
-    picture_t *             p_picture;
-    int                     i_mb_x, i_mb_y;
-    int                     i_structure;
-    int                     i_l_x, i_l_y;    /* position of macroblock (lum) */
-    int                     i_c_x, i_c_y; /* position of macroblock (chroma) */
-    int                     i_structure;
-    int                     i_chroma_nb_blocks;  /* nb of bks for a chr comp */
+    picture_t *             p_picture;          /* current frame in progress */
+
+    int                     i_mb_type;                    /* macroblock type */
+    int                     i_coded_block_pattern;
+                                                 /* which blocks are coded ? */
+    int                     i_chroma_nb_blocks;         /* number of blocks for
+                                                         * chroma components */
 
     /* IDCT information */
-    elem_t                  ppi_blocks[12][64];                    /* blocks */
-    f_idct_t                pf_idct[12];             /* sparse IDCT or not ? */
-    int                     pi_sparse_pos[12];
+    dctelem_t               ppi_blocks[12][64];                    /* blocks */
+    void ( * pf_idct[12] )  ( struct vdec_thread_s *,
+                              dctelem_t*, int );     /* sparse IDCT or not ? */
+    int                     pi_sparse_pos[12];             /* position of the
+                                                            * non-NULL coeff */
 
     /* Motion compensation information */
     f_motion_t              pf_motion;    /* function to use for motion comp */
-    f_chroma_motion_t       pf_chroma_motion;
-    picture_t *             p_backw_top, p_backw_bot;
-    picture_t *             p_forw_top, p_forw_bot;
-    int                     i_field_select_backw_top, i_field_select_backw_bot;
-    int                     i_field_select_forw_top, i_field_select_forw_bot;
-    int                     pi_motion_vectors_backw_top[2];
-    int                     pi_motion_vectors_backw_bot[2];
-    int                     pi_motion_vectors_forw_top[2];
-    int                     pi_motion_vectors_forw_bot[2];
+    picture_t *             p_backward;          /* backward reference frame */
+    picture_t *             p_forward;            /* forward reference frame */
+    int                     ppi_field_select[2][2];      /* field to use to
+                                                          * form predictions */
+    int                     pppi_motion_vectors[2][2][2];  /* motion vectors */
+    int                     ppi_dmv[2][2];    /* differential motion vectors */
+                            /* coordinates of the block in the picture */
+    int                     i_l_x, i_c_x;
+    int                     i_motion_l_y;
+    int                     i_motion_c_y;
+    int                     i_l_stride;         /* number of yuv_data_t to
+                                                 * ignore when changing line */
+    int                     i_c_stride;                  /* idem, for chroma */
+    boolean_t               b_P_second;  /* Second field of a P picture ?
+                                          * (used to determine the predicting
+                                          * frame)                           */
+    boolean_t               b_motion_field;  /* Field we are predicting
+                                              * (top field or bottom field) */
 
     /* AddBlock information */
-    f_addb_t                pf_addb[12];
-    data_t *                p_data[12];    /* positions of blocks in picture */
-    int                     i_lum_incr, i_chroma_incr;
+    yuv_data_t *            p_data[12];              /* pointer to the position
+                                                      * in the final picture */
+    int                     i_addb_l_stride, i_addb_c_stride;
+                                 /* nb of coeffs to jump when changing lines */
 } macroblock_t;
 
 /*****************************************************************************
- * macroblock_parsing_t : parser context descriptor #3
+ * macroblock_parsing_t : macroblock context & predictors
  *****************************************************************************/
 typedef struct
 {
-    int                     i_mb_type, i_motion_type, i_mv_count, i_mv_format;
-    int                     i_coded_block_pattern;
-    boolean_t               b_dct_type;
+    unsigned char       i_quantizer_scale;        /* scale of the quantization
+                                                   * matrices                */
+    int                 pi_dc_dct_pred[3];          /* ISO/IEC 13818-2 7.2.1 */
+    int                 pppi_pmv[2][2][2];  /* Motion vect predictors, 7.6.3 */
+    int                 i_motion_dir;/* Used for the next skipped macroblock */
+
+    /* Context used to optimize block parsing */
+    int                 i_motion_type, i_mv_count, i_mv_format;
+    boolean_t           b_dmv, b_dct_type;
+
+    /* Coordinates of the upper-left pixel of the macroblock, in lum and
+     * chroma */
+    int                 i_l_x, i_l_y, i_c_x, i_c_y;
 } macroblock_parsing_t;
 
 /*****************************************************************************
- * LoadQuantizerScale
- *****************************************************************************
- * Quantizer scale factor (ISO/IEC 13818-2 7.4.2.2)
+ * lookup_t : entry type for lookup tables                                   *
+ *****************************************************************************/
+typedef struct lookup_s
+{
+    int    i_value;
+    int    i_length;
+} lookup_t;
+
+/*****************************************************************************
+ * ac_lookup_t : special entry type for lookup tables about ac coefficients
  *****************************************************************************/
-static __inline__ void LoadQuantizerScale( vpar_thread_t * p_vpar )
+typedef struct dct_lookup_s
 {
-    /* Quantization coefficient table */
-    static unsigned char    ppi_quantizer_scale[3][32] =
-    {
-        /* MPEG-2 */
-        {
-            /* q_scale_type */
-            /* linear */
-            0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,
-            32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
-        },
-        {
-            /* non-linear */
-            0, 1, 2, 3, 4, 5, 6, 7, 8, 10,12,14,16,18,20, 22,
-            24,28,32,36,40,44,48,52,56,64,72,80,88,96,104,112
-        },
-        /* MPEG-1 */
-        {
-            0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-            16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
-        }
-    };
-
-    p_vpar->slice.i_quantizer_scale = ppi_quantizer_scale
-           [(!p_vpar->sequence.b_mpeg2 << 1) | p_vpar->picture.b_q_scale_type]
-           [GetBits( &p_vpar->bit_stream, 5 )];
-}
+    char   i_run;
+    char   i_level;
+    char   i_length;
+} dct_lookup_t;
 
 /*****************************************************************************
  * Standard codes
@@ -110,3 +139,37 @@ static __inline__ void LoadQuantizerScale( vpar_thread_t * p_vpar )
 #define MOTION_FRAME                    2
 #define MOTION_16X8                     2
 #define MOTION_DMV                      3
+
+/* Macroblock Address Increment types */
+#define MB_ADDRINC_ESCAPE               8
+#define MB_ADDRINC_STUFFING             15
+
+/* Error constant for lookup tables */
+#define MB_ERROR                        (-1)
+
+/* Scan */
+#define SCAN_ZIGZAG                     0
+#define SCAN_ALT                        1
+
+/* Constant for block decoding */
+#define DCT_EOB                         64
+#define DCT_ESCAPE                      65
+
+/*****************************************************************************
+ * Constants
+ *****************************************************************************/
+extern u8       pi_default_intra_quant[64];
+extern u8       pi_default_nonintra_quant[64];
+extern u8       pi_scan[2][64];
+
+/*****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+void vpar_InitCrop( struct vpar_thread_s* p_vpar );
+void vpar_InitMbAddrInc( struct vpar_thread_s * p_vpar );
+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_InitScanTable( struct vpar_thread_s * p_vpar );
+void vpar_PictureData( struct vpar_thread_s * p_vpar, int i_mb_base );