Revision b3bfb299

View differences:

Changelog
3 3
- IBM Ultimotion (ULTI) video decoder
4 4
- Sierra Online audio file demuxer and decoder
5 5
- Apple QuickDraw (qdrw) video decoder
6
- Creative ADPCM audio decoder
6 7

  
7 8
version 0.4.9-pre1:
8 9

  
doc/ffmpeg-doc.texi
805 805
@tab used in Sega Dreamcast games
806 806
@item Electronic Arts ADPCM  @tab      @tab X
807 807
@tab used in various EA titles
808
@item Creative ADPCM         @tab      @tab X
808 809
@item RA144                  @tab      @tab X
809 810
@tab Real 14400 bit/s codec
810 811
@item RA288                  @tab      @tab X
libavcodec/adpcm.c
103 103
    3, 4, 7, 8, 10, 11, 0, -1, -3, -4
104 104
};
105 105

  
106
static int ct_adpcm_table[8] = {
107
    0x00E6, 0x00E6, 0x00E6, 0x00E6,
108
    0x0133, 0x0199, 0x0200, 0x0266
109
};
110

  
106 111
/* end of tables */
107 112

  
108 113
typedef struct ADPCMChannelStatus {
......
361 366
    c->status[0].step = c->status[1].step = 0;
362 367

  
363 368
    switch(avctx->codec->id) {
369
    case CODEC_ID_ADPCM_CT:
370
	c->status[0].step = c->status[1].step = 511;
371
	break;
364 372
    default:
365 373
        break;
366 374
    }
......
411 419
    return (short)predictor;
412 420
}
413 421

  
422
static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
423
{
424
    int predictor;
425
    int sign, delta, diff;
426
    int new_step;
427

  
428
    sign = nibble & 8;
429
    delta = nibble & 7;
430
    /* perform direct multiplication instead of series of jumps proposed by
431
     * the reference ADPCM implementation since modern CPUs can do the mults
432
     * quickly enough */
433
    diff = ((2 * delta + 1) * c->step) >> 3;
434
    predictor = c->predictor;
435
    /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
436
    if(sign)
437
	predictor = ((predictor * 254) >> 8) - diff;
438
    else
439
    	predictor = ((predictor * 254) >> 8) + diff;
440
    /* calculate new step and clamp it to range 511..32767 */
441
    new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8;
442
    c->step = new_step;
443
    if(c->step < 511)
444
	c->step = 511;
445
    if(c->step > 32767)
446
	c->step = 32767;
447

  
448
    CLAMP_TO_SHORT(predictor);
449
    c->predictor = predictor;
450
    return (short)predictor;
451
}
452

  
414 453
static void xa_decode(short *out, const unsigned char *in, 
415 454
    ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
416 455
{
......
840 879
            src++;
841 880
        }
842 881
        break;
882
    case CODEC_ID_ADPCM_CT:
883
	while (src < buf + buf_size) {
884
            if (st) {
885
                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
886
                    (src[0] >> 4) & 0x0F);
887
                *samples++ = adpcm_ct_expand_nibble(&c->status[1], 
888
                    src[0] & 0x0F);
889
            } else {
890
                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
891
                    (src[0] >> 4) & 0x0F);
892
                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
893
                    src[0] & 0x0F);
894
            }
895
	    src++;
896
        }
897
        break;
843 898
    default:
844 899
        return -1;
845 900
    }
......
895 950
ADPCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
896 951
ADPCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
897 952
ADPCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
953
ADPCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
898 954

  
899 955
#undef ADPCM_CODEC
libavcodec/allcodecs.c
223 223
PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
224 224
PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
225 225
PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
226
PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
226 227

  
227 228
#undef PCM_CODEC
228 229

  
libavcodec/avcodec.h
128 128
    CODEC_ID_ADPCM_ADX,
129 129
    CODEC_ID_ADPCM_EA,
130 130
    CODEC_ID_ADPCM_G726,
131
    CODEC_ID_ADPCM_CT,
131 132

  
132 133
	/* AMR */
133 134
    CODEC_ID_AMR_NB,
......
1916 1917
PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
1917 1918
PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
1918 1919
PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
1920
PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
1919 1921

  
1920 1922
#undef PCM_CODEC
1921 1923

  
libavformat/wav.c
38 38
    { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id?
39 39
    { CODEC_ID_SONIC, 0x2048 },
40 40
    { CODEC_ID_SONIC_LS, 0x2048 },
41
    { CODEC_ID_ADPCM_CT, 0x200 },
41 42
    { 0, 0 },
42 43
};
43 44

  

Also available in: Unified diff