Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
mpeg2_internal.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #define MACROBLOCK_INTRA 1
00026 #define MACROBLOCK_PATTERN 2
00027 #define MACROBLOCK_MOTION_BACKWARD 4
00028 #define MACROBLOCK_MOTION_FORWARD 8
00029 #define MACROBLOCK_QUANT 16
00030 #define DCT_TYPE_INTERLACED 32
00031 
00032 #define MOTION_TYPE_MASK (3*64)
00033 #define MOTION_TYPE_BASE 64
00034 #define MC_FIELD (1*64)
00035 #define MC_FRAME (2*64)
00036 #define MC_16X8 (2*64)
00037 #define MC_DMV (3*64)
00038 
00039 
00040 #define TOP_FIELD 1
00041 #define BOTTOM_FIELD 2
00042 #define FRAME_PICTURE 3
00043 
00044 
00045 #define I_TYPE 1
00046 #define P_TYPE 2
00047 #define B_TYPE 3
00048 #define D_TYPE 4
00049 
00050 typedef struct {
00051     uint8_t * ref[2][3];
00052     uint8_t ** ref2[2];
00053     int pmv[2][2];
00054     int f_code[2];
00055 } motion_t;
00056 
00057 struct decoder_s {
00058     
00059     
00060 
00061     
00062     int16_t DCTblock[64];
00063 
00064     
00065     uint32_t bitstream_buf;             
00066     int bitstream_bits;                 
00067     const uint8_t * bitstream_ptr;      
00068 
00069     uint8_t * dest[3];
00070     uint8_t * picture_dest[3];
00071     void (* convert) (void * fbuf_id, uint8_t * const * src,
00072                       unsigned int v_offset);
00073     void * fbuf_id;
00074 
00075     int offset;
00076     int stride;
00077     int uv_stride;
00078     unsigned int limit_x;
00079     unsigned int limit_y_16;
00080     unsigned int limit_y_8;
00081     unsigned int limit_y;
00082 
00083     
00084     
00085     
00086     motion_t b_motion;
00087     motion_t f_motion;
00088 
00089     
00090     int16_t dc_dct_pred[3];
00091 
00092     int quantizer_scale;        
00093     int dmv_offset;             
00094     unsigned int v_offset;      
00095 
00096     
00097 
00098     
00099     uint8_t intra_quantizer_matrix [64];
00100     uint8_t non_intra_quantizer_matrix [64];
00101 
00102     
00103     int width;
00104     int height;
00105     int vertical_position_extension;
00106 
00107     
00108 
00109     
00110     int coding_type;
00111 
00112     
00113 
00114     
00115     int intra_dc_precision;
00116     
00117     int picture_structure;
00118     
00119     int frame_pred_frame_dct;
00120     
00121     
00122     int concealment_motion_vectors;
00123     
00124     int q_scale_type;
00125     
00126     int intra_vlc_format;
00127     
00128     int top_field_first;
00129 
00130     
00131 
00132     
00133     const uint8_t * scan;
00134 
00135     int second_field;
00136 
00137     int mpeg1;
00138 };
00139 
00140 typedef struct {
00141     fbuf_t fbuf;
00142 } fbuf_alloc_t;
00143 
00144 struct mpeg2dec_s {
00145     decoder_t decoder;
00146 
00147     mpeg2_info_t info;
00148 
00149     uint32_t shift;
00150     int is_display_initialized;
00151     int (* action) (struct mpeg2dec_s * mpeg2dec);
00152     int state;
00153     uint32_t ext_state;
00154 
00155     
00156     uint8_t * chunk_buffer;
00157     
00158     uint8_t * chunk_start;
00159     
00160     uint8_t * chunk_ptr;
00161     
00162     uint8_t code;
00163 
00164     
00165     uint32_t pts_current, pts_previous;
00166     int num_pts;
00167     int bytes_since_pts;
00168 
00169     int first;
00170     int alloc_index_user;
00171     int alloc_index;
00172     uint8_t first_decode_slice;
00173     uint8_t nb_decode_slices;
00174 
00175     sequence_t new_sequence;
00176     sequence_t sequence;
00177     picture_t pictures[4];
00178     picture_t * picture;
00179      fbuf_t * fbuf[3]; 
00180 
00181     fbuf_alloc_t fbuf_alloc[3];
00182     int custom_fbuf;
00183 
00184     uint8_t * yuv_buf[3][3];
00185     int yuv_index;
00186     void * convert_id;
00187     int convert_size[3];
00188     void (* convert_start) (void * id, uint8_t * const * dest, int flags);
00189     void (* convert_copy) (void * id, uint8_t * const * src,
00190                            unsigned int v_offset);
00191 
00192     uint8_t * buf_start;
00193     uint8_t * buf_end;
00194 
00195     int16_t display_offset_x, display_offset_y;
00196 };
00197 
00198 typedef struct {
00199 #ifdef ARCH_PPC
00200     uint8_t regv[12*16];
00201 #endif
00202     int dummy;
00203 } cpu_state_t;
00204 
00205 
00206 #define ALLOC_MPEG2DEC 0
00207 #define ALLOC_CHUNK 1
00208 #define ALLOC_YUV 2
00209 #define ALLOC_CONVERT_ID 3
00210 #define ALLOC_CONVERTED 4
00211 void * mpeg2_malloc (int size, int reason);
00212 void mpeg2_free (void * buf);
00213 
00214 
00215 uint32_t mpeg2_detect_accel (void);
00216 
00217 
00218 void mpeg2_cpu_state_init (uint32_t accel);
00219 
00220 
00221 int mpeg2_seek_sequence (mpeg2dec_t * mpeg2dec);
00222 int mpeg2_seek_header (mpeg2dec_t * mpeg2dec);
00223 int mpeg2_parse_header (mpeg2dec_t * mpeg2dec);
00224 
00225 
00226 void mpeg2_header_state_init (mpeg2dec_t * mpeg2dec);
00227 int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec);
00228 int mpeg2_header_gop (mpeg2dec_t * mpeg2dec);
00229 int mpeg2_header_picture_start (mpeg2dec_t * mpeg2dec);
00230 int mpeg2_header_picture (mpeg2dec_t * mpeg2dec);
00231 int mpeg2_header_extension (mpeg2dec_t * mpeg2dec);
00232 int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec);
00233 void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec);
00234 int mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec);
00235 int mpeg2_header_end (mpeg2dec_t * mpeg2dec);
00236 void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int coding_type);
00237 
00238 
00239 void mpeg2_idct_init (uint32_t accel);
00240 
00241 
00242 void mpeg2_idct_add_mlib (int last, int16_t * block,
00243                           uint8_t * dest, int stride);
00244 void mpeg2_idct_copy_mlib_non_ieee (int16_t * block, uint8_t * dest,
00245                                     int stride);
00246 void mpeg2_idct_add_mlib_non_ieee (int last, int16_t * block,
00247                                    uint8_t * dest, int stride);
00248 
00249 
00250 void mpeg2_idct_copy_mmxext (int16_t * block, uint8_t * dest, int stride);
00251 void mpeg2_idct_add_mmxext (int last, int16_t * block,
00252                             uint8_t * dest, int stride);
00253 void mpeg2_idct_copy_mmx (int16_t * block, uint8_t * dest, int stride);
00254 void mpeg2_idct_add_mmx (int last, int16_t * block,
00255                          uint8_t * dest, int stride);
00256 void mpeg2_idct_mmx_init (void);
00257 
00258 
00259 void mpeg2_idct_copy_altivec (int16_t * block, uint8_t * dest, int stride);
00260 void mpeg2_idct_add_altivec (int last, int16_t * block,
00261                              uint8_t * dest, int stride);
00262 void mpeg2_idct_altivec_init (void);
00263 
00264 
00265 void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, int stride);
00266 void mpeg2_idct_add_mvi (int last, int16_t * block,
00267                          uint8_t * dest, int stride);
00268 void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, int stride);
00269 void mpeg2_idct_add_alpha (int last, int16_t * block,
00270                            uint8_t * dest, int stride);
00271 void mpeg2_idct_alpha_init(int no_mvi);
00272 
00273 
00274 void mpeg2_mc_init (uint32_t accel);
00275 
00276 typedef void mpeg2_mc_fct (uint8_t *, const uint8_t *, int, int);
00277 
00278 typedef struct {
00279     mpeg2_mc_fct * put [8];
00280     mpeg2_mc_fct * avg [8];
00281 } mpeg2_mc_t;
00282 
00283 #define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = {                    \
00284     {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
00285      MC_put_o_8_##x,  MC_put_x_8_##x,  MC_put_y_8_##x,  MC_put_xy_8_##x}, \
00286     {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
00287      MC_avg_o_8_##x,  MC_avg_x_8_##x,  MC_avg_y_8_##x,  MC_avg_xy_8_##x}  \
00288 };
00289 
00290 extern mpeg2_mc_t mpeg2_mc_c;
00291 extern mpeg2_mc_t mpeg2_mc_mmx;
00292 extern mpeg2_mc_t mpeg2_mc_mmxext;
00293 extern mpeg2_mc_t mpeg2_mc_3dnow;
00294 extern mpeg2_mc_t mpeg2_mc_altivec;
00295 extern mpeg2_mc_t mpeg2_mc_alpha;
00296 extern mpeg2_mc_t mpeg2_mc_mlib;