Unified · Split
| @@ -1966,42 +1966,42 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1965 unmodified lines | ||
| 1966 | 1966 | case AV_CODEC_ID_ADPCM_PSX: |
| 1967 | 1967 | for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * avctx->channels); block++) { |
| 1968 | 1968 | int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels); |
| 1969 | − for (channel = 0; channel < avctx->channels; channel++) { | |
| 1970 | − samples = samples_p[channel] + block * nb_samples_per_block; | |
| 1971 | − | |
| 1972 | − /* Read in every sample for this channel. */ | |
| 1973 | − for (i = 0; i < nb_samples_per_block / 28; i++) { | |
| 1974 | − int filter, shift, flag, byte; | |
| 1975 | − | |
| 1976 | − filter = bytestream2_get_byteu(&gb); | |
| 1977 | − shift = filter & 0xf; | |
| 1978 | − filter = filter >> 4; | |
| 1979 | − if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) | |
| 1980 | − return AVERROR_INVALIDDATA; | |
| 1981 | − flag = bytestream2_get_byteu(&gb); | |
| 1982 | − | |
| 1983 | − /* Decode 28 samples. */ | |
| 1984 | − for (n = 0; n < 28; n++) { | |
| 1985 | − int sample = 0, scale; | |
| 1986 | − | |
| 1987 | − if (flag < 0x07) { | |
| 1988 | − if (n & 1) { | |
| 1989 | − scale = sign_extend(byte >> 4, 4); | |
| 1990 | − } else { | |
| 1991 | − byte = bytestream2_get_byteu(&gb); | |
| 1992 | − scale = sign_extend(byte, 4); | |
| 1969 | + for (channel = 0; channel < avctx->channels; channel++) { | |
| 1970 | + samples = samples_p[channel] + block * nb_samples_per_block; | |
| 1971 | + | |
| 1972 | + /* Read in every sample for this channel. */ | |
| 1973 | + for (i = 0; i < nb_samples_per_block / 28; i++) { | |
| 1974 | + int filter, shift, flag, byte; | |
| 1975 | + | |
| 1976 | + filter = bytestream2_get_byteu(&gb); | |
| 1977 | + shift = filter & 0xf; | |
| 1978 | + filter = filter >> 4; | |
| 1979 | + if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) | |
| 1980 | + return AVERROR_INVALIDDATA; | |
| 1981 | + flag = bytestream2_get_byteu(&gb); | |
| 1982 | + | |
| 1983 | + /* Decode 28 samples. */ | |
| 1984 | + for (n = 0; n < 28; n++) { | |
| 1985 | + int sample = 0, scale; | |
| 1986 | + | |
| 1987 | + if (flag < 0x07) { | |
| 1988 | + if (n & 1) { | |
| 1989 | + scale = sign_extend(byte >> 4, 4); | |
| 1990 | + } else { | |
| 1991 | + byte = bytestream2_get_byteu(&gb); | |
| 1992 | + scale = sign_extend(byte, 4); | |
| 1993 | + } | |
| 1994 | + | |
| 1995 | + scale = scale * (1 << 12); | |
| 1996 | + sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64); | |
| 1993 | 1997 | } |
| 1994 | − | |
| 1995 | − scale = scale * (1 << 12); | |
| 1996 | − sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64); | |
| 1998 | + *samples++ = av_clip_int16(sample); | |
| 1999 | + c->status[channel].sample2 = c->status[channel].sample1; | |
| 2000 | + c->status[channel].sample1 = sample; | |
| 1997 | 2001 | } |
| 1998 | − *samples++ = av_clip_int16(sample); | |
| 1999 | − c->status[channel].sample2 = c->status[channel].sample1; | |
| 2000 | − c->status[channel].sample1 = sample; | |
| 2001 | 2002 | } |
| 2002 | 2003 | } |
| 2003 | 2004 | } |
| 2004 | − } | |
| 2005 | 2005 | break; |
| 2006 | 2006 | case AV_CODEC_ID_ADPCM_ARGO: |
| 2007 | 2007 | /* |
| @@ -2022,23 +2022,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 14 unmodified lines | ||
| 2022 | 2022 | * They should be 0 initially. |
| 2023 | 2023 | */ |
| 2024 | 2024 | for (int block = 0; block < avpkt->size / avctx->block_align; block++) { |
| 2025 | − for (channel = 0; channel < avctx->channels; channel++) { | |
| 2026 | − int control, shift; | |
| 2025 | + for (channel = 0; channel < avctx->channels; channel++) { | |
| 2026 | + int control, shift; | |
| 2027 | 2027 | |
| 2028 | − samples = samples_p[channel] + block * 32; | |
| 2029 | − cs = c->status + channel; | |
| 2028 | + samples = samples_p[channel] + block * 32; | |
| 2029 | + cs = c->status + channel; | |
| 2030 | 2030 | |
| 2031 | − /* Get the control byte and decode the samples, 2 at a time. */ | |
| 2032 | − control = bytestream2_get_byteu(&gb); | |
| 2033 | − shift = (control >> 4) + 2; | |
| 2031 | + /* Get the control byte and decode the samples, 2 at a time. */ | |
| 2032 | + control = bytestream2_get_byteu(&gb); | |
| 2033 | + shift = (control >> 4) + 2; | |
| 2034 | 2034 | |
| 2035 | − for (n = 0; n < 16; n++) { | |
| 2036 | − int sample = bytestream2_get_byteu(&gb); | |
| 2037 | − *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04); | |
| 2038 | − *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04); | |
| 2035 | + for (n = 0; n < 16; n++) { | |
| 2036 | + int sample = bytestream2_get_byteu(&gb); | |
| 2037 | + *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04); | |
| 2038 | + *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04); | |
| 2039 | + } | |
| 2039 | 2040 | } |
| 2040 | 2041 | } |
| 2041 | − } | |
| 2042 | 2042 | break; |
| 2043 | 2043 | case AV_CODEC_ID_ADPCM_ZORK: |
| 2044 | 2044 | if (!c->has_status) { |