cosmetics: add {}s on continued control statements

for consistency within the codebase. in some cases simply join the
lines.

Change-Id: I071f061052e274c8a69f651ed4305befb4414a40
This commit is contained in:
James Zern
2016-08-03 18:53:40 -07:00
parent d2e4484ef3
commit b551e587b3
11 changed files with 65 additions and 76 deletions

View File

@ -92,59 +92,35 @@ int WebPConfigInitInternal(WebPConfig* config,
int WebPValidateConfig(const WebPConfig* config) {
if (config == NULL) return 0;
if (config->quality < 0 || config->quality > 100)
return 0;
if (config->target_size < 0)
return 0;
if (config->target_PSNR < 0)
return 0;
if (config->method < 0 || config->method > 6)
return 0;
if (config->segments < 1 || config->segments > 4)
return 0;
if (config->sns_strength < 0 || config->sns_strength > 100)
return 0;
if (config->filter_strength < 0 || config->filter_strength > 100)
return 0;
if (config->filter_sharpness < 0 || config->filter_sharpness > 7)
return 0;
if (config->filter_type < 0 || config->filter_type > 1)
return 0;
if (config->autofilter < 0 || config->autofilter > 1)
return 0;
if (config->pass < 1 || config->pass > 10)
return 0;
if (config->show_compressed < 0 || config->show_compressed > 1)
return 0;
if (config->preprocessing < 0 || config->preprocessing > 7)
return 0;
if (config->partitions < 0 || config->partitions > 3)
return 0;
if (config->partition_limit < 0 || config->partition_limit > 100)
return 0;
if (config->alpha_compression < 0)
return 0;
if (config->alpha_filtering < 0)
return 0;
if (config->alpha_quality < 0 || config->alpha_quality > 100)
return 0;
if (config->lossless < 0 || config->lossless > 1)
return 0;
if (config->near_lossless < 0 || config->near_lossless > 100)
return 0;
if (config->image_hint >= WEBP_HINT_LAST)
return 0;
if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1)
return 0;
if (config->thread_level < 0 || config->thread_level > 1)
return 0;
if (config->low_memory < 0 || config->low_memory > 1)
return 0;
if (config->exact < 0 || config->exact > 1)
return 0;
if (config->quality < 0 || config->quality > 100) return 0;
if (config->target_size < 0) return 0;
if (config->target_PSNR < 0) return 0;
if (config->method < 0 || config->method > 6) return 0;
if (config->segments < 1 || config->segments > 4) return 0;
if (config->sns_strength < 0 || config->sns_strength > 100) return 0;
if (config->filter_strength < 0 || config->filter_strength > 100) return 0;
if (config->filter_sharpness < 0 || config->filter_sharpness > 7) return 0;
if (config->filter_type < 0 || config->filter_type > 1) return 0;
if (config->autofilter < 0 || config->autofilter > 1) return 0;
if (config->pass < 1 || config->pass > 10) return 0;
if (config->show_compressed < 0 || config->show_compressed > 1) return 0;
if (config->preprocessing < 0 || config->preprocessing > 7) return 0;
if (config->partitions < 0 || config->partitions > 3) return 0;
if (config->partition_limit < 0 || config->partition_limit > 100) return 0;
if (config->alpha_compression < 0) return 0;
if (config->alpha_filtering < 0) return 0;
if (config->alpha_quality < 0 || config->alpha_quality > 100) return 0;
if (config->lossless < 0 || config->lossless > 1) return 0;
if (config->near_lossless < 0 || config->near_lossless > 100) return 0;
if (config->image_hint >= WEBP_HINT_LAST) return 0;
if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1) return 0;
if (config->thread_level < 0 || config->thread_level > 1) return 0;
if (config->low_memory < 0 || config->low_memory > 1) return 0;
if (config->exact < 0 || config->exact > 1) return 0;
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (config->delta_palettization < 0 || config->delta_palettization > 1)
if (config->delta_palettization < 0 || config->delta_palettization > 1) {
return 0;
}
#endif // WEBP_EXPERIMENTAL_FEATURES
return 1;
}

View File

@ -248,8 +248,9 @@ static int PutCoeffs(VP8BitWriter* const bw, int ctx, const VP8Residual* res) {
p = res->prob[VP8EncBands[n]][1];
} else {
if (!VP8PutBit(bw, v > 4, p[3])) {
if (VP8PutBit(bw, v != 2, p[4]))
if (VP8PutBit(bw, v != 2, p[4])) {
VP8PutBit(bw, v == 4, p[5]);
}
} else if (!VP8PutBit(bw, v > 10, p[6])) {
if (!VP8PutBit(bw, v > 6, p[7])) {
VP8PutBit(bw, v == 6, 159);
@ -557,8 +558,9 @@ static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
size += info.R + info.H;
size_p0 += info.H;
distortion += info.D;
if (percent_delta && !VP8IteratorProgress(&it, percent_delta))
if (percent_delta && !VP8IteratorProgress(&it, percent_delta)) {
return 0;
}
VP8IteratorSaveBoundary(&it);
} while (VP8IteratorNext(&it) && --nb_mbs > 0);

View File

@ -362,8 +362,7 @@ int VP8EncWrite(VP8Encoder* const enc) {
for (p = 0; p < enc->num_parts_; ++p) {
const uint8_t* const buf = VP8BitWriterBuf(enc->parts_ + p);
const size_t size = VP8BitWriterSize(enc->parts_ + p);
if (size)
ok = ok && pic->writer(buf, size, pic);
if (size) ok = ok && pic->writer(buf, size, pic);
VP8BitWriterWipeOut(enc->parts_ + p); // will free the internal buffer.
ok = ok && WebPReportProgress(pic, enc->percent_ + percent_per_part,
&enc->percent_);

View File

@ -137,8 +137,9 @@ int VP8RecordCoeffTokens(int ctx, const struct VP8Residual* const res,
s = res->stats[VP8EncBands[n]][1];
} else {
if (!AddToken(tokens, v > 4, base_id + 3, s + 3)) {
if (AddToken(tokens, v != 2, base_id + 4, s + 4))
if (AddToken(tokens, v != 2, base_id + 4, s + 4)) {
AddToken(tokens, v == 4, base_id + 5, s + 5);
}
} else if (!AddToken(tokens, v > 10, base_id + 6, s + 6)) {
if (!AddToken(tokens, v > 6, base_id + 7, s + 7)) {
AddConstantToken(tokens, v == 6, 159);

View File

@ -315,18 +315,21 @@ int WebPReportProgress(const WebPPicture* const pic,
int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
int ok = 0;
if (pic == NULL) return 0;
if (pic == NULL)
return 0;
WebPEncodingSetError(pic, VP8_ENC_OK); // all ok so far
if (config == NULL) // bad params
if (config == NULL) { // bad params
return WebPEncodingSetError(pic, VP8_ENC_ERROR_NULL_PARAMETER);
if (!WebPValidateConfig(config))
}
if (!WebPValidateConfig(config)) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_INVALID_CONFIGURATION);
if (pic->width <= 0 || pic->height <= 0)
}
if (pic->width <= 0 || pic->height <= 0) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION)
}
if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
}
if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats));