Mercurial > libavcodec.hg
comparison dca.c @ 7724:ea9aa2aa4caa libavcodec
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
author | andoma |
---|---|
date | Fri, 29 Aug 2008 10:09:51 +0000 |
parents | eb4802bc73f0 |
children | 2cddcef36256 |
comparison
equal
deleted
inserted
replaced
7723:20b105281e87 | 7724:ea9aa2aa4caa |
---|---|
162 | 162 |
163 int output; ///< type of output | 163 int output; ///< type of output |
164 int bias; ///< output bias | 164 int bias; ///< output bias |
165 | 165 |
166 DECLARE_ALIGNED_16(float, samples[1536]); /* 6 * 256 = 1536, might only need 5 */ | 166 DECLARE_ALIGNED_16(float, samples[1536]); /* 6 * 256 = 1536, might only need 5 */ |
167 DECLARE_ALIGNED_16(int16_t, tsamples[1536]); | 167 float *samples_chanptr[6]; |
168 | 168 |
169 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; | 169 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; |
170 int dca_buffer_size; ///< how much data is in the dca_buffer | 170 int dca_buffer_size; ///< how much data is in the dca_buffer |
171 | 171 |
172 GetBitContext gb; | 172 GetBitContext gb; |
1143 static int dca_decode_frame(AVCodecContext * avctx, | 1143 static int dca_decode_frame(AVCodecContext * avctx, |
1144 void *data, int *data_size, | 1144 void *data, int *data_size, |
1145 const uint8_t * buf, int buf_size) | 1145 const uint8_t * buf, int buf_size) |
1146 { | 1146 { |
1147 | 1147 |
1148 int i, j, k; | 1148 int i; |
1149 int16_t *samples = data; | 1149 int16_t *samples = data; |
1150 DCAContext *s = avctx->priv_data; | 1150 DCAContext *s = avctx->priv_data; |
1151 int channels; | 1151 int channels; |
1152 | 1152 |
1153 | 1153 |
1184 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) | 1184 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) |
1185 return -1; | 1185 return -1; |
1186 *data_size = 0; | 1186 *data_size = 0; |
1187 for (i = 0; i < (s->sample_blocks / 8); i++) { | 1187 for (i = 0; i < (s->sample_blocks / 8); i++) { |
1188 dca_decode_block(s); | 1188 dca_decode_block(s); |
1189 s->dsp.float_to_int16(s->tsamples, s->samples, 256 * channels); | 1189 s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); |
1190 /* interleave samples */ | 1190 samples += 256 * channels; |
1191 for (j = 0; j < 256; j++) { | |
1192 for (k = 0; k < channels; k++) | |
1193 samples[k] = s->tsamples[j + k * 256]; | |
1194 samples += channels; | |
1195 } | |
1196 *data_size += 256 * sizeof(int16_t) * channels; | 1191 *data_size += 256 * sizeof(int16_t) * channels; |
1197 } | 1192 } |
1198 | 1193 |
1199 return buf_size; | 1194 return buf_size; |
1200 } | 1195 } |
1238 */ | 1233 */ |
1239 | 1234 |
1240 static av_cold int dca_decode_init(AVCodecContext * avctx) | 1235 static av_cold int dca_decode_init(AVCodecContext * avctx) |
1241 { | 1236 { |
1242 DCAContext *s = avctx->priv_data; | 1237 DCAContext *s = avctx->priv_data; |
1238 int i; | |
1243 | 1239 |
1244 s->avctx = avctx; | 1240 s->avctx = avctx; |
1245 dca_init_vlcs(); | 1241 dca_init_vlcs(); |
1246 pre_calc_cosmod(s); | 1242 pre_calc_cosmod(s); |
1247 | 1243 |
1250 /* allow downmixing to stereo */ | 1246 /* allow downmixing to stereo */ |
1251 if (avctx->channels > 0 && avctx->request_channels < avctx->channels && | 1247 if (avctx->channels > 0 && avctx->request_channels < avctx->channels && |
1252 avctx->request_channels == 2) { | 1248 avctx->request_channels == 2) { |
1253 avctx->channels = avctx->request_channels; | 1249 avctx->channels = avctx->request_channels; |
1254 } | 1250 } |
1255 | 1251 for(i = 0; i < 6; i++) |
1252 s->samples_chanptr[i] = s->samples + i * 256; | |
1256 avctx->sample_fmt = SAMPLE_FMT_S16; | 1253 avctx->sample_fmt = SAMPLE_FMT_S16; |
1257 return 0; | 1254 return 0; |
1258 } | 1255 } |
1259 | 1256 |
1260 | 1257 |