mp4dec_lib.h revision 3306cfee3bf38ab207a0504e49c2d492bb73ffbf
1/* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18#ifndef _MP4DECLIB_H_
19#define _MP4DECLIB_H_
20
21/*----------------------------------------------------------------------------
22; INCLUDES
23----------------------------------------------------------------------------*/
24#include "mp4def.h" /* typedef */
25#include "mp4lib_int.h" /* main video structure */
26
27/*----------------------------------------------------------------------------
28; MACROS
29; Define module specific macros here
30----------------------------------------------------------------------------*/
31
32/*----------------------------------------------------------------------------
33; DEFINES
34; Include all pre-processor statements here.
35----------------------------------------------------------------------------*/
36
37/*----------------------------------------------------------------------------
38; EXTERNAL VARIABLES REFERENCES
39; Declare variables used in this module but defined elsewhere
40----------------------------------------------------------------------------*/
41
42/*----------------------------------------------------------------------------
43; SIMPLE TYPEDEF'S
44----------------------------------------------------------------------------*/
45
46/*----------------------------------------------------------------------------
47; ENUMERATED TYPEDEF'S
48----------------------------------------------------------------------------*/
49
50/*----------------------------------------------------------------------------
51; STRUCTURES TYPEDEF'S
52----------------------------------------------------------------------------*/
53
54/*----------------------------------------------------------------------------
55; GLOBAL FUNCTION DEFINITIONS
56; Function Prototype declaration
57----------------------------------------------------------------------------*/
58#ifdef __cplusplus
59extern "C"
60{
61#endif /* __cplusplus */
62
63    /* defined in pvdec_api.c, these function are not supposed to be    */
64    /* exposed to programmers outside PacketVideo.  08/15/2000.    */
65    uint VideoDecoderErrorDetected(VideoDecData *video);
66
67#ifdef ENABLE_LOG
68    void m4vdec_dprintf(char *format, ...);
69#define mp4dec_log(message) m4vdec_dprintf(message)
70#else
71#define mp4dec_log(message)
72#endif
73
74    /*--------------------------------------------------------------------------*/
75    /* defined in frame_buffer.c */
76    PV_STATUS FillFrameBufferNew(BitstreamDecVideo *stream);
77    PV_STATUS FillFrameBuffer(BitstreamDecVideo *stream, int short_header);
78
79    /*--------------------------------------------------------------------------*/
80    /* defined in dc_ac_pred.c */
81    int cal_dc_scaler(int QP, int type);
82    PV_STATUS PV_DecodePredictedIntraDC(int compnum, BitstreamDecVideo *stream,
83                                        int16 *IntraDC_delta);
84
85    void    doDCACPrediction(VideoDecData *video, int comp, int16 *q_block,
86                             int *direction);
87
88#ifdef PV_ANNEX_IJKT_SUPPORT
89    void    doDCACPrediction_I(VideoDecData *video, int comp, int16 *q_block);
90#endif
91    /*--------------------------------------------------------------------------*/
92    /* defined in block_idct.c */
93    void MBlockIDCTAdd(VideoDecData *video, int nz_coefs[]);
94
95    void BlockIDCT(uint8 *dst, uint8 *pred, int16 *blk, int width, int nzcoefs,
96                   uint8 *bitmapcol, uint8 bitmaprow);
97
98    void MBlockIDCT(VideoDecData *video);
99    void BlockIDCT_intra(MacroBlock *mblock, PIXEL *c_comp, int comp, int width_offset);
100    /*--------------------------------------------------------------------------*/
101    /* defined in combined_decode.c */
102    PV_STATUS DecodeFrameCombinedMode(VideoDecData *video);
103    PV_STATUS GetMBheader(VideoDecData *video, int16 *QP);
104    PV_STATUS GetMBData(VideoDecData *video);
105
106    /*--------------------------------------------------------------------------*/
107    /* defined in datapart_decode.c */
108    PV_STATUS DecodeFrameDataPartMode(VideoDecData *video);
109    PV_STATUS GetMBheaderDataPart_DQUANT_DC(VideoDecData *video, int16 *QP);
110    PV_STATUS GetMBheaderDataPart_P(VideoDecData *video);
111    PV_STATUS DecodeDataPart_I_VideoPacket(VideoDecData *video, int slice_counter);
112    PV_STATUS DecodeDataPart_P_VideoPacket(VideoDecData *video, int slice_counter);
113    PV_STATUS GetMBData_DataPart(VideoDecData *video);
114
115    /*--------------------------------------------------------------------------*/
116    /* defined in packet_util.c */
117    PV_STATUS PV_ReadVideoPacketHeader(VideoDecData *video, int *next_MB);
118    PV_STATUS RecoverPacketError(BitstreamDecVideo *stream, int marker_length, int32 *nextVop);
119    PV_STATUS RecoverGOBError(BitstreamDecVideo *stream, int marker_length, int32 *vopPos);
120    PV_STATUS PV_GobHeader(VideoDecData *video);
121#ifdef PV_ANNEX_IJKT_SUPPORT
122    PV_STATUS PV_H263SliceHeader(VideoDecData *videoInt, int *next_MB);
123#endif
124    /*--------------------------------------------------------------------------*/
125    /* defined in motion_comp.c */
126    void MBMotionComp(VideoDecData *video, int CBP);
127    void  SkippedMBMotionComp(VideoDecData *video);
128
129    /*--------------------------------------------------------------------------*/
130    /* defined in chrominance_pred.c */
131    void chrominance_pred(
132        int xpred,          /* i */
133        int ypred,          /* i */
134        uint8 *cu_prev,     /* i */
135        uint8 *cv_prev,     /* i */
136        uint8 *pred_block,  /* i */
137        int width_uv,       /* i */
138        int height_uv,      /* i */
139        int round1
140    );
141
142    /*--------------------------------------------------------------------------*/
143    /* defined in luminance_pred_mode_inter.c */
144    void luminance_pred_mode_inter(
145        int xpred,          /* i */
146        int ypred,          /* i */
147        uint8 *c_prev,      /* i */
148        uint8 *pred_block,  /* i */
149        int width,          /* i */
150        int height,         /* i */
151        int round1
152    );
153
154    /*--------------------------------------------------------------------------*/
155    /* defined in luminance_pred_mode_inter4v.c */
156    void luminance_pred_mode_inter4v(
157        int xpos,           /* i */
158        int ypos,           /* i */
159        MOT *px,            /* i */
160        MOT *py,            /* i */
161        uint8 *c_prev,      /* i */
162        uint8 *pred_block,  /* i */
163        int width,          /* i */
164        int height,         /* i */
165        int round1,         /* i */
166        int mvwidth,            /* i */
167        int *xsum_ptr,          /* i/o */
168        int *ysum_ptr           /* i/o */
169    );
170
171    /*--------------------------------------------------------------------------*/
172    /* defined in pp_semaphore_chroma_inter.c */
173#ifdef PV_POSTPROC_ON
174    void pp_semaphore_chroma_inter(
175        int xpred,      /* i */
176        int ypred,      /* i */
177        uint8   *pp_dec_u,  /* i/o */
178        uint8   *pstprcTypPrv,  /* i */
179        int dx,     /* i */
180        int dy,     /* i */
181        int mvwidth,    /* i */
182        int height,     /* i */
183        int32   size,       /* i */
184        int mv_loc,     /* i */
185        uint8   msk_deblock /* i */
186    );
187
188    /*--------------------------------------------------------------------------*/
189    /* defined in pp_semaphore_luma.c */
190    uint8 pp_semaphore_luma(
191        int xpred,      /* i */
192        int ypred,      /* i */
193        uint8   *pp_dec_y,  /* i/o */
194        uint8   *pstprcTypPrv,  /* i */
195        int *ll,        /* i */
196        int *mv_loc,    /* i/o */
197        int dx,     /* i */
198        int dy,     /* i */
199        int mvwidth,    /* i */
200        int width,      /* i */
201        int height      /* i */
202    );
203#endif
204    /*--------------------------------------------------------------------------*/
205    /* defined in get_pred_adv_mb_add.c */
206    int GetPredAdvancedMB(
207        int xpos,
208        int ypos,
209        uint8 *c_prev,
210        uint8 *pred_block,
211        int width,
212        int rnd1
213    );
214
215    /*--------------------------------------------------------------------------*/
216    /* defined in get_pred_adv_b_add.c */
217    int GetPredAdvancedBy0x0(
218        uint8 *c_prev,      /* i */
219        uint8 *pred_block,      /* i */
220        int width,      /* i */
221        int pred_width_rnd /* i */
222    );
223
224    int GetPredAdvancedBy0x1(
225        uint8 *c_prev,      /* i */
226        uint8 *pred_block,      /* i */
227        int width,      /* i */
228        int pred_width_rnd /* i */
229    );
230
231    int GetPredAdvancedBy1x0(
232        uint8 *c_prev,      /* i */
233        uint8 *pred_block,      /* i */
234        int width,      /* i */
235        int pred_width_rnd /* i */
236    );
237
238    int GetPredAdvancedBy1x1(
239        uint8 *c_prev,      /* i */
240        uint8 *pred_block,      /* i */
241        int width,      /* i */
242        int pred_width_rnd /* i */
243    );
244
245    /*--------------------------------------------------------------------------*/
246    /* defined in get_pred_outside.c */
247    int GetPredOutside(
248        int xpos,
249        int ypos,
250        uint8 *c_prev,
251        uint8 *pred_block,
252        int width,
253        int height,
254        int rnd1,
255        int pred_width
256    );
257
258    /*--------------------------------------------------------------------------*/
259    /* defined in find_pmvsErrRes.c */
260    void mv_prediction(VideoDecData *video, int block, MOT *mvx, MOT *mvy);
261
262    /*--------------------------------------------------------------------------*/
263
264    /*--------------------------------------------------------------------------*/
265    /* defined in mb_utils.c */
266    void Copy_MB_into_Vop(uint8 *comp, int yChan[][NCOEFF_BLOCK], int width);
267    void Copy_B_into_Vop(uint8 *comp, int cChan[], int width);
268    void PutSKIPPED_MB(uint8 *comp, uint8 *c_prev, int width);
269    void PutSKIPPED_B(uint8 *comp, uint8 *c_prev, int width);
270
271    /*--------------------------------------------------------------------------*/
272    /* defined in vop.c */
273    PV_STATUS DecodeGOVHeader(BitstreamDecVideo *stream, uint32 *time_base);
274    PV_STATUS DecodeVOLHeader(VideoDecData *video, int layer);
275    PV_STATUS DecodeVOPHeader(VideoDecData *video, Vop *currVop, Bool use_ext_tiemstamp);
276    PV_STATUS DecodeShortHeader(VideoDecData *video, Vop *currVop);
277    PV_STATUS PV_DecodeVop(VideoDecData *video);
278    uint32 CalcVopDisplayTime(Vol *currVol, Vop *currVop, int shortVideoHeader);
279
280    /*--------------------------------------------------------------------------*/
281    /* defined in post_proc.c */
282#ifdef PV_ANNEX_IJKT_SUPPORT
283    void H263_Deblock(uint8 *rec,   int width, int height, int16 *QP_store, uint8 *mode, int chr, int T);
284#endif
285    int  PostProcSemaphore(int16 *q_block);
286    void PostFilter(VideoDecData *video, int filer_type, uint8 *output);
287    void FindMaxMin(uint8 *ptr, int *min, int *max, int incr);
288    void DeringAdaptiveSmoothMMX(uint8 *img, int incr, int thres, int mxdf);
289    void AdaptiveSmooth_NoMMX(uint8 *Rec_Y, int v0, int h0, int v_blk, int h_blk,
290                              int thr, int width, int max_diff);
291    void Deringing_Luma(uint8 *Rec_Y, int width, int height, int16 *QP_store,
292                        int Combined, uint8 *pp_mod);
293    void Deringing_Chroma(uint8 *Rec_C, int width, int height, int16 *QP_store,
294                          int Combined, uint8 *pp_mod);
295    void CombinedHorzVertFilter(uint8 *rec, int width, int height, int16 *QP_store,
296                                int chr, uint8 *pp_mod);
297    void CombinedHorzVertFilter_NoSoftDeblocking(uint8 *rec, int width, int height, int16 *QP_store,
298            int chr, uint8 *pp_mod);
299    void CombinedHorzVertRingFilter(uint8 *rec, int width, int height,
300                                    int16 *QP_store, int chr, uint8 *pp_mod);
301
302    /*--------------------------------------------------------------------------*/
303    /* defined in conceal.c */
304    void ConcealTexture_I(VideoDecData *video, int32 startFirstPartition, int mb_start, int mb_stop,
305                          int slice_counter);
306    void ConcealTexture_P(VideoDecData *video, int mb_start, int mb_stop,
307                          int slice_counter);
308    void ConcealPacket(VideoDecData *video, int mb_start, int mb_stop,
309                       int slice_counter);
310    void CopyVopMB(Vop *curr, uint8 *prev, int mbnum, int width, int height);
311
312    /* define in vlc_dequant.c ,  09/18/2000*/
313#ifdef PV_SUPPORT_MAIN_PROFILE
314    int VlcDequantMpegIntraBlock(void *video, int comp, int switched,
315                                 uint8 *bitmapcol, uint8 *bitmaprow);
316    int VlcDequantMpegInterBlock(void *video, int comp,
317                                 uint8 *bitmapcol, uint8 *bitmaprow);
318#endif
319    int VlcDequantH263IntraBlock(VideoDecData *video, int comp, int switched,
320                                 uint8 *bitmapcol, uint8 *bitmaprow);
321    int VlcDequantH263IntraBlock_SH(VideoDecData *video, int comp,
322                                    uint8 *bitmapcol, uint8 *bitmaprow);
323    int VlcDequantH263InterBlock(VideoDecData *video, int comp,
324                                 uint8 *bitmapcol, uint8 *bitmaprow);
325
326#ifdef __cplusplus
327}
328#endif /* __cplusplus */
329
330/*----------------------------------------------------------------------------
331; END
332----------------------------------------------------------------------------*/
333#endif
334
335