OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / modules / codec.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005 \r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / modules interfaces\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 \r
26 \r
27 #ifndef _GF_MODULE_CODEC_H_\r
28 #define _GF_MODULE_CODEC_H_\r
29 \r
30 \r
31 #include <gpac/module.h>\r
32 #include <gpac/mpeg4_odf.h>\r
33 \r
34 #ifdef __cplusplus\r
35 extern "C" {\r
36 #endif\r
37 \r
38 /*multimedia processing levels*/\r
39 enum\r
40 {\r
41         /*normal, full processing*/\r
42         GF_CODEC_LEVEL_NORMAL,\r
43         /*codec is late, should scale down processing*/\r
44         GF_CODEC_LEVEL_LATE,\r
45         /*codec is very late, should turn off post-processing, even drop*/\r
46         GF_CODEC_LEVEL_VERY_LATE,\r
47         /*input frames are already late before decoding*/\r
48         GF_CODEC_LEVEL_DROP,\r
49         /*this is a special level indicating that a seek is happening (decode but no dispatch)\r
50         it is set dynamically*/\r
51         GF_CODEC_LEVEL_SEEK\r
52 };\r
53 \r
54 /*the structure for capabilities*/\r
55 typedef struct \r
56 {\r
57         /*cap code cf below*/\r
58         u16 CapCode;\r
59         union {\r
60                 u32 valueInt;\r
61                 Float valueFloat;\r
62         } cap;\r
63 } GF_CodecCapability;\r
64 \r
65 \r
66 /*\r
67                         all codecs capabilities\r
68 */\r
69 \r
70 enum\r
71 {\r
72         /*size of a single composition unit */\r
73         GF_CODEC_OUTPUT_SIZE =  0x01,\r
74         /*resilency: if packets are lost within an AU, resilience means the AU won't be discarded and the codec\r
75         will try to decode */\r
76         GF_CODEC_RESILIENT,\r
77         /*critical level of composition memory - if below, media management for the object */\r
78         GF_CODEC_BUFFER_MIN,\r
79         /*maximum size in CU of composition memory */\r
80         GF_CODEC_BUFFER_MAX,\r
81         /*flags that all AUs should be discarded till next RAP (needed in case RAPs are not carried by the transport\r
82         protocol */\r
83         GF_CODEC_WAIT_RAP,\r
84         /*number of padding bytes needed - if the decoder needs padding input cannot be pulled and data is duplicated*/\r
85         GF_CODEC_PADDING_BYTES,\r
86         /*codecs can be threaded at will - by default a single thread is used for all decoders and priority is handled\r
87         by the app, but a codec can configure itself to run in a dedicated thread*/\r
88         GF_CODEC_WANTS_THREAD,\r
89 \r
90         /*video width and height and horizontal pitch (in YV12 we assume half Y pitch for U and V planes) */\r
91         GF_CODEC_WIDTH,\r
92         GF_CODEC_HEIGHT,\r
93         GF_CODEC_STRIDE,\r
94         GF_CODEC_FPS,\r
95         /*Pixel Aspect Ratio, expressed as (par.num<<16) | par.den*/\r
96         GF_CODEC_PAR,\r
97         /*video color mode - color modes are defined in constants.h*/\r
98         GF_CODEC_PIXEL_FORMAT,\r
99         /*isgnal decoder performs frame re-ordering in temporal scalability*/\r
100         GF_CODEC_REORDER,\r
101         \r
102         /*Audio sample rate*/\r
103         GF_CODEC_SAMPLERATE,\r
104         /*Audio num channels*/\r
105         GF_CODEC_NB_CHAN,\r
106         /*Audio bps*/\r
107         GF_CODEC_BITS_PER_SAMPLE,\r
108         /*audio frame format*/\r
109         GF_CODEC_CHANNEL_CONFIG,\r
110         /*this is only used for audio in case transport mapping relies on sampleRate (RTP)\r
111         gets the CU duration in samplerate unit (type: int) */\r
112         GF_CODEC_CU_DURATION,\r
113 \r
114         /*This is only called on scene decoders to signal that potential overlay scene should be \r
115         showed (cap.valueINT=1) or hidden (cap.valueINT=0). Currently only used with SetCap*/\r
116         GF_CODEC_SHOW_SCENE,\r
117         /*This is only called on scene decoders, GetCap only. If the decoder may continue modifying the scene once the last AU is received,\r
118         it must set cap.valueINT to 1 (typically, text stream decoder will hold the scene for a given duration\r
119         after the last AU). Otherwise the decoder will be stoped and ask to remove any extra scene being displayed*/\r
120         GF_CODEC_MEDIA_NOT_OVER,\r
121 };\r
122 \r
123 \r
124         /* Generic interface used by both media decoders and scene decoders\r
125 @AttachStream:\r
126         Add a Stream to the codec. If DependsOnESID is NULL, the stream is a base layer\r
127         UpStream means that the decoder should send feedback on this channel. \r
128         WARNING: Feedback format is not standardized by MPEG\r
129         the same API is used for both encoder and decoder (decSpecInfo is ignored\r
130         for an encoder) \r
131 @DetachStream:\r
132         Remove stream\r
133 @GetCapabilities:\r
134         Get the desired capability given its code\r
135 @SetCapabilities\r
136         Set the desired capability given its code if possible\r
137         if the codec does not support the request capability, return GF_NOT_SUPPORTED\r
138 @CanHandleStream\r
139         Can module handle this codec? Return 0 if No and !0 otherwise\r
140         decoderSpecificInfo is provided for MPEG4 audio/visual where a bunch of codecs are defined \r
141         with same objectType\r
142 @GetDecoderName\r
143         returns codec name - only called once the stream is successfully attached\r
144 @privateStack\r
145         user defined.\r
146 */\r
147 \r
148 #define GF_CODEC_BASE_INTERFACE(IFCE_NAME)              \\r
149         GF_DECL_MODULE_INTERFACE        \\r
150         GF_Err (*AttachStream)(IFCE_NAME, GF_ESD *esd);\\r
151         GF_Err (*DetachStream)(IFCE_NAME, u16 ES_ID);\\r
152         GF_Err (*GetCapabilities)(IFCE_NAME, GF_CodecCapability *capability);\\r
153         GF_Err (*SetCapabilities)(IFCE_NAME, GF_CodecCapability capability);\\r
154         Bool (*CanHandleStream)(IFCE_NAME, u32 StreamType, u32 ObjectType, char *decSpecInfo, u32 decSpecInfoSize, u32 PL);\\r
155         const char *(*GetName)(IFCE_NAME);\\r
156         void *privateStack;     \\r
157 \r
158 \r
159 typedef struct _basedecoder\r
160 {\r
161         GF_CODEC_BASE_INTERFACE(struct _basedecoder *)\r
162 } GF_BaseDecoder;\r
163 \r
164 /*interface name and version for media decoder */\r
165 #define GF_MEDIA_DECODER_INTERFACE              GF_4CC('G', 'M', 'D', 0x02)\r
166 \r
167 /*the media module interface. A media module MUST be implemented in synchronous mode as time \r
168 and resources management is done by the terminal*/\r
169 typedef struct _mediadecoder\r
170 {\r
171         GF_CODEC_BASE_INTERFACE(struct _basedecoder *)\r
172 \r
173         /*Process the media data in inAU. \r
174         @inBuffer, inBufferLength: encoded input data (complete framing of encoded data)\r
175         @ES_ID: stream this data belongs too (scalable object)\r
176         @outBuffer, outBufferLength: allocated data for decoding - if outBufferLength is not enough\r
177                 you must set the size in outBufferLength and GF_BUFFER_TOO_SMALL \r
178 \r
179         @PaddingBits is the padding at the end of the buffer (some codecs need this info)\r
180         @mmlevel: speed indicator for the decoding - cf above for values*/\r
181         GF_Err (*ProcessData)(struct _mediadecoder *, \r
182                         char *inBuffer, u32 inBufferLength,\r
183                         u16 ES_ID,\r
184                         char *outBuffer, u32 *outBufferLength,\r
185                         u8 PaddingBits, u32 mmlevel);\r
186 } GF_MediaDecoder;\r
187 \r
188 \r
189 \r
190 typedef struct _inline_scene *LPINLINESCENE;\r
191 \r
192 /*interface name and version for scene decoder */\r
193 #define GF_SCENE_DECODER_INTERFACE              GF_4CC('G', 'S', 'D', 0x02)\r
194 \r
195 typedef struct _scenedecoder\r
196 {\r
197         GF_CODEC_BASE_INTERFACE(struct _basedecoder *)\r
198         \r
199         /*attaches scene to the decoder - a scene may be attached to several decoders of several types\r
200         (BIFS or others scene dec, ressource decoders (OD), etc. \r
201         is: inline scene owning graph (and not just graph), defined in intern/terminal_dev.h. With inline scene\r
202         the complete terminal is exposed so there's pretty much everything doable in a scene decoder\r
203         @is_scene_root: set to true if this decoder is the root of the scene, false otherwise (either another decoder\r
204         or a re-entrant call, cf below)\r
205         This is called once upon creation of the decoder (several times if re-entrant)\r
206         */\r
207         GF_Err (*AttachScene)(struct _scenedecoder *, LPINLINESCENE is, Bool is_scene_root);\r
208         /*releases scene. If the decoder manages nodes / resources in the scene, \r
209         THESE MUST BE DESTROYED. May be NULL if decoder doesn't manage nodes but only create them (like BIFS, OD) and\r
210         doesn't have to be instructed the scene is about to be resumed\r
211         This is called each time the scene is about to be reseted (eg, seek and destroy)\r
212         */\r
213         GF_Err (*ReleaseScene)(struct _scenedecoder *);\r
214         /*Process the scene data in inAU. \r
215         @inBuffer, inBufferLength: encoded input data (complete framing of encoded data)\r
216         @ES_ID: stream this data belongs too (scalable object)\r
217         @AU_Time: specifies the current AU time. This is usually unused, however is needed for decoder\r
218         handling the scene graph without input data (cf below). In this case the buffer passed is always NULL and the AU\r
219         time caries the time of the scene (or of the stream object attached to the scene decoder, cf below)\r
220         @mmlevel: speed indicator for the decoding - cf above for values*/\r
221         GF_Err (*ProcessData)(struct _scenedecoder *, char *inBuffer, u32 inBufferLength,\r
222                                         u16 ES_ID, u32 AU_Time, u32 mmlevel);\r
223 \r
224 } GF_SceneDecoder;\r
225 \r
226 #ifdef __cplusplus\r
227 }\r
228 #endif\r
229 \r
230 #endif  /*_GF_MODULE_CODEC_H_*/\r
231 \r