Mercurial > libavcodec.hg
comparison utils.c @ 495:6f47eef8879f libavcodec
moved code to mem.c and allcodecs.c
| author | bellard |
|---|---|
| date | Tue, 11 Jun 2002 13:45:17 +0000 |
| parents | 000aeeac27a2 |
| children | 9c66b5183ab3 |
comparison
equal
deleted
inserted
replaced
| 494:54b88078c361 | 495:6f47eef8879f |
|---|---|
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 */ | 18 */ |
| 19 #include "avcodec.h" | 19 #include "avcodec.h" |
| 20 #include "dsputil.h" | 20 #include "dsputil.h" |
| 21 #include "mpegvideo.h" | 21 #include "mpegvideo.h" |
| 22 #ifdef HAVE_MALLOC_H | |
| 23 #include <malloc.h> | |
| 24 #endif | |
| 25 | |
| 26 /* memory alloc */ | |
| 27 void *av_malloc(int size) | |
| 28 { | |
| 29 void *ptr; | |
| 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 | |
| 42 ptr = malloc(size); | |
| 43 #endif | |
| 44 if (!ptr) | |
| 45 return NULL; | |
| 46 memset(ptr, 0, size); | |
| 47 return ptr; | |
| 48 } | |
| 49 | 22 |
| 50 void *av_mallocz(int size) | 23 void *av_mallocz(int size) |
| 51 { | 24 { |
| 52 void *ptr; | 25 void *ptr; |
| 53 ptr = av_malloc(size); | 26 ptr = av_malloc(size); |
| 54 if (!ptr) | 27 if (!ptr) |
| 55 return NULL; | 28 return NULL; |
| 56 memset(ptr, 0, size); | 29 memset(ptr, 0, size); |
| 57 return ptr; | 30 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 } | 31 } |
| 67 | 32 |
| 68 /* cannot call it directly because of 'void **' casting is not automatic */ | 33 /* cannot call it directly because of 'void **' casting is not automatic */ |
| 69 void __av_freep(void **ptr) | 34 void __av_freep(void **ptr) |
| 70 { | 35 { |
| 443 inited = 1; | 408 inited = 1; |
| 444 | 409 |
| 445 dsputil_init(); | 410 dsputil_init(); |
| 446 } | 411 } |
| 447 | 412 |
| 448 /* simple call to use all the codecs */ | |
| 449 void avcodec_register_all(void) | |
| 450 { | |
| 451 static int inited = 0; | |
| 452 | |
| 453 if (inited != 0) | |
| 454 return; | |
| 455 inited = 1; | |
| 456 | |
| 457 /* encoders */ | |
| 458 #ifdef CONFIG_ENCODERS | |
| 459 register_avcodec(&ac3_encoder); | |
| 460 register_avcodec(&mp2_encoder); | |
| 461 #ifdef CONFIG_MP3LAME | |
| 462 register_avcodec(&mp3lame_encoder); | |
| 463 #endif | |
| 464 register_avcodec(&mpeg1video_encoder); | |
| 465 register_avcodec(&h263_encoder); | |
| 466 register_avcodec(&h263p_encoder); | |
| 467 register_avcodec(&rv10_encoder); | |
| 468 register_avcodec(&mjpeg_encoder); | |
| 469 register_avcodec(&mpeg4_encoder); | |
| 470 register_avcodec(&msmpeg4v1_encoder); | |
| 471 register_avcodec(&msmpeg4v2_encoder); | |
| 472 register_avcodec(&msmpeg4v3_encoder); | |
| 473 #endif /* CONFIG_ENCODERS */ | |
| 474 register_avcodec(&rawvideo_codec); | |
| 475 | |
| 476 /* decoders */ | |
| 477 #ifdef CONFIG_DECODERS | |
| 478 register_avcodec(&h263_decoder); | |
| 479 register_avcodec(&mpeg4_decoder); | |
| 480 register_avcodec(&msmpeg4v1_decoder); | |
| 481 register_avcodec(&msmpeg4v2_decoder); | |
| 482 register_avcodec(&msmpeg4v3_decoder); | |
| 483 register_avcodec(&wmv1_decoder); | |
| 484 register_avcodec(&mpeg_decoder); | |
| 485 register_avcodec(&h263i_decoder); | |
| 486 register_avcodec(&rv10_decoder); | |
| 487 register_avcodec(&mjpeg_decoder); | |
| 488 register_avcodec(&mp2_decoder); | |
| 489 register_avcodec(&mp3_decoder); | |
| 490 #ifdef CONFIG_AC3 | |
| 491 register_avcodec(&ac3_decoder); | |
| 492 #endif | |
| 493 #endif /* CONFIG_DECODERS */ | |
| 494 | |
| 495 /* pcm codecs */ | |
| 496 | |
| 497 #define PCM_CODEC(id, name) \ | |
| 498 register_avcodec(& name ## _encoder); \ | |
| 499 register_avcodec(& name ## _decoder); \ | |
| 500 | |
| 501 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); | |
| 502 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); | |
| 503 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); | |
| 504 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be); | |
| 505 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8); | |
| 506 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8); | |
| 507 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw); | |
| 508 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw); | |
| 509 | |
| 510 #undef PCM_CODEC | |
| 511 } | |
| 512 | |
| 513 /* this should be called after seeking and before trying to decode the next frame */ | 413 /* this should be called after seeking and before trying to decode the next frame */ |
| 514 void avcodec_flush_buffers(AVCodecContext *avctx) | 414 void avcodec_flush_buffers(AVCodecContext *avctx) |
| 515 { | 415 { |
| 516 MpegEncContext *s = avctx->priv_data; | 416 MpegEncContext *s = avctx->priv_data; |
| 517 s->num_available_buffers=0; | 417 s->num_available_buffers=0; |
