[FFmpeg-devel] [PATCH v2 1/2] avcodec/adpcmenc: Adds encoder for Westwood ADPCM.

Aidan R aidan.is at hotmail.co.uk
Sun Apr 25 00:34:59 EEST 2021


> +    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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

Turns out that the decoder is wrong. I had submitted a bug to the tracker as I couldn't work out what was wrong with it, I didn't consider it might be reading the nibbles in the wrong order, My next round of updates to the patch will contain a fixed decoder too.

Aidan


More information about the ffmpeg-devel mailing list