Commit 87dd0b579b for ffmpeg
commit 87dd0b579bd6e37947de65dd5ece7035b0374605
Author: Mark Thompson <sw@jkqxz.net>
Date: Sun Oct 25 09:45:01 2026 +0000
lavc/apv: Use a local copy of the GetBitContext
Having it on the stack lets the compiler see within this translation
unit that there are no side effects, improving optimisation.
diff --git a/libavcodec/apv_entropy.c b/libavcodec/apv_entropy.c
index 507318cafa..98aa9da62b 100644
--- a/libavcodec/apv_entropy.c
+++ b/libavcodec/apv_entropy.c
@@ -318,9 +318,10 @@ static int apv_apply_multi_entry(int16_t *restrict coeff,
}
}
-int ff_apv_entropy_decode_block(int16_t *restrict coeff,
- GetBitContext *restrict gbc,
- APVEntropyState *restrict state)
+av_always_inline
+static int apv_entropy_decode_block_internal(int16_t *restrict coeff,
+ GetBitContext *restrict gbc,
+ APVEntropyState *restrict state)
{
const APVVLCLUT *lut = state->decode_lut;
const APVMultiVLCLUTEntry *tables = lut->multi_lut[0][0][0];
@@ -496,3 +497,16 @@ normal_loop:
return 0;
}
}
+
+int ff_apv_entropy_decode_block(int16_t *restrict coeff,
+ GetBitContext *restrict gbc,
+ APVEntropyState *restrict state)
+{
+ // Use a local copy of the bitstream reader in this translation unit
+ // to improve optimisation opportunities. Only the position in the
+ // bitstream needs to be written back.
+ GetBitContext gb = *gbc;
+ int err = apv_entropy_decode_block_internal(coeff, &gb, state);
+ gbc->index = gb.index;
+ return err;
+}