15234
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <inttypes.h>
|
15238
|
5 #include <unistd.h>
|
15240
|
6 #include <sys/types.h>
|
15234
|
7 #include <math.h>
|
|
8 #include "aviheader.h"
|
|
9 #include "ms_hdr.h"
|
|
10 #include "muxer.h"
|
|
11 #include "ae.h"
|
|
12 #include "../config.h"
|
|
13
|
|
14 #ifdef HAVE_TOOLAME
|
|
15 #include "ae_toolame.h"
|
|
16 #endif
|
|
17
|
|
18 #ifdef HAVE_MP3LAME
|
|
19 #include "ae_lame.h"
|
|
20 #endif
|
|
21
|
|
22 #ifdef USE_LIBAVCODEC
|
|
23 #include "ae_lavc.h"
|
|
24 #endif
|
|
25
|
15259
|
26 #ifdef HAVE_FAAC
|
|
27 #include "ae_faac.h"
|
|
28 #endif
|
|
29
|
15359
|
30 #ifdef HAVE_TWOLAME
|
|
31 #include "ae_twolame.h"
|
|
32 #endif
|
|
33
|
15234
|
34 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
|
|
35 {
|
|
36 int ris;
|
15242
|
37 audio_encoder_t *encoder;
|
15234
|
38 if(! params)
|
|
39 return NULL;
|
|
40
|
15242
|
41 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
|
15234
|
42 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
|
|
43 encoder->stream = stream;
|
|
44
|
|
45 switch(stream->codec)
|
|
46 {
|
|
47 case ACODEC_PCM:
|
|
48 ris = mpae_init_pcm(encoder);
|
|
49 break;
|
|
50 #ifdef HAVE_TOOLAME
|
|
51 case ACODEC_TOOLAME:
|
|
52 ris = mpae_init_toolame(encoder);
|
|
53 break;
|
|
54 #endif
|
|
55 #ifdef USE_LIBAVCODEC
|
|
56 case ACODEC_LAVC:
|
|
57 ris = mpae_init_lavc(encoder);
|
|
58 break;
|
|
59 #endif
|
|
60 #ifdef HAVE_MP3LAME
|
|
61 case ACODEC_VBRMP3:
|
|
62 ris = mpae_init_lame(encoder);
|
|
63 break;
|
|
64 #endif
|
15259
|
65 #ifdef HAVE_FAAC
|
|
66 case ACODEC_FAAC:
|
|
67 ris = mpae_init_faac(encoder);
|
|
68 break;
|
|
69 #endif
|
15359
|
70 #ifdef HAVE_TWOLAME
|
|
71 case ACODEC_TWOLAME:
|
|
72 ris = mpae_init_twolame(encoder);
|
|
73 break;
|
|
74 #endif
|
15234
|
75 }
|
|
76
|
|
77 if(! ris)
|
|
78 {
|
|
79 free(encoder);
|
|
80 return NULL;
|
|
81 }
|
|
82 encoder->bind(encoder, stream);
|
|
83 encoder->decode_buffer = (int*)malloc(encoder->decode_buffer_size);
|
|
84 if(! encoder->decode_buffer)
|
|
85 {
|
|
86 free(encoder);
|
|
87 return NULL;
|
|
88 }
|
|
89
|
|
90 encoder->codec = stream->codec;
|
|
91 return encoder;
|
|
92 }
|
|
93
|
|
94
|