Mercurial > libavcodec.hg
annotate utils.c @ 394:e2cb8a4ee0c5 libavcodec
proper memory handling functions
author | glantau |
---|---|
date | Sat, 18 May 2002 22:59:50 +0000 |
parents | 47c878305986 |
children | b0aed401a756 |
rev | line source |
---|---|
0 | 1 /* |
2 * utils for libavcodec | |
3 * Copyright (c) 2001 Gerard Lantau. | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 */ | |
394 | 19 #include "avcodec.h" |
0 | 20 #include "dsputil.h" |
341 | 21 #include "mpegvideo.h" |
80 | 22 #ifdef HAVE_MALLOC_H |
23 #include <malloc.h> | |
24 #endif | |
0 | 25 |
26 /* memory alloc */ | |
394 | 27 void *av_malloc(int size) |
0 | 28 { |
29 void *ptr; | |
77 | 30 #if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN ) |
31 ptr = memalign(64,size); | |
32 /* Why 64? | |
33 Indeed, we should align it: | |
34 on 4 for 386 | |
35 on 16 for 486 | |
36 on 32 for 586, PPro - k6-III | |
37 on 64 for K7 (maybe for P3 too). | |
38 Because L1 and L2 caches are aligned on those values. | |
39 But I don't want to code such logic here! | |
40 */ | |
41 #else | |
0 | 42 ptr = malloc(size); |
77 | 43 #endif |
0 | 44 if (!ptr) |
45 return NULL; | |
46 memset(ptr, 0, size); | |
47 return ptr; | |
48 } | |
49 | |
394 | 50 void *av_mallocz(int size) |
51 { | |
52 void *ptr; | |
53 ptr = av_malloc(size); | |
54 if (!ptr) | |
55 return NULL; | |
56 memset(ptr, 0, size); | |
57 return ptr; | |
58 } | |
59 | |
60 /* NOTE: ptr = NULL is explicetly allowed */ | |
61 void av_free(void *ptr) | |
62 { | |
63 /* XXX: this test should not be needed on most libcs */ | |
64 if (ptr) | |
65 free(ptr); | |
66 } | |
67 | |
0 | 68 /* encoder management */ |
69 AVCodec *first_avcodec; | |
70 | |
71 void register_avcodec(AVCodec *format) | |
72 { | |
73 AVCodec **p; | |
74 p = &first_avcodec; | |
75 while (*p != NULL) p = &(*p)->next; | |
76 *p = format; | |
77 format->next = NULL; | |
78 } | |
79 | |
80 int avcodec_open(AVCodecContext *avctx, AVCodec *codec) | |
81 { | |
82 int ret; | |
83 | |
84 avctx->codec = codec; | |
85 avctx->frame_number = 0; | |
374
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
86 if (codec->priv_data_size > 0) { |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
87 avctx->priv_data = av_mallocz(codec->priv_data_size); |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
88 if (!avctx->priv_data) |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
89 return -ENOMEM; |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
90 } else { |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
91 avctx->priv_data = NULL; |
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
92 } |
0 | 93 ret = avctx->codec->init(avctx); |
94 if (ret < 0) { | |
394 | 95 av_freep(&avctx->priv_data); |
0 | 96 return ret; |
97 } | |
98 return 0; | |
99 } | |
100 | |
101 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
102 const short *samples) | |
103 { | |
104 int ret; | |
105 | |
106 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples); | |
107 avctx->frame_number++; | |
108 return ret; | |
109 } | |
110 | |
111 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
112 const AVPicture *pict) | |
113 { | |
114 int ret; | |
115 | |
116 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict); | |
117 avctx->frame_number++; | |
118 return ret; | |
119 } | |
120 | |
121 /* decode a frame. return -1 if error, otherwise return the number of | |
122 bytes used. If no frame could be decompressed, *got_picture_ptr is | |
123 zero. Otherwise, it is non zero */ | |
124 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, | |
125 int *got_picture_ptr, | |
126 UINT8 *buf, int buf_size) | |
127 { | |
128 int ret; | |
129 | |
130 ret = avctx->codec->decode(avctx, picture, got_picture_ptr, | |
131 buf, buf_size); | |
267
e10840e4f773
- Bug fix MPEG-2 decoder to handle "repeat_first_field" (Telecine)
pulento
parents:
260
diff
changeset
|
132 if (*got_picture_ptr) |
e10840e4f773
- Bug fix MPEG-2 decoder to handle "repeat_first_field" (Telecine)
pulento
parents:
260
diff
changeset
|
133 avctx->frame_number++; |
0 | 134 return ret; |
135 } | |
136 | |
137 /* decode an audio frame. return -1 if error, otherwise return the | |
138 *number of bytes used. If no frame could be decompressed, | |
139 *frame_size_ptr is zero. Otherwise, it is the decompressed frame | |
140 *size in BYTES. */ | |
141 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, | |
142 int *frame_size_ptr, | |
143 UINT8 *buf, int buf_size) | |
144 { | |
145 int ret; | |
146 | |
147 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, | |
148 buf, buf_size); | |
149 avctx->frame_number++; | |
150 return ret; | |
151 } | |
152 | |
153 int avcodec_close(AVCodecContext *avctx) | |
154 { | |
155 if (avctx->codec->close) | |
156 avctx->codec->close(avctx); | |
394 | 157 av_freep(&avctx->priv_data); |
0 | 158 avctx->codec = NULL; |
159 return 0; | |
160 } | |
161 | |
162 AVCodec *avcodec_find_encoder(enum CodecID id) | |
163 { | |
164 AVCodec *p; | |
165 p = first_avcodec; | |
166 while (p) { | |
167 if (p->encode != NULL && p->id == id) | |
168 return p; | |
169 p = p->next; | |
170 } | |
171 return NULL; | |
172 } | |
173 | |
177 | 174 AVCodec *avcodec_find_encoder_by_name(const char *name) |
175 { | |
176 AVCodec *p; | |
177 p = first_avcodec; | |
178 while (p) { | |
179 if (p->encode != NULL && strcmp(name,p->name) == 0) | |
180 return p; | |
181 p = p->next; | |
182 } | |
183 return NULL; | |
184 } | |
185 | |
0 | 186 AVCodec *avcodec_find_decoder(enum CodecID id) |
187 { | |
188 AVCodec *p; | |
189 p = first_avcodec; | |
190 while (p) { | |
191 if (p->decode != NULL && p->id == id) | |
192 return p; | |
193 p = p->next; | |
194 } | |
195 return NULL; | |
196 } | |
197 | |
198 AVCodec *avcodec_find_decoder_by_name(const char *name) | |
199 { | |
200 AVCodec *p; | |
201 p = first_avcodec; | |
202 while (p) { | |
203 if (p->decode != NULL && strcmp(name,p->name) == 0) | |
204 return p; | |
205 p = p->next; | |
206 } | |
207 return NULL; | |
208 } | |
209 | |
210 AVCodec *avcodec_find(enum CodecID id) | |
211 { | |
212 AVCodec *p; | |
213 p = first_avcodec; | |
214 while (p) { | |
215 if (p->id == id) | |
216 return p; | |
217 p = p->next; | |
218 } | |
219 return NULL; | |
220 } | |
221 | |
55 | 222 const char *pix_fmt_str[] = { |
315 | 223 "??", |
55 | 224 "yuv420p", |
225 "yuv422", | |
226 "rgb24", | |
227 "bgr24", | |
228 "yuv422p", | |
229 "yuv444p", | |
230 }; | |
231 | |
0 | 232 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) |
233 { | |
234 const char *codec_name; | |
235 AVCodec *p; | |
236 char buf1[32]; | |
337 | 237 char channels_str[100]; |
92 | 238 int bitrate; |
0 | 239 |
240 if (encode) | |
241 p = avcodec_find_encoder(enc->codec_id); | |
242 else | |
243 p = avcodec_find_decoder(enc->codec_id); | |
244 | |
245 if (p) { | |
246 codec_name = p->name; | |
247 } else if (enc->codec_name[0] != '\0') { | |
248 codec_name = enc->codec_name; | |
249 } else { | |
250 /* output avi tags */ | |
251 if (enc->codec_type == CODEC_TYPE_VIDEO) { | |
252 snprintf(buf1, sizeof(buf1), "%c%c%c%c", | |
253 enc->codec_tag & 0xff, | |
254 (enc->codec_tag >> 8) & 0xff, | |
255 (enc->codec_tag >> 16) & 0xff, | |
256 (enc->codec_tag >> 24) & 0xff); | |
257 } else { | |
258 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); | |
259 } | |
260 codec_name = buf1; | |
261 } | |
262 | |
263 switch(enc->codec_type) { | |
264 case CODEC_TYPE_VIDEO: | |
265 snprintf(buf, buf_size, | |
266 "Video: %s%s", | |
267 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : ""); | |
55 | 268 if (enc->codec_id == CODEC_ID_RAWVIDEO) { |
269 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
270 ", %s", | |
271 pix_fmt_str[enc->pix_fmt]); | |
272 } | |
0 | 273 if (enc->width) { |
274 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
275 ", %dx%d, %0.2f fps", | |
276 enc->width, enc->height, | |
277 (float)enc->frame_rate / FRAME_RATE_BASE); | |
278 } | |
315 | 279 snprintf(buf + strlen(buf), buf_size - strlen(buf), |
280 ", q=%d-%d", enc->qmin, enc->qmax); | |
281 | |
92 | 282 bitrate = enc->bit_rate; |
0 | 283 break; |
284 case CODEC_TYPE_AUDIO: | |
285 snprintf(buf, buf_size, | |
286 "Audio: %s", | |
287 codec_name); | |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
288 switch (enc->channels) { |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
289 case 1: |
337 | 290 strcpy(channels_str, "mono"); |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
291 break; |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
292 case 2: |
337 | 293 strcpy(channels_str, "stereo"); |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
294 break; |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
295 case 6: |
337 | 296 strcpy(channels_str, "5:1"); |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
297 break; |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
298 default: |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
299 sprintf(channels_str, "%d channels", enc->channels); |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
300 break; |
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
301 } |
0 | 302 if (enc->sample_rate) { |
303 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
304 ", %d Hz, %s", | |
305 enc->sample_rate, | |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
306 channels_str); |
0 | 307 } |
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
308 |
92 | 309 /* for PCM codecs, compute bitrate directly */ |
310 switch(enc->codec_id) { | |
311 case CODEC_ID_PCM_S16LE: | |
312 case CODEC_ID_PCM_S16BE: | |
313 case CODEC_ID_PCM_U16LE: | |
314 case CODEC_ID_PCM_U16BE: | |
94 | 315 bitrate = enc->sample_rate * enc->channels * 16; |
92 | 316 break; |
317 case CODEC_ID_PCM_S8: | |
318 case CODEC_ID_PCM_U8: | |
319 case CODEC_ID_PCM_ALAW: | |
320 case CODEC_ID_PCM_MULAW: | |
94 | 321 bitrate = enc->sample_rate * enc->channels * 8; |
92 | 322 break; |
323 default: | |
324 bitrate = enc->bit_rate; | |
325 break; | |
326 } | |
0 | 327 break; |
328 default: | |
329 abort(); | |
330 } | |
92 | 331 if (bitrate != 0) { |
0 | 332 snprintf(buf + strlen(buf), buf_size - strlen(buf), |
92 | 333 ", %d kb/s", bitrate / 1000); |
0 | 334 } |
335 } | |
336 | |
55 | 337 /* Picture field are filled with 'ptr' addresses */ |
338 void avpicture_fill(AVPicture *picture, UINT8 *ptr, | |
339 int pix_fmt, int width, int height) | |
340 { | |
341 int size; | |
342 | |
343 size = width * height; | |
344 switch(pix_fmt) { | |
345 case PIX_FMT_YUV420P: | |
346 picture->data[0] = ptr; | |
347 picture->data[1] = picture->data[0] + size; | |
348 picture->data[2] = picture->data[1] + size / 4; | |
349 picture->linesize[0] = width; | |
350 picture->linesize[1] = width / 2; | |
351 picture->linesize[2] = width / 2; | |
352 break; | |
353 case PIX_FMT_YUV422P: | |
354 picture->data[0] = ptr; | |
355 picture->data[1] = picture->data[0] + size; | |
356 picture->data[2] = picture->data[1] + size / 2; | |
357 picture->linesize[0] = width; | |
358 picture->linesize[1] = width / 2; | |
359 picture->linesize[2] = width / 2; | |
360 break; | |
361 case PIX_FMT_YUV444P: | |
362 picture->data[0] = ptr; | |
363 picture->data[1] = picture->data[0] + size; | |
364 picture->data[2] = picture->data[1] + size; | |
365 picture->linesize[0] = width; | |
366 picture->linesize[1] = width; | |
367 picture->linesize[2] = width; | |
368 break; | |
369 case PIX_FMT_RGB24: | |
370 case PIX_FMT_BGR24: | |
371 picture->data[0] = ptr; | |
372 picture->data[1] = NULL; | |
373 picture->data[2] = NULL; | |
374 picture->linesize[0] = width * 3; | |
375 break; | |
376 case PIX_FMT_YUV422: | |
377 picture->data[0] = ptr; | |
378 picture->data[1] = NULL; | |
379 picture->data[2] = NULL; | |
380 picture->linesize[0] = width * 2; | |
381 break; | |
382 default: | |
383 picture->data[0] = NULL; | |
384 picture->data[1] = NULL; | |
385 picture->data[2] = NULL; | |
386 break; | |
387 } | |
388 } | |
389 | |
390 int avpicture_get_size(int pix_fmt, int width, int height) | |
391 { | |
392 int size; | |
393 | |
394 size = width * height; | |
395 switch(pix_fmt) { | |
396 case PIX_FMT_YUV420P: | |
397 size = (size * 3) / 2; | |
398 break; | |
399 case PIX_FMT_YUV422P: | |
400 size = (size * 2); | |
401 break; | |
402 case PIX_FMT_YUV444P: | |
403 size = (size * 3); | |
404 break; | |
405 case PIX_FMT_RGB24: | |
406 case PIX_FMT_BGR24: | |
407 size = (size * 3); | |
408 break; | |
409 case PIX_FMT_YUV422: | |
410 size = (size * 2); | |
411 break; | |
412 default: | |
413 size = -1; | |
414 break; | |
415 } | |
416 return size; | |
417 } | |
418 | |
362 | 419 unsigned avcodec_version( void ) |
420 { | |
421 return LIBAVCODEC_VERSION_INT; | |
422 } | |
55 | 423 |
379 | 424 unsigned avcodec_build( void ) |
425 { | |
426 return LIBAVCODEC_BUILD; | |
427 } | |
428 | |
0 | 429 /* must be called before any other functions */ |
430 void avcodec_init(void) | |
431 { | |
303
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
432 static int inited = 0; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
433 |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
434 if (inited != 0) |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
435 return; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
436 inited = 1; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
437 |
0 | 438 dsputil_init(); |
439 } | |
440 | |
441 /* simple call to use all the codecs */ | |
442 void avcodec_register_all(void) | |
443 { | |
303
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
444 static int inited = 0; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
445 |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
446 if (inited != 0) |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
447 return; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
448 inited = 1; |
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
449 |
3
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
450 /* encoders */ |
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
451 #ifdef CONFIG_ENCODERS |
0 | 452 register_avcodec(&ac3_encoder); |
453 register_avcodec(&mp2_encoder); | |
260
e1bacfb3f51f
- Added MP3 encoding through libmp3lame contributed by Lennert Buytenhek.
pulento
parents:
177
diff
changeset
|
454 #ifdef CONFIG_MP3LAME |
e1bacfb3f51f
- Added MP3 encoding through libmp3lame contributed by Lennert Buytenhek.
pulento
parents:
177
diff
changeset
|
455 register_avcodec(&mp3lame_encoder); |
e1bacfb3f51f
- Added MP3 encoding through libmp3lame contributed by Lennert Buytenhek.
pulento
parents:
177
diff
changeset
|
456 #endif |
0 | 457 register_avcodec(&mpeg1video_encoder); |
458 register_avcodec(&h263_encoder); | |
459 register_avcodec(&h263p_encoder); | |
460 register_avcodec(&rv10_encoder); | |
461 register_avcodec(&mjpeg_encoder); | |
71 | 462 register_avcodec(&mpeg4_encoder); |
307 | 463 register_avcodec(&msmpeg4v1_encoder); |
464 register_avcodec(&msmpeg4v2_encoder); | |
465 register_avcodec(&msmpeg4v3_encoder); | |
3
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
466 #endif /* CONFIG_ENCODERS */ |
0 | 467 register_avcodec(&rawvideo_codec); |
3
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
468 |
0 | 469 /* decoders */ |
3
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
470 #ifdef CONFIG_DECODERS |
0 | 471 register_avcodec(&h263_decoder); |
71 | 472 register_avcodec(&mpeg4_decoder); |
307 | 473 register_avcodec(&msmpeg4v1_decoder); |
474 register_avcodec(&msmpeg4v2_decoder); | |
475 register_avcodec(&msmpeg4v3_decoder); | |
311 | 476 register_avcodec(&wmv1_decoder); |
0 | 477 register_avcodec(&mpeg_decoder); |
478 register_avcodec(&h263i_decoder); | |
479 register_avcodec(&rv10_decoder); | |
24 | 480 register_avcodec(&mjpeg_decoder); |
322 | 481 register_avcodec(&mp2_decoder); |
3
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
482 register_avcodec(&mp3_decoder); |
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
483 #ifdef CONFIG_AC3 |
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
484 register_avcodec(&ac3_decoder); |
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
485 #endif |
1bdbd869c1f0
added CONFIG_AC3, CONFIG_MPGLIB, CONFIG_DECODERS and CONFIG_ENCODERS (Arpi: don't forget to put CONFIG_DECODERS in mplayer)
glantau
parents:
0
diff
changeset
|
486 #endif /* CONFIG_DECODERS */ |
92 | 487 |
488 /* pcm codecs */ | |
489 | |
490 #define PCM_CODEC(id, name) \ | |
491 register_avcodec(& name ## _encoder); \ | |
492 register_avcodec(& name ## _decoder); \ | |
493 | |
494 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); | |
495 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); | |
496 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); | |
497 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be); | |
498 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8); | |
499 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8); | |
500 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw); | |
501 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw); | |
502 | |
503 #undef PCM_CODEC | |
0 | 504 } |
505 | |
341 | 506 /* this should be called after seeking and before trying to decode the next frame */ |
507 void avcodec_flush_buffers(AVCodecContext *avctx) | |
508 { | |
509 MpegEncContext *s = avctx->priv_data; | |
510 s->num_available_buffers=0; | |
511 } | |
512 | |
513 | |
0 | 514 static int encode_init(AVCodecContext *s) |
515 { | |
516 return 0; | |
517 } | |
518 | |
519 static int decode_frame(AVCodecContext *avctx, | |
520 void *data, int *data_size, | |
521 UINT8 *buf, int buf_size) | |
522 { | |
523 return -1; | |
524 } | |
525 | |
526 static int encode_frame(AVCodecContext *avctx, | |
527 unsigned char *frame, int buf_size, void *data) | |
528 { | |
529 return -1; | |
530 } | |
531 | |
532 AVCodec rawvideo_codec = { | |
533 "rawvideo", | |
534 CODEC_TYPE_VIDEO, | |
535 CODEC_ID_RAWVIDEO, | |
536 0, | |
537 encode_init, | |
538 encode_frame, | |
539 NULL, | |
540 decode_frame, | |
541 }; |