OpenCores
URL https://opencores.org/ocsvn/mpeg2fpga/mpeg2fpga/trunk

Subversion Repositories mpeg2fpga

[/] [mpeg2fpga/] [trunk/] [tools/] [mpeg2dec/] [global.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
/* global.h, global variables                                               */
2
 
3
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
4
 
5
/*
6
 * Disclaimer of Warranty
7
 *
8
 * These software programs are available to the user without any license fee or
9
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
10
 * any and all warranties, whether express, implied, or statuary, including any
11
 * implied warranties or merchantability or of fitness for a particular
12
 * purpose.  In no event shall the copyright-holder be liable for any
13
 * incidental, punitive, or consequential damages of any kind whatsoever
14
 * arising from the use of these programs.
15
 *
16
 * This disclaimer of warranty extends to the user of these programs and user's
17
 * customers, employees, agents, transferees, successors, and assigns.
18
 *
19
 * The MPEG Software Simulation Group does not represent or warrant that the
20
 * programs furnished hereunder are free of infringement of any third-party
21
 * patents.
22
 *
23
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24
 * are subject to royalty fees to patent holders.  Many of these patents are
25
 * general enough such that they are unavoidable regardless of implementation
26
 * design.
27
 *
28
 */
29
 
30
#include "mpeg2dec.h"
31
 
32
/* choose between declaration (GLOBAL undefined)
33
 * and definition (GLOBAL defined)
34
 * GLOBAL is defined in exactly one file mpeg2dec.c)
35
 */
36
 
37
#ifndef GLOBAL
38
#define EXTERN extern
39
#else
40
#define EXTERN
41
#endif
42
 
43
/* prototypes of global functions */
44
/* readpic.c */
45
void Substitute_Frame_Buffer _ANSI_ARGS_ ((int bitstream_framenum,
46
  int sequence_framenum));
47
 
48
/* Get_Bits.c */
49
void Initialize_Buffer _ANSI_ARGS_((void));
50
void Fill_Buffer _ANSI_ARGS_((void));
51
unsigned int Show_Bits _ANSI_ARGS_((int n));
52
unsigned int Get_Bits1 _ANSI_ARGS_((void));
53
void Flush_Buffer _ANSI_ARGS_((int n));
54
unsigned int Get_Bits _ANSI_ARGS_((int n));
55
int Get_Byte _ANSI_ARGS_((void));
56
int Get_Word _ANSI_ARGS_((void));
57
 
58
/* systems.c */
59
void Next_Packet _ANSI_ARGS_((void));
60
int Get_Long _ANSI_ARGS_((void));
61
void Flush_Buffer32 _ANSI_ARGS_((void));
62
unsigned int Get_Bits32 _ANSI_ARGS_((void));
63
 
64
 
65
/* getblk.c */
66
void Decode_MPEG1_Intra_Block _ANSI_ARGS_((int comp, int dc_dct_pred[]));
67
void Decode_MPEG1_Non_Intra_Block _ANSI_ARGS_((int comp));
68
void Decode_MPEG2_Intra_Block _ANSI_ARGS_((int comp, int dc_dct_pred[]));
69
void Decode_MPEG2_Non_Intra_Block _ANSI_ARGS_((int comp));
70
 
71
/* gethdr.c */
72
int Get_Hdr _ANSI_ARGS_((void));
73
void next_start_code _ANSI_ARGS_((void));
74
int slice_header _ANSI_ARGS_((void));
75
void marker_bit _ANSI_ARGS_((char *text));
76
 
77
/* getpic.c */
78
void Decode_Picture _ANSI_ARGS_((int bitstream_framenum,
79
  int sequence_framenum));
80
void Output_Last_Frame_of_Sequence _ANSI_ARGS_((int framenum));
81
 
82
/* getvlc.c */
83
int Get_macroblock_type _ANSI_ARGS_((void));
84
int Get_motion_code _ANSI_ARGS_((void));
85
int Get_dmvector _ANSI_ARGS_((void));
86
int Get_coded_block_pattern _ANSI_ARGS_((void));
87
int Get_macroblock_address_increment _ANSI_ARGS_((void));
88
int Get_Luma_DC_dct_diff _ANSI_ARGS_((void));
89
int Get_Chroma_DC_dct_diff _ANSI_ARGS_((void));
90
 
91
/* idct.c */
92
void Fast_IDCT _ANSI_ARGS_((short *block));
93
void Initialize_Fast_IDCT _ANSI_ARGS_((void));
94
 
95
/* Reference_IDCT.c */
96
void Initialize_Reference_IDCT _ANSI_ARGS_((void));
97
#ifdef HAVE_MMX
98
void Reference_IDCT _ANSI_ARGS_((short *block, int i));
99
#else
100
void Reference_IDCT _ANSI_ARGS_((short *block));
101
#endif
102
 
103
/* motion.c */
104
void motion_vectors _ANSI_ARGS_((int PMV[2][2][2], int dmvector[2],
105
  int motion_vertical_field_select[2][2], int s, int motion_vector_count,
106
  int mv_format, int h_r_size, int v_r_size, int dmv, int mvscale));
107
void motion_vector _ANSI_ARGS_((int *PMV, int *dmvector,
108
  int h_r_size, int v_r_size, int dmv, int mvscale, int full_pel_vector));
109
void Dual_Prime_Arithmetic _ANSI_ARGS_((int DMV[][2], int *dmvector, int mvx, int mvy));
110
 
111
/* mpeg2dec.c */
112
void Error _ANSI_ARGS_((char *text));
113
void Warning _ANSI_ARGS_((char *text));
114
void Print_Bits _ANSI_ARGS_((int code, int bits, int len));
115
 
116
/* recon.c */
117
void form_predictions _ANSI_ARGS_((int bx, int by, int macroblock_type,
118
  int motion_type, int PMV[2][2][2], int motion_vertical_field_select[2][2],
119
  int dmvector[2], int stwtype));
120
 
121
/* spatscal.c */
122
void Spatial_Prediction _ANSI_ARGS_((void));
123
 
124
/* store.c */
125
void Write_Frame _ANSI_ARGS_((unsigned char *src[], int frame));
126
 
127
#ifdef DISPLAY
128
/* display.c */
129
void Initialize_Display_Process _ANSI_ARGS_((char *name));
130
void Terminate_Display_Process _ANSI_ARGS_((void));
131
void Display_Second_Field _ANSI_ARGS_((void));
132
void dither _ANSI_ARGS_((unsigned char *src[]));
133
void Initialize_Dither_Matrix _ANSI_ARGS_((void));
134
#endif
135
 
136
/* global variables */
137
 
138
EXTERN char Version[]
139
#ifdef GLOBAL
140
  ="mpeg2decode V1.2a, 96/07/19"
141
#endif
142
;
143
 
144
EXTERN char Author[]
145
#ifdef GLOBAL
146
  ="(C) 1996, MPEG Software Simulation Group"
147
#endif
148
;
149
 
150
 
151
/* zig-zag and alternate scan patterns */
152
EXTERN unsigned char scan[2][64]
153
#ifdef GLOBAL
154
=
155
{
156
#ifdef HAVE_MMX
157
  { /* MMX Zig-Zag scan pattern (transposed)  */
158
         0, 8, 1, 2, 9,16,24,17,10, 3, 4,11,18,25,32,40,
159
        33,26,19,12, 5, 6,13,20,27,34,41,48,56,49,42,35,
160
        28,21,14, 7,15,22,29,36,43,50,57,58,51,44,37,30,
161
        23,31,38,45,52,59,60,53,46,39,47,54,61,62,55,63
162
  },
163
  { /* Alternate scan pattern (transposed)*/
164
 
165
         0, 1, 2, 3, 8, 9,16,17,10,11, 4, 5, 6, 7,15,14,
166
        13,12,19,18,24,25,32,33,26,27,20,21,22,23,28,29,
167
        30,31,34,35,40,41,48,49,42,43,36,37,38,39,44,45,
168
        46,47,50,51,56,57,58,59,52,53,54,55,60,61,62,63,
169
  }
170
#else
171
  { /* Zig-Zag scan pattern  */
172
    0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,
173
    12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,
174
    35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,
175
    58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63
176
  },
177
  { /* Alternate scan pattern */
178
    0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
179
    41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
180
    51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
181
    53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63
182
  }
183
#endif
184
}
185
#endif
186
;
187
 
188
/* default intra quantization matrix */
189
EXTERN unsigned char default_intra_quantizer_matrix[64]
190
#ifdef GLOBAL
191
=
192
{
193
  8, 16, 19, 22, 26, 27, 29, 34,
194
  16, 16, 22, 24, 27, 29, 34, 37,
195
  19, 22, 26, 27, 29, 34, 34, 38,
196
  22, 22, 26, 27, 29, 34, 37, 40,
197
  22, 26, 27, 29, 32, 35, 40, 48,
198
  26, 27, 29, 32, 35, 40, 48, 58,
199
  26, 27, 29, 34, 38, 46, 56, 69,
200
  27, 29, 35, 38, 46, 56, 69, 83
201
}
202
#endif
203
;
204
 
205
/* non-linear quantization coefficient table */
206
EXTERN unsigned char Non_Linear_quantizer_scale[32]
207
#ifdef GLOBAL
208
=
209
{
210
   0, 1, 2, 3, 4, 5, 6, 7,
211
   8,10,12,14,16,18,20,22,
212
  24,28,32,36,40,44,48,52,
213
  56,64,72,80,88,96,104,112
214
}
215
#endif
216
;
217
 
218
/* color space conversion coefficients
219
 * for YCbCr -> RGB mapping
220
 *
221
 * entries are {crv,cbu,cgu,cgv}
222
 *
223
 * crv=(255/224)*65536*(1-cr)/0.5
224
 * cbu=(255/224)*65536*(1-cb)/0.5
225
 * cgu=(255/224)*65536*(cb/cg)*(1-cb)/0.5
226
 * cgv=(255/224)*65536*(cr/cg)*(1-cr)/0.5
227
 *
228
 * where Y=cr*R+cg*G+cb*B (cr+cg+cb=1)
229
 */
230
 
231
/* ISO/IEC 13818-2 section 6.3.6 sequence_display_extension() */
232
 
233
EXTERN int Inverse_Table_6_9[8][4]
234
#ifdef GLOBAL
235
=
236
{
237
  {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
238
  {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
239
  {104597, 132201, 25675, 53279}, /* unspecified */
240
  {104597, 132201, 25675, 53279}, /* reserved */
241
  {104448, 132798, 24759, 53109}, /* FCC */
242
  {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
243
  {104597, 132201, 25675, 53279}, /* SMPTE 170M */
244
  {117579, 136230, 16907, 35559}  /* SMPTE 240M (1987) */
245
}
246
#endif
247
;
248
 
249
 
250
 
251
 
252
 
253
/* output types (Output_Type) */
254
#define T_YUV   0
255
#define T_SIF   1
256
#define T_TGA   2
257
#define T_PPM   3
258
#define T_X11   4
259
#define T_X11HIQ 5
260
 
261
/* decoder operation control variables */
262
EXTERN int Output_Type;
263
EXTERN int hiQdither;
264
 
265
/* decoder operation control flags */
266
EXTERN int Quiet_Flag;
267
EXTERN int Trace_Flag;
268
EXTERN int Fault_Flag;
269
EXTERN int Verbose_Flag;
270
EXTERN int Two_Streams;
271
EXTERN int Spatial_Flag;
272
EXTERN int Reference_IDCT_Flag;
273
EXTERN int Frame_Store_Flag;
274
EXTERN int System_Stream_Flag;
275
EXTERN int Display_Progressive_Flag;
276
EXTERN int Ersatz_Flag;
277
EXTERN int Big_Picture_Flag;
278
EXTERN int Verify_Flag;
279
EXTERN int Stats_Flag;
280
EXTERN int User_Data_Flag;
281
EXTERN int Main_Bitstream_Flag;
282
 
283
 
284
/* filenames */
285
EXTERN char *Output_Picture_Filename;
286
EXTERN char *Substitute_Picture_Filename;
287
EXTERN char *Main_Bitstream_Filename;
288
EXTERN char *Enhancement_Layer_Bitstream_Filename;
289
 
290
 
291
/* buffers for multiuse purposes */
292
EXTERN char Error_Text[256];
293
EXTERN unsigned char *Clip;
294
 
295
/* pointers to generic picture buffers */
296
EXTERN unsigned char *backward_reference_frame[3];
297
EXTERN unsigned char *forward_reference_frame[3];
298
 
299
EXTERN unsigned char *auxframe[3];
300
EXTERN unsigned char *current_frame[3];
301
EXTERN unsigned char *substitute_frame[3];
302
 
303
 
304
/* pointers to scalability picture buffers */
305
EXTERN unsigned char *llframe0[3];
306
EXTERN unsigned char *llframe1[3];
307
 
308
EXTERN short *lltmp;
309
EXTERN char *Lower_Layer_Picture_Filename;
310
 
311
 
312
 
313
 
314
/* non-normative variables derived from normative elements */
315
EXTERN int Coded_Picture_Width;
316
EXTERN int Coded_Picture_Height;
317
EXTERN int Chroma_Width;
318
EXTERN int Chroma_Height;
319
EXTERN int block_count;
320
EXTERN int Second_Field;
321
EXTERN int profile, level;
322
 
323
/* normative derived variables (as per ISO/IEC 13818-2) */
324
EXTERN int horizontal_size;
325
EXTERN int vertical_size;
326
EXTERN int mb_width;
327
EXTERN int mb_height;
328
EXTERN double bit_rate;
329
EXTERN double frame_rate;
330
 
331
 
332
 
333
/* headers */
334
 
335
/* ISO/IEC 13818-2 section 6.2.2.1:  sequence_header() */
336
EXTERN int aspect_ratio_information;
337
EXTERN int frame_rate_code;
338
EXTERN int bit_rate_value;
339
EXTERN int vbv_buffer_size;
340
EXTERN int constrained_parameters_flag;
341
 
342
/* ISO/IEC 13818-2 section 6.2.2.3:  sequence_extension() */
343
EXTERN int profile_and_level_indication;
344
EXTERN int progressive_sequence;
345
EXTERN int chroma_format;
346
EXTERN int low_delay;
347
EXTERN int frame_rate_extension_n;
348
EXTERN int frame_rate_extension_d;
349
 
350
/* ISO/IEC 13818-2 section 6.2.2.4:  sequence_display_extension() */
351
EXTERN int video_format;
352
EXTERN int color_description;
353
EXTERN int color_primaries;
354
EXTERN int transfer_characteristics;
355
EXTERN int matrix_coefficients;
356
EXTERN int display_horizontal_size;
357
EXTERN int display_vertical_size;
358
 
359
/* ISO/IEC 13818-2 section 6.2.3: picture_header() */
360
EXTERN int temporal_reference;
361
EXTERN int picture_coding_type;
362
EXTERN int vbv_delay;
363
EXTERN int full_pel_forward_vector;
364
EXTERN int forward_f_code;
365
EXTERN int full_pel_backward_vector;
366
EXTERN int backward_f_code;
367
 
368
 
369
/* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */
370
EXTERN int f_code[2][2];
371
EXTERN int intra_dc_precision;
372
EXTERN int picture_structure;
373
EXTERN int top_field_first;
374
EXTERN int frame_pred_frame_dct;
375
EXTERN int concealment_motion_vectors;
376
 
377
EXTERN int intra_vlc_format;
378
 
379
EXTERN int repeat_first_field;
380
 
381
EXTERN int chroma_420_type;
382
EXTERN int progressive_frame;
383
EXTERN int composite_display_flag;
384
EXTERN int v_axis;
385
EXTERN int field_sequence;
386
EXTERN int sub_carrier;
387
EXTERN int burst_amplitude;
388
EXTERN int sub_carrier_phase;
389
 
390
 
391
 
392
/* ISO/IEC 13818-2 section 6.2.3.3: picture_display_extension() header */
393
EXTERN int frame_center_horizontal_offset[3];
394
EXTERN int frame_center_vertical_offset[3];
395
 
396
 
397
 
398
/* ISO/IEC 13818-2 section 6.2.2.5: sequence_scalable_extension() header */
399
EXTERN int layer_id;
400
EXTERN int lower_layer_prediction_horizontal_size;
401
EXTERN int lower_layer_prediction_vertical_size;
402
EXTERN int horizontal_subsampling_factor_m;
403
EXTERN int horizontal_subsampling_factor_n;
404
EXTERN int vertical_subsampling_factor_m;
405
EXTERN int vertical_subsampling_factor_n;
406
 
407
 
408
/* ISO/IEC 13818-2 section 6.2.3.5: picture_spatial_scalable_extension() header */
409
EXTERN int lower_layer_temporal_reference;
410
EXTERN int lower_layer_horizontal_offset;
411
EXTERN int lower_layer_vertical_offset;
412
EXTERN int spatial_temporal_weight_code_table_index;
413
EXTERN int lower_layer_progressive_frame;
414
EXTERN int lower_layer_deinterlaced_field_select;
415
 
416
 
417
 
418
 
419
 
420
 
421
/* ISO/IEC 13818-2 section 6.2.3.6: copyright_extension() header */
422
EXTERN int copyright_flag;
423
EXTERN int copyright_identifier;
424
EXTERN int original_or_copy;
425
EXTERN int copyright_number_1;
426
EXTERN int copyright_number_2;
427
EXTERN int copyright_number_3;
428
 
429
/* ISO/IEC 13818-2 section 6.2.2.6: group_of_pictures_header()  */
430
EXTERN int drop_flag;
431
EXTERN int hour;
432
EXTERN int minute;
433
EXTERN int sec;
434
EXTERN int frame;
435
EXTERN int closed_gop;
436
EXTERN int broken_link;
437
 
438
 
439
 
440
/* layer specific variables (needed for SNR and DP scalability) */
441
EXTERN struct layer_data {
442
  /* bit input */
443
  int Infile;
444
  unsigned char Rdbfr[2048];
445
  unsigned char *Rdptr;
446
  unsigned char Inbfr[16];
447
  /* from mpeg2play */
448
  unsigned int Bfr;
449
  unsigned char *Rdmax;
450
  int Incnt;
451
  int Bitcnt;
452
  /* sequence header and quant_matrix_extension() */
453
  int intra_quantizer_matrix[64];
454
  int non_intra_quantizer_matrix[64];
455
  int chroma_intra_quantizer_matrix[64];
456
  int chroma_non_intra_quantizer_matrix[64];
457
 
458
  int load_intra_quantizer_matrix;
459
  int load_non_intra_quantizer_matrix;
460
  int load_chroma_intra_quantizer_matrix;
461
  int load_chroma_non_intra_quantizer_matrix;
462
 
463
  int MPEG2_Flag;
464
  /* sequence scalable extension */
465
  int scalable_mode;
466
  /* picture coding extension */
467
  int q_scale_type;
468
  int alternate_scan;
469
  /* picture spatial scalable extension */
470
  int pict_scal;
471
  /* slice/macroblock */
472
  int priority_breakpoint;
473
  int quantizer_scale;
474
  int intra_slice;
475
  short *block[12];
476
} base, enhan, *ld;
477
 
478
 
479
 
480
#ifdef VERIFY
481
EXTERN int verify_sequence_header;
482
EXTERN int verify_group_of_pictures_header;
483
EXTERN int verify_picture_header;
484
EXTERN int verify_slice_header;
485
EXTERN int verify_sequence_extension;
486
EXTERN int verify_sequence_display_extension;
487
EXTERN int verify_quant_matrix_extension;
488
EXTERN int verify_sequence_scalable_extension;
489
EXTERN int verify_picture_display_extension;
490
EXTERN int verify_picture_coding_extension;
491
EXTERN int verify_picture_spatial_scalable_extension;
492
EXTERN int verify_picture_temporal_scalable_extension;
493
EXTERN int verify_copyright_extension;
494
#endif /* VERIFY */
495
 
496
 
497
EXTERN int Decode_Layer;
498
 
499
/* verify.c */
500
#ifdef VERIFY
501
void Check_Headers _ANSI_ARGS_((int Bitstream_Framenum, int Sequence_Framenum));
502
void Clear_Verify_Headers _ANSI_ARGS_((void));
503
#endif /* VERIFY */
504
 
505
 
506
EXTERN int global_MBA;
507
EXTERN int global_pic;
508
EXTERN int True_Framenum;
509
 
510
#define TRACE 1
511
// Run-length decoding
512
//#define TRACE_RLD 1
513
// DCT decoding
514
//#define TRACE_DCT 1
515
// Inverse Discrete Cosine Transform
516
//#define TRACE_IDCT 1
517
// Trace calculation of individual pixels (very detailed)
518
//#define TRACE_RECON 1
519
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.