PageRenderTime 123ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 52ms app.codeStats 1ms

/Show/avc/avcdec_api.h

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