summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/avc/dec/src/avcdec_lib.h
blob: fdead05eabee2af6554e58fa0f0171b7d9549d28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
/* ------------------------------------------------------------------
 * Copyright (C) 1998-2009 PacketVideo
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 * -------------------------------------------------------------------
 */
/**
This file contains declarations of internal functions for AVC decoder library.
@publishedAll
*/
#ifndef _AVCDEC_LIB_H_
#define _AVCDEC_LIB_H_

#include "avclib_common.h"
#include "avcdec_int.h"

/*----------- avcdec_api.c -------------*/
/**
This function takes out the emulation prevention bytes from the input to creat RBSP.
The result is written over the input bitstream.
\param "nal_unit"   "(I/O) Pointer to the input buffer."
\param "size"       "(I/O) Pointer to the size of the input/output buffer."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
*/
AVCDec_Status EBSPtoRBSP(uint8 *nal_unit, int *size);

/*------------- pred_intra.c ---------------*/
/**
This function is the main entry point to intra prediction operation on a
macroblock.
\param "video"  "Pointer to AVCCommonObj."
*/
AVCStatus  IntraMBPrediction(AVCCommonObj *video);

void SaveNeighborForIntraPred(AVCCommonObj *video, int offset);

AVCStatus Intra_4x4(AVCCommonObj *video, int component, int SubBlock_indx, uint8 *comp);
void Intra_4x4_Vertical(AVCCommonObj *video, int block_offset);
void Intra_4x4_Horizontal(AVCCommonObj *video, int pitch, int block_offset);
void Intra_4x4_DC(AVCCommonObj *video, int pitch, int block_offset, AVCNeighborAvailability *availability);
void Intra_4x4_Down_Left(AVCCommonObj *video, int block_offset, AVCNeighborAvailability *availability);
void Intra_4x4_Diagonal_Down_Right(AVCCommonObj *video, int pitch, int block_offset);
void Intra_4x4_Diagonal_Vertical_Right(AVCCommonObj *video, int pitch, int block_offset);
void Intra_4x4_Diagonal_Horizontal_Down(AVCCommonObj *video, int pitch, int block_offset);
void Intra_4x4_Vertical_Left(AVCCommonObj *video,  int block_offset, AVCNeighborAvailability *availability);
void Intra_4x4_Horizontal_Up(AVCCommonObj *video, int pitch, int block_offset);
void  Intra_16x16_Vertical(AVCCommonObj *video);
void Intra_16x16_Horizontal(AVCCommonObj *video, int pitch);
void Intra_16x16_DC(AVCCommonObj *video, int pitch);
void Intra_16x16_Plane(AVCCommonObj *video, int pitch);
void Intra_Chroma_DC(AVCCommonObj *video, int pitch, uint8 *predCb, uint8 *predCr);
void  Intra_Chroma_Horizontal(AVCCommonObj *video, int pitch, uint8 *predCb, uint8 *predCr);
void  Intra_Chroma_Vertical(AVCCommonObj *video, uint8 *predCb, uint8 *predCr);
void  Intra_Chroma_Plane(AVCCommonObj *video, int pitch, uint8 *predCb, uint8 *predCr);

/*------------ pred_inter.c ---------------*/
/**
This function is the main entrance to inter prediction operation for
a macroblock. For decoding, this function also calls inverse transform and
compensation.
\param "video"  "Pointer to AVCCommonObj."
\return "void"
*/
void InterMBPrediction(AVCCommonObj *video);

/**
This function is called for luma motion compensation.
\param "ref"    "Pointer to the origin of a reference luma."
\param "picwidth"   "Width of the picture."
\param "picheight"  "Height of the picture."
\param "x_pos"  "X-coordinate of the predicted block in quarter pel resolution."
\param "y_pos"  "Y-coordinate of the predicted block in quarter pel resolution."
\param "pred"   "Pointer to the output predicted block."
\param "pred_pitch" "Width of pred."
\param "blkwidth"   "Width of the current partition."
\param "blkheight"  "Height of the current partition."
\return "void"
*/
void LumaMotionComp(uint8 *ref, int picwidth, int picheight,
                    int x_pos, int y_pos,
                    uint8 *pred, int pred_pitch,
                    int blkwidth, int blkheight);

/**
Functions below are special cases for luma motion compensation.
LumaFullPelMC is for full pixel motion compensation.
LumaBorderMC is for interpolation in only one dimension.
LumaCrossMC is for interpolation in one dimension and half point in the other dimension.
LumaDiagonalMC is for interpolation in diagonal direction.

\param "ref"    "Pointer to the origin of a reference luma."
\param "picwidth"   "Width of the picture."
\param "picheight"  "Height of the picture."
\param "x_pos"  "X-coordinate of the predicted block in full pel resolution."
\param "y_pos"  "Y-coordinate of the predicted block in full pel resolution."
\param "dx"     "Fraction of x_pos in quarter pel."
\param "dy"     "Fraction of y_pos in quarter pel."
\param "curr"   "Pointer to the current partition in the current picture."
\param "residue"    "Pointer to the current partition for the residue block."
\param "blkwidth"   "Width of the current partition."
\param "blkheight"  "Height of the current partition."
\return "void"
*/
void CreatePad(uint8 *ref, int picwidth, int picheight, int x_pos, int y_pos,
               uint8 *out, int blkwidth, int blkheight);

void FullPelMC(uint8 *in, int inwidth, uint8 *out, int outpitch,
               int blkwidth, int blkheight);

void HorzInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
                   int blkwidth, int blkheight, int dx);

void HorzInterp2MC(int *in, int inpitch, uint8 *out, int outpitch,
                   int blkwidth, int blkheight, int dx);

void HorzInterp3MC(uint8 *in, int inpitch, int *out, int outpitch,
                   int blkwidth, int blkheight);

void VertInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
                   int blkwidth, int blkheight, int dy);

void VertInterp2MC(uint8 *in, int inpitch, int *out, int outpitch,
                   int blkwidth, int blkheight);

void VertInterp3MC(int *in, int inpitch, uint8 *out, int outpitch,
                   int blkwidth, int blkheight, int dy);

void DiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch,
                      uint8 *out, int outpitch,
                      int blkwidth, int blkheight);


void ChromaMotionComp(uint8 *ref, int picwidth, int picheight,
                      int x_pos, int y_pos, uint8 *pred, int pred_pitch,
                      int blkwidth, int blkheight);

void ChromaFullPelMC(uint8 *in, int inpitch, uint8 *out, int outpitch,
                     int blkwidth, int blkheight) ;
void ChromaBorderMC(uint8 *ref, int picwidth, int dx, int dy,
                    uint8 *pred, int pred_pitch, int blkwidth, int blkheight);
void ChromaDiagonalMC(uint8 *ref, int picwidth, int dx, int dy,
                      uint8 *pred, int pred_pitch, int blkwidth, int blkheight);

void ChromaFullPelMCOutside(uint8 *ref, uint8 *pred, int pred_pitch,
                            int blkwidth, int blkheight, int x_inc,
                            int y_inc0, int y_inc1, int x_mid, int y_mid);
void ChromaBorderMCOutside(uint8 *ref, int picwidth, int dx, int dy,
                           uint8 *pred, int pred_pitch, int blkwidth, int blkheight,
                           int x_inc, int z_inc, int y_inc0, int y_inc1, int x_mid, int y_mid);
void ChromaDiagonalMCOutside(uint8 *ref, int picwidth,
                             int dx, int dy, uint8 *pred, int pred_pitch,
                             int blkwidth, int blkheight, int x_inc, int z_inc,
                             int y_inc0, int y_inc1, int x_mid, int y_mid);

void ChromaDiagonalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                           uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaHorizontalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                             uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaVerticalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                           uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaFullMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                       uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaVerticalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                            uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaHorizontalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                              uint8 *pOut, int predPitch, int blkwidth, int blkheight);

void ChromaDiagonalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                            uint8 *pOut, int predPitch, int blkwidth, int blkheight);


/*----------- slice.c ---------------*/
/**
This function performs the main decoding loop for slice data including
INTRA/INTER prediction, transform and quantization and compensation.
See decode_frame_slice() in JM.
\param "video"  "Pointer to AVCDecObject."
\return "AVCDEC_SUCCESS for success, AVCDEC_PICTURE_READY for end-of-picture and AVCDEC_FAIL otherwise."
*/
AVCDec_Status DecodeSlice(AVCDecObject *video);
AVCDec_Status ConcealSlice(AVCDecObject *decvid, int mbnum_start, int mbnum_end);
/**
This function performs the decoding of one macroblock.
\param "video"  "Pointer to AVCDecObject."
\param "prevMbSkipped"  "A value derived in 7.3.4."
\return "AVCDEC_SUCCESS for success or AVCDEC_FAIL otherwise."
*/
AVCDec_Status DecodeMB(AVCDecObject *video);

/**
This function performs macroblock prediction type decoding as in subclause 7.3.5.1.
\param "video" "Pointer to AVCCommonObj."
\param "currMB" "Pointer to the current macroblock."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS for success or AVCDEC_FAIL otherwise."
*/
AVCDec_Status mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCDecBitstream *stream);

/**
This function performs sub-macroblock prediction type decoding as in subclause 7.3.5.2.
\param "video" "Pointer to AVCCommonObj."
\param "currMB" "Pointer to the current macroblock."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS for success or AVCDEC_FAIL otherwise."
*/
AVCDec_Status sub_mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCDecBitstream *stream);

/**
This function interprets the mb_type and sets necessary information
when the slice type is AVC_I_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretMBModeI(AVCMacroblock *mblock, uint mb_type);

/**
This function interprets the mb_type and sets necessary information
when the slice type is AVC_P_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretMBModeP(AVCMacroblock *mblock, uint mb_type);

/**
This function interprets the mb_type and sets necessary information
when the slice type is AVC_B_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretMBModeB(AVCMacroblock *mblock, uint mb_type);

/**
This function interprets the mb_type and sets necessary information
when the slice type is AVC_SI_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretMBModeSI(AVCMacroblock *mblock, uint mb_type);

/**
This function interprets the sub_mb_type and sets necessary information
when the slice type is AVC_P_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "sub_mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretSubMBModeP(AVCMacroblock *mblock, uint *sub_mb_type);

/**
This function interprets the sub_mb_type and sets necessary information
when the slice type is AVC_B_SLICE.
in the macroblock structure.
\param "mblock" "Pointer to current AVCMacroblock."
\param "sub_mb_type" "From the syntax bitstream."
\return "void"
*/
void InterpretSubMBModeB(AVCMacroblock *mblock, uint *sub_mb_type);

/**
This function decodes the Intra4x4 prediction mode from neighboring information
and from the decoded syntax.
\param "video"  "Pointer to AVCCommonObj."
\param "currMB" "Pointer to current macroblock."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status DecodeIntra4x4Mode(AVCCommonObj *video, AVCMacroblock *currMB, AVCDecBitstream *stream);

/*----------- vlc.c -------------------*/
/**
This function reads and decodes Exp-Golomb codes.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "codeNum" "Pointer to the value of the codeNum."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status ue_v(AVCDecBitstream *bitstream, uint *codeNum);

/**
This function reads and decodes signed Exp-Golomb codes.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "value"  "Pointer to syntax element value."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status  se_v(AVCDecBitstream *bitstream, int *value);

/**
This function reads and decodes signed Exp-Golomb codes for
32 bit codeword.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "value"  "Pointer to syntax element value."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status  se_v32bit(AVCDecBitstream *bitstream, int32 *value);

/**
This function reads and decodes truncated Exp-Golomb codes.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "value"  "Pointer to syntax element value."
\param "range"  "Range of the value as input to determine the algorithm."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status te_v(AVCDecBitstream *bitstream, uint *value, uint range);

/**
This function parse Exp-Golomb code from the bitstream.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "leadingZeros" "Pointer to the number of leading zeros."
\param "infobits"   "Pointer to the value after leading zeros and the first one.
                    The total number of bits read is 2*leadingZeros + 1."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status GetEGBitstring(AVCDecBitstream *bitstream, int *leadingZeros, int *infobits);

/**
This function parse Exp-Golomb code from the bitstream for 32 bit codewords.
\param "bitstream" "Pointer to AVCDecBitstream."
\param "leadingZeros" "Pointer to the number of leading zeros."
\param "infobits"   "Pointer to the value after leading zeros and the first one.
                    The total number of bits read is 2*leadingZeros + 1."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status GetEGBitstring32bit(AVCDecBitstream *bitstream, int *leadingZeros, uint32 *infobits);

/**
This function performs CAVLC decoding of the CBP (coded block pattern) of a macroblock
by calling ue_v() and then mapping the codeNum to the corresponding CBP value.
\param "currMB"  "Pointer to the current AVCMacroblock structure."
\param "stream"  "Pointer to the AVCDecBitstream."
\return "void"
*/
AVCDec_Status DecodeCBP(AVCMacroblock *currMB, AVCDecBitstream *stream);

/**
This function decodes the syntax for trailing ones and total coefficient.
Subject to optimization.
\param "stream" "Pointer to the AVCDecBitstream."
\param "TrailingOnes"   "Pointer to the trailing one variable output."
\param "TotalCoeff" "Pointer to the total coefficient variable output."
\param "nC" "Context for number of nonzero coefficient (prediction context)."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_TotalCoeffTrailingOnes(AVCDecBitstream *stream, int *TrailingOnes, int *TotalCoeff, int nC);

/**
This function decodes the syntax for trailing ones and total coefficient for
chroma DC block. Subject to optimization.
\param "stream" "Pointer to the AVCDecBitstream."
\param "TrailingOnes"   "Pointer to the trailing one variable output."
\param "TotalCoeff" "Pointer to the total coefficient variable output."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_TotalCoeffTrailingOnesChromaDC(AVCDecBitstream *stream, int *TrailingOnes, int *TotalCoeff);

/**
This function decode a VLC table with 2 output.
\param "stream" "Pointer to the AVCDecBitstream."
\param "lentab" "Table for code length."
\param "codtab" "Table for code value."
\param "tabwidth" "Width of the table or alphabet size of the first output."
\param "tabheight"  "Height of the table or alphabet size of the second output."
\param "code1"  "Pointer to the first output."
\param "code2"  "Pointer to the second output."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status code_from_bitstream_2d(AVCDecBitstream *stream, int *lentab, int *codtab, int tabwidth,
                                     int tabheight, int *code1, int *code2);

/**
This function decodes the level_prefix VLC value as in Table 9-6.
\param "stream" "Pointer to the AVCDecBitstream."
\param "code"   "Pointer to the output."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_LevelPrefix(AVCDecBitstream *stream, uint *code);

/**
This function decodes total_zeros VLC syntax as in Table 9-7 and 9-8.
\param "stream" "Pointer to the AVCDecBitstream."
\param "code"   "Pointer to the output."
\param "TotalCoeff" "Context parameter."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_TotalZeros(AVCDecBitstream *stream, int *code, int TotalCoeff);

/**
This function decodes total_zeros VLC syntax for chroma DC as in Table 9-9.
\param "stream" "Pointer to the AVCDecBitstream."
\param "code"   "Pointer to the output."
\param "TotalCoeff" "Context parameter."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_TotalZerosChromaDC(AVCDecBitstream *stream, int *code, int TotalCoeff);

/**
This function decodes run_before VLC syntax as in Table 9-10.
\param "stream" "Pointer to the AVCDecBitstream."
\param "code"   "Pointer to the output."
\param "zeroLeft"   "Context parameter."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status ce_RunBefore(AVCDecBitstream *stream, int *code, int zeroLeft);

/*----------- header.c -------------------*/
/**
This function parses vui_parameters.
\param "decvid" "Pointer to AVCDecObject."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status vui_parameters(AVCDecObject *decvid, AVCDecBitstream *stream, AVCSeqParamSet *currSPS);
AVCDec_Status sei_payload(AVCDecObject *decvid, AVCDecBitstream *stream, uint payloadType, uint payloadSize);

AVCDec_Status buffering_period(AVCDecObject *decvid, AVCDecBitstream *stream);
AVCDec_Status pic_timing(AVCDecObject *decvid, AVCDecBitstream *stream);
AVCDec_Status recovery_point(AVCDecObject *decvid, AVCDecBitstream *stream);
AVCDec_Status dec_ref_pic_marking_repetition(AVCDecObject *decvid, AVCDecBitstream *stream);
AVCDec_Status motion_constrained_slice_group_set(AVCDecObject *decvid, AVCDecBitstream *stream);


/**
This function parses hrd_parameters.
\param "decvid" "Pointer to AVCDecObject."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status hrd_parameters(AVCDecObject *decvid, AVCDecBitstream *stream, AVCHRDParams *HRDParam);

/**
This function decodes the syntax in sequence parameter set slice and fill up the AVCSeqParamSet
structure.
\param "decvid" "Pointer to AVCDecObject."
\param "video" "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status DecodeSPS(AVCDecObject *decvid, AVCDecBitstream *stream);

/**
This function decodes the syntax in picture parameter set and fill up the AVCPicParamSet
structure.
\param "decvid" "Pointer to AVCDecObject."
\param "video" "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS or AVCDEC_FAIL."
*/
AVCDec_Status DecodePPS(AVCDecObject *decvid, AVCCommonObj *video, AVCDecBitstream *stream);
AVCDec_Status DecodeSEI(AVCDecObject *decvid, AVCDecBitstream *stream);

/**
This function decodes slice header, calls related functions such as
reference picture list reordering, prediction weight table, decode ref marking.
See FirstPartOfSliceHeader() and RestOfSliceHeader() in JM.
\param "decvid" "Pointer to AVCDecObject."
\param "video" "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
*/
AVCDec_Status DecodeSliceHeader(AVCDecObject *decvid, AVCCommonObj *video, AVCDecBitstream *stream);

/**
This function performes necessary operations to create dummy frames when
there is a gap in frame_num.
\param "video"  "Pointer to AVCCommonObj."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
*/
AVCDec_Status fill_frame_num_gap(AVCHandle *avcHandle, AVCCommonObj *video);

/**
This function decodes ref_pic_list_reordering related syntax and fill up the AVCSliceHeader
structure.
\param "video" "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
\param "sliceHdr" "Pointer to AVCSliceHdr."
\param "slice_type" "Value of slice_type - 5 if greater than 5."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
*/
AVCDec_Status ref_pic_list_reordering(AVCCommonObj *video, AVCDecBitstream *stream, AVCSliceHeader *sliceHdr, int slice_type);

/**
This function decodes dec_ref_pic_marking related syntax  and fill up the AVCSliceHeader
structure.
\param "video" "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
\param "sliceHdr" "Pointer to AVCSliceHdr."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
*/
AVCDec_Status dec_ref_pic_marking(AVCCommonObj *video, AVCDecBitstream *stream, AVCSliceHeader *sliceHdr);

/**
This function performs POC related operation prior to decoding a picture
\param "video" "Pointer to AVCCommonObj."
\return "AVCDEC_SUCCESS for success and AVCDEC_FAIL otherwise."
See also PostPOC() for initialization of some variables.
*/
AVCDec_Status DecodePOC(AVCCommonObj *video);



/*------------ residual.c ------------------*/
/**
This function decodes the intra pcm data and fill it in the corresponding location
on the current picture.
\param "video"  "Pointer to AVCCommonObj."
\param "stream" "Pointer to AVCDecBitstream."
*/
AVCDec_Status DecodeIntraPCM(AVCCommonObj *video, AVCDecBitstream *stream);

/**
This function performs residual syntax decoding as well as quantization and transformation of
the decoded coefficients. See subclause 7.3.5.3.
\param "video"  "Pointer to AVCDecObject."
\param "currMB" "Pointer to current macroblock."
*/
AVCDec_Status residual(AVCDecObject *video, AVCMacroblock *currMB);

/**
This function performs CAVLC syntax decoding to get the run and level information of the coefficients.
\param "video"  "Pointer to AVCDecObject."
\param "type"   "One of AVCResidualType for a particular 4x4 block."
\param "bx"     "Horizontal block index."
\param "by"     "Vertical block index."
\param "level"  "Pointer to array of level for output."
\param "run"    "Pointer to array of run for output."
\param "numcoeff"   "Pointer to the total number of nonzero coefficients."
\return "AVCDEC_SUCCESS for success."
*/
AVCDec_Status residual_block_cavlc(AVCDecObject *video, int nC, int maxNumCoeff,
                                   int *level, int *run, int *numcoeff);

#endif /* _AVCDEC_LIB_H_ */