mirror of
https://github.com/webmproject/libwebp.git
synced 2025-01-26 22:52:55 +01:00
unroll the kBands[] indirection to remove a dereference in GetCoeffs()
speed-up is small but visible. Change-Id: Icff546adc3276f3c3d46b147c4a735b5eb8ff22e
This commit is contained in:
parent
8ed9c00d5e
commit
1c4e3efea0
@ -494,6 +494,12 @@ static const uint8_t
|
||||
};
|
||||
|
||||
// Paragraph 9.9
|
||||
|
||||
static const int kBands[16 + 1] = {
|
||||
0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7,
|
||||
0 // extra entry as sentinel
|
||||
};
|
||||
|
||||
void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
|
||||
VP8Proba* const proba = &dec->proba_;
|
||||
int t, b, c, p;
|
||||
@ -507,6 +513,9 @@ void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (b = 0; b < 16 + 1; ++b) {
|
||||
proba->bands_ptr_[t][b] = &proba->bands_[t][kBands[b]];
|
||||
}
|
||||
}
|
||||
dec->use_skip_proba_ = VP8Get(br);
|
||||
if (dec->use_skip_proba_) {
|
||||
|
@ -371,11 +371,6 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Residual decoding (Paragraph 13.2 / 13.3)
|
||||
|
||||
static const int kBands[16 + 1] = {
|
||||
0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7,
|
||||
0 // extra entry as sentinel
|
||||
};
|
||||
|
||||
static const uint8_t kCat3[] = { 173, 148, 140, 0 };
|
||||
static const uint8_t kCat4[] = { 176, 155, 140, 135, 0 };
|
||||
static const uint8_t kCat5[] = { 180, 157, 141, 134, 130, 0 };
|
||||
@ -419,20 +414,19 @@ static int GetLargeValue(VP8BitReader* const br, const uint8_t* const p) {
|
||||
}
|
||||
|
||||
// Returns the position of the last non-zero coeff plus one
|
||||
static int GetCoeffs(VP8BitReader* const br, const VP8BandProbas* const prob,
|
||||
static int GetCoeffs(VP8BitReader* const br, const VP8BandProbas* const prob[],
|
||||
int ctx, const quant_t dq, int n, int16_t* out) {
|
||||
// n is either 0 or 1 here. kBands[n] is not necessary for extracting '*p'.
|
||||
const uint8_t* p = prob[n].probas_[ctx];
|
||||
const uint8_t* p = prob[n]->probas_[ctx];
|
||||
for (; n < 16; ++n) {
|
||||
if (!VP8GetBit(br, p[0])) {
|
||||
return n; // previous coeff was last non-zero coeff
|
||||
}
|
||||
while (!VP8GetBit(br, p[1])) { // sequence of zero coeffs
|
||||
p = prob[kBands[++n]].probas_[0];
|
||||
p = prob[++n]->probas_[0];
|
||||
if (n == 16) return 16;
|
||||
}
|
||||
{ // non zero coeff
|
||||
const VP8ProbaArray* const p_ctx = &prob[kBands[n + 1]].probas_[0];
|
||||
const VP8ProbaArray* const p_ctx = &prob[n + 1]->probas_[0];
|
||||
int v;
|
||||
if (!VP8GetBit(br, p[2])) {
|
||||
v = 1;
|
||||
@ -455,8 +449,8 @@ static WEBP_INLINE uint32_t NzCodeBits(uint32_t nz_coeffs, int nz, int dc_nz) {
|
||||
|
||||
static int ParseResiduals(VP8Decoder* const dec,
|
||||
VP8MB* const mb, VP8BitReader* const token_br) {
|
||||
VP8BandProbas (* const bands)[NUM_BANDS] = dec->proba_.bands_;
|
||||
const VP8BandProbas* ac_proba;
|
||||
const VP8BandProbas* (* const bands)[16 + 1] = dec->proba_.bands_ptr_;
|
||||
const VP8BandProbas* const * ac_proba;
|
||||
VP8MBData* const block = dec->mb_data_ + dec->mb_x_;
|
||||
const VP8QuantMatrix* const q = &dec->dqm_[block->segment_];
|
||||
int16_t* dst = block->coeffs_;
|
||||
|
@ -141,6 +141,7 @@ typedef struct {
|
||||
uint8_t segments_[MB_FEATURE_TREE_PROBS];
|
||||
// Type: 0:Intra16-AC 1:Intra16-DC 2:Chroma 3:Intra4
|
||||
VP8BandProbas bands_[NUM_TYPES][NUM_BANDS];
|
||||
const VP8BandProbas* bands_ptr_[NUM_TYPES][16 + 1];
|
||||
} VP8Proba;
|
||||
|
||||
// Filter parameters
|
||||
|
Loading…
x
Reference in New Issue
Block a user