diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2017-04-29 02:15:32 +0000 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2017-07-09 20:51:24 +0200 |
commit | 0f5ad12ba2b538cb329c507ecc914e06bfa70194 (patch) | |
tree | 3e94eec708ba1b89f8ac2c8f4cc5847aa526dfa3 /libavcodec | |
parent | 15f1cc09a406cf6296818d475a256902235eefc4 (diff) | |
download | ffmpeg-streaming-0f5ad12ba2b538cb329c507ecc914e06bfa70194.zip ffmpeg-streaming-0f5ad12ba2b538cb329c507ecc914e06bfa70194.tar.gz |
flac: Use a local cache for decode_residual()
About an additional 4% speedup.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/flacdec.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 1caed91..87ab2e5 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -199,12 +199,13 @@ static int get_metadata_size(const uint8_t *buf, int buf_size) static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) { + BitstreamContext bc = s->bc; int i, tmp, partition, method_type, rice_order; int rice_bits, rice_esc; int samples; - method_type = bitstream_read(&s->bc, 2); - rice_order = bitstream_read(&s->bc, 4); + method_type = bitstream_read(&bc, 2); + rice_order = bitstream_read(&bc, 4); samples = s->blocksize >> rice_order; rice_bits = 4 + method_type; @@ -226,19 +227,21 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) } for (partition = 0; partition < (1 << rice_order); partition++) { - tmp = bitstream_read(&s->bc, rice_bits); + tmp = bitstream_read(&bc, rice_bits); if (tmp == rice_esc) { - tmp = bitstream_read(&s->bc, 5); + tmp = bitstream_read(&bc, 5); for (; i < samples; i++) - *decoded++ = bitstream_read_signed(&s->bc, tmp); + *decoded++ = bitstream_read_signed(&bc, tmp); } else { for (; i < samples; i++) { - *decoded++ = get_sr_golomb_flac(&s->bc, tmp, INT_MAX, 0); + *decoded++ = get_sr_golomb_flac(&bc, tmp, INT_MAX, 0); } } i= 0; } + s->bc = bc; + return 0; } |