+ int ch = 0;
+ int stereo = avctx->channels - 1;
+ int16_t *output_samples, *samples_end;
+ GetByteContext gb;
+
+ if (stereo && (buf_size & 1))
+ buf_size--;
+ bytestream2_init(&gb, avpkt->data, buf_size);
+
+ /* calculate output size */
+ switch(avctx->codec->id) {
+ case AV_CODEC_ID_ROQ_DPCM:
+ out = buf_size - 8;
+ break;
+ case AV_CODEC_ID_INTERPLAY_DPCM:
+ out = buf_size - 6 - avctx->channels;
+ break;
+ case AV_CODEC_ID_XAN_DPCM:
+ out = buf_size - 2 * avctx->channels;
+ break;
+ case AV_CODEC_ID_SOL_DPCM:
+ if (avctx->codec_tag != 3)
+ out = buf_size * 2;
+ else
+ out = buf_size;
+ break;
+ }
+ if (out <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
+ return AVERROR(EINVAL);
+ }