]> git.sesse.net Git - x264/blobdiff - common/common.h
10l in rev290: duplicate declaration of x264_pixel_sub_8x8_mmx.
[x264] / common / common.h
index 80f41dc588012a35d506da12afde653780f8a36b..e0986c4eab9023dc90eb3973d47bc9048e97f9b6 100644 (file)
@@ -33,6 +33,7 @@
 
 #ifdef _MSC_VER
 #define snprintf _snprintf
+#define X264_VERSION "" // no configure script for msvc
 #endif
 
 #include "x264.h"
@@ -66,6 +67,9 @@ void *x264_malloc( int );
 void *x264_realloc( void *p, int i_size );
 void  x264_free( void * );
 
+/* x264_slurp_file: malloc space for the whole file and read it */
+char *x264_slurp_file( const char *filename );
+
 /* mdate: return the current date in microsecond */
 int64_t x264_mdate( void );
 
@@ -111,6 +115,8 @@ enum slice_type_e
     SLICE_TYPE_SI = 4
 };
 
+static const char slice_type_to_char[] = { 'P', 'B', 'I', 'S', 'S' };
+
 typedef struct
 {
     x264_sps_t *sps;
@@ -118,6 +124,7 @@ typedef struct
 
     int i_type;
     int i_first_mb;
+    int i_last_mb;
 
     int i_pps_id;
 
@@ -192,6 +199,8 @@ static const int x264_scan8[16+2*4] =
 */
 
 #define X264_BFRAME_MAX 16
+#define X264_SLICE_MAX 4
+#define X264_NAL_MAX (4 + X264_SLICE_MAX)
 
 typedef struct x264_ratecontrol_t   x264_ratecontrol_t;
 typedef struct x264_vlc_table_t     x264_vlc_table_t;
@@ -201,11 +210,13 @@ struct x264_t
     /* encoder parameters */
     x264_param_t    param;
 
+    x264_t *thread[X264_SLICE_MAX];
+
     /* bitstream output */
     struct
     {
         int         i_nal;
-        x264_nal_t  nal[4];         /* for now 4 is enough */
+        x264_nal_t  nal[X264_NAL_MAX];
         int         i_bitstream;    /* size of p_bitstream */
         uint8_t     *p_bitstream;   /* will hold data for all nal */
         bs_t        bs;
@@ -213,20 +224,29 @@ struct x264_t
 
     /* frame number/poc */
     int             i_frame;
-    int             i_poc;
 
     int             i_frame_offset; /* decoding only */
     int             i_frame_num;    /* decoding only */
     int             i_poc_msb;      /* decoding only */
     int             i_poc_lsb;      /* decoding only */
+    int             i_poc;          /* decoding only */
+
+    int             i_thread_num;   /* threads only */
+    int             i_nal_type;     /* threads only */
+    int             i_nal_ref_idc;  /* threads only */
 
     /* We use only one SPS and one PPS */
-    x264_sps_t      sps_array[32];
+    x264_sps_t      sps_array[1];
     x264_sps_t      *sps;
-    x264_pps_t      pps_array[256];
+    x264_pps_t      pps_array[1];
     x264_pps_t      *pps;
     int             i_idr_pic_id;
 
+    int             dequant4_mf[4][6][4][4];
+    int             dequant8_mf[2][6][8][8];
+    int             quant4_mf[4][6][4][4];
+    int             quant8_mf[2][6][8][8];
+
     /* Slice header */
     x264_slice_header_t sh;
 
@@ -235,17 +255,17 @@ struct x264_t
 
     struct
     {
-        /* Frames to be encoded */
-        x264_frame_t *current[X264_BFRAME_MAX+1];
-        /* Temporary buffer (eg B frames pending until we reach the I/P) */
-        x264_frame_t *next[X264_BFRAME_MAX+1];
+        /* Frames to be encoded (whose types have been decided) */
+        x264_frame_t *current[X264_BFRAME_MAX+3];
+        /* Temporary buffer (frames types not yet decided) */
+        x264_frame_t *next[X264_BFRAME_MAX+3];
         /* Unused frames */
-        x264_frame_t *unused[X264_BFRAME_MAX+1];
+        x264_frame_t *unused[X264_BFRAME_MAX+3];
         /* For adaptive B decision */
         x264_frame_t *last_nonb;
 
-        /* frames used for reference +1 for decoding +1 sentinel */
-        x264_frame_t *reference[16+2+1+1];
+        /* frames used for reference +1 for decoding + sentinels */
+        x264_frame_t *reference[16+2+1+2];
 
         int i_last_idr; /* Frame number of the last IDR */
 
@@ -265,9 +285,9 @@ struct x264_t
 
     /* references lists */
     int             i_ref0;
-    x264_frame_t    *fref0[16];       /* ref list 0 */
+    x264_frame_t    *fref0[16+3];     /* ref list 0 */
     int             i_ref1;
-    x264_frame_t    *fref1[16];       /* ref list 1 */
+    x264_frame_t    *fref1[16+3];     /* ref list 1 */
     int             b_ref_reorder[2];
 
 
@@ -277,6 +297,8 @@ struct x264_t
     {
         DECLARE_ALIGNED( int, luma16x16_dc[16], 16 );
         DECLARE_ALIGNED( int, chroma_dc[2][4], 16 );
+        // FIXME merge with union
+        DECLARE_ALIGNED( int, luma8x8[4][64], 16 );
         union
         {
             DECLARE_ALIGNED( int, residual_ac[15], 16 );
@@ -302,7 +324,9 @@ struct x264_t
         int     i_b4_xy;
         
         /* Search parameters */
+        int     i_me_method;
         int     i_subpel_refine;
+        int     b_chroma_me;
         /* Allowed qpel MV range to stay within the picture + emulated edge pixels */
         int     mv_min[2];
         int     mv_max[2];
@@ -310,7 +334,14 @@ struct x264_t
         int     mv_min_fpel[2];
         int     mv_max_fpel[2];
 
+        /* neighboring MBs */
         unsigned int i_neighbour;
+        unsigned int i_neighbour8[4];       /* neighbours of each 8x8 or 4x4 block that are available */
+        unsigned int i_neighbour4[16];      /* at the time the block is coded */
+        int     i_mb_type_top; 
+        int     i_mb_type_left; 
+        int     i_mb_type_topleft; 
+        int     i_mb_type_topright; 
 
         /* mb table */
         int8_t  *type;                      /* mb type */
@@ -324,11 +355,13 @@ struct x264_t
         int8_t   *ref[2];                   /* mb ref. set to -1 if non used (intra or Lx only) */
         int16_t (*mvr[2][16])[2];           /* 16x16 mv for each possible ref */
         int8_t  *skipbp;                    /* block pattern for SKIP or DIRECT (sub)mbs. B-frames + cabac only */
+        int8_t  *mb_transform_size;         /* transform_size_8x8_flag of each mb */
 
         /* current value */
         int     i_type;
         int     i_partition;
         int     i_sub_partition[4];
+        int     b_transform_8x8;
 
         int     i_cbp_luma;
         int     i_cbp_chroma;
@@ -354,7 +387,7 @@ struct x264_t
         /* cache */
         struct
         {
-            /* real intra4x4_pred_mode if I_4X4, I_PRED_4x4_DC if mb available, -1 if not */
+            /* real intra4x4_pred_mode if I_4X4 or I_8X8, I_PRED_4x4_DC if mb available, -1 if not */
             int     intra4x4_pred_mode[X264_SCAN8_SIZE];
 
             /* i_non_zero_count if availble else 0x80 */
@@ -372,12 +405,18 @@ struct x264_t
 
             int16_t direct_mv[2][X264_SCAN8_SIZE][2];
             int8_t  direct_ref[2][X264_SCAN8_SIZE];
+
+            /* number of neighbors (top and left) that used 8x8 dct */
+            int     i_neighbour_transform_size;
+            int     b_transform_8x8_allowed;
         } cache;
 
         /* */
+        int     i_qp;       /* current qp */
         int     i_last_qp;  /* last qp */
         int     i_last_dqp; /* last delta qp */
         int     b_variable_qp; /* whether qp is allowed to vary per macroblock */
+        int     b_lossless;
 
         /* B_direct and weighted prediction */
         int     dist_scale_factor[16][16];
@@ -408,9 +447,11 @@ struct x264_t
             /* ? */
             int i_misc_bits;
             /* MB type counts */
-            int i_mb_count[18];
+            int i_mb_count[19];
+            int i_mb_count_i;
             int i_mb_count_p;
             int i_mb_count_skip;
+            int i_mb_count_8x8dct[2];
             /* Estimated (SATD) cost as Intra/Predicted frame */
             /* XXX: both omit the cost of MBs coded as P_SKIP */
             int i_intra_cost;
@@ -430,13 +471,15 @@ struct x264_t
         float   f_psnr_mean_u[5];
         float   f_psnr_mean_v[5];
         /* */
-        int64_t i_mb_count[5][18];
+        int64_t i_mb_count[5][19];
+        int64_t i_mb_count_8x8dct[2];
 
     } stat;
 
     /* CPU functions dependants */
     x264_predict_t      predict_16x16[4+3];
-    x264_predict_t      predict_8x8[4+3];
+    x264_predict_t      predict_8x8c[4+3];
+    x264_predict8x8_t   predict_8x8[9+3];
     x264_predict_t      predict_4x4[9+3];
 
     x264_pixel_function_t pixf;
@@ -450,6 +493,10 @@ struct x264_t
     x264_vlc_table_t *x264_total_zeros_lookup[15];
     x264_vlc_table_t *x264_total_zeros_dc_lookup[3];
     x264_vlc_table_t *x264_run_before_lookup[7];
+
+#if VISUALIZE
+    struct visualize_t *visualize;
+#endif
 };
 
 #endif