--- ../dcaenc.c 2008-03-22 19:45:40.000000000 +0200 +++ dcaenc.c 2008-03-23 13:28:59.000000000 +0200 @@ -27,7 +27,6 @@ int32_t pcm[DCA_SUBBANDS_32]; int32_t subband[64][MAX_CHANNELS][DCA_SUBBANDS_32]; /* [sample][channel][subband] */ int16_t st_samples[4096]; - int fill_samples; } DCAContext; static int32_t cos_table[128]; @@ -94,7 +93,7 @@ (0.0, 0.0, ..., 0.0, -1.0, 1.0, 0.0, ..., 0.0) so that -1.0 cancels 1.0 from the previous step */ - memset(accum,0,sizeof(int32_t)); + memset(accum,0,sizeof(accum)); for (k = 48, j = 0, i = c->start[channel]; i < 512; k++, j++, i++) accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] += mul32(c->history[channel][i], UnQMF[j]); @@ -248,7 +247,7 @@ static uint32_t quantize(int32_t d) { d = d >> 16; - return d & 0xffff; + return d & 0xfffe; } @@ -299,8 +298,7 @@ for (i = 0; i < 8; i++) put_bits(&c->pb, 16, quantize(subband_data[ss * 8 + i][ch][sub])); /* DSYNC */ - align_put_bits(&c->pb); - put_bits(&c->pb, 0xffff, 16); + put_bits(&c->pb, 16, 0xffff); } void put_frame(DCAContext *c, int32_t subband_data[64][2][32], uint8_t *frame) @@ -321,46 +319,35 @@ { int i,k,channel; DCAContext *c = avctx->priv_data; -// int16_t *samples = data; + int16_t *samples = data; // if (buf_size < MAX_CHANNELS*2048*sizeof(int16_t)) // return -1; - // We always get 2048 16bit samples per call so save then until next call - - if (c->fill_samples) { - memcpy(c->st_samples, data, 2048*sizeof(int16_t)); - c->fill_samples = 0; - return 0; - } - memcpy(&c->st_samples[2048], data, 2048*sizeof(int16_t)); - c->fill_samples = 0; - for (i = 0; i < 64; i ++) /* i is the decimated sample number */ for (channel=0; channel<2 ; channel++) { /* Get 32 PCM samples */ for (k = 0; k < 32; k++) { /* k is the sample number in a 32-sample block */ - c->pcm[k] = c->st_samples[4 * (32*i+k) + 2 * channel] << 16; + c->pcm[k] = samples[2 * (32*i+k) + channel] << 16; } - /* Put subband samples into the proper place */ - qmf_decompose(c, c->pcm, &c->subband[i][channel][0], channel); - } + /* Put subband samples into the proper place */ + qmf_decompose(c, c->pcm, &c->subband[i][channel][0], channel); + } put_frame(c, c->subband, frame); - return 4000; + return put_bits_count(&c->pb)>>3; } static int DCA_encode_init(AVCodecContext *avctx) { - DCAContext *c = avctx->priv_data; + //DCAContext *c = avctx->priv_data; if(avctx->channels != 2 || avctx->sample_rate != 44100) { av_log(avctx, AV_LOG_ERROR, "Only 44.1 kHz stereo is supported at the moment!\n"); return -1; } - - // Make sure that the first call to encode is a fill call - c->fill_samples = 1; + + avctx->frame_size = 2048; qmf_init(); return 0;