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 _MP4DEC_API_H_
19 #define _MP4DEC_API_H_
20 
21 #include "m4vh263_decoder_pv_types.h"
22 
23 // #define PV_TOLERATE_VOL_ERRORS
24 #define PV_MEMORY_POOL
25 
26 #ifndef _PV_TYPES_
27 #define _PV_TYPES_
28 
29 typedef uint Bool;
30 
31 #define PV_CODEC_INIT  0
32 #define PV_CODEC_STOP  1
33 #endif
34 
35 #define PV_TRUE  1
36 #define PV_FALSE 0
37 
38 #ifndef OSCL_IMPORT_REF
39 #define OSCL_IMPORT_REF /* empty */
40 #endif
41 #ifndef OSCL_EXPORT_REF
42 #define OSCL_EXPORT_REF /* empty */
43 #endif
44 
45 
46 #define PV_NO_POST_PROC 0
47 #define PV_DEBLOCK 1
48 #define PV_DERING  2
49 
50 
51 
52 #include "visual_header.h" // struct VolInfo is defined
53 
54 
55 /**@name Structure and Data Types
56  * These type definitions specify the input / output from the PVMessage
57  * library.
58  */
59 
60 /*@{*/
61 /* The application has to allocate space for this structure */
62 typedef struct tagOutputFrame
63 {
64     uint8       *data;          /* pointer to output YUV buffer */
65     uint32      timeStamp;      /* time stamp */
66 } OutputFrame;
67 
68 typedef struct tagApplicationData
69 {
70     int layer;          /* current video layer */
71     void *object;       /* some optional data field */
72 } applicationData;
73 
74 /* Application controls, this structed shall be allocated */
75 /*    and initialized in the application.                 */
76 typedef struct tagvideoDecControls
77 {
78     /* The following fucntion pointer is copied to BitstreamDecVideo structure  */
79     /*    upon initialization and never used again. */
80     int (*readBitstreamData)(uint8 *buf, int nbytes_required, void *appData);
81     applicationData appData;
82 
83     uint8 *outputFrame;
84     void *videoDecoderData;     /* this is an internal pointer that is only used */
85     /* in the decoder library.   */
86 #ifdef PV_MEMORY_POOL
87     int32 size;
88 #endif
89     int nLayers;
90     /* pointers to VOL data for frame-based decoding. */
91     uint8 *volbuf[2];           /* maximum of 2 layers for now */
92     int32 volbuf_size[2];
93 
94 } VideoDecControls;
95 
96 typedef enum
97 {
98     H263_MODE = 0, MPEG4_MODE, UNKNOWN_MODE
99 } MP4DecodingMode;
100 
101 typedef enum
102 {
103     MP4_I_FRAME, MP4_P_FRAME, MP4_B_FRAME, MP4_BAD_FRAME
104 } MP4FrameType;
105 
106 typedef struct tagVopHeaderInfo
107 {
108     int     currLayer;
109     uint32  timestamp;
110     MP4FrameType    frameType;
111     int     refSelCode;
112     int16       quantizer;
113 } VopHeaderInfo;
114 
115 /*--------------------------------------------------------------------------*
116  * VideoRefCopyInfo:
117  * OMAP DSP specific typedef structure, to support the user (ARM) copying
118  * of a Reference Frame into the Video Decoder.
119  *--------------------------------------------------------------------------*/
120 typedef struct tagVideoRefCopyInfoPtr
121 {
122     uint8   *yChan;             /* The Y component frame the user can copy a new reference to */
123     uint8   *uChan;             /* The U component frame the user can copy a new reference to */
124     uint8   *vChan;             /* The V component frame the user can copy a new reference to */
125     uint8   *currentVop;        /* The Vop for video the user can copy a new reference to */
126 } VideoRefCopyInfoPtr;
127 
128 typedef struct tagVideoRefCopyInfoData
129 {
130     int16   width;              /* Width */
131     int16   height;             /* Height */
132     int16   realWidth;          /* Non-padded width, not a multiple of 16. */
133     int16   realHeight;         /* Non-padded height, not a multiple of 16. */
134 } VideoRefCopyInfoData;
135 
136 typedef struct tagVideoRefCopyInfo
137 {
138     VideoRefCopyInfoData data;
139     VideoRefCopyInfoPtr ptrs;
140 } VideoRefCopyInfo;
141 
142 /*@}*/
143 
144 #ifdef __cplusplus
145 extern "C"
146 {
147 #endif
148 
149 
150     OSCL_IMPORT_REF Bool    PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[], int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode);
151     Bool    PVAllocVideoData(VideoDecControls *decCtrl, int width, int height, int nLayers);
152     OSCL_IMPORT_REF Bool    PVCleanUpVideoDecoder(VideoDecControls *decCtrl);
153     Bool    PVResetVideoDecoder(VideoDecControls *decCtrl);
154     OSCL_IMPORT_REF void    PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *refYUV);
155     Bool    PVDecSetReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp);
156     Bool    PVDecSetEnhReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp);
157     OSCL_IMPORT_REF Bool    PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *bitstream[], uint32 *timestamp, int32 *buffer_size, uint use_ext_timestamp[], uint8* currYUV);
158     Bool    PVDecodeVopHeader(VideoDecControls *decCtrl, uint8 *buffer[], uint32 timestamp[], int32 buffer_size[], VopHeaderInfo *header_info, uint use_ext_timestamp[], uint8 *currYUV);
159     Bool    PVDecodeVopBody(VideoDecControls *decCtrl, int32 buffer_size[]);
160     void    PVDecPostProcess(VideoDecControls *decCtrl, uint8 *outputYUV);
161     OSCL_IMPORT_REF void    PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height);
162     OSCL_IMPORT_REF void    PVGetBufferDimensions(VideoDecControls *decCtrl, int32 *buf_width, int32 *buf_height);
163     OSCL_IMPORT_REF void    PVSetPostProcType(VideoDecControls *decCtrl, int mode);
164     uint32  PVGetVideoTimeStamp(VideoDecControls *decoderControl);
165     int     PVGetDecBitrate(VideoDecControls *decCtrl);
166     int     PVGetDecFramerate(VideoDecControls *decCtrl);
167     uint8   *PVGetDecOutputFrame(VideoDecControls *decCtrl);
168     int     PVGetLayerID(VideoDecControls *decCtrl);
169     int32   PVGetDecMemoryUsage(VideoDecControls *decCtrl);
170     OSCL_IMPORT_REF MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl);
171     Bool    PVExtractVolHeader(uint8 *video_buffer, uint8 *vol_header, int32 *vol_header_size);
172     int32   PVLocateFrameHeader(uint8 *video_buffer, int32 vop_size);
173     int32   PVLocateH263FrameHeader(uint8 *video_buffer, int32 vop_size);
174     Bool    PVGetVolInfo(VideoDecControls *decCtrl, VolInfo *pVolInfo); // BX 6/24/04
175     Bool    IsIntraFrame(VideoDecControls *decoderControl);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 #endif /* _MP4DEC_API_H_ */
181 
182