diff mpegvideo.h @ 1177:fea03d2c4946 libavcodec

simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture more direct use of the new mb_type stuff instead of codec specific stuff runtime mb_type debug output h264/h263 variants/mpeg1/2/4 error concealment /resilience for mpeg1/2 various minor optimizations
author michaelni
date Thu, 10 Apr 2003 13:18:38 +0000
parents 5af9aeadbdc3
children 358bbc952e27
line wrap: on
line diff
--- a/mpegvideo.h	Thu Apr 10 08:47:08 2003 +0000
+++ b/mpegvideo.h	Thu Apr 10 13:18:38 2003 +0000
@@ -137,31 +137,40 @@
     
     int16_t (*motion_val[2])[2];
     int8_t *ref_index[2];
-    uint16_t *mb_type_base;
-    uint16_t *mb_type;           ///< mb_type_base + mb_width + 2
+    uint32_t *mb_type_base;
+    uint32_t *mb_type;           ///< mb_type_base + mb_width + 2, note: only used for decoding currently
 #define MB_TYPE_INTRA4x4   0x0001
-#define MB_TYPE_INTRA16x16 0x0002
-#define MB_TYPE_INTRA_PCM  0x0004
+#define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
+#define MB_TYPE_INTRA_PCM  0x0004 //FIXME h264 specific
 #define MB_TYPE_16x16      0x0008
 #define MB_TYPE_16x8       0x0010
 #define MB_TYPE_8x16       0x0020
 #define MB_TYPE_8x8        0x0040
 #define MB_TYPE_INTERLACED 0x0080
 #define MB_TYPE_DIRECT2     0x0100 //FIXME
-#define MB_TYPE_REF0       0x0200
-#define MB_TYPE_GMC2        0x0400 //FIXME
+#define MB_TYPE_ACPRED     0x0200
+#define MB_TYPE_GMC        0x0400 //FIXME mpeg4 specific
+#define MB_TYPE_SKIP       0x0800
 #define MB_TYPE_P0L0       0x1000
 #define MB_TYPE_P1L0       0x2000
 #define MB_TYPE_P0L1       0x4000
 #define MB_TYPE_P1L1       0x8000
+#define MB_TYPE_L0         (MB_TYPE_P0L0 | MB_TYPE_P1L0)
+#define MB_TYPE_L1         (MB_TYPE_P0L1 | MB_TYPE_P1L1)
+#define MB_TYPE_L0L1       (MB_TYPE_L0   | MB_TYPE_L1)
+#define MB_TYPE_QUANT      0x00010000
+//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 pat, ...)
 
 #define IS_INTRA4x4(a)   ((a)&MB_TYPE_INTRA4x4)
 #define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
-#define IS_INTRA(a)      ((a)&3)
+#define IS_PCM(a)        ((a)&MB_TYPE_INTRA_PCM)
+#define IS_INTRA(a)      ((a)&7)
 #define IS_INTER(a)      ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
+#define IS_SKIP(a)       ((a)&MB_TYPE_SKIP)
 #define IS_INTRA_PCM(a)  ((a)&MB_TYPE_INTRA_PCM)
 #define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
 #define IS_DIRECT(a)     ((a)&MB_TYPE_DIRECT2)
+#define IS_GMC(a)        ((a)&MB_TYPE_GMC)
 #define IS_16X16(a)      ((a)&MB_TYPE_16x16)
 #define IS_16X8(a)       ((a)&MB_TYPE_16x8)
 #define IS_8X16(a)       ((a)&MB_TYPE_8x16)
@@ -170,7 +179,8 @@
 #define IS_SUB_8X4(a)    ((a)&MB_TYPE_16x8)  //note reused
 #define IS_SUB_4X8(a)    ((a)&MB_TYPE_8x16)  //note reused
 #define IS_SUB_4X4(a)    ((a)&MB_TYPE_8x8)   //note reused
-#define IS_REF0(a)       ((a)&MB_TYPE_REF0)
+#define IS_ACPRED(a)     ((a)&MB_TYPE_ACPRED)
+#define IS_QUANT(a)      ((a)&MB_TYPE_QUANT)
 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note doesnt work if subMBs
 
@@ -283,6 +293,7 @@
     int picture_in_gop_number; ///< 0-> first pic in gop, ... 
     int b_frames_since_non_b;  ///< used for encoding, relative to not yet reordered input 
     int mb_width, mb_height;   ///< number of MBs horizontally & vertically 
+    int mb_stride;             ///< mb_width+1 used for some arrays to allow simple addressng of left & top MBs withoutt sig11
     int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replicateion)
     int mb_num;                ///< number of MBs of a picture 
     int linesize;              ///< line size, in bytes, may be different from width 
@@ -355,7 +366,13 @@
     DSPContext dsp;             ///< pointers for accelerated dsp fucntions 
     int f_code;                 ///< forward MV resolution 
     int b_code;                 ///< backward MV resolution for B Frames (mpeg4) 
-    int16_t (*motion_val)[2];            ///< used for MV prediction (4MV per MB) 
+    int16_t (*motion_val)[2];
+    int16_t (*p_mv_table_base)[2];
+    int16_t (*b_forw_mv_table_base)[2];
+    int16_t (*b_back_mv_table_base)[2];
+    int16_t (*b_bidir_forw_mv_table_base)[2]; 
+    int16_t (*b_bidir_back_mv_table_base)[2]; 
+    int16_t (*b_direct_mv_table_base)[2];
     int16_t (*p_mv_table)[2];            ///< MV table (1MV per MB) p-frame encoding 
     int16_t (*b_forw_mv_table)[2];       ///< MV table (1MV per MB) forward mode b-frame encoding 
     int16_t (*b_back_mv_table)[2];       ///< MV table (1MV per MB) backward mode b-frame encoding 
@@ -396,12 +413,12 @@
     int mb_x, mb_y;
     int mb_skip_run;
     int mb_intra;
-    uint8_t *mb_type;       ///< Table for MB type 
+    uint8_t *mb_type;       ///< Table for MB type FIXME remove and use picture->mb_type
 #define MB_TYPE_INTRA    0x01
 #define MB_TYPE_INTER    0x02
 #define MB_TYPE_INTER4V  0x04
 #define MB_TYPE_SKIPED   0x08
-#define MB_TYPE_GMC      0x10
+//#define MB_TYPE_GMC      0x10
 
 #define MB_TYPE_DIRECT   0x10
 #define MB_TYPE_FORWARD  0x20
@@ -410,6 +427,8 @@
 
     int block_index[6]; ///< index to current MB in block based arrays with edges
     int block_wrap[6];
+    
+    int *mb_index2xy;        ///< mb_index -> mb_x + mb_y*mb_stride
 
     /** matrix transmitted in the bitstream */
     uint16_t intra_matrix[64];
@@ -467,6 +486,7 @@
     int last_bits; ///< temp var used for calculating the above vars
     
     /* error concealment / resync */
+    int error_count;
     uint8_t *error_status_table;       ///< table of the error status of each MB  
 #define VP_START            1          ///< current MB is the first after a resync marker 
 #define AC_ERROR            2
@@ -544,9 +564,6 @@
     uint8_t *tex_pb_buffer;          
     uint8_t *pb2_buffer;
     int mpeg_quant;
-#define CO_LOCATED_TYPE_4MV     1
-#define CO_LOCATED_TYPE_FIELDMV 2
-    int8_t *co_located_type_table;     ///< 4mv & field_mv info for next b frame 
     int16_t (*field_mv_table)[2][2];   ///< used for interlaced b frame decoding 
     int8_t (*field_select_table)[2];   ///< wtf, no really another table for interlaced b frames 
     int t_frame;                       ///< time distance of first I -> B, used for interlaced b frames 
@@ -693,6 +710,7 @@
                                     int src_x, int src_y, int w, int h);
 char ff_get_pict_type_char(int pict_type);
 int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
+void ff_print_debug_info(MpegEncContext *s, Picture *pict);
 
 void ff_er_frame_start(MpegEncContext *s);
 void ff_er_frame_end(MpegEncContext *s);
@@ -827,7 +845,7 @@
 int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
 int ff_h263_resync(MpegEncContext *s);
 int ff_h263_get_gob_height(MpegEncContext *s);
-void ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
+int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
 inline int ff_h263_round_chroma(int x);