ref: 04b1a827507edf22ae8703382422d4ced6696a88
parent: 52d1e3818910d14fee92aab71859279067e99c18
author: Sebastian Rasmussen <sebras@gmail.com>
date: Sat May 26 11:46:16 EDT 2018
jbig2dec: Reindent sources in the same way as before. Accept some whitespace changes as done by the commands from commit d3d767d9b91ae7d82c261fbdfd735f3042161032.
--- a/jbig2.c
+++ b/jbig2.c
@@ -293,12 +293,11 @@
return 0; /* need more data */
ctx->buf_rd_ix += header_size;
- if (ctx->n_segments == ctx->n_segments_max)
- {
+ if (ctx->n_segments == ctx->n_segments_max) {
Jbig2Segment **segments;
+
segments = jbig2_renew(ctx, ctx->segments, Jbig2Segment *, (ctx->n_segments_max <<= 2));
- if (segments == NULL)
- {
+ if (segments == NULL) {
ctx->state = JBIG2_FILE_EOF;
return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "could not reallocate space for more segments");
}
--- a/jbig2_arith.h
+++ b/jbig2_arith.h
@@ -28,7 +28,7 @@
Jbig2ArithState *jbig2_arith_new(Jbig2Ctx *ctx, Jbig2WordStream *ws);
/* decode a bit */
-bool jbig2_arith_decode(Jbig2ArithState *as, Jbig2ArithCx *pcx, int *code);
+bool jbig2_arith_decode(Jbig2ArithState *as, Jbig2ArithCx *pcx, int *code);
/* returns true if the end of the data stream has been reached (for sanity checks) */
-bool jbig2_arith_has_reached_marker(Jbig2ArithState *as);
+bool jbig2_arith_has_reached_marker(Jbig2ArithState *as);
--- a/jbig2_halftone.c
+++ b/jbig2_halftone.c
@@ -619,8 +619,7 @@
}
code = jbig2_page_add_result(ctx, &ctx->pages[ctx->current_page], image, region_info.x, region_info.y, region_info.op);
- if (code < 0)
- {
+ if (code < 0) {
jbig2_image_release(ctx, image);
return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable add halftone region to page");
}
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -149,7 +149,7 @@
/* clip to the dst image boundaries */
if (x < 0) {
sx += -x;
- if (sw < (uint32_t)-x)
+ if (sw < (uint32_t) -x)
sw = 0;
else
sw -= -x;
@@ -157,20 +157,20 @@
}
if (y < 0) {
sy += -y;
- if (sh < (uint32_t)-y)
+ if (sh < (uint32_t) -y)
sh = 0;
else
sh -= -y;
y = 0;
}
- if ((uint32_t)x + sw >= dst->width) {
- if (dst->width >= (uint32_t)x)
+ if ((uint32_t) x + sw >= dst->width) {
+ if (dst->width >= (uint32_t) x)
sw = dst->width - x;
else
sw = 0;
}
- if ((uint32_t)y + sh >= dst->height) {
- if (dst->height >= (uint32_t)y)
+ if ((uint32_t) y + sh >= dst->height) {
+ if (dst->height >= (uint32_t) y)
sh = dst->height - y;
else
sh = 0;
@@ -240,7 +240,7 @@
ss = src->data;
if (x < 0) {
- if (w < (uint32_t)-x)
+ if (w < (uint32_t) -x)
w = 0;
else
w += x;
@@ -247,14 +247,14 @@
x = 0;
}
if (y < 0) {
- if (h < (uint32_t)-y)
+ if (h < (uint32_t) -y)
h = 0;
else
h += y;
y = 0;
}
- w = ((uint32_t)x + w < dst->width) ? w : ((dst->width >= (uint32_t)x) ? dst->width - (uint32_t)x : 0);
- h = ((uint32_t)y + h < dst->height) ? h : ((dst->height >= (uint32_t)y) ? dst->height - (uint32_t)y : 0);
+ w = ((uint32_t) x + w < dst->width) ? w : ((dst->width >= (uint32_t) x) ? dst->width - (uint32_t) x : 0);
+ h = ((uint32_t) y + h < dst->height) ? h : ((dst->height >= (uint32_t) y) ? dst->height - (uint32_t) y : 0);
#ifdef JBIG2_DEBUG
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "compositing %dx%d at (%d, %d) after clipping", w, h, x, y);
#endif
@@ -276,8 +276,8 @@
}
#endif
- leftbyte = (uint32_t)x >> 3;
- rightbyte = ((uint32_t)x + w - 1) >> 3;
+ leftbyte = (uint32_t) x >> 3;
+ rightbyte = ((uint32_t) x + w - 1) >> 3;
shift = x & 7;
/* general OR case */
@@ -284,7 +284,7 @@
s = ss;
d = dd = dst->data + y * dst->stride + leftbyte;
if (d < dst->data || leftbyte > dst->stride || d - leftbyte + h * dst->stride > dst->data + dst->height * dst->stride ||
- s - leftbyte + (h - 1) * src->stride + rightbyte > src->data + src->height * src->stride) {
+ s - leftbyte + (h - 1) * src->stride + rightbyte > src->data + src->height * src->stride) {
return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "preventing heap overflow in jbig2_image_compose");
}
if (leftbyte == rightbyte) {
--- a/jbig2_metadata.c
+++ b/jbig2_metadata.c
@@ -107,8 +107,7 @@
/* copy the passed key,value pair */
md->keys[md->entries] = jbig2_strndup(ctx, key, key_length);
md->values[md->entries] = jbig2_strndup(ctx, value, value_length);
- if (md->keys[md->entries] == NULL || md->values[md->entries] == NULL)
- {
+ if (md->keys[md->entries] == NULL || md->values[md->entries] == NULL) {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to accomodate more metadata");
return -1;
}
--- a/jbig2_mmr.c
+++ b/jbig2_mmr.c
@@ -1022,8 +1022,7 @@
for (y = 0; y < image->height; y++) {
memset(dst, 0, rowstride);
code = jbig2_decode_mmr_line(ctx, &mmr, ref, dst);
- if (code < 0)
- {
+ if (code < 0) {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode mmr line");
return code;
}
@@ -1064,8 +1063,7 @@
for (y = 0; y < image->height; y++) {
memset(dst, 0, rowstride);
code = jbig2_decode_mmr_line(ctx, &mmr, ref, dst);
- if (code < 0)
- {
+ if (code < 0) {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode halftone mmr line");
return code;
}
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -268,6 +268,7 @@
if (page->image->height < new_height) {
Jbig2Image *resized_image = NULL;
+
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "growing page buffer to %d rows " "to accomodate new stripe", new_height);
resized_image = jbig2_image_resize(ctx, page->image, page->image->width, new_height);
if (resized_image == NULL) {
--- a/jbig2_priv.h
+++ b/jbig2_priv.h
@@ -91,7 +91,7 @@
Jbig2Page *pages;
};
-uint32_t jbig2_get_uint32(const byte *bptr);
+uint32_t jbig2_get_uint32(const byte *bptr);
int32_t jbig2_get_int32(const byte *buf);
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -512,9 +512,8 @@
/* multiple symbols are handled as a text region */
code = jbig2_decode_text_region(ctx, segment, tparams, (const Jbig2SymbolDict * const *)refagg_dicts,
- n_refagg_dicts, image, data, size, GR_stats, as, ws);
- if (code < 0)
- {
+ n_refagg_dicts, image, data, size, GR_stats, as, ws);
+ if (code < 0) {
jbig2_image_release(ctx, image);
goto cleanup4;
}
@@ -740,7 +739,7 @@
if (params->SDHUFF)
exrunlength = jbig2_huffman_get(hs, SBHUFFRSIZE, &code);
else
- code = jbig2_arith_int_decode(ctx, IAEX, as, (int32_t *)&exrunlength);
+ code = jbig2_arith_int_decode(ctx, IAEX, as, (int32_t *) &exrunlength);
/* prevent infinite loop */
zerolength = exrunlength > 0 ? 0 : zerolength + 1;
if (code || (exrunlength > limit - i) || (zerolength > 4) || (exflag && (exrunlength + j > params->SDNUMEXSYMS))) {
--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -411,9 +411,8 @@
break;
case render:
- if ((argc - filearg) == 1)
+ if ((argc - filearg) == 1) {
/* only one argument--open as a jbig2 file */
- {
char *fn = argv[filearg];
f = fopen(fn, "rb");
@@ -421,9 +420,8 @@
fprintf(stderr, "error opening %s\n", fn);
goto cleanup;
}
- } else if ((argc - filearg) == 2)
+ } else if ((argc - filearg) == 2) {
/* two arguments open as separate global and page streams */
- {
char *fn = argv[filearg];
char *fn_page = argv[filearg + 1];
@@ -488,8 +486,7 @@
Jbig2Image *image;
/* work around broken CVision embedded streams */
- if (f_page != NULL)
- {
+ if (f_page != NULL) {
code = jbig2_complete_page(ctx);
if (code < 0)
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to complete page");