annotate libmpcodecs/ae.c @ 26213:893103b2b11c

Add a separate definition for quartz.
author diego
date Sat, 15 Mar 2008 09:49:14 +0000
parents 4eed49de214f
children e7c989f7a7c9
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>
23640
4eed49de214f config.h must be included before other headers
reimar
parents: 22601
diff changeset
8 #include "config.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
9 #include "libmpdemux/aviheader.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
10 #include "libmpdemux/ms_hdr.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 21660
diff changeset
11 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
12 #include "libmpdemux/muxer.h"
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
13 #include "ae.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
14
16616
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
15 #include "ae_pcm.h"
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
16
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
17 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
18 #include "ae_toolame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
19 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
20
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
21 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
22 #include "ae_lame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
23 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
24
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
25 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
26 #include "ae_lavc.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
27 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
28
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
29 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
30 #include "ae_faac.h"
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
31 #endif
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
32
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
33 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
34 #include "ae_twolame.h"
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
35 #endif
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
36
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
39 int ris;
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
40 audio_encoder_t *encoder;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41 if(! params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
43
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
44 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
46 encoder->stream = stream;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
47
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
48 switch(stream->codec)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
49 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
50 case ACODEC_PCM:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
51 ris = mpae_init_pcm(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
52 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
53 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
54 case ACODEC_TOOLAME:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 ris = mpae_init_toolame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
56 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
58 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 case ACODEC_LAVC:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 ris = mpae_init_lavc(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
61 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
62 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 case ACODEC_VBRMP3:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
65 ris = mpae_init_lame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
66 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
67 #endif
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
68 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
69 case ACODEC_FAAC:
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
70 ris = mpae_init_faac(encoder);
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
71 break;
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
72 #endif
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
73 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
74 case ACODEC_TWOLAME:
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
75 ris = mpae_init_twolame(encoder);
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
76 break;
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
77 #endif
17781
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
78 default:
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
79 ris = 0;
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
80 break;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
81 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
82
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
83 if(! ris)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
84 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
85 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
86 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
87 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
88 encoder->bind(encoder, stream);
17122
c23ca41ad996 more warning fixes
ods15
parents: 17012
diff changeset
89 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
90 if(! encoder->decode_buffer)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
91 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
92 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
93 return NULL;
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 encoder->codec = stream->codec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
97 return encoder;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
98 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
99
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
100