Revision 9dc92a38 libavcodec/adpcm.c

View differences:

libavcodec/adpcm.c
165 165
        avctx->block_align = BLKSIZE;
166 166
        /* seems frame_size isn't taken into account... have to buffer the samples :-( */
167 167
        break;
168
    case CODEC_ID_ADPCM_IMA_QT:
169
        avctx->frame_size = 64;
170
        avctx->block_align = 34 * avctx->channels;
171
        break;
168 172
    case CODEC_ID_ADPCM_MS:
169 173
        avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */
170 174
                                                             /* and we have 7 bytes per channel overhead */
......
295 299
    nodes[0]->step = c->step_index;
296 300
    nodes[0]->sample1 = c->sample1;
297 301
    nodes[0]->sample2 = c->sample2;
298
    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_SWF))
302
    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF))
299 303
        nodes[0]->sample1 = c->prev_sample;
300 304
    if(version == CODEC_ID_ADPCM_MS)
301 305
        nodes[0]->step = c->idelta;
......
366 370
                    next_##NAME:;
367 371
                    STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8));
368 372
                }
369
            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_SWF)) {
373
            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) {
370 374
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
371 375
                const int predictor = nodes[j]->sample1;\
372 376
                const int div = (sample - predictor) * 4 / STEP_TABLE;\
......
509 513
                samples += 8 * avctx->channels;
510 514
            }
511 515
        break;
516
    case CODEC_ID_ADPCM_IMA_QT:
517
    {
518
        int ch, i;
519
        PutBitContext pb;
520
        init_put_bits(&pb, dst, buf_size*8);
521

  
522
        for(ch=0; ch<avctx->channels; ch++){
523
            put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7);
524
            put_bits(&pb, 7, c->status[ch].step_index);
525
            if(avctx->trellis > 0) {
526
                uint8_t buf[64];
527
                adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64);
528
                for(i=0; i<64; i++)
529
                    put_bits(&pb, 4, buf[i^1]);
530
                c->status[ch].prev_sample = c->status[ch].predictor & ~0x7F;
531
            } else {
532
                for (i=0; i<64; i+=2){
533
                    int t1, t2;
534
                    t1 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]);
535
                    t2 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]);
536
                    put_bits(&pb, 4, t2);
537
                    put_bits(&pb, 4, t1);
538
                }
539
                c->status[ch].prev_sample &= ~0x7F;
540
            }
541
        }
542

  
543
        dst += put_bits_count(&pb)>>3;
544
        break;
545
    }
512 546
    case CODEC_ID_ADPCM_SWF:
513 547
    {
514 548
        int i;
......
1588 1622
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
1589 1623
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs);
1590 1624
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead);
1591
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1625
ADPCM_CODEC  (CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1592 1626
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg);
1593 1627
ADPCM_CODEC  (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1594 1628
ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);

Also available in: Unified diff