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