Revision ce992c69

View differences:

libavcodec/utils.c
19 19
#include "avcodec.h"
20 20
#include "dsputil.h"
21 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 23
void *av_mallocz(int size)
51 24
{
......
57 30
    return ptr;
58 31
}
59 32

  
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

  
68 33
/* cannot call it directly because of 'void **' casting is not automatic */
69 34
void __av_freep(void **ptr)
70 35
{
......
445 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 413
/* this should be called after seeking and before trying to decode the next frame */
514 414
void avcodec_flush_buffers(AVCodecContext *avctx)
515 415
{

Also available in: Unified diff