annotate liba52.c @ 6557:e1208c4f8898 libavcodec

h264 chroma mc ssse3 width8: 180->92, width4: 78->63 cycles (core2)
author lorenm
date Tue, 01 Apr 2008 04:51:28 +0000
parents 48759bfbd073
children 5b3acf9fd50a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
1 /*
4617
a0b9e07527c4 Clarify that this decoder uses liba52.
diego
parents: 4514
diff changeset
2 * A52 decoder using liba52
429
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
429
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
15 * Lesser General Public License for more details.
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
16 *
429
718a22dc121f license/copyright change
glantau
parents: 368
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3059
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
20 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
23 * @file a52dec.c
4617
a0b9e07527c4 Clarify that this decoder uses liba52.
diego
parents: 4514
diff changeset
24 * A52 decoder using liba52
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
25 */
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
26
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
27 #include "avcodec.h"
4511
91872ae737b2 Remove internal liba52; external lib still works, native decoder coming up.
diego
parents: 4356
diff changeset
28 #include <a52dec/a52.h>
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
29
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
30 #ifdef CONFIG_LIBA52BIN
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
31 #include <dlfcn.h>
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
32 static const char* liba52name = "liba52.so.0";
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
33 #endif
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
34
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
35 /**
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
36 * liba52 - Copyright (C) Aaron Holtzman
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
37 * released under the GPL license.
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
38 */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
39 typedef struct AC3DecodeState {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
40 int flags;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
41 int channels;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
42 a52_state_t* state;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
43 sample_t* samples;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
44
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
45 /*
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
46 * virtual method table
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
47 *
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
48 * using this function table so the liba52 doesn't
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
49 * have to be really linked together with ffmpeg
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
50 * and might be linked in runtime - this allows binary
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
51 * distribution of ffmpeg library which doens't depend
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
52 * on liba52 library - but if user has it installed
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
53 * it will be used - user might install such library
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
54 * separately
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
55 */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
56 void* handle;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
57 a52_state_t* (*a52_init)(uint32_t mm_accel);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
58 sample_t* (*a52_samples)(a52_state_t * state);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
59 int (*a52_syncinfo)(uint8_t * buf, int * flags,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
60 int * sample_rate, int * bit_rate);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
61 int (*a52_frame)(a52_state_t * state, uint8_t * buf, int * flags,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
62 sample_t * level, sample_t bias);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
63 void (*a52_dynrng)(a52_state_t * state,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
64 sample_t (* call) (sample_t, void *), void * data);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
65 int (*a52_block)(a52_state_t * state);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
66 void (*a52_free)(a52_state_t * state);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
67
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
68 } AC3DecodeState;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
69
4618
bb06df70f857 Add proper #idef to dlsymm call, also fixes an unresolved symbol on OS X 10.2.
diego
parents: 4617
diff changeset
70 #ifdef CONFIG_LIBA52BIN
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
71 static void* dlsymm(void* handle, const char* symbol)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
72 {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
73 void* f = dlsym(handle, symbol);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
74 if (!f)
2846
40765c51a7a9 Compilation fixes part 1 patch by (Arvind R. and Burkhard Plaum, plaum, ipf uni-stuttgart de)
michael
parents: 2028
diff changeset
75 av_log( NULL, AV_LOG_ERROR, "A52 Decoder - function '%s' can't be resolved\n", symbol);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
76 return f;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
77 }
4618
bb06df70f857 Add proper #idef to dlsymm call, also fixes an unresolved symbol on OS X 10.2.
diego
parents: 4617
diff changeset
78 #endif
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
79
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6352
diff changeset
80 static av_cold int a52_decode_init(AVCodecContext *avctx)
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
81 {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
82 AC3DecodeState *s = avctx->priv_data;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
83
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
84 #ifdef CONFIG_LIBA52BIN
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
85 s->handle = dlopen(liba52name, RTLD_LAZY);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
86 if (!s->handle)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
87 {
2846
40765c51a7a9 Compilation fixes part 1 patch by (Arvind R. and Burkhard Plaum, plaum, ipf uni-stuttgart de)
michael
parents: 2028
diff changeset
88 av_log( avctx, AV_LOG_ERROR, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
89 return -1;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
90 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
91 s->a52_init = (a52_state_t* (*)(uint32_t)) dlsymm(s->handle, "a52_init");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
92 s->a52_samples = (sample_t* (*)(a52_state_t*)) dlsymm(s->handle, "a52_samples");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
93 s->a52_syncinfo = (int (*)(uint8_t*, int*, int*, int*)) dlsymm(s->handle, "a52_syncinfo");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
94 s->a52_frame = (int (*)(a52_state_t*, uint8_t*, int*, sample_t*, sample_t)) dlsymm(s->handle, "a52_frame");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
95 s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
96 s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free");
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
97 if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
98 || !s->a52_frame || !s->a52_block || !s->a52_free)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
99 {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
100 dlclose(s->handle);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
101 return -1;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
102 }
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
103 #else
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
104 s->handle = 0;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
105 s->a52_init = a52_init;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
106 s->a52_samples = a52_samples;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
107 s->a52_syncinfo = a52_syncinfo;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
108 s->a52_frame = a52_frame;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
109 s->a52_block = a52_block;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
110 s->a52_free = a52_free;
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
111 #endif
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
112 s->state = s->a52_init(0); /* later use CPU flags */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
113 s->samples = s->a52_samples(s->state);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
114
6114
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
115 /* allow downmixing to stereo or mono */
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
116 if (avctx->channels > 0 && avctx->request_channels > 0 &&
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
117 avctx->request_channels < avctx->channels &&
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
118 avctx->request_channels <= 2) {
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
119 avctx->channels = avctx->request_channels;
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
120 }
f6b691720c7d use request_channels in liba52 decoder
jbr
parents: 5525
diff changeset
121
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
122 return 0;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
123 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
124
5525
bc4791868c52 various simplifications around recent av_clip_int16() usage
aurel
parents: 5523
diff changeset
125 /**** the following function comes from a52dec */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1018
diff changeset
126 static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
127 {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
128 int i, j, c;
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
129 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
130
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
131 j = 0;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
132 nchannels *= 256;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
133 for (i = 0; i < 256; i++) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
134 for (c = 0; c < nchannels; c += 256)
5525
bc4791868c52 various simplifications around recent av_clip_int16() usage
aurel
parents: 5523
diff changeset
135 s16[j++] = av_clip_int16(f[i + c] - 0x43c00000);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
136 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
137 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
138
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
139 /**** end */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
140
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
141 #define HEADER_SIZE 7
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
142
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
143 static int a52_decode_frame(AVCodecContext *avctx,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
144 void *data, int *data_size,
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1018
diff changeset
145 uint8_t *buf, int buf_size)
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
146 {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
147 AC3DecodeState *s = avctx->priv_data;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
148 int flags, i, len;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
149 int sample_rate, bit_rate;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
150 short *out_samples = data;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
151 float level;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
152 static const int ac3_channels[8] = {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2846
diff changeset
153 2, 1, 2, 3, 3, 4, 4, 5
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
154 };
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
155
4356
c8bc01fee409 set data_size to 0 so that in case we return without setting it nothing funny can happen
michael
parents: 4343
diff changeset
156 *data_size= 0;
c8bc01fee409 set data_size to 0 so that in case we return without setting it nothing funny can happen
michael
parents: 4343
diff changeset
157
6351
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
158 if (buf_size < HEADER_SIZE) {
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
159 av_log(avctx, AV_LOG_ERROR, "Error decoding frame, not enough bytes for header\n");
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
160 return -1;
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
161 }
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
162 len = s->a52_syncinfo(buf, &s->flags, &sample_rate, &bit_rate);
6352
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
163 if (len == 0) {
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
164 av_log(avctx, AV_LOG_ERROR, "Error decoding frame, no sync byte at begin\n");
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
165 return -1;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
166 }
6351
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
167 if (buf_size < len) {
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
168 av_log(avctx, AV_LOG_ERROR, "Error decoding frame, not enough bytes\n");
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
169 return -1;
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
170 }
6352
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
171 /* update codec info */
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
172 avctx->sample_rate = sample_rate;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
173 s->channels = ac3_channels[s->flags & 7];
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
174 if (s->flags & A52_LFE)
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
175 s->channels++;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
176 if (avctx->request_channels > 0 &&
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
177 avctx->request_channels <= 2 &&
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
178 avctx->request_channels < s->channels) {
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
179 avctx->channels = avctx->request_channels;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
180 } else {
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
181 avctx->channels = s->channels;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
182 }
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
183 avctx->bit_rate = bit_rate;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
184 flags = s->flags;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
185 if (avctx->channels == 1)
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
186 flags = A52_MONO;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
187 else if (avctx->channels == 2)
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
188 flags = A52_STEREO;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
189 else
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
190 flags |= A52_ADJUST_LEVEL;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
191 level = 1;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
192 if (s->a52_frame(s->state, buf, &flags, &level, 384)) {
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
193 fail:
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
194 av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
195 return -1;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
196 }
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
197 for (i = 0; i < 6; i++) {
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
198 if (s->a52_block(s->state))
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
199 goto fail;
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
200 float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels);
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
201 }
a14abb3d08aa Cosmetics: indentation
superdump
parents: 6351
diff changeset
202 *data_size = 6 * avctx->channels * 256 * sizeof(int16_t);
6351
b568fe642948 Remove useless buffering of input data, so that avcodec_decode_audio never
superdump
parents: 6115
diff changeset
203 return len;
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
204 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
205
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6352
diff changeset
206 static av_cold int a52_decode_end(AVCodecContext *avctx)
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
207 {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
208 AC3DecodeState *s = avctx->priv_data;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
209 s->a52_free(s->state);
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
210 #ifdef CONFIG_LIBA52BIN
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
211 dlclose(s->handle);
4514
790d1cb93686 Restore the possibility to link liba52 instead of dlopening.
diego
parents: 4513
diff changeset
212 #endif
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
213 return 0;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
214 }
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
215
4513
3367310f8460 Rename ac3 decoder to liba52 to prepare for native decoder.
diego
parents: 4511
diff changeset
216 AVCodec liba52_decoder = {
5102
4323e587708d Give names of external library decoders/encoders a lib prefix
diego
parents: 5101
diff changeset
217 "liba52",
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
218 CODEC_TYPE_AUDIO,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
219 CODEC_ID_AC3,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
220 sizeof(AC3DecodeState),
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
221 a52_decode_init,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
222 NULL,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
223 a52_decode_end,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
224 a52_decode_frame,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
225 };