Mercurial > libavcodec.hg
comparison a52dec.c @ 2979:bfabfdf9ce55 libavcodec
COSMETICS: tabs --> spaces, some prettyprinting
author | diego |
---|---|
date | Thu, 22 Dec 2005 01:10:11 +0000 |
parents | 40765c51a7a9 |
children | 0b546eab515d |
comparison
equal
deleted
inserted
replaced
2978:403183bbb505 | 2979:bfabfdf9ce55 |
---|---|
56 */ | 56 */ |
57 void* handle; | 57 void* handle; |
58 a52_state_t* (*a52_init)(uint32_t mm_accel); | 58 a52_state_t* (*a52_init)(uint32_t mm_accel); |
59 sample_t* (*a52_samples)(a52_state_t * state); | 59 sample_t* (*a52_samples)(a52_state_t * state); |
60 int (*a52_syncinfo)(uint8_t * buf, int * flags, | 60 int (*a52_syncinfo)(uint8_t * buf, int * flags, |
61 int * sample_rate, int * bit_rate); | 61 int * sample_rate, int * bit_rate); |
62 int (*a52_frame)(a52_state_t * state, uint8_t * buf, int * flags, | 62 int (*a52_frame)(a52_state_t * state, uint8_t * buf, int * flags, |
63 sample_t * level, sample_t bias); | 63 sample_t * level, sample_t bias); |
64 void (*a52_dynrng)(a52_state_t * state, | 64 void (*a52_dynrng)(a52_state_t * state, |
65 sample_t (* call) (sample_t, void *), void * data); | 65 sample_t (* call) (sample_t, void *), void * data); |
66 int (*a52_block)(a52_state_t * state); | 66 int (*a52_block)(a52_state_t * state); |
67 void (*a52_free)(a52_state_t * state); | 67 void (*a52_free)(a52_state_t * state); |
68 | 68 |
69 } AC3DecodeState; | 69 } AC3DecodeState; |
70 | 70 |
103 s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block"); | 103 s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block"); |
104 s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free"); | 104 s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free"); |
105 if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo | 105 if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo |
106 || !s->a52_frame || !s->a52_block || !s->a52_free) | 106 || !s->a52_frame || !s->a52_block || !s->a52_free) |
107 { | 107 { |
108 dlclose(s->handle); | 108 dlclose(s->handle); |
109 return -1; | 109 return -1; |
110 } | 110 } |
111 #else | 111 #else |
112 /* static linked version */ | 112 /* static linked version */ |
113 s->handle = 0; | 113 s->handle = 0; |
128 | 128 |
129 /**** the following two functions comes from a52dec */ | 129 /**** the following two functions comes from a52dec */ |
130 static inline int blah (int32_t i) | 130 static inline int blah (int32_t i) |
131 { | 131 { |
132 if (i > 0x43c07fff) | 132 if (i > 0x43c07fff) |
133 return 32767; | 133 return 32767; |
134 else if (i < 0x43bf8000) | 134 else if (i < 0x43bf8000) |
135 return -32768; | 135 return -32768; |
136 return i - 0x43c00000; | 136 return i - 0x43c00000; |
137 } | 137 } |
138 | 138 |
139 static inline void float_to_int (float * _f, int16_t * s16, int nchannels) | 139 static inline void float_to_int (float * _f, int16_t * s16, int nchannels) |
140 { | 140 { |
141 int i, j, c; | 141 int i, j, c; |
142 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format | 142 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format |
143 | 143 |
144 j = 0; | 144 j = 0; |
145 nchannels *= 256; | 145 nchannels *= 256; |
146 for (i = 0; i < 256; i++) { | 146 for (i = 0; i < 256; i++) { |
147 for (c = 0; c < nchannels; c += 256) | 147 for (c = 0; c < nchannels; c += 256) |
148 s16[j++] = blah (f[i + c]); | 148 s16[j++] = blah (f[i + c]); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 /**** end */ | 152 /**** end */ |
153 | 153 |
162 int flags, i, len; | 162 int flags, i, len; |
163 int sample_rate, bit_rate; | 163 int sample_rate, bit_rate; |
164 short *out_samples = data; | 164 short *out_samples = data; |
165 float level; | 165 float level; |
166 static const int ac3_channels[8] = { | 166 static const int ac3_channels[8] = { |
167 2, 1, 2, 3, 3, 4, 4, 5 | 167 2, 1, 2, 3, 3, 4, 4, 5 |
168 }; | 168 }; |
169 | 169 |
170 buf_ptr = buf; | 170 buf_ptr = buf; |
171 while (buf_size > 0) { | 171 while (buf_size > 0) { |
172 len = s->inbuf_ptr - s->inbuf; | 172 len = s->inbuf_ptr - s->inbuf; |
184 if (len == 0) { | 184 if (len == 0) { |
185 /* no sync found : move by one byte (inefficient, but simple!) */ | 185 /* no sync found : move by one byte (inefficient, but simple!) */ |
186 memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); | 186 memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); |
187 s->inbuf_ptr--; | 187 s->inbuf_ptr--; |
188 } else { | 188 } else { |
189 s->frame_size = len; | 189 s->frame_size = len; |
190 /* update codec info */ | 190 /* update codec info */ |
191 avctx->sample_rate = sample_rate; | 191 avctx->sample_rate = sample_rate; |
192 s->channels = ac3_channels[s->flags & 7]; | 192 s->channels = ac3_channels[s->flags & 7]; |
193 if (s->flags & A52_LFE) | 193 if (s->flags & A52_LFE) |
194 s->channels++; | 194 s->channels++; |
195 if (avctx->channels == 0) | 195 if (avctx->channels == 0) |
196 /* No specific number of channel requested */ | 196 /* No specific number of channel requested */ |
197 avctx->channels = s->channels; | 197 avctx->channels = s->channels; |
198 else if (s->channels < avctx->channels) { | 198 else if (s->channels < avctx->channels) { |
199 av_log(avctx, AV_LOG_ERROR, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len); | 199 av_log(avctx, AV_LOG_ERROR, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len); |
200 avctx->channels = s->channels; | 200 avctx->channels = s->channels; |
201 } | 201 } |
202 avctx->bit_rate = bit_rate; | 202 avctx->bit_rate = bit_rate; |
203 } | 203 } |
204 } | 204 } |
205 } else if (len < s->frame_size) { | 205 } else if (len < s->frame_size) { |
206 len = s->frame_size - len; | 206 len = s->frame_size - len; |
207 if (len > buf_size) | 207 if (len > buf_size) |