[FFmpeg-devel] [PATCH v2 1/2] avcodec/adpcmenc: Adds encoder for Westwood ADPCM.
Zane van Iperen
zane at zanevaniperen.com
Sat Apr 24 07:25:11 EEST 2021
On 24/4/21 8:35 am, Aidan Richmond wrote:
> + case AV_CODEC_ID_ADPCM_IMA_WS:
> + {
> + PutBitContext pb;
> + init_put_bits(&pb, dst, pkt_size);
> +
> + av_assert0(avctx->trellis == 0);
> + for (n = frame->nb_samples / 2; n > 0; n--) {
> + /* stereo: 1 byte (2 samples) for left, 1 byte for right */
> + for (ch = 0; ch < avctx->channels; ch++) {
> + int t1, t2;
> + t1 = adpcm_ima_compress_sample(&c->status[ch], *samples++);
> + t2 = adpcm_ima_compress_sample(&c->status[ch], samples[st]);
> + put_bits(&pb, 4, t2);
> + put_bits(&pb, 4, t1);
> + }
> + samples += avctx->channels;
You've got the channels flipped around. When run as-is:
stddev:14745.44 PSNR: 12.96 MAXDIFF:65535 bytes: 1058400/ 1058400
With:
put_bits(&pb, 4, t1);
put_bits(&pb, 4, t2);
I get:
stddev: 906.36 PSNR: 37.18 MAXDIFF:34026 bytes: 1058400/ 1058400
Which is similar to all the other ADPCM codecs. This is assuming the current decoder is correct, of course.
Also, could you please --signoff the commits?
Zane
More information about the ffmpeg-devel
mailing list