Add support for VDPAU video out, including hardware decoding.
[mplayer/glamo.git] / libmpcodecs / ae.c
blob5e7b76b4e99b2184c64e0764188dda84726b31e2
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <inttypes.h>
5 #include <unistd.h>
6 #include <sys/types.h>
7 #include <math.h>
8 #include "config.h"
9 #include "libmpdemux/aviheader.h"
10 #include "libmpdemux/ms_hdr.h"
11 #include "stream/stream.h"
12 #include "libmpdemux/muxer.h"
13 #include "ae.h"
15 #include "ae_pcm.h"
17 #ifdef CONFIG_TOOLAME
18 #include "ae_toolame.h"
19 #endif
21 #ifdef CONFIG_MP3LAME
22 #include "ae_lame.h"
23 #endif
25 #ifdef CONFIG_LIBAVCODEC
26 #include "ae_lavc.h"
27 #endif
29 #ifdef CONFIG_FAAC
30 #include "ae_faac.h"
31 #endif
33 #ifdef CONFIG_TWOLAME
34 #include "ae_twolame.h"
35 #endif
37 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
39 int ris;
40 audio_encoder_t *encoder;
41 if(! params)
42 return NULL;
44 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
45 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
46 encoder->stream = stream;
48 switch(stream->codec)
50 case ACODEC_PCM:
51 ris = mpae_init_pcm(encoder);
52 break;
53 #ifdef CONFIG_TOOLAME
54 case ACODEC_TOOLAME:
55 ris = mpae_init_toolame(encoder);
56 break;
57 #endif
58 #ifdef CONFIG_LIBAVCODEC
59 case ACODEC_LAVC:
60 ris = mpae_init_lavc(encoder);
61 break;
62 #endif
63 #ifdef CONFIG_MP3LAME
64 case ACODEC_VBRMP3:
65 ris = mpae_init_lame(encoder);
66 break;
67 #endif
68 #ifdef CONFIG_FAAC
69 case ACODEC_FAAC:
70 ris = mpae_init_faac(encoder);
71 break;
72 #endif
73 #ifdef CONFIG_TWOLAME
74 case ACODEC_TWOLAME:
75 ris = mpae_init_twolame(encoder);
76 break;
77 #endif
78 default:
79 ris = 0;
80 break;
83 if(! ris)
85 free(encoder);
86 return NULL;
88 encoder->bind(encoder, stream);
89 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
90 if(! encoder->decode_buffer)
92 free(encoder);
93 return NULL;
96 encoder->codec = stream->codec;
97 return encoder;