PageRenderTime 444ms CodeModel.GetById 121ms app.highlight 10ms RepoModel.GetById 110ms app.codeStats 0ms

/Show/avc/avcapi_common.h

http://github.com/mbebenita/Broadway
C Header | 276 lines | 105 code | 46 blank | 125 comment | 0 complexity | 8515cc64c0b9470e95e7aa84d35f6cf6 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 common type definitions and enumerations used by AVC encoder
 20and decoder libraries which are exposed to the users.
 21@publishedAll
 22*/
 23
 24#ifndef AVCAPI_COMMON_H_INCLUDED
 25#define AVCAPI_COMMON_H_INCLUDED
 26
 27#include "avc_types.h"
 28
 29// #define PV_MEMORY_POOL
 30
 31
 32/**
 33This is common return status.
 34@publishedAll
 35*/
 36typedef enum
 37{
 38    AVC_NO_BUFFER = -2,
 39    AVC_MEMORY_FAIL = -1,
 40    AVC_FAIL = 0,
 41    AVC_SUCCESS = 1,
 42    AVC_PICTURE_OUTPUT_READY = 2
 43} AVCStatus;
 44
 45/**
 46This enumeration is for profiles. The value follows the profile_idc  in sequence
 47parameter set rbsp. See Annex A.
 48@publishedAll
 49*/
 50typedef enum
 51{
 52    AVC_BASELINE = 66,
 53    AVC_MAIN = 77,
 54    AVC_EXTENDED = 88,
 55    AVC_HIGH = 100,
 56    AVC_HIGH10 = 110,
 57    AVC_HIGH422 = 122,
 58    AVC_HIGH444 = 144
 59} AVCProfile;
 60
 61/**
 62This enumeration is for levels. The value follows the level_idc in sequence
 63parameter set rbsp. See Annex A.
 64@published All
 65*/
 66typedef enum
 67{
 68    AVC_LEVEL_AUTO = 0,
 69    AVC_LEVEL1_B = 9,
 70    AVC_LEVEL1 = 10,
 71    AVC_LEVEL1_1 = 11,
 72    AVC_LEVEL1_2 = 12,
 73    AVC_LEVEL1_3 = 13,
 74    AVC_LEVEL2 = 20,
 75    AVC_LEVEL2_1 = 21,
 76    AVC_LEVEL2_2 = 22,
 77    AVC_LEVEL3 = 30,
 78    AVC_LEVEL3_1 = 31,
 79    AVC_LEVEL3_2 = 32,
 80    AVC_LEVEL4 = 40,
 81    AVC_LEVEL4_1 = 41,
 82    AVC_LEVEL4_2 = 42,
 83    AVC_LEVEL5 = 50,
 84    AVC_LEVEL5_1 = 51
 85} AVCLevel;
 86
 87/**
 88This enumeration follows Table 7-1 for NAL unit type codes.
 89This may go to avccommon_api.h later (external common).
 90@publishedAll
 91*/
 92typedef enum
 93{
 94    AVC_NALTYPE_SLICE = 1,  /* non-IDR non-data partition */
 95    AVC_NALTYPE_DPA = 2,    /* data partition A */
 96    AVC_NALTYPE_DPB = 3,    /* data partition B */
 97    AVC_NALTYPE_DPC = 4,    /* data partition C */
 98    AVC_NALTYPE_IDR = 5,    /* IDR NAL */
 99    AVC_NALTYPE_SEI = 6,    /* supplemental enhancement info */
100    AVC_NALTYPE_SPS = 7,    /* sequence parameter set */
101    AVC_NALTYPE_PPS = 8,    /* picture parameter set */
102    AVC_NALTYPE_AUD = 9,    /* access unit delimiter */
103    AVC_NALTYPE_EOSEQ = 10, /* end of sequence */
104    AVC_NALTYPE_EOSTREAM = 11, /* end of stream */
105    AVC_NALTYPE_FILL = 12   /* filler data */
106} AVCNalUnitType;
107
108/**
109This enumeration specifies debug logging type.
110This may go to avccommon_api.h later (external common).
111@publishedAll
112*/
113typedef enum
114{
115    AVC_LOGTYPE_ERROR = 0,
116    AVC_LOGTYPE_WARNING = 1,
117    AVC_LOGTYPE_INFO = 2
118} AVCLogType;
119
120/**
121This enumerate the status of certain flags.
122@publishedAll
123*/
124typedef enum
125{
126    AVC_OFF = 0,
127    AVC_ON = 1
128} AVCFlag;
129
130/**
131This structure contains input information.
132Note, this structure is identical to AVCDecOutput for now.
133*/
134typedef struct tagAVCFrameIO
135{
136    /** A unique identification number for a particular instance of this structure.
137    To remain unchanged by the application between the time when it is given to the
138    library and the time when the library returns it back. */
139	uintptr_t id;
140
141    /** Array of pointers to Y,Cb,Cr content in 4:2:0 format. For AVC decoding,
142    this memory is allocated by the AVC decoder library. For AVC encoding, only the
143    memory for original unencoded frame is allocated by the application. Internal
144    memory is also allocated by the AVC encoder library. */
145    uint8 *YCbCr[3];
146
147    /** In/Out: Coded width of the luma component, it has to be multiple of 16. */
148    int pitch;
149
150    /** In/Out: Coded height of the luma component, must be multiple of 16. */
151    int height;
152
153    /** In/Out: Display width, less than picth */
154    int clip_width;
155
156    /** In/Out: Display height, less than height */
157    int clip_height;
158
159    /** Input: Origin of the display area [0]=>row, [1]=>column  */
160    int clip_origin[2];
161
162    /** Output: Frame number in de/encoding order (not necessary)*/
163    uint32 coding_order;
164
165    /** Output: Frame number in displaying order (this may or may not be associated with the POC at all!!!). */
166    uint32 disp_order;
167
168    /** In/Out: Flag for use for reference or not. */
169    uint  is_reference;
170
171    /** In/Out: Coding timestamp in msec (not display timestamp) */
172    uint32 coding_timestamp;
173
174    /* there could be something else here such as format, DON (decoding order number)
175     if available thru SEI, etc. */
176} AVCFrameIO;
177
178
179/** CALLBACK FUNCTION TO BE IMPLEMENTED BY APPLICATION */
180/** In AVCDecControls structure, userData is a pointer to an object with the following
181    member functions.
182*/
183
184
185/** @brief Decoded picture buffers (DPB) must be allocated or re-allocated before an
186    IDR frame is decoded. If PV_MEMORY_POOL is not defined, AVC lib will allocate DPB
187    internally which cannot be shared with the application. In that case, this function
188    will not be called.
189    @param userData  The same value of userData in AVCHandle object.
190    @param frame_size_in_mbs  The size of each frame in number of macroblocks.
191    @param num_frames The number of frames in DPB.
192    @return 1 for success, 0 for fail (cannot allocate DPB)
193*/
194
195typedef int (*FunctionType_DPBAlloc)(void *userData, uint frame_size_in_mbs, uint num_buffers);
196
197/** @brief AVC library calls this function is reserve a memory of one frame from the DPB.
198    Once reserved, this frame shall not be deleted or over-written by the app.
199    @param userData  The same value of userData in AVCHandle object.
200    @param indx      Index of a frame in DPB (AVC library keeps track of the index).
201    @param yuv      The address of the yuv pointer returned to the AVC lib.
202    @return         1 for success, 0 for fail (no frames available to bind).
203    */
204typedef int (*FunctionType_FrameBind)(void *userData, int indx, uint8 **yuv);
205
206/** @brief AVC library calls this function once a bound frame is not needed for decoding
207    operation (falls out of the sliding window, or marked unused for reference).
208    @param userData  The same value of userData in AVCHandle object.
209    @param indx      Index of frame to be unbound (AVC library keeps track of the index).
210    @return  none.
211*/
212typedef void (*FuctionType_FrameUnbind)(void *userData, int);
213
214/** Pointer to malloc function for general memory allocation, so that application can keep track of
215    memory usage.
216\param "size" "Size of requested memory in bytes."
217\param "attribute" "Some value specifying types, priority, etc. of the memory."
218\return "The address of the allocated memory casted to int"size
219*/
220typedef uintptr_t (*FunctionType_Malloc)(void *userData, int32 size, int attribute);
221
222/** Function pointer to free
223\param "mem" "Pointer to the memory to be freed casted to int"
224\return "void"
225*/
226typedef void (*FunctionType_Free)(void *userData, uintptr_t mem);
227
228/** Debug logging information is returned to the application thru this function.
229\param "type"   "Type of logging message, see definition of AVCLogType."
230\param "string1"    "Logging message."
231\param "string2"    "To be defined."
232*/
233typedef void (*FunctionType_DebugLog)(uint32 *userData, AVCLogType type, char *string1, int val1, int val2);
234
235/**
236This structure has to be allocated and maintained by the user of the library.
237This structure is used as a handle to the library object.
238*/
239typedef struct tagAVCHandle
240{
241    /** A pointer to the internal data structure. Users have to make sure that this value
242        is NULL at the beginning.
243    */
244    void        *AVCObject;
245
246    /** A pointer to user object which has the following member functions used for
247    callback purpose.  !!! */
248    void        *userData;
249
250    /** Pointers to functions implemented by the users of AVC library */
251    FunctionType_DPBAlloc CBAVC_DPBAlloc;
252
253    FunctionType_FrameBind CBAVC_FrameBind;
254
255    FuctionType_FrameUnbind CBAVC_FrameUnbind;
256
257    FunctionType_Malloc CBAVC_Malloc;
258
259    FunctionType_Free  CBAVC_Free;
260
261    FunctionType_DebugLog CBAVC_DebugLog;
262
263    /** Flag to enable debugging */
264    uint32  debugEnable;
265
266} AVCHandle;
267
268
269
270#ifdef PVDEBUGMSG_LOG
271#define DEBUG_LOG(a,b,c,d,e)    CBAVC_DebugLog(a,b,c,d,e)
272#else
273#define DEBUG_LOG(a,b,c,d,e)
274#endif
275
276#endif /* _AVCAPI_COMMON_H_ */