annotate libmpcodecs/ae.c @ 30754:dff9ee89b7c1

Move stream_read_line implementation from stream.h to stream.c, it is not speed critical and the function call overhead is not relevant for its overall speed anyway.
author reimar
date Sun, 28 Feb 2010 13:54:55 +0000
parents 9fc9d1e788aa
children 20bc9bdd7aa1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
19 #include <stdio.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
20 #include <string.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
21 #include <stdlib.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
22 #include <inttypes.h>
15238
2cc48c37a7eb FreeBSD fix
nexus
parents: 15234
diff changeset
23 #include <unistd.h>
15240
6d6792c02b6f macosx compilation fix
nicodvb
parents: 15238
diff changeset
24 #include <sys/types.h>
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
25 #include <math.h>
23640
4eed49de214f config.h must be included before other headers
reimar
parents: 22601
diff changeset
26 #include "config.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
27 #include "libmpdemux/aviheader.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
28 #include "libmpdemux/ms_hdr.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 21660
diff changeset
29 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
30 #include "libmpdemux/muxer.h"
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
31 #include "ae.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
32
16616
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
33 #include "ae_pcm.h"
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
34
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
35 #ifdef CONFIG_TOOLAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
36 #include "ae_toolame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
39 #ifdef CONFIG_MP3LAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
40 #include "ae_lame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 23640
diff changeset
43 #ifdef CONFIG_LIBAVCODEC
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
44 #include "ae_lavc.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
46
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
47 #ifdef CONFIG_FAAC
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
48 #include "ae_faac.h"
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
49 #endif
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
50
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
51 #ifdef CONFIG_TWOLAME
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
52 #include "ae_twolame.h"
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
53 #endif
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
54
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
56 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 int ris;
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
58 audio_encoder_t *encoder;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 if(! params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 return NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
61
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30633
diff changeset
62 encoder = calloc(1, sizeof(audio_encoder_t));
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 encoder->stream = stream;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
65
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
66 switch(stream->codec)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
67 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
68 case ACODEC_PCM:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
69 ris = mpae_init_pcm(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
70 break;
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
71 #ifdef CONFIG_TOOLAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
72 case ACODEC_TOOLAME:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
73 ris = mpae_init_toolame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
74 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
75 #endif
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 23640
diff changeset
76 #ifdef CONFIG_LIBAVCODEC
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
77 case ACODEC_LAVC:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
78 ris = mpae_init_lavc(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
79 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
80 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
81 #ifdef CONFIG_MP3LAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
82 case ACODEC_VBRMP3:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
83 ris = mpae_init_lame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
84 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
85 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
86 #ifdef CONFIG_FAAC
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
87 case ACODEC_FAAC:
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
88 ris = mpae_init_faac(encoder);
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
89 break;
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
90 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
91 #ifdef CONFIG_TWOLAME
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
92 case ACODEC_TWOLAME:
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
93 ris = mpae_init_twolame(encoder);
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
94 break;
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
95 #endif
17781
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
96 default:
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
97 ris = 0;
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
98 break;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
99 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
100
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
101 if(! ris)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
102 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
103 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
104 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
105 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
106 encoder->bind(encoder, stream);
17122
c23ca41ad996 more warning fixes
ods15
parents: 17012
diff changeset
107 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
108 if(! encoder->decode_buffer)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
109 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
110 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
111 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
112 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
113
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
114 encoder->codec = stream->codec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
115 return encoder;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
116 }