vo_tga: Use the proper imgfmt names
[mplayer/glamo.git] / libmpcodecs / ae.c
blob166935998103ac35bba481bf980d25c08b2b31e1
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <inttypes.h>
23 #include <unistd.h>
24 #include <sys/types.h>
25 #include <math.h>
26 #include "config.h"
27 #include "libmpdemux/aviheader.h"
28 #include "libmpdemux/ms_hdr.h"
29 #include "stream/stream.h"
30 #include "libmpdemux/muxer.h"
31 #include "ae.h"
33 #include "ae_pcm.h"
35 #ifdef CONFIG_TOOLAME
36 #include "ae_toolame.h"
37 #endif
39 #ifdef CONFIG_MP3LAME
40 #include "ae_lame.h"
41 #endif
43 #ifdef CONFIG_LIBAVCODEC
44 #include "ae_lavc.h"
45 #endif
47 #ifdef CONFIG_FAAC
48 #include "ae_faac.h"
49 #endif
51 #ifdef CONFIG_TWOLAME
52 #include "ae_twolame.h"
53 #endif
55 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
57 int ris;
58 audio_encoder_t *encoder;
59 if(! params)
60 return NULL;
62 encoder = calloc(1, sizeof(audio_encoder_t));
63 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
64 encoder->stream = stream;
66 switch(stream->codec)
68 case ACODEC_PCM:
69 ris = mpae_init_pcm(encoder);
70 break;
71 #ifdef CONFIG_TOOLAME
72 case ACODEC_TOOLAME:
73 ris = mpae_init_toolame(encoder);
74 break;
75 #endif
76 #ifdef CONFIG_LIBAVCODEC
77 case ACODEC_LAVC:
78 ris = mpae_init_lavc(encoder);
79 break;
80 #endif
81 #ifdef CONFIG_MP3LAME
82 case ACODEC_VBRMP3:
83 ris = mpae_init_lame(encoder);
84 break;
85 #endif
86 #ifdef CONFIG_FAAC
87 case ACODEC_FAAC:
88 ris = mpae_init_faac(encoder);
89 break;
90 #endif
91 #ifdef CONFIG_TWOLAME
92 case ACODEC_TWOLAME:
93 ris = mpae_init_twolame(encoder);
94 break;
95 #endif
96 default:
97 ris = 0;
98 break;
101 if(! ris)
103 free(encoder);
104 return NULL;
106 encoder->bind(encoder, stream);
107 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
108 if(! encoder->decode_buffer)
110 free(encoder);
111 return NULL;
114 encoder->codec = stream->codec;
115 return encoder;