15234
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <inttypes.h>
|
|
5 #include <math.h>
|
|
6 #include "aviheader.h"
|
|
7 #include "ms_hdr.h"
|
|
8 #include "muxer.h"
|
|
9 #include "ae.h"
|
|
10 #include "../config.h"
|
|
11
|
|
12 #ifdef HAVE_TOOLAME
|
|
13 #include "ae_toolame.h"
|
|
14 #endif
|
|
15
|
|
16 #ifdef HAVE_MP3LAME
|
|
17 #include "ae_lame.h"
|
|
18 #endif
|
|
19
|
|
20 #ifdef USE_LIBAVCODEC
|
|
21 #include "ae_lavc.h"
|
|
22 #endif
|
|
23
|
|
24 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
|
|
25 {
|
|
26 int ris;
|
|
27 if(! params)
|
|
28 return NULL;
|
|
29
|
|
30 audio_encoder_t *encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
|
|
31 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
|
|
32 encoder->stream = stream;
|
|
33
|
|
34 switch(stream->codec)
|
|
35 {
|
|
36 case ACODEC_PCM:
|
|
37 ris = mpae_init_pcm(encoder);
|
|
38 break;
|
|
39 #ifdef HAVE_TOOLAME
|
|
40 case ACODEC_TOOLAME:
|
|
41 ris = mpae_init_toolame(encoder);
|
|
42 break;
|
|
43 #endif
|
|
44 #ifdef USE_LIBAVCODEC
|
|
45 case ACODEC_LAVC:
|
|
46 ris = mpae_init_lavc(encoder);
|
|
47 break;
|
|
48 #endif
|
|
49 #ifdef HAVE_MP3LAME
|
|
50 case ACODEC_VBRMP3:
|
|
51 ris = mpae_init_lame(encoder);
|
|
52 break;
|
|
53 #endif
|
|
54 }
|
|
55
|
|
56 if(! ris)
|
|
57 {
|
|
58 free(encoder);
|
|
59 return NULL;
|
|
60 }
|
|
61 encoder->bind(encoder, stream);
|
|
62 encoder->decode_buffer = (int*)malloc(encoder->decode_buffer_size);
|
|
63 if(! encoder->decode_buffer)
|
|
64 {
|
|
65 free(encoder);
|
|
66 return NULL;
|
|
67 }
|
|
68
|
|
69 encoder->codec = stream->codec;
|
|
70 return encoder;
|
|
71 }
|
|
72
|
|
73
|