summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/m4v_h263/dec/src/mp4dec_lib.h
blob: 9cd4edc359ad9df9d1c10a11304a703fbda54c5d (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
/* ------------------------------------------------------------------
 * 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.
 * -------------------------------------------------------------------
 */
#ifndef _MP4DECLIB_H_
#define _MP4DECLIB_H_

/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "mp4def.h" /* typedef */
#include "mp4lib_int.h" /* main video structure */

/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

    /* defined in pvdec_api.c, these function are not supposed to be    */
    /* exposed to programmers outside PacketVideo.  08/15/2000.    */
    uint VideoDecoderErrorDetected(VideoDecData *video);

#ifdef ENABLE_LOG
    void m4vdec_dprintf(char *format, ...);
#define mp4dec_log(message) m4vdec_dprintf(message)
#else
#define mp4dec_log(message)
#endif

    /*--------------------------------------------------------------------------*/
    /* defined in frame_buffer.c */
    PV_STATUS FillFrameBufferNew(BitstreamDecVideo *stream);
    PV_STATUS FillFrameBuffer(BitstreamDecVideo *stream, int short_header);

    /*--------------------------------------------------------------------------*/
    /* defined in dc_ac_pred.c */
    int cal_dc_scaler(int QP, int type);
    PV_STATUS PV_DecodePredictedIntraDC(int compnum, BitstreamDecVideo *stream,
                                        int16 *IntraDC_delta);

    void    doDCACPrediction(VideoDecData *video, int comp, int16 *q_block,
                             int *direction);

#ifdef PV_ANNEX_IJKT_SUPPORT
    void    doDCACPrediction_I(VideoDecData *video, int comp, int16 *q_block);
#endif
    /*--------------------------------------------------------------------------*/
    /* defined in block_idct.c */
    void MBlockIDCTAdd(VideoDecData *video, int nz_coefs[]);

    void BlockIDCT(uint8 *dst, uint8 *pred, int16 *blk, int width, int nzcoefs,
                   uint8 *bitmapcol, uint8 bitmaprow);

    void MBlockIDCT(VideoDecData *video);
    void BlockIDCT_intra(MacroBlock *mblock, PIXEL *c_comp, int comp, int width_offset);
    /*--------------------------------------------------------------------------*/
    /* defined in combined_decode.c */
    PV_STATUS DecodeFrameCombinedMode(VideoDecData *video);
    PV_STATUS GetMBheader(VideoDecData *video, int16 *QP);
    PV_STATUS GetMBData(VideoDecData *video);

    /*--------------------------------------------------------------------------*/
    /* defined in datapart_decode.c */
    PV_STATUS DecodeFrameDataPartMode(VideoDecData *video);
    PV_STATUS GetMBheaderDataPart_DQUANT_DC(VideoDecData *video, int16 *QP);
    PV_STATUS GetMBheaderDataPart_P(VideoDecData *video);
    PV_STATUS DecodeDataPart_I_VideoPacket(VideoDecData *video, int slice_counter);
    PV_STATUS DecodeDataPart_P_VideoPacket(VideoDecData *video, int slice_counter);
    PV_STATUS GetMBData_DataPart(VideoDecData *video);

    /*--------------------------------------------------------------------------*/
    /* defined in packet_util.c */
    PV_STATUS PV_ReadVideoPacketHeader(VideoDecData *video, int *next_MB);
    PV_STATUS RecoverPacketError(BitstreamDecVideo *stream, int marker_length, int32 *nextVop);
    PV_STATUS RecoverGOBError(BitstreamDecVideo *stream, int marker_length, int32 *vopPos);
    PV_STATUS PV_GobHeader(VideoDecData *video);
#ifdef PV_ANNEX_IJKT_SUPPORT
    PV_STATUS PV_H263SliceHeader(VideoDecData *videoInt, int *next_MB);
#endif
    /*--------------------------------------------------------------------------*/
    /* defined in motion_comp.c */
    void MBMotionComp(VideoDecData *video, int CBP);
    void  SkippedMBMotionComp(VideoDecData *video);

    /*--------------------------------------------------------------------------*/
    /* defined in chrominance_pred.c */
    void chrominance_pred(
        int xpred,          /* i */
        int ypred,          /* i */
        uint8 *cu_prev,     /* i */
        uint8 *cv_prev,     /* i */
        uint8 *pred_block,  /* i */
        int width_uv,       /* i */
        int height_uv,      /* i */
        int round1
    );

    /*--------------------------------------------------------------------------*/
    /* defined in luminance_pred_mode_inter.c */
    void luminance_pred_mode_inter(
        int xpred,          /* i */
        int ypred,          /* i */
        uint8 *c_prev,      /* i */
        uint8 *pred_block,  /* i */
        int width,          /* i */
        int height,         /* i */
        int round1
    );

    /*--------------------------------------------------------------------------*/
    /* defined in luminance_pred_mode_inter4v.c */
    void luminance_pred_mode_inter4v(
        int xpos,           /* i */
        int ypos,           /* i */
        MOT *px,            /* i */
        MOT *py,            /* i */
        uint8 *c_prev,      /* i */
        uint8 *pred_block,  /* i */
        int width,          /* i */
        int height,         /* i */
        int round1,         /* i */
        int mvwidth,            /* i */
        int *xsum_ptr,          /* i/o */
        int *ysum_ptr           /* i/o */
    );

    /*--------------------------------------------------------------------------*/
    /* defined in pp_semaphore_chroma_inter.c */
#ifdef PV_POSTPROC_ON
    void pp_semaphore_chroma_inter(
        int xpred,      /* i */
        int ypred,      /* i */
        uint8   *pp_dec_u,  /* i/o */
        uint8   *pstprcTypPrv,  /* i */
        int dx,     /* i */
        int dy,     /* i */
        int mvwidth,    /* i */
        int height,     /* i */
        int32   size,       /* i */
        int mv_loc,     /* i */
        uint8   msk_deblock /* i */
    );

    /*--------------------------------------------------------------------------*/
    /* defined in pp_semaphore_luma.c */
    uint8 pp_semaphore_luma(
        int xpred,      /* i */
        int ypred,      /* i */
        uint8   *pp_dec_y,  /* i/o */
        uint8   *pstprcTypPrv,  /* i */
        int *ll,        /* i */
        int *mv_loc,    /* i/o */
        int dx,     /* i */
        int dy,     /* i */
        int mvwidth,    /* i */
        int width,      /* i */
        int height      /* i */
    );
#endif
    /*--------------------------------------------------------------------------*/
    /* defined in get_pred_adv_mb_add.c */
    int GetPredAdvancedMB(
        int xpos,
        int ypos,
        uint8 *c_prev,
        uint8 *pred_block,
        int width,
        int rnd1
    );

    /*--------------------------------------------------------------------------*/
    /* defined in get_pred_adv_b_add.c */
    int GetPredAdvancedBy0x0(
        uint8 *c_prev,      /* i */
        uint8 *pred_block,      /* i */
        int width,      /* i */
        int pred_width_rnd /* i */
    );

    int GetPredAdvancedBy0x1(
        uint8 *c_prev,      /* i */
        uint8 *pred_block,      /* i */
        int width,      /* i */
        int pred_width_rnd /* i */
    );

    int GetPredAdvancedBy1x0(
        uint8 *c_prev,      /* i */
        uint8 *pred_block,      /* i */
        int width,      /* i */
        int pred_width_rnd /* i */
    );

    int GetPredAdvancedBy1x1(
        uint8 *c_prev,      /* i */
        uint8 *pred_block,      /* i */
        int width,      /* i */
        int pred_width_rnd /* i */
    );

    /*--------------------------------------------------------------------------*/
    /* defined in get_pred_outside.c */
    int GetPredOutside(
        int xpos,
        int ypos,
        uint8 *c_prev,
        uint8 *pred_block,
        int width,
        int height,
        int rnd1,
        int pred_width
    );

    /*--------------------------------------------------------------------------*/
    /* defined in find_pmvsErrRes.c */
    void mv_prediction(VideoDecData *video, int block, MOT *mvx, MOT *mvy);

    /*--------------------------------------------------------------------------*/

    /*--------------------------------------------------------------------------*/
    /* defined in mb_utils.c */
    void Copy_MB_into_Vop(uint8 *comp, int yChan[][NCOEFF_BLOCK], int width);
    void Copy_B_into_Vop(uint8 *comp, int cChan[], int width);
    void PutSKIPPED_MB(uint8 *comp, uint8 *c_prev, int width);
    void PutSKIPPED_B(uint8 *comp, uint8 *c_prev, int width);

    /*--------------------------------------------------------------------------*/
    /* defined in vop.c */
    PV_STATUS DecodeGOVHeader(BitstreamDecVideo *stream, uint32 *time_base);
    PV_STATUS DecodeVOLHeader(VideoDecData *video, int layer);
    PV_STATUS DecodeVOPHeader(VideoDecData *video, Vop *currVop, Bool use_ext_tiemstamp);
    PV_STATUS DecodeShortHeader(VideoDecData *video, Vop *currVop);
    PV_STATUS PV_DecodeVop(VideoDecData *video);
    uint32 CalcVopDisplayTime(Vol *currVol, Vop *currVop, int shortVideoHeader);

    /*--------------------------------------------------------------------------*/
    /* defined in post_proc.c */
#ifdef PV_ANNEX_IJKT_SUPPORT
    void H263_Deblock(uint8 *rec,   int width, int height, int16 *QP_store, uint8 *mode, int chr, int T);
#endif
    int  PostProcSemaphore(int16 *q_block);
    void PostFilter(VideoDecData *video, int filer_type, uint8 *output);
    void FindMaxMin(uint8 *ptr, int *min, int *max, int incr);
    void DeringAdaptiveSmoothMMX(uint8 *img, int incr, int thres, int mxdf);
    void AdaptiveSmooth_NoMMX(uint8 *Rec_Y, int v0, int h0, int v_blk, int h_blk,
                              int thr, int width, int max_diff);
    void Deringing_Luma(uint8 *Rec_Y, int width, int height, int16 *QP_store,
                        int Combined, uint8 *pp_mod);
    void Deringing_Chroma(uint8 *Rec_C, int width, int height, int16 *QP_store,
                          int Combined, uint8 *pp_mod);
    void CombinedHorzVertFilter(uint8 *rec, int width, int height, int16 *QP_store,
                                int chr, uint8 *pp_mod);
    void CombinedHorzVertFilter_NoSoftDeblocking(uint8 *rec, int width, int height, int16 *QP_store,
            int chr, uint8 *pp_mod);
    void CombinedHorzVertRingFilter(uint8 *rec, int width, int height,
                                    int16 *QP_store, int chr, uint8 *pp_mod);

    /*--------------------------------------------------------------------------*/
    /* defined in conceal.c */
    void ConcealTexture_I(VideoDecData *video, int32 startFirstPartition, int mb_start, int mb_stop,
                          int slice_counter);
    void ConcealTexture_P(VideoDecData *video, int mb_start, int mb_stop,
                          int slice_counter);
    void ConcealPacket(VideoDecData *video, int mb_start, int mb_stop,
                       int slice_counter);
    void CopyVopMB(Vop *curr, uint8 *prev, int mbnum, int width, int height);

    /* define in vlc_dequant.c ,  09/18/2000*/
#ifdef PV_SUPPORT_MAIN_PROFILE
    int VlcDequantMpegIntraBlock(void *video, int comp, int switched,
                                 uint8 *bitmapcol, uint8 *bitmaprow);
    int VlcDequantMpegInterBlock(void *video, int comp,
                                 uint8 *bitmapcol, uint8 *bitmaprow);
#endif
    int VlcDequantH263IntraBlock(VideoDecData *video, int comp, int switched,
                                 uint8 *bitmapcol, uint8 *bitmaprow);
    int VlcDequantH263IntraBlock_SH(VideoDecData *video, int comp,
                                    uint8 *bitmapcol, uint8 *bitmaprow);
    int VlcDequantH263InterBlock(VideoDecData *video, int comp,
                                 uint8 *bitmapcol, uint8 *bitmaprow);

#ifdef __cplusplus
}
#endif /* __cplusplus */

/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif