enable sparse dc/ac transforms
non-zero dc-bit was mixed with non-zero ac-bit, preventing finer optimization during VP8ReconstructBlock. Depending on sparsity, i see 2-5% gain on average. Change-Id: I7f34f18d0701c77837de3540b732e5b7d85d7c5d
This commit is contained in:
parent
07dbb8d5af
commit
4c0da7aad5
@ -386,7 +386,8 @@ static const uint8_t kZigzag[16] = {
|
|||||||
|
|
||||||
typedef const uint8_t (*ProbaArray)[NUM_CTX][NUM_PROBAS]; // for const-casting
|
typedef const uint8_t (*ProbaArray)[NUM_CTX][NUM_PROBAS]; // for const-casting
|
||||||
|
|
||||||
// Returns 1 if there's non-zero coeffs, 0 otherwise
|
// Returns the position of the last non-zero coeff plus one
|
||||||
|
// (and 0 if there's no coeff at all)
|
||||||
static int GetCoeffs(VP8BitReader* const br, ProbaArray prob,
|
static int GetCoeffs(VP8BitReader* const br, ProbaArray prob,
|
||||||
int ctx, const uint16_t dq[2], int n, int16_t* out) {
|
int ctx, const uint16_t dq[2], int n, int16_t* out) {
|
||||||
const uint8_t* p = prob[kBands[n]][ctx];
|
const uint8_t* p = prob[kBands[n]][ctx];
|
||||||
@ -433,14 +434,13 @@ static int GetCoeffs(VP8BitReader* const br, ProbaArray prob,
|
|||||||
j = kZigzag[n - 1];
|
j = kZigzag[n - 1];
|
||||||
out[j] = VP8GetSigned(br, v) * dq[j > 0];
|
out[j] = VP8GetSigned(br, v) * dq[j > 0];
|
||||||
if (n == 16 || !VP8GetBit(br, p[0])) { // EOB
|
if (n == 16 || !VP8GetBit(br, p[0])) { // EOB
|
||||||
return 1;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n == 16) {
|
if (n == 16) {
|
||||||
return 1;
|
return 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alias-safe way of converting 4bytes to 32bits.
|
// Alias-safe way of converting 4bytes to 32bits.
|
||||||
@ -483,8 +483,8 @@ static void ParseResiduals(VP8Decoder* const dec,
|
|||||||
int16_t dc[16] = { 0 };
|
int16_t dc[16] = { 0 };
|
||||||
const int ctx = mb->dc_nz_ + left_mb->dc_nz_;
|
const int ctx = mb->dc_nz_ + left_mb->dc_nz_;
|
||||||
mb->dc_nz_ = left_mb->dc_nz_ =
|
mb->dc_nz_ = left_mb->dc_nz_ =
|
||||||
GetCoeffs(token_br, (ProbaArray)dec->proba_.coeffs_[1],
|
(GetCoeffs(token_br, (ProbaArray)dec->proba_.coeffs_[1],
|
||||||
ctx, q->y2_mat_, 0, dc);
|
ctx, q->y2_mat_, 0, dc) > 0);
|
||||||
first = 1;
|
first = 1;
|
||||||
ac_prob = (ProbaArray)dec->proba_.coeffs_[0];
|
ac_prob = (ProbaArray)dec->proba_.coeffs_[0];
|
||||||
VP8TransformWHT(dc, dst);
|
VP8TransformWHT(dc, dst);
|
||||||
@ -499,10 +499,11 @@ static void ParseResiduals(VP8Decoder* const dec,
|
|||||||
int l = lnz.i8[y];
|
int l = lnz.i8[y];
|
||||||
for (x = 0; x < 4; ++x) {
|
for (x = 0; x < 4; ++x) {
|
||||||
const int ctx = l + tnz.i8[x];
|
const int ctx = l + tnz.i8[x];
|
||||||
l = GetCoeffs(token_br, ac_prob, ctx,
|
const int nz = GetCoeffs(token_br, ac_prob, ctx,
|
||||||
q->y1_mat_, first, dst);
|
q->y1_mat_, first, dst);
|
||||||
|
tnz.i8[x] = l = (nz > 0);
|
||||||
nz_dc.i8[x] = (dst[0] != 0);
|
nz_dc.i8[x] = (dst[0] != 0);
|
||||||
nz_ac.i8[x] = tnz.i8[x] = l;
|
nz_ac.i8[x] = (nz > 1);
|
||||||
dst += 16;
|
dst += 16;
|
||||||
}
|
}
|
||||||
lnz.i8[y] = l;
|
lnz.i8[y] = l;
|
||||||
@ -519,10 +520,12 @@ static void ParseResiduals(VP8Decoder* const dec,
|
|||||||
int l = lnz.i8[ch + y];
|
int l = lnz.i8[ch + y];
|
||||||
for (x = 0; x < 2; ++x) {
|
for (x = 0; x < 2; ++x) {
|
||||||
const int ctx = l + tnz.i8[ch + x];
|
const int ctx = l + tnz.i8[ch + x];
|
||||||
l = GetCoeffs(token_br, (ProbaArray)dec->proba_.coeffs_[2],
|
const int nz =
|
||||||
|
GetCoeffs(token_br, (ProbaArray)dec->proba_.coeffs_[2],
|
||||||
ctx, q->uv_mat_, 0, dst);
|
ctx, q->uv_mat_, 0, dst);
|
||||||
|
tnz.i8[ch + x] = l = (nz > 0);
|
||||||
nz_dc.i8[y * 2 + x] = (dst[0] != 0);
|
nz_dc.i8[y * 2 + x] = (dst[0] != 0);
|
||||||
nz_ac.i8[y * 2 + x] = tnz.i8[ch + x] = l;
|
nz_ac.i8[y * 2 + x] = (nz > 1);
|
||||||
dst += 16;
|
dst += 16;
|
||||||
}
|
}
|
||||||
lnz.i8[ch + y] = l;
|
lnz.i8[ch + y] = l;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user