Mercurial > libavcodec.hg
comparison mace.c @ 7806:b90764c4f31a libavcodec
Remove output pointer from context
author | vitor |
---|---|
date | Sun, 07 Sep 2008 09:38:37 +0000 |
parents | e7ec66d55d9e |
children | 8c32b5606f83 |
comparison
equal
deleted
inserted
replaced
7805:d1ebbf1e4d50 | 7806:b90764c4f31a |
---|---|
234 { 0x3E22, 0x7FFF, 0x8000, 0xC1DD, 0, 0, 0, 0 }, { 0x40E7, 0x7FFF, 0x8000, 0xBF18, 0, 0, 0, 0 }, | 234 { 0x3E22, 0x7FFF, 0x8000, 0xC1DD, 0, 0, 0, 0 }, { 0x40E7, 0x7FFF, 0x8000, 0xBF18, 0, 0, 0, 0 }, |
235 }; | 235 }; |
236 | 236 |
237 typedef struct MACEContext { | 237 typedef struct MACEContext { |
238 short index, lev, factor, prev2, previous, level; | 238 short index, lev, factor, prev2, previous, level; |
239 short *outPtr; | |
240 } MACEContext; | 239 } MACEContext; |
241 | 240 |
242 static void chomp3(MACEContext *ctx, uint8_t val, const uint16_t tab1[], | 241 static void chomp3(MACEContext *ctx, int16_t *output, uint8_t val, |
242 const uint16_t tab1[], | |
243 const uint16_t tab2[][8], uint32_t numChannels) | 243 const uint16_t tab2[][8], uint32_t numChannels) |
244 { | 244 { |
245 short current; | 245 short current; |
246 | 246 |
247 current = (short) tab2[(ctx->index & 0x7f0) >> 4][val]; | 247 current = (short) tab2[(ctx->index & 0x7f0) >> 4][val]; |
253 else | 253 else |
254 current += ctx->lev; | 254 current += ctx->lev; |
255 | 255 |
256 ctx->lev = current - (current >> 3); | 256 ctx->lev = current - (current >> 3); |
257 //*ctx->outPtr++=current >> 8; | 257 //*ctx->outPtr++=current >> 8; |
258 *ctx->outPtr = current; | 258 *output = current; |
259 ctx->outPtr += numChannels; | |
260 if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0) | 259 if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0) |
261 ctx->index = 0; | 260 ctx->index = 0; |
262 } | 261 } |
263 | 262 |
264 static void chomp6(MACEContext *ctx, uint8_t val, const uint16_t tab1[], | 263 static void chomp6(MACEContext *ctx, int16_t *output, uint8_t val, |
264 const uint16_t tab1[], | |
265 const uint16_t tab2[][8], uint32_t numChannels) | 265 const uint16_t tab2[][8], uint32_t numChannels) |
266 { | 266 { |
267 short current; | 267 short current; |
268 | 268 |
269 current = (short)tab2[(ctx->index & 0x7f0) >> 4][val]; | 269 current = (short)tab2[(ctx->index & 0x7f0) >> 4][val]; |
290 ctx->level = ((current*ctx->factor) >> 15); | 290 ctx->level = ((current*ctx->factor) >> 15); |
291 current >>= 1; | 291 current >>= 1; |
292 | 292 |
293 // *ctx->outPtr++=(ctx->previous+ctx->prev2-((ctx->prev2-current) >> 2)) >> 8; | 293 // *ctx->outPtr++=(ctx->previous+ctx->prev2-((ctx->prev2-current) >> 2)) >> 8; |
294 // *ctx->outPtr++=(ctx->previous+current+((ctx->prev2-current) >> 2)) >> 8; | 294 // *ctx->outPtr++=(ctx->previous+current+((ctx->prev2-current) >> 2)) >> 8; |
295 *ctx->outPtr = (ctx->previous + ctx->prev2 - ((ctx->prev2-current) >> 2)); | 295 output[0] = (ctx->previous + ctx->prev2 - ((ctx->prev2-current) >> 2)); |
296 ctx->outPtr += numChannels; | 296 output[numChannels] = (ctx->previous + current + ((ctx->prev2-current) >> 2)); |
297 *ctx->outPtr = (ctx->previous + current + ((ctx->prev2-current) >> 2)); | |
298 ctx->outPtr += numChannels; | |
299 ctx->prev2 = ctx->previous; | 297 ctx->prev2 = ctx->previous; |
300 ctx->previous = current; | 298 ctx->previous = current; |
301 | 299 |
302 if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0) | 300 if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0) |
303 ctx->index = 0; | 301 ctx->index = 0; |
318 short *samples = data; | 316 short *samples = data; |
319 MACEContext *ctx = avctx->priv_data; | 317 MACEContext *ctx = avctx->priv_data; |
320 int i, j, k; | 318 int i, j, k; |
321 | 319 |
322 for(i = 0; i < avctx->channels; i++) { | 320 for(i = 0; i < avctx->channels; i++) { |
321 int16_t *output = samples + i; | |
323 ctx->index = ctx->lev = 0; | 322 ctx->index = ctx->lev = 0; |
324 | |
325 ctx->outPtr = samples + i; | |
326 | 323 |
327 for (j=0; j < buf_size / 2 / avctx->channels; j++) | 324 for (j=0; j < buf_size / 2 / avctx->channels; j++) |
328 for (k=0; k < 2; k++) { | 325 for (k=0; k < 2; k++) { |
329 uint8_t pkt = buf[i*2 + j*2*avctx->channels + k]; | 326 uint8_t pkt = buf[i*2 + j*2*avctx->channels + k]; |
330 chomp3(ctx, pkt &7, MACEtab1, MACEtab2, avctx->channels); | 327 chomp3(ctx, output, pkt &7, MACEtab1, MACEtab2, avctx->channels); |
331 chomp3(ctx,(pkt >> 3) &3, MACEtab3, MACEtab4, avctx->channels); | 328 output += avctx->channels; |
332 chomp3(ctx, pkt >> 5 , MACEtab1, MACEtab2, avctx->channels); | 329 chomp3(ctx, output,(pkt >> 3) &3, MACEtab3, MACEtab4, avctx->channels); |
330 output += avctx->channels; | |
331 chomp3(ctx, output, pkt >> 5 , MACEtab1, MACEtab2, avctx->channels); | |
332 output += avctx->channels; | |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 *data_size = 2 * 3 * buf_size; | 336 *data_size = 2 * 3 * buf_size; |
337 | 337 |
345 short *samples = data; | 345 short *samples = data; |
346 MACEContext *ctx = avctx->priv_data; | 346 MACEContext *ctx = avctx->priv_data; |
347 int i, j; | 347 int i, j; |
348 | 348 |
349 for(i = 0; i < avctx->channels; i++) { | 349 for(i = 0; i < avctx->channels; i++) { |
350 int16_t *output = samples + i; | |
350 ctx->previous = ctx->prev2 = ctx->index = ctx->level = ctx->factor = 0; | 351 ctx->previous = ctx->prev2 = ctx->index = ctx->level = ctx->factor = 0; |
351 | |
352 ctx->outPtr = samples + i; | |
353 | 352 |
354 for (j = 0; j < buf_size / avctx->channels; j++) { | 353 for (j = 0; j < buf_size / avctx->channels; j++) { |
355 uint8_t pkt = buf[i + j*avctx->channels]; | 354 uint8_t pkt = buf[i + j*avctx->channels]; |
356 | 355 |
357 chomp6(ctx, pkt >> 5 , MACEtab1, MACEtab2, avctx->channels); | 356 chomp6(ctx, output, pkt >> 5 , MACEtab1, MACEtab2, avctx->channels); |
358 chomp6(ctx,(pkt >> 3) & 3, MACEtab3, MACEtab4, avctx->channels); | 357 output += avctx->channels << 1; |
359 chomp6(ctx, pkt & 7, MACEtab1, MACEtab2, avctx->channels); | 358 chomp6(ctx, output,(pkt >> 3) & 3, MACEtab3, MACEtab4, avctx->channels); |
359 output += avctx->channels << 1; | |
360 chomp6(ctx, output, pkt & 7, MACEtab1, MACEtab2, avctx->channels); | |
361 output += avctx->channels << 1; | |
360 } | 362 } |
361 } | 363 } |
362 | 364 |
363 *data_size = 2 * 6 * buf_size; | 365 *data_size = 2 * 6 * buf_size; |
364 | 366 |