1 /* Changed Sept 15th by John M McIntosh to support Macintosh & Squeak 2 */ 3 #ifndef MPEGVIDEO_H 4 #define MPEGVIDEO_H 5 6 #include "bitstream.h" 7 #include "mpeg3private.inc" 8 #include "timecode.h" 9 10 #include "idct.h" 11 #include "slice.h" 12 13 /* zig-zag scan */ 14 extern unsigned char mpeg3_zig_zag_scan_nommx[64]; 15 extern unsigned char mpeg3_zig_zag_scan_mmx[64]; 16 17 /* alternate scan */ 18 extern unsigned char mpeg3_alternate_scan_nommx[64]; 19 extern unsigned char mpeg3_alternate_scan_mmx[64]; 20 21 /* default intra quantization matrix */ 22 extern unsigned char mpeg3_default_intra_quantizer_matrix[64]; 23 24 /* Frame rate table must agree with the one in the encoder */ 25 extern double mpeg3_frame_rate_table[16]; 26 27 /* non-linear quantization coefficient table */ 28 extern unsigned char mpeg3_non_linear_mquant_table[32]; 29 30 #define CHROMA420 1 /* chroma_format */ 31 #define CHROMA422 2 32 #define CHROMA444 3 33 34 #define TOP_FIELD 1 /* picture structure */ 35 #define BOTTOM_FIELD 2 36 #define FRAME_PICTURE 3 37 38 #define SEQ_ID 1 /* extension start code IDs */ 39 #define DISP_ID 2 40 #define QUANT_ID 3 41 #define SEQSCAL_ID 5 42 #define PANSCAN_ID 7 43 #define CODING_ID 8 44 #define SPATSCAL_ID 9 45 #define TEMPSCAL_ID 10 46 47 #define MPERROR (-1) 48 49 #define SC_NONE 0 /* scalable_mode */ 50 #define SC_DP 1 51 #define SC_SPAT 2 52 #define SC_SNR 3 53 #define SC_TEMP 4 54 55 #define I_TYPE 1 /* picture coding type */ 56 #define P_TYPE 2 57 #define B_TYPE 3 58 #define D_TYPE 4 59 60 #define MB_INTRA 1 /* macroblock type */ 61 #define MB_PATTERN 2 62 #define MB_BACKWARD 4 63 #define MB_FORWARD 8 64 #define MB_QUANT 16 65 #define MB_WEIGHT 32 66 #define MB_CLASS4 64 67 68 #define MC_FIELD 1 /* motion_type */ 69 #define MC_FRAME 2 70 #define MC_16X8 2 71 #define MC_DMV 3 72 73 #define MV_FIELD 0 /* mv_format */ 74 #define MV_FRAME 1 75 76 #define CLIP(x) ((x) >= 0 ? ((x) < 255 ? (x) : 255) : 0) 77 78 /* Statically allocate as little as possible so a fake video struct */ 79 /* can be used for reading the GOP headers. */ 80 81 typedef struct 82 { 83 void* file; 84 void* track; 85 86 /* ================================= Seeking variables ========================= */ 87 mpeg3_bits_t *vstream; 88 int decoder_initted; 89 unsigned char **output_rows; /* Output frame buffer supplied by user */ 90 int in_x, in_y, in_w, in_h, out_w, out_h; /* Output dimensions */ 91 int *x_table, *y_table; /* Location of every output pixel in the input */ 92 int color_model; 93 int want_yvu; /* Want to return a YUV frame */ 94 char *y_output, *u_output, *v_output; /* Output pointers for a YUV frame */ 95 96 mpeg3_slice_t slice_decoders[MPEG3_MAX_CPUS]; /* One slice decoder for every CPU */ 97 int total_slice_decoders; /* Total slice decoders in use */ 98 mpeg3_slice_buffer_t slice_buffers[MPEG3_MAX_CPUS]; /* Buffers for holding the slice data */ 99 int total_slice_buffers; /* Total buffers in the array to be decompressed */ 100 int slice_buffers_initialized; /* Total buffers initialized in the array */ 101 #ifdef USE_PTHREADS 102 pthread_mutex_t slice_lock; /* Lock slice array while getting the next buffer */ 103 pthread_mutex_t test_lock; 104 #endif 105 int blockreadsize; 106 long maxframe; /* Max value of frame num to read */ 107 double percentage_seek; /* Perform a percentage seek before the next frame is read */ 108 int frame_seek; /* Perform a frame seek before the next frame is read */ 109 long framenum; /* Number of the next frame to be decoded */ 110 long last_number; /* Last framenum rendered */ 111 int found_seqhdr; 112 long bitrate; 113 mpeg3_timecode_t gop_timecode; /* Timecode for the last GOP header read. */ 114 115 /* These are only available from elementary streams. */ 116 long frames_per_gop; /* Frames per GOP after the first GOP. */ 117 long first_gop_frames; /* Frames in the first GOP. */ 118 long first_frame; /* Number of first frame stored in timecode */ 119 long last_frame; /* Last frame in file */ 120 121 /* ================================= Compression variables ===================== */ 122 /* Malloced frame buffers. 2 refframes are swapped in and out. */ 123 /* while only 1 auxframe is used. */ 124 unsigned char *yuv_buffer[5]; /* Make YVU buffers contiguous for all frames */ 125 unsigned char *oldrefframe[3], *refframe[3], *auxframe[3]; 126 unsigned char *llframe0[3], *llframe1[3]; 127 unsigned char *mpeg3_zigzag_scan_table; 128 unsigned char *mpeg3_alternate_scan_table; 129 // Source for the next frame presentation 130 unsigned char **output_src; 131 /* Pointers to frame buffers. */ 132 unsigned char *newframe[3]; 133 int horizontal_size, vertical_size, mb_width, mb_height; 134 int coded_picture_width, coded_picture_height; 135 int chroma_format, chrom_width, chrom_height, blk_cnt; 136 int pict_type; 137 int forw_r_size, back_r_size, full_forw, full_back; 138 int prog_seq, prog_frame; 139 int h_forw_r_size, v_forw_r_size, h_back_r_size, v_back_r_size; 140 int dc_prec, pict_struct, topfirst, frame_pred_dct, conceal_mv; 141 int intravlc; 142 int repeatfirst; 143 int repeat_count; /* Number of times to repeat the current frame * 100 since floating point is impossible in MMX */ 144 int current_repeat; /* Number of times the current frame has been repeated * 100 */ 145 int secondfield; 146 int skip_bframes; 147 int stwc_table_index, llw, llh, hm, hn, vm, vn; 148 int lltempref, llx0, lly0, llprog_frame, llfieldsel; 149 int matrix_coefficients; 150 int framerate_code; 151 float frame_rate; 152 long *cr_to_r, *cr_to_g, *cb_to_g, *cb_to_b; 153 long *cr_to_r_ptr, *cr_to_g_ptr, *cb_to_g_ptr, *cb_to_b_ptr; 154 int have_mmx; 155 int intra_quantizer_matrix[64], non_intra_quantizer_matrix[64]; 156 int chroma_intra_quantizer_matrix[64], chroma_non_intra_quantizer_matrix[64]; 157 int mpeg2; 158 int qscale_type, altscan; /* picture coding extension */ 159 int pict_scal; /* picture spatial scalable extension */ 160 int scalable_mode; /* sequence scalable extension */ 161 } mpeg3video_t; 162 163 #endif 164