• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
19 This file contains application function interfaces to the AVC decoder library
20 and necessary type defitionitions and enumerations.
21 @publishedAll
22 */
23 
24 #ifndef _AVCDEC_API_H_
25 #define _AVCDEC_API_H_
26 
27 #ifndef OSCL_BASE_H_INCLUDED
28 #include "oscl_base.h"
29 #endif
30 
31 #include "avcapi_common.h"
32 
33 /**
34  This enumeration is used for the status returned from the library interface.
35 */
36 typedef enum
37 {
38     /**
39     The followings are fail with details. Their values are negative.
40     */
41     AVCDEC_NO_DATA = -4,
42     AVCDEC_PACKET_LOSS = -3,
43     /**
44     Fail information
45     */
46     AVCDEC_NO_BUFFER = -2, /* no output picture buffer available */
47     AVCDEC_MEMORY_FAIL = -1, /* memory allocation failed */
48     AVCDEC_FAIL = 0,
49     /**
50     Generic success value
51     */
52     AVCDEC_SUCCESS = 1,
53     AVCDEC_PICTURE_OUTPUT_READY = 2,
54     AVCDEC_PICTURE_READY = 3,
55 
56     /**
57     The followings are success with warnings. Their values are positive integers.
58     */
59     AVCDEC_NO_NEXT_SC = 4,
60     AVCDEC_REDUNDANT_FRAME = 5,
61     AVCDEC_CONCEALED_FRAME = 6  /* detect and conceal the error */
62 } AVCDec_Status;
63 
64 
65 /**
66 This structure contains sequence parameters information.
67 */
68 typedef struct tagAVCDecSPSInfo
69 {
70     int FrameWidth;
71     int FrameHeight;
72     uint frame_only_flag;
73     int  frame_crop_left;
74     int  frame_crop_right;
75     int  frame_crop_top;
76     int  frame_crop_bottom;
77 
78 } AVCDecSPSInfo;
79 
80 
81 #ifdef __cplusplus
82 extern "C"
83 {
84 #endif
85     /** THE FOLLOWINGS ARE APIS */
86     /**
87     This function parses one NAL unit from byte stream format input according to Annex B.
88     \param "bitstream"  "Pointer to the bitstream buffer."
89     \param "nal_unit"   "Point to pointer and the location of the start of the first NAL unit
90                          found in bitstream."
91     \param "size"       "As input, the pointer to the size of bitstream in bytes. As output,
92                          the value is changed to be the size of the found NAL unit."
93     \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL if no first start code is found, AVCDEC_NO_NEX_SC if
94             the first start code is found, but the second start code is missing (potential partial NAL)."
95     */
96     OSCL_IMPORT_REF AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit, int *size);
97 
98     /**
99     This function sniffs the nal_unit_type such that users can call corresponding APIs.
100     \param "bitstream"  "Pointer to the beginning of a NAL unit (start with forbidden_zero_bit, etc.)."
101     \param "size"       "size of the bitstream (NumBytesInNALunit + 1)."
102     \param "nal_unit_type" "Pointer to the return value of nal unit type."
103     \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL otherwise."
104     */
105     OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
106 
107     /**
108     This function decodes the sequence parameters set, initializes related parameters and
109     allocates memory (reference frames list), must also be compliant with Annex A.
110     It is equivalent to decode VOL header of MPEG4.
111     \param "avcHandle"  "Handle to the AVC decoder library object."
112     \param "nal_unit"   "Pointer to the buffer containing single NAL unit.
113                         The content will change due to EBSP-to-RBSP conversion."
114     \param "nal_size"       "size of the bitstream NumBytesInNALunit."
115     \return "AVCDEC_SUCCESS if success,
116             AVCDEC_FAIL if profile and level is not supported,
117             AVCDEC_MEMORY_FAIL if memory allocations return null."
118     */
119     OSCL_IMPORT_REF AVCDec_Status PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
120 
121     /**
122     This function returns sequence parameters such as dimension and field flag of the most recently
123     decoded SPS. More can be added later or grouped together into a structure. This API can be called
124     after PVAVCInitSequence. If no sequence parameter has been decoded yet, it will return AVCDEC_FAIL.
125 
126     \param "avcHandle"  "Handle to the AVC decoder library object."
127     \param "seqInfo"    "Pointer to the AVCDecSeqParamInfo structure."
128     \return "AVCDEC_SUCCESS if success and AVCDEC_FAIL if fail."
129     \note "This API can be combined with PVAVCInitSequence if wanted to be consistent with m4vdec lib."
130     */
131     OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo);
132 
133     /**
134     This function decodes the picture parameters set and initializes related parameters. Note thate
135     the PPS may not be present for every picture.
136     \param "avcHandle"  "Handle to the AVC decoder library object."
137     \param "nal_unit"   "Pointer to the buffer containing single NAL unit.
138                         The content will change due to EBSP-to-RBSP conversion."
139     \param "nal_size"       "size of the bitstream NumBytesInNALunit."
140     \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL if profile and level is not supported."
141     */
142     OSCL_IMPORT_REF AVCDec_Status PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
143 
144     /**
145     This function decodes one NAL unit of bitstream. The type of nal unit is one of the
146     followings, 1, 5. (for now, no data partitioning, type 2,3,4).
147     \param "avcHandle"  "Handle to the AVC decoder library object."
148     \param "nal_unit"   "Pointer to the buffer containing a single or partial NAL unit.
149                         The content will change due to EBSP-to-RBSP conversion."
150     \param "buf_size"   "Size of the buffer (less than or equal nal_size)."
151     \param "nal_size"   "size of the current NAL unit NumBytesInNALunit."
152     \return "AVCDEC_PICTURE_READY for success and an output is ready,
153             AVCDEC_SUCCESS for success but no output is ready,
154             AVCDEC_PACKET_LOSS is GetData returns AVCDEC_PACKET_LOSS,
155             AVCDEC_FAIL if syntax error is detected,
156             AVCDEC_MEMORY_FAIL if memory is corrupted.
157             AVCDEC_NO_PICTURE if no frame memory to write to (users need to get output and/or return picture).
158             AVCDEC_REDUNDANT_PICTURE if error has been detected in the primary picture and redundant picture is available,
159             AVCDEC_CONCEALED_PICTURE if error has been detected and decoder has concealed it."
160     */
161     OSCL_IMPORT_REF AVCDec_Status PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
162 
163     OSCL_IMPORT_REF AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer, int buf_size);
164 
165     /**
166     Check the availability of the decoded picture in decoding order (frame_num).
167     The AVCFrameIO also provide displaying order information such that the application
168     can re-order the frame for display. A picture can be retrieved only once.
169     \param "avcHandle"  "Handle to the AVC decoder library object."
170     \param "output"      "Pointer to the AVCOutput structure. Note that decoder library will
171                         not re-used the pixel memory in this structure until it has been returned
172                         thru PVAVCReleaseOutput API."
173     \return "AVCDEC_SUCCESS for success, AVCDEC_FAIL if no picture is available to be displayed,
174             AVCDEC_PICTURE_READY if there is another picture to be displayed."
175     */
176     OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release_flag, AVCFrameIO *output);
177 
178     /**
179     This function resets the decoder and expects to see the next IDR slice.
180     \param "avcHandle"  "Handle to the AVC decoder library object."
181     */
182     OSCL_IMPORT_REF void    PVAVCDecReset(AVCHandle *avcHandle);
183 
184     /**
185     This function performs clean up operation including memory deallocation.
186     \param "avcHandle"  "Handle to the AVC decoder library object."
187     */
188     OSCL_IMPORT_REF void    PVAVCCleanUpDecoder(AVCHandle *avcHandle);
189 //AVCDec_Status EBSPtoRBSP(uint8 *nal_unit,int *size);
190 
191 
192 
193     /** CALLBACK FUNCTION TO BE IMPLEMENTED BY APPLICATION */
194     /** In AVCHandle structure, userData is a pointer to an object with the following
195         member functions.
196     */
197     AVCDec_Status CBAVCDec_GetData(uint32 *userData, unsigned char **buffer, unsigned int *size);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* _AVCDEC_API_H_ */
204 
205