History

avcodec/adpcm_argo: support decoding multiple frames

Increases decode speed significantly.

Zane van Iperen committed 6 years ago

Commit 9eabe9c1 parent 624f6df1 file · +8 −8Browse files

Unified · Split

libavcodec/adpcm.c+8−8
@@ -181,7 +181,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 180 unmodified lines
181181 c->vqa_version = AV_RL16(avctx->extradata);
182182 break;
183183 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)
185185 return AVERROR_INVALIDDATA;
186186 break;
187187 case AV_CODEC_ID_ADPCM_ZORK:
@@ -745,11 +745,6 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 557 unmodified lines
745745 return 0;
746746 nb_samples = 64;
747747 break;
748− case AV_CODEC_ID_ADPCM_ARGO:
749− if (buf_size < 17 * ch)
750− return 0;
751− nb_samples = 32;
752− break;
753748 /* simple 4-bit adpcm */
754749 case AV_CODEC_ID_ADPCM_CT:
755750 case AV_CODEC_ID_ADPCM_IMA_APC:
@@ -922,6 +917,9 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 166 unmodified lines
922917 case AV_CODEC_ID_ADPCM_PSX:
923918 nb_samples = buf_size / (16 * ch) * 28;
924919 break;
920+ case AV_CODEC_ID_ADPCM_ARGO:
921+ nb_samples = buf_size / avctx->block_align * 32;
922+ break;
925923 case AV_CODEC_ID_ADPCM_ZORK:
926924 nb_samples = buf_size / ch;
927925 break;
@@ -2023,22 +2021,24 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1095 unmodified lines
20232021 * Each block relies on the previous two samples of each channel.
20242022 * They should be 0 initially.
20252023 */
2024+ for (int block = 0; block < avpkt->size / avctx->block_align; block++) {
20262025 for (channel = 0; channel < avctx->channels; channel++) {
20272026 int control, shift;
20282027
2029− samples = samples_p[channel];
2028+ samples = samples_p[channel] + block * 32;
20302029 cs = c->status + channel;
20312030
20322031 /* Get the control byte and decode the samples, 2 at a time. */
20332032 control = bytestream2_get_byteu(&gb);
20342033 shift = (control >> 4) + 2;
20352034
2036− for (n = 0; n < nb_samples / 2; n++) {
2035+ for (n = 0; n < 16; n++) {
20372036 int sample = bytestream2_get_byteu(&gb);
20382037 *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04);
20392038 *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04);
20402039 }
20412040 }
2041+ }
20422042 break;
20432043 case AV_CODEC_ID_ADPCM_ZORK:
20442044 if (!c->has_status) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t