diff options
author | Diego Biurrun <diego@biurrun.de> | 2005-12-22 01:10:11 +0000 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2005-12-22 01:10:11 +0000 |
commit | bb270c0896b39e1ae9277355e3c120ed3feb64a3 (patch) | |
tree | fc2fc2b1216d19acb3879abb6ea5a3b400f43fe4 /libavcodec/adpcm.c | |
parent | 50827fcf44f34521df4708cdb633809b56fb9df3 (diff) | |
download | ffmpeg-bb270c0896b39e1ae9277355e3c120ed3feb64a3.tar.gz |
COSMETICS: tabs --> spaces, some prettyprinting
Originally committed as revision 4764 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r-- | libavcodec/adpcm.c | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index b22442e28c..1cb788109f 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -300,7 +300,7 @@ static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, } static int adpcm_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) + unsigned char *frame, int buf_size, void *data) { int n, i, st; short *samples; @@ -431,8 +431,8 @@ static int adpcm_decode_init(AVCodecContext * avctx) switch(avctx->codec->id) { case CODEC_ID_ADPCM_CT: - c->status[0].step = c->status[1].step = 511; - break; + c->status[0].step = c->status[1].step = 511; + break; default: break; } @@ -498,16 +498,16 @@ static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble) predictor = c->predictor; /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */ if(sign) - predictor = ((predictor * 254) >> 8) - diff; + predictor = ((predictor * 254) >> 8) - diff; else - predictor = ((predictor * 254) >> 8) + diff; + predictor = ((predictor * 254) >> 8) + diff; /* calculate new step and clamp it to range 511..32767 */ new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8; c->step = new_step; if(c->step < 511) - c->step = 511; + c->step = 511; if(c->step > 32767) - c->step = 32767; + c->step = 32767; CLAMP_TO_SHORT(predictor); c->predictor = predictor; @@ -612,8 +612,8 @@ static void xa_decode(short *out, const unsigned char *in, } static int adpcm_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) + void *data, int *data_size, + uint8_t *buf, int buf_size) { ADPCMContext *c = avctx->priv_data; ADPCMChannelStatus *cs; @@ -701,7 +701,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, cs->predictor -= 0x10000; CLAMP_TO_SHORT(cs->predictor); - // XXX: is this correct ??: *samples++ = cs->predictor; + // XXX: is this correct ??: *samples++ = cs->predictor; cs->step_index = *src++; if (cs->step_index < 0) cs->step_index = 0; @@ -710,19 +710,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } for(m=4; src < (buf + buf_size);) { - *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); + *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[4] & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); - if (st) { + if (st) { *samples++ = adpcm_ima_expand_nibble(&c->status[1], (src[4] >> 4) & 0x0F, 3); - if (!--m) { - m=4; - src+=4; - } - } - src++; - } + if (!--m) { + m=4; + src+=4; + } + } + src++; + } break; case CODEC_ID_ADPCM_4XM: cs = &(c->status[0]); @@ -739,13 +739,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, m= (buf_size - (src - buf))>>st; for(i=0; i<m; i++) { - *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4); + *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4); *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4); - if (st) + if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4); - } + } src += m<<st; @@ -958,7 +958,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } break; case CODEC_ID_ADPCM_CT: - while (src < buf + buf_size) { + while (src < buf + buf_size) { if (st) { *samples++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); @@ -970,78 +970,78 @@ static int adpcm_decode_frame(AVCodecContext *avctx, *samples++ = adpcm_ct_expand_nibble(&c->status[0], src[0] & 0x0F); } - src++; + src++; } break; case CODEC_ID_ADPCM_SWF: { - GetBitContext gb; - const int *table; - int k0, signmask; - int size = buf_size*8; - - init_get_bits(&gb, buf, size); - - // first frame, read bits & inital values - if (!c->nb_bits) - { - c->nb_bits = get_bits(&gb, 2)+2; -// av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", c->nb_bits); - } - - table = swf_index_tables[c->nb_bits-2]; - k0 = 1 << (c->nb_bits-2); - signmask = 1 << (c->nb_bits-1); - - while (get_bits_count(&gb) <= size) - { - int i; - - c->nb_samples++; - // wrap around at every 4096 samples... - if ((c->nb_samples & 0xfff) == 1) - { - for (i = 0; i <= st; i++) - { - *samples++ = c->status[i].predictor = get_sbits(&gb, 16); - c->status[i].step_index = get_bits(&gb, 6); - } - } - - // similar to IMA adpcm - for (i = 0; i <= st; i++) - { - int delta = get_bits(&gb, c->nb_bits); - int step = step_table[c->status[i].step_index]; - long vpdiff = 0; // vpdiff = (delta+0.5)*step/4 - int k = k0; - - do { - if (delta & k) - vpdiff += step; - step >>= 1; - k >>= 1; - } while(k); - vpdiff += step; - - if (delta & signmask) - c->status[i].predictor -= vpdiff; - else - c->status[i].predictor += vpdiff; - - c->status[i].step_index += table[delta & (~signmask)]; - - c->status[i].step_index = clip(c->status[i].step_index, 0, 88); - c->status[i].predictor = clip(c->status[i].predictor, -32768, 32767); - - *samples++ = c->status[i].predictor; - } - } - -// src += get_bits_count(&gb)*8; - src += size; - - break; + GetBitContext gb; + const int *table; + int k0, signmask; + int size = buf_size*8; + + init_get_bits(&gb, buf, size); + + // first frame, read bits & inital values + if (!c->nb_bits) + { + c->nb_bits = get_bits(&gb, 2)+2; +// av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", c->nb_bits); + } + + table = swf_index_tables[c->nb_bits-2]; + k0 = 1 << (c->nb_bits-2); + signmask = 1 << (c->nb_bits-1); + + while (get_bits_count(&gb) <= size) + { + int i; + + c->nb_samples++; + // wrap around at every 4096 samples... + if ((c->nb_samples & 0xfff) == 1) + { + for (i = 0; i <= st; i++) + { + *samples++ = c->status[i].predictor = get_sbits(&gb, 16); + c->status[i].step_index = get_bits(&gb, 6); + } + } + + // similar to IMA adpcm + for (i = 0; i <= st; i++) + { + int delta = get_bits(&gb, c->nb_bits); + int step = step_table[c->status[i].step_index]; + long vpdiff = 0; // vpdiff = (delta+0.5)*step/4 + int k = k0; + + do { + if (delta & k) + vpdiff += step; + step >>= 1; + k >>= 1; + } while(k); + vpdiff += step; + + if (delta & signmask) + c->status[i].predictor -= vpdiff; + else + c->status[i].predictor += vpdiff; + + c->status[i].step_index += table[delta & (~signmask)]; + + c->status[i].step_index = clip(c->status[i].step_index, 0, 88); + c->status[i].predictor = clip(c->status[i].predictor, -32768, 32767); + + *samples++ = c->status[i].predictor; + } + } + +// src += get_bits_count(&gb)*8; + src += size; + + break; } case CODEC_ID_ADPCM_YAMAHA: while (src < buf + buf_size) { |