annotate libmpcodecs/ae.c @ 16823:850947f65258

cross compiling probably worth mentioining
author ods15
date Fri, 21 Oct 2005 14:44:13 +0000
parents d9b74d27974d
children 6ff3379a0862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
1 #include <stdio.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
2 #include <string.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
3 #include <stdlib.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
4 #include <inttypes.h>
15238
2cc48c37a7eb FreeBSD fix
nexus
parents: 15234
diff changeset
5 #include <unistd.h>
15240
6d6792c02b6f macosx compilation fix
nicodvb
parents: 15238
diff changeset
6 #include <sys/types.h>
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
7 #include <math.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
8 #include "aviheader.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
9 #include "ms_hdr.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
10 #include "muxer.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
11 #include "ae.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
12 #include "../config.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
13
16616
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
14 #include "ae_pcm.h"
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
15
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
16 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
17 #include "ae_toolame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
18 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
19
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
20 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
21 #include "ae_lame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
22 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
23
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
24 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
25 #include "ae_lavc.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
26 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
27
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
28 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
29 #include "ae_faac.h"
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
30 #endif
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
31
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
32 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
33 #include "ae_twolame.h"
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
34 #endif
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
35
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
36 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38 int ris;
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
39 audio_encoder_t *encoder;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
40 if(! params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
43 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
44 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 encoder->stream = stream;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
46
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
47 switch(stream->codec)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
48 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
49 case ACODEC_PCM:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
50 ris = mpae_init_pcm(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
51 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
52 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
53 case ACODEC_TOOLAME:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
54 ris = mpae_init_toolame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
56 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
58 case ACODEC_LAVC:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 ris = mpae_init_lavc(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
61 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
62 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 case ACODEC_VBRMP3:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 ris = mpae_init_lame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
65 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
66 #endif
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
67 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
68 case ACODEC_FAAC:
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
69 ris = mpae_init_faac(encoder);
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
70 break;
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
71 #endif
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
72 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
73 case ACODEC_TWOLAME:
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
74 ris = mpae_init_twolame(encoder);
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
75 break;
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
76 #endif
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
77 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
78
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
79 if(! ris)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
80 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
81 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
82 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
83 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
84 encoder->bind(encoder, stream);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
85 encoder->decode_buffer = (int*)malloc(encoder->decode_buffer_size);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
86 if(! encoder->decode_buffer)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
87 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
88 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
89 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
90 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
91
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
92 encoder->codec = stream->codec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
93 return encoder;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
94 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
95
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
96