~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/codec/tmndec/global.h

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 /************************************************************************
  2  *
  3  *  global.h, global variables for tmndecode (H.263 decoder)
  4  *  Copyright (C) 1995, 1996  Telenor R&D, Norway
  5  *
  6  *  Contacts:
  7  *  Robert Danielsen                  <Robert.Danielsen@nta.no>
  8  *
  9  *  Telenor Research and Development  http://www.nta.no/brukere/DVC/
 10  *  P.O.Box 83                        tel.:   +47 63 84 84 00
 11  *  N-2007 Kjeller, Norway            fax.:   +47 63 81 00 76
 12  *
 13  *  Copyright (C) 1997  University of BC, Canada
 14  *  Modified by: Michael Gallant <mikeg@ee.ubc.ca>
 15  *               Guy Cote <guyc@ee.ubc.ca>
 16  *               Berna Erol <bernae@ee.ubc.ca>
 17  *
 18  *  Contacts:
 19  *  Michael Gallant                   <mikeg@ee.ubc.ca>
 20  *
 21  *  UBC Image Processing Laboratory   http://www.ee.ubc.ca/image
 22  *  2356 Main Mall                    tel.: +1 604 822 4051
 23  *  Vancouver BC Canada V6T1Z4        fax.: +1 604 822 5949
 24  *
 25  ************************************************************************/
 26 
 27 /* Disclaimer of Warranty
 28  * 
 29  * These software programs are available to the user without any license fee
 30  * or royalty on an "as is" basis. The University of British Columbia
 31  * disclaims any and all warranties, whether express, implied, or
 32  * statuary, including any implied warranties or merchantability or of
 33  * fitness for a particular purpose.  In no event shall the
 34  * copyright-holder be liable for any incidental, punitive, or
 35  * consequential damages of any kind whatsoever arising from the use of
 36  * these programs.
 37  * 
 38  * This disclaimer of warranty extends to the user of these programs and
 39  * user's customers, employees, agents, transferees, successors, and
 40  * assigns.
 41  * 
 42  * The University of British Columbia does not represent or warrant that the
 43  * programs furnished hereunder are free of infringement of any
 44  * third-party patents.
 45  * 
 46  * Commercial implementations of H.263, including shareware, are subject to
 47  * royalty fees to patent holders.  Many of these patents are general
 48  * enough such that they are unavoidable regardless of implementation
 49  * design.
 50  * 
 51  */
 52 
 53 
 54 
 55 /* based on mpeg2decode, (C) 1994, MPEG Software Simulation Group and
 56  * mpeg2play, (C) 1994 Stefan Eckart <stefan@lis.e-technik.tu-muenchen.de>
 57  * 
 58  */
 59 
 60 
 61 /* choose between declaration (GLOBAL undefined) and definition (GLOBAL
 62  * defined) GLOBAL is defined in exactly one file (tmndec.c) */
 63 
 64 #include <stdio.h>
 65 
 66 #ifndef GLOBAL
 67 #define EXTERN extern
 68 #else
 69 #define EXTERN
 70 #endif
 71 
 72 /* Some macros */
 73 #define mmax(a, b)        ((a) > (b) ? (a) : (b))
 74 #define mmin(a, b)        ((a) < (b) ? (a) : (b))
 75 #define mnint(a)        ((a) < 0 ? (int)(a - 0.5) : (int)(a + 0.5))
 76 #define sign(a)         ((a) < 0 ? -1 : 1)
 77 
 78 /* prototypes of global functions */
 79 
 80 /* getbits.c */
 81 void initbits _ANSI_ARGS_ ((void));
 82 void fillbfr _ANSI_ARGS_ ((void));
 83 unsigned int showbits _ANSI_ARGS_ ((int n));
 84 unsigned int getbits1 _ANSI_ARGS_ ((void));
 85 void flushbits _ANSI_ARGS_ ((int n));
 86 unsigned int getbits _ANSI_ARGS_ ((int n));
 87 
 88 /* getblk.c */
 89 void getblock _ANSI_ARGS_ ((int comp, int mode, int INTRA_AC_DC, int Mode));
 90 void get_sac_block _ANSI_ARGS_ ((int comp, int mode, int INTRA_AC_DC, int Mode));
 91 
 92 /* gethdr.c */
 93 int getheader _ANSI_ARGS_ ((void));
 94 void startcode _ANSI_ARGS_ ((void));
 95 void initoptions _ANSI_ARGS_ ((void));
 96 
 97 /* getpic.c */
 98 void getpicture _ANSI_ARGS_ ((int *framenum));
 99 void putlast _ANSI_ARGS_ ((int framenum));
100 void PictureDisplay _ANSI_ARGS_((int *framenum));
101 
102 /* scalability funcitons */
103 void UpsampleReferenceLayerPicture _ANSI_ARGS_((void));
104 void UpsampleComponent _ANSI_ARGS_((unsigned char *enhanced, unsigned char *base,
105                         int horiz, int vert));
106 /* advanced intra coding functions */
107 void Intra_AC_DC_Decode _ANSI_ARGS_ ((short *store_qcoeff, int INTRA_AC_DC, int MBA, int xpos, int ypos, int comp, int newgob));
108 void fill_null _ANSI_ARGS_ ((int pred[]));
109 void fill_A _ANSI_ARGS_ ((int pred[], short *store_qcoeff, int xpos, int ypos, int block));
110 void fill_B _ANSI_ARGS_ ((int pred[], short *store_qcoeff, int xpos, int ypos, int block));
111 int oddifyclipDC _ANSI_ARGS_ ((int x));
112 int clipAC _ANSI_ARGS_ ((int x));
113 int clipDC _ANSI_ARGS_ ((int x));
114 void interpolate_image _ANSI_ARGS_ ((unsigned char *in, unsigned char
115                                      *out, int width, int height));
116 
117 /* getvlc.c */
118 int getTMNMV _ANSI_ARGS_ ((void));
119 int getRVLC  _ANSI_ARGS_ ((void));
120 int getMCBPC _ANSI_ARGS_ ((void));
121 int getMODB _ANSI_ARGS_ ((void));
122 int getMCBPCintra _ANSI_ARGS_ ((void));
123 int getCBPY _ANSI_ARGS_ ((void));
124 int getMBTYPE _ANSI_ARGS_ ((int *true_B_cbp, int *true_B_quant));
125 int getscalabilityCBPC ();
126 
127 /* idct.c */
128 void idct _ANSI_ARGS_ ((short *block));
129 void init_idct _ANSI_ARGS_ ((void));
130 
131 /* idctref.c */
132 void init_idctref _ANSI_ARGS_ ((void));
133 void idctref _ANSI_ARGS_ ((short *block));
134 
135 /* tmndec.c */
136 void error _ANSI_ARGS_ ((char *text));
137 void printbits _ANSI_ARGS_ ((int code, int bits, int len));
138 #ifdef USE_TIME
139 void doframerate (int pb);
140 #endif
141 
142 /* recon.c */
143 void reconstruct _ANSI_ARGS_ ((int bx, int by, int P, int bdx, int bdy, int MODB));
144 void reconstruct_true_B _ANSI_ARGS_ ((int bx, int by, int true_B_prediction_type));
145 void reconstruct_ei_ep _ANSI_ARGS_ ((int bx, int by, int ei_ep_prediction_type));
146 
147 /* store.c */
148 void storeframe _ANSI_ARGS_ ((unsigned char *src[], int frame));
149 void store_enhancement_frame _ANSI_ARGS_ ((unsigned char *src[], int frame));
150 void save_frame _ANSI_ARGS_ ((unsigned char *src[], int framenum, FILE * file));
151 void store_one _ANSI_ARGS_ ((char *outname, unsigned char *src[], int offset, int incr, 
152                              int height));
153 
154 /* sac.c */
155 int decode_a_symbol _ANSI_ARGS_ ((int cumul_freq[]));
156 void decoder_reset ();
157 
158 #ifdef DISPLAY
159 /* display.c */
160 void init_display _ANSI_ARGS_ ((char *name));
161 void exit_display _ANSI_ARGS_ ((void));
162 void dither _ANSI_ARGS_ ((unsigned char *src[]));
163 void init_dither _ANSI_ARGS_ ((void));
164 
165 /* dither.c */
166 void ord4x4_dither_init _ANSI_ARGS_ ((void));
167 void ord4x4_dither_frame _ANSI_ARGS_ ((unsigned char *[], unsigned char *));
168 
169 /* yuv2rgb.c */
170 void Color16DitherImage _ANSI_ARGS_ ((unsigned char *[], unsigned char *));
171 void Color32DitherImage _ANSI_ARGS_ ((unsigned char *[], unsigned char *));
172 void InitColorDither _ANSI_ARGS_ ((int));
173 void init_dither_tab _ANSI_ARGS_ ((void));
174 
175 /* yuvrgb24.c */
176 void ConvertYUVtoRGB (
177                        unsigned char *src0,
178                        unsigned char *src1,
179                        unsigned char *src2,
180                        unsigned char *dst_ori,
181                        int width,
182                        int height
183 );
184 #endif
185 
186 
187 
188 /* global variables */
189 
190 #ifndef VIC
191 EXTERN char version[]
192 #ifdef GLOBAL
193 = "tmndecode v3.0\n(C) 1997, University of British Columbia, Canada\n(C) 1995, 1996 Telenor R&D, Norway\n"
194 #endif
195 ;
196 #endif
197 
198 /* zig-zag scan */
199 EXTERN unsigned char zig_zag_scan[64]
200 #ifdef GLOBAL
201 =
202 {
203   0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
204   12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
205   35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
206   58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
207 }
208 #endif
209 ;
210 
211 EXTERN int lines[]
212 #ifdef GLOBAL
213 = {-1,128,176,352,704,1408,-1}
214 #endif
215 ;
216 
217 EXTERN int pels[7]
218 #ifdef GLOBAL
219 = {-1,96,144,288,576,1152,-1}
220 #endif
221 ;
222 
223 /* other scan orders needed in advanced intra coding mode */
224 EXTERN unsigned char alternate_horizontal_scan[64]
225 #ifdef GLOBAL
226 =
227 {
228   0, 1, 2, 3, 8, 9, 16, 17, 10, 11, 4, 5, 6, 7, 15, 14,
229   13, 12, 19, 18, 24, 25, 32, 33, 26, 27, 20, 21, 22, 23, 28, 29,
230   30, 31, 34, 35, 40, 41, 48, 49, 42, 43, 36, 37, 38, 39, 44, 45,
231   46, 47, 50, 51, 56, 57, 58, 59, 52, 53, 54, 55, 60, 61, 62, 63
232 }
233 #endif
234 ;
235 EXTERN unsigned char alternate_vertical_scan[64]
236 #ifdef GLOBAL
237 =
238 {
239   0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
240   41, 33, 26, 18, 3, 11, 4, 12, 19, 27, 34, 42, 50, 58, 35, 43,
241   51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
242   53, 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
243 }
244 #endif
245 ;
246 
247 /* color space conversion coefficients
248  * 
249  * entries are {crv,cbu,cgu,cgv}
250  * 
251  * crv=(255/224)*65536*(1-cr)/0.5 cbu=(255/224)*65536*(1-cb)/0.5
252  * cgu=(255/224)*65536*(cb/cg)*(1-cb)/0.5
253  * cgv=(255/224)*65536*(cr/cg)*(1-cr)/0.5
254  * 
255  * where Y=cr*R+cg*G+cb*B (cr+cg+cb=1) */
256 
257 EXTERN int convmat[8][4]
258 #ifdef GLOBAL
259 =
260 {
261   {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
262   {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
263   {104597, 132201, 25675, 53279}, /* unspecified */
264   {104597, 132201, 25675, 53279}, /* reserved */
265   {104448, 132798, 24759, 53109}, /* FCC */
266   {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
267   {104597, 132201, 25675, 53279}, /* SMPTE 170M */
268   {117579, 136230, 16907, 35559}/* SMPTE 240M (1987) */
269 }
270 #endif
271 ;
272 
273 EXTERN int quiet;
274 EXTERN int trace;
275 EXTERN int save_frames;
276 EXTERN char errortext[256];
277 EXTERN unsigned char *prev_frame[3], *current_frame[3], *bframe[3];
278 EXTERN unsigned char *tmp_f[3], *tmp_b[3];
279 EXTERN unsigned char *edgeframe[3], *edgeframeorig[3], *exnewframe[3];
280 EXTERN unsigned char *nextedgeframe[3], *nextedgeframeorig[3];
281 EXTERN unsigned char *enhancementedgeframe[3], *enhacnementedgeframeorig[3];
282 EXTERN unsigned char *next_I_P_frame[3], *prev_I_P_frame[3], *buffered_frame[3];
283 EXTERN int MV[2][6][MBR + 1][MBC + 2];
284 EXTERN int true_B_direct_mode_MV[2][MBR + 1][MBC + 2];
285 EXTERN int modemap[MBR + 1][MBC + 2];
286 EXTERN int predictionmap[MBR + 1][MBC + 2];
287 EXTERN unsigned char *clp;
288 EXTERN int horizontal_size, vertical_size, mb_width, mb_height;
289 EXTERN int coded_picture_width, coded_picture_height;
290 EXTERN int ref_coded_picture_width, ref_coded_picture_height;
291 EXTERN int chrom_width, chrom_height, blk_cnt;
292 EXTERN int ref_chrom_width, ref_chrom_height;
293 EXTERN int pict_type, newgob;
294 EXTERN int mv_outside_frame;
295 EXTERN int syntax_arith_coding;
296 EXTERN int adv_pred_mode;
297 EXTERN int overlapping_MC;
298 EXTERN int use_4mv;
299 EXTERN int pb_frame;
300 EXTERN int true_B_frame;
301 EXTERN int scalability_mode;
302 EXTERN int buffered_framenum;
303 EXTERN int long_vectors;
304 EXTERN int fault, expand;
305 EXTERN int verbose;
306 EXTERN int refidct;
307 EXTERN int matrix_coefficients;
308 EXTERN int temp_ref, prev_non_disposable_temp_ref, next_non_disposable_temp_ref;
309 EXTERN int pic_quant, quant, source_format, source_format_old, base_source_format;
310 
311 /* Following variables are used in H.263+ bitstream decoding */
312 EXTERN int plus_type;           /* indicates if extended PTYPE exists or
313                                  * not. */
314 EXTERN int optional_custom_PCF;
315 EXTERN int advanced_intra_coding;
316 EXTERN int deblocking_filter_mode;
317 EXTERN int slice_structured_mode;
318 EXTERN int reference_picture_selection_mode;
319 EXTERN int independently_segmented_decoding_mode;
320 EXTERN int alternative_inter_VLC_mode;
321 EXTERN int modified_quantization_mode;
322 EXTERN int reduced_resolution_update_mode;
323 EXTERN int reference_picture_resampling_mode;
324 EXTERN int rtype;
325 EXTERN int post_filter;
326 
327 /* Scalability globals */
328 EXTERN unsigned char *prev_enhancement_frame[MAX_LAYERS][3], *current_enhancement_frame[MAX_LAYERS][3];
329 EXTERN unsigned char *curr_reference_frame[3], *upsampled_reference_frame[3];
330 EXTERN unsigned char *enhance_edgeframeorig[MAX_LAYERS][3], *enhance_edgeframe[MAX_LAYERS][3];
331 EXTERN unsigned char *tmp_enhance_fwd[MAX_LAYERS][3], *tmp_enhance_up[MAX_LAYERS][3];
332 EXTERN int enhancement_layer_init[MAX_LAYERS];
333 EXTERN int enhance_pict;
334  
335 /* custom format variables */
336 EXTERN int CP_PAR_code;
337 EXTERN int CP_picture_width_indication;
338 EXTERN int CP_picture_width;
339 EXTERN int CP_picture_height_indication;
340 EXTERN int CP_picture_height;
341 EXTERN int PAR_width;
342 EXTERN int PAR_height;
343 
344 EXTERN int CP_clock_frequency;
345 EXTERN int SSS_rectangular_slices;
346 EXTERN int SSS_arbitary_slice_ordering;
347 EXTERN int enhancement_layer_num;
348 EXTERN int reference_layer_number;
349 EXTERN int MF_of_reference_picture_selection;
350 EXTERN int TRPI;
351 EXTERN int temporal_reference_for_prediction;
352 
353 
354 #ifdef USE_TIME
355 EXTERN int framerate;
356 #ifndef WIN32
357 EXTERN struct timeval tftarget;
358 #else
359 EXTERN unsigned int targetTime;
360 #endif
361 #endif
362 
363 
364 EXTERN int trd, trb, bscan, bquant, true_b_trb;
365 EXTERN int bscan_tab[]
366 #ifdef GLOBAL
367 = {2, 4, 6, 8}
368 #endif
369 ;
370 EXTERN int bquant_tab[]
371 #ifdef GLOBAL
372 = {5, 6, 7, 8}
373 #endif
374 ;
375 
376 EXTERN int OM[5][8][8]
377 #ifdef GLOBAL
378 = {
379   {
380     {4, 5, 5, 5, 5, 5, 5, 4},
381     {5, 5, 5, 5, 5, 5, 5, 5},
382     {5, 5, 6, 6, 6, 6, 5, 5},
383     {5, 5, 6, 6, 6, 6, 5, 5},
384     {5, 5, 6, 6, 6, 6, 5, 5},
385     {5, 5, 6, 6, 6, 6, 5, 5},
386     {5, 5, 5, 5, 5, 5, 5, 5},
387     {4, 5, 5, 5, 5, 5, 5, 4},
388   }, {
389     {2, 2, 2, 2, 2, 2, 2, 2},
390     {1, 1, 2, 2, 2, 2, 1, 1},
391     {1, 1, 1, 1, 1, 1, 1, 1},
392     {1, 1, 1, 1, 1, 1, 1, 1},
393     {0, 0, 0, 0, 0, 0, 0, 0},
394     {0, 0, 0, 0, 0, 0, 0, 0},
395     {0, 0, 0, 0, 0, 0, 0, 0},
396     {0, 0, 0, 0, 0, 0, 0, 0},
397   }, {
398     {0, 0, 0, 0, 0, 0, 0, 0},
399     {0, 0, 0, 0, 0, 0, 0, 0},
400     {0, 0, 0, 0, 0, 0, 0, 0},
401     {0, 0, 0, 0, 0, 0, 0, 0},
402     {1, 1, 1, 1, 1, 1, 1, 1},
403     {1, 1, 1, 1, 1, 1, 1, 1},
404     {1, 1, 2, 2, 2, 2, 1, 1},
405     {2, 2, 2, 2, 2, 2, 2, 2},
406   }, {
407     {0, 0, 0, 0, 1, 1, 1, 2},
408     {0, 0, 0, 0, 1, 1, 2, 2},
409     {0, 0, 0, 0, 1, 1, 2, 2},
410     {0, 0, 0, 0, 1, 1, 2, 2},
411     {0, 0, 0, 0, 1, 1, 2, 2},
412     {0, 0, 0, 0, 1, 1, 2, 2},
413     {0, 0, 0, 0, 1, 1, 2, 2},
414     {0, 0, 0, 0, 1, 1, 1, 2},
415   }, {
416     {2, 1, 1, 1, 0, 0, 0, 0},
417     {2, 2, 1, 1, 0, 0, 0, 0},
418     {2, 2, 1, 1, 0, 0, 0, 0},
419     {2, 2, 1, 1, 0, 0, 0, 0},
420     {2, 2, 1, 1, 0, 0, 0, 0},
421     {2, 2, 1, 1, 0, 0, 0, 0},
422     {2, 2, 1, 1, 0, 0, 0, 0},
423     {2, 1, 1, 1, 0, 0, 0, 0},
424 }}
425 #endif
426 ;
427 
428 EXTERN int roundtab[16]
429 #ifdef GLOBAL
430 = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}
431 #endif
432 ;
433 
434 EXTERN int MQ_chroma_QP_table[32]
435 #ifdef GLOBAL
436  = {0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 
437 14, 14, 14, 14, 14, 15, 15, 15, 15, 15}
438 #endif
439 ;
440 
441 /* output */
442 EXTERN char *outputname;
443 EXTERN char trace_file_name[100];
444 EXTERN FILE *trace_file;
445 EXTERN char recon_file_name[100];
446 EXTERN FILE *recon_file_ptr;
447 EXTERN char enhance_recon_file_name[MAX_LAYERS][100];
448 EXTERN FILE *enhance_recon_file_ptr[MAX_LAYERS];
449 
450 EXTERN int outtype;
451 #define T_YUV      0
452 #define T_SIF      1
453 #define T_TGA      2
454 #define T_PPM      3
455 #define T_X11      4
456 #define T_YUV_CONC 5
457 #define T_WIN      6
458 
459 EXTERN struct ld
460 {
461   /* bit input */
462   int infile;
463   unsigned char rdbfr[2051];
464   unsigned char *rdptr;
465   unsigned char inbfr[16];
466   int incnt;
467   int bitcnt;
468   /* block data */
469   short block[12][64];
470 } base, *ld;
471 
472 
473 /* for reference picture selection */
474 
475 #define RING_SIZE 8
476 
477 EXTERN int   ring_ptr;               /* pointer - to last picture */
478 EXTERN void *ring_lum[RING_SIZE];    /* luminance */
479 EXTERN void *ring_c1[RING_SIZE];     /* chominance */
480 EXTERN void *ring_c2[RING_SIZE];
481 EXTERN int   ring_tr[RING_SIZE];     /* TR values for the pictures */
482 EXTERN int   ring_qu[RING_SIZE];     /* picture quality */
483 EXTERN int   stop_decoder;           /* flag if we completely out of sync */
484 
485 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.