Mercurial > mplayer.hg
annotate libmpcodecs/ae.c @ 31624:40c30c70ead0
Fix memory leak for subtitles decoded by libavcodec.
author | reimar |
---|---|
date | Sun, 11 Jul 2010 07:37:02 +0000 |
parents | 9fc9d1e788aa |
children | 20bc9bdd7aa1 |
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 | 19 #include <stdio.h> |
20 #include <string.h> | |
21 #include <stdlib.h> | |
22 #include <inttypes.h> | |
15238 | 23 #include <unistd.h> |
15240 | 24 #include <sys/types.h> |
15234 | 25 #include <math.h> |
23640 | 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 | 31 #include "ae.h" |
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 | 36 #include "ae_toolame.h" |
37 #endif | |
38 | |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27341
diff
changeset
|
39 #ifdef CONFIG_MP3LAME |
15234 | 40 #include "ae_lame.h" |
41 #endif | |
42 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
23640
diff
changeset
|
43 #ifdef CONFIG_LIBAVCODEC |
15234 | 44 #include "ae_lavc.h" |
45 #endif | |
46 | |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27341
diff
changeset
|
47 #ifdef CONFIG_FAAC |
15259 | 48 #include "ae_faac.h" |
49 #endif | |
50 | |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27341
diff
changeset
|
51 #ifdef CONFIG_TWOLAME |
15359 | 52 #include "ae_twolame.h" |
53 #endif | |
54 | |
15234 | 55 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params) |
56 { | |
57 int ris; | |
15242 | 58 audio_encoder_t *encoder; |
15234 | 59 if(! params) |
60 return NULL; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27363
diff
changeset
|
61 |
30702 | 62 encoder = calloc(1, sizeof(audio_encoder_t)); |
15234 | 63 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t)); |
64 encoder->stream = stream; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27363
diff
changeset
|
65 |
15234 | 66 switch(stream->codec) |
67 { | |
68 case ACODEC_PCM: | |
69 ris = mpae_init_pcm(encoder); | |
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 | 72 case ACODEC_TOOLAME: |
73 ris = mpae_init_toolame(encoder); | |
74 break; | |
75 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
23640
diff
changeset
|
76 #ifdef CONFIG_LIBAVCODEC |
15234 | 77 case ACODEC_LAVC: |
78 ris = mpae_init_lavc(encoder); | |
79 break; | |
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 | 82 case ACODEC_VBRMP3: |
83 ris = mpae_init_lame(encoder); | |
84 break; | |
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 | 87 case ACODEC_FAAC: |
88 ris = mpae_init_faac(encoder); | |
89 break; | |
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 | 92 case ACODEC_TWOLAME: |
93 ris = mpae_init_twolame(encoder); | |
94 break; | |
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 | 99 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27363
diff
changeset
|
100 |
15234 | 101 if(! ris) |
102 { | |
103 free(encoder); | |
104 return NULL; | |
105 } | |
106 encoder->bind(encoder, stream); | |
17122 | 107 encoder->decode_buffer = malloc(encoder->decode_buffer_size); |
15234 | 108 if(! encoder->decode_buffer) |
109 { | |
110 free(encoder); | |
111 return NULL; | |
112 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27363
diff
changeset
|
113 |
15234 | 114 encoder->codec = stream->codec; |
115 return encoder; | |
116 } |