mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avcodec/adpcm: add support for 5.1 ADPCM MS
This commit is contained in:
parent
052d41377a
commit
f79873409b
@ -105,6 +105,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
case AV_CODEC_ID_ADPCM_EA_R2:
|
||||
case AV_CODEC_ID_ADPCM_EA_R3:
|
||||
case AV_CODEC_ID_ADPCM_EA_XAS:
|
||||
case AV_CODEC_ID_ADPCM_MS:
|
||||
max_channels = 6;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_MTAF:
|
||||
@ -170,6 +171,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P :
|
||||
AV_SAMPLE_FMT_S16;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_MS:
|
||||
avctx->sample_fmt = avctx->channels > 2 ? AV_SAMPLE_FMT_S16P :
|
||||
AV_SAMPLE_FMT_S16;
|
||||
break;
|
||||
default:
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
}
|
||||
@ -924,6 +929,29 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
{
|
||||
int block_predictor;
|
||||
|
||||
if (avctx->channels > 2) {
|
||||
for (channel = 0; channel < avctx->channels; channel++) {
|
||||
samples = samples_p[channel];
|
||||
block_predictor = bytestream2_get_byteu(&gb);
|
||||
if (block_predictor > 6) {
|
||||
av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[%d] = %d\n",
|
||||
channel, block_predictor);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
c->status[channel].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
|
||||
c->status[channel].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
|
||||
c->status[channel].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
|
||||
c->status[channel].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
|
||||
c->status[channel].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
|
||||
*samples++ = c->status[channel].sample2;
|
||||
*samples++ = c->status[channel].sample1;
|
||||
for(n = (nb_samples - 2) >> 1; n > 0; n--) {
|
||||
int byte = bytestream2_get_byteu(&gb);
|
||||
*samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte >> 4 );
|
||||
*samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte & 0x0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
block_predictor = bytestream2_get_byteu(&gb);
|
||||
if (block_predictor > 6) {
|
||||
av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n",
|
||||
@ -961,6 +989,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 );
|
||||
*samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AV_CODEC_ID_ADPCM_MTAF:
|
||||
@ -1810,7 +1839,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad,
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_s16, adpcm_ms, "ADPCM Microsoft");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_both, adpcm_ms, "ADPCM Microsoft");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MTAF, sample_fmts_s16p, adpcm_mtaf, "ADPCM MTAF");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_PSX, sample_fmts_s16p, adpcm_psx, "ADPCM Playstation");
|
||||
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
|
||||
|
@ -590,6 +590,8 @@ break_loop:
|
||||
} else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 ||
|
||||
st->codecpar->codec_id == AV_CODEC_ID_XMA2) {
|
||||
st->codecpar->block_align = 2048;
|
||||
} else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2) {
|
||||
st->codecpar->block_align *= st->codecpar->channels;
|
||||
}
|
||||
|
||||
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user