annotate libmpcodecs/ae.c @ 35038:3b57273e1301

Support Alberto's / Kostya's MSS2 decoder.
author cehoyos
date Fri, 31 Aug 2012 14:28:32 +0000
parents 4614728cab25
children
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"
32120
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
31 #include "ae_faac.h"
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
32 #include "ae_lame.h"
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
33 #include "ae_lavc.h"
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
34 #include "ae_pcm.h"
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
35 #include "ae_toolame.h"
20bc9bdd7aa1 Skip #ifdefs around harmless ae_*.h header #includes.
diego
parents: 30702
diff changeset
36 #include "ae_twolame.h"
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 #include "ae.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
39
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
40 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42 int ris;
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
43 audio_encoder_t *encoder;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
44 if(! params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 return NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
46
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30633
diff changeset
47 encoder = calloc(1, sizeof(audio_encoder_t));
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
48 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
49 encoder->stream = stream;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
50
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
51 switch(stream->codec)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
52 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
53 case ACODEC_PCM:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
54 ris = mpae_init_pcm(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 break;
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
56 #ifdef CONFIG_TOOLAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 case ACODEC_TOOLAME:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
58 ris = mpae_init_toolame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 #endif
32142
4614728cab25 build system: Merge all FFmpeg library checks into a single FFmpeg check.
diego
parents: 32120
diff changeset
61 #ifdef CONFIG_FFMPEG
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
62 case ACODEC_LAVC:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 ris = mpae_init_lavc(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
65 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
66 #ifdef CONFIG_MP3LAME
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
67 case ACODEC_VBRMP3:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
68 ris = mpae_init_lame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
69 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
70 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
71 #ifdef CONFIG_FAAC
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
72 case ACODEC_FAAC:
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
73 ris = mpae_init_faac(encoder);
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
74 break;
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
75 #endif
27363
40057010b1fa Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents: 27341
diff changeset
76 #ifdef CONFIG_TWOLAME
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
77 case ACODEC_TWOLAME:
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
78 ris = mpae_init_twolame(encoder);
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
79 break;
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
80 #endif
17781
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
81 default:
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
82 ris = 0;
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
83 break;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
84 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
85
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
86 if(! ris)
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 encoder->bind(encoder, stream);
17122
c23ca41ad996 more warning fixes
ods15
parents: 17012
diff changeset
92 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
93 if(! encoder->decode_buffer)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
94 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
95 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
96 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
97 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27363
diff changeset
98
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
99 encoder->codec = stream->codec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
100 return encoder;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
101 }