mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
replace num_parts_ by num_parts_minus_one_ (unsigned)
This avoids spurious warnings and extra calculations. Change-Id: Ibbe1b893cf89ee6b31a04d7bcbf92b4b357c8628
This commit is contained in:
parent
9629f4bcda
commit
2309fd5c1d
@ -120,9 +120,9 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
|
|||||||
if (idec->dec_ != NULL) {
|
if (idec->dec_ != NULL) {
|
||||||
if (!idec->is_lossless_) {
|
if (!idec->is_lossless_) {
|
||||||
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
|
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
|
||||||
const int last_part = dec->num_parts_ - 1;
|
const uint32_t last_part = dec->num_parts_minus_one_;
|
||||||
if (offset != 0) {
|
if (offset != 0) {
|
||||||
int p;
|
uint32_t p;
|
||||||
for (p = 0; p <= last_part; ++p) {
|
for (p = 0; p <= last_part; ++p) {
|
||||||
VP8RemapBitReader(dec->parts_ + p, offset);
|
VP8RemapBitReader(dec->parts_ + p, offset);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,6 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
const uint8_t* const last_start = dec->parts_[last_part].buf_;
|
const uint8_t* const last_start = dec->parts_[last_part].buf_;
|
||||||
assert(last_part >= 0);
|
|
||||||
VP8BitReaderSetBuffer(&dec->parts_[last_part], last_start,
|
VP8BitReaderSetBuffer(&dec->parts_[last_part], last_start,
|
||||||
mem->buf_ + mem->end_ - last_start);
|
mem->buf_ + mem->end_ - last_start);
|
||||||
}
|
}
|
||||||
@ -465,19 +464,20 @@ static VP8StatusCode DecodeRemaining(WebPIDecoder* const idec) {
|
|||||||
}
|
}
|
||||||
for (; dec->mb_x_ < dec->mb_w_; ++dec->mb_x_) {
|
for (; dec->mb_x_ < dec->mb_w_; ++dec->mb_x_) {
|
||||||
VP8BitReader* const token_br =
|
VP8BitReader* const token_br =
|
||||||
&dec->parts_[dec->mb_y_ & (dec->num_parts_ - 1)];
|
&dec->parts_[dec->mb_y_ & dec->num_parts_minus_one_];
|
||||||
MBContext context;
|
MBContext context;
|
||||||
SaveContext(dec, token_br, &context);
|
SaveContext(dec, token_br, &context);
|
||||||
if (!VP8DecodeMB(dec, token_br)) {
|
if (!VP8DecodeMB(dec, token_br)) {
|
||||||
// We shouldn't fail when MAX_MB data was available
|
// We shouldn't fail when MAX_MB data was available
|
||||||
if (dec->num_parts_ == 1 && MemDataSize(&idec->mem_) > MAX_MB_SIZE) {
|
if (dec->num_parts_minus_one_ == 0 &&
|
||||||
|
MemDataSize(&idec->mem_) > MAX_MB_SIZE) {
|
||||||
return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
|
return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
|
||||||
}
|
}
|
||||||
RestoreContext(&context, dec, token_br);
|
RestoreContext(&context, dec, token_br);
|
||||||
return VP8_STATUS_SUSPENDED;
|
return VP8_STATUS_SUSPENDED;
|
||||||
}
|
}
|
||||||
// Release buffer only if there is only one partition
|
// Release buffer only if there is only one partition
|
||||||
if (dec->num_parts_ == 1) {
|
if (dec->num_parts_minus_one_ == 0) {
|
||||||
idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_;
|
idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_;
|
||||||
assert(idec->mem_.start_ <= idec->mem_.end_);
|
assert(idec->mem_.start_ <= idec->mem_.end_);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ VP8Decoder* VP8New(void) {
|
|||||||
SetOk(dec);
|
SetOk(dec);
|
||||||
WebPGetWorkerInterface()->Init(&dec->worker_);
|
WebPGetWorkerInterface()->Init(&dec->worker_);
|
||||||
dec->ready_ = 0;
|
dec->ready_ = 0;
|
||||||
dec->num_parts_ = 1;
|
dec->num_parts_minus_one_ = 0;
|
||||||
}
|
}
|
||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
@ -194,8 +194,8 @@ static VP8StatusCode ParsePartitions(VP8Decoder* const dec,
|
|||||||
size_t last_part;
|
size_t last_part;
|
||||||
size_t p;
|
size_t p;
|
||||||
|
|
||||||
dec->num_parts_ = 1 << VP8GetValue(br, 2);
|
dec->num_parts_minus_one_ = (1 << VP8GetValue(br, 2)) - 1;
|
||||||
last_part = dec->num_parts_ - 1;
|
last_part = dec->num_parts_minus_one_;
|
||||||
if (size < 3 * last_part) {
|
if (size < 3 * last_part) {
|
||||||
// we can't even read the sizes with sz[]! That's a failure.
|
// we can't even read the sizes with sz[]! That's a failure.
|
||||||
return VP8_STATUS_NOT_ENOUGH_DATA;
|
return VP8_STATUS_NOT_ENOUGH_DATA;
|
||||||
@ -586,7 +586,7 @@ static int ParseFrame(VP8Decoder* const dec, VP8Io* io) {
|
|||||||
for (dec->mb_y_ = 0; dec->mb_y_ < dec->br_mb_y_; ++dec->mb_y_) {
|
for (dec->mb_y_ = 0; dec->mb_y_ < dec->br_mb_y_; ++dec->mb_y_) {
|
||||||
// Parse bitstream for this row.
|
// Parse bitstream for this row.
|
||||||
VP8BitReader* const token_br =
|
VP8BitReader* const token_br =
|
||||||
&dec->parts_[dec->mb_y_ & (dec->num_parts_ - 1)];
|
&dec->parts_[dec->mb_y_ & dec->num_parts_minus_one_];
|
||||||
if (!VP8ParseIntraModeRow(&dec->br_, dec)) {
|
if (!VP8ParseIntraModeRow(&dec->br_, dec)) {
|
||||||
return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
|
return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
|
||||||
"Premature end-of-partition0 encountered.");
|
"Premature end-of-partition0 encountered.");
|
||||||
|
@ -209,8 +209,8 @@ struct VP8Decoder {
|
|||||||
int tl_mb_x_, tl_mb_y_; // top-left MB that must be in-loop filtered
|
int tl_mb_x_, tl_mb_y_; // top-left MB that must be in-loop filtered
|
||||||
int br_mb_x_, br_mb_y_; // last bottom-right MB that must be decoded
|
int br_mb_x_, br_mb_y_; // last bottom-right MB that must be decoded
|
||||||
|
|
||||||
// number of partitions.
|
// number of partitions minus one.
|
||||||
int num_parts_;
|
uint32_t num_parts_minus_one_;
|
||||||
// per-partition boolean decoders.
|
// per-partition boolean decoders.
|
||||||
VP8BitReader parts_[MAX_NUM_PARTITIONS];
|
VP8BitReader parts_[MAX_NUM_PARTITIONS];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user