summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2017-04-29 02:15:31 +0000
committerDiego Biurrun <diego@biurrun.de>2017-07-09 20:49:57 +0200
commit15f1cc09a406cf6296818d475a256902235eefc4 (patch)
treeee67f6724f37e33e2fa7d02f71254fec4d816d26
parent9c1e111406bd4cbb04d8e8611b71bebf203bec5e (diff)
downloadffmpeg-streaming-15f1cc09a406cf6296818d475a256902235eefc4.zip
ffmpeg-streaming-15f1cc09a406cf6296818d475a256902235eefc4.tar.gz
flac: Postpone unlikely condition checks
About 2% speedup on gcc-6.3. Signed-off-by: Diego Biurrun <diego@biurrun.de>
-rw-r--r--libavcodec/flacdec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 10e1c48..1caed91 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -204,26 +204,27 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
int samples;
method_type = bitstream_read(&s->bc, 2);
+ rice_order = bitstream_read(&s->bc, 4);
+
+ samples = s->blocksize >> rice_order;
+ rice_bits = 4 + method_type;
+ rice_esc = (1 << rice_bits) - 1;
+
+ decoded += pred_order;
+ i = pred_order;
+
if (method_type > 1) {
av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
method_type);
return AVERROR_INVALIDDATA;
}
- rice_order = bitstream_read(&s->bc, 4);
-
- samples= s->blocksize >> rice_order;
if (pred_order > samples) {
av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
pred_order, samples);
return AVERROR_INVALIDDATA;
}
- rice_bits = 4 + method_type;
- rice_esc = (1 << rice_bits) - 1;
-
- decoded += pred_order;
- i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++) {
tmp = bitstream_read(&s->bc, rice_bits);
if (tmp == rice_esc) {
OpenPOWER on IntegriCloud