Increases decode speed significantly.
Unified · Split
| @@ -181,7 +181,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 180 unmodified lines | ||
| 181 | 181 | c->vqa_version = AV_RL16(avctx->extradata); |
| 182 | 182 | break; |
| 183 | 183 | case AV_CODEC_ID_ADPCM_ARGO: |
| 184 | − if (avctx->bits_per_coded_sample != 4) | |
| 184 | + if (avctx->bits_per_coded_sample != 4 || avctx->block_align != 17 * avctx->channels) | |
| 185 | 185 | return AVERROR_INVALIDDATA; |
| 186 | 186 | break; |
| 187 | 187 | case AV_CODEC_ID_ADPCM_ZORK: |
| @@ -745,11 +745,6 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 557 unmodified lines | ||
| 745 | 745 | return 0; |
| 746 | 746 | nb_samples = 64; |
| 747 | 747 | break; |
| 748 | − case AV_CODEC_ID_ADPCM_ARGO: | |
| 749 | − if (buf_size < 17 * ch) | |
| 750 | − return 0; | |
| 751 | − nb_samples = 32; | |
| 752 | − break; | |
| 753 | 748 | /* simple 4-bit adpcm */ |
| 754 | 749 | case AV_CODEC_ID_ADPCM_CT: |
| 755 | 750 | case AV_CODEC_ID_ADPCM_IMA_APC: |
| @@ -922,6 +917,9 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 166 unmodified lines | ||
| 922 | 917 | case AV_CODEC_ID_ADPCM_PSX: |
| 923 | 918 | nb_samples = buf_size / (16 * ch) * 28; |
| 924 | 919 | break; |
| 920 | + case AV_CODEC_ID_ADPCM_ARGO: | |
| 921 | + nb_samples = buf_size / avctx->block_align * 32; | |
| 922 | + break; | |
| 925 | 923 | case AV_CODEC_ID_ADPCM_ZORK: |
| 926 | 924 | nb_samples = buf_size / ch; |
| 927 | 925 | break; |
| @@ -2023,22 +2021,24 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1095 unmodified lines | ||
| 2023 | 2021 | * Each block relies on the previous two samples of each channel. |
| 2024 | 2022 | * They should be 0 initially. |
| 2025 | 2023 | */ |
| 2024 | + for (int block = 0; block < avpkt->size / avctx->block_align; block++) { | |
| 2026 | 2025 | for (channel = 0; channel < avctx->channels; channel++) { |
| 2027 | 2026 | int control, shift; |
| 2028 | 2027 | |
| 2029 | − samples = samples_p[channel]; | |
| 2028 | + samples = samples_p[channel] + block * 32; | |
| 2030 | 2029 | cs = c->status + channel; |
| 2031 | 2030 | |
| 2032 | 2031 | /* Get the control byte and decode the samples, 2 at a time. */ |
| 2033 | 2032 | control = bytestream2_get_byteu(&gb); |
| 2034 | 2033 | shift = (control >> 4) + 2; |
| 2035 | 2034 | |
| 2036 | − for (n = 0; n < nb_samples / 2; n++) { | |
| 2035 | + for (n = 0; n < 16; n++) { | |
| 2037 | 2036 | int sample = bytestream2_get_byteu(&gb); |
| 2038 | 2037 | *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04); |
| 2039 | 2038 | *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04); |
| 2040 | 2039 | } |
| 2041 | 2040 | } |
| 2041 | + } | |
| 2042 | 2042 | break; |
| 2043 | 2043 | case AV_CODEC_ID_ADPCM_ZORK: |
| 2044 | 2044 | if (!c->has_status) { |