1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

adpcm: convert adpcm_ima_amv/smjpeg to bytestream2.

This commit is contained in:
Ronald S. Bultje 2012-03-17 15:32:57 -07:00
parent 22c48d399d
commit b3084e29e6

View File

@ -1060,27 +1060,33 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
case CODEC_ID_ADPCM_IMA_AMV: case CODEC_ID_ADPCM_IMA_AMV:
case CODEC_ID_ADPCM_IMA_SMJPEG: case CODEC_ID_ADPCM_IMA_SMJPEG:
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) { if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16); c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
c->status[0].step_index = av_clip(bytestream_get_le16(&src), 0, 88); c->status[0].step_index = bytestream2_get_le16u(&gb);
src += 4; bytestream2_skipu(&gb, 4);
} else { } else {
c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16); c->status[0].predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
c->status[0].step_index = av_clip(bytestream_get_byte(&src), 0, 88); c->status[0].step_index = bytestream2_get_byteu(&gb);
src += 1; bytestream2_skipu(&gb, 1);
}
if (c->status[0].step_index > 88u) {
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
c->status[0].step_index);
return AVERROR_INVALIDDATA;
} }
for (n = nb_samples >> (1 - st); n > 0; n--, src++) { for (n = nb_samples >> (1 - st); n > 0; n--) {
char hi, lo; int hi, lo, v = bytestream2_get_byteu(&gb);
lo = *src & 0x0F;
hi = *src >> 4;
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
FFSWAP(char, hi, lo); hi = v & 0x0F;
lo = v >> 4;
} else {
lo = v & 0x0F;
hi = v >> 4;
}
*samples++ = adpcm_ima_expand_nibble(&c->status[0], *samples++ = adpcm_ima_expand_nibble(&c->status[0], lo, 3);
lo, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], hi, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
hi, 3);
} }
break; break;
case CODEC_ID_ADPCM_CT: case CODEC_ID_ADPCM_CT: