OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [test/] [decoder/] [ldecod/] [inc/] [global.h] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jamey.hick
 
2
/*!
3
 ************************************************************************
4
 *  \file
5
 *     global.h
6
 *  \brief
7
 *     global definitions for H.264 decoder.
8
 *  \author
9
 *     Copyright (C) 1999  Telenor Satellite Services,Norway
10
 *                         Ericsson Radio Systems, Sweden
11
 *
12
 *     Inge Lille-Langoy               <inge.lille-langoy@telenor.com>
13
 *
14
 *     Telenor Satellite Services
15
 *     Keysers gt.13                       tel.:   +47 23 13 86 98
16
 *     N-0130 Oslo,Norway                  fax.:   +47 22 77 79 80
17
 *
18
 *     Rickard Sjoberg                 <rickard.sjoberg@era.ericsson.se>
19
 *
20
 *     Ericsson Radio Systems
21
 *     KI/ERA/T/VV
22
 *     164 80 Stockholm, Sweden
23
 *
24
 ************************************************************************
25
 */
26
#ifndef _GLOBAL_H_
27
#define _GLOBAL_H_
28
 
29
#include <stdio.h>
30
#include <stdarg.h>
31
 
32
#include <time.h>
33
#include <sys/timeb.h>
34
#include "win32.h"
35
#include "defines.h"
36
#include "ifunctions.h"
37
#include "parsetcommon.h"
38
 
39
 
40
typedef unsigned char  byte;                     //!<  8 bit unsigned
41
typedef unsigned short imgpel;                  //!<  Pixel type definition (16 bit for FRExt)
42
//typedef unsigned char  imgpel;                //!<  Pixel type definition (8 bit without FRExt)
43
 
44
pic_parameter_set_rbsp_t *active_pps;
45
seq_parameter_set_rbsp_t *active_sps;
46
 
47
// global picture format dependent buffers, memory allocation in decod.c
48
imgpel **imgY_ref;                              //!< reference frame find snr
49
imgpel ***imgUV_ref;
50
 
51
int **PicPos;
52
int  ReMapRef[20];
53
// B pictures
54
int  Bframe_ctr;
55
int  frame_no;
56
 
57
int  g_nFrame;
58
 
59
// For MB level frame/field coding
60
int  TopFieldForSkip_Y[16][16];
61
int  TopFieldForSkip_UV[2][16][16];
62
 
63
int  InvLevelScale4x4Luma_Intra[6][4][4];
64
int  InvLevelScale4x4Chroma_Intra[2][6][4][4];
65
 
66
int  InvLevelScale4x4Luma_Inter[6][4][4];
67
int  InvLevelScale4x4Chroma_Inter[2][6][4][4];
68
 
69
int  InvLevelScale8x8Luma_Intra[6][8][8];
70
 
71
int  InvLevelScale8x8Luma_Inter[6][8][8];
72
 
73
int  *qmatrix[8];
74
 
75
#define ET_SIZE 300      //!< size of error text buffer
76
char errortext[ET_SIZE]; //!< buffer for error message for exit with error()
77
 
78
/***********************************************************************
79
 * T y p e    d e f i n i t i o n s    f o r    T M L
80
 ***********************************************************************
81
 */
82
 
83
//! Data Partitioning Modes
84
typedef enum
85
{
86
  PAR_DP_1,    //!< no data partitioning is supported
87
  PAR_DP_3,    //!< data partitioning with 3 partitions
88
} PAR_DP_TYPE;
89
 
90
 
91
//! Output File Types
92
typedef enum
93
{
94
  PAR_OF_ANNEXB,   //!< Current TML description
95
  PAR_OF_RTP       //!< RTP Packet Output format
96
} PAR_OF_TYPE;
97
 
98
 
99
//! definition of H.264 syntax elements
100
typedef enum {
101
  SE_HEADER,
102
  SE_PTYPE,
103
  SE_MBTYPE,
104
  SE_REFFRAME,
105
  SE_INTRAPREDMODE,
106
  SE_MVD,
107
  SE_CBP_INTRA,
108
  SE_LUM_DC_INTRA,
109
  SE_CHR_DC_INTRA,
110
  SE_LUM_AC_INTRA,
111
  SE_CHR_AC_INTRA,
112
  SE_CBP_INTER,
113
  SE_LUM_DC_INTER,
114
  SE_CHR_DC_INTER,
115
  SE_LUM_AC_INTER,
116
  SE_CHR_AC_INTER,
117
  SE_DELTA_QUANT_INTER,
118
  SE_DELTA_QUANT_INTRA,
119
  SE_BFRAME,
120
  SE_EOS,
121
  SE_MAX_ELEMENTS //!< number of maximum syntax elements, this MUST be the last one!
122
} SE_type;        // substituting the definitions in element.h
123
 
124
 
125
typedef enum {
126
  INTER_MB,
127
  INTRA_MB_4x4,
128
  INTRA_MB_16x16
129
} IntraInterDecision;
130
 
131
typedef enum {
132
  BITS_TOTAL_MB,
133
  BITS_HEADER_MB,
134
  BITS_INTER_MB,
135
  BITS_CBP_MB,
136
  BITS_COEFF_Y_MB,
137
  BITS_COEFF_UV_MB,
138
  MAX_BITCOUNTER_MB
139
} BitCountType;
140
 
141
typedef enum {
142
  NO_SLICES,
143
  FIXED_MB,
144
  FIXED_RATE,
145
  CALLBACK,
146
  FMO
147
} SliceMode;
148
 
149
 
150
typedef enum {
151
  UVLC,
152
  CABAC
153
} SymbolMode;
154
 
155
typedef enum {
156
 LIST_0=0,
157
 LIST_1=1
158
} Lists;
159
 
160
 
161
typedef enum {
162
  FRAME,
163
  TOP_FIELD,
164
  BOTTOM_FIELD
165
} PictureStructure;           //!< New enum for field processing
166
 
167
 
168
typedef enum {
169
  P_SLICE = 0,
170
  B_SLICE,
171
  I_SLICE,
172
  SP_SLICE,
173
  SI_SLICE
174
} SliceType;
175
 
176
typedef enum
177
{
178
  IS_LUMA = 0,
179
  IS_CHROMA = 1
180
} Component_Type;
181
 
182
 
183
/***********************************************************************
184
 * D a t a    t y p e s   f o r  C A B A C
185
 ***********************************************************************
186
 */
187
 
188
//! struct to characterize the state of the arithmetic coding engine
189
typedef struct
190
{
191
  unsigned int    Dlow, Drange;
192
  unsigned int    Dvalue;
193
  unsigned int    Dbuffer;
194
  int             Dbits_to_go;
195
  byte            *Dcodestrm;
196
  int             *Dcodestrm_len;
197
} DecodingEnvironment;
198
 
199
typedef DecodingEnvironment *DecodingEnvironmentPtr;
200
 
201
//! struct for context management
202
typedef struct
203
{
204
  unsigned short state;         // index into state-table CP
205
  unsigned char  MPS;           // Least Probable Symbol 0/1 CP
206
} BiContextType;
207
 
208
typedef BiContextType *BiContextTypePtr;
209
 
210
 
211
/**********************************************************************
212
 * C O N T E X T S   F O R   T M L   S Y N T A X   E L E M E N T S
213
 **********************************************************************
214
 */
215
 
216
#define NUM_MB_TYPE_CTX  11
217
#define NUM_B8_TYPE_CTX  9
218
#define NUM_MV_RES_CTX   10
219
#define NUM_REF_NO_CTX   6
220
#define NUM_DELTA_QP_CTX 4
221
#define NUM_MB_AFF_CTX 4
222
#define NUM_TRANSFORM_SIZE_CTX 3
223
 
224
 
225
typedef struct
226
{
227
  BiContextType mb_type_contexts [4][NUM_MB_TYPE_CTX];
228
  BiContextType b8_type_contexts [2][NUM_B8_TYPE_CTX];
229
  BiContextType mv_res_contexts  [2][NUM_MV_RES_CTX];
230
  BiContextType ref_no_contexts  [2][NUM_REF_NO_CTX];
231
  BiContextType delta_qp_contexts[NUM_DELTA_QP_CTX];
232
  BiContextType mb_aff_contexts  [NUM_MB_AFF_CTX];
233
  BiContextType transform_size_contexts [NUM_TRANSFORM_SIZE_CTX];
234
 
235
} MotionInfoContexts;
236
 
237
#define NUM_IPR_CTX    2
238
#define NUM_CIPR_CTX   4
239
#define NUM_CBP_CTX    4
240
#define NUM_BCBP_CTX   4
241
#define NUM_MAP_CTX   15
242
#define NUM_LAST_CTX  15
243
#define NUM_ONE_CTX    5
244
#define NUM_ABS_CTX    5
245
 
246
 
247
typedef struct
248
{
249
  BiContextType  ipr_contexts [NUM_IPR_CTX];
250
  BiContextType  cipr_contexts[NUM_CIPR_CTX];
251
  BiContextType  cbp_contexts [3][NUM_CBP_CTX];
252
  BiContextType  bcbp_contexts[NUM_BLOCK_TYPES][NUM_BCBP_CTX];
253
  BiContextType  map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];
254
  BiContextType  last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];
255
  BiContextType  one_contexts [NUM_BLOCK_TYPES][NUM_ONE_CTX];
256
  BiContextType  abs_contexts [NUM_BLOCK_TYPES][NUM_ABS_CTX];
257
  BiContextType  fld_map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];
258
  BiContextType  fld_last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];
259
} TextureInfoContexts;
260
 
261
 
262
//*********************** end of data type definition for CABAC *******************
263
 
264
/***********************************************************************
265
 * N e w   D a t a    t y p e s   f o r    T M L
266
 ***********************************************************************
267
 */
268
 
269
struct img_par;
270
struct inp_par;
271
struct stat_par;
272
 
273
/*! Buffer structure for decoded referenc picture marking commands */
274
typedef struct DecRefPicMarking_s
275
{
276
  int memory_management_control_operation;
277
  int difference_of_pic_nums_minus1;
278
  int long_term_pic_num;
279
  int long_term_frame_idx;
280
  int max_long_term_frame_idx_plus1;
281
  struct DecRefPicMarking_s *Next;
282
} DecRefPicMarking_t;
283
 
284
//! Syntaxelement
285
typedef struct syntaxelement
286
{
287
  int           type;                  //!< type of syntax element for data part.
288
  int           value1;                //!< numerical value of syntax element
289
  int           value2;                //!< for blocked symbols, e.g. run/level
290
  int           len;                   //!< length of code
291
  int           inf;                   //!< info part of UVLC code
292
  unsigned int  bitpattern;            //!< UVLC bitpattern
293
  int           context;               //!< CABAC context
294
  int           k;                     //!< CABAC context for coeff_count,uv
295
 
296
#if TRACE
297
  #define       TRACESTRING_SIZE 100           //!< size of trace string
298
  char          tracestring[TRACESTRING_SIZE]; //!< trace string
299
#endif
300
 
301
  //! for mapping of UVLC to syntaxElement
302
  void    (*mapping)(int len, int info, int *value1, int *value2);
303
  //! used for CABAC: refers to actual coding method of each individual syntax element type
304
  void  (*reading)(struct syntaxelement *, struct img_par *, DecodingEnvironmentPtr);
305
 
306
} SyntaxElement;
307
 
308
//! Macroblock
309
typedef struct macroblock
310
{
311
  int           qp;                  //!< QP luma
312
  int           qpc[2];              //!< QP chroma
313
 
314
  int           slice_nr;
315
  int           delta_quant;          //!< for rate control
316
 
317
  struct macroblock   *mb_available_up;   //!< pointer to neighboring MB (CABAC)
318
  struct macroblock   *mb_available_left; //!< pointer to neighboring MB (CABAC)
319
 
320
  // some storage of macroblock syntax elements for global access
321
  int           mb_type;
322
  int           mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2];      //!< indices correspond to [forw,backw][block_y][block_x][x,y]
323
  int           cbp;
324
  int64         cbp_blk ;
325
  int64         cbp_bits;
326
 
327
  int           is_skip;
328
 
329
  int           i16mode;
330
  char          b8mode[4];
331
  char          b8pdir[4];
332
  int           ei_flag;
333
 
334
  int           LFDisableIdc;
335
  int           LFAlphaC0Offset;
336
  int           LFBetaOffset;
337
 
338
  int           c_ipred_mode;       //!< chroma intra prediction mode
339
  int           mb_field;
340
 
341
  int           skip_flag;
342
 
343
  int mbAddrA, mbAddrB, mbAddrC, mbAddrD;
344
  int mbAvailA, mbAvailB, mbAvailC, mbAvailD;
345
 
346
  int           luma_transform_size_8x8_flag;
347
  int           NoMbPartLessThan8x8Flag;
348
} Macroblock;
349
 
350
//! Bitstream
351
typedef struct
352
{
353
  // CABAC Decoding
354
  int           read_len;           //!< actual position in the codebuffer, CABAC only
355
  int           code_len;           //!< overall codebuffer length, CABAC only
356
  // UVLC Decoding
357
  int           frame_bitoffset;    //!< actual position in the codebuffer, bit-oriented, UVLC only
358
  int           bitstream_length;   //!< over codebuffer lnegth, byte oriented, UVLC only
359
  // ErrorConcealment
360
  byte          *streamBuffer;      //!< actual codebuffer for read bytes
361
  int           ei_flag;            //!< error indication, 0: no error, else unspecified error
362
} Bitstream;
363
 
364
//! DataPartition
365
typedef struct datapartition
366
{
367
 
368
  Bitstream           *bitstream;
369
  DecodingEnvironment de_cabac;
370
 
371
  int     (*readSyntaxElement)(SyntaxElement *, struct img_par *, struct datapartition *);
372
          /*!< virtual function;
373
               actual method depends on chosen data partition and
374
               entropy coding method  */
375
} DataPartition;
376
 
377
//! Slice
378
typedef struct
379
{
380
  int                 ei_flag;       //!< 0 if the partArr[0] contains valid information
381
  int                 qp;
382
  int                 slice_qp_delta;
383
  int                 picture_type;  //!< picture type
384
  PictureStructure    structure;     //!< Identify picture structure type
385
  int                 start_mb_nr;   //!< MUST be set by NAL even in case of ei_flag == 1
386
  int                 max_part_nr;
387
  int                 dp_mode;       //!< data partioning mode
388
  int                 next_header;
389
//  int                 last_mb_nr;    //!< only valid when entropy coding == CABAC
390
  DataPartition       *partArr;      //!< array of partitions
391
  MotionInfoContexts  *mot_ctx;      //!< pointer to struct of context models for use in CABAC
392
  TextureInfoContexts *tex_ctx;      //!< pointer to struct of context models for use in CABAC
393
 
394
  int                 ref_pic_list_reordering_flag_l0;
395
  int                 *reordering_of_pic_nums_idc_l0;
396
  int                 *abs_diff_pic_num_minus1_l0;
397
  int                 *long_term_pic_idx_l0;
398
  int                 ref_pic_list_reordering_flag_l1;
399
  int                 *reordering_of_pic_nums_idc_l1;
400
  int                 *abs_diff_pic_num_minus1_l1;
401
  int                 *long_term_pic_idx_l1;
402
 
403
  int     (*readSlice)(struct img_par *, struct inp_par *);
404
 
405
  int                 LFDisableIdc;     //!< Disable loop filter on slice
406
  int                 LFAlphaC0Offset;  //!< Alpha and C0 offset for filtering slice
407
  int                 LFBetaOffset;     //!< Beta offset for filtering slice
408
 
409
  int                 pic_parameter_set_id;   //!<the ID of the picture parameter set the slice is reffering to
410
 
411
} Slice;
412
 
413
//****************************** ~DM ***********************************
414
 
415
// image parameters
416
typedef struct img_par
417
{
418
  int number;                                 //!< frame number
419
  unsigned int current_mb_nr; // bitstream order
420
  unsigned int num_dec_mb;
421
  int current_slice_nr;
422
  int *intra_block;
423
  int tr;                                     //!< temporal reference, 8 bit, wrapps at 255
424
  int qp;                                     //!< quant for the current frame
425
  int qpsp;                                   //!< quant for SP-picture predicted frame
426
  int sp_switch;                              //!< 1 for switching sp, 0 for normal sp
427
  int direct_spatial_mv_pred_flag;            //!< 1 for Spatial Direct, 0 for Temporal
428
  int type;                                   //!< image type INTER/INTRA
429
  int width;
430
  int height;
431
  int width_cr;                               //!< width chroma
432
  int width_cr_m1;                               //!< width chroma
433
  int height_cr;                              //!< height chroma
434
  int mb_y;
435
  int mb_x;
436
  int block_y;
437
  int pix_y;
438
  int pix_x;
439
  int pix_c_y;
440
  int block_x;
441
  int pix_c_x;
442
 
443
  int allrefzero;
444
  imgpel mpr[16][16];                         //!< predicted block
445
  int mvscale[6][MAX_REFERENCE_PICTURES];
446
  int m7[16][16];                             //!< final 4x4 block. Extended to 16x16 for ABT
447
  int cof[4][12][4][4];                       //!< correction coefficients from predicted
448
  int cofu[16];
449
  byte **ipredmode;                            //!< prediction type [90][74]
450
  int *quad;
451
  int ***nz_coeff;
452
  int **siblock;
453
  int cod_counter;                            //!< Current count of number of skipped macroblocks in a row
454
 
455
  int newframe;
456
 
457
  int structure;                               //!< Identify picture structure type
458
  int pstruct_next_P;
459
 
460
  // B pictures
461
  Slice       *currentSlice;                   //!< pointer to current Slice data struct
462
  Macroblock          *mb_data;                //!< array containing all MBs of a whole frame
463
  int subblock_x;
464
  int subblock_y;
465
  int is_intra_block;
466
  int is_v_block;
467
 
468
  // For MB level frame/field coding
469
  int MbaffFrameFlag;
470
 
471
  // for signalling to the neighbour logic that this is a deblocker call
472
  int DeblockCall;
473
 
474
  DecRefPicMarking_t *dec_ref_pic_marking_buffer;                    //!< stores the memory management control operations
475
 
476
  int num_ref_idx_l0_active;             //!< number of forward reference
477
  int num_ref_idx_l1_active;             //!< number of backward reference
478
 
479
  int slice_group_change_cycle;
480
 
481
  int redundant_pic_cnt;
482
 
483
  int explicit_B_prediction;
484
 
485
  unsigned int pre_frame_num;           //!< store the frame_num in the last decoded slice. For detecting gap in frame_num.
486
 
487
  // End JVT-D101
488
  // POC200301: from unsigned int to int
489
           int toppoc;      //poc for this top field // POC200301
490
           int bottompoc;   //poc of bottom field of frame
491
           int framepoc;    //poc of this frame // POC200301
492
  unsigned int frame_num;   //frame_num for this frame
493
  unsigned int field_pic_flag;
494
  unsigned int bottom_field_flag;
495
 
496
  //the following is for slice header syntax elements of poc
497
  // for poc mode 0.
498
  unsigned int pic_order_cnt_lsb;
499
           int delta_pic_order_cnt_bottom;
500
  // for poc mode 1.
501
           int delta_pic_order_cnt[3];
502
 
503
  // ////////////////////////
504
  // for POC mode 0:
505
    signed int PrevPicOrderCntMsb;
506
  unsigned int PrevPicOrderCntLsb;
507
    signed int PicOrderCntMsb;
508
 
509
  // for POC mode 1:
510
  unsigned int AbsFrameNum;
511
    signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt, FrameNumInPicOrderCntCycle;
512
  unsigned int PreviousFrameNum, FrameNumOffset;
513
           int ExpectedDeltaPerPicOrderCntCycle;
514
           int PreviousPOC, ThisPOC;
515
           int PreviousFrameNumOffset;
516
  // /////////////////////////
517
 
518
  //weighted prediction
519
  unsigned int luma_log2_weight_denom;
520
  unsigned int chroma_log2_weight_denom;
521
  int ***wp_weight;  // weight in [list][index][component] order
522
  int ***wp_offset;  // offset in [list][index][component] order
523
  int ****wbp_weight; //weight in [list][fw_index][bw_index][component] order
524
  int wp_round_luma;
525
  int wp_round_chroma;
526
  unsigned int apply_weights;
527
 
528
  int idr_flag;
529
  int nal_reference_idc;                       //!< nal_reference_idc from NAL unit
530
 
531
  int idr_pic_id;
532
 
533
  int MaxFrameNum;
534
 
535
  unsigned int PicWidthInMbs;
536
  unsigned int PicHeightInMapUnits;
537
  unsigned int FrameHeightInMbs;
538
  unsigned int PicHeightInMbs;
539
  unsigned int PicSizeInMbs;
540
  unsigned int FrameSizeInMbs;
541
  unsigned int oldFrameSizeInMbs;
542
 
543
  int no_output_of_prior_pics_flag;
544
  int long_term_reference_flag;
545
  int adaptive_ref_pic_buffering_flag;
546
 
547
  int last_has_mmco_5;
548
  int last_pic_bottom_field;
549
 
550
  int model_number;
551
 
552
  // Fidelity Range Extensions Stuff
553
  int pic_unit_bitsize_on_disk;
554
  int bitdepth_luma;
555
  int bitdepth_chroma;
556
  int bitdepth_luma_qp_scale;
557
  int bitdepth_chroma_qp_scale;
558
  unsigned int dc_pred_value_luma;            //!< luma value for DC prediction (depends on luma pel bit depth)
559
  unsigned int dc_pred_value_chroma;          //!< chroma value for DC prediction (depends on chroma pel bit depth)
560
  int max_imgpel_value;                       //!< max value that one luma picture element (pixel) can take (depends on pic_unit_bitdepth)
561
  int max_imgpel_value_uv;                    //!< max value that one chroma picture element (pixel) can take (depends on pic_unit_bitdepth)
562
  int Transform8x8Mode;
563
  int profile_idc;
564
  int yuv_format;
565
  int lossless_qpprime_flag;
566
  int num_blk8x8_uv;
567
  int num_cdc_coeff;
568
  int mb_cr_size_x;
569
  int mb_cr_size_y;
570
  int mb_cr_size_x_blk;
571
  int mb_cr_size_y_blk;
572
  int mb_size[3][2];                         //!< component macroblock dimensions
573
  int mb_size_blk[3][2];                         //!< component macroblock dimensions
574
 
575
  int idr_psnr_number;
576
  int psnr_number;
577
 
578
  time_t ltime_start;               // for time measurement
579
  time_t ltime_end;                 // for time measurement
580
 
581
#ifdef WIN32
582
  struct _timeb tstruct_start;
583
  struct _timeb tstruct_end;
584
#else
585
  struct timeb tstruct_start;
586
  struct timeb tstruct_end;
587
#endif
588
 
589
  // picture error concealment
590
  int last_ref_pic_poc;
591
  int ref_poc_gap;
592
  int poc_gap;
593
  int conceal_mode;
594
  int earlier_missing_poc;
595
  unsigned int frame_to_conceal;
596
  int IDR_concealment_flag;
597
  int conceal_slice_type;
598
 
599
  // random access point decoding
600
  int recovery_point;
601
  int recovery_point_found;
602
  int recovery_frame_cnt;
603
  int recovery_frame_num;
604
  int recovery_poc;
605
 
606
} ImageParameters;
607
 
608
extern ImageParameters *img;
609
extern struct snr_par  *snr;
610
 
611
// signal to noise ratio parameters
612
struct snr_par
613
{
614
  int   frame_ctr;
615
  float snr_y;                                 //!< current Y SNR
616
  float snr_u;                                 //!< current U SNR
617
  float snr_v;                                 //!< current V SNR
618
  float snr_y1;                                //!< SNR Y(dB) first frame
619
  float snr_u1;                                //!< SNR U(dB) first frame
620
  float snr_v1;                                //!< SNR V(dB) first frame
621
  float snr_ya;                                //!< Average SNR Y(dB) remaining frames
622
  float snr_ua;                                //!< Average SNR U(dB) remaining frames
623
  float snr_va;                                //!< Average SNR V(dB) remaining frames
624
  float sse_y;                                 //!< SSE Y
625
  float sse_u;                                 //!< SSE U
626
  float sse_v;                                 //!< SSE V
627
  float msse_y;                                //!< Average SSE Y
628
  float msse_u;                                //!< Average SSE U
629
  float msse_v;                                //!< Average SSE V
630
};
631
 
632
time_t tot_time;
633
 
634
// input parameters from configuration file
635
struct inp_par
636
{
637
  char infile[100];                       //!< H.264 inputfile
638
  char outfile[100];                      //!< Decoded YUV 4:2:0 output
639
  char reffile[100];                      //!< Optional YUV 4:2:0 reference file for SNR measurement
640
  int FileFormat;                         //!< File format of the Input file, PAR_OF_ANNEXB or PAR_OF_RTP
641
  int ref_offset;
642
  int poc_scale;
643
  int write_uv;
644
  int silent;
645
 
646
#ifdef _LEAKYBUCKET_
647
  unsigned long R_decoder;                //!< Decoder Rate in HRD Model
648
  unsigned long B_decoder;                //!< Decoder Buffer size in HRD model
649
  unsigned long F_decoder;                //!< Decoder Initial buffer fullness in HRD model
650
  char LeakyBucketParamFile[100];         //!< LeakyBucketParamFile
651
#endif
652
 
653
  // picture error concealment
654
  int conceal_mode;
655
  int ref_poc_gap;
656
  int poc_gap;
657
 
658
};
659
 
660
extern struct inp_par *input;
661
 
662
typedef struct pix_pos
663
{
664
  int available;
665
  int mb_addr;
666
  int x;
667
  int y;
668
  int pos_x;
669
  int pos_y;
670
} PixelPos;
671
 
672
typedef struct old_slice_par
673
{
674
   unsigned field_pic_flag;
675
   unsigned bottom_field_flag;
676
   unsigned frame_num;
677
   int nal_ref_idc;
678
   unsigned pic_oder_cnt_lsb;
679
   int delta_pic_oder_cnt_bottom;
680
   int delta_pic_order_cnt[2];
681
   int idr_flag;
682
   int idr_pic_id;
683
   int pps_id;
684
} OldSliceParams;
685
 
686
extern OldSliceParams old_slice;
687
 
688
// files
689
int p_out;                    //!< file descriptor to output YUV file
690
//FILE *p_out2;                    //!< pointer to debug output YUV file
691
int p_ref;                    //!< pointer to input original reference YUV file file
692
 
693
FILE *p_log;                    //!< SNR file
694
 
695
#if TRACE
696
FILE *p_trace;
697
#endif
698
 
699
// Redundant slices
700
unsigned int previous_frame_num;          //!< frame number of previous slice
701
int ref_flag[17];                //!< 0: i-th previous frame is incorrect
702
                                 //!< non-zero: i-th previous frame is correct
703
int Is_primary_correct;          //!< if primary frame is correct, 0: incorrect
704
int Is_redundant_correct;        //!< if redundant frame is correct, 0:incorrect
705
int redundant_slice_ref_idx;     //!< reference index of redundant slice
706
void Error_tracking(void);
707
 
708
// prototypes
709
void init_conf(struct inp_par *inp, char *config_filename);
710
void report(struct inp_par *inp, struct img_par *img, struct snr_par *snr);
711
void init(struct img_par *img);
712
 
713
void malloc_slice(struct inp_par *inp, struct img_par *img);
714
void free_slice(struct inp_par *inp, struct img_par *img);
715
 
716
int  decode_one_frame(struct img_par *img,struct inp_par *inp, struct snr_par *snr);
717
void init_picture(struct img_par *img, struct inp_par *inp);
718
void exit_picture();
719
 
720
int  read_new_slice();
721
void decode_one_slice(struct img_par *img,struct inp_par *inp);
722
 
723
void start_macroblock(struct img_par *img,int CurrentMBInScanOrder);
724
int  read_one_macroblock(struct img_par *img,struct inp_par *inp);
725
void read_ipred_modes(struct img_par *img,struct inp_par *inp);
726
int  decode_one_macroblock(struct img_par *img,struct inp_par *inp);
727
Boolean  exit_macroblock(struct img_par *img,struct inp_par *inp, int eos_bit);
728
void decode_ipcm_mb(struct img_par *img);
729
 
730
 
731
void readMotionInfoFromNAL (struct img_par *img,struct inp_par *inp);
732
void readCBPandCoeffsFromNAL(struct img_par *img,struct inp_par *inp);
733
void readIPCMcoeffsFromNAL(struct img_par *img, struct inp_par *inp, struct datapartition *dP);
734
 
735
void readLumaCoeff8x8_CABAC (struct img_par *img,struct inp_par *inp, int b8);
736
void itrans8x8(struct img_par *img, int ioff, int joff);
737
 
738
void copyblock_sp(struct img_par *img,int block_x,int block_y);
739
void itrans_sp_chroma(struct img_par *img,int ll);
740
void itrans(struct img_par *img,int ioff,int joff,int i0,int j0, int chroma);
741
void itrans_sp(struct img_par *img,int ioff,int joff,int i0,int j0);
742
int  intrapred(struct img_par *img,int ioff,int joff,int i4,int j4);
743
void itrans_2(struct img_par *img);
744
int  intrapred_luma_16x16(struct img_par *img,int predmode);
745
void intrapred_chroma(struct img_par *img, int uv);
746
 
747
// SLICE function pointers
748
int  (*nal_startcode_follows) (struct img_par*, int );
749
 
750
// NAL functions TML/CABAC bitstream
751
int  uvlc_startcode_follows(struct img_par *img, int dummy);
752
int  cabac_startcode_follows(struct img_par *img, int eos_bit);
753
void free_Partition(Bitstream *currStream);
754
 
755
// ErrorConcealment
756
void reset_ec_flags();
757
 
758
void error(char *text, int code);
759
int  is_new_picture();
760
void init_old_slice();
761
 
762
// dynamic mem allocation
763
int  init_global_buffers();
764
void free_global_buffers();
765
 
766
void frame_postprocessing(struct img_par *img, struct inp_par *inp);
767
void field_postprocessing(struct img_par *img, struct inp_par *inp);
768
int  bottom_field_picture(struct img_par *img,struct inp_par *inp);
769
void decode_slice(struct img_par *img,struct inp_par *inp, int current_header);
770
 
771
int RBSPtoSODB(byte *streamBuffer, int last_byte_pos);
772
int EBSPtoRBSP(byte *streamBuffer, int end_bytepos, int begin_bytepos);
773
 
774
// For MB level frame/field coding
775
void init_super_macroblock(struct img_par *img,struct inp_par *inp);
776
void exit_super_macroblock(struct img_par *img,struct inp_par *inp);
777
int  decode_super_macroblock(struct img_par *img,struct inp_par *inp);
778
void decode_one_Copy_topMB(struct img_par *img,struct inp_par *inp);
779
 
780
void SetOneRefMV(struct img_par* img);
781
int peekSyntaxElement_UVLC(SyntaxElement *sym, struct img_par *img, struct datapartition *dP);
782
 
783
void fill_wp_params(struct img_par *img);
784
 
785
void reset_wp_params(struct img_par *img);
786
 
787
void FreePartition (DataPartition *dp, int n);
788
DataPartition *AllocPartition();
789
 
790
void tracebits2(const char *trace_str, int len, int info);
791
 
792
void init_decoding_engine_IPCM(struct img_par *img);
793
void readIPCMBytes_CABAC(SyntaxElement *sym, Bitstream *currStream);
794
 
795
unsigned CeilLog2( unsigned uiVal);
796
 
797
// For Q-matrix
798
void AssignQuantParam(pic_parameter_set_rbsp_t* pps, seq_parameter_set_rbsp_t* sps);
799
void CalculateQuantParam(void);
800
void CalculateQuant8Param(void);
801
 
802
#endif
803
 
804
 

powered by: WebSVN 2.1.0

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