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