jsimd_set_ycc_rgb:
  241|      1|{
  242|      1|  init_simd((j_common_ptr)cinfo);
  243|       |
  244|      1|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|      1|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (244:7): [Folded, False: 1]
  ------------------
  245|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  246|      1|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (246:7): [Folded, False: 1]
  ------------------
  247|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  248|      1|  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|      1|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
                if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|      0|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
  |  Branch (248:7): [Folded, False: 1]
  |  Branch (248:31): [True: 0, Folded]
  ------------------
  249|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  250|      1|  if (!cinfo->cconvert)
  ------------------
  |  Branch (250:7): [True: 0, False: 1]
  ------------------
  251|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  252|       |
  253|      1|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  254|      1|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|      1|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (254:7): [True: 1, False: 0]
  ------------------
  255|      1|      IS_ALIGNED_AVX(jconst_ycc_rgb_convert_avx2)) {
  ------------------
  |  |   46|      1|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      1|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  256|      1|    SET_SIMD_EXTRGB_COLOR_DECONVERTER(avx2);
  ------------------
  |  |  128|      1|#define SET_SIMD_EXTRGB_COLOR_DECONVERTER(instrset) { \
  |  |  129|      1|  switch (cinfo->out_color_space) { \
  |  |  130|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (130:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  131|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  132|      0|        jsimd_ycc_extrgb_convert_##instrset; \
  |  |  133|      0|      break; \
  |  |  134|      0|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (134:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  135|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (135:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  136|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  137|      0|        jsimd_ycc_extrgbx_convert_##instrset; \
  |  |  138|      0|      break; \
  |  |  139|      0|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (139:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  140|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  141|      0|        jsimd_ycc_extbgr_convert_##instrset; \
  |  |  142|      0|      break; \
  |  |  143|      0|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (143:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  144|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (144:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  145|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  146|      0|        jsimd_ycc_extbgrx_convert_##instrset; \
  |  |  147|      0|      break; \
  |  |  148|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (148:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  149|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (149:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  150|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  151|      0|        jsimd_ycc_extxbgr_convert_##instrset; \
  |  |  152|      0|      break; \
  |  |  153|      0|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  154|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (154:5): [True: 0, False: 1]
  |  |  ------------------
  |  |  155|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  156|      0|        jsimd_ycc_extxrgb_convert_##instrset; \
  |  |  157|      0|      break; \
  |  |  158|      1|    default: \
  |  |  ------------------
  |  |  |  Branch (158:5): [True: 1, False: 0]
  |  |  ------------------
  |  |  159|      1|      cinfo->cconvert->color_convert_simd = \
  |  |  160|      1|        jsimd_ycc_rgb_convert_##instrset; \
  |  |  161|      1|  } \
  |  |  162|      1|}
  ------------------
  257|      1|    return JSIMD_AVX2;
  ------------------
  |  |   46|      1|#define JSIMD_AVX2       0x80
  ------------------
  258|      1|  }
  259|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (259:7): [True: 0, False: 0]
  ------------------
  260|      0|      IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  261|      0|    SET_SIMD_EXTRGB_COLOR_DECONVERTER(sse2);
  ------------------
  |  |  128|      0|#define SET_SIMD_EXTRGB_COLOR_DECONVERTER(instrset) { \
  |  |  129|      0|  switch (cinfo->out_color_space) { \
  |  |  130|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (130:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  131|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  132|      0|        jsimd_ycc_extrgb_convert_##instrset; \
  |  |  133|      0|      break; \
  |  |  134|      0|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (134:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  135|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (135:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  136|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  137|      0|        jsimd_ycc_extrgbx_convert_##instrset; \
  |  |  138|      0|      break; \
  |  |  139|      0|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (139:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  140|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  141|      0|        jsimd_ycc_extbgr_convert_##instrset; \
  |  |  142|      0|      break; \
  |  |  143|      0|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (143:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  144|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (144:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  145|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  146|      0|        jsimd_ycc_extbgrx_convert_##instrset; \
  |  |  147|      0|      break; \
  |  |  148|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (148:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  149|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (149:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  150|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  151|      0|        jsimd_ycc_extxbgr_convert_##instrset; \
  |  |  152|      0|      break; \
  |  |  153|      0|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  154|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (154:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  155|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  156|      0|        jsimd_ycc_extxrgb_convert_##instrset; \
  |  |  157|      0|      break; \
  |  |  158|      0|    default: \
  |  |  ------------------
  |  |  |  Branch (158:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  159|      0|      cinfo->cconvert->color_convert_simd = \
  |  |  160|      0|        jsimd_ycc_rgb_convert_##instrset; \
  |  |  161|      0|  } \
  |  |  162|      0|}
  ------------------
  262|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  263|      0|  }
  264|       |#if SIMD_ARCHITECTURE == I386
  265|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  266|       |    SET_SIMD_EXTRGB_COLOR_DECONVERTER(mmx);
  267|       |    return JSIMD_MMX;
  268|       |  }
  269|       |#endif
  270|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  271|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  272|       |    SET_SIMD_EXTRGB_COLOR_DECONVERTER(neon);
  273|       |    return JSIMD_NEON;
  274|       |  }
  275|       |#elif SIMD_ARCHITECTURE == POWERPC
  276|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  277|       |    SET_SIMD_EXTRGB_COLOR_DECONVERTER(altivec);
  278|       |    return JSIMD_ALTIVEC;
  279|       |  }
  280|       |#elif SIMD_ARCHITECTURE == RISCV64
  281|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  282|       |    SET_SIMD_EXTRGB_COLOR_DECONVERTER(rvv);
  283|       |    return JSIMD_RVV;
  284|       |  }
  285|       |#elif SIMD_ARCHITECTURE == MIPS64
  286|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  287|       |    SET_SIMD_EXTRGB_COLOR_DECONVERTER(mmi);
  288|       |    return JSIMD_MMI;
  289|       |  }
  290|       |#endif
  291|       |
  292|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  293|      0|}
jsimd_set_h2v2_fancy_upsample:
  637|      2|{
  638|      2|  init_simd((j_common_ptr)cinfo);
  639|       |
  640|      2|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|      2|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (640:7): [Folded, False: 2]
  ------------------
  641|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  642|      2|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (642:7): [Folded, False: 2]
  ------------------
  643|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  644|      2|  if (!cinfo->upsample)
  ------------------
  |  Branch (644:7): [True: 0, False: 2]
  ------------------
  645|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  646|       |
  647|      2|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  648|      2|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|      2|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (648:7): [True: 2, False: 0]
  ------------------
  649|      2|      IS_ALIGNED_AVX(jconst_fancy_upsample_avx2)) {
  ------------------
  |  |   46|      2|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      2|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  650|      2|    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_avx2;
  651|      2|    return JSIMD_AVX2;
  ------------------
  |  |   46|      2|#define JSIMD_AVX2       0x80
  ------------------
  652|      2|  }
  653|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (653:7): [True: 0, False: 0]
  ------------------
  654|      0|      IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  655|      0|    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_sse2;
  656|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  657|      0|  }
  658|       |#if SIMD_ARCHITECTURE == I386
  659|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  660|       |    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_mmx;
  661|       |    return JSIMD_MMX;
  662|       |  }
  663|       |#endif
  664|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  665|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  666|       |    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_neon;
  667|       |    return JSIMD_NEON;
  668|       |  }
  669|       |#elif SIMD_ARCHITECTURE == POWERPC
  670|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  671|       |    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_altivec;
  672|       |    return JSIMD_ALTIVEC;
  673|       |  }
  674|       |#elif SIMD_ARCHITECTURE == RISCV64
  675|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  676|       |    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_rvv;
  677|       |    return JSIMD_RVV;
  678|       |  }
  679|       |#elif SIMD_ARCHITECTURE == MIPS64
  680|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  681|       |    cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_mmi;
  682|       |    return JSIMD_MMI;
  683|       |  }
  684|       |#endif
  685|       |
  686|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  687|      0|}
jsimd_set_idct_islow:
 1153|  22.8k|{
 1154|  22.8k|  init_simd((j_common_ptr)cinfo);
 1155|       |
 1156|  22.8k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1156:7): [Folded, False: 22.8k]
  ------------------
 1157|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1158|  22.8k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (1158:7): [Folded, False: 22.8k]
  ------------------
 1159|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1160|  22.8k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (1160:7): [Folded, False: 22.8k]
  ------------------
 1161|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1162|  22.8k|  if (sizeof(ISLOW_MULT_TYPE) != 2)
  ------------------
  |  Branch (1162:7): [Folded, False: 22.8k]
  ------------------
 1163|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1164|  22.8k|  if (!cinfo->idct)
  ------------------
  |  Branch (1164:7): [True: 0, False: 22.8k]
  ------------------
 1165|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1166|       |
 1167|  22.8k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1168|  22.8k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  22.8k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (1168:7): [True: 22.8k, False: 0]
  ------------------
 1169|  22.8k|      IS_ALIGNED_AVX(jconst_idct_islow_avx2)) {
  ------------------
  |  |   46|  22.8k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  22.8k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 22.8k, False: 0]
  |  |  ------------------
  ------------------
 1170|  22.8k|    cinfo->idct->idct_simd = jsimd_idct_islow_avx2;
 1171|  22.8k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  22.8k|#define JSIMD_AVX2       0x80
  ------------------
 1172|  22.8k|  }
 1173|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1173:7): [True: 0, False: 0]
  ------------------
 1174|      0|      IS_ALIGNED_SSE(jconst_idct_islow_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1175|      0|    cinfo->idct->idct_simd = jsimd_idct_islow_sse2;
 1176|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
 1177|      0|  }
 1178|       |#if SIMD_ARCHITECTURE == I386
 1179|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
 1180|       |    cinfo->idct->idct_simd = jsimd_idct_islow_mmx;
 1181|       |    return JSIMD_MMX;
 1182|       |  }
 1183|       |#endif
 1184|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1185|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
 1186|       |    cinfo->idct->idct_simd = jsimd_idct_islow_neon;
 1187|       |    return JSIMD_NEON;
 1188|       |  }
 1189|       |#elif SIMD_ARCHITECTURE == POWERPC
 1190|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
 1191|       |    cinfo->idct->idct_simd = jsimd_idct_islow_altivec;
 1192|       |    return JSIMD_ALTIVEC;
 1193|       |  }
 1194|       |#elif SIMD_ARCHITECTURE == RISCV64
 1195|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
 1196|       |    cinfo->idct->idct_simd = jsimd_idct_islow_rvv;
 1197|       |    return JSIMD_RVV;
 1198|       |  }
 1199|       |#elif SIMD_ARCHITECTURE == MIPS64
 1200|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
 1201|       |    cinfo->idct->idct_simd = jsimd_idct_islow_mmi;
 1202|       |    return JSIMD_MMI;
 1203|       |  }
 1204|       |#endif
 1205|       |
 1206|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1207|      0|}
jsimd_idct_islow:
 1214|  1.26M|{
 1215|  1.26M|  cinfo->idct->idct_simd(compptr->dct_table, coef_block, output_buf,
 1216|  1.26M|                         output_col);
 1217|  1.26M|}
jsimd.c:init_simd:
   56|  22.8k|{
   57|  22.8k|#ifndef NO_GETENV
   58|  22.8k|  char env[2] = { 0 };
   59|  22.8k|#endif
   60|  22.8k|  unsigned int simd_support = cinfo->is_decompressor ?
  ------------------
  |  Branch (60:31): [True: 22.8k, False: 0]
  ------------------
   61|  22.8k|                              ((j_decompress_ptr)cinfo)->master->simd_support :
   62|  22.8k|                              ((j_compress_ptr)cinfo)->master->simd_support;
   63|  22.8k|  unsigned int simd_huffman = cinfo->is_decompressor ?
  ------------------
  |  Branch (63:31): [True: 22.8k, False: 0]
  ------------------
   64|  22.8k|                              ((j_decompress_ptr)cinfo)->master->simd_huffman :
   65|  22.8k|                              ((j_compress_ptr)cinfo)->master->simd_huffman;
   66|       |
   67|  22.8k|  if (simd_support != JSIMD_UNDEFINED)
  ------------------
  |  |   49|  22.8k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  22.8k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  |  Branch (67:7): [True: 58, False: 22.8k]
  ------------------
   68|     58|    return;
   69|       |
   70|  22.8k|  simd_support = jpeg_simd_cpu_support();
   71|       |
   72|  22.8k|#ifndef NO_GETENV
   73|       |  /* Force different settings through environment variables */
   74|  22.8k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
   75|  22.8k|  if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
  ------------------
  |  Branch (75:7): [True: 22.8k, False: 0]
  |  Branch (75:47): [True: 0, False: 22.8k]
  ------------------
   76|      0|    simd_support &= JSIMD_SSE2 | JSIMD_SSE;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
                  simd_support &= JSIMD_SSE2 | JSIMD_SSE;
  ------------------
  |  |   41|      0|#define JSIMD_SSE        0x04
  ------------------
   77|       |#if SIMD_ARCHITECTURE == I386
   78|       |  if (!GETENV_S(env, 2, "JSIMD_FORCESSE") && !strcmp(env, "1"))
   79|       |    simd_support &= JSIMD_SSE | JSIMD_MMX;
   80|       |  if (!GETENV_S(env, 2, "JSIMD_FORCEMMX") && !strcmp(env, "1"))
   81|       |    simd_support &= JSIMD_MMX;
   82|       |  if (!GETENV_S(env, 2, "JSIMD_FORCE3DNOW") && !strcmp(env, "1"))
   83|       |    simd_support &= JSIMD_3DNOW | JSIMD_MMX;
   84|       |#endif
   85|       |#elif SIMD_ARCHITECTURE == ARM
   86|       |  if (!GETENV_S(env, 2, "JSIMD_FORCENEON") && !strcmp(env, "1"))
   87|       |    simd_support = JSIMD_NEON;
   88|       |#elif SIMD_ARCHITECTURE == RISCV64
   89|       |  if (!GETENV_S(env, 2, "JSIMD_FORCERVV") && !strcmp(env, "1"))
   90|       |    simd_support = JSIMD_RVV;
   91|       |#elif SIMD_ARCHITECTURE == MIPS64
   92|       |  if (!GETENV_S(env, 2, "JSIMD_FORCEMMI") && !strcmp(env, "1"))
   93|       |    simd_support = JSIMD_MMI;
   94|       |#endif
   95|  22.8k|  if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
  ------------------
  |  Branch (95:7): [True: 22.8k, False: 0]
  |  Branch (95:47): [True: 0, False: 22.8k]
  ------------------
   96|      0|    simd_support = 0;
   97|       |#ifdef WITH_SIMDE
   98|       |  if (!GETENV_S(env, 2, "JSIMD_HUFFENC") && !strcmp(env, "1"))
   99|       |    simd_huffman = 1;
  100|       |#else
  101|  22.8k|  if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
  ------------------
  |  Branch (101:7): [True: 22.8k, False: 0]
  |  Branch (101:47): [True: 0, False: 22.8k]
  ------------------
  102|      0|    simd_huffman = 0;
  103|  22.8k|#endif
  104|  22.8k|#endif
  105|       |
  106|  22.8k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (106:7): [True: 22.8k, False: 0]
  ------------------
  107|  22.8k|    ((j_decompress_ptr)cinfo)->master->simd_support = simd_support;
  108|  22.8k|    ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  109|  22.8k|  } else {
  110|      0|    ((j_compress_ptr)cinfo)->master->simd_support = simd_support;
  111|      0|    ((j_compress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  112|      0|  }
  113|  22.8k|}

jpeg_abort:
   37|  75.3k|{
   38|  75.3k|  int pool;
   39|       |
   40|       |  /* Do nothing if called on a not-initialized or destroyed JPEG object. */
   41|  75.3k|  if (cinfo->mem == NULL)
  ------------------
  |  Branch (41:7): [True: 0, False: 75.3k]
  ------------------
   42|      0|    return;
   43|       |
   44|       |  /* Releasing pools in reverse order might help avoid fragmentation
   45|       |   * with some (brain-damaged) malloc libraries.
   46|       |   */
   47|   150k|  for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  75.3k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|   150k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (47:35): [True: 75.3k, False: 75.3k]
  ------------------
   48|  75.3k|    (*cinfo->mem->free_pool) (cinfo, pool);
   49|  75.3k|  }
   50|       |
   51|       |  /* Reset overall state for possible reuse of object */
   52|  75.3k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (52:7): [True: 75.3k, False: 0]
  ------------------
   53|  75.3k|    cinfo->global_state = DSTATE_START;
  ------------------
  |  |   48|  75.3k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
   54|       |    /* Try to keep application from accessing now-deleted marker list.
   55|       |     * A bit kludgy to do it here, but this is the most central place.
   56|       |     */
   57|  75.3k|    ((j_decompress_ptr)cinfo)->marker_list = NULL;
   58|  75.3k|    ((j_decompress_ptr)cinfo)->master->marker_list_end = NULL;
   59|  75.3k|  } else {
   60|      0|    cinfo->global_state = CSTATE_START;
  ------------------
  |  |   44|      0|#define CSTATE_START     100    /* after create_compress */
  ------------------
   61|      0|  }
   62|       |
   63|       |#ifdef WITH_PROFILE
   64|       |  if (cinfo->is_decompressor) {
   65|       |    if (((j_decompress_ptr)cinfo)->master->total_start > 0.0)
   66|       |      ((j_decompress_ptr)cinfo)->master->total_elapsed +=
   67|       |        getTime() - ((j_decompress_ptr)cinfo)->master->total_start;
   68|       |  } else {
   69|       |    if (((j_compress_ptr)cinfo)->master->total_start > 0.0)
   70|       |      ((j_compress_ptr)cinfo)->master->total_elapsed +=
   71|       |        getTime() - ((j_compress_ptr)cinfo)->master->total_start;
   72|       |  }
   73|       |#endif
   74|  75.3k|}
jpeg_destroy:
   90|  23.3k|{
   91|       |#ifdef WITH_PROFILE
   92|       |  if (cinfo->is_decompressor) {
   93|       |    j_decompress_ptr dinfo = (j_decompress_ptr)cinfo;
   94|       |
   95|       |    if (dinfo->master->entropy_mcoeffs > 0.0) {
   96|       |      fprintf(stderr, "Entropy decoding:    %14.6f Mcoefficients/sec",
   97|       |              dinfo->master->entropy_mcoeffs / dinfo->master->entropy_elapsed);
   98|       |      if (dinfo->master->total_elapsed > 0.0)
   99|       |        fprintf(stderr, "  (%5.2f%% of total time)",
  100|       |                dinfo->master->entropy_elapsed * 100.0 /
  101|       |                  dinfo->master->total_elapsed);
  102|       |      fprintf(stderr, "\n");
  103|       |    }
  104|       |    if (dinfo->master->idct_mcoeffs > 0.0) {
  105|       |      fprintf(stderr, "Inverse DCT:         %14.6f Mcoefficients/sec",
  106|       |              dinfo->master->idct_mcoeffs / dinfo->master->idct_elapsed);
  107|       |      if (dinfo->master->total_elapsed > 0.0)
  108|       |        fprintf(stderr, "  (%5.2f%% of total time)",
  109|       |                dinfo->master->idct_elapsed * 100.0 /
  110|       |                  dinfo->master->total_elapsed);
  111|       |      fprintf(stderr, "\n");
  112|       |    }
  113|       |    if (dinfo->master->merged_upsample_mpixels > 0.0) {
  114|       |      fprintf(stderr, "Merged upsampling:   %14.6f Mpixels/sec",
  115|       |              dinfo->master->merged_upsample_mpixels /
  116|       |                dinfo->master->merged_upsample_elapsed);
  117|       |      if (dinfo->master->total_elapsed > 0.0)
  118|       |        fprintf(stderr, "        (%5.2f%% of total time)",
  119|       |                dinfo->master->merged_upsample_elapsed * 100.0 /
  120|       |                  dinfo->master->total_elapsed);
  121|       |      fprintf(stderr, "\n");
  122|       |    }
  123|       |    if (dinfo->master->upsample_msamples > 0.0) {
  124|       |      fprintf(stderr, "Upsampling:          %14.6f Msamples/sec",
  125|       |              dinfo->master->upsample_msamples /
  126|       |                dinfo->master->upsample_elapsed);
  127|       |      if (dinfo->master->total_elapsed > 0.0)
  128|       |        fprintf(stderr, "       (%5.2f%% of total time)",
  129|       |                dinfo->master->upsample_elapsed * 100.0 /
  130|       |                  dinfo->master->total_elapsed);
  131|       |      fprintf(stderr, "\n");
  132|       |    }
  133|       |    if (dinfo->master->cconvert_mpixels > 0.0) {
  134|       |      fprintf(stderr, "Color deconversion:  %14.6f Mpixels/sec",
  135|       |              dinfo->master->cconvert_mpixels /
  136|       |                dinfo->master->cconvert_elapsed);
  137|       |      if (dinfo->master->total_elapsed > 0.0)
  138|       |        fprintf(stderr, "        (%5.2f%% of total time)",
  139|       |                dinfo->master->cconvert_elapsed * 100.0 /
  140|       |                  dinfo->master->total_elapsed);
  141|       |      fprintf(stderr, "\n");
  142|       |    }
  143|       |  } else {
  144|       |    j_compress_ptr _cinfo = (j_compress_ptr)cinfo;
  145|       |
  146|       |    if (_cinfo->master->cconvert_mpixels > 0.0) {
  147|       |      fprintf(stderr, "Color conversion:    %14.6f Mpixels/sec",
  148|       |              _cinfo->master->cconvert_mpixels /
  149|       |                _cinfo->master->cconvert_elapsed);
  150|       |      if (_cinfo->master->total_elapsed > 0.0)
  151|       |        fprintf(stderr, "        (%5.2f%% of total time)",
  152|       |                _cinfo->master->cconvert_elapsed * 100.0 /
  153|       |                  _cinfo->master->total_elapsed);
  154|       |      fprintf(stderr, "\n");
  155|       |    }
  156|       |    if (_cinfo->master->downsample_msamples > 0.0) {
  157|       |      fprintf(stderr, "Downsampling:        %14.6f Msamples/sec",
  158|       |              _cinfo->master->downsample_msamples /
  159|       |                _cinfo->master->downsample_elapsed);
  160|       |      if (_cinfo->master->total_elapsed > 0.0)
  161|       |        fprintf(stderr, "       (%5.2f%% of total time)",
  162|       |                _cinfo->master->downsample_elapsed * 100.0 /
  163|       |                  _cinfo->master->total_elapsed);
  164|       |      fprintf(stderr, "\n");
  165|       |    }
  166|       |    if (_cinfo->master->convsamp_msamples > 0.0) {
  167|       |      fprintf(stderr, "Sample conversion:   %14.6f Msamples/sec",
  168|       |              _cinfo->master->convsamp_msamples /
  169|       |                _cinfo->master->convsamp_elapsed);
  170|       |      if (_cinfo->master->total_elapsed > 0.0)
  171|       |        fprintf(stderr, "       (%5.2f%% of total time)",
  172|       |                _cinfo->master->convsamp_elapsed * 100.0 /
  173|       |                  _cinfo->master->total_elapsed);
  174|       |      fprintf(stderr, "\n");
  175|       |    }
  176|       |    if (_cinfo->master->fdct_mcoeffs > 0.0) {
  177|       |      fprintf(stderr, "Forward DCT:         %14.6f Mcoefficients/sec",
  178|       |              _cinfo->master->fdct_mcoeffs / _cinfo->master->fdct_elapsed);
  179|       |      if (_cinfo->master->total_elapsed > 0.0)
  180|       |        fprintf(stderr, "  (%5.2f%% of total time)",
  181|       |                _cinfo->master->fdct_elapsed * 100.0 /
  182|       |                  _cinfo->master->total_elapsed);
  183|       |      fprintf(stderr, "\n");
  184|       |    }
  185|       |    if (_cinfo->master->quantize_mcoeffs > 0.0) {
  186|       |      fprintf(stderr, "Quantization:        %14.6f Mcoefficients/sec",
  187|       |              _cinfo->master->quantize_mcoeffs /
  188|       |                _cinfo->master->quantize_elapsed);
  189|       |      if (_cinfo->master->total_elapsed > 0.0)
  190|       |        fprintf(stderr, "  (%5.2f%% of total time)",
  191|       |                _cinfo->master->quantize_elapsed * 100.0 /
  192|       |                  _cinfo->master->total_elapsed);
  193|       |      fprintf(stderr, "\n");
  194|       |    }
  195|       |    if (_cinfo->master->entropy_mcoeffs > 0.0) {
  196|       |      fprintf(stderr, "Entropy encoding:    %14.6f Mcoefficients/sec",
  197|       |              _cinfo->master->entropy_mcoeffs /
  198|       |                _cinfo->master->entropy_elapsed);
  199|       |      if (_cinfo->master->total_elapsed > 0.0)
  200|       |        fprintf(stderr, "  (%5.2f%% of total time)",
  201|       |                _cinfo->master->entropy_elapsed * 100.0 /
  202|       |                  _cinfo->master->total_elapsed);
  203|       |      fprintf(stderr, "\n");
  204|       |    }
  205|       |  }
  206|       |#endif
  207|       |
  208|       |  /* We need only tell the memory manager to release everything. */
  209|       |  /* NB: mem pointer is NULL if memory mgr failed to initialize. */
  210|  23.3k|  if (cinfo->mem != NULL)
  ------------------
  |  Branch (210:7): [True: 23.3k, False: 0]
  ------------------
  211|  23.3k|    (*cinfo->mem->self_destruct) (cinfo);
  212|       |  cinfo->mem = NULL;            /* be safe if jpeg_destroy is called twice */
  213|  23.3k|  cinfo->global_state = 0;      /* mark it destroyed */
  214|  23.3k|}
jpeg_alloc_quant_table:
  224|  23.0k|{
  225|  23.0k|  JQUANT_TBL *tbl;
  226|       |
  227|  23.0k|  tbl = (JQUANT_TBL *)
  228|  23.0k|    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JQUANT_TBL));
  ------------------
  |  |  888|  23.0k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  229|  23.0k|  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
  ------------------
  |  |  207|  23.0k|#define FALSE   0               /* values of boolean */
  ------------------
  230|  23.0k|  return tbl;
  231|  23.0k|}
jpeg_alloc_huff_table:
  236|  91.5k|{
  237|  91.5k|  JHUFF_TBL *tbl;
  238|       |
  239|  91.5k|  tbl = (JHUFF_TBL *)
  240|  91.5k|    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JHUFF_TBL));
  ------------------
  |  |  888|  91.5k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  241|  91.5k|  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
  ------------------
  |  |  207|  91.5k|#define FALSE   0               /* values of boolean */
  ------------------
  242|  91.5k|  return tbl;
  243|  91.5k|}

jpeg_CreateDecompress:
   40|  23.3k|{
   41|  23.3k|  int i;
   42|       |
   43|       |  /* Guard against version mismatches between library and caller. */
   44|  23.3k|  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
   45|  23.3k|  if (version != JPEG_LIB_VERSION)
  ------------------
  |  |    4|  23.3k|#define JPEG_LIB_VERSION  62
  ------------------
  |  Branch (45:7): [True: 0, False: 23.3k]
  ------------------
   46|      0|    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
  ------------------
  |  |  247|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  248|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|      0|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   47|  23.3k|  if (structsize != sizeof(struct jpeg_decompress_struct))
  ------------------
  |  Branch (47:7): [True: 0, False: 23.3k]
  ------------------
   48|      0|    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
  ------------------
  |  |  247|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  248|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|      0|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   49|  23.3k|             (int)sizeof(struct jpeg_decompress_struct), (int)structsize);
   50|       |
   51|       |  /* For debugging purposes, we zero the whole master structure.
   52|       |   * But the application has already set the err pointer, and may have set
   53|       |   * client_data, so we have to save and restore those fields.
   54|       |   * Note: if application hasn't set client_data, tools like Purify may
   55|       |   * complain here.
   56|       |   */
   57|  23.3k|  {
   58|  23.3k|    struct jpeg_error_mgr *err = cinfo->err;
   59|  23.3k|    void *client_data = cinfo->client_data; /* ignore Purify complaint here */
   60|  23.3k|    memset(cinfo, 0, sizeof(struct jpeg_decompress_struct));
   61|  23.3k|    cinfo->err = err;
   62|  23.3k|    cinfo->client_data = client_data;
   63|  23.3k|  }
   64|  23.3k|  cinfo->is_decompressor = TRUE;
  ------------------
  |  |  210|  23.3k|#define TRUE    1
  ------------------
   65|       |
   66|       |  /* Initialize a memory manager instance for this object */
   67|  23.3k|  jinit_memory_mgr((j_common_ptr)cinfo);
   68|       |
   69|       |  /* Zero out pointers to permanent structures. */
   70|  23.3k|  cinfo->progress = NULL;
   71|  23.3k|  cinfo->src = NULL;
   72|       |
   73|   116k|  for (i = 0; i < NUM_QUANT_TBLS; i++)
  ------------------
  |  |   68|   116k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (73:15): [True: 93.4k, False: 23.3k]
  ------------------
   74|  93.4k|    cinfo->quant_tbl_ptrs[i] = NULL;
   75|       |
   76|   116k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   116k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (76:15): [True: 93.4k, False: 23.3k]
  ------------------
   77|  93.4k|    cinfo->dc_huff_tbl_ptrs[i] = NULL;
   78|  93.4k|    cinfo->ac_huff_tbl_ptrs[i] = NULL;
   79|  93.4k|  }
   80|       |
   81|       |  /* Initialize marker processor so application can override methods
   82|       |   * for COM, APPn markers before calling jpeg_read_header.
   83|       |   */
   84|  23.3k|  cinfo->marker_list = NULL;
   85|  23.3k|  jinit_marker_reader(cinfo);
   86|       |
   87|       |  /* And initialize the overall input controller. */
   88|  23.3k|  jinit_input_controller(cinfo);
   89|       |
   90|  23.3k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  |   34|  23.3k|#define BITS_IN_JSAMPLE  8
  ------------------
   91|       |
   92|       |  /* OK, I'm ready */
   93|  23.3k|  cinfo->global_state = DSTATE_START;
  ------------------
  |  |   48|  23.3k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
   94|       |
   95|       |  /* The master struct is used to store extension parameters, so we allocate it
   96|       |   * here.
   97|       |   */
   98|  23.3k|  cinfo->master = (struct jpeg_decomp_master *)
   99|  23.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  23.3k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  100|  23.3k|                                sizeof(my_decomp_master));
  101|  23.3k|  memset(cinfo->master, 0, sizeof(my_decomp_master));
  102|  23.3k|#ifdef WITH_SIMD
  103|  23.3k|  cinfo->master->simd_support = JSIMD_UNDEFINED;
  ------------------
  |  |   49|  23.3k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  23.3k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  104|  23.3k|#ifndef WITH_SIMDE
  105|  23.3k|  cinfo->master->simd_huffman = 1;
  106|  23.3k|#endif
  107|  23.3k|#endif
  108|  23.3k|}
jpeg_read_header:
  277|  60.6k|{
  278|  60.6k|  int retcode;
  279|       |
  280|  60.6k|  if (cinfo->global_state != DSTATE_START &&
  ------------------
  |  |   48|   121k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
  |  Branch (280:7): [True: 0, False: 60.6k]
  ------------------
  281|      0|      cinfo->global_state != DSTATE_INHEADER)
  ------------------
  |  |   49|      0|#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
  ------------------
  |  Branch (281:7): [True: 0, False: 0]
  ------------------
  282|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  283|       |
  284|  60.6k|  retcode = jpeg_consume_input(cinfo);
  285|       |
  286|  60.6k|  switch (retcode) {
  ------------------
  |  Branch (286:11): [True: 26.4k, False: 34.1k]
  ------------------
  287|  22.8k|  case JPEG_REACHED_SOS:
  ------------------
  |  | 1111|  22.8k|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (287:3): [True: 22.8k, False: 37.7k]
  ------------------
  288|  22.8k|    retcode = JPEG_HEADER_OK;
  ------------------
  |  | 1066|  22.8k|#define JPEG_HEADER_OK           1 /* Found valid image datastream */
  ------------------
  289|  22.8k|    break;
  290|  3.58k|  case JPEG_REACHED_EOI:
  ------------------
  |  | 1112|  3.58k|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  |  Branch (290:3): [True: 3.58k, False: 57.0k]
  ------------------
  291|  3.58k|    if (require_image)          /* Complain if application wanted an image */
  ------------------
  |  Branch (291:9): [True: 3.58k, False: 0]
  ------------------
  292|  3.58k|      ERREXIT(cinfo, JERR_NO_IMAGE);
  ------------------
  |  |  240|  3.58k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  3.58k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  293|       |    /* Reset to start state; it would be safer to require the application to
  294|       |     * call jpeg_abort, but we can't change it now for compatibility reasons.
  295|       |     * A side effect is to free any temporary memory (there shouldn't be any).
  296|       |     */
  297|  3.58k|    jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
  298|  3.58k|    retcode = JPEG_HEADER_TABLES_ONLY;
  ------------------
  |  | 1067|  3.58k|#define JPEG_HEADER_TABLES_ONLY  2 /* Found valid table-specs-only datastream */
  ------------------
  299|  3.58k|    break;
  300|      0|  case JPEG_SUSPENDED:
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  |  Branch (300:3): [True: 0, False: 60.6k]
  ------------------
  301|       |    /* no work */
  302|      0|    break;
  303|  60.6k|  }
  304|       |
  305|  22.8k|  return retcode;
  306|  60.6k|}
jpeg_consume_input:
  323|  60.6k|{
  324|  60.6k|  int retcode = JPEG_SUSPENDED;
  ------------------
  |  | 1065|  60.6k|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  325|       |
  326|       |  /* NB: every possible DSTATE value should be listed in this switch */
  327|  60.6k|  switch (cinfo->global_state) {
  328|  60.6k|  case DSTATE_START:
  ------------------
  |  |   48|  60.6k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
  |  Branch (328:3): [True: 60.6k, False: 0]
  ------------------
  329|       |    /* Start-of-datastream actions: reset appropriate modules */
  330|  60.6k|    (*cinfo->inputctl->reset_input_controller) (cinfo);
  331|       |    /* Initialize application's data source module */
  332|  60.6k|    (*cinfo->src->init_source) (cinfo);
  333|  60.6k|    cinfo->global_state = DSTATE_INHEADER;
  ------------------
  |  |   49|  60.6k|#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
  ------------------
  334|  60.6k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  60.6k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  335|  60.6k|  case DSTATE_INHEADER:
  ------------------
  |  |   49|  60.6k|#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
  ------------------
  |  Branch (335:3): [True: 0, False: 60.6k]
  ------------------
  336|  60.6k|    retcode = (*cinfo->inputctl->consume_input) (cinfo);
  337|  60.6k|    if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
  ------------------
  |  | 1111|  60.6k|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (337:9): [True: 22.8k, False: 37.7k]
  ------------------
  338|       |      /* Set up default parameters based on header data */
  339|  22.8k|      default_decompress_parms(cinfo);
  340|       |      /* Set global state: ready for start_decompress */
  341|  22.8k|      cinfo->global_state = DSTATE_READY;
  ------------------
  |  |   50|  22.8k|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  342|  22.8k|    }
  343|  60.6k|    break;
  344|      0|  case DSTATE_READY:
  ------------------
  |  |   50|      0|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (344:3): [True: 0, False: 60.6k]
  ------------------
  345|       |    /* Can't advance past first SOS until start_decompress is called */
  346|      0|    retcode = JPEG_REACHED_SOS;
  ------------------
  |  | 1111|      0|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  347|      0|    break;
  348|      0|  case DSTATE_PRELOAD:
  ------------------
  |  |   51|      0|#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
  ------------------
  |  Branch (348:3): [True: 0, False: 60.6k]
  ------------------
  349|      0|  case DSTATE_PRESCAN:
  ------------------
  |  |   52|      0|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (349:3): [True: 0, False: 60.6k]
  ------------------
  350|      0|  case DSTATE_SCANNING:
  ------------------
  |  |   53|      0|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (350:3): [True: 0, False: 60.6k]
  ------------------
  351|      0|  case DSTATE_RAW_OK:
  ------------------
  |  |   54|      0|#define DSTATE_RAW_OK    206    /* start_decompress done, read_raw_data OK */
  ------------------
  |  Branch (351:3): [True: 0, False: 60.6k]
  ------------------
  352|      0|  case DSTATE_BUFIMAGE:
  ------------------
  |  |   55|      0|#define DSTATE_BUFIMAGE  207    /* expecting jpeg_start_output */
  ------------------
  |  Branch (352:3): [True: 0, False: 60.6k]
  ------------------
  353|      0|  case DSTATE_BUFPOST:
  ------------------
  |  |   56|      0|#define DSTATE_BUFPOST   208    /* looking for SOS/EOI in jpeg_finish_output */
  ------------------
  |  Branch (353:3): [True: 0, False: 60.6k]
  ------------------
  354|      0|  case DSTATE_STOPPING:
  ------------------
  |  |   58|      0|#define DSTATE_STOPPING  210    /* looking for EOI in jpeg_finish_decompress */
  ------------------
  |  Branch (354:3): [True: 0, False: 60.6k]
  ------------------
  355|      0|    retcode = (*cinfo->inputctl->consume_input) (cinfo);
  356|      0|    break;
  357|      0|  default:
  ------------------
  |  Branch (357:3): [True: 0, False: 60.6k]
  ------------------
  358|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  359|  60.6k|  }
  360|  26.4k|  return retcode;
  361|  60.6k|}
jpeg_has_multiple_scans:
  385|      3|{
  386|       |  /* Only valid after jpeg_read_header completes */
  387|      3|  if (cinfo->global_state < DSTATE_READY ||
  ------------------
  |  |   50|      6|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (387:7): [True: 0, False: 3]
  ------------------
  388|      3|      cinfo->global_state > DSTATE_STOPPING)
  ------------------
  |  |   58|      3|#define DSTATE_STOPPING  210    /* looking for EOI in jpeg_finish_decompress */
  ------------------
  |  Branch (388:7): [True: 0, False: 3]
  ------------------
  389|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  390|      3|  return cinfo->inputctl->has_multiple_scans;
  391|      3|}
jdapimin.c:default_decompress_parms:
  140|  22.8k|{
  141|       |  /* Guess the input colorspace, and set output colorspace accordingly. */
  142|       |  /* (Wish JPEG committee had provided a real way to specify this...) */
  143|       |  /* Note application may override our guesses. */
  144|  22.8k|  switch (cinfo->num_components) {
  145|  22.8k|  case 1:
  ------------------
  |  Branch (145:3): [True: 22.8k, False: 77]
  ------------------
  146|  22.8k|    cinfo->jpeg_color_space = JCS_GRAYSCALE;
  147|  22.8k|    cinfo->out_color_space = JCS_GRAYSCALE;
  148|  22.8k|    break;
  149|       |
  150|     77|  case 3:
  ------------------
  |  Branch (150:3): [True: 77, False: 22.8k]
  ------------------
  151|     77|    if (cinfo->saw_JFIF_marker) {
  ------------------
  |  Branch (151:9): [True: 0, False: 77]
  ------------------
  152|      0|      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
  153|     77|    } else if (cinfo->saw_Adobe_marker) {
  ------------------
  |  Branch (153:16): [True: 7, False: 70]
  ------------------
  154|      7|      switch (cinfo->Adobe_transform) {
  155|      1|      case 0:
  ------------------
  |  Branch (155:7): [True: 1, False: 6]
  ------------------
  156|      1|        cinfo->jpeg_color_space = JCS_RGB;
  157|      1|        break;
  158|      3|      case 1:
  ------------------
  |  Branch (158:7): [True: 3, False: 4]
  ------------------
  159|      3|        cinfo->jpeg_color_space = JCS_YCbCr;
  160|      3|        break;
  161|      3|      default:
  ------------------
  |  Branch (161:7): [True: 3, False: 4]
  ------------------
  162|      3|        WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
  ------------------
  |  |  286|      3|  ((cinfo)->err->msg_code = (code), \
  |  |  287|      3|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  288|      3|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  163|      3|        cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
  164|      3|        break;
  165|      7|      }
  166|     70|    } else {
  167|       |      /* Saw no special markers, try to guess from the component IDs */
  168|     70|      int cid0 = cinfo->comp_info[0].component_id;
  169|     70|      int cid1 = cinfo->comp_info[1].component_id;
  170|     70|      int cid2 = cinfo->comp_info[2].component_id;
  171|       |
  172|     70|      if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
  ------------------
  |  Branch (172:11): [True: 0, False: 70]
  |  Branch (172:24): [True: 0, False: 0]
  |  Branch (172:37): [True: 0, False: 0]
  ------------------
  173|      0|#ifdef D_LOSSLESS_SUPPORTED
  174|      0|        if (cinfo->master->lossless)
  ------------------
  |  Branch (174:13): [True: 0, False: 0]
  ------------------
  175|      0|          cinfo->jpeg_color_space = JCS_RGB; /* assume RGB w/out marker */
  176|      0|        else
  177|      0|#endif
  178|      0|          cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
  179|     70|      } else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
  ------------------
  |  Branch (179:18): [True: 0, False: 70]
  |  Branch (179:32): [True: 0, False: 0]
  |  Branch (179:46): [True: 0, False: 0]
  ------------------
  180|      0|        cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
  181|     70|      else {
  182|     70|        TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
  ------------------
  |  |  309|     70|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|     70|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|     70|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|     70|           (cinfo)->err->msg_code = (code); \
  |  |  312|     70|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  183|     70|#ifdef D_LOSSLESS_SUPPORTED
  184|     70|        if (cinfo->master->lossless)
  ------------------
  |  Branch (184:13): [True: 2, False: 68]
  ------------------
  185|      2|          cinfo->jpeg_color_space = JCS_RGB; /* assume it's RGB */
  186|     68|        else
  187|     68|#endif
  188|     68|          cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
  189|     70|      }
  190|     70|    }
  191|       |    /* Always guess RGB is proper output colorspace. */
  192|     77|    cinfo->out_color_space = JCS_RGB;
  193|     77|    break;
  194|       |
  195|      0|  case 4:
  ------------------
  |  Branch (195:3): [True: 0, False: 22.8k]
  ------------------
  196|      0|    if (cinfo->saw_Adobe_marker) {
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|      switch (cinfo->Adobe_transform) {
  198|      0|      case 0:
  ------------------
  |  Branch (198:7): [True: 0, False: 0]
  ------------------
  199|      0|        cinfo->jpeg_color_space = JCS_CMYK;
  200|      0|        break;
  201|      0|      case 2:
  ------------------
  |  Branch (201:7): [True: 0, False: 0]
  ------------------
  202|      0|        cinfo->jpeg_color_space = JCS_YCCK;
  203|      0|        break;
  204|      0|      default:
  ------------------
  |  Branch (204:7): [True: 0, False: 0]
  ------------------
  205|      0|        WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
  ------------------
  |  |  286|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  287|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  288|      0|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  206|      0|        cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
  207|      0|        break;
  208|      0|      }
  209|      0|    } else {
  210|       |      /* No special markers, assume straight CMYK. */
  211|      0|      cinfo->jpeg_color_space = JCS_CMYK;
  212|      0|    }
  213|      0|    cinfo->out_color_space = JCS_CMYK;
  214|      0|    break;
  215|       |
  216|      0|  default:
  ------------------
  |  Branch (216:3): [True: 0, False: 22.8k]
  ------------------
  217|      0|    cinfo->jpeg_color_space = JCS_UNKNOWN;
  218|      0|    cinfo->out_color_space = JCS_UNKNOWN;
  219|      0|    break;
  220|  22.8k|  }
  221|       |
  222|       |  /* Set defaults for other decompression parameters. */
  223|  22.8k|  cinfo->scale_num = 1;         /* 1:1 scaling */
  224|  22.8k|  cinfo->scale_denom = 1;
  225|  22.8k|  cinfo->output_gamma = 1.0;
  226|  22.8k|  cinfo->buffered_image = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  227|  22.8k|  cinfo->raw_data_out = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  228|  22.8k|  cinfo->dct_method = JDCT_DEFAULT;
  ------------------
  |  |  301|  22.8k|#define JDCT_DEFAULT  JDCT_ISLOW
  ------------------
  229|  22.8k|  cinfo->do_fancy_upsampling = TRUE;
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  230|  22.8k|  cinfo->do_block_smoothing = TRUE;
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  231|  22.8k|  cinfo->quantize_colors = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  232|       |  /* We set these in case application only sets quantize_colors. */
  233|  22.8k|  cinfo->dither_mode = JDITHER_FS;
  234|  22.8k|#ifdef QUANT_2PASS_SUPPORTED
  235|  22.8k|  cinfo->two_pass_quantize = TRUE;
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  236|       |#else
  237|       |  cinfo->two_pass_quantize = FALSE;
  238|       |#endif
  239|  22.8k|  cinfo->desired_number_of_colors = 256;
  240|  22.8k|  cinfo->colormap = NULL;
  241|       |  /* Initialize for no mode change in buffered-image mode. */
  242|  22.8k|  cinfo->enable_1pass_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  243|  22.8k|  cinfo->enable_external_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  244|  22.8k|  cinfo->enable_2pass_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  245|  22.8k|}

jpeg_start_decompress:
   56|  22.8k|{
   57|  22.8k|  if (cinfo->global_state == DSTATE_READY) {
  ------------------
  |  |   50|  22.8k|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (57:7): [True: 22.8k, False: 0]
  ------------------
   58|       |    /* First call: initialize master control, select active modules */
   59|  22.8k|    jinit_master_decompress(cinfo);
   60|  22.8k|    if (cinfo->buffered_image) {
  ------------------
  |  Branch (60:9): [True: 0, False: 22.8k]
  ------------------
   61|       |      /* No more work here; expecting jpeg_start_output next */
   62|      0|      cinfo->global_state = DSTATE_BUFIMAGE;
  ------------------
  |  |   55|      0|#define DSTATE_BUFIMAGE  207    /* expecting jpeg_start_output */
  ------------------
   63|      0|      return TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
   64|      0|    }
   65|  22.8k|    cinfo->global_state = DSTATE_PRELOAD;
  ------------------
  |  |   51|  22.8k|#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
  ------------------
   66|  22.8k|  }
   67|  22.8k|  if (cinfo->global_state == DSTATE_PRELOAD) {
  ------------------
  |  |   51|  22.8k|#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
  ------------------
  |  Branch (67:7): [True: 22.8k, False: 43]
  ------------------
   68|       |    /* If file has multiple scans, absorb them all into the coef buffer */
   69|  22.8k|    if (cinfo->inputctl->has_multiple_scans) {
  ------------------
  |  Branch (69:9): [True: 0, False: 22.8k]
  ------------------
   70|      0|#ifdef D_MULTISCAN_FILES_SUPPORTED
   71|      0|      for (;;) {
   72|      0|        int retcode;
   73|       |        /* Call progress monitor hook if present */
   74|      0|        if (cinfo->progress != NULL)
  ------------------
  |  Branch (74:13): [True: 0, False: 0]
  ------------------
   75|      0|          (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
   76|       |        /* Absorb some more input */
   77|      0|        retcode = (*cinfo->inputctl->consume_input) (cinfo);
   78|      0|        if (retcode == JPEG_SUSPENDED)
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  |  Branch (78:13): [True: 0, False: 0]
  ------------------
   79|      0|          return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   80|      0|        if (retcode == JPEG_REACHED_EOI)
  ------------------
  |  | 1112|      0|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  |  Branch (80:13): [True: 0, False: 0]
  ------------------
   81|      0|          break;
   82|       |        /* Advance progress counter if appropriate */
   83|      0|        if (cinfo->progress != NULL &&
  ------------------
  |  Branch (83:13): [True: 0, False: 0]
  ------------------
   84|      0|            (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
  ------------------
  |  | 1113|      0|#define JPEG_ROW_COMPLETED      3 /* Completed one iMCU row */
  ------------------
                          (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
  ------------------
  |  | 1111|      0|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (84:14): [True: 0, False: 0]
  |  Branch (84:47): [True: 0, False: 0]
  ------------------
   85|      0|          if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
  ------------------
  |  Branch (85:15): [True: 0, False: 0]
  ------------------
   86|       |            /* jdmaster underestimated number of scans; ratchet up one scan */
   87|      0|            cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
   88|      0|          }
   89|      0|        }
   90|      0|      }
   91|       |#else
   92|       |      ERREXIT(cinfo, JERR_NOT_COMPILED);
   93|       |#endif /* D_MULTISCAN_FILES_SUPPORTED */
   94|      0|    }
   95|  22.8k|    cinfo->output_scan_number = cinfo->input_scan_number;
   96|  22.8k|  } else if (cinfo->global_state != DSTATE_PRESCAN)
  ------------------
  |  |   52|     43|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (96:14): [True: 0, False: 43]
  ------------------
   97|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   98|       |  /* Perform any dummy output passes, and set up for the final pass */
   99|  22.8k|  return output_pass_setup(cinfo);
  100|  22.8k|}
jpeg_read_scanlines:
  328|   299M|{
  329|   299M|#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
  330|   299M|  JDIMENSION row_ctr;
  331|       |
  332|   299M|#ifdef D_LOSSLESS_SUPPORTED
  333|   299M|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (333:7): [True: 0, False: 299M]
  ------------------
  334|      0|#if BITS_IN_JSAMPLE == 8
  335|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (335:9): [True: 0, False: 0]
  |  Branch (335:52): [True: 0, False: 0]
  ------------------
  336|       |#else
  337|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  338|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  339|       |#endif
  340|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  341|      0|  } else
  342|   299M|#endif
  343|   299M|  {
  344|   299M|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|   299M|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (344:9): [True: 0, False: 299M]
  ------------------
  345|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  346|   299M|  }
  347|       |
  348|   299M|  if (cinfo->global_state != DSTATE_SCANNING)
  ------------------
  |  |   53|   299M|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (348:7): [True: 0, False: 299M]
  ------------------
  349|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  350|   299M|  if (cinfo->output_scanline >= cinfo->output_height) {
  ------------------
  |  Branch (350:7): [True: 290M, False: 9.07M]
  ------------------
  351|   290M|    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
  ------------------
  |  |  283|   290M|  ((cinfo)->err->msg_code = (code), \
  |  |  284|   290M|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  352|   290M|    return 0;
  353|   290M|  }
  354|       |
  355|       |  /* Call progress monitor hook if present */
  356|  9.07M|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (356:7): [True: 0, False: 9.07M]
  ------------------
  357|      0|    cinfo->progress->pass_counter = (long)cinfo->output_scanline;
  358|      0|    cinfo->progress->pass_limit = (long)cinfo->output_height;
  359|      0|    (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  360|      0|  }
  361|       |
  362|       |  /* Process some data */
  363|  9.07M|  row_ctr = 0;
  364|  9.07M|  if (cinfo->main->_process_data == NULL)
  ------------------
  |  |  256|  9.07M|#define _process_data  process_data
  ------------------
  |  Branch (364:7): [True: 0, False: 9.07M]
  ------------------
  365|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  366|  9.07M|  (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, max_lines);
  ------------------
  |  |  256|  9.07M|#define _process_data  process_data
  ------------------
  367|  9.07M|  cinfo->output_scanline += row_ctr;
  368|  9.07M|  return row_ctr;
  369|       |#else
  370|       |  ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  371|       |  return 0;
  372|       |#endif
  373|   299M|}
jpeg_read_raw_data:
  720|  2.42k|{
  721|  2.42k|  JDIMENSION lines_per_iMCU_row;
  722|       |
  723|  2.42k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  2.42k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (723:7): [True: 0, False: 2.42k]
  ------------------
  724|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  725|       |
  726|  2.42k|  if (cinfo->master->lossless)
  ------------------
  |  Branch (726:7): [True: 0, False: 2.42k]
  ------------------
  727|      0|    ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  728|       |
  729|  2.42k|  if (cinfo->global_state != DSTATE_RAW_OK)
  ------------------
  |  |   54|  2.42k|#define DSTATE_RAW_OK    206    /* start_decompress done, read_raw_data OK */
  ------------------
  |  Branch (729:7): [True: 0, False: 2.42k]
  ------------------
  730|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  731|  2.42k|  if (cinfo->output_scanline >= cinfo->output_height) {
  ------------------
  |  Branch (731:7): [True: 336, False: 2.09k]
  ------------------
  732|    336|    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
  ------------------
  |  |  283|    336|  ((cinfo)->err->msg_code = (code), \
  |  |  284|    336|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  733|    336|    return 0;
  734|    336|  }
  735|       |
  736|       |  /* Call progress monitor hook if present */
  737|  2.09k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (737:7): [True: 0, False: 2.09k]
  ------------------
  738|      0|    cinfo->progress->pass_counter = (long)cinfo->output_scanline;
  739|      0|    cinfo->progress->pass_limit = (long)cinfo->output_height;
  740|      0|    (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  741|      0|  }
  742|       |
  743|       |  /* Verify that at least one iMCU row can be returned. */
  744|  2.09k|  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  2.09k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  745|  2.09k|  if (max_lines < lines_per_iMCU_row)
  ------------------
  |  Branch (745:7): [True: 0, False: 2.09k]
  ------------------
  746|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  747|       |
  748|       |  /* Decompress directly into user's buffer. */
  749|  2.09k|  if (cinfo->coef->_decompress_data == NULL)
  ------------------
  |  |  258|  2.09k|#define _decompress_data  decompress_data
  ------------------
  |  Branch (749:7): [True: 0, False: 2.09k]
  ------------------
  750|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  751|  2.09k|  if (!(*cinfo->coef->_decompress_data) (cinfo, data))
  ------------------
  |  |  258|  2.09k|#define _decompress_data  decompress_data
  ------------------
  |  Branch (751:7): [True: 0, False: 2.09k]
  ------------------
  752|      0|    return 0;                   /* suspension forced, can do nothing more */
  753|       |
  754|       |  /* OK, we processed one iMCU row. */
  755|  2.09k|  cinfo->output_scanline += lines_per_iMCU_row;
  756|  2.09k|  return lines_per_iMCU_row;
  757|  2.09k|}
jdapistd-8.c:output_pass_setup:
  113|  22.8k|{
  114|  22.8k|  if (cinfo->global_state != DSTATE_PRESCAN) {
  ------------------
  |  |   52|  22.8k|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (114:7): [True: 22.8k, False: 0]
  ------------------
  115|       |    /* First call: do pass setup */
  116|  22.8k|    (*cinfo->master->prepare_for_output_pass) (cinfo);
  117|  22.8k|    cinfo->output_scanline = 0;
  118|  22.8k|    cinfo->global_state = DSTATE_PRESCAN;
  ------------------
  |  |   52|  22.8k|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  119|  22.8k|  }
  120|       |  /* Loop over any required dummy passes */
  121|  22.8k|  while (cinfo->master->is_dummy_pass) {
  ------------------
  |  Branch (121:10): [True: 0, False: 22.8k]
  ------------------
  122|      0|#ifdef QUANT_2PASS_SUPPORTED
  123|       |    /* Crank through the dummy pass */
  124|      0|    while (cinfo->output_scanline < cinfo->output_height) {
  ------------------
  |  Branch (124:12): [True: 0, False: 0]
  ------------------
  125|      0|      JDIMENSION last_scanline;
  126|       |      /* Call progress monitor hook if present */
  127|      0|      if (cinfo->progress != NULL) {
  ------------------
  |  Branch (127:11): [True: 0, False: 0]
  ------------------
  128|      0|        cinfo->progress->pass_counter = (long)cinfo->output_scanline;
  129|      0|        cinfo->progress->pass_limit = (long)cinfo->output_height;
  130|      0|        (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  131|      0|      }
  132|       |      /* Process some data */
  133|      0|      last_scanline = cinfo->output_scanline;
  134|      0|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (134:11): [True: 0, False: 0]
  ------------------
  135|      0|        if (cinfo->main->process_data == NULL)
  ------------------
  |  Branch (135:13): [True: 0, False: 0]
  ------------------
  136|      0|          ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  137|      0|        (*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
  138|      0|                                      &cinfo->output_scanline, (JDIMENSION)0);
  139|      0|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (139:18): [True: 0, False: 0]
  ------------------
  140|      0|        if (cinfo->main->process_data_12 == NULL)
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  ------------------
  141|      0|          ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  142|      0|        (*cinfo->main->process_data_12) (cinfo, (J12SAMPARRAY)NULL,
  143|      0|                                         &cinfo->output_scanline,
  144|      0|                                         (JDIMENSION)0);
  145|      0|      } else {
  146|      0|#ifdef D_LOSSLESS_SUPPORTED
  147|      0|        if (cinfo->main->process_data_16 == NULL)
  ------------------
  |  Branch (147:13): [True: 0, False: 0]
  ------------------
  148|      0|          ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  149|      0|        (*cinfo->main->process_data_16) (cinfo, (J16SAMPARRAY)NULL,
  150|      0|                                         &cinfo->output_scanline,
  151|      0|                                         (JDIMENSION)0);
  152|       |#else
  153|       |        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  154|       |#endif
  155|      0|      }
  156|      0|      if (cinfo->output_scanline == last_scanline)
  ------------------
  |  Branch (156:11): [True: 0, False: 0]
  ------------------
  157|      0|        return FALSE;           /* No progress made, must suspend */
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  158|      0|    }
  159|       |    /* Finish up dummy pass, and set up for another one */
  160|      0|    (*cinfo->master->finish_output_pass) (cinfo);
  161|      0|    (*cinfo->master->prepare_for_output_pass) (cinfo);
  162|      0|    cinfo->output_scanline = 0;
  163|       |#else
  164|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  165|       |#endif /* QUANT_2PASS_SUPPORTED */
  166|      0|  }
  167|       |  /* Ready for application to drive output pass through
  168|       |   * _jpeg_read_scanlines or _jpeg_read_raw_data.
  169|       |   */
  170|  22.8k|  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
  ------------------
  |  |   54|     28|#define DSTATE_RAW_OK    206    /* start_decompress done, read_raw_data OK */
  ------------------
                cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
  ------------------
  |  |   53|  45.5k|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (170:25): [True: 28, False: 22.7k]
  ------------------
  171|  22.8k|  return TRUE;
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  172|  22.8k|}

jinit_d_coef_controller:
  869|  22.8k|{
  870|  22.8k|  my_coef_ptr coef;
  871|       |
  872|  22.8k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (872:7): [True: 0, False: 22.8k]
  ------------------
  873|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  874|       |
  875|  22.8k|  coef = (my_coef_ptr)
  876|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  877|  22.8k|                                sizeof(my_coef_controller));
  878|  22.8k|  memset(coef, 0, sizeof(my_coef_controller));
  879|  22.8k|  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
  880|  22.8k|  coef->pub.start_input_pass = start_input_pass;
  881|  22.8k|  coef->pub.start_output_pass = start_output_pass;
  882|  22.8k|#ifdef BLOCK_SMOOTHING_SUPPORTED
  883|  22.8k|  coef->coef_bits_latch = NULL;
  884|  22.8k|#endif
  885|       |
  886|       |  /* Create the coefficient buffer. */
  887|  22.8k|  if (need_full_buffer) {
  ------------------
  |  Branch (887:7): [True: 1, False: 22.8k]
  ------------------
  888|      1|#ifdef D_MULTISCAN_FILES_SUPPORTED
  889|       |    /* Allocate a full-image virtual array for each component, */
  890|       |    /* padded to a multiple of samp_factor DCT blocks in each direction. */
  891|       |    /* Note we ask for a pre-zeroed array. */
  892|      1|    int ci, access_rows;
  893|      1|    jpeg_component_info *compptr;
  894|       |
  895|      4|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (895:46): [True: 3, False: 1]
  ------------------
  896|      3|         ci++, compptr++) {
  897|      3|      access_rows = compptr->v_samp_factor;
  898|      3|#ifdef BLOCK_SMOOTHING_SUPPORTED
  899|       |      /* If block smoothing could be used, need a bigger window */
  900|      3|      if (cinfo->progressive_mode)
  ------------------
  |  Branch (900:11): [True: 0, False: 3]
  ------------------
  901|      0|        access_rows *= 5;
  902|      3|#endif
  903|      3|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  904|      3|        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  889|      3|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  210|      3|#define TRUE    1
  ------------------
  905|      3|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  906|      3|                               (long)compptr->h_samp_factor),
  907|      3|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  908|      3|                               (long)compptr->v_samp_factor),
  909|      3|         (JDIMENSION)access_rows);
  910|      3|    }
  911|      1|    coef->pub.consume_data = consume_data;
  912|      1|    coef->pub._decompress_data = decompress_data;
  ------------------
  |  |  258|      1|#define _decompress_data  decompress_data
  ------------------
  913|      1|    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
  914|       |#else
  915|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  916|       |#endif
  917|  22.8k|  } else {
  918|       |    /* We only need a single-MCU buffer. */
  919|  22.8k|    JBLOCKROW buffer;
  920|  22.8k|    int i;
  921|       |
  922|  22.8k|    buffer = (JBLOCKROW)
  923|  22.8k|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  924|  22.8k|                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   82|  22.8k|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  925|   251k|    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   82|   251k|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  |  Branch (925:17): [True: 228k, False: 22.8k]
  ------------------
  926|   228k|      coef->MCU_buffer[i] = buffer + i;
  927|   228k|    }
  928|  22.8k|    coef->pub.consume_data = dummy_consume_data;
  929|  22.8k|    coef->pub._decompress_data = decompress_onepass;
  ------------------
  |  |  258|  22.8k|#define _decompress_data  decompress_data
  ------------------
  930|  22.8k|    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
  931|  22.8k|  }
  932|       |
  933|       |  /* Allocate the workspace buffer */
  934|  22.8k|  coef->workspace = (JCOEF *)
  935|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  936|  22.8k|                                sizeof(JCOEF) * DCTSIZE2);
  ------------------
  |  |   67|  22.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  937|  22.8k|}
jdcoefct-8.c:start_input_pass:
   50|  22.8k|{
   51|  22.8k|  cinfo->input_iMCU_row = 0;
   52|  22.8k|  start_iMCU_row(cinfo);
   53|  22.8k|}
jdcoefct-8.c:start_output_pass:
   62|  22.8k|{
   63|  22.8k|#ifdef BLOCK_SMOOTHING_SUPPORTED
   64|  22.8k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
   65|       |
   66|       |  /* If multipass, check to see whether to use block smoothing on this pass */
   67|  22.8k|  if (coef->pub.coef_arrays != NULL) {
  ------------------
  |  Branch (67:7): [True: 0, False: 22.8k]
  ------------------
   68|      0|    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
  ------------------
  |  Branch (68:9): [True: 0, False: 0]
  |  Branch (68:38): [True: 0, False: 0]
  ------------------
   69|      0|      coef->pub._decompress_data = decompress_smooth_data;
  ------------------
  |  |  258|      0|#define _decompress_data  decompress_data
  ------------------
   70|      0|    else
   71|      0|      coef->pub._decompress_data = decompress_data;
  ------------------
  |  |  258|      0|#define _decompress_data  decompress_data
  ------------------
   72|      0|  }
   73|  22.8k|#endif
   74|  22.8k|  cinfo->output_iMCU_row = 0;
   75|  22.8k|}
jdcoefct-8.c:decompress_onepass:
   90|  1.16M|{
   91|  1.16M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
   92|  1.16M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
   93|  1.16M|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
   94|  1.16M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
   95|  1.16M|  int blkn, ci, xindex, yindex, yoffset, useful_width;
   96|  1.16M|  _JSAMPARRAY output_ptr;
  ------------------
  |  |  230|  1.16M|#define _JSAMPARRAY  JSAMPARRAY
  ------------------
   97|  1.16M|  JDIMENSION start_col, output_col;
   98|  1.16M|  jpeg_component_info *compptr;
   99|  1.16M|  _inverse_DCT_method_ptr inverse_DCT;
  ------------------
  |  |  262|  1.16M|#define _inverse_DCT_method_ptr  inverse_DCT_method_ptr
  ------------------
  100|       |
  101|       |  /* Loop to process as much as one whole iMCU row */
  102|  2.33M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (102:41): [True: 1.16M, False: 1.16M]
  ------------------
  103|  1.16M|       yoffset++) {
  104|  2.44M|    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (104:39): [True: 1.28M, False: 1.16M]
  ------------------
  105|  1.28M|         MCU_col_num++) {
  106|       |      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
  107|  1.28M|      jzero_far((void *)coef->MCU_buffer[0],
  108|  1.28M|                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
  109|  1.28M|      if (!cinfo->entropy->insufficient_data)
  ------------------
  |  Branch (109:11): [True: 255k, False: 1.02M]
  ------------------
  110|   255k|        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
  111|       |#ifdef WITH_PROFILE
  112|       |      cinfo->master->start = getTime();
  113|       |#endif
  114|  1.28M|      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (114:11): [True: 0, False: 1.28M]
  ------------------
  115|       |        /* Suspension forced; update state counters and exit */
  116|      0|        coef->MCU_vert_offset = yoffset;
  117|      0|        coef->MCU_ctr = MCU_col_num;
  118|       |#ifdef WITH_PROFILE
  119|       |        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  120|       |        cinfo->master->entropy_mcoeffs +=
  121|       |          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  122|       |#endif
  123|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  124|      0|      }
  125|       |#ifdef WITH_PROFILE
  126|       |      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  127|       |      cinfo->master->entropy_mcoeffs +=
  128|       |        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  129|       |#endif
  130|       |
  131|       |      /* Only perform the IDCT on blocks that are contained within the desired
  132|       |       * cropping region.
  133|       |       */
  134|  1.28M|      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
  ------------------
  |  Branch (134:11): [True: 1.24M, False: 35.0k]
  ------------------
  135|  1.24M|          MCU_col_num <= cinfo->master->last_iMCU_col) {
  ------------------
  |  Branch (135:11): [True: 1.24M, False: 0]
  ------------------
  136|       |        /* Determine where data should go in output_buf and do the IDCT thing.
  137|       |         * We skip dummy blocks at the right and bottom edges (but blkn gets
  138|       |         * incremented past them!).  Note the inner loop relies on having
  139|       |         * allocated the MCU_buffer[] blocks sequentially.
  140|       |         */
  141|  1.24M|        blkn = 0;               /* index of current DCT block within MCU */
  142|  2.49M|        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (142:22): [True: 1.25M, False: 1.24M]
  ------------------
  143|  1.25M|          compptr = cinfo->cur_comp_info[ci];
  144|       |          /* Don't bother to IDCT an uninteresting component. */
  145|  1.25M|          if (!compptr->component_needed) {
  ------------------
  |  Branch (145:15): [True: 0, False: 1.25M]
  ------------------
  146|      0|            blkn += compptr->MCU_blocks;
  147|      0|            continue;
  148|      0|          }
  149|  1.25M|          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
  ------------------
  |  |  263|  1.25M|#define _inverse_DCT  inverse_DCT
  ------------------
  150|  1.25M|          useful_width = (MCU_col_num < last_MCU_col) ?
  ------------------
  |  Branch (150:26): [True: 117k, False: 1.13M]
  ------------------
  151|  1.13M|                         compptr->MCU_width : compptr->last_col_width;
  152|  1.25M|          output_ptr = output_buf[compptr->component_index] +
  153|  1.25M|                       yoffset * compptr->_DCT_scaled_size;
  ------------------
  |  |   24|  1.25M|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  154|  1.25M|          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
  155|  1.25M|                      compptr->MCU_sample_width;
  156|  2.51M|          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (156:28): [True: 1.25M, False: 1.25M]
  ------------------
  157|  1.25M|            if (cinfo->input_iMCU_row < last_iMCU_row ||
  ------------------
  |  Branch (157:17): [True: 1.23M, False: 19.5k]
  ------------------
  158|  1.25M|                yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (158:17): [True: 19.5k, False: 12]
  ------------------
  159|  1.25M|              output_col = start_col;
  160|  2.52M|              for (xindex = 0; xindex < useful_width; xindex++) {
  ------------------
  |  Branch (160:32): [True: 1.26M, False: 1.25M]
  ------------------
  161|       |#ifdef WITH_PROFILE
  162|       |                cinfo->master->start = getTime();
  163|       |#endif
  164|  1.26M|                (*inverse_DCT) (cinfo, compptr,
  165|  1.26M|                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
  166|  1.26M|                                output_ptr, output_col);
  167|       |#ifdef WITH_PROFILE
  168|       |                cinfo->master->idct_elapsed +=
  169|       |                  getTime() - cinfo->master->start;
  170|       |                cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
  171|       |#endif
  172|  1.26M|                output_col += compptr->_DCT_scaled_size;
  ------------------
  |  |   24|  1.26M|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  173|  1.26M|              }
  174|  1.25M|            }
  175|  1.25M|            blkn += compptr->MCU_width;
  176|  1.25M|            output_ptr += compptr->_DCT_scaled_size;
  ------------------
  |  |   24|  1.25M|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  177|  1.25M|          }
  178|  1.25M|        }
  179|  1.24M|      }
  180|  1.28M|    }
  181|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  182|  1.16M|    coef->MCU_ctr = 0;
  183|  1.16M|  }
  184|       |  /* Completed the iMCU row, advance counters for next one */
  185|  1.16M|  cinfo->output_iMCU_row++;
  186|  1.16M|  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
  ------------------
  |  Branch (186:7): [True: 1.12M, False: 43.2k]
  ------------------
  187|  1.12M|    start_iMCU_row(cinfo);
  188|  1.12M|    return JPEG_ROW_COMPLETED;
  ------------------
  |  | 1113|  1.12M|#define JPEG_ROW_COMPLETED      3 /* Completed one iMCU row */
  ------------------
  189|  1.12M|  }
  190|       |  /* Completed the scan */
  191|  43.2k|  (*cinfo->inputctl->finish_input_pass) (cinfo);
  192|  43.2k|  return JPEG_SCAN_COMPLETED;
  ------------------
  |  | 1114|  43.2k|#define JPEG_SCAN_COMPLETED     4 /* Completed last iMCU row of a scan */
  ------------------
  193|  1.16M|}

jdcoefct-8.c:start_iMCU_row:
   68|  1.14M|{
   69|  1.14M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
   70|       |
   71|       |  /* In an interleaved scan, an MCU row is the same as an iMCU row.
   72|       |   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
   73|       |   * But at the bottom of the image, process only what's left.
   74|       |   */
   75|  1.14M|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (75:7): [True: 2.09k, False: 1.14M]
  ------------------
   76|  2.09k|    coef->MCU_rows_per_iMCU_row = 1;
   77|  1.14M|  } else {
   78|  1.14M|    if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (78:9): [True: 1.13M, False: 8.23k]
  ------------------
   79|  1.13M|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   80|  8.23k|    else
   81|  8.23k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   82|  1.14M|  }
   83|       |
   84|  1.14M|  coef->MCU_ctr = 0;
   85|  1.14M|  coef->MCU_vert_offset = 0;
   86|  1.14M|}

jinit_color_deconverter:
  625|  22.8k|{
  626|  22.8k|  my_cconvert_ptr cconvert;
  627|  22.8k|  int ci;
  628|       |
  629|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  630|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (630:7): [True: 9, False: 22.8k]
  ------------------
  631|      9|#if BITS_IN_JSAMPLE == 8
  632|      9|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (632:9): [True: 0, False: 9]
  |  Branch (632:52): [True: 0, False: 9]
  ------------------
  633|       |#else
  634|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  635|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  636|       |#endif
  637|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  638|      9|  } else
  639|  22.8k|#endif
  640|  22.8k|  {
  641|  22.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (641:9): [True: 0, False: 22.8k]
  ------------------
  642|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  643|  22.8k|  }
  644|       |
  645|  22.8k|  cconvert = (my_cconvert_ptr)
  646|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  647|  22.8k|                                sizeof(my_color_deconverter));
  648|  22.8k|  cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
  649|  22.8k|  cconvert->pub.start_pass = start_pass_dcolor;
  650|       |
  651|       |  /* Make sure num_components agrees with jpeg_color_space */
  652|  22.8k|  switch (cinfo->jpeg_color_space) {
  653|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (653:3): [True: 0, False: 22.8k]
  ------------------
  654|      0|    if (cinfo->num_components != 1)
  ------------------
  |  Branch (654:9): [True: 0, False: 0]
  ------------------
  655|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  656|      0|    break;
  657|       |
  658|      0|  case JCS_RGB:
  ------------------
  |  Branch (658:3): [True: 0, False: 22.8k]
  ------------------
  659|      1|  case JCS_YCbCr:
  ------------------
  |  Branch (659:3): [True: 1, False: 22.8k]
  ------------------
  660|      1|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (660:9): [True: 0, False: 1]
  ------------------
  661|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  662|      1|    break;
  663|       |
  664|      0|  case JCS_CMYK:
  ------------------
  |  Branch (664:3): [True: 0, False: 22.8k]
  ------------------
  665|      0|  case JCS_YCCK:
  ------------------
  |  Branch (665:3): [True: 0, False: 22.8k]
  ------------------
  666|      0|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (666:9): [True: 0, False: 0]
  ------------------
  667|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  668|      0|    break;
  669|       |
  670|  22.8k|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (670:3): [True: 22.8k, False: 1]
  ------------------
  671|  22.8k|    if (cinfo->num_components < 1)
  ------------------
  |  Branch (671:9): [True: 0, False: 22.8k]
  ------------------
  672|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  673|  22.8k|    break;
  674|  22.8k|  }
  675|       |
  676|       |  /* Set out_color_components and conversion method based on requested space.
  677|       |   * Also clear the component_needed flags for any unused components,
  678|       |   * so that earlier pipeline stages can avoid useless computation.
  679|       |   * NOTE: We do not allow any lossy color conversion algorithms in lossless
  680|       |   * mode.
  681|       |   */
  682|       |
  683|  22.8k|  switch (cinfo->out_color_space) {
  684|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (684:3): [True: 0, False: 22.8k]
  ------------------
  685|      0|#ifdef D_LOSSLESS_SUPPORTED
  686|      0|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (686:9): [True: 0, False: 0]
  ------------------
  687|      0|        cinfo->jpeg_color_space != cinfo->out_color_space)
  ------------------
  |  Branch (687:9): [True: 0, False: 0]
  ------------------
  688|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  689|      0|#endif
  690|      0|    cinfo->out_color_components = 1;
  691|      0|    if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
  ------------------
  |  Branch (691:9): [True: 0, False: 0]
  ------------------
  692|      0|        cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (692:9): [True: 0, False: 0]
  ------------------
  693|      0|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  694|       |      /* For color->grayscale conversion, only the Y (0) component is needed */
  695|      0|      for (ci = 1; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (695:20): [True: 0, False: 0]
  ------------------
  696|      0|        cinfo->comp_info[ci].component_needed = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  697|      0|    } else if (cinfo->jpeg_color_space == JCS_RGB) {
  ------------------
  |  Branch (697:16): [True: 0, False: 0]
  ------------------
  698|      0|      cconvert->pub._color_convert = rgb_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  699|      0|      build_rgb_y_table(cinfo);
  700|      0|    } else
  701|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  702|      0|    break;
  703|       |
  704|      1|  case JCS_RGB:
  ------------------
  |  Branch (704:3): [True: 1, False: 22.8k]
  ------------------
  705|      1|  case JCS_EXT_RGB:
  ------------------
  |  Branch (705:3): [True: 0, False: 22.8k]
  ------------------
  706|      1|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (706:3): [True: 0, False: 22.8k]
  ------------------
  707|      1|  case JCS_EXT_BGR:
  ------------------
  |  Branch (707:3): [True: 0, False: 22.8k]
  ------------------
  708|      1|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (708:3): [True: 0, False: 22.8k]
  ------------------
  709|      1|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (709:3): [True: 0, False: 22.8k]
  ------------------
  710|      1|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (710:3): [True: 0, False: 22.8k]
  ------------------
  711|      1|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (711:3): [True: 0, False: 22.8k]
  ------------------
  712|      1|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (712:3): [True: 0, False: 22.8k]
  ------------------
  713|      1|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (713:3): [True: 0, False: 22.8k]
  ------------------
  714|      1|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (714:3): [True: 0, False: 22.8k]
  ------------------
  715|      1|#ifdef D_LOSSLESS_SUPPORTED
  716|      1|    if (cinfo->master->lossless && cinfo->jpeg_color_space != JCS_RGB)
  ------------------
  |  Branch (716:9): [True: 0, False: 1]
  |  Branch (716:36): [True: 0, False: 0]
  ------------------
  717|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  718|      1|#endif
  719|      1|    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
  720|      1|    if (cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (720:9): [True: 1, False: 0]
  ------------------
  721|      1|#ifdef WITH_SIMD
  722|      1|      if (jsimd_set_ycc_rgb(cinfo))
  ------------------
  |  Branch (722:11): [True: 1, False: 0]
  ------------------
  723|      1|        cconvert->pub._color_convert = jsimd_color_deconvert;
  ------------------
  |  |  267|      1|#define _color_convert  color_convert
  ------------------
  724|      0|      else
  725|      0|#endif
  726|      0|      {
  727|      0|        switch (cinfo->out_color_space) {
  728|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (728:9): [True: 0, False: 0]
  ------------------
  729|      0|          cconvert->pub._color_convert = ycc_extrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  730|      0|          break;
  731|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (731:9): [True: 0, False: 0]
  ------------------
  732|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (732:9): [True: 0, False: 0]
  ------------------
  733|      0|          cconvert->pub._color_convert = ycc_extrgbx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  734|      0|          break;
  735|      0|        case JCS_EXT_BGR:
  ------------------
  |  Branch (735:9): [True: 0, False: 0]
  ------------------
  736|      0|          cconvert->pub._color_convert = ycc_extbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  737|      0|          break;
  738|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (738:9): [True: 0, False: 0]
  ------------------
  739|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (739:9): [True: 0, False: 0]
  ------------------
  740|      0|          cconvert->pub._color_convert = ycc_extbgrx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  741|      0|          break;
  742|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (742:9): [True: 0, False: 0]
  ------------------
  743|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (743:9): [True: 0, False: 0]
  ------------------
  744|      0|          cconvert->pub._color_convert = ycc_extxbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  745|      0|          break;
  746|      0|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (746:9): [True: 0, False: 0]
  ------------------
  747|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (747:9): [True: 0, False: 0]
  ------------------
  748|      0|          cconvert->pub._color_convert = ycc_extxrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  749|      0|          break;
  750|      0|        default:
  ------------------
  |  Branch (750:9): [True: 0, False: 0]
  ------------------
  751|      0|          cconvert->pub._color_convert = ycc_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  752|      0|        }
  753|      0|        build_ycc_rgb_table(cinfo);
  754|      0|      }
  755|      1|    } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (755:16): [True: 0, False: 0]
  ------------------
  756|      0|      switch (cinfo->out_color_space) {
  757|      0|      case JCS_EXT_RGB:
  ------------------
  |  Branch (757:7): [True: 0, False: 0]
  ------------------
  758|      0|        cconvert->pub._color_convert = gray_extrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  759|      0|        break;
  760|      0|      case JCS_EXT_RGBX:
  ------------------
  |  Branch (760:7): [True: 0, False: 0]
  ------------------
  761|      0|      case JCS_EXT_RGBA:
  ------------------
  |  Branch (761:7): [True: 0, False: 0]
  ------------------
  762|      0|        cconvert->pub._color_convert = gray_extrgbx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  763|      0|        break;
  764|      0|      case JCS_EXT_BGR:
  ------------------
  |  Branch (764:7): [True: 0, False: 0]
  ------------------
  765|      0|        cconvert->pub._color_convert = gray_extbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  766|      0|        break;
  767|      0|      case JCS_EXT_BGRX:
  ------------------
  |  Branch (767:7): [True: 0, False: 0]
  ------------------
  768|      0|      case JCS_EXT_BGRA:
  ------------------
  |  Branch (768:7): [True: 0, False: 0]
  ------------------
  769|      0|        cconvert->pub._color_convert = gray_extbgrx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  770|      0|        break;
  771|      0|      case JCS_EXT_XBGR:
  ------------------
  |  Branch (771:7): [True: 0, False: 0]
  ------------------
  772|      0|      case JCS_EXT_ABGR:
  ------------------
  |  Branch (772:7): [True: 0, False: 0]
  ------------------
  773|      0|        cconvert->pub._color_convert = gray_extxbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  774|      0|        break;
  775|      0|      case JCS_EXT_XRGB:
  ------------------
  |  Branch (775:7): [True: 0, False: 0]
  ------------------
  776|      0|      case JCS_EXT_ARGB:
  ------------------
  |  Branch (776:7): [True: 0, False: 0]
  ------------------
  777|      0|        cconvert->pub._color_convert = gray_extxrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  778|      0|        break;
  779|      0|      default:
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  ------------------
  780|      0|        cconvert->pub._color_convert = gray_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  781|      0|      }
  782|      0|    } else if (cinfo->jpeg_color_space == JCS_RGB) {
  ------------------
  |  Branch (782:16): [True: 0, False: 0]
  ------------------
  783|      0|      if (rgb_red[cinfo->out_color_space] == 0 &&
  ------------------
  |  Branch (783:11): [True: 0, False: 0]
  ------------------
  784|      0|          rgb_green[cinfo->out_color_space] == 1 &&
  ------------------
  |  Branch (784:11): [True: 0, False: 0]
  ------------------
  785|      0|          rgb_blue[cinfo->out_color_space] == 2 &&
  ------------------
  |  Branch (785:11): [True: 0, False: 0]
  ------------------
  786|      0|          rgb_pixelsize[cinfo->out_color_space] == 3)
  ------------------
  |  Branch (786:11): [True: 0, False: 0]
  ------------------
  787|      0|        cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  788|      0|      else {
  789|      0|        switch (cinfo->out_color_space) {
  790|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (790:9): [True: 0, False: 0]
  ------------------
  791|      0|          cconvert->pub._color_convert = rgb_extrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  792|      0|          break;
  793|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (793:9): [True: 0, False: 0]
  ------------------
  794|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (794:9): [True: 0, False: 0]
  ------------------
  795|      0|          cconvert->pub._color_convert = rgb_extrgbx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  796|      0|          break;
  797|      0|        case JCS_EXT_BGR:
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      0|          cconvert->pub._color_convert = rgb_extbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  799|      0|          break;
  800|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (800:9): [True: 0, False: 0]
  ------------------
  801|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (801:9): [True: 0, False: 0]
  ------------------
  802|      0|          cconvert->pub._color_convert = rgb_extbgrx_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  803|      0|          break;
  804|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (804:9): [True: 0, False: 0]
  ------------------
  805|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (805:9): [True: 0, False: 0]
  ------------------
  806|      0|          cconvert->pub._color_convert = rgb_extxbgr_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  807|      0|          break;
  808|      0|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (808:9): [True: 0, False: 0]
  ------------------
  809|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (809:9): [True: 0, False: 0]
  ------------------
  810|      0|          cconvert->pub._color_convert = rgb_extxrgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  811|      0|          break;
  812|      0|        default:
  ------------------
  |  Branch (812:9): [True: 0, False: 0]
  ------------------
  813|      0|          cconvert->pub._color_convert = rgb_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  814|      0|        }
  815|      0|      }
  816|      0|    } else
  817|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  818|      1|    break;
  819|       |
  820|      1|  case JCS_RGB565:
  ------------------
  |  Branch (820:3): [True: 0, False: 22.8k]
  ------------------
  821|      0|#ifdef D_LOSSLESS_SUPPORTED
  822|      0|    if (cinfo->master->lossless)
  ------------------
  |  Branch (822:9): [True: 0, False: 0]
  ------------------
  823|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  824|      0|#endif
  825|      0|    cinfo->out_color_components = 3;
  826|      0|    if (cinfo->dither_mode == JDITHER_NONE) {
  ------------------
  |  Branch (826:9): [True: 0, False: 0]
  ------------------
  827|      0|      if (cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (827:11): [True: 0, False: 0]
  ------------------
  828|      0|#ifdef WITH_SIMD
  829|      0|        if (jsimd_set_ycc_rgb565(cinfo))
  ------------------
  |  Branch (829:13): [True: 0, False: 0]
  ------------------
  830|      0|          cconvert->pub._color_convert = jsimd_color_deconvert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  831|      0|        else
  832|      0|#endif
  833|      0|        {
  834|      0|          cconvert->pub._color_convert = ycc_rgb565_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  835|      0|          build_ycc_rgb_table(cinfo);
  836|      0|        }
  837|      0|      } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (837:18): [True: 0, False: 0]
  ------------------
  838|      0|        cconvert->pub._color_convert = gray_rgb565_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  839|      0|      } else if (cinfo->jpeg_color_space == JCS_RGB) {
  ------------------
  |  Branch (839:18): [True: 0, False: 0]
  ------------------
  840|      0|        cconvert->pub._color_convert = rgb_rgb565_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  841|      0|      } else
  842|      0|        ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  843|      0|    } else {
  844|       |      /* only ordered dithering is supported */
  845|      0|      if (cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (845:11): [True: 0, False: 0]
  ------------------
  846|      0|        cconvert->pub._color_convert = ycc_rgb565D_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  847|      0|        build_ycc_rgb_table(cinfo);
  848|      0|      } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (848:18): [True: 0, False: 0]
  ------------------
  849|      0|        cconvert->pub._color_convert = gray_rgb565D_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  850|      0|      } else if (cinfo->jpeg_color_space == JCS_RGB) {
  ------------------
  |  Branch (850:18): [True: 0, False: 0]
  ------------------
  851|      0|        cconvert->pub._color_convert = rgb_rgb565D_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  852|      0|      } else
  853|      0|        ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  854|      0|    }
  855|      0|    break;
  856|       |
  857|      0|  case JCS_CMYK:
  ------------------
  |  Branch (857:3): [True: 0, False: 22.8k]
  ------------------
  858|      0|#ifdef D_LOSSLESS_SUPPORTED
  859|      0|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (859:9): [True: 0, False: 0]
  ------------------
  860|      0|        cinfo->jpeg_color_space != cinfo->out_color_space)
  ------------------
  |  Branch (860:9): [True: 0, False: 0]
  ------------------
  861|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  862|      0|#endif
  863|      0|    cinfo->out_color_components = 4;
  864|      0|    if (cinfo->jpeg_color_space == JCS_YCCK) {
  ------------------
  |  Branch (864:9): [True: 0, False: 0]
  ------------------
  865|      0|      cconvert->pub._color_convert = ycck_cmyk_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  866|      0|      build_ycc_rgb_table(cinfo);
  867|      0|    } else if (cinfo->jpeg_color_space == JCS_CMYK) {
  ------------------
  |  Branch (867:16): [True: 0, False: 0]
  ------------------
  868|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  869|      0|    } else
  870|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  871|      0|    break;
  872|       |
  873|  22.8k|  default:
  ------------------
  |  Branch (873:3): [True: 22.8k, False: 1]
  ------------------
  874|       |    /* Permit null conversion to same output space */
  875|  22.8k|    if (cinfo->out_color_space == cinfo->jpeg_color_space) {
  ------------------
  |  Branch (875:9): [True: 22.8k, False: 0]
  ------------------
  876|  22.8k|      cinfo->out_color_components = cinfo->num_components;
  877|  22.8k|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|  22.8k|#define _color_convert  color_convert
  ------------------
  878|  22.8k|    } else                      /* unsupported non-null conversion */
  879|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  880|  22.8k|    break;
  881|  22.8k|  }
  882|       |
  883|  22.8k|  if (cinfo->quantize_colors)
  ------------------
  |  Branch (883:7): [True: 0, False: 22.8k]
  ------------------
  884|      0|    cinfo->output_components = 1; /* single colormapped output component */
  885|  22.8k|  else
  886|  22.8k|    cinfo->output_components = cinfo->out_color_components;
  887|  22.8k|}
jdcolor-8.c:start_pass_dcolor:
  614|  22.7k|{
  615|       |  /* no work needed */
  616|  22.7k|}
jdcolor-8.c:null_convert:
  336|  9.03M|{
  337|  9.03M|  register _JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
  338|  9.03M|  register JDIMENSION col;
  339|  9.03M|  register int num_components = cinfo->num_components;
  340|  9.03M|  JDIMENSION num_cols = cinfo->output_width;
  341|  9.03M|  int ci;
  342|       |
  343|  9.03M|  if (num_components == 3) {
  ------------------
  |  Branch (343:7): [True: 0, False: 9.03M]
  ------------------
  344|      0|    while (--num_rows >= 0) {
  ------------------
  |  Branch (344:12): [True: 0, False: 0]
  ------------------
  345|      0|      inptr0 = input_buf[0][input_row];
  346|      0|      inptr1 = input_buf[1][input_row];
  347|      0|      inptr2 = input_buf[2][input_row];
  348|      0|      input_row++;
  349|      0|      outptr = *output_buf++;
  350|      0|      for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (350:21): [True: 0, False: 0]
  ------------------
  351|      0|        *outptr++ = inptr0[col];
  352|      0|        *outptr++ = inptr1[col];
  353|      0|        *outptr++ = inptr2[col];
  354|      0|      }
  355|      0|    }
  356|  9.03M|  } else if (num_components == 4) {
  ------------------
  |  Branch (356:14): [True: 0, False: 9.03M]
  ------------------
  357|      0|    while (--num_rows >= 0) {
  ------------------
  |  Branch (357:12): [True: 0, False: 0]
  ------------------
  358|      0|      inptr0 = input_buf[0][input_row];
  359|      0|      inptr1 = input_buf[1][input_row];
  360|      0|      inptr2 = input_buf[2][input_row];
  361|      0|      inptr3 = input_buf[3][input_row];
  362|      0|      input_row++;
  363|      0|      outptr = *output_buf++;
  364|      0|      for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (364:21): [True: 0, False: 0]
  ------------------
  365|      0|        *outptr++ = inptr0[col];
  366|      0|        *outptr++ = inptr1[col];
  367|      0|        *outptr++ = inptr2[col];
  368|      0|        *outptr++ = inptr3[col];
  369|      0|      }
  370|      0|    }
  371|  9.03M|  } else {
  372|  18.0M|    while (--num_rows >= 0) {
  ------------------
  |  Branch (372:12): [True: 9.03M, False: 9.03M]
  ------------------
  373|  18.0M|      for (ci = 0; ci < num_components; ci++) {
  ------------------
  |  Branch (373:20): [True: 9.03M, False: 9.03M]
  ------------------
  374|  9.03M|        inptr = input_buf[ci][input_row];
  375|  9.03M|        outptr = *output_buf;
  376|  42.5M|        for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (376:23): [True: 33.5M, False: 9.03M]
  ------------------
  377|  33.5M|          outptr[ci] = inptr[col];
  378|  33.5M|          outptr += num_components;
  379|  33.5M|        }
  380|  9.03M|      }
  381|  9.03M|      output_buf++;
  382|  9.03M|      input_row++;
  383|  9.03M|    }
  384|  9.03M|  }
  385|  9.03M|}

jinit_inverse_dct:
  335|  22.8k|{
  336|  22.8k|  my_idct_ptr idct;
  337|  22.8k|  int ci;
  338|  22.8k|  jpeg_component_info *compptr;
  339|       |
  340|  22.8k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (340:7): [True: 0, False: 22.8k]
  ------------------
  341|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|       |
  343|  22.8k|  idct = (my_idct_ptr)
  344|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  345|  22.8k|                                sizeof(my_idct_controller));
  346|  22.8k|  cinfo->idct = (struct jpeg_inverse_dct *)idct;
  347|  22.8k|  idct->pub.start_pass = start_pass;
  348|       |
  349|  45.7k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (349:44): [True: 22.9k, False: 22.8k]
  ------------------
  350|  22.9k|       ci++, compptr++) {
  351|       |    /* Allocate and pre-zero a multiplier table for each component */
  352|  22.9k|    compptr->dct_table =
  353|  22.9k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|  22.9k|                                  sizeof(multiplier_table));
  355|  22.9k|    memset(compptr->dct_table, 0, sizeof(multiplier_table));
  356|       |    /* Mark multiplier table not yet set up for any method */
  357|  22.9k|    idct->cur_method[ci] = -1;
  358|  22.9k|  }
  359|  22.8k|}
jddctmgr-8.c:start_pass:
  102|  22.8k|{
  103|  22.8k|  my_idct_ptr idct = (my_idct_ptr)cinfo->idct;
  104|  22.8k|  int ci, i;
  105|  22.8k|  jpeg_component_info *compptr;
  106|  22.8k|  int method = 0;
  107|  22.8k|  _inverse_DCT_method_ptr method_ptr = NULL;
  ------------------
  |  |  262|  22.8k|#define _inverse_DCT_method_ptr  inverse_DCT_method_ptr
  ------------------
  108|  22.8k|  JQUANT_TBL *qtbl;
  109|       |
  110|  45.6k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (110:44): [True: 22.8k, False: 22.8k]
  ------------------
  111|  22.8k|       ci++, compptr++) {
  112|       |    /* Select the proper IDCT routine for this component's scaling */
  113|  22.8k|    switch (compptr->_DCT_scaled_size) {
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  114|      0|#ifdef IDCT_SCALING_SUPPORTED
  115|      0|    case 1:
  ------------------
  |  Branch (115:5): [True: 0, False: 22.8k]
  ------------------
  116|      0|      method_ptr = _jpeg_idct_1x1;
  ------------------
  |  |  312|      0|#define _jpeg_idct_1x1  jpeg_idct_1x1
  ------------------
  117|      0|      method = JDCT_ISLOW;      /* jidctred uses islow-style table */
  118|      0|      break;
  119|      0|    case 2:
  ------------------
  |  Branch (119:5): [True: 0, False: 22.8k]
  ------------------
  120|      0|#ifdef WITH_SIMD
  121|      0|      if (jsimd_set_idct_2x2(cinfo))
  ------------------
  |  Branch (121:11): [True: 0, False: 0]
  ------------------
  122|      0|        method_ptr = jsimd_idct_2x2;
  123|      0|      else
  124|      0|#endif
  125|      0|        method_ptr = _jpeg_idct_2x2;
  ------------------
  |  |  311|      0|#define _jpeg_idct_2x2  jpeg_idct_2x2
  ------------------
  126|      0|      method = JDCT_ISLOW;      /* jidctred uses islow-style table */
  127|      0|      break;
  128|      0|    case 3:
  ------------------
  |  Branch (128:5): [True: 0, False: 22.8k]
  ------------------
  129|      0|      method_ptr = _jpeg_idct_3x3;
  ------------------
  |  |  310|      0|#define _jpeg_idct_3x3  jpeg_idct_3x3
  ------------------
  130|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  131|      0|      break;
  132|      0|    case 4:
  ------------------
  |  Branch (132:5): [True: 0, False: 22.8k]
  ------------------
  133|      0|#ifdef WITH_SIMD
  134|      0|      if (jsimd_set_idct_4x4(cinfo))
  ------------------
  |  Branch (134:11): [True: 0, False: 0]
  ------------------
  135|      0|        method_ptr = jsimd_idct_4x4;
  136|      0|      else
  137|      0|#endif
  138|      0|        method_ptr = _jpeg_idct_4x4;
  ------------------
  |  |  309|      0|#define _jpeg_idct_4x4  jpeg_idct_4x4
  ------------------
  139|      0|      method = JDCT_ISLOW;      /* jidctred uses islow-style table */
  140|      0|      break;
  141|      0|    case 5:
  ------------------
  |  Branch (141:5): [True: 0, False: 22.8k]
  ------------------
  142|      0|      method_ptr = _jpeg_idct_5x5;
  ------------------
  |  |  308|      0|#define _jpeg_idct_5x5  jpeg_idct_5x5
  ------------------
  143|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  144|      0|      break;
  145|      0|    case 6:
  ------------------
  |  Branch (145:5): [True: 0, False: 22.8k]
  ------------------
  146|      0|      method_ptr = _jpeg_idct_6x6;
  ------------------
  |  |  307|      0|#define _jpeg_idct_6x6  jpeg_idct_6x6
  ------------------
  147|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  148|      0|      break;
  149|      0|    case 7:
  ------------------
  |  Branch (149:5): [True: 0, False: 22.8k]
  ------------------
  150|      0|      method_ptr = _jpeg_idct_7x7;
  ------------------
  |  |  306|      0|#define _jpeg_idct_7x7  jpeg_idct_7x7
  ------------------
  151|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  152|      0|      break;
  153|      0|#endif
  154|  22.8k|    case DCTSIZE:
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (154:5): [True: 22.8k, False: 0]
  ------------------
  155|  22.8k|      switch (cinfo->dct_method) {
  156|      0|#ifdef DCT_ISLOW_SUPPORTED
  157|  22.8k|      case JDCT_ISLOW:
  ------------------
  |  Branch (157:7): [True: 22.8k, False: 0]
  ------------------
  158|  22.8k|#ifdef WITH_SIMD
  159|  22.8k|        if (jsimd_set_idct_islow(cinfo))
  ------------------
  |  Branch (159:13): [True: 22.8k, False: 0]
  ------------------
  160|  22.8k|          method_ptr = jsimd_idct_islow;
  161|      0|        else
  162|      0|#endif
  163|      0|          method_ptr = _jpeg_idct_islow;
  ------------------
  |  |  303|      0|#define _jpeg_idct_islow  jpeg_idct_islow
  ------------------
  164|  22.8k|        method = JDCT_ISLOW;
  165|  22.8k|        break;
  166|      0|#endif
  167|      0|#ifdef DCT_IFAST_SUPPORTED
  168|      0|      case JDCT_IFAST:
  ------------------
  |  Branch (168:7): [True: 0, False: 22.8k]
  ------------------
  169|      0|#ifdef WITH_SIMD
  170|      0|        if (jsimd_set_idct_ifast(cinfo))
  ------------------
  |  Branch (170:13): [True: 0, False: 0]
  ------------------
  171|      0|          method_ptr = jsimd_idct_ifast;
  172|      0|        else
  173|      0|#endif
  174|      0|          method_ptr = _jpeg_idct_ifast;
  ------------------
  |  |  304|      0|#define _jpeg_idct_ifast  jpeg_idct_ifast
  ------------------
  175|      0|        method = JDCT_IFAST;
  176|      0|        break;
  177|      0|#endif
  178|      0|#ifdef DCT_FLOAT_SUPPORTED
  179|      0|      case JDCT_FLOAT:
  ------------------
  |  Branch (179:7): [True: 0, False: 22.8k]
  ------------------
  180|      0|#ifdef WITH_SIMD
  181|      0|        if (jsimd_set_idct_float(cinfo))
  ------------------
  |  Branch (181:13): [True: 0, False: 0]
  ------------------
  182|      0|          method_ptr = jsimd_idct_float;
  183|      0|        else
  184|      0|#endif
  185|      0|          method_ptr = _jpeg_idct_float;
  ------------------
  |  |  305|      0|#define _jpeg_idct_float  jpeg_idct_float
  ------------------
  186|      0|        method = JDCT_FLOAT;
  187|      0|        break;
  188|      0|#endif
  189|      0|      default:
  ------------------
  |  Branch (189:7): [True: 0, False: 22.8k]
  ------------------
  190|      0|        ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  191|      0|        break;
  192|  22.8k|      }
  193|  22.8k|      break;
  194|  22.8k|#ifdef IDCT_SCALING_SUPPORTED
  195|  22.8k|    case 9:
  ------------------
  |  Branch (195:5): [True: 0, False: 22.8k]
  ------------------
  196|      0|      method_ptr = _jpeg_idct_9x9;
  ------------------
  |  |  313|      0|#define _jpeg_idct_9x9  jpeg_idct_9x9
  ------------------
  197|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  198|      0|      break;
  199|      0|    case 10:
  ------------------
  |  Branch (199:5): [True: 0, False: 22.8k]
  ------------------
  200|      0|      method_ptr = _jpeg_idct_10x10;
  ------------------
  |  |  314|      0|#define _jpeg_idct_10x10  jpeg_idct_10x10
  ------------------
  201|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  202|      0|      break;
  203|      0|    case 11:
  ------------------
  |  Branch (203:5): [True: 0, False: 22.8k]
  ------------------
  204|      0|      method_ptr = _jpeg_idct_11x11;
  ------------------
  |  |  315|      0|#define _jpeg_idct_11x11  jpeg_idct_11x11
  ------------------
  205|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  206|      0|      break;
  207|      0|    case 12:
  ------------------
  |  Branch (207:5): [True: 0, False: 22.8k]
  ------------------
  208|      0|      method_ptr = _jpeg_idct_12x12;
  ------------------
  |  |  316|      0|#define _jpeg_idct_12x12  jpeg_idct_12x12
  ------------------
  209|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  210|      0|      break;
  211|      0|    case 13:
  ------------------
  |  Branch (211:5): [True: 0, False: 22.8k]
  ------------------
  212|      0|      method_ptr = _jpeg_idct_13x13;
  ------------------
  |  |  317|      0|#define _jpeg_idct_13x13  jpeg_idct_13x13
  ------------------
  213|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  214|      0|      break;
  215|      0|    case 14:
  ------------------
  |  Branch (215:5): [True: 0, False: 22.8k]
  ------------------
  216|      0|      method_ptr = _jpeg_idct_14x14;
  ------------------
  |  |  318|      0|#define _jpeg_idct_14x14  jpeg_idct_14x14
  ------------------
  217|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  218|      0|      break;
  219|      0|    case 15:
  ------------------
  |  Branch (219:5): [True: 0, False: 22.8k]
  ------------------
  220|      0|      method_ptr = _jpeg_idct_15x15;
  ------------------
  |  |  319|      0|#define _jpeg_idct_15x15  jpeg_idct_15x15
  ------------------
  221|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  222|      0|      break;
  223|      0|    case 16:
  ------------------
  |  Branch (223:5): [True: 0, False: 22.8k]
  ------------------
  224|      0|      method_ptr = _jpeg_idct_16x16;
  ------------------
  |  |  320|      0|#define _jpeg_idct_16x16  jpeg_idct_16x16
  ------------------
  225|      0|      method = JDCT_ISLOW;      /* jidctint uses islow-style table */
  226|      0|      break;
  227|      0|#endif
  228|      0|    default:
  ------------------
  |  Branch (228:5): [True: 0, False: 22.8k]
  ------------------
  229|      0|      ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  230|      0|      break;
  231|  22.8k|    }
  232|  22.8k|    idct->pub._inverse_DCT[ci] = method_ptr;
  ------------------
  |  |  263|  22.8k|#define _inverse_DCT  inverse_DCT
  ------------------
  233|       |    /* Create multiplier table from quant table.
  234|       |     * However, we can skip this if the component is uninteresting
  235|       |     * or if we already built the table.  Also, if no quant table
  236|       |     * has yet been saved for the component, we leave the
  237|       |     * multiplier table all-zero; we'll be reading zeroes from the
  238|       |     * coefficient controller's buffer anyway.
  239|       |     */
  240|  22.8k|    if (!compptr->component_needed || idct->cur_method[ci] == method)
  ------------------
  |  Branch (240:9): [True: 0, False: 22.8k]
  |  Branch (240:39): [True: 0, False: 22.8k]
  ------------------
  241|      0|      continue;
  242|  22.8k|    qtbl = compptr->quant_table;
  243|  22.8k|    if (qtbl == NULL)           /* happens if no data yet for component */
  ------------------
  |  Branch (243:9): [True: 0, False: 22.8k]
  ------------------
  244|      0|      continue;
  245|  22.8k|    idct->cur_method[ci] = method;
  246|  22.8k|    switch (method) {
  247|      0|#ifdef PROVIDE_ISLOW_TABLES
  248|  22.8k|    case JDCT_ISLOW:
  ------------------
  |  Branch (248:5): [True: 22.8k, False: 0]
  ------------------
  249|  22.8k|      {
  250|       |        /* For LL&M IDCT method, multipliers are equal to raw quantization
  251|       |         * coefficients, but are stored as ints to ensure access efficiency.
  252|       |         */
  253|  22.8k|        ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table;
  254|  1.48M|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  1.48M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (254:21): [True: 1.46M, False: 22.8k]
  ------------------
  255|  1.46M|          ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i];
  256|  1.46M|        }
  257|  22.8k|      }
  258|  22.8k|      break;
  259|      0|#endif
  260|      0|#ifdef DCT_IFAST_SUPPORTED
  261|      0|    case JDCT_IFAST:
  ------------------
  |  Branch (261:5): [True: 0, False: 22.8k]
  ------------------
  262|      0|      {
  263|       |        /* For AA&N IDCT method, multipliers are equal to quantization
  264|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  265|       |         *   scalefactor[0] = 1
  266|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  267|       |         * For integer operation, the multiplier table is to be scaled by
  268|       |         * IFAST_SCALE_BITS.
  269|       |         */
  270|      0|        IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *)compptr->dct_table;
  271|      0|#define CONST_BITS  14
  272|      0|        static const INT16 aanscales[DCTSIZE2] = {
  273|       |          /* precomputed values scaled up by 14 bits */
  274|      0|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  275|      0|          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
  276|      0|          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
  277|      0|          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
  278|      0|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  279|      0|          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
  280|      0|           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
  281|      0|           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
  282|      0|        };
  283|      0|        SHIFT_TEMPS
  284|       |
  285|      0|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (285:21): [True: 0, False: 0]
  ------------------
  286|      0|          ifmtbl[i] = (IFAST_MULT_TYPE)
  287|      0|            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  ------------------
  |  |  216|      0|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|      0|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  288|      0|                                  (JLONG)aanscales[i]),
  289|      0|                    CONST_BITS - IFAST_SCALE_BITS);
  290|      0|        }
  291|      0|      }
  292|      0|      break;
  293|      0|#endif
  294|      0|#ifdef DCT_FLOAT_SUPPORTED
  295|      0|    case JDCT_FLOAT:
  ------------------
  |  Branch (295:5): [True: 0, False: 22.8k]
  ------------------
  296|      0|      {
  297|       |        /* For float AA&N IDCT method, multipliers are equal to quantization
  298|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  299|       |         *   scalefactor[0] = 1
  300|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  301|       |         */
  302|      0|        FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *)compptr->dct_table;
  303|      0|        int row, col;
  304|      0|        static const double aanscalefactor[DCTSIZE] = {
  305|      0|          1.0, 1.387039845, 1.306562965, 1.175875602,
  306|      0|          1.0, 0.785694958, 0.541196100, 0.275899379
  307|      0|        };
  308|       |
  309|      0|        i = 0;
  310|      0|        for (row = 0; row < DCTSIZE; row++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (310:23): [True: 0, False: 0]
  ------------------
  311|      0|          for (col = 0; col < DCTSIZE; col++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (311:25): [True: 0, False: 0]
  ------------------
  312|      0|            fmtbl[i] = (FLOAT_MULT_TYPE)
  313|      0|              ((double)qtbl->quantval[i] *
  314|      0|               aanscalefactor[row] * aanscalefactor[col]);
  315|      0|            i++;
  316|      0|          }
  317|      0|        }
  318|      0|      }
  319|      0|      break;
  320|      0|#endif
  321|      0|    default:
  ------------------
  |  Branch (321:5): [True: 0, False: 22.8k]
  ------------------
  322|      0|      ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  323|      0|      break;
  324|  22.8k|    }
  325|  22.8k|  }
  326|  22.8k|}

jinit_d_diff_controller:
  348|      9|{
  349|      9|  my_diff_ptr diff;
  350|      9|  int ci;
  351|      9|  jpeg_component_info *compptr;
  352|       |
  353|      9|#if BITS_IN_JSAMPLE == 8
  354|      9|  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (354:7): [True: 0, False: 9]
  |  Branch (354:50): [True: 0, False: 9]
  ------------------
  355|       |#else
  356|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  357|       |      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  358|       |#endif
  359|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  360|       |
  361|      9|  diff = (my_diff_ptr)
  362|      9|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      9|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  363|      9|                                sizeof(my_diff_controller));
  364|      9|  cinfo->coef = (struct jpeg_d_coef_controller *)diff;
  365|      9|  diff->pub.start_input_pass = start_input_pass;
  366|      9|  diff->pub.start_output_pass = start_output_pass;
  367|       |
  368|       |  /* Create the [un]difference buffers. */
  369|     22|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (369:44): [True: 13, False: 9]
  ------------------
  370|     13|       ci++, compptr++) {
  371|     13|    diff->diff_buf[ci] =
  372|     13|      ALLOC_DARRAY(JPOOL_IMAGE,
  ------------------
  |  |   28|     13|  (JDIFFARRAY)(*cinfo->mem->alloc_sarray) \
  |  |   29|     13|    ((j_common_ptr)cinfo, pool_id, \
  |  |   30|     13|     (diffsperrow) * sizeof(JDIFF) / sizeof(_JSAMPLE), numrows)
  ------------------
  373|     13|                   (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  374|     13|                                         (long)compptr->h_samp_factor),
  375|     13|                   (JDIMENSION)compptr->v_samp_factor);
  376|     13|    diff->undiff_buf[ci] =
  377|     13|      ALLOC_DARRAY(JPOOL_IMAGE,
  ------------------
  |  |   28|     13|  (JDIFFARRAY)(*cinfo->mem->alloc_sarray) \
  |  |   29|     13|    ((j_common_ptr)cinfo, pool_id, \
  |  |   30|     13|     (diffsperrow) * sizeof(JDIFF) / sizeof(_JSAMPLE), numrows)
  ------------------
  378|     13|                   (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  379|     13|                                         (long)compptr->h_samp_factor),
  380|     13|                   (JDIMENSION)compptr->v_samp_factor);
  381|     13|  }
  382|       |
  383|      9|  if (need_full_buffer) {
  ------------------
  |  Branch (383:7): [True: 2, False: 7]
  ------------------
  384|      2|#ifdef D_MULTISCAN_FILES_SUPPORTED
  385|       |    /* Allocate a full-image virtual array for each component. */
  386|      2|    int access_rows;
  387|       |
  388|      8|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (388:46): [True: 6, False: 2]
  ------------------
  389|      6|         ci++, compptr++) {
  390|      6|      access_rows = compptr->v_samp_factor;
  391|      6|      diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
  392|      6|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|      6|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|      6|#define FALSE   0               /* values of boolean */
  ------------------
  393|      6|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  394|      6|                               (long)compptr->h_samp_factor),
  395|      6|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  396|      6|                               (long)compptr->v_samp_factor),
  397|      6|         (JDIMENSION)access_rows);
  398|      6|    }
  399|      2|    diff->pub.consume_data = consume_data;
  400|      2|    diff->pub._decompress_data = output_data;
  ------------------
  |  |  258|      2|#define _decompress_data  decompress_data
  ------------------
  401|       |#else
  402|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  403|       |#endif
  404|      7|  } else {
  405|      7|    diff->pub.consume_data = dummy_consume_data;
  406|      7|    diff->pub._decompress_data = decompress_data;
  ------------------
  |  |  258|      7|#define _decompress_data  decompress_data
  ------------------
  407|       |    diff->whole_image[0] = NULL; /* flag for no virtual arrays */
  408|      7|  }
  409|      9|}

jpeg_make_d_derived_tbl:
  145|  45.7k|{
  146|  45.7k|  JHUFF_TBL *htbl;
  147|  45.7k|  d_derived_tbl *dtbl;
  148|  45.7k|  int p, i, l, si, numsymbols;
  149|  45.7k|  int lookbits, ctr;
  150|  45.7k|  char huffsize[257];
  151|  45.7k|  unsigned int huffcode[257];
  152|  45.7k|  unsigned int code;
  153|       |
  154|       |  /* Note that huffsize[] and huffcode[] are filled in code-length order,
  155|       |   * paralleling the order of the symbols themselves in htbl->huffval[].
  156|       |   */
  157|       |
  158|       |  /* Find the input Huffman table */
  159|  45.7k|  if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  45.7k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (159:7): [True: 0, False: 45.7k]
  |  Branch (159:20): [True: 4, False: 45.7k]
  ------------------
  160|      4|    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
  ------------------
  |  |  243|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      4|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  161|  45.7k|  htbl =
  162|  45.7k|    isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
  ------------------
  |  Branch (162:5): [True: 22.8k, False: 22.8k]
  ------------------
  163|  45.7k|  if (htbl == NULL)
  ------------------
  |  Branch (163:7): [True: 7, False: 45.7k]
  ------------------
  164|      7|    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
  ------------------
  |  |  243|      7|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      7|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      7|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  165|       |
  166|       |  /* Allocate a workspace if we haven't already done so. */
  167|  45.7k|  if (*pdtbl == NULL)
  ------------------
  |  Branch (167:7): [True: 45.7k, False: 59]
  ------------------
  168|  45.7k|    *pdtbl = (d_derived_tbl *)
  169|  45.7k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  45.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  170|  45.7k|                                  sizeof(d_derived_tbl));
  171|  45.7k|  dtbl = *pdtbl;
  172|  45.7k|  dtbl->pub = htbl;             /* fill in back link */
  173|       |
  174|       |  /* Figure C.1: make table of Huffman code length for each symbol */
  175|       |
  176|  45.7k|  p = 0;
  177|   777k|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (177:15): [True: 732k, False: 45.7k]
  ------------------
  178|   732k|    i = (int)htbl->bits[l];
  179|   732k|    if (i < 0 || p + i > 256)   /* protect against table overrun */
  ------------------
  |  Branch (179:9): [True: 0, False: 732k]
  |  Branch (179:18): [True: 0, False: 732k]
  ------------------
  180|      0|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  181|  4.69M|    while (i--)
  ------------------
  |  Branch (181:12): [True: 3.96M, False: 732k]
  ------------------
  182|  3.96M|      huffsize[p++] = (char)l;
  183|   732k|  }
  184|  45.7k|  huffsize[p] = 0;
  185|  45.7k|  numsymbols = p;
  186|       |
  187|       |  /* Figure C.2: generate the codes themselves */
  188|       |  /* We also validate that the counts represent a legal Huffman code tree. */
  189|       |
  190|  45.7k|  code = 0;
  191|  45.7k|  si = huffsize[0];
  192|  45.7k|  p = 0;
  193|   571k|  while (huffsize[p]) {
  ------------------
  |  Branch (193:10): [True: 525k, False: 45.7k]
  ------------------
  194|  4.49M|    while (((int)huffsize[p]) == si) {
  ------------------
  |  Branch (194:12): [True: 3.96M, False: 525k]
  ------------------
  195|  3.96M|      huffcode[p++] = code;
  196|  3.96M|      code++;
  197|  3.96M|    }
  198|       |    /* code is now 1 more than the last code used for codelength si; but
  199|       |     * it must still fit in si bits, since no code is allowed to be all ones.
  200|       |     */
  201|   525k|    if (((JLONG)code) >= (((JLONG)1) << si))
  ------------------
  |  Branch (201:9): [True: 10, False: 525k]
  ------------------
  202|     10|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|     10|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     10|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  203|   525k|    code <<= 1;
  204|   525k|    si++;
  205|   525k|  }
  206|       |
  207|       |  /* Figure F.15: generate decoding tables for bit-sequential decoding */
  208|       |
  209|  45.7k|  p = 0;
  210|   777k|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (210:15): [True: 731k, False: 45.7k]
  ------------------
  211|   731k|    if (htbl->bits[l]) {
  ------------------
  |  Branch (211:9): [True: 479k, False: 252k]
  ------------------
  212|       |      /* valoffset[l] = huffval[] index of 1st symbol of code length l,
  213|       |       * minus the minimum code of length l
  214|       |       */
  215|   479k|      dtbl->valoffset[l] = (JLONG)p - (JLONG)huffcode[p];
  216|   479k|      p += htbl->bits[l];
  217|   479k|      dtbl->maxcode[l] = huffcode[p - 1]; /* maximum code of length l */
  218|   479k|    } else {
  219|   252k|      dtbl->maxcode[l] = -1;    /* -1 if no codes of this length */
  220|   252k|    }
  221|   731k|  }
  222|  45.7k|  dtbl->valoffset[17] = 0;
  223|  45.7k|  dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
  224|       |
  225|       |  /* Compute lookahead tables to speed up decoding.
  226|       |   * First we set all the table entries to 0, indicating "too long";
  227|       |   * then we iterate through the Huffman codes that are short enough and
  228|       |   * fill in all the entries that correspond to bit sequences starting
  229|       |   * with that code.
  230|       |   */
  231|       |
  232|  11.7M|  for (i = 0; i < (1 << HUFF_LOOKAHEAD); i++)
  ------------------
  |  |   25|  11.7M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (232:15): [True: 11.7M, False: 45.7k]
  ------------------
  233|  11.7M|    dtbl->lookup[i] = (HUFF_LOOKAHEAD + 1) << HUFF_LOOKAHEAD;
  ------------------
  |  |   25|  11.7M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
                  dtbl->lookup[i] = (HUFF_LOOKAHEAD + 1) << HUFF_LOOKAHEAD;
  ------------------
  |  |   25|  11.7M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  234|       |
  235|  45.7k|  p = 0;
  236|   411k|  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
  ------------------
  |  |   25|   411k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (236:15): [True: 365k, False: 45.7k]
  ------------------
  237|  1.02M|    for (i = 1; i <= (int)htbl->bits[l]; i++, p++) {
  ------------------
  |  Branch (237:17): [True: 661k, False: 365k]
  ------------------
  238|       |      /* l = current code's length, p = its index in huffcode[] & huffval[]. */
  239|       |      /* Generate left-justified code followed by all possible bit sequences */
  240|   661k|      lookbits = huffcode[p] << (HUFF_LOOKAHEAD - l);
  ------------------
  |  |   25|   661k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  241|  12.1M|      for (ctr = 1 << (HUFF_LOOKAHEAD - l); ctr > 0; ctr--) {
  ------------------
  |  |   25|   661k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (241:45): [True: 11.5M, False: 661k]
  ------------------
  242|  11.5M|        dtbl->lookup[lookbits] = (l << HUFF_LOOKAHEAD) | htbl->huffval[p];
  ------------------
  |  |   25|  11.5M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  243|  11.5M|        lookbits++;
  244|  11.5M|      }
  245|   661k|    }
  246|   365k|  }
  247|       |
  248|       |  /* Validate symbols as being reasonable.
  249|       |   * For AC tables, we make no check, but accept all byte values 0..255.
  250|       |   * For DC tables, we require the symbols to be in range 0..15 in lossy mode
  251|       |   * and 0..16 in lossless mode.  (Tighter bounds could be applied depending on
  252|       |   * the data depth and mode, but this is sufficient to ensure safe decoding.)
  253|       |   */
  254|  45.7k|  if (isDC) {
  ------------------
  |  Branch (254:7): [True: 22.8k, False: 22.8k]
  ------------------
  255|   296k|    for (i = 0; i < numsymbols; i++) {
  ------------------
  |  Branch (255:17): [True: 273k, False: 22.8k]
  ------------------
  256|   273k|      int sym = htbl->huffval[i];
  257|   273k|      if (sym < 0 || sym > (cinfo->master->lossless ? 16 : 15))
  ------------------
  |  Branch (257:11): [True: 0, False: 273k]
  |  Branch (257:22): [True: 5, False: 273k]
  |  Branch (257:29): [True: 0, False: 273k]
  ------------------
  258|      5|        ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      5|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      5|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  259|   273k|    }
  260|  22.8k|  }
  261|  45.7k|}
jpeg_fill_bit_buffer:
  291|   349k|{
  292|       |  /* Copy heavily used state fields into locals (hopefully registers) */
  293|   349k|  register const JOCTET *next_input_byte = state->next_input_byte;
  294|   349k|  register size_t bytes_in_buffer = state->bytes_in_buffer;
  295|   349k|  j_decompress_ptr cinfo = state->cinfo;
  296|       |
  297|       |  /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
  298|       |  /* (It is assumed that no request will be for more than that many bits.) */
  299|       |  /* We fail to do so only if we hit a marker or are forced to suspend. */
  300|       |
  301|   349k|  if (cinfo->unread_marker == 0) {      /* cannot advance past a marker */
  ------------------
  |  Branch (301:7): [True: 210k, False: 139k]
  ------------------
  302|  1.63M|    while (bits_left < MIN_GET_BITS) {
  ------------------
  |  |  282|  1.63M|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  1.63M|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  |  Branch (302:12): [True: 1.44M, False: 187k]
  ------------------
  303|  1.44M|      register int c;
  304|       |
  305|       |      /* Attempt to read a byte */
  306|  1.44M|      if (bytes_in_buffer == 0) {
  ------------------
  |  Branch (306:11): [True: 34.8k, False: 1.41M]
  ------------------
  307|  34.8k|        if (!(*cinfo->src->fill_input_buffer) (cinfo))
  ------------------
  |  Branch (307:13): [True: 0, False: 34.8k]
  ------------------
  308|      0|          return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  309|  34.8k|        next_input_byte = cinfo->src->next_input_byte;
  310|  34.8k|        bytes_in_buffer = cinfo->src->bytes_in_buffer;
  311|  34.8k|      }
  312|  1.44M|      bytes_in_buffer--;
  313|  1.44M|      c = *next_input_byte++;
  314|       |
  315|       |      /* If it's 0xFF, check and discard stuffed zero byte */
  316|  1.44M|      if (c == 0xFF) {
  ------------------
  |  Branch (316:11): [True: 26.6k, False: 1.41M]
  ------------------
  317|       |        /* Loop here to discard any padding FF's on terminating marker,
  318|       |         * so that we can save a valid unread_marker value.  NOTE: we will
  319|       |         * accept multiple FF's followed by a 0 as meaning a single FF data
  320|       |         * byte.  This data pattern is not valid according to the standard.
  321|       |         */
  322|  85.8k|        do {
  323|  85.8k|          if (bytes_in_buffer == 0) {
  ------------------
  |  Branch (323:15): [True: 231, False: 85.6k]
  ------------------
  324|    231|            if (!(*cinfo->src->fill_input_buffer) (cinfo))
  ------------------
  |  Branch (324:17): [True: 0, False: 231]
  ------------------
  325|      0|              return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  326|    231|            next_input_byte = cinfo->src->next_input_byte;
  327|    231|            bytes_in_buffer = cinfo->src->bytes_in_buffer;
  328|    231|          }
  329|  85.8k|          bytes_in_buffer--;
  330|  85.8k|          c = *next_input_byte++;
  331|  85.8k|        } while (c == 0xFF);
  ------------------
  |  Branch (331:18): [True: 59.2k, False: 26.6k]
  ------------------
  332|       |
  333|  26.6k|        if (c == 0) {
  ------------------
  |  Branch (333:13): [True: 4.52k, False: 22.0k]
  ------------------
  334|       |          /* Found FF/00, which represents an FF data byte */
  335|  4.52k|          c = 0xFF;
  336|  22.0k|        } else {
  337|       |          /* Oops, it's actually a marker indicating end of compressed data.
  338|       |           * Save the marker code for later use.
  339|       |           * Fine point: it might appear that we should save the marker into
  340|       |           * bitread working state, not straight into permanent state.  But
  341|       |           * once we have hit a marker, we cannot need to suspend within the
  342|       |           * current MCU, because we will read no more bytes from the data
  343|       |           * source.  So it is OK to update permanent state right away.
  344|       |           */
  345|  22.0k|          cinfo->unread_marker = c;
  346|       |          /* See if we need to insert some fake zero bits. */
  347|  22.0k|          goto no_more_bytes;
  348|  22.0k|        }
  349|  26.6k|      }
  350|       |
  351|       |      /* OK, load c into get_buffer */
  352|  1.42M|      get_buffer = (get_buffer << 8) | c;
  353|  1.42M|      bits_left += 8;
  354|  1.42M|    } /* end while */
  355|   210k|  } else {
  356|   162k|no_more_bytes:
  357|       |    /* We get here if we've read the marker that terminates the compressed
  358|       |     * data segment.  There should be enough bits in the buffer register
  359|       |     * to satisfy the request; if so, no problem.
  360|       |     */
  361|   162k|    if (nbits > bits_left) {
  ------------------
  |  Branch (361:9): [True: 42.9k, False: 119k]
  ------------------
  362|       |      /* Uh-oh.  Report corrupted data to user and stuff zeroes into
  363|       |       * the data stream, so that we can produce some kind of image.
  364|       |       * We use a nonvolatile flag to ensure that only one warning message
  365|       |       * appears per data segment.
  366|       |       */
  367|  42.9k|      if (!cinfo->entropy->insufficient_data) {
  ------------------
  |  Branch (367:11): [True: 15.2k, False: 27.6k]
  ------------------
  368|  15.2k|        WARNMS(cinfo, JWRN_HIT_MARKER);
  ------------------
  |  |  283|  15.2k|  ((cinfo)->err->msg_code = (code), \
  |  |  284|  15.2k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  369|  15.2k|        cinfo->entropy->insufficient_data = TRUE;
  ------------------
  |  |  210|  15.2k|#define TRUE    1
  ------------------
  370|  15.2k|      }
  371|       |      /* Fill the buffer with zero bits */
  372|  42.9k|      get_buffer <<= MIN_GET_BITS - bits_left;
  ------------------
  |  |  282|  42.9k|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  42.9k|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  373|  42.9k|      bits_left = MIN_GET_BITS;
  ------------------
  |  |  282|  42.9k|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  42.9k|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  374|  42.9k|    }
  375|   162k|  }
  376|       |
  377|       |  /* Unload the local registers */
  378|   349k|  state->next_input_byte = next_input_byte;
  379|   349k|  state->bytes_in_buffer = bytes_in_buffer;
  380|   349k|  state->get_buffer = get_buffer;
  381|   349k|  state->bits_left = bits_left;
  382|       |
  383|   349k|  return TRUE;
  ------------------
  |  |  210|   349k|#define TRUE    1
  ------------------
  384|   349k|}
jpeg_huff_decode:
  439|   113k|{
  440|   113k|  register int l = min_bits;
  441|   113k|  register JLONG code;
  442|       |
  443|       |  /* HUFF_DECODE has determined that the code is at least min_bits */
  444|       |  /* bits long, so fetch that many bits in one swoop. */
  445|       |
  446|   113k|  CHECK_BIT_BUFFER(*state, l, return -1);
  ------------------
  |  |  160|   113k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|   113k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 12.1k, False: 101k]
  |  |  ------------------
  |  |  162|  12.1k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 12.1k]
  |  |  ------------------
  |  |  163|  12.1k|      { action; } \
  |  |  164|  12.1k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  12.1k|  } \
  |  |  166|   113k|}
  ------------------
  447|   113k|  code = GET_BITS(l);
  ------------------
  |  |  169|   113k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  448|       |
  449|       |  /* Collect the rest of the Huffman code one bit at a time. */
  450|       |  /* This is per Figure F.16. */
  451|       |
  452|   264k|  while (code > htbl->maxcode[l]) {
  ------------------
  |  Branch (452:10): [True: 150k, False: 113k]
  ------------------
  453|   150k|    code <<= 1;
  454|   150k|    CHECK_BIT_BUFFER(*state, 1, return -1);
  ------------------
  |  |  160|   150k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|   150k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 13.1k, False: 137k]
  |  |  ------------------
  |  |  162|  13.1k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 13.1k]
  |  |  ------------------
  |  |  163|  13.1k|      { action; } \
  |  |  164|  13.1k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  13.1k|  } \
  |  |  166|   150k|}
  ------------------
  455|   150k|    code |= GET_BITS(1);
  ------------------
  |  |  169|   150k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  456|   150k|    l++;
  457|   150k|  }
  458|       |
  459|       |  /* Unload the local registers */
  460|   113k|  state->get_buffer = get_buffer;
  461|   113k|  state->bits_left = bits_left;
  462|       |
  463|       |  /* With garbage input we may reach the sentinel value l = 17. */
  464|       |
  465|   113k|  if (l > 16) {
  ------------------
  |  Branch (465:7): [True: 2.16k, False: 111k]
  ------------------
  466|  2.16k|    WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
  ------------------
  |  |  283|  2.16k|  ((cinfo)->err->msg_code = (code), \
  |  |  284|  2.16k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  467|  2.16k|    return 0;                   /* fake a zero as the safest result */
  468|  2.16k|  }
  469|       |
  470|   111k|  return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
  471|   113k|}
jinit_huff_decoder:
  815|  22.8k|{
  816|  22.8k|  huff_entropy_ptr entropy;
  817|  22.8k|  int i;
  818|       |
  819|       |  /* Motion JPEG frames typically do not include the Huffman tables if they
  820|       |     are the default tables.  Thus, if the tables are not set by the time
  821|       |     the Huffman decoder is initialized (usually within the body of
  822|       |     jpeg_start_decompress()), we set them to default values. */
  823|  22.8k|  std_huff_tables((j_common_ptr)cinfo);
  824|       |
  825|  22.8k|  entropy = (huff_entropy_ptr)
  826|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  827|  22.8k|                                sizeof(huff_entropy_decoder));
  828|  22.8k|  cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
  829|  22.8k|  entropy->pub.start_pass = start_pass_huff_decoder;
  830|  22.8k|  entropy->pub.decode_mcu = decode_mcu;
  831|       |
  832|       |  /* Mark tables unallocated */
  833|   114k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   114k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (833:15): [True: 91.3k, False: 22.8k]
  ------------------
  834|       |    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
  835|  91.3k|  }
  836|  22.8k|}
jdhuff.c:start_pass_huff_decoder:
   80|  22.8k|{
   81|  22.8k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
   82|  22.8k|  int ci, blkn, dctbl, actbl;
   83|  22.8k|  d_derived_tbl **pdtbl;
   84|  22.8k|  jpeg_component_info *compptr;
   85|       |
   86|       |  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
   87|       |   * This ought to be an error condition, but we make it a warning because
   88|       |   * there are some baseline files out there with all zeroes in these bytes.
   89|       |   */
   90|  22.8k|  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
  ------------------
  |  |   67|  22.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (90:7): [True: 0, False: 22.8k]
  |  Branch (90:25): [True: 0, False: 22.8k]
  ------------------
   91|  22.8k|      cinfo->Ah != 0 || cinfo->Al != 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 22.8k]
  |  Branch (91:25): [True: 0, False: 22.8k]
  ------------------
   92|      0|    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
  ------------------
  |  |  283|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  284|      0|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
   93|       |
   94|  45.7k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (94:16): [True: 22.8k, False: 22.8k]
  ------------------
   95|  22.8k|    compptr = cinfo->cur_comp_info[ci];
   96|  22.8k|    dctbl = compptr->dc_tbl_no;
   97|  22.8k|    actbl = compptr->ac_tbl_no;
   98|       |    /* Compute derived values for Huffman tables */
   99|       |    /* We may do this more than once for a table, but it's not expensive */
  100|  22.8k|    pdtbl = (d_derived_tbl **)(entropy->dc_derived_tbls) + dctbl;
  101|  22.8k|    jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  102|  22.8k|    pdtbl = (d_derived_tbl **)(entropy->ac_derived_tbls) + actbl;
  103|  22.8k|    jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  104|       |    /* Initialize DC predictions to 0 */
  105|  22.8k|    entropy->saved.last_dc_val[ci] = 0;
  106|  22.8k|  }
  107|       |
  108|       |  /* Precalculate decoding info for each block in an MCU of this scan */
  109|  45.7k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (109:18): [True: 22.9k, False: 22.8k]
  ------------------
  110|  22.9k|    ci = cinfo->MCU_membership[blkn];
  111|  22.9k|    compptr = cinfo->cur_comp_info[ci];
  112|       |    /* Precalculate which table to use for each block */
  113|  22.9k|    entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
  114|  22.9k|    entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
  115|       |    /* Decide whether we really care about the coefficient values */
  116|  22.9k|    if (compptr->component_needed) {
  ------------------
  |  Branch (116:9): [True: 22.9k, False: 0]
  ------------------
  117|  22.9k|      entropy->dc_needed[blkn] = TRUE;
  ------------------
  |  |  210|  22.9k|#define TRUE    1
  ------------------
  118|       |      /* we don't need the ACs if producing a 1/8th-size image */
  119|  22.9k|      entropy->ac_needed[blkn] = (compptr->_DCT_scaled_size > 1);
  ------------------
  |  |   24|  22.9k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  120|  22.9k|    } else {
  121|      0|      entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  122|      0|    }
  123|  22.9k|  }
  124|       |
  125|       |  /* Initialize bitread state variables */
  126|  22.8k|  entropy->bitstate.bits_left = 0;
  127|  22.8k|  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
  128|  22.8k|  entropy->pub.insufficient_data = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  129|       |
  130|       |  /* Initialize restart counter */
  131|  22.8k|  entropy->restarts_to_go = cinfo->restart_interval;
  132|  22.8k|}
jdhuff.c:decode_mcu:
  771|  1.28M|{
  772|  1.28M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  773|  1.28M|  int usefast = 1;
  774|       |
  775|       |  /* Process restart marker if needed; may have to suspend */
  776|  1.28M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (776:7): [True: 90.2k, False: 1.19M]
  ------------------
  777|  90.2k|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (777:9): [True: 41.5k, False: 48.6k]
  ------------------
  778|  41.5k|      if (!process_restart(cinfo))
  ------------------
  |  Branch (778:11): [True: 0, False: 41.5k]
  ------------------
  779|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  780|  90.2k|    usefast = 0;
  781|  90.2k|  }
  782|       |
  783|  1.28M|  if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU ||
  ------------------
  |  |  767|  1.28M|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  ------------------
  |  |  |  |   67|  1.28M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  ------------------
  ------------------
  |  Branch (783:7): [True: 779k, False: 501k]
  ------------------
  784|   501k|      cinfo->unread_marker != 0)
  ------------------
  |  Branch (784:7): [True: 329k, False: 171k]
  ------------------
  785|  1.07M|    usefast = 0;
  786|       |
  787|       |  /* If we've run out of data, just leave the MCU set to zeroes.
  788|       |   * This way, we return uniform gray for the remainder of the segment.
  789|       |   */
  790|  1.28M|  if (!entropy->pub.insufficient_data) {
  ------------------
  |  Branch (790:7): [True: 248k, False: 1.03M]
  ------------------
  791|       |
  792|   248k|    if (usefast) {
  ------------------
  |  Branch (792:9): [True: 171k, False: 77.2k]
  ------------------
  793|   171k|      if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
  ------------------
  |  Branch (793:11): [True: 4.92k, False: 166k]
  ------------------
  794|   171k|    } else {
  795|  82.1k|use_slow:
  796|  82.1k|      if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (796:11): [True: 0, False: 82.1k]
  ------------------
  797|  82.1k|    }
  798|       |
  799|   248k|  }
  800|       |
  801|       |  /* Account for restart interval (no-op if not using restarts) */
  802|  1.28M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (802:7): [True: 55.2k, False: 1.22M]
  ------------------
  803|  55.2k|    entropy->restarts_to_go--;
  804|       |
  805|  1.28M|  return TRUE;
  ------------------
  |  |  210|  1.28M|#define TRUE    1
  ------------------
  806|  1.28M|}
jdhuff.c:process_restart:
  513|  41.5k|{
  514|  41.5k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  515|  41.5k|  int ci;
  516|       |
  517|       |  /* Throw away any unused bits remaining in bit buffer; */
  518|       |  /* include any full bytes in next_marker's count of discarded bytes */
  519|  41.5k|  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
  520|  41.5k|  entropy->bitstate.bits_left = 0;
  521|       |
  522|       |  /* Advance past the RSTn marker */
  523|  41.5k|  if (!(*cinfo->marker->read_restart_marker) (cinfo))
  ------------------
  |  Branch (523:7): [True: 0, False: 41.5k]
  ------------------
  524|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  525|       |
  526|       |  /* Re-initialize DC predictions to 0 */
  527|  49.1k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++)
  ------------------
  |  Branch (527:16): [True: 7.56k, False: 41.5k]
  ------------------
  528|  7.56k|    entropy->saved.last_dc_val[ci] = 0;
  529|       |
  530|       |  /* Reset restart counter */
  531|  41.5k|  entropy->restarts_to_go = cinfo->restart_interval;
  532|       |
  533|       |  /* Reset out-of-data flag, unless read_restart_marker left us smack up
  534|       |   * against a marker.  In that case we will end up treating the next data
  535|       |   * segment as empty, and we can avoid producing bogus output pixels by
  536|       |   * leaving the flag set.
  537|       |   */
  538|  41.5k|  if (cinfo->unread_marker == 0)
  ------------------
  |  Branch (538:7): [True: 7.56k, False: 34.0k]
  ------------------
  539|  7.56k|    entropy->pub.insufficient_data = FALSE;
  ------------------
  |  |  207|  7.56k|#define FALSE   0               /* values of boolean */
  ------------------
  540|       |
  541|  41.5k|  return TRUE;
  ------------------
  |  |  210|  41.5k|#define TRUE    1
  ------------------
  542|  41.5k|}
jdhuff.c:decode_mcu_fast:
  664|   171k|{
  665|   171k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  666|   171k|  BITREAD_STATE_VARS;
  ------------------
  |  |  125|   171k|  register bit_buf_type get_buffer; \
  |  |  126|   171k|  register int bits_left; \
  |  |  127|   171k|  bitread_working_state br_state
  ------------------
  667|   171k|  JOCTET *buffer;
  668|   171k|  int blkn;
  669|   171k|  savable_state state;
  670|       |  /* Outer loop handles each block in the MCU */
  671|       |
  672|       |  /* Load up working state */
  673|   171k|  BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  130|   171k|  br_state.cinfo = cinfop; \
  |  |  131|   171k|  br_state.next_input_byte = cinfop->src->next_input_byte; \
  |  |  132|   171k|  br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
  |  |  133|   171k|  get_buffer = permstate.get_buffer; \
  |  |  134|   171k|  bits_left = permstate.bits_left;
  ------------------
  674|   171k|  buffer = (JOCTET *)br_state.next_input_byte;
  675|   171k|  state = entropy->saved;
  676|       |
  677|   342k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (677:18): [True: 171k, False: 171k]
  ------------------
  678|   171k|    JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
  ------------------
  |  Branch (678:23): [True: 171k, False: 0]
  ------------------
  679|   171k|    d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
  680|   171k|    d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
  681|   171k|    register int s, k, r, l;
  682|       |
  683|   171k|    HUFF_DECODE_FAST(s, l, dctbl);
  ------------------
  |  |  224|   171k|  FILL_BIT_BUFFER_FAST; \
  |  |  ------------------
  |  |  |  |  415|   171k|  if (bits_left <= 16) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (415:7): [True: 8.47k, False: 162k]
  |  |  |  |  ------------------
  |  |  |  |  416|  8.47k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 794, False: 7.67k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    794|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    794|    buffer++; \
  |  |  |  |  |  |  401|    794|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 636, False: 158]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    636|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    636|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    636|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    636|      buffer -= 2; \
  |  |  |  |  |  |  406|    636|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    636|    } \
  |  |  |  |  |  |  408|    794|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 952, False: 7.51k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    952|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    952|    buffer++; \
  |  |  |  |  |  |  401|    952|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 636, False: 316]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    636|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    636|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    636|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    636|      buffer -= 2; \
  |  |  |  |  |  |  406|    636|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    636|    } \
  |  |  |  |  |  |  408|    952|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 856, False: 7.61k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    856|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    856|    buffer++; \
  |  |  |  |  |  |  401|    856|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 686, False: 170]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    686|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    686|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    686|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    686|      buffer -= 2; \
  |  |  |  |  |  |  406|    686|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    686|    } \
  |  |  |  |  |  |  408|    856|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 810, False: 7.66k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    810|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    810|    buffer++; \
  |  |  |  |  |  |  401|    810|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 727, False: 83]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    727|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    727|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    727|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    727|      buffer -= 2; \
  |  |  |  |  |  |  406|    727|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    727|    } \
  |  |  |  |  |  |  408|    810|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 895, False: 7.57k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    895|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    895|    buffer++; \
  |  |  |  |  |  |  401|    895|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 727, False: 168]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    727|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    727|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    727|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    727|      buffer -= 2; \
  |  |  |  |  |  |  406|    727|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    727|    } \
  |  |  |  |  |  |  408|    895|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  8.47k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  8.47k|  register int c0, c1; \
  |  |  |  |  |  |  393|  8.47k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  8.47k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  8.47k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  8.47k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  8.47k|  bits_left += 8; \
  |  |  |  |  |  |  398|  8.47k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 743, False: 7.72k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    743|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    743|    buffer++; \
  |  |  |  |  |  |  401|    743|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 739, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    739|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    739|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    739|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    739|      buffer -= 2; \
  |  |  |  |  |  |  406|    739|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    739|    } \
  |  |  |  |  |  |  408|    743|  } \
  |  |  |  |  |  |  409|  8.47k|}
  |  |  |  |  ------------------
  |  |  |  |  417|  8.47k|  }
  |  |  ------------------
  |  |  225|   171k|  s = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|   171k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  226|   171k|  s = htbl->lookup[s]; \
  |  |  227|   171k|  nb = s >> HUFF_LOOKAHEAD; \
  |  |  ------------------
  |  |  |  |   25|   171k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  228|   171k|  /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
  |  |  229|   171k|  DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|   171k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  230|   171k|  s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|   171k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  231|   171k|  if (nb > HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   342k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (231:7): [True: 2.99k, False: 168k]
  |  |  ------------------
  |  |  232|  2.99k|    /* Equivalent of jpeg_huff_decode() */ \
  |  |  233|  2.99k|    /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
  |  |  234|  2.99k|    s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
  |  |  235|  24.4k|    while (s > htbl->maxcode[nb]) { \
  |  |  ------------------
  |  |  |  Branch (235:12): [True: 21.4k, False: 2.99k]
  |  |  ------------------
  |  |  236|  21.4k|      s <<= 1; \
  |  |  237|  21.4k|      s |= GET_BITS(1); \
  |  |  ------------------
  |  |  |  |  169|  21.4k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  238|  21.4k|      nb++; \
  |  |  239|  21.4k|    } \
  |  |  240|  2.99k|    if (nb > 16) \
  |  |  ------------------
  |  |  |  Branch (240:9): [True: 2.68k, False: 316]
  |  |  ------------------
  |  |  241|  2.99k|      s = 0; \
  |  |  242|  2.99k|    else \
  |  |  243|  2.99k|      s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
  |  |  244|  2.99k|  }
  ------------------
  684|   171k|    if (s) {
  ------------------
  |  Branch (684:9): [True: 99.0k, False: 71.9k]
  ------------------
  685|  99.0k|      FILL_BIT_BUFFER_FAST
  ------------------
  |  |  415|  99.0k|  if (bits_left <= 16) { \
  |  |  ------------------
  |  |  |  Branch (415:7): [True: 9.97k, False: 89.1k]
  |  |  ------------------
  |  |  416|  9.97k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 237, False: 9.74k]
  |  |  |  |  ------------------
  |  |  |  |  399|    237|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    237|    buffer++; \
  |  |  |  |  401|    237|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 79, False: 158]
  |  |  |  |  ------------------
  |  |  |  |  402|     79|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     79|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     79|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     79|      buffer -= 2; \
  |  |  |  |  406|     79|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     79|    } \
  |  |  |  |  408|    237|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 869, False: 9.10k]
  |  |  |  |  ------------------
  |  |  |  |  399|    869|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    869|    buffer++; \
  |  |  |  |  401|    869|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 79, False: 790]
  |  |  |  |  ------------------
  |  |  |  |  402|     79|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     79|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     79|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     79|      buffer -= 2; \
  |  |  |  |  406|     79|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     79|    } \
  |  |  |  |  408|    869|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 237, False: 9.74k]
  |  |  |  |  ------------------
  |  |  |  |  399|    237|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    237|    buffer++; \
  |  |  |  |  401|    237|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 79, False: 158]
  |  |  |  |  ------------------
  |  |  |  |  402|     79|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     79|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     79|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     79|      buffer -= 2; \
  |  |  |  |  406|     79|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     79|    } \
  |  |  |  |  408|    237|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 237, False: 9.74k]
  |  |  |  |  ------------------
  |  |  |  |  399|    237|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    237|    buffer++; \
  |  |  |  |  401|    237|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 79, False: 158]
  |  |  |  |  ------------------
  |  |  |  |  402|     79|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     79|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     79|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     79|      buffer -= 2; \
  |  |  |  |  406|     79|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     79|    } \
  |  |  |  |  408|    237|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 240, False: 9.73k]
  |  |  |  |  ------------------
  |  |  |  |  399|    240|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    240|    buffer++; \
  |  |  |  |  401|    240|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 82, False: 158]
  |  |  |  |  ------------------
  |  |  |  |  402|     82|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     82|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     82|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     82|      buffer -= 2; \
  |  |  |  |  406|     82|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     82|    } \
  |  |  |  |  408|    240|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  9.97k|#define GET_BYTE { \
  |  |  |  |  392|  9.97k|  register int c0, c1; \
  |  |  |  |  393|  9.97k|  c0 = *buffer++; \
  |  |  |  |  394|  9.97k|  c1 = *buffer; \
  |  |  |  |  395|  9.97k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  9.97k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  9.97k|  bits_left += 8; \
  |  |  |  |  398|  9.97k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 242, False: 9.73k]
  |  |  |  |  ------------------
  |  |  |  |  399|    242|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    242|    buffer++; \
  |  |  |  |  401|    242|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 82, False: 160]
  |  |  |  |  ------------------
  |  |  |  |  402|     82|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     82|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     82|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     82|      buffer -= 2; \
  |  |  |  |  406|     82|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     82|    } \
  |  |  |  |  408|    242|  } \
  |  |  |  |  409|  9.97k|}
  |  |  ------------------
  |  |  417|  9.97k|  }
  ------------------
  686|  99.0k|      r = GET_BITS(s);
  ------------------
  |  |  169|  99.0k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  687|  99.0k|      s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|  99.0k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|  99.0k|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  688|  99.0k|    }
  689|       |
  690|   171k|    if (entropy->dc_needed[blkn]) {
  ------------------
  |  Branch (690:9): [True: 171k, False: 0]
  ------------------
  691|   171k|      int ci = cinfo->MCU_membership[blkn];
  692|       |      /* Refer to the comment in decode_mcu_slow() regarding the supression of
  693|       |       * a UBSan integer overflow error in this line of code.
  694|       |       */
  695|   171k|      s += state.last_dc_val[ci];
  696|   171k|      state.last_dc_val[ci] = s;
  697|   171k|      if (block)
  ------------------
  |  Branch (697:11): [True: 171k, False: 0]
  ------------------
  698|   171k|        (*block)[0] = (JCOEF)s;
  699|   171k|    }
  700|       |
  701|   171k|    if (entropy->ac_needed[blkn] && block) {
  ------------------
  |  Branch (701:9): [True: 171k, False: 0]
  |  Branch (701:37): [True: 171k, False: 0]
  ------------------
  702|       |
  703|  3.84M|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|  3.84M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (703:19): [True: 3.78M, False: 63.4k]
  ------------------
  704|  3.78M|        HUFF_DECODE_FAST(s, l, actbl);
  ------------------
  |  |  224|  3.78M|  FILL_BIT_BUFFER_FAST; \
  |  |  ------------------
  |  |  |  |  415|  3.78M|  if (bits_left <= 16) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (415:7): [True: 128k, False: 3.65M]
  |  |  |  |  ------------------
  |  |  |  |  416|   128k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 5.00k, False: 123k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  5.00k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  5.00k|    buffer++; \
  |  |  |  |  |  |  401|  5.00k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 4.44k, False: 562]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  4.44k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  4.44k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  4.44k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  4.44k|      buffer -= 2; \
  |  |  |  |  |  |  406|  4.44k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  4.44k|    } \
  |  |  |  |  |  |  408|  5.00k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 4.91k, False: 124k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  4.91k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  4.91k|    buffer++; \
  |  |  |  |  |  |  401|  4.91k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 4.57k, False: 336]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  4.57k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  4.57k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  4.57k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  4.57k|      buffer -= 2; \
  |  |  |  |  |  |  406|  4.57k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  4.57k|    } \
  |  |  |  |  |  |  408|  4.91k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 5.33k, False: 123k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  5.33k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  5.33k|    buffer++; \
  |  |  |  |  |  |  401|  5.33k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 4.82k, False: 504]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  4.82k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  4.82k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  4.82k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  4.82k|      buffer -= 2; \
  |  |  |  |  |  |  406|  4.82k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  4.82k|    } \
  |  |  |  |  |  |  408|  5.33k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 5.03k, False: 123k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  5.03k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  5.03k|    buffer++; \
  |  |  |  |  |  |  401|  5.03k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 5.00k, False: 37]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  5.00k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  5.00k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  5.00k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  5.00k|      buffer -= 2; \
  |  |  |  |  |  |  406|  5.00k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  5.00k|    } \
  |  |  |  |  |  |  408|  5.03k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 6.04k, False: 122k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  6.04k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  6.04k|    buffer++; \
  |  |  |  |  |  |  401|  6.04k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 5.24k, False: 797]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  5.24k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  5.24k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  5.24k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  5.24k|      buffer -= 2; \
  |  |  |  |  |  |  406|  5.24k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  5.24k|    } \
  |  |  |  |  |  |  408|  6.04k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   128k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   128k|  register int c0, c1; \
  |  |  |  |  |  |  393|   128k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   128k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   128k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   128k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   128k|  bits_left += 8; \
  |  |  |  |  |  |  398|   128k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 6.56k, False: 122k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  6.56k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  6.56k|    buffer++; \
  |  |  |  |  |  |  401|  6.56k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 5.75k, False: 814]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  5.75k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  5.75k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  5.75k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  5.75k|      buffer -= 2; \
  |  |  |  |  |  |  406|  5.75k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  5.75k|    } \
  |  |  |  |  |  |  408|  6.56k|  } \
  |  |  |  |  |  |  409|   128k|}
  |  |  |  |  ------------------
  |  |  |  |  417|   128k|  }
  |  |  ------------------
  |  |  225|  3.78M|  s = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|  3.78M|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  226|  3.78M|  s = htbl->lookup[s]; \
  |  |  227|  3.78M|  nb = s >> HUFF_LOOKAHEAD; \
  |  |  ------------------
  |  |  |  |   25|  3.78M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  228|  3.78M|  /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
  |  |  229|  3.78M|  DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|  3.78M|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  230|  3.78M|  s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|  3.78M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  231|  3.78M|  if (nb > HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  7.57M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (231:7): [True: 16.2k, False: 3.76M]
  |  |  ------------------
  |  |  232|  16.2k|    /* Equivalent of jpeg_huff_decode() */ \
  |  |  233|  16.2k|    /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
  |  |  234|  16.2k|    s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
  |  |  235|  39.7k|    while (s > htbl->maxcode[nb]) { \
  |  |  ------------------
  |  |  |  Branch (235:12): [True: 23.5k, False: 16.2k]
  |  |  ------------------
  |  |  236|  23.5k|      s <<= 1; \
  |  |  237|  23.5k|      s |= GET_BITS(1); \
  |  |  ------------------
  |  |  |  |  169|  23.5k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  238|  23.5k|      nb++; \
  |  |  239|  23.5k|    } \
  |  |  240|  16.2k|    if (nb > 16) \
  |  |  ------------------
  |  |  |  Branch (240:9): [True: 446, False: 15.7k]
  |  |  ------------------
  |  |  241|  16.2k|      s = 0; \
  |  |  242|  16.2k|    else \
  |  |  243|  16.2k|      s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
  |  |  244|  16.2k|  }
  ------------------
  705|  3.78M|        r = s >> 4;
  706|  3.78M|        s &= 15;
  707|       |
  708|  3.78M|        if (s) {
  ------------------
  |  Branch (708:13): [True: 3.67M, False: 107k]
  ------------------
  709|  3.67M|          k += r;
  710|  3.67M|          FILL_BIT_BUFFER_FAST
  ------------------
  |  |  415|  3.67M|  if (bits_left <= 16) { \
  |  |  ------------------
  |  |  |  Branch (415:7): [True: 297k, False: 3.38M]
  |  |  ------------------
  |  |  416|   297k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 6.31k, False: 291k]
  |  |  |  |  ------------------
  |  |  |  |  399|  6.31k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  6.31k|    buffer++; \
  |  |  |  |  401|  6.31k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 5.06k, False: 1.25k]
  |  |  |  |  ------------------
  |  |  |  |  402|  5.06k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  5.06k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  5.06k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  5.06k|      buffer -= 2; \
  |  |  |  |  406|  5.06k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  5.06k|    } \
  |  |  |  |  408|  6.31k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 6.05k, False: 291k]
  |  |  |  |  ------------------
  |  |  |  |  399|  6.05k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  6.05k|    buffer++; \
  |  |  |  |  401|  6.05k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 5.86k, False: 191]
  |  |  |  |  ------------------
  |  |  |  |  402|  5.86k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  5.86k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  5.86k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  5.86k|      buffer -= 2; \
  |  |  |  |  406|  5.86k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  5.86k|    } \
  |  |  |  |  408|  6.05k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 6.42k, False: 291k]
  |  |  |  |  ------------------
  |  |  |  |  399|  6.42k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  6.42k|    buffer++; \
  |  |  |  |  401|  6.42k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 5.86k, False: 554]
  |  |  |  |  ------------------
  |  |  |  |  402|  5.86k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  5.86k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  5.86k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  5.86k|      buffer -= 2; \
  |  |  |  |  406|  5.86k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  5.86k|    } \
  |  |  |  |  408|  6.42k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 7.23k, False: 290k]
  |  |  |  |  ------------------
  |  |  |  |  399|  7.23k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  7.23k|    buffer++; \
  |  |  |  |  401|  7.23k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 6.67k, False: 569]
  |  |  |  |  ------------------
  |  |  |  |  402|  6.67k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  6.67k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  6.67k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  6.67k|      buffer -= 2; \
  |  |  |  |  406|  6.67k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  6.67k|    } \
  |  |  |  |  408|  7.23k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 8.16k, False: 289k]
  |  |  |  |  ------------------
  |  |  |  |  399|  8.16k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  8.16k|    buffer++; \
  |  |  |  |  401|  8.16k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 6.97k, False: 1.18k]
  |  |  |  |  ------------------
  |  |  |  |  402|  6.97k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  6.97k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  6.97k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  6.97k|      buffer -= 2; \
  |  |  |  |  406|  6.97k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  6.97k|    } \
  |  |  |  |  408|  8.16k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|   297k|#define GET_BYTE { \
  |  |  |  |  392|   297k|  register int c0, c1; \
  |  |  |  |  393|   297k|  c0 = *buffer++; \
  |  |  |  |  394|   297k|  c1 = *buffer; \
  |  |  |  |  395|   297k|  /* Pre-execute most common case */ \
  |  |  |  |  396|   297k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|   297k|  bits_left += 8; \
  |  |  |  |  398|   297k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 8.89k, False: 288k]
  |  |  |  |  ------------------
  |  |  |  |  399|  8.89k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  8.89k|    buffer++; \
  |  |  |  |  401|  8.89k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 7.15k, False: 1.73k]
  |  |  |  |  ------------------
  |  |  |  |  402|  7.15k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  7.15k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  7.15k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  7.15k|      buffer -= 2; \
  |  |  |  |  406|  7.15k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  7.15k|    } \
  |  |  |  |  408|  8.89k|  } \
  |  |  |  |  409|   297k|}
  |  |  ------------------
  |  |  417|   297k|  }
  ------------------
  711|  3.67M|          r = GET_BITS(s);
  ------------------
  |  |  169|  3.67M|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  712|  3.67M|          s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|  3.67M|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|  3.67M|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  713|  3.67M|          (*block)[jpeg_natural_order[k]] = (JCOEF)s;
  714|  3.67M|        } else {
  715|   107k|          if (r != 15) break;
  ------------------
  |  Branch (715:15): [True: 107k, False: 2]
  ------------------
  716|      2|          k += 15;
  717|      2|        }
  718|  3.78M|      }
  719|       |
  720|   171k|    } else {
  721|       |
  722|      0|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (722:19): [True: 0, False: 0]
  ------------------
  723|      0|        HUFF_DECODE_FAST(s, l, actbl);
  ------------------
  |  |  224|      0|  FILL_BIT_BUFFER_FAST; \
  |  |  ------------------
  |  |  |  |  415|      0|  if (bits_left <= 16) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (415:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  416|      0|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|      0|    } \
  |  |  |  |  |  |  408|      0|  } \
  |  |  |  |  |  |  409|      0|}
  |  |  |  |  ------------------
  |  |  |  |  417|      0|  }
  |  |  ------------------
  |  |  225|      0|  s = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|      0|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  226|      0|  s = htbl->lookup[s]; \
  |  |  227|      0|  nb = s >> HUFF_LOOKAHEAD; \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  228|      0|  /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
  |  |  229|      0|  DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|      0|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  230|      0|  s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  231|      0|  if (nb > HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (231:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  232|      0|    /* Equivalent of jpeg_huff_decode() */ \
  |  |  233|      0|    /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
  |  |  234|      0|    s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
  |  |  235|      0|    while (s > htbl->maxcode[nb]) { \
  |  |  ------------------
  |  |  |  Branch (235:12): [True: 0, False: 0]
  |  |  ------------------
  |  |  236|      0|      s <<= 1; \
  |  |  237|      0|      s |= GET_BITS(1); \
  |  |  ------------------
  |  |  |  |  169|      0|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  238|      0|      nb++; \
  |  |  239|      0|    } \
  |  |  240|      0|    if (nb > 16) \
  |  |  ------------------
  |  |  |  Branch (240:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  241|      0|      s = 0; \
  |  |  242|      0|    else \
  |  |  243|      0|      s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
  |  |  244|      0|  }
  ------------------
  724|      0|        r = s >> 4;
  725|      0|        s &= 15;
  726|       |
  727|      0|        if (s) {
  ------------------
  |  Branch (727:13): [True: 0, False: 0]
  ------------------
  728|      0|          k += r;
  729|      0|          FILL_BIT_BUFFER_FAST
  ------------------
  |  |  415|      0|  if (bits_left <= 16) { \
  |  |  ------------------
  |  |  |  Branch (415:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  416|      0|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|      0|#define GET_BYTE { \
  |  |  |  |  392|      0|  register int c0, c1; \
  |  |  |  |  393|      0|  c0 = *buffer++; \
  |  |  |  |  394|      0|  c1 = *buffer; \
  |  |  |  |  395|      0|  /* Pre-execute most common case */ \
  |  |  |  |  396|      0|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|      0|  bits_left += 8; \
  |  |  |  |  398|      0|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  399|      0|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|      0|    buffer++; \
  |  |  |  |  401|      0|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  402|      0|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|      0|      cinfo->unread_marker = c1; \
  |  |  |  |  404|      0|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|      0|      buffer -= 2; \
  |  |  |  |  406|      0|      get_buffer &= ~0xFF; \
  |  |  |  |  407|      0|    } \
  |  |  |  |  408|      0|  } \
  |  |  |  |  409|      0|}
  |  |  ------------------
  |  |  417|      0|  }
  ------------------
  730|      0|          DROP_BITS(s);
  ------------------
  |  |  175|      0|  (bits_left -= (nbits))
  ------------------
  731|      0|        } else {
  732|      0|          if (r != 15) break;
  ------------------
  |  Branch (732:15): [True: 0, False: 0]
  ------------------
  733|      0|          k += 15;
  734|      0|        }
  735|      0|      }
  736|      0|    }
  737|   171k|  }
  738|       |
  739|   171k|  if (cinfo->unread_marker != 0) {
  ------------------
  |  Branch (739:7): [True: 4.92k, False: 166k]
  ------------------
  740|  4.92k|    cinfo->unread_marker = 0;
  741|  4.92k|    return FALSE;
  ------------------
  |  |  207|  4.92k|#define FALSE   0               /* values of boolean */
  ------------------
  742|  4.92k|  }
  743|       |
  744|   166k|  br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
  745|   166k|  br_state.next_input_byte = buffer;
  746|   166k|  BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  137|   166k|  cinfop->src->next_input_byte = br_state.next_input_byte; \
  |  |  138|   166k|  cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
  |  |  139|   166k|  permstate.get_buffer = get_buffer; \
  |  |  140|   166k|  permstate.bits_left = bits_left
  ------------------
  747|   166k|  entropy->saved = state;
  748|   166k|  return TRUE;
  ------------------
  |  |  210|   166k|#define TRUE    1
  ------------------
  749|   171k|}
jdhuff.c:decode_mcu_slow:
  553|  82.1k|{
  554|  82.1k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  555|  82.1k|  BITREAD_STATE_VARS;
  ------------------
  |  |  125|  82.1k|  register bit_buf_type get_buffer; \
  |  |  126|  82.1k|  register int bits_left; \
  |  |  127|  82.1k|  bitread_working_state br_state
  ------------------
  556|  82.1k|  int blkn;
  557|  82.1k|  savable_state state;
  558|       |  /* Outer loop handles each block in the MCU */
  559|       |
  560|       |  /* Load up working state */
  561|  82.1k|  BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  130|  82.1k|  br_state.cinfo = cinfop; \
  |  |  131|  82.1k|  br_state.next_input_byte = cinfop->src->next_input_byte; \
  |  |  132|  82.1k|  br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
  |  |  133|  82.1k|  get_buffer = permstate.get_buffer; \
  |  |  134|  82.1k|  bits_left = permstate.bits_left;
  ------------------
  562|  82.1k|  state = entropy->saved;
  563|       |
  564|   163k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (564:18): [True: 82.6k, False: 81.1k]
  ------------------
  565|  82.6k|    JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
  ------------------
  |  Branch (565:23): [True: 82.6k, False: 0]
  ------------------
  566|  82.6k|    d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
  567|  82.6k|    d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
  568|  82.6k|    register int s, k, r;
  569|       |
  570|       |    /* Decode a single block's worth of coefficients */
  571|       |
  572|       |    /* Section F.2.2.1: decode the DC coefficient difference */
  573|  82.6k|    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
  ------------------
  |  |  200|  82.6k|#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
  |  |  201|  82.6k|  register int nb, look; \
  |  |  202|  82.6k|  if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  82.6k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (202:7): [True: 40.3k, False: 42.3k]
  |  |  ------------------
  |  |  203|  40.3k|    if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
  |  |  ------------------
  |  |  |  Branch (203:9): [True: 0, False: 40.3k]
  |  |  ------------------
  |  |  204|  40.3k|      { failaction; } \
  |  |  205|  40.3k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  206|  40.3k|    if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  40.3k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (206:9): [True: 204, False: 40.1k]
  |  |  ------------------
  |  |  207|    204|      nb = 1;  goto slowlabel; \
  |  |  208|    204|    } \
  |  |  209|  40.3k|  } \
  |  |  210|  82.6k|  look = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|  82.4k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  211|  82.4k|  if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  82.4k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |                 if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  82.4k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (211:7): [True: 79.8k, False: 2.60k]
  |  |  ------------------
  |  |  212|  79.8k|    DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|  79.8k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  213|  79.8k|    result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|  79.8k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  214|  79.8k|  } else { \
  |  |  215|  1.79k|slowlabel: \
  |  |  216|  1.79k|    if ((result = \
  |  |  ------------------
  |  |  |  Branch (216:9): [True: 0, False: 1.79k]
  |  |  ------------------
  |  |  217|  1.79k|         jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
  |  |  218|  1.79k|      { failaction; } \
  |  |  219|  1.79k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  220|  1.79k|  } \
  |  |  221|  82.4k|}
  ------------------
  574|  81.6k|    if (s) {
  ------------------
  |  Branch (574:9): [True: 46.6k, False: 35.0k]
  ------------------
  575|  46.6k|      CHECK_BIT_BUFFER(br_state, s, return FALSE);
  ------------------
  |  |  160|  46.6k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|  46.6k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 336, False: 46.3k]
  |  |  ------------------
  |  |  162|    336|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 336]
  |  |  ------------------
  |  |  163|    336|      { action; } \
  |  |  164|    336|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|    336|  } \
  |  |  166|  46.6k|}
  ------------------
  576|  46.6k|      r = GET_BITS(s);
  ------------------
  |  |  169|  46.6k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  577|  46.6k|      s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|  46.6k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|  46.6k|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  578|  46.6k|    }
  579|       |
  580|  81.6k|    if (entropy->dc_needed[blkn]) {
  ------------------
  |  Branch (580:9): [True: 81.6k, False: 0]
  ------------------
  581|       |      /* Convert DC difference to actual value, update last_dc_val */
  582|  81.6k|      int ci = cinfo->MCU_membership[blkn];
  583|       |      /* Certain malformed JPEG images produce repeated DC coefficient
  584|       |       * differences of 2047 or -2047, which causes state.last_dc_val[ci] to
  585|       |       * grow until it overflows or underflows a 32-bit signed integer.  This
  586|       |       * behavior is, to the best of our understanding, innocuous, and it is
  587|       |       * unclear how to work around it without potentially affecting
  588|       |       * performance.  Thus, we (hopefully temporarily) suppress UBSan integer
  589|       |       * overflow errors for this function and decode_mcu_fast().
  590|       |       */
  591|  81.6k|      s += state.last_dc_val[ci];
  592|  81.6k|      state.last_dc_val[ci] = s;
  593|  81.6k|      if (block) {
  ------------------
  |  Branch (593:11): [True: 81.6k, False: 0]
  ------------------
  594|       |        /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
  595|  81.6k|        (*block)[0] = (JCOEF)s;
  596|  81.6k|      }
  597|  81.6k|    }
  598|       |
  599|  81.6k|    if (entropy->ac_needed[blkn] && block) {
  ------------------
  |  Branch (599:9): [True: 81.6k, False: 0]
  |  Branch (599:37): [True: 81.6k, False: 0]
  ------------------
  600|       |
  601|       |      /* Section F.2.2.2: decode the AC coefficients */
  602|       |      /* Since zeroes are skipped, output area must be cleared beforehand */
  603|  2.94M|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|  2.94M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (603:19): [True: 2.88M, False: 62.7k]
  ------------------
  604|  2.88M|        HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
  ------------------
  |  |  200|  2.88M|#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
  |  |  201|  2.88M|  register int nb, look; \
  |  |  202|  2.88M|  if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  2.88M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (202:7): [True: 253k, False: 2.62M]
  |  |  ------------------
  |  |  203|   253k|    if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
  |  |  ------------------
  |  |  |  Branch (203:9): [True: 0, False: 253k]
  |  |  ------------------
  |  |  204|   253k|      { failaction; } \
  |  |  205|   253k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  206|   253k|    if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   253k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (206:9): [True: 97.2k, False: 155k]
  |  |  ------------------
  |  |  207|  97.2k|      nb = 1;  goto slowlabel; \
  |  |  208|  97.2k|    } \
  |  |  209|   253k|  } \
  |  |  210|  2.88M|  look = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|  2.78M|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  211|  2.78M|  if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  2.78M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |                 if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  2.78M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (211:7): [True: 2.76M, False: 14.5k]
  |  |  ------------------
  |  |  212|  2.76M|    DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|  2.76M|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  213|  2.76M|    result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|  2.76M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  214|  2.76M|  } else { \
  |  |  215|   111k|slowlabel: \
  |  |  216|   111k|    if ((result = \
  |  |  ------------------
  |  |  |  Branch (216:9): [True: 0, False: 111k]
  |  |  ------------------
  |  |  217|   111k|         jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
  |  |  218|   111k|      { failaction; } \
  |  |  219|   111k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  220|   111k|  } \
  |  |  221|  2.78M|}
  ------------------
  605|       |
  606|  2.88M|        r = s >> 4;
  607|  2.88M|        s &= 15;
  608|       |
  609|  2.88M|        if (s) {
  ------------------
  |  Branch (609:13): [True: 2.86M, False: 18.8k]
  ------------------
  610|  2.86M|          k += r;
  611|  2.86M|          CHECK_BIT_BUFFER(br_state, s, return FALSE);
  ------------------
  |  |  160|  2.86M|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|  2.86M|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 30.7k, False: 2.83M]
  |  |  ------------------
  |  |  162|  30.7k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 30.7k]
  |  |  ------------------
  |  |  163|  30.7k|      { action; } \
  |  |  164|  30.7k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  30.7k|  } \
  |  |  166|  2.86M|}
  ------------------
  612|  2.86M|          r = GET_BITS(s);
  ------------------
  |  |  169|  2.86M|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  613|  2.86M|          s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|  2.86M|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|  2.86M|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  614|       |          /* Output coefficient in natural (dezigzagged) order.
  615|       |           * Note: the extra entries in jpeg_natural_order[] will save us
  616|       |           * if k >= DCTSIZE2, which could happen if the data is corrupted.
  617|       |           */
  618|  2.86M|          (*block)[jpeg_natural_order[k]] = (JCOEF)s;
  619|  2.86M|        } else {
  620|  18.8k|          if (r != 15)
  ------------------
  |  Branch (620:15): [True: 18.8k, False: 0]
  ------------------
  621|  18.8k|            break;
  622|      0|          k += 15;
  623|      0|        }
  624|  2.88M|      }
  625|       |
  626|  81.6k|    } else {
  627|       |
  628|       |      /* Section F.2.2.2: decode the AC coefficients */
  629|       |      /* In this path we just discard the values */
  630|      0|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (630:19): [True: 0, False: 0]
  ------------------
  631|      0|        HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
  ------------------
  |  |  200|      0|#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
  |  |  201|      0|  register int nb, look; \
  |  |  202|      0|  if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (202:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  203|      0|    if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
  |  |  ------------------
  |  |  |  Branch (203:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  204|      0|      { failaction; } \
  |  |  205|      0|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  206|      0|    if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (206:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  207|      0|      nb = 1;  goto slowlabel; \
  |  |  208|      0|    } \
  |  |  209|      0|  } \
  |  |  210|      0|  look = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|      0|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  211|      0|  if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |                 if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (211:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  212|      0|    DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|      0|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  213|      0|    result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|      0|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  214|      0|  } else { \
  |  |  215|      0|slowlabel: \
  |  |  216|      0|    if ((result = \
  |  |  ------------------
  |  |  |  Branch (216:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  217|      0|         jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
  |  |  218|      0|      { failaction; } \
  |  |  219|      0|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  220|      0|  } \
  |  |  221|      0|}
  ------------------
  632|       |
  633|      0|        r = s >> 4;
  634|      0|        s &= 15;
  635|       |
  636|      0|        if (s) {
  ------------------
  |  Branch (636:13): [True: 0, False: 0]
  ------------------
  637|      0|          k += r;
  638|      0|          CHECK_BIT_BUFFER(br_state, s, return FALSE);
  ------------------
  |  |  160|      0|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|      0|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  162|      0|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  163|      0|      { action; } \
  |  |  164|      0|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|      0|  } \
  |  |  166|      0|}
  ------------------
  639|      0|          DROP_BITS(s);
  ------------------
  |  |  175|      0|  (bits_left -= (nbits))
  ------------------
  640|      0|        } else {
  641|      0|          if (r != 15)
  ------------------
  |  Branch (641:15): [True: 0, False: 0]
  ------------------
  642|      0|            break;
  643|      0|          k += 15;
  644|      0|        }
  645|      0|      }
  646|      0|    }
  647|  81.6k|  }
  648|       |
  649|       |  /* Completed MCU, so update state */
  650|  81.1k|  BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  137|  81.1k|  cinfop->src->next_input_byte = br_state.next_input_byte; \
  |  |  138|  81.1k|  cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
  |  |  139|  81.1k|  permstate.get_buffer = get_buffer; \
  |  |  140|  81.1k|  permstate.bits_left = bits_left
  ------------------
  651|  81.1k|  entropy->saved = state;
  652|  81.1k|  return TRUE;
  ------------------
  |  |  210|  81.1k|#define TRUE    1
  ------------------
  653|  82.1k|}

jinit_input_controller:
  405|  23.3k|{
  406|  23.3k|  my_inputctl_ptr inputctl;
  407|       |
  408|       |  /* Create subobject in permanent pool */
  409|  23.3k|  inputctl = (my_inputctl_ptr)
  410|  23.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  23.3k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  411|  23.3k|                                sizeof(my_input_controller));
  412|  23.3k|  cinfo->inputctl = (struct jpeg_input_controller *)inputctl;
  413|       |  /* Initialize method pointers */
  414|  23.3k|  inputctl->pub.consume_input = consume_markers;
  415|  23.3k|  inputctl->pub.reset_input_controller = reset_input_controller;
  416|  23.3k|  inputctl->pub.start_input_pass = start_input_pass;
  417|  23.3k|  inputctl->pub.finish_input_pass = finish_input_pass;
  418|       |  /* Initialize state: can't use reset_input_controller since we don't
  419|       |   * want to try to reset other modules yet.
  420|       |   */
  421|  23.3k|  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
  ------------------
  |  |  207|  23.3k|#define FALSE   0               /* values of boolean */
  ------------------
  422|  23.3k|  inputctl->pub.eoi_reached = FALSE;
  ------------------
  |  |  207|  23.3k|#define FALSE   0               /* values of boolean */
  ------------------
  423|  23.3k|  inputctl->inheaders = TRUE;
  ------------------
  |  |  210|  23.3k|#define TRUE    1
  ------------------
  424|  23.3k|}
jdinput.c:consume_markers:
  332|  60.6k|{
  333|  60.6k|  my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
  334|  60.6k|  int val;
  335|       |
  336|  60.6k|  if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
  ------------------
  |  Branch (336:7): [True: 0, False: 60.6k]
  ------------------
  337|      0|    return JPEG_REACHED_EOI;
  ------------------
  |  | 1112|      0|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  338|       |
  339|  60.6k|  val = (*cinfo->marker->read_markers) (cinfo);
  340|       |
  341|  60.6k|  switch (val) {
  ------------------
  |  Branch (341:11): [True: 26.5k, False: 34.1k]
  ------------------
  342|  22.8k|  case JPEG_REACHED_SOS:        /* Found SOS */
  ------------------
  |  | 1111|  22.8k|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (342:3): [True: 22.8k, False: 37.7k]
  ------------------
  343|  22.8k|    if (inputctl->inheaders) {  /* 1st SOS */
  ------------------
  |  Branch (343:9): [True: 22.8k, False: 0]
  ------------------
  344|  22.8k|      initial_setup(cinfo);
  345|  22.8k|      inputctl->inheaders = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  346|       |      /* Note: start_input_pass must be called by jdmaster.c
  347|       |       * before any more input can be consumed.  jdapimin.c is
  348|       |       * responsible for enforcing this sequencing.
  349|       |       */
  350|  22.8k|    } else {                    /* 2nd or later SOS marker */
  351|      0|      if (!inputctl->pub.has_multiple_scans)
  ------------------
  |  Branch (351:11): [True: 0, False: 0]
  ------------------
  352|      0|        ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  353|      0|      start_input_pass(cinfo);
  354|      0|    }
  355|  22.8k|    break;
  356|  3.61k|  case JPEG_REACHED_EOI:        /* Found EOI */
  ------------------
  |  | 1112|  3.61k|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  |  Branch (356:3): [True: 3.61k, False: 57.0k]
  ------------------
  357|  3.61k|    inputctl->pub.eoi_reached = TRUE;
  ------------------
  |  |  210|  3.61k|#define TRUE    1
  ------------------
  358|  3.61k|    if (inputctl->inheaders) {  /* Tables-only datastream, apparently */
  ------------------
  |  Branch (358:9): [True: 3.61k, False: 0]
  ------------------
  359|  3.61k|      if (cinfo->marker->saw_SOF)
  ------------------
  |  Branch (359:11): [True: 36, False: 3.58k]
  ------------------
  360|     36|        ERREXIT(cinfo, JERR_SOF_NO_SOS);
  ------------------
  |  |  240|     36|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     36|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  361|  3.61k|    } else {
  362|       |      /* Prevent infinite loop in coef ctlr's decompress_data routine
  363|       |       * if user set output_scan_number larger than number of scans.
  364|       |       */
  365|      0|      if (cinfo->output_scan_number > cinfo->input_scan_number)
  ------------------
  |  Branch (365:11): [True: 0, False: 0]
  ------------------
  366|      0|        cinfo->output_scan_number = cinfo->input_scan_number;
  367|      0|    }
  368|  3.61k|    break;
  369|      0|  case JPEG_SUSPENDED:
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  |  Branch (369:3): [True: 0, False: 60.6k]
  ------------------
  370|      0|    break;
  371|  60.6k|  }
  372|       |
  373|  26.4k|  return val;
  374|  60.6k|}
jdinput.c:initial_setup:
   49|  22.8k|{
   50|  22.8k|  int ci;
   51|  22.8k|  jpeg_component_info *compptr;
   52|  22.8k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (52:19): [True: 16, False: 22.8k]
  ------------------
   53|       |
   54|       |  /* Make sure image isn't bigger than I can handle */
   55|  22.8k|  if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  45.7k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (55:7): [True: 0, False: 22.8k]
  ------------------
   56|  22.8k|      (long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  22.8k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (56:7): [True: 4, False: 22.8k]
  ------------------
   57|      4|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      4|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   58|       |
   59|       |  /* Lossy JPEG images must have 8 or 12 bits per sample.  Lossless JPEG images
   60|       |   * can have 2 to 16 bits per sample.
   61|       |   */
   62|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
   63|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (63:7): [True: 16, False: 22.8k]
  ------------------
   64|     16|    if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
  ------------------
  |  Branch (64:9): [True: 0, False: 16]
  |  Branch (64:38): [True: 0, False: 16]
  ------------------
   65|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   66|     16|  } else
   67|  22.8k|#endif
   68|  22.8k|  {
   69|  22.8k|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (69:9): [True: 24, False: 22.8k]
  |  Branch (69:39): [True: 0, False: 24]
  ------------------
   70|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   71|  22.8k|  }
   72|       |
   73|       |  /* Check that number of components won't exceed internal array sizes */
   74|  22.8k|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|  22.8k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (74:7): [True: 4, False: 22.8k]
  ------------------
   75|      4|    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
  ------------------
  |  |  247|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  248|      4|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|      4|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   76|  22.8k|             MAX_COMPONENTS);
   77|       |
   78|       |  /* Compute maximum sampling factors; check factor validity */
   79|  22.8k|  cinfo->max_h_samp_factor = 1;
   80|  22.8k|  cinfo->max_v_samp_factor = 1;
   81|  45.9k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (81:44): [True: 23.0k, False: 22.8k]
  ------------------
   82|  23.0k|       ci++, compptr++) {
   83|  23.0k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (83:9): [True: 0, False: 23.0k]
  ------------------
   84|  23.0k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|  46.0k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (84:9): [True: 3, False: 23.0k]
  ------------------
   85|  23.0k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (85:9): [True: 0, False: 23.0k]
  ------------------
   86|  23.0k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  23.0k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (86:9): [True: 2, False: 23.0k]
  ------------------
   87|      5|      ERREXIT(cinfo, JERR_BAD_SAMPLING);
  ------------------
  |  |  240|      5|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      5|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   88|  23.0k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  23.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 86, False: 22.9k]
  |  |  ------------------
  ------------------
   89|  23.0k|                                   compptr->h_samp_factor);
   90|  23.0k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  23.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 82, False: 22.9k]
  |  |  ------------------
  ------------------
   91|  23.0k|                                   compptr->v_samp_factor);
   92|  23.0k|  }
   93|       |
   94|       |#if JPEG_LIB_VERSION >= 80
   95|       |  cinfo->block_size = data_unit;
   96|       |  cinfo->natural_order = jpeg_natural_order;
   97|       |  cinfo->lim_Se = DCTSIZE2 - 1;
   98|       |#endif
   99|       |
  100|       |  /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE in lossy
  101|       |   * mode.  In the full decompressor, this will be overridden by jdmaster.c;
  102|       |   * but in the transcoder, jdmaster.c is not used, so we must do it here.
  103|       |   */
  104|       |#if JPEG_LIB_VERSION >= 70
  105|       |  cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = data_unit;
  106|       |#else
  107|  22.8k|  cinfo->min_DCT_scaled_size = data_unit;
  108|  22.8k|#endif
  109|       |
  110|       |  /* Compute dimensions of components */
  111|  45.9k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (111:44): [True: 23.0k, False: 22.8k]
  ------------------
  112|  23.0k|       ci++, compptr++) {
  113|       |#if JPEG_LIB_VERSION >= 70
  114|       |    compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
  115|       |#else
  116|  23.0k|    compptr->DCT_scaled_size = data_unit;
  117|  23.0k|#endif
  118|       |    /* Size in data units */
  119|  23.0k|    compptr->width_in_blocks = (JDIMENSION)
  120|  23.0k|      jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
  121|  23.0k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  122|  23.0k|    compptr->height_in_blocks = (JDIMENSION)
  123|  23.0k|      jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
  124|  23.0k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  125|       |    /* Set the first and last MCU columns to decompress from multi-scan images.
  126|       |     * By default, decompress all of the MCU columns.
  127|       |     */
  128|  23.0k|    cinfo->master->first_MCU_col[ci] = 0;
  129|  23.0k|    cinfo->master->last_MCU_col[ci] = compptr->width_in_blocks - 1;
  130|       |    /* downsampled_width and downsampled_height will also be overridden by
  131|       |     * jdmaster.c if we are doing full decompression.  The transcoder library
  132|       |     * doesn't use these values, but the calling application might.
  133|       |     */
  134|       |    /* Size in samples */
  135|  23.0k|    compptr->downsampled_width = (JDIMENSION)
  136|  23.0k|      jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
  137|  23.0k|                    (long)cinfo->max_h_samp_factor);
  138|  23.0k|    compptr->downsampled_height = (JDIMENSION)
  139|  23.0k|      jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
  140|  23.0k|                    (long)cinfo->max_v_samp_factor);
  141|       |    /* Mark component needed, until color conversion says otherwise */
  142|  23.0k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  23.0k|#define TRUE    1
  ------------------
  143|       |    /* Mark no quantization table yet saved for component */
  144|  23.0k|    compptr->quant_table = NULL;
  145|  23.0k|  }
  146|       |
  147|       |  /* Compute number of fully interleaved MCU rows. */
  148|  22.8k|  cinfo->total_iMCU_rows = (JDIMENSION)
  149|  22.8k|    jdiv_round_up((long)cinfo->image_height,
  150|  22.8k|                  (long)(cinfo->max_v_samp_factor * data_unit));
  151|       |
  152|       |  /* Decide whether file contains multiple scans */
  153|  22.8k|  if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
  ------------------
  |  Branch (153:7): [True: 50, False: 22.8k]
  |  Branch (153:55): [True: 0, False: 22.8k]
  ------------------
  154|     37|    cinfo->inputctl->has_multiple_scans = TRUE;
  ------------------
  |  |  210|     37|#define TRUE    1
  ------------------
  155|  22.8k|  else
  156|  22.8k|    cinfo->inputctl->has_multiple_scans = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  157|  22.8k|}
jdinput.c:reset_input_controller:
  383|  60.6k|{
  384|  60.6k|  my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
  385|       |
  386|  60.6k|  inputctl->pub.consume_input = consume_markers;
  387|  60.6k|  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
  ------------------
  |  |  207|  60.6k|#define FALSE   0               /* values of boolean */
  ------------------
  388|  60.6k|  inputctl->pub.eoi_reached = FALSE;
  ------------------
  |  |  207|  60.6k|#define FALSE   0               /* values of boolean */
  ------------------
  389|  60.6k|  inputctl->inheaders = TRUE;
  ------------------
  |  |  210|  60.6k|#define TRUE    1
  ------------------
  390|       |  /* Reset other modules */
  391|  60.6k|  (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
  392|  60.6k|  (*cinfo->marker->reset_marker_reader) (cinfo);
  393|       |  /* Reset progression state -- would be cleaner if entropy decoder did this */
  394|       |  cinfo->coef_bits = NULL;
  395|  60.6k|}
jdinput.c:start_input_pass:
  297|  22.8k|{
  298|  22.8k|  per_scan_setup(cinfo);
  299|  22.8k|  if (!cinfo->master->lossless)
  ------------------
  |  Branch (299:7): [True: 22.8k, False: 12]
  ------------------
  300|  22.8k|    latch_quant_tables(cinfo);
  301|  22.8k|  (*cinfo->entropy->start_pass) (cinfo);
  302|  22.8k|  (*cinfo->coef->start_input_pass) (cinfo);
  303|  22.8k|  cinfo->inputctl->consume_input = cinfo->coef->consume_data;
  304|  22.8k|}
jdinput.c:per_scan_setup:
  164|  22.8k|{
  165|  22.8k|  int ci, mcublks, tmp;
  166|  22.8k|  jpeg_component_info *compptr;
  167|  22.8k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (167:19): [True: 9, False: 22.8k]
  ------------------
  168|       |
  169|  22.8k|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (169:7): [True: 22.8k, False: 40]
  ------------------
  170|       |
  171|       |    /* Noninterleaved (single-component) scan */
  172|  22.8k|    compptr = cinfo->cur_comp_info[0];
  173|       |
  174|       |    /* Overall image size in MCUs */
  175|  22.8k|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  176|  22.8k|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  177|       |
  178|       |    /* For noninterleaved scan, always one data unit per MCU */
  179|  22.8k|    compptr->MCU_width = 1;
  180|  22.8k|    compptr->MCU_height = 1;
  181|  22.8k|    compptr->MCU_blocks = 1;
  182|  22.8k|    compptr->MCU_sample_width = compptr->_DCT_scaled_size;
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  183|  22.8k|    compptr->last_col_width = 1;
  184|       |    /* For noninterleaved scans, it is convenient to define last_row_height
  185|       |     * as the number of data unit rows present in the last iMCU row.
  186|       |     */
  187|  22.8k|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  188|  22.8k|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (188:9): [True: 22.8k, False: 8]
  ------------------
  189|  22.8k|    compptr->last_row_height = tmp;
  190|       |
  191|       |    /* Prepare array describing MCU composition */
  192|  22.8k|    cinfo->blocks_in_MCU = 1;
  193|  22.8k|    cinfo->MCU_membership[0] = 0;
  194|       |
  195|  22.8k|  } else {
  196|       |
  197|       |    /* Interleaved (multi-component) scan */
  198|     40|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|     40|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (198:9): [True: 0, False: 40]
  |  Branch (198:38): [True: 0, False: 40]
  ------------------
  199|      0|      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
  ------------------
  |  |  247|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  248|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|      0|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  200|     40|               MAX_COMPS_IN_SCAN);
  201|       |
  202|       |    /* Overall image size in MCUs */
  203|     40|    cinfo->MCUs_per_row = (JDIMENSION)
  204|     40|      jdiv_round_up((long)cinfo->image_width,
  205|     40|                    (long)(cinfo->max_h_samp_factor * data_unit));
  206|     40|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  207|     40|      jdiv_round_up((long)cinfo->image_height,
  208|     40|                    (long)(cinfo->max_v_samp_factor * data_unit));
  209|       |
  210|     40|    cinfo->blocks_in_MCU = 0;
  211|       |
  212|    154|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (212:18): [True: 114, False: 40]
  ------------------
  213|    114|      compptr = cinfo->cur_comp_info[ci];
  214|       |      /* Sampling factors give # of data units of component in each MCU */
  215|    114|      compptr->MCU_width = compptr->h_samp_factor;
  216|    114|      compptr->MCU_height = compptr->v_samp_factor;
  217|    114|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  218|    114|      compptr->MCU_sample_width = compptr->MCU_width *
  219|    114|                                  compptr->_DCT_scaled_size;
  ------------------
  |  |   24|    114|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  220|       |      /* Figure number of non-dummy data units in last MCU column & row */
  221|    114|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  222|    114|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (222:11): [True: 90, False: 24]
  ------------------
  223|    114|      compptr->last_col_width = tmp;
  224|    114|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  225|    114|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (225:11): [True: 102, False: 12]
  ------------------
  226|    114|      compptr->last_row_height = tmp;
  227|       |      /* Prepare array describing MCU composition */
  228|    114|      mcublks = compptr->MCU_blocks;
  229|    114|      if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   82|    114|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  |  Branch (229:11): [True: 3, False: 111]
  ------------------
  230|      3|        ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
  ------------------
  |  |  240|      3|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      3|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  231|    336|      while (mcublks-- > 0) {
  ------------------
  |  Branch (231:14): [True: 222, False: 114]
  ------------------
  232|    222|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  233|    222|      }
  234|    114|    }
  235|       |
  236|     40|  }
  237|  22.8k|}
jdinput.c:latch_quant_tables:
  263|  22.8k|{
  264|  22.8k|  int ci, qtblno;
  265|  22.8k|  jpeg_component_info *compptr;
  266|  22.8k|  JQUANT_TBL *qtbl;
  267|       |
  268|  45.7k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (268:16): [True: 22.9k, False: 22.8k]
  ------------------
  269|  22.9k|    compptr = cinfo->cur_comp_info[ci];
  270|       |    /* No work if we already saved Q-table for this component */
  271|  22.9k|    if (compptr->quant_table != NULL)
  ------------------
  |  Branch (271:9): [True: 0, False: 22.9k]
  ------------------
  272|      0|      continue;
  273|       |    /* Make sure specified quantization table is present */
  274|  22.9k|    qtblno = compptr->quant_tbl_no;
  275|  22.9k|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|  45.8k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (275:9): [True: 0, False: 22.9k]
  |  Branch (275:23): [True: 2, False: 22.9k]
  ------------------
  276|  22.9k|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (276:9): [True: 3, False: 22.9k]
  ------------------
  277|      5|      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
  ------------------
  |  |  243|      5|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      5|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      5|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  278|       |    /* OK, save away the quantization table */
  279|  22.9k|    qtbl = (JQUANT_TBL *)
  280|  22.9k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  281|  22.9k|                                  sizeof(JQUANT_TBL));
  282|  22.9k|    memcpy(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
  283|  22.9k|    compptr->quant_table = qtbl;
  284|  22.9k|  }
  285|  22.8k|}
jdinput.c:finish_input_pass:
  315|  8.26k|{
  316|  8.26k|  cinfo->inputctl->consume_input = consume_markers;
  317|  8.26k|}

jinit_lhuff_decoder:
  284|      9|{
  285|      9|  lhuff_entropy_ptr entropy;
  286|      9|  int i;
  287|       |
  288|      9|  entropy = (lhuff_entropy_ptr)
  289|      9|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      9|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  290|      9|                                sizeof(lhuff_entropy_decoder));
  291|      9|  cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
  292|      9|  entropy->pub.start_pass = start_pass_lhuff_decoder;
  293|      9|  entropy->pub.decode_mcus = decode_mcus;
  294|      9|  entropy->pub.process_restart = process_restart;
  295|       |
  296|       |  /* Mark tables unallocated */
  297|     45|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|     45|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (297:15): [True: 36, False: 9]
  ------------------
  298|       |    entropy->derived_tbls[i] = NULL;
  299|     36|  }
  300|      9|}
jdlhuff.c:start_pass_lhuff_decoder:
   84|      9|{
   85|      9|  lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
   86|      9|  int ci, dctbl, sampn, ptrn, yoffset, xoffset;
   87|      9|  jpeg_component_info *compptr;
   88|       |
   89|     18|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (89:16): [True: 9, False: 9]
  ------------------
   90|      9|    compptr = cinfo->cur_comp_info[ci];
   91|      9|    dctbl = compptr->dc_tbl_no;
   92|       |    /* Make sure requested tables are present */
   93|      9|    if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||
  ------------------
  |  |   69|     18|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (93:9): [True: 0, False: 9]
  |  Branch (93:22): [True: 2, False: 7]
  ------------------
   94|      7|        cinfo->dc_huff_tbl_ptrs[dctbl] == NULL)
  ------------------
  |  Branch (94:9): [True: 7, False: 0]
  ------------------
   95|      9|      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);
  ------------------
  |  |  243|      9|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      9|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      9|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   96|       |    /* Compute derived values for Huffman tables */
   97|       |    /* We may do this more than once for a table, but it's not expensive */
   98|      9|    jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
  ------------------
  |  |  210|      9|#define TRUE    1
  ------------------
   99|      9|                            &entropy->derived_tbls[dctbl]);
  100|      9|  }
  101|       |
  102|       |  /* Precalculate decoding info for each sample in an MCU of this scan */
  103|      9|  for (sampn = 0, ptrn = 0; sampn < cinfo->blocks_in_MCU;) {
  ------------------
  |  Branch (103:29): [True: 0, False: 9]
  ------------------
  104|      0|    compptr = cinfo->cur_comp_info[cinfo->MCU_membership[sampn]];
  105|      0|    ci = compptr->component_index;
  106|      0|    for (yoffset = 0; yoffset < compptr->MCU_height; yoffset++, ptrn++) {
  ------------------
  |  Branch (106:23): [True: 0, False: 0]
  ------------------
  107|       |      /* Precalculate the setup info for each output pointer */
  108|      0|      entropy->output_ptr_info[ptrn].ci = ci;
  109|      0|      entropy->output_ptr_info[ptrn].yoffset = yoffset;
  110|      0|      entropy->output_ptr_info[ptrn].MCU_width = compptr->MCU_width;
  111|      0|      for (xoffset = 0; xoffset < compptr->MCU_width; xoffset++, sampn++) {
  ------------------
  |  Branch (111:25): [True: 0, False: 0]
  ------------------
  112|       |        /* Precalculate the output pointer index for each sample */
  113|      0|        entropy->output_ptr_index[sampn] = ptrn;
  114|       |        /* Precalculate which table to use for each sample */
  115|      0|        entropy->cur_tbls[sampn] = entropy->derived_tbls[compptr->dc_tbl_no];
  116|      0|      }
  117|      0|    }
  118|      0|  }
  119|      9|  entropy->num_output_ptrs = ptrn;
  120|       |
  121|       |  /* Initialize bitread state variables */
  122|      9|  entropy->bitstate.bits_left = 0;
  123|      9|  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
  124|      9|  entropy->pub.insufficient_data = FALSE;
  ------------------
  |  |  207|      9|#define FALSE   0               /* values of boolean */
  ------------------
  125|      9|}

jinit_lossless_decompressor:
  281|      9|{
  282|      9|  lossless_decomp_ptr losslessd;
  283|       |
  284|      9|#if BITS_IN_JSAMPLE == 8
  285|      9|  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (285:7): [True: 0, False: 9]
  |  Branch (285:50): [True: 0, False: 9]
  ------------------
  286|       |#else
  287|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  288|       |      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  289|       |#endif
  290|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  291|       |
  292|       |  /* Create subobject in permanent pool */
  293|      9|  losslessd = (lossless_decomp_ptr)
  294|      9|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|      9|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  295|      9|                                sizeof(jpeg_lossless_decompressor));
  296|      9|  cinfo->idct = (struct jpeg_inverse_dct *)losslessd;
  297|      9|  losslessd->pub.start_pass = start_pass_lossless;
  298|      9|}

jinit_d_main_controller:
  429|  22.8k|{
  430|  22.8k|  my_main_ptr main_ptr;
  431|  22.8k|  int ci, rgroup, ngroups;
  432|  22.8k|  jpeg_component_info *compptr;
  433|       |
  434|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  435|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (435:7): [True: 9, False: 22.8k]
  ------------------
  436|      9|#if BITS_IN_JSAMPLE == 8
  437|      9|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (437:9): [True: 0, False: 9]
  |  Branch (437:52): [True: 0, False: 9]
  ------------------
  438|       |#else
  439|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  440|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  441|       |#endif
  442|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  443|      9|  } else
  444|  22.8k|#endif
  445|  22.8k|  {
  446|  22.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (446:9): [True: 0, False: 22.8k]
  ------------------
  447|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  448|  22.8k|  }
  449|       |
  450|  22.8k|  main_ptr = (my_main_ptr)
  451|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  452|  22.8k|                                sizeof(my_main_controller));
  453|  22.8k|  memset(main_ptr, 0, sizeof(my_main_controller));
  454|  22.8k|  cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
  455|  22.8k|  main_ptr->pub.start_pass = start_pass_main;
  456|       |
  457|  22.8k|  if (need_full_buffer)         /* shouldn't happen */
  ------------------
  |  Branch (457:7): [True: 0, False: 22.8k]
  ------------------
  458|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  459|       |
  460|       |  /* Allocate the workspace.
  461|       |   * ngroups is the number of row groups we need.
  462|       |   */
  463|  22.8k|  if (cinfo->upsample->need_context_rows) {
  ------------------
  |  Branch (463:7): [True: 1, False: 22.8k]
  ------------------
  464|      1|    if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
  ------------------
  |  |   27|      1|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (464:9): [True: 0, False: 1]
  ------------------
  465|      0|      ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  466|      1|    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
  467|      1|    ngroups = cinfo->_min_DCT_scaled_size + 2;
  ------------------
  |  |   27|      1|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  468|  22.8k|  } else {
  469|  22.8k|    ngroups = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  22.8k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  470|  22.8k|  }
  471|       |
  472|  45.6k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (472:44): [True: 22.8k, False: 22.8k]
  ------------------
  473|  22.8k|       ci++, compptr++) {
  474|  22.8k|    rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  475|  22.8k|      cinfo->_min_DCT_scaled_size; /* height of a row group of component */
  ------------------
  |  |   27|  22.8k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  476|  22.8k|    main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  477|  22.8k|                        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|  22.8k|                         compptr->width_in_blocks * compptr->_DCT_scaled_size,
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  479|  22.8k|                         (JDIMENSION)(rgroup * ngroups));
  480|  22.8k|  }
  481|  22.8k|}
jdmainct-8.c:start_pass_main:
  259|  22.7k|{
  260|  22.7k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  261|       |
  262|  22.7k|  switch (pass_mode) {
  263|  22.7k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (263:3): [True: 22.7k, False: 0]
  ------------------
  264|  22.7k|    if (cinfo->upsample->need_context_rows) {
  ------------------
  |  Branch (264:9): [True: 0, False: 22.7k]
  ------------------
  265|      0|      main_ptr->pub._process_data = process_data_context_main;
  ------------------
  |  |  256|      0|#define _process_data  process_data
  ------------------
  266|      0|      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
  267|      0|      main_ptr->whichptr = 0;   /* Read first iMCU row into xbuffer[0] */
  268|      0|      main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
  ------------------
  |  |   46|      0|#define CTX_PREPARE_FOR_IMCU    0       /* need to prepare for MCU row */
  ------------------
  269|      0|      main_ptr->iMCU_row_ctr = 0;
  270|  22.7k|    } else {
  271|       |      /* Simple case with no context needed */
  272|  22.7k|      main_ptr->pub._process_data = process_data_simple_main;
  ------------------
  |  |  256|  22.7k|#define _process_data  process_data
  ------------------
  273|  22.7k|    }
  274|  22.7k|    main_ptr->buffer_full = FALSE;      /* Mark buffer empty */
  ------------------
  |  |  207|  22.7k|#define FALSE   0               /* values of boolean */
  ------------------
  275|  22.7k|    main_ptr->rowgroup_ctr = 0;
  276|  22.7k|    break;
  277|      0|#ifdef QUANT_2PASS_SUPPORTED
  278|      0|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (278:3): [True: 0, False: 22.7k]
  ------------------
  279|       |    /* For last pass of 2-pass quantization, just crank the postprocessor */
  280|      0|    main_ptr->pub._process_data = process_data_crank_post;
  ------------------
  |  |  256|      0|#define _process_data  process_data
  ------------------
  281|      0|    break;
  282|      0|#endif
  283|      0|  default:
  ------------------
  |  Branch (283:3): [True: 0, False: 22.7k]
  ------------------
  284|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  285|      0|    break;
  286|  22.7k|  }
  287|  22.7k|}
jdmainct-8.c:process_data_simple_main:
  298|  9.07M|{
  299|  9.07M|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  300|  9.07M|  JDIMENSION rowgroups_avail;
  301|       |
  302|       |  /* Read input data if we haven't filled the main buffer yet */
  303|  9.07M|  if (!main_ptr->buffer_full) {
  ------------------
  |  Branch (303:7): [True: 1.16M, False: 7.90M]
  ------------------
  304|  1.16M|    if (!(*cinfo->coef->_decompress_data) (cinfo, main_ptr->buffer))
  ------------------
  |  |  258|  1.16M|#define _decompress_data  decompress_data
  ------------------
  |  Branch (304:9): [True: 0, False: 1.16M]
  ------------------
  305|      0|      return;                   /* suspension forced, can do nothing more */
  306|  1.16M|    main_ptr->buffer_full = TRUE;       /* OK, we have an iMCU row to work with */
  ------------------
  |  |  210|  1.16M|#define TRUE    1
  ------------------
  307|  1.16M|  }
  308|       |
  309|       |  /* There are always min_DCT_scaled_size row groups in an iMCU row. */
  310|  9.07M|  rowgroups_avail = (JDIMENSION)cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  9.07M|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  311|       |  /* Note: at the bottom of the image, we may pass extra garbage row groups
  312|       |   * to the postprocessor.  The postprocessor has to check for bottom
  313|       |   * of image anyway (at row resolution), so no point in us doing it too.
  314|       |   */
  315|       |
  316|       |  /* Feed the postprocessor */
  317|  9.07M|  (*cinfo->post->_post_process_data) (cinfo, main_ptr->buffer,
  ------------------
  |  |  260|  9.07M|#define _post_process_data  post_process_data
  ------------------
  318|  9.07M|                                      &main_ptr->rowgroup_ctr, rowgroups_avail,
  319|  9.07M|                                      output_buf, out_row_ctr, out_rows_avail);
  320|       |
  321|       |  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */
  322|  9.07M|  if (main_ptr->rowgroup_ctr >= rowgroups_avail) {
  ------------------
  |  Branch (322:7): [True: 1.12M, False: 7.94M]
  ------------------
  323|  1.12M|    main_ptr->buffer_full = FALSE;
  ------------------
  |  |  207|  1.12M|#define FALSE   0               /* values of boolean */
  ------------------
  324|  1.12M|    main_ptr->rowgroup_ctr = 0;
  325|  1.12M|  }
  326|  9.07M|}
jdmainct-8.c:alloc_funny_pointers:
  139|      1|{
  140|      1|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  141|      1|  int ci, rgroup;
  142|      1|  int M = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|      1|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  143|      1|  jpeg_component_info *compptr;
  144|      1|  _JSAMPARRAY xbuf;
  ------------------
  |  |  230|      1|#define _JSAMPARRAY  JSAMPARRAY
  ------------------
  145|       |
  146|       |  /* Get top-level space for component array pointers.
  147|       |   * We alloc both arrays with one call to save a few cycles.
  148|       |   */
  149|      1|  main_ptr->xbuffer[0] = (_JSAMPIMAGE)
  150|      1|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      1|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  151|      1|                                cinfo->num_components * 2 *
  152|      1|                                sizeof(_JSAMPARRAY));
  153|      1|  main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
  154|       |
  155|      4|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (155:44): [True: 3, False: 1]
  ------------------
  156|      3|       ci++, compptr++) {
  157|      3|    rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|      3|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  158|      3|      cinfo->_min_DCT_scaled_size; /* height of a row group of component */
  ------------------
  |  |   27|      3|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  159|       |    /* Get space for pointer lists --- M+4 row groups in each list.
  160|       |     * We alloc both pointer lists with one call to save a few cycles.
  161|       |     */
  162|      3|    xbuf = (_JSAMPARRAY)
  163|      3|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      3|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  164|      3|                                  2 * (rgroup * (M + 4)) * sizeof(_JSAMPROW));
  165|      3|    xbuf += rgroup;             /* want one row group at negative offsets */
  166|      3|    main_ptr->xbuffer[0][ci] = xbuf;
  167|      3|    xbuf += rgroup * (M + 4);
  168|      3|    main_ptr->xbuffer[1][ci] = xbuf;
  169|      3|  }
  170|      1|}

jinit_marker_reader:
 1288|  23.3k|{
 1289|  23.3k|  my_marker_ptr marker;
 1290|  23.3k|  int i;
 1291|       |
 1292|       |  /* Create subobject in permanent pool */
 1293|  23.3k|  marker = (my_marker_ptr)
 1294|  23.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  23.3k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
 1295|  23.3k|                                sizeof(my_marker_reader));
 1296|  23.3k|  cinfo->marker = (struct jpeg_marker_reader *)marker;
 1297|       |  /* Initialize public method pointers */
 1298|  23.3k|  marker->pub.reset_marker_reader = reset_marker_reader;
 1299|  23.3k|  marker->pub.read_markers = read_markers;
 1300|  23.3k|  marker->pub.read_restart_marker = read_restart_marker;
 1301|       |  /* Initialize COM/APPn processing.
 1302|       |   * By default, we examine and then discard APP0 and APP14,
 1303|       |   * but simply discard COM and all other APPn.
 1304|       |   */
 1305|  23.3k|  marker->process_COM = skip_variable;
 1306|  23.3k|  marker->length_limit_COM = 0;
 1307|   397k|  for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (1307:15): [True: 373k, False: 23.3k]
  ------------------
 1308|   373k|    marker->process_APPn[i] = skip_variable;
 1309|   373k|    marker->length_limit_APPn[i] = 0;
 1310|   373k|  }
 1311|  23.3k|  marker->process_APPn[0] = get_interesting_appn;
 1312|  23.3k|  marker->process_APPn[14] = get_interesting_appn;
 1313|       |  /* Reset marker processing state */
 1314|  23.3k|  reset_marker_reader(cinfo);
 1315|  23.3k|}
jdmarker.c:next_marker:
  892|   140k|{
  893|   140k|  int c;
  894|   140k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|   140k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|   140k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|   140k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  895|       |
  896|   145k|  for (;;) {
  897|   145k|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|   145k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   397k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 83.9k]
  |  |  |  |  |  Branch (279:38): [True: 83.9k, False: 61.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 145k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|   145k|            bytes_in_buffer--; \
  |  |  156|   145k|            V = *next_input_byte++; )
  ------------------
  898|       |    /* Skip any non-FF bytes.
  899|       |     * This may look a bit inefficient, but it will not occur in a valid file.
  900|       |     * We sync after each discarded byte so that a suspending data source
  901|       |     * can discard the byte from its buffer.
  902|       |     */
  903|  17.1M|    while (c != 0xFF) {
  ------------------
  |  Branch (903:12): [True: 16.9M, False: 145k]
  ------------------
  904|  16.9M|      cinfo->marker->discarded_bytes++;
  905|  16.9M|      INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  16.9M|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  16.9M|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  906|  16.9M|      INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  16.9M|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  17.0M|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 13.4k]
  |  |  |  |  |  Branch (279:38): [True: 13.4k, False: 16.9M]
  |  |  |  |  |  Branch (279:53): [Folded, False: 16.9M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  16.9M|            bytes_in_buffer--; \
  |  |  156|  16.9M|            V = *next_input_byte++; )
  ------------------
  907|  16.9M|    }
  908|       |    /* This loop swallows any duplicate FF bytes.  Extra FFs are legal as
  909|       |     * pad bytes, so don't count them in discarded_bytes.  We assume there
  910|       |     * will not be so many consecutive FF bytes as to overflow a suspending
  911|       |     * data source's input buffer.
  912|       |     */
  913|   175k|    do {
  914|   175k|      INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|   175k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   175k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 263]
  |  |  |  |  |  Branch (279:38): [True: 263, False: 174k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 175k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|   175k|            bytes_in_buffer--; \
  |  |  156|   175k|            V = *next_input_byte++; )
  ------------------
  915|   175k|    } while (c == 0xFF);
  ------------------
  |  Branch (915:14): [True: 29.9k, False: 145k]
  ------------------
  916|   145k|    if (c != 0)
  ------------------
  |  Branch (916:9): [True: 140k, False: 4.57k]
  ------------------
  917|   140k|      break;                    /* found a valid marker, exit loop */
  918|       |    /* Reach here if we found a stuffed-zero data sequence (FF/00).
  919|       |     * Discard it and loop back to try again.
  920|       |     */
  921|  4.57k|    cinfo->marker->discarded_bytes += 2;
  922|  4.57k|    INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  4.57k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  4.57k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  923|  4.57k|  }
  924|       |
  925|   140k|  if (cinfo->marker->discarded_bytes != 0) {
  ------------------
  |  Branch (925:7): [True: 54.8k, False: 85.8k]
  ------------------
  926|  54.8k|    WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
  ------------------
  |  |  290|  54.8k|  ((cinfo)->err->msg_code = (code), \
  |  |  291|  54.8k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  292|  54.8k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  293|  54.8k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  927|  54.8k|    cinfo->marker->discarded_bytes = 0;
  928|  54.8k|  }
  929|       |
  930|   140k|  cinfo->unread_marker = c;
  931|       |
  932|   140k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|   140k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|   140k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  933|   140k|  return TRUE;
  ------------------
  |  |  210|   140k|#define TRUE    1
  ------------------
  934|   140k|}
jdmarker.c:reset_marker_reader:
 1268|  84.0k|{
 1269|  84.0k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
 1270|       |
 1271|  84.0k|  cinfo->comp_info = NULL;              /* until allocated by get_sof */
 1272|  84.0k|  cinfo->input_scan_number = 0;         /* no SOS seen yet */
 1273|  84.0k|  cinfo->unread_marker = 0;             /* no pending marker */
 1274|  84.0k|  marker->pub.saw_SOI = FALSE;          /* set internal state too */
  ------------------
  |  |  207|  84.0k|#define FALSE   0               /* values of boolean */
  ------------------
 1275|  84.0k|  marker->pub.saw_SOF = FALSE;
  ------------------
  |  |  207|  84.0k|#define FALSE   0               /* values of boolean */
  ------------------
 1276|  84.0k|  marker->pub.discarded_bytes = 0;
 1277|       |  marker->cur_marker = NULL;
 1278|  84.0k|}
jdmarker.c:read_markers:
  970|  60.6k|{
  971|       |  /* Outer loop repeats once for each marker. */
  972|   194k|  for (;;) {
  973|       |    /* Collect the marker proper, unless we already did. */
  974|       |    /* NB: first_marker() enforces the requirement that SOI appear first. */
  975|   194k|    if (cinfo->unread_marker == 0) {
  ------------------
  |  Branch (975:9): [True: 194k, False: 0]
  ------------------
  976|   194k|      if (!cinfo->marker->saw_SOI) {
  ------------------
  |  Branch (976:11): [True: 60.6k, False: 133k]
  ------------------
  977|  60.6k|        if (!first_marker(cinfo))
  ------------------
  |  Branch (977:13): [True: 0, False: 60.6k]
  ------------------
  978|      0|          return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  979|   133k|      } else {
  980|   133k|        if (!next_marker(cinfo))
  ------------------
  |  Branch (980:13): [True: 0, False: 133k]
  ------------------
  981|      0|          return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  982|   133k|      }
  983|   194k|    }
  984|       |    /* At this point cinfo->unread_marker contains the marker code and the
  985|       |     * input point is just past the marker proper, but before any parameters.
  986|       |     * A suspension will cause us to return with this state still true.
  987|       |     */
  988|   194k|    switch (cinfo->unread_marker) {
  989|  33.1k|    case M_SOI:
  ------------------
  |  Branch (989:5): [True: 33.1k, False: 160k]
  ------------------
  990|  33.1k|      if (!get_soi(cinfo))
  ------------------
  |  Branch (990:11): [True: 0, False: 33.1k]
  ------------------
  991|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  992|  33.1k|      break;
  993|       |
  994|  33.1k|    case M_SOF0:                /* Baseline */
  ------------------
  |  Branch (994:5): [True: 22.9k, False: 171k]
  ------------------
  995|  23.1k|    case M_SOF1:                /* Extended sequential, Huffman */
  ------------------
  |  Branch (995:5): [True: 204, False: 193k]
  ------------------
  996|  23.1k|      if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|  23.1k|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|  23.1k|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|  23.1k|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (996:11): [True: 0, False: 23.1k]
  ------------------
  997|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  998|  23.1k|      break;
  999|       |
 1000|  23.1k|    case M_SOF2:                /* Progressive, Huffman */
  ------------------
  |  Branch (1000:5): [True: 340, False: 193k]
  ------------------
 1001|    340|      if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  210|    340|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  207|    340|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  207|    340|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (1001:11): [True: 0, False: 340]
  ------------------
 1002|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1003|    340|      break;
 1004|       |
 1005|    340|    case M_SOF3:                /* Lossless, Huffman */
  ------------------
  |  Branch (1005:5): [True: 140, False: 193k]
  ------------------
 1006|    140|      if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  207|    140|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  210|    140|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  207|    140|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (1006:11): [True: 0, False: 140]
  ------------------
 1007|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1008|    140|      break;
 1009|       |
 1010|    697|    case M_SOF9:                /* Extended sequential, arithmetic */
  ------------------
  |  Branch (1010:5): [True: 697, False: 193k]
  ------------------
 1011|    697|      if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  207|    697|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  207|    697|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  210|    697|#define TRUE    1
  ------------------
  |  Branch (1011:11): [True: 0, False: 697]
  ------------------
 1012|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1013|    697|      break;
 1014|       |
 1015|    697|    case M_SOF10:               /* Progressive, arithmetic */
  ------------------
  |  Branch (1015:5): [True: 229, False: 193k]
  ------------------
 1016|    229|      if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  210|    229|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  207|    229|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  210|    229|#define TRUE    1
  ------------------
  |  Branch (1016:11): [True: 0, False: 229]
  ------------------
 1017|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1018|    229|      break;
 1019|       |
 1020|    358|    case M_SOF11:               /* Lossless, arithmetic */
  ------------------
  |  Branch (1020:5): [True: 358, False: 193k]
  ------------------
 1021|    358|      if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  207|    358|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  210|    358|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  210|    358|#define TRUE    1
  ------------------
  |  Branch (1021:11): [True: 0, False: 358]
  ------------------
 1022|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1023|    358|      break;
 1024|       |
 1025|       |    /* Currently unsupported SOFn types */
 1026|    358|    case M_SOF5:                /* Differential sequential, Huffman */
  ------------------
  |  Branch (1026:5): [True: 158, False: 193k]
  ------------------
 1027|    291|    case M_SOF6:                /* Differential progressive, Huffman */
  ------------------
  |  Branch (1027:5): [True: 133, False: 193k]
  ------------------
 1028|    434|    case M_SOF7:                /* Differential lossless, Huffman */
  ------------------
  |  Branch (1028:5): [True: 143, False: 193k]
  ------------------
 1029|    564|    case M_JPG:                 /* Reserved for JPEG extensions */
  ------------------
  |  Branch (1029:5): [True: 130, False: 193k]
  ------------------
 1030|    564|    case M_SOF13:               /* Differential sequential, arithmetic */
  ------------------
  |  Branch (1030:5): [True: 0, False: 194k]
  ------------------
 1031|    692|    case M_SOF14:               /* Differential progressive, arithmetic */
  ------------------
  |  Branch (1031:5): [True: 128, False: 193k]
  ------------------
 1032|    692|    case M_SOF15:               /* Differential lossless, arithmetic */
  ------------------
  |  Branch (1032:5): [True: 0, False: 194k]
  ------------------
 1033|    692|      ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
  ------------------
  |  |  243|    692|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    692|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    692|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1034|    692|      break;
 1035|       |
 1036|  23.4k|    case M_SOS:
  ------------------
  |  Branch (1036:5): [True: 23.4k, False: 170k]
  ------------------
 1037|  23.4k|      if (!get_sos(cinfo))
  ------------------
  |  Branch (1037:11): [True: 0, False: 23.4k]
  ------------------
 1038|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1039|  23.4k|      cinfo->unread_marker = 0; /* processed the marker */
 1040|  23.4k|      return JPEG_REACHED_SOS;
  ------------------
  |  | 1111|  23.4k|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
 1041|       |
 1042|  3.61k|    case M_EOI:
  ------------------
  |  Branch (1042:5): [True: 3.61k, False: 190k]
  ------------------
 1043|  3.61k|      TRACEMS(cinfo, 1, JTRC_EOI);
  ------------------
  |  |  297|  3.61k|  ((cinfo)->err->msg_code = (code), \
  |  |  298|  3.61k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1044|  3.61k|      cinfo->unread_marker = 0; /* processed the marker */
 1045|  3.61k|      return JPEG_REACHED_EOI;
  ------------------
  |  | 1112|  3.61k|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
 1046|       |
 1047|    698|    case M_DAC:
  ------------------
  |  Branch (1047:5): [True: 698, False: 193k]
  ------------------
 1048|    698|      if (!get_dac(cinfo))
  ------------------
  |  Branch (1048:11): [True: 0, False: 698]
  ------------------
 1049|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1050|    698|      break;
 1051|       |
 1052|    698|    case M_DHT:
  ------------------
  |  Branch (1052:5): [True: 513, False: 193k]
  ------------------
 1053|    513|      if (!get_dht(cinfo))
  ------------------
  |  Branch (1053:11): [True: 0, False: 513]
  ------------------
 1054|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1055|    513|      break;
 1056|       |
 1057|  24.5k|    case M_DQT:
  ------------------
  |  Branch (1057:5): [True: 24.5k, False: 169k]
  ------------------
 1058|  24.5k|      if (!get_dqt(cinfo))
  ------------------
  |  Branch (1058:11): [True: 0, False: 24.5k]
  ------------------
 1059|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1060|  24.5k|      break;
 1061|       |
 1062|  24.5k|    case M_DRI:
  ------------------
  |  Branch (1062:5): [True: 16.3k, False: 177k]
  ------------------
 1063|  16.3k|      if (!get_dri(cinfo))
  ------------------
  |  Branch (1063:11): [True: 0, False: 16.3k]
  ------------------
 1064|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1065|  16.3k|      break;
 1066|       |
 1067|  16.3k|    case M_APP0:
  ------------------
  |  Branch (1067:5): [True: 14.4k, False: 179k]
  ------------------
 1068|  26.1k|    case M_APP1:
  ------------------
  |  Branch (1068:5): [True: 11.6k, False: 182k]
  ------------------
 1069|  26.2k|    case M_APP2:
  ------------------
  |  Branch (1069:5): [True: 99, False: 193k]
  ------------------
 1070|  26.5k|    case M_APP3:
  ------------------
  |  Branch (1070:5): [True: 279, False: 193k]
  ------------------
 1071|  26.8k|    case M_APP4:
  ------------------
  |  Branch (1071:5): [True: 280, False: 193k]
  ------------------
 1072|  27.3k|    case M_APP5:
  ------------------
  |  Branch (1072:5): [True: 559, False: 193k]
  ------------------
 1073|  27.5k|    case M_APP6:
  ------------------
  |  Branch (1073:5): [True: 138, False: 193k]
  ------------------
 1074|  27.5k|    case M_APP7:
  ------------------
  |  Branch (1074:5): [True: 62, False: 194k]
  ------------------
 1075|  28.4k|    case M_APP8:
  ------------------
  |  Branch (1075:5): [True: 884, False: 193k]
  ------------------
 1076|  28.8k|    case M_APP9:
  ------------------
  |  Branch (1076:5): [True: 402, False: 193k]
  ------------------
 1077|  28.9k|    case M_APP10:
  ------------------
  |  Branch (1077:5): [True: 104, False: 193k]
  ------------------
 1078|  29.2k|    case M_APP11:
  ------------------
  |  Branch (1078:5): [True: 259, False: 193k]
  ------------------
 1079|  29.3k|    case M_APP12:
  ------------------
  |  Branch (1079:5): [True: 119, False: 193k]
  ------------------
 1080|  29.4k|    case M_APP13:
  ------------------
  |  Branch (1080:5): [True: 97, False: 193k]
  ------------------
 1081|  33.1k|    case M_APP14:
  ------------------
  |  Branch (1081:5): [True: 3.69k, False: 190k]
  ------------------
 1082|  33.1k|    case M_APP15:
  ------------------
  |  Branch (1082:5): [True: 1, False: 194k]
  ------------------
 1083|  33.1k|      if (!(*((my_marker_ptr)cinfo->marker)->process_APPn[
  ------------------
  |  Branch (1083:11): [True: 0, False: 33.1k]
  ------------------
 1084|  33.1k|               cinfo->unread_marker - (int)M_APP0]) (cinfo))
 1085|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1086|  33.1k|      break;
 1087|       |
 1088|  33.1k|    case M_COM:
  ------------------
  |  Branch (1088:5): [True: 1.04k, False: 193k]
  ------------------
 1089|  1.04k|      if (!(*((my_marker_ptr)cinfo->marker)->process_COM) (cinfo))
  ------------------
  |  Branch (1089:11): [True: 0, False: 1.04k]
  ------------------
 1090|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1091|  1.04k|      break;
 1092|       |
 1093|  1.04k|    case M_RST0:                /* these are all parameterless */
  ------------------
  |  Branch (1093:5): [True: 518, False: 193k]
  ------------------
 1094|    896|    case M_RST1:
  ------------------
  |  Branch (1094:5): [True: 378, False: 193k]
  ------------------
 1095|  1.06k|    case M_RST2:
  ------------------
  |  Branch (1095:5): [True: 166, False: 193k]
  ------------------
 1096|  1.46k|    case M_RST3:
  ------------------
  |  Branch (1096:5): [True: 401, False: 193k]
  ------------------
 1097|  1.47k|    case M_RST4:
  ------------------
  |  Branch (1097:5): [True: 12, False: 194k]
  ------------------
 1098|  1.48k|    case M_RST5:
  ------------------
  |  Branch (1098:5): [True: 8, False: 194k]
  ------------------
 1099|  1.51k|    case M_RST6:
  ------------------
  |  Branch (1099:5): [True: 32, False: 194k]
  ------------------
 1100|  1.86k|    case M_RST7:
  ------------------
  |  Branch (1100:5): [True: 353, False: 193k]
  ------------------
 1101|  2.79k|    case M_TEM:
  ------------------
  |  Branch (1101:5): [True: 925, False: 193k]
  ------------------
 1102|  2.79k|      TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
  ------------------
  |  |  300|  2.79k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  2.79k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  2.79k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1103|  2.79k|      break;
 1104|       |
 1105|    711|    case M_DNL:                 /* Ignore DNL ... perhaps the wrong thing */
  ------------------
  |  Branch (1105:5): [True: 711, False: 193k]
  ------------------
 1106|    711|      if (!skip_variable(cinfo))
  ------------------
  |  Branch (1106:11): [True: 0, False: 711]
  ------------------
 1107|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1108|    711|      break;
 1109|       |
 1110|    724|    default:                    /* must be DHP, EXP, JPGn, or RESn */
  ------------------
  |  Branch (1110:5): [True: 724, False: 193k]
  ------------------
 1111|       |      /* For now, we treat the reserved markers as fatal errors since they are
 1112|       |       * likely to be used to signal incompatible JPEG Part 3 extensions.
 1113|       |       * Once the JPEG 3 version-number marker is well defined, this code
 1114|       |       * ought to change!
 1115|       |       */
 1116|    724|      ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
  ------------------
  |  |  243|    724|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    724|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    724|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1117|    724|      break;
 1118|   194k|    }
 1119|       |    /* Successfully processed marker, so reset state variable */
 1120|   133k|    cinfo->unread_marker = 0;
 1121|   133k|  } /* end loop */
 1122|  60.6k|}
jdmarker.c:first_marker:
  945|  60.6k|{
  946|  60.6k|  int c, c2;
  947|  60.6k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  60.6k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  60.6k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  60.6k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  948|       |
  949|  60.6k|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  60.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   129k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 22.9k]
  |  |  |  |  |  Branch (279:38): [True: 22.9k, False: 37.6k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 60.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  60.6k|            bytes_in_buffer--; \
  |  |  156|  60.6k|            V = *next_input_byte++; )
  ------------------
  950|  60.6k|  INPUT_BYTE(cinfo, c2, return FALSE);
  ------------------
  |  |  154|  60.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  70.5k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 3.30k]
  |  |  |  |  |  Branch (279:38): [True: 3.30k, False: 57.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 60.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  60.6k|            bytes_in_buffer--; \
  |  |  156|  60.6k|            V = *next_input_byte++; )
  ------------------
  951|  60.6k|  if (c != 0xFF || c2 != (int)M_SOI)
  ------------------
  |  Branch (951:7): [True: 26.5k, False: 34.1k]
  |  Branch (951:20): [True: 1.08k, False: 33.0k]
  ------------------
  952|  27.6k|    ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
  ------------------
  |  |  247|  27.6k|  ((cinfo)->err->msg_code = (code), \
  |  |  248|  27.6k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|  27.6k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|  27.6k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  953|       |
  954|  60.6k|  cinfo->unread_marker = c2;
  955|       |
  956|  60.6k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  60.6k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  60.6k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  957|  60.6k|  return TRUE;
  ------------------
  |  |  210|  60.6k|#define TRUE    1
  ------------------
  958|  60.6k|}
jdmarker.c:get_soi:
  204|  33.1k|{
  205|  33.1k|  int i;
  206|       |
  207|  33.1k|  TRACEMS(cinfo, 1, JTRC_SOI);
  ------------------
  |  |  297|  33.1k|  ((cinfo)->err->msg_code = (code), \
  |  |  298|  33.1k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  208|       |
  209|  33.1k|  if (cinfo->marker->saw_SOI)
  ------------------
  |  Branch (209:7): [True: 173, False: 33.0k]
  ------------------
  210|    173|    ERREXIT(cinfo, JERR_SOI_DUPLICATE);
  ------------------
  |  |  240|    173|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    173|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  211|       |
  212|       |  /* Reset all parameters that are defined to be reset by SOI */
  213|       |
  214|   561k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   561k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (214:15): [True: 528k, False: 33.1k]
  ------------------
  215|   528k|    cinfo->arith_dc_L[i] = 0;
  216|   528k|    cinfo->arith_dc_U[i] = 1;
  217|   528k|    cinfo->arith_ac_K[i] = 5;
  218|   528k|  }
  219|  33.1k|  cinfo->restart_interval = 0;
  220|       |
  221|       |  /* Set initial assumptions for colorspace etc */
  222|       |
  223|  33.1k|  cinfo->jpeg_color_space = JCS_UNKNOWN;
  224|  33.1k|  cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
  ------------------
  |  |  207|  33.1k|#define FALSE   0               /* values of boolean */
  ------------------
  225|       |
  226|  33.1k|  cinfo->saw_JFIF_marker = FALSE;
  ------------------
  |  |  207|  33.1k|#define FALSE   0               /* values of boolean */
  ------------------
  227|  33.1k|  cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */
  228|  33.1k|  cinfo->JFIF_minor_version = 1;
  229|  33.1k|  cinfo->density_unit = 0;
  230|  33.1k|  cinfo->X_density = 1;
  231|  33.1k|  cinfo->Y_density = 1;
  232|  33.1k|  cinfo->saw_Adobe_marker = FALSE;
  ------------------
  |  |  207|  33.1k|#define FALSE   0               /* values of boolean */
  ------------------
  233|  33.1k|  cinfo->Adobe_transform = 0;
  234|       |
  235|  33.1k|  cinfo->marker->saw_SOI = TRUE;
  ------------------
  |  |  210|  33.1k|#define TRUE    1
  ------------------
  236|       |
  237|  33.1k|  return TRUE;
  ------------------
  |  |  210|  33.1k|#define TRUE    1
  ------------------
  238|  33.1k|}
jdmarker.c:get_sof:
  245|  24.9k|{
  246|  24.9k|  JLONG length;
  247|  24.9k|  int c, ci;
  248|  24.9k|  jpeg_component_info *compptr;
  249|  24.9k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  24.9k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  24.9k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  24.9k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  250|       |
  251|  24.9k|  if (cinfo->marker->saw_SOF)
  ------------------
  |  Branch (251:7): [True: 115, False: 24.7k]
  ------------------
  252|    115|    ERREXIT(cinfo, JERR_SOF_DUPLICATE);
  ------------------
  |  |  240|    115|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    115|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  253|       |
  254|  24.9k|  cinfo->progressive_mode = is_prog;
  255|  24.9k|  cinfo->master->lossless = is_lossless;
  256|  24.9k|  cinfo->arith_code = is_arith;
  257|       |
  258|  24.9k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  24.9k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  51.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 145]
  |  |  |  |  |  Branch (279:38): [True: 145, False: 24.7k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 482]
  |  |  |  |  |  Branch (279:38): [True: 482, False: 24.4k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  24.9k|            bytes_in_buffer--; \
  |  |  164|  24.9k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  24.9k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  24.9k|            bytes_in_buffer--; \
  |  |  167|  24.9k|            V += *next_input_byte++; )
  ------------------
  259|       |
  260|  24.9k|  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
  ------------------
  |  |  154|  24.9k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  25.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 146]
  |  |  |  |  |  Branch (279:38): [True: 146, False: 24.7k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  24.9k|            bytes_in_buffer--; \
  |  |  156|  24.9k|            V = *next_input_byte++; )
  ------------------
  261|  24.9k|  cinfo->master->jpeg_data_precision = cinfo->data_precision;
  262|  24.9k|  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
  ------------------
  |  |  162|  24.9k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  51.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 486]
  |  |  |  |  |  Branch (279:38): [True: 486, False: 24.4k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 147]
  |  |  |  |  |  Branch (279:38): [True: 147, False: 24.7k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  24.9k|            bytes_in_buffer--; \
  |  |  164|  24.9k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  24.9k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  24.9k|            bytes_in_buffer--; \
  |  |  167|  24.9k|            V += *next_input_byte++; )
  ------------------
  263|  24.9k|  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
  ------------------
  |  |  162|  24.9k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  51.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 488]
  |  |  |  |  |  Branch (279:38): [True: 488, False: 24.4k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 152]
  |  |  |  |  |  Branch (279:38): [True: 152, False: 24.7k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  24.9k|            bytes_in_buffer--; \
  |  |  164|  24.9k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  24.9k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  24.9k|            bytes_in_buffer--; \
  |  |  167|  24.9k|            V += *next_input_byte++; )
  ------------------
  264|  24.9k|  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);
  ------------------
  |  |  154|  24.9k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  26.4k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 518]
  |  |  |  |  |  Branch (279:38): [True: 518, False: 24.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  24.9k|            bytes_in_buffer--; \
  |  |  156|  24.9k|            V = *next_input_byte++; )
  ------------------
  265|       |
  266|  24.9k|  length -= 8;
  267|       |
  268|  24.9k|  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
  ------------------
  |  |  314|  24.9k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  24.9k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|  24.9k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|  24.9k|           (cinfo)->err->msg_code = (code); \
  |  |  317|  24.9k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  269|  24.9k|           (int)cinfo->image_width, (int)cinfo->image_height,
  270|  24.9k|           cinfo->num_components);
  271|       |
  272|       |  /* We don't support files in which the image height is initially specified */
  273|       |  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */
  274|       |  /* might as well have a general sanity check. */
  275|  24.9k|  if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
  ------------------
  |  Branch (275:7): [True: 115, False: 24.7k]
  |  Branch (275:35): [True: 200, False: 24.5k]
  ------------------
  276|  24.5k|      cinfo->num_components <= 0)
  ------------------
  |  Branch (276:7): [True: 268, False: 24.3k]
  ------------------
  277|    468|    ERREXIT(cinfo, JERR_EMPTY_IMAGE);
  ------------------
  |  |  240|    468|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    468|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  278|       |
  279|  24.9k|  if (length != (cinfo->num_components * 3))
  ------------------
  |  Branch (279:7): [True: 648, False: 24.2k]
  ------------------
  280|    648|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|    648|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    648|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  281|       |
  282|  24.9k|  if (cinfo->comp_info == NULL) /* do only once, even if suspend */
  ------------------
  |  Branch (282:7): [True: 23.6k, False: 1.23k]
  ------------------
  283|  23.6k|    cinfo->comp_info = (jpeg_component_info *)(*cinfo->mem->alloc_small)
  284|  23.6k|                        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  23.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  285|  23.6k|                         cinfo->num_components * sizeof(jpeg_component_info));
  286|       |
  287|  50.5k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (287:44): [True: 25.6k, False: 24.9k]
  ------------------
  288|  25.6k|       ci++, compptr++) {
  289|  25.6k|    compptr->component_index = ci;
  290|  25.6k|    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
  ------------------
  |  |  154|  25.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  25.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 9]
  |  |  |  |  |  Branch (279:38): [True: 9, False: 25.5k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  25.6k|            bytes_in_buffer--; \
  |  |  156|  25.6k|            V = *next_input_byte++; )
  ------------------
  291|  25.6k|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  25.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  25.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 8]
  |  |  |  |  |  Branch (279:38): [True: 8, False: 25.5k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  25.6k|            bytes_in_buffer--; \
  |  |  156|  25.6k|            V = *next_input_byte++; )
  ------------------
  292|  25.6k|    compptr->h_samp_factor = (c >> 4) & 15;
  293|  25.6k|    compptr->v_samp_factor = (c     ) & 15;
  294|  25.6k|    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);
  ------------------
  |  |  154|  25.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  25.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 15]
  |  |  |  |  |  Branch (279:38): [True: 15, False: 25.5k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  25.6k|            bytes_in_buffer--; \
  |  |  156|  25.6k|            V = *next_input_byte++; )
  ------------------
  295|       |
  296|  25.6k|    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
  ------------------
  |  |  314|  25.6k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  25.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|  25.6k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|  25.6k|           (cinfo)->err->msg_code = (code); \
  |  |  317|  25.6k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  297|  25.6k|             compptr->component_id, compptr->h_samp_factor,
  298|  25.6k|             compptr->v_samp_factor, compptr->quant_tbl_no);
  299|  25.6k|  }
  300|       |
  301|  24.9k|  cinfo->marker->saw_SOF = TRUE;
  ------------------
  |  |  210|  24.9k|#define TRUE    1
  ------------------
  302|       |
  303|  24.9k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  24.9k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  24.9k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  304|  24.9k|  return TRUE;
  ------------------
  |  |  210|  24.9k|#define TRUE    1
  ------------------
  305|  24.9k|}
jdmarker.c:get_sos:
  311|  23.4k|{
  312|  23.4k|  JLONG length;
  313|  23.4k|  int i, ci, n, c, cc, pi;
  314|  23.4k|  jpeg_component_info *compptr;
  315|  23.4k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  23.4k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  23.4k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  23.4k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  316|       |
  317|  23.4k|  if (!cinfo->marker->saw_SOF)
  ------------------
  |  Branch (317:7): [True: 0, False: 23.4k]
  ------------------
  318|      0|    ERREXIT(cinfo, JERR_SOS_NO_SOF);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  319|       |
  320|  23.4k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  23.4k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  47.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 143]
  |  |  |  |  |  Branch (279:38): [True: 143, False: 23.3k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 131]
  |  |  |  |  |  Branch (279:38): [True: 131, False: 23.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  23.4k|            bytes_in_buffer--; \
  |  |  164|  23.4k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  23.4k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  23.4k|            bytes_in_buffer--; \
  |  |  167|  23.4k|            V += *next_input_byte++; )
  ------------------
  321|       |
  322|  23.4k|  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */
  ------------------
  |  |  154|  23.4k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.9k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 143]
  |  |  |  |  |  Branch (279:38): [True: 143, False: 23.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.4k|            bytes_in_buffer--; \
  |  |  156|  23.4k|            V = *next_input_byte++; )
  ------------------
  323|       |
  324|  23.4k|  TRACEMS1(cinfo, 1, JTRC_SOS, n);
  ------------------
  |  |  300|  23.4k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  23.4k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  23.4k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  325|       |
  326|  23.4k|  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  23.1k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (326:7): [True: 341, False: 23.1k]
  |  Branch (326:32): [True: 0, False: 23.1k]
  |  Branch (326:41): [True: 0, False: 23.1k]
  ------------------
  327|    341|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|    341|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    341|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  328|       |
  329|  23.4k|  cinfo->comps_in_scan = n;
  330|       |
  331|       |  /* Collect the component-spec parameters */
  332|       |
  333|   116k|  for (i = 0; i < MAX_COMPS_IN_SCAN; i++)
  ------------------
  |  |   71|   116k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:15): [True: 92.5k, False: 23.4k]
  ------------------
  334|  92.5k|    cinfo->cur_comp_info[i] = NULL;
  335|       |
  336|  46.4k|  for (i = 0; i < n; i++) {
  ------------------
  |  Branch (336:15): [True: 23.2k, False: 23.2k]
  ------------------
  337|  23.2k|    INPUT_BYTE(cinfo, cc, return FALSE);
  ------------------
  |  |  154|  23.2k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 23.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.2k|            bytes_in_buffer--; \
  |  |  156|  23.2k|            V = *next_input_byte++; )
  ------------------
  338|  23.2k|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  23.2k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 23.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.2k|            bytes_in_buffer--; \
  |  |  156|  23.2k|            V = *next_input_byte++; )
  ------------------
  339|       |
  340|  23.2k|    for (ci = 0, compptr = cinfo->comp_info;
  341|  24.0k|         ci < cinfo->num_components && ci < MAX_COMPS_IN_SCAN;
  ------------------
  |  |   71|  23.8k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (341:10): [True: 23.8k, False: 243]
  |  Branch (341:40): [True: 23.8k, False: 0]
  ------------------
  342|  23.8k|         ci++, compptr++) {
  343|  23.8k|      if (cc == compptr->component_id && !cinfo->cur_comp_info[ci])
  ------------------
  |  Branch (343:11): [True: 23.0k, False: 803]
  |  Branch (343:42): [True: 22.9k, False: 10]
  ------------------
  344|  22.9k|        goto id_found;
  345|  23.8k|    }
  346|       |
  347|    243|    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
  ------------------
  |  |  243|    243|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    243|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    243|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  348|       |
  349|  22.9k|id_found:
  350|       |
  351|  22.9k|    cinfo->cur_comp_info[i] = compptr;
  352|  22.9k|    compptr->dc_tbl_no = (c >> 4) & 15;
  353|  22.9k|    compptr->ac_tbl_no = (c     ) & 15;
  354|       |
  355|  22.9k|    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
  ------------------
  |  |  309|  22.9k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  22.9k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 22.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  22.9k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  22.9k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  22.9k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  356|  22.9k|             compptr->dc_tbl_no, compptr->ac_tbl_no);
  357|       |
  358|       |    /* This CSi (cc) should differ from the previous CSi */
  359|  23.1k|    for (pi = 0; pi < i; pi++) {
  ------------------
  |  Branch (359:18): [True: 124, False: 22.9k]
  ------------------
  360|    124|      if (cinfo->cur_comp_info[pi] == compptr) {
  ------------------
  |  Branch (360:11): [True: 4, False: 120]
  ------------------
  361|      4|        ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
  ------------------
  |  |  243|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      4|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  362|      4|      }
  363|    124|    }
  364|  22.9k|  }
  365|       |
  366|       |  /* Collect the additional scan parameters Ss, Se, Ah/Al. */
  367|  23.2k|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  23.2k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 23.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.2k|            bytes_in_buffer--; \
  |  |  156|  23.2k|            V = *next_input_byte++; )
  ------------------
  368|  23.2k|  cinfo->Ss = c;
  369|  23.2k|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  23.2k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 23.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.2k|            bytes_in_buffer--; \
  |  |  156|  23.2k|            V = *next_input_byte++; )
  ------------------
  370|  23.2k|  cinfo->Se = c;
  371|  23.2k|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  23.2k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 23.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  23.2k|            bytes_in_buffer--; \
  |  |  156|  23.2k|            V = *next_input_byte++; )
  ------------------
  372|  23.2k|  cinfo->Ah = (c >> 4) & 15;
  373|  23.2k|  cinfo->Al = (c     ) & 15;
  374|       |
  375|  23.2k|  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
  ------------------
  |  |  314|  23.2k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  23.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 23.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|  23.2k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|  23.2k|           (cinfo)->err->msg_code = (code); \
  |  |  317|  23.2k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  376|  23.2k|           cinfo->Ah, cinfo->Al);
  377|       |
  378|       |  /* Prepare to scan data & restart markers */
  379|  23.2k|  cinfo->marker->next_restart_num = 0;
  380|       |
  381|       |  /* Count another SOS marker */
  382|  23.2k|  cinfo->input_scan_number++;
  383|       |
  384|  23.2k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  23.2k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  23.2k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  385|  23.2k|  return TRUE;
  ------------------
  |  |  210|  23.2k|#define TRUE    1
  ------------------
  386|  23.2k|}
jdmarker.c:get_dac:
  394|    698|{
  395|    698|  JLONG length;
  396|    698|  int index, val;
  397|    698|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|    698|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|    698|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|    698|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  398|       |
  399|    698|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|    698|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.94k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 182]
  |  |  |  |  |  Branch (279:38): [True: 182, False: 516]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 698]
  |  |  |  |  |  Branch (279:53): [Folded, False: 698]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    698|            bytes_in_buffer--; \
  |  |  164|    698|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    698|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    698|            bytes_in_buffer--; \
  |  |  167|    698|            V += *next_input_byte++; )
  ------------------
  400|    698|  length -= 2;
  401|       |
  402|  3.16k|  while (length > 0) {
  ------------------
  |  Branch (402:10): [True: 2.46k, False: 698]
  ------------------
  403|  2.46k|    INPUT_BYTE(cinfo, index, return FALSE);
  ------------------
  |  |  154|  2.46k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  3.02k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 186]
  |  |  |  |  |  Branch (279:38): [True: 186, False: 2.28k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 2.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  2.46k|            bytes_in_buffer--; \
  |  |  156|  2.46k|            V = *next_input_byte++; )
  ------------------
  404|  2.46k|    INPUT_BYTE(cinfo, val, return FALSE);
  ------------------
  |  |  154|  2.46k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  4.30k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 612]
  |  |  |  |  |  Branch (279:38): [True: 612, False: 1.85k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 2.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  2.46k|            bytes_in_buffer--; \
  |  |  156|  2.46k|            V = *next_input_byte++; )
  ------------------
  405|       |
  406|  2.46k|    length -= 2;
  407|       |
  408|  2.46k|    TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
  ------------------
  |  |  304|  2.46k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  2.46k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  2.46k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  2.46k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  409|       |
  410|  2.46k|    if (index < 0 || index >= (2 * NUM_ARITH_TBLS))
  ------------------
  |  |   70|  2.46k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (410:9): [True: 0, False: 2.46k]
  |  Branch (410:22): [True: 496, False: 1.97k]
  ------------------
  411|    496|      ERREXIT1(cinfo, JERR_DAC_INDEX, index);
  ------------------
  |  |  243|    496|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    496|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    496|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|       |
  413|  2.46k|    if (index >= NUM_ARITH_TBLS) { /* define AC table */
  ------------------
  |  |   70|  2.46k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (413:9): [True: 0, False: 2.46k]
  ------------------
  414|      0|      cinfo->arith_ac_K[index - NUM_ARITH_TBLS] = (UINT8)val;
  ------------------
  |  |   70|      0|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  415|  2.46k|    } else {                    /* define DC table */
  416|  2.46k|      cinfo->arith_dc_L[index] = (UINT8)(val & 0x0F);
  417|  2.46k|      cinfo->arith_dc_U[index] = (UINT8)(val >> 4);
  418|  2.46k|      if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
  ------------------
  |  Branch (418:11): [True: 183, False: 2.28k]
  ------------------
  419|    183|        ERREXIT1(cinfo, JERR_DAC_VALUE, val);
  ------------------
  |  |  243|    183|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    183|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    183|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  420|  2.46k|    }
  421|  2.46k|  }
  422|       |
  423|    698|  if (length != 0)
  ------------------
  |  Branch (423:7): [True: 15, False: 683]
  ------------------
  424|     15|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|     15|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     15|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  425|       |
  426|    698|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|    698|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|    698|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  427|    698|  return TRUE;
  ------------------
  |  |  210|    698|#define TRUE    1
  ------------------
  428|    698|}
jdmarker.c:get_dht:
  440|    513|{
  441|    513|  JLONG length;
  442|    513|  UINT8 bits[17];
  443|    513|  UINT8 huffval[256];
  444|    513|  int i, index, count;
  445|    513|  JHUFF_TBL **htblptr;
  446|    513|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|    513|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|    513|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|    513|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  447|       |
  448|    513|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|    513|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.02k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 513]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1]
  |  |  |  |  |  Branch (279:38): [True: 1, False: 512]
  |  |  |  |  |  Branch (279:53): [Folded, False: 513]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    513|            bytes_in_buffer--; \
  |  |  164|    513|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    513|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    513|            bytes_in_buffer--; \
  |  |  167|    513|            V += *next_input_byte++; )
  ------------------
  449|    513|  length -= 2;
  450|       |
  451|  15.1k|  while (length > 16) {
  ------------------
  |  Branch (451:10): [True: 14.6k, False: 513]
  ------------------
  452|  14.6k|    INPUT_BYTE(cinfo, index, return FALSE);
  ------------------
  |  |  154|  14.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  14.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 14.6k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 14.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  14.6k|            bytes_in_buffer--; \
  |  |  156|  14.6k|            V = *next_input_byte++; )
  ------------------
  453|       |
  454|  14.6k|    TRACEMS1(cinfo, 1, JTRC_DHT, index);
  ------------------
  |  |  300|  14.6k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  14.6k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  14.6k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  455|       |
  456|  14.6k|    bits[0] = 0;
  457|  14.6k|    count = 0;
  458|   248k|    for (i = 1; i <= 16; i++) {
  ------------------
  |  Branch (458:17): [True: 234k, False: 14.6k]
  ------------------
  459|   234k|      INPUT_BYTE(cinfo, bits[i], return FALSE);
  ------------------
  |  |  154|   234k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   234k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 8]
  |  |  |  |  |  Branch (279:38): [True: 8, False: 234k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 234k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|   234k|            bytes_in_buffer--; \
  |  |  156|   234k|            V = *next_input_byte++; )
  ------------------
  460|   234k|      count += bits[i];
  461|   234k|    }
  462|       |
  463|  14.6k|    length -= 1 + 16;
  464|       |
  465|  14.6k|    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
  ------------------
  |  |  325|  14.6k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  14.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 14.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  326|  14.6k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  327|  14.6k|           _mp[4] = (p5);  _mp[5] = (p6);  _mp[6] = (p7);  _mp[7] = (p8); \
  |  |  328|  14.6k|           (cinfo)->err->msg_code = (code); \
  |  |  329|  14.6k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  466|  14.6k|             bits[1], bits[2], bits[3], bits[4],
  467|  14.6k|             bits[5], bits[6], bits[7], bits[8]);
  468|  14.6k|    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
  ------------------
  |  |  325|  14.6k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  14.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 14.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  326|  14.6k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  327|  14.6k|           _mp[4] = (p5);  _mp[5] = (p6);  _mp[6] = (p7);  _mp[7] = (p8); \
  |  |  328|  14.6k|           (cinfo)->err->msg_code = (code); \
  |  |  329|  14.6k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  469|  14.6k|             bits[9], bits[10], bits[11], bits[12],
  470|  14.6k|             bits[13], bits[14], bits[15], bits[16]);
  471|       |
  472|       |    /* Here we just do minimal validation of the counts to avoid walking
  473|       |     * off the end of our table space.  jdhuff.c will check more carefully.
  474|       |     */
  475|  14.6k|    if (count > 256 || ((JLONG)count) > length)
  ------------------
  |  Branch (475:9): [True: 75, False: 14.5k]
  |  Branch (475:24): [True: 0, False: 14.5k]
  ------------------
  476|     75|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|     75|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     75|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  477|       |
  478|  40.2k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (478:17): [True: 25.5k, False: 14.6k]
  ------------------
  479|  25.5k|      INPUT_BYTE(cinfo, huffval[i], return FALSE);
  ------------------
  |  |  154|  25.5k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  40.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 25.5k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  14.6k|            bytes_in_buffer--; \
  |  |  156|  14.6k|            V = *next_input_byte++; )
  ------------------
  480|       |
  481|  14.6k|    memset(&huffval[count], 0, (256 - count) * sizeof(UINT8));
  482|       |
  483|  14.6k|    length -= count;
  484|       |
  485|  14.6k|    if (index & 0x10) {         /* AC table definition */
  ------------------
  |  Branch (485:9): [True: 89, False: 14.5k]
  ------------------
  486|     89|      index -= 0x10;
  487|     89|      if (index < 0 || index >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|     89|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (487:11): [True: 0, False: 89]
  |  Branch (487:24): [True: 3, False: 86]
  ------------------
  488|      3|        ERREXIT1(cinfo, JERR_DHT_INDEX, index);
  ------------------
  |  |  243|      3|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      3|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      3|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  489|     89|      htblptr = &cinfo->ac_huff_tbl_ptrs[index];
  490|  14.5k|    } else {                    /* DC table definition */
  491|  14.5k|      if (index < 0 || index >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  14.4k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (491:11): [True: 75, False: 14.4k]
  |  Branch (491:24): [True: 8, False: 14.4k]
  ------------------
  492|      8|        ERREXIT1(cinfo, JERR_DHT_INDEX, index);
  ------------------
  |  |  243|      8|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      8|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      8|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  493|  14.5k|      htblptr = &cinfo->dc_huff_tbl_ptrs[index];
  494|  14.5k|    }
  495|       |
  496|  14.6k|    if (*htblptr == NULL)
  ------------------
  |  Branch (496:9): [True: 281, False: 14.3k]
  ------------------
  497|    281|      *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
  498|       |
  499|  14.6k|    memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
  500|  14.6k|    memcpy((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
  501|  14.6k|  }
  502|       |
  503|    513|  if (length != 0)
  ------------------
  |  Branch (503:7): [True: 169, False: 344]
  ------------------
  504|    169|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|    169|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    169|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  505|       |
  506|    513|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|    513|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|    513|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  507|    513|  return TRUE;
  ------------------
  |  |  210|    513|#define TRUE    1
  ------------------
  508|    513|}
jdmarker.c:get_dqt:
  514|  24.5k|{
  515|  24.5k|  JLONG length;
  516|  24.5k|  int n, i, prec;
  517|  24.5k|  unsigned int tmp;
  518|  24.5k|  JQUANT_TBL *quant_ptr;
  519|  24.5k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  24.5k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  24.5k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  24.5k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  520|       |
  521|  24.5k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  24.5k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  50.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 242]
  |  |  |  |  |  Branch (279:38): [True: 242, False: 24.2k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 175]
  |  |  |  |  |  Branch (279:38): [True: 175, False: 24.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 24.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  24.5k|            bytes_in_buffer--; \
  |  |  164|  24.5k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  24.5k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  24.5k|            bytes_in_buffer--; \
  |  |  167|  24.5k|            V += *next_input_byte++; )
  ------------------
  522|  24.5k|  length -= 2;
  523|       |
  524|  50.2k|  while (length > 0) {
  ------------------
  |  Branch (524:10): [True: 25.6k, False: 24.5k]
  ------------------
  525|  25.6k|    INPUT_BYTE(cinfo, n, return FALSE);
  ------------------
  |  |  154|  25.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  28.2k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 861]
  |  |  |  |  |  Branch (279:38): [True: 861, False: 24.8k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  25.6k|            bytes_in_buffer--; \
  |  |  156|  25.6k|            V = *next_input_byte++; )
  ------------------
  526|  25.6k|    prec = n >> 4;
  527|  25.6k|    n &= 0x0F;
  528|       |
  529|  25.6k|    TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
  ------------------
  |  |  304|  25.6k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  25.6k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  25.6k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  25.6k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  530|       |
  531|  25.6k|    if (n >= NUM_QUANT_TBLS)
  ------------------
  |  |   68|  25.6k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (531:9): [True: 1.24k, False: 24.4k]
  ------------------
  532|  1.24k|      ERREXIT1(cinfo, JERR_DQT_INDEX, n);
  ------------------
  |  |  243|  1.24k|  ((cinfo)->err->msg_code = (code), \
  |  |  244|  1.24k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|  1.24k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  533|       |
  534|  25.6k|    if (cinfo->quant_tbl_ptrs[n] == NULL)
  ------------------
  |  Branch (534:9): [True: 23.0k, False: 2.62k]
  ------------------
  535|  23.0k|      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
  536|  25.6k|    quant_ptr = cinfo->quant_tbl_ptrs[n];
  537|       |
  538|  1.58M|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  1.58M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (538:17): [True: 1.56M, False: 25.6k]
  ------------------
  539|  1.56M|      if (prec)
  ------------------
  |  Branch (539:11): [True: 44.7k, False: 1.51M]
  ------------------
  540|  1.56M|        INPUT_2BYTES(cinfo, tmp, return FALSE);
  ------------------
  |  |  162|  44.7k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   136k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 9.49k]
  |  |  |  |  |  Branch (279:38): [True: 9.49k, False: 35.2k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 6.13k]
  |  |  |  |  |  Branch (279:38): [True: 6.13k, False: 38.5k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 44.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  1.56M|            bytes_in_buffer--; \
  |  |  164|  1.56M|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  1.56M|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  1.56M|            bytes_in_buffer--; \
  |  |  167|  1.56M|            V += *next_input_byte++; )
  ------------------
  541|  1.51M|      else
  542|  1.56M|        INPUT_BYTE(cinfo, tmp, return FALSE);
  ------------------
  |  |  154|  1.51M|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.53M|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 6.32k]
  |  |  |  |  |  Branch (279:38): [True: 6.32k, False: 1.51M]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.51M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.56M|            bytes_in_buffer--; \
  |  |  156|  1.56M|            V = *next_input_byte++; )
  ------------------
  543|       |      /* We convert the zigzag-order table to natural array order. */
  544|  1.56M|      quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16)tmp;
  545|  1.56M|    }
  546|       |
  547|  25.6k|    if (cinfo->err->trace_level >= 2) {
  ------------------
  |  Branch (547:9): [True: 0, False: 25.6k]
  ------------------
  548|      0|      for (i = 0; i < DCTSIZE2; i += 8) {
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (548:19): [True: 0, False: 0]
  ------------------
  549|      0|        TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
  ------------------
  |  |  325|      0|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|      0|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  326|      0|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  327|      0|           _mp[4] = (p5);  _mp[5] = (p6);  _mp[6] = (p7);  _mp[7] = (p8); \
  |  |  328|      0|           (cinfo)->err->msg_code = (code); \
  |  |  329|      0|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  550|      0|                 quant_ptr->quantval[i],     quant_ptr->quantval[i + 1],
  551|      0|                 quant_ptr->quantval[i + 2], quant_ptr->quantval[i + 3],
  552|      0|                 quant_ptr->quantval[i + 4], quant_ptr->quantval[i + 5],
  553|      0|                 quant_ptr->quantval[i + 6], quant_ptr->quantval[i + 7]);
  554|      0|      }
  555|      0|    }
  556|       |
  557|  25.6k|    length -= DCTSIZE2 + 1;
  ------------------
  |  |   67|  25.6k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  558|  25.6k|    if (prec) length -= DCTSIZE2;
  ------------------
  |  |   67|    699|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (558:9): [True: 699, False: 24.9k]
  ------------------
  559|  25.6k|  }
  560|       |
  561|  24.5k|  if (length != 0)
  ------------------
  |  Branch (561:7): [True: 147, False: 24.3k]
  ------------------
  562|    147|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|    147|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    147|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|       |
  564|  24.5k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  24.5k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  24.5k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  565|  24.5k|  return TRUE;
  ------------------
  |  |  210|  24.5k|#define TRUE    1
  ------------------
  566|  24.5k|}
jdmarker.c:get_dri:
  572|  16.3k|{
  573|  16.3k|  JLONG length;
  574|  16.3k|  unsigned int tmp;
  575|  16.3k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  16.3k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  16.3k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  16.3k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  576|       |
  577|  16.3k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  16.3k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  33.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 188]
  |  |  |  |  |  Branch (279:38): [True: 188, False: 16.2k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 145]
  |  |  |  |  |  Branch (279:38): [True: 145, False: 16.2k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 16.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  16.3k|            bytes_in_buffer--; \
  |  |  164|  16.3k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  16.3k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  16.3k|            bytes_in_buffer--; \
  |  |  167|  16.3k|            V += *next_input_byte++; )
  ------------------
  578|       |
  579|  16.3k|  if (length != 4)
  ------------------
  |  Branch (579:7): [True: 751, False: 15.6k]
  ------------------
  580|    751|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|    751|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    751|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  581|       |
  582|  16.3k|  INPUT_2BYTES(cinfo, tmp, return FALSE);
  ------------------
  |  |  162|  16.3k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  32.7k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 16.3k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 16.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 16.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  16.3k|            bytes_in_buffer--; \
  |  |  164|  16.3k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  16.3k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  16.3k|            bytes_in_buffer--; \
  |  |  167|  16.3k|            V += *next_input_byte++; )
  ------------------
  583|       |
  584|  16.3k|  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
  ------------------
  |  |  300|  16.3k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  16.3k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  16.3k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  585|       |
  586|  16.3k|  cinfo->restart_interval = tmp;
  587|       |
  588|  16.3k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  16.3k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  16.3k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  589|  16.3k|  return TRUE;
  ------------------
  |  |  210|  16.3k|#define TRUE    1
  ------------------
  590|  16.3k|}
jdmarker.c:read_restart_marker:
 1139|  41.5k|{
 1140|       |  /* Obtain a marker unless we already did. */
 1141|       |  /* Note that next_marker will complain if it skips any data. */
 1142|  41.5k|  if (cinfo->unread_marker == 0) {
  ------------------
  |  Branch (1142:7): [True: 7.23k, False: 34.3k]
  ------------------
 1143|  7.23k|    if (!next_marker(cinfo))
  ------------------
  |  Branch (1143:9): [True: 0, False: 7.23k]
  ------------------
 1144|      0|      return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1145|  7.23k|  }
 1146|       |
 1147|  41.5k|  if (cinfo->unread_marker ==
  ------------------
  |  Branch (1147:7): [True: 7.56k, False: 34.0k]
  ------------------
 1148|  41.5k|      ((int)M_RST0 + cinfo->marker->next_restart_num)) {
 1149|       |    /* Normal case --- swallow the marker and let entropy decoder continue */
 1150|  7.56k|    TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
  ------------------
  |  |  300|  7.56k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  7.56k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  7.56k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1151|  7.56k|    cinfo->unread_marker = 0;
 1152|  34.0k|  } else {
 1153|       |    /* Uh-oh, the restart markers have been messed up. */
 1154|       |    /* Let the data source manager determine how to resync. */
 1155|  34.0k|    if (!(*cinfo->src->resync_to_restart) (cinfo,
  ------------------
  |  Branch (1155:9): [True: 0, False: 34.0k]
  ------------------
 1156|  34.0k|                                           cinfo->marker->next_restart_num))
 1157|      0|      return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1158|  34.0k|  }
 1159|       |
 1160|       |  /* Update next-restart state */
 1161|  41.5k|  cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
 1162|       |
 1163|  41.5k|  return TRUE;
  ------------------
  |  |  210|  41.5k|#define TRUE    1
  ------------------
 1164|  41.5k|}
jdmarker.c:skip_variable:
  864|  16.7k|{
  865|  16.7k|  JLONG length;
  866|  16.7k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  16.7k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  16.7k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  16.7k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  867|       |
  868|  16.7k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  16.7k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  34.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 26]
  |  |  |  |  |  Branch (279:38): [True: 26, False: 16.6k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 272]
  |  |  |  |  |  Branch (279:38): [True: 272, False: 16.4k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 16.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  16.7k|            bytes_in_buffer--; \
  |  |  164|  16.7k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  16.7k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  16.7k|            bytes_in_buffer--; \
  |  |  167|  16.7k|            V += *next_input_byte++; )
  ------------------
  869|  16.7k|  length -= 2;
  870|       |
  871|  16.7k|  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int)length);
  ------------------
  |  |  304|  16.7k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  16.7k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  16.7k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  16.7k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  872|       |
  873|  16.7k|  INPUT_SYNC(cinfo);            /* do before skip_input_data */
  ------------------
  |  |  131|  16.7k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  16.7k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  874|  16.7k|  if (length > 0)
  ------------------
  |  Branch (874:7): [True: 10.8k, False: 5.84k]
  ------------------
  875|  10.8k|    (*cinfo->src->skip_input_data) (cinfo, (long)length);
  876|       |
  877|  16.7k|  return TRUE;
  ------------------
  |  |  210|  16.7k|#define TRUE    1
  ------------------
  878|  16.7k|}
jdmarker.c:get_interesting_appn:
  712|  18.1k|{
  713|  18.1k|  JLONG length;
  714|  18.1k|  JOCTET b[APPN_DATA_LEN];
  715|  18.1k|  unsigned int i, numtoread;
  716|  18.1k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  18.1k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  18.1k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  18.1k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  717|       |
  718|  18.1k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  18.1k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  37.4k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 230]
  |  |  |  |  |  Branch (279:38): [True: 230, False: 17.9k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 147]
  |  |  |  |  |  Branch (279:38): [True: 147, False: 18.0k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 18.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  18.1k|            bytes_in_buffer--; \
  |  |  164|  18.1k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  18.1k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  18.1k|            bytes_in_buffer--; \
  |  |  167|  18.1k|            V += *next_input_byte++; )
  ------------------
  719|  18.1k|  length -= 2;
  720|       |
  721|       |  /* get the interesting part of the marker data */
  722|  18.1k|  if (length >= APPN_DATA_LEN)
  ------------------
  |  |  602|  18.1k|#define APPN_DATA_LEN   14      /* Must be the largest of the above!! */
  ------------------
  |  Branch (722:7): [True: 14.6k, False: 3.52k]
  ------------------
  723|  14.6k|    numtoread = APPN_DATA_LEN;
  ------------------
  |  |  602|  14.6k|#define APPN_DATA_LEN   14      /* Must be the largest of the above!! */
  ------------------
  724|  3.52k|  else if (length > 0)
  ------------------
  |  Branch (724:12): [True: 2.55k, False: 968]
  ------------------
  725|  2.55k|    numtoread = (unsigned int)length;
  726|    968|  else
  727|    968|    numtoread = 0;
  728|   236k|  for (i = 0; i < numtoread; i++)
  ------------------
  |  Branch (728:15): [True: 218k, False: 18.1k]
  ------------------
  729|   218k|    INPUT_BYTE(cinfo, b[i], return FALSE);
  ------------------
  |  |  154|   218k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   236k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 2.87k]
  |  |  |  |  |  Branch (279:38): [True: 2.87k, False: 215k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 218k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  18.1k|            bytes_in_buffer--; \
  |  |  156|  18.1k|            V = *next_input_byte++; )
  ------------------
  730|  18.1k|  length -= numtoread;
  731|       |
  732|       |  /* process it */
  733|  18.1k|  switch (cinfo->unread_marker) {
  734|  14.4k|  case M_APP0:
  ------------------
  |  Branch (734:3): [True: 14.4k, False: 3.69k]
  ------------------
  735|  14.4k|    examine_app0(cinfo, (JOCTET *)b, numtoread, length);
  736|  14.4k|    break;
  737|  3.69k|  case M_APP14:
  ------------------
  |  Branch (737:3): [True: 3.69k, False: 14.4k]
  ------------------
  738|  3.69k|    examine_app14(cinfo, (JOCTET *)b, numtoread, length);
  739|  3.69k|    break;
  740|      0|  default:
  ------------------
  |  Branch (740:3): [True: 0, False: 18.1k]
  ------------------
  741|       |    /* can't get here unless jpeg_save_markers chooses wrong processor */
  742|      0|    ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  743|      0|    break;
  744|  18.1k|  }
  745|       |
  746|       |  /* skip any remaining data -- could be lots */
  747|  18.1k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  18.1k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  18.1k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  748|  18.1k|  if (length > 0)
  ------------------
  |  Branch (748:7): [True: 3.30k, False: 14.8k]
  ------------------
  749|  3.30k|    (*cinfo->src->skip_input_data) (cinfo, (long)length);
  750|       |
  751|  18.1k|  return TRUE;
  ------------------
  |  |  210|  18.1k|#define TRUE    1
  ------------------
  752|  18.1k|}
jdmarker.c:examine_app0:
  612|  14.4k|{
  613|  14.4k|  JLONG totallen = (JLONG)datalen + remaining;
  614|       |
  615|  14.4k|  if (datalen >= APP0_DATA_LEN &&
  ------------------
  |  |  600|  28.9k|#define APP0_DATA_LEN   14      /* Length of interesting data in APP0 */
  ------------------
  |  Branch (615:7): [True: 11.7k, False: 2.75k]
  ------------------
  616|  11.7k|      data[0] == 0x4A &&
  ------------------
  |  Branch (616:7): [True: 5.60k, False: 6.10k]
  ------------------
  617|  5.60k|      data[1] == 0x46 &&
  ------------------
  |  Branch (617:7): [True: 5.09k, False: 511]
  ------------------
  618|  5.09k|      data[2] == 0x49 &&
  ------------------
  |  Branch (618:7): [True: 1.65k, False: 3.43k]
  ------------------
  619|  1.65k|      data[3] == 0x46 &&
  ------------------
  |  Branch (619:7): [True: 1.40k, False: 250]
  ------------------
  620|  1.40k|      data[4] == 0) {
  ------------------
  |  Branch (620:7): [True: 1.07k, False: 332]
  ------------------
  621|       |    /* Found JFIF APP0 marker: save info */
  622|  1.07k|    cinfo->saw_JFIF_marker = TRUE;
  ------------------
  |  |  210|  1.07k|#define TRUE    1
  ------------------
  623|  1.07k|    cinfo->JFIF_major_version = data[5];
  624|  1.07k|    cinfo->JFIF_minor_version = data[6];
  625|  1.07k|    cinfo->density_unit = data[7];
  626|  1.07k|    cinfo->X_density = (data[8] << 8) + data[9];
  627|  1.07k|    cinfo->Y_density = (data[10] << 8) + data[11];
  628|       |    /* Check version.
  629|       |     * Major version must be 1, anything else signals an incompatible change.
  630|       |     * (We used to treat this as an error, but now it's a nonfatal warning,
  631|       |     * because some bozo at Hijaak couldn't read the spec.)
  632|       |     * Minor version should be 0..2, but process anyway if newer.
  633|       |     */
  634|  1.07k|    if (cinfo->JFIF_major_version != 1)
  ------------------
  |  Branch (634:9): [True: 382, False: 694]
  ------------------
  635|    382|      WARNMS2(cinfo, JWRN_JFIF_MAJOR,
  ------------------
  |  |  290|    382|  ((cinfo)->err->msg_code = (code), \
  |  |  291|    382|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  292|    382|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  293|    382|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  636|  1.07k|              cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
  637|       |    /* Generate trace messages */
  638|  1.07k|    TRACEMS5(cinfo, 1, JTRC_JFIF,
  ------------------
  |  |  319|  1.07k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.07k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  320|  1.07k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  321|  1.07k|           _mp[4] = (p5); \
  |  |  322|  1.07k|           (cinfo)->err->msg_code = (code); \
  |  |  323|  1.07k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  639|  1.07k|             cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
  640|  1.07k|             cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
  641|       |    /* Validate thumbnail dimensions and issue appropriate messages */
  642|  1.07k|    if (data[12] | data[13])
  ------------------
  |  Branch (642:9): [True: 706, False: 370]
  ------------------
  643|    706|      TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, data[12], data[13]);
  ------------------
  |  |  304|    706|  ((cinfo)->err->msg_code = (code), \
  |  |  305|    706|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|    706|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|    706|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  644|  1.07k|    totallen -= APP0_DATA_LEN;
  ------------------
  |  |  600|  1.07k|#define APP0_DATA_LEN   14      /* Length of interesting data in APP0 */
  ------------------
  645|  1.07k|    if (totallen != ((JLONG)data[12] * (JLONG)data[13] * (JLONG)3))
  ------------------
  |  Branch (645:9): [True: 498, False: 578]
  ------------------
  646|    498|      TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)totallen);
  ------------------
  |  |  300|    498|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    498|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    498|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  647|  13.3k|  } else if (datalen >= 6 &&
  ------------------
  |  Branch (647:14): [True: 10.7k, False: 2.60k]
  ------------------
  648|  10.7k|             data[0] == 0x4A &&
  ------------------
  |  Branch (648:14): [True: 4.54k, False: 6.23k]
  ------------------
  649|  4.54k|             data[1] == 0x46 &&
  ------------------
  |  Branch (649:14): [True: 4.03k, False: 511]
  ------------------
  650|  4.03k|             data[2] == 0x58 &&
  ------------------
  |  Branch (650:14): [True: 1.96k, False: 2.07k]
  ------------------
  651|  1.96k|             data[3] == 0x58 &&
  ------------------
  |  Branch (651:14): [True: 1.17k, False: 788]
  ------------------
  652|  1.17k|             data[4] == 0) {
  ------------------
  |  Branch (652:14): [True: 909, False: 264]
  ------------------
  653|       |    /* Found JFIF "JFXX" extension APP0 marker */
  654|       |    /* The library doesn't actually do anything with these,
  655|       |     * but we try to produce a helpful trace message.
  656|       |     */
  657|    909|    switch (data[5]) {
  658|    196|    case 0x10:
  ------------------
  |  Branch (658:5): [True: 196, False: 713]
  ------------------
  659|    196|      TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int)totallen);
  ------------------
  |  |  300|    196|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    196|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    196|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  660|    196|      break;
  661|    256|    case 0x11:
  ------------------
  |  Branch (661:5): [True: 256, False: 653]
  ------------------
  662|    256|      TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int)totallen);
  ------------------
  |  |  300|    256|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    256|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    256|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  663|    256|      break;
  664|    196|    case 0x13:
  ------------------
  |  Branch (664:5): [True: 196, False: 713]
  ------------------
  665|    196|      TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int)totallen);
  ------------------
  |  |  300|    196|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    196|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    196|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  666|    196|      break;
  667|    261|    default:
  ------------------
  |  Branch (667:5): [True: 261, False: 648]
  ------------------
  668|    261|      TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, data[5], (int)totallen);
  ------------------
  |  |  304|    261|  ((cinfo)->err->msg_code = (code), \
  |  |  305|    261|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|    261|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|    261|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  669|    261|      break;
  670|    909|    }
  671|  12.4k|  } else {
  672|       |    /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
  673|  12.4k|    TRACEMS1(cinfo, 1, JTRC_APP0, (int)totallen);
  ------------------
  |  |  300|  12.4k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  12.4k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  12.4k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  674|  12.4k|  }
  675|  14.4k|}
jdmarker.c:examine_app14:
  685|  3.69k|{
  686|  3.69k|  unsigned int version, flags0, flags1, transform;
  687|       |
  688|  3.69k|  if (datalen >= APP14_DATA_LEN &&
  ------------------
  |  |  601|  7.39k|#define APP14_DATA_LEN  12      /* Length of interesting data in APP14 */
  ------------------
  |  Branch (688:7): [True: 2.93k, False: 764]
  ------------------
  689|  2.93k|      data[0] == 0x41 &&
  ------------------
  |  Branch (689:7): [True: 1.83k, False: 1.10k]
  ------------------
  690|  1.83k|      data[1] == 0x64 &&
  ------------------
  |  Branch (690:7): [True: 1.59k, False: 233]
  ------------------
  691|  1.59k|      data[2] == 0x6F &&
  ------------------
  |  Branch (691:7): [True: 618, False: 981]
  ------------------
  692|    618|      data[3] == 0x62 &&
  ------------------
  |  Branch (692:7): [True: 434, False: 184]
  ------------------
  693|    434|      data[4] == 0x65) {
  ------------------
  |  Branch (693:7): [True: 188, False: 246]
  ------------------
  694|       |    /* Found Adobe APP14 marker */
  695|    188|    version = (data[5] << 8) + data[6];
  696|    188|    flags0 = (data[7] << 8) + data[8];
  697|    188|    flags1 = (data[9] << 8) + data[10];
  698|    188|    transform = data[11];
  699|    188|    TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
  ------------------
  |  |  314|    188|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    188|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 188]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|    188|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|    188|           (cinfo)->err->msg_code = (code); \
  |  |  317|    188|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  700|    188|    cinfo->saw_Adobe_marker = TRUE;
  ------------------
  |  |  210|    188|#define TRUE    1
  ------------------
  701|    188|    cinfo->Adobe_transform = (UINT8)transform;
  702|  3.51k|  } else {
  703|       |    /* Start of APP14 does not match "Adobe", or too short */
  704|  3.51k|    TRACEMS1(cinfo, 1, JTRC_APP14, (int)(datalen + remaining));
  ------------------
  |  |  300|  3.51k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  3.51k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  3.51k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  705|  3.51k|  }
  706|  3.69k|}

jpeg_calc_output_dimensions:
  269|  22.8k|{
  270|  22.8k|#ifdef IDCT_SCALING_SUPPORTED
  271|  22.8k|  int ci;
  272|  22.8k|  jpeg_component_info *compptr;
  273|  22.8k|#endif
  274|       |
  275|       |  /* Prevent application from calling me at wrong times */
  276|  22.8k|  if (cinfo->global_state != DSTATE_READY)
  ------------------
  |  |   50|  22.8k|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (276:7): [True: 0, False: 22.8k]
  ------------------
  277|      0|    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  278|       |
  279|       |  /* Compute core output image dimensions and DCT scaling choices. */
  280|  22.8k|  jpeg_core_output_dimensions(cinfo);
  281|       |
  282|  22.8k|#ifdef IDCT_SCALING_SUPPORTED
  283|       |
  284|  22.8k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (284:7): [True: 22.8k, False: 9]
  ------------------
  285|       |    /* In selecting the actual DCT scaling for each component, we try to
  286|       |     * scale up the chroma components via IDCT scaling rather than upsampling.
  287|       |     * This saves time if the upsampler gets to use 1:1 scaling.
  288|       |     * Note this code adapts subsampling ratios which are powers of 2.
  289|       |     */
  290|  45.7k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (290:46): [True: 22.9k, False: 22.8k]
  ------------------
  291|  22.9k|         ci++, compptr++) {
  292|  22.9k|      int ssize = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  22.9k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  293|  22.9k|      while (ssize < DCTSIZE &&
  ------------------
  |  |   66|  45.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (293:14): [True: 0, False: 22.9k]
  ------------------
  294|      0|             ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (294:14): [True: 0, False: 0]
  ------------------
  295|      0|              (compptr->h_samp_factor * ssize * 2) == 0) &&
  296|      0|             ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (296:14): [True: 0, False: 0]
  ------------------
  297|      0|              (compptr->v_samp_factor * ssize * 2) == 0)) {
  298|      0|        ssize = ssize * 2;
  299|      0|      }
  300|       |#if JPEG_LIB_VERSION >= 70
  301|       |      compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
  302|       |#else
  303|  22.9k|      compptr->DCT_scaled_size = ssize;
  304|  22.9k|#endif
  305|  22.9k|    }
  306|       |
  307|       |    /* Recompute downsampled dimensions of components;
  308|       |     * application needs to know these if using raw downsampled data.
  309|       |     */
  310|  45.7k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:46): [True: 22.9k, False: 22.8k]
  ------------------
  311|  22.9k|         ci++, compptr++) {
  312|       |      /* Size in samples, after IDCT scaling */
  313|  22.9k|      compptr->downsampled_width = (JDIMENSION)
  314|  22.9k|        jdiv_round_up((long)cinfo->image_width *
  315|  22.9k|                      (long)(compptr->h_samp_factor *
  316|  22.9k|                             compptr->_DCT_scaled_size),
  ------------------
  |  |   24|  22.9k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  317|  22.9k|                      (long)(cinfo->max_h_samp_factor * DCTSIZE));
  ------------------
  |  |   66|  22.9k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  318|  22.9k|      compptr->downsampled_height = (JDIMENSION)
  319|  22.9k|        jdiv_round_up((long)cinfo->image_height *
  320|  22.9k|                      (long)(compptr->v_samp_factor *
  321|  22.9k|                             compptr->_DCT_scaled_size),
  ------------------
  |  |   24|  22.9k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  322|  22.9k|                      (long)(cinfo->max_v_samp_factor * DCTSIZE));
  ------------------
  |  |   66|  22.9k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  323|  22.9k|    }
  324|  22.8k|  } else
  325|      9|#endif /* IDCT_SCALING_SUPPORTED */
  326|      9|  {
  327|       |    /* Hardwire it to "no scaling" */
  328|      9|    cinfo->output_width = cinfo->image_width;
  329|      9|    cinfo->output_height = cinfo->image_height;
  330|       |    /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
  331|       |     * and has computed unscaled downsampled_width and downsampled_height.
  332|       |     */
  333|      9|  }
  334|       |
  335|       |  /* Report number of components in selected colorspace. */
  336|       |  /* Probably this should be in the color conversion module... */
  337|  22.8k|  switch (cinfo->out_color_space) {
  338|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (338:3): [True: 0, False: 22.8k]
  ------------------
  339|      0|    cinfo->out_color_components = 1;
  340|      0|    break;
  341|     41|  case JCS_RGB:
  ------------------
  |  Branch (341:3): [True: 41, False: 22.8k]
  ------------------
  342|     41|  case JCS_EXT_RGB:
  ------------------
  |  Branch (342:3): [True: 0, False: 22.8k]
  ------------------
  343|     41|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (343:3): [True: 0, False: 22.8k]
  ------------------
  344|     41|  case JCS_EXT_BGR:
  ------------------
  |  Branch (344:3): [True: 0, False: 22.8k]
  ------------------
  345|     41|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (345:3): [True: 0, False: 22.8k]
  ------------------
  346|     41|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (346:3): [True: 0, False: 22.8k]
  ------------------
  347|     41|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (347:3): [True: 0, False: 22.8k]
  ------------------
  348|     41|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (348:3): [True: 0, False: 22.8k]
  ------------------
  349|     41|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (349:3): [True: 0, False: 22.8k]
  ------------------
  350|     41|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (350:3): [True: 0, False: 22.8k]
  ------------------
  351|     41|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (351:3): [True: 0, False: 22.8k]
  ------------------
  352|     41|    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
  353|     41|    break;
  354|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (354:3): [True: 0, False: 22.8k]
  ------------------
  355|      0|  case JCS_RGB565:
  ------------------
  |  Branch (355:3): [True: 0, False: 22.8k]
  ------------------
  356|      0|    cinfo->out_color_components = 3;
  357|      0|    break;
  358|      0|  case JCS_CMYK:
  ------------------
  |  Branch (358:3): [True: 0, False: 22.8k]
  ------------------
  359|      0|  case JCS_YCCK:
  ------------------
  |  Branch (359:3): [True: 0, False: 22.8k]
  ------------------
  360|      0|    cinfo->out_color_components = 4;
  361|      0|    break;
  362|  22.8k|  default:                      /* else must be same colorspace as in file */
  ------------------
  |  Branch (362:3): [True: 22.8k, False: 41]
  ------------------
  363|  22.8k|    cinfo->out_color_components = cinfo->num_components;
  364|  22.8k|    break;
  365|  22.8k|  }
  366|  22.8k|  cinfo->output_components = (cinfo->quantize_colors ? 1 :
  ------------------
  |  Branch (366:31): [True: 0, False: 22.8k]
  ------------------
  367|  22.8k|                              cinfo->out_color_components);
  368|       |
  369|       |  /* See if upsampler will want to emit more than one row at a time */
  370|  22.8k|  if (use_merged_upsample(cinfo))
  ------------------
  |  Branch (370:7): [True: 0, False: 22.8k]
  ------------------
  371|      0|    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
  372|  22.8k|  else
  373|  22.8k|    cinfo->rec_outbuf_height = 1;
  374|  22.8k|}
jinit_master_decompress:
  902|  22.8k|{
  903|  22.8k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  904|       |
  905|       |#ifdef WITH_PROFILE
  906|       |  master->pub.total_start = getTime();
  907|       |#endif
  908|       |
  909|  22.8k|  master->pub.prepare_for_output_pass = prepare_for_output_pass;
  910|  22.8k|  master->pub.finish_output_pass = finish_output_pass;
  911|       |
  912|  22.8k|  master->pub.is_dummy_pass = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  913|  22.8k|  master->pub.jinit_upsampler_no_alloc = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  914|       |
  915|  22.8k|  master_selection(cinfo);
  916|  22.8k|}
jdmaster.c:jpeg_core_output_dimensions:
  103|  22.8k|{
  104|  22.8k|#ifdef IDCT_SCALING_SUPPORTED
  105|  22.8k|  int ci;
  106|  22.8k|  jpeg_component_info *compptr;
  107|       |
  108|  22.8k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (108:7): [True: 22.8k, False: 9]
  ------------------
  109|       |    /* Compute actual output image dimensions and DCT scaling choices. */
  110|  22.8k|    if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (110:9): [True: 0, False: 22.8k]
  ------------------
  111|       |      /* Provide 1/block_size scaling */
  112|      0|      cinfo->output_width = (JDIMENSION)
  113|      0|        jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  114|      0|      cinfo->output_height = (JDIMENSION)
  115|      0|        jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  116|      0|      cinfo->_min_DCT_h_scaled_size = 1;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  117|      0|      cinfo->_min_DCT_v_scaled_size = 1;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  118|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (118:16): [True: 0, False: 22.8k]
  ------------------
  119|       |      /* Provide 2/block_size scaling */
  120|      0|      cinfo->output_width = (JDIMENSION)
  121|      0|        jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  122|      0|      cinfo->output_height = (JDIMENSION)
  123|      0|        jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  124|      0|      cinfo->_min_DCT_h_scaled_size = 2;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  125|      0|      cinfo->_min_DCT_v_scaled_size = 2;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  126|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (126:16): [True: 0, False: 22.8k]
  ------------------
  127|       |      /* Provide 3/block_size scaling */
  128|      0|      cinfo->output_width = (JDIMENSION)
  129|      0|        jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  130|      0|      cinfo->output_height = (JDIMENSION)
  131|      0|        jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  132|      0|      cinfo->_min_DCT_h_scaled_size = 3;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  133|      0|      cinfo->_min_DCT_v_scaled_size = 3;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  134|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (134:16): [True: 0, False: 22.8k]
  ------------------
  135|       |      /* Provide 4/block_size scaling */
  136|      0|      cinfo->output_width = (JDIMENSION)
  137|      0|        jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  138|      0|      cinfo->output_height = (JDIMENSION)
  139|      0|        jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  140|      0|      cinfo->_min_DCT_h_scaled_size = 4;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  141|      0|      cinfo->_min_DCT_v_scaled_size = 4;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  142|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (142:16): [True: 0, False: 22.8k]
  ------------------
  143|       |      /* Provide 5/block_size scaling */
  144|      0|      cinfo->output_width = (JDIMENSION)
  145|      0|        jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  146|      0|      cinfo->output_height = (JDIMENSION)
  147|      0|        jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  148|      0|      cinfo->_min_DCT_h_scaled_size = 5;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  149|      0|      cinfo->_min_DCT_v_scaled_size = 5;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  150|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (150:16): [True: 0, False: 22.8k]
  ------------------
  151|       |      /* Provide 6/block_size scaling */
  152|      0|      cinfo->output_width = (JDIMENSION)
  153|      0|        jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  154|      0|      cinfo->output_height = (JDIMENSION)
  155|      0|        jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  156|      0|      cinfo->_min_DCT_h_scaled_size = 6;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  157|      0|      cinfo->_min_DCT_v_scaled_size = 6;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  158|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:16): [True: 0, False: 22.8k]
  ------------------
  159|       |      /* Provide 7/block_size scaling */
  160|      0|      cinfo->output_width = (JDIMENSION)
  161|      0|        jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  162|      0|      cinfo->output_height = (JDIMENSION)
  163|      0|        jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  164|      0|      cinfo->_min_DCT_h_scaled_size = 7;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  165|      0|      cinfo->_min_DCT_v_scaled_size = 7;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  166|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (166:16): [True: 22.8k, False: 0]
  ------------------
  167|       |      /* Provide 8/block_size scaling */
  168|  22.8k|      cinfo->output_width = (JDIMENSION)
  169|  22.8k|        jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  170|  22.8k|      cinfo->output_height = (JDIMENSION)
  171|  22.8k|        jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
  ------------------
  |  |   66|  22.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  172|  22.8k|      cinfo->_min_DCT_h_scaled_size = 8;
  ------------------
  |  |   28|  22.8k|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  173|  22.8k|      cinfo->_min_DCT_v_scaled_size = 8;
  ------------------
  |  |   29|  22.8k|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  174|  22.8k|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (174:16): [True: 0, False: 0]
  ------------------
  175|       |      /* Provide 9/block_size scaling */
  176|      0|      cinfo->output_width = (JDIMENSION)
  177|      0|        jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  178|      0|      cinfo->output_height = (JDIMENSION)
  179|      0|        jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  180|      0|      cinfo->_min_DCT_h_scaled_size = 9;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  181|      0|      cinfo->_min_DCT_v_scaled_size = 9;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  182|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (182:16): [True: 0, False: 0]
  ------------------
  183|       |      /* Provide 10/block_size scaling */
  184|      0|      cinfo->output_width = (JDIMENSION)
  185|      0|        jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  186|      0|      cinfo->output_height = (JDIMENSION)
  187|      0|        jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  188|      0|      cinfo->_min_DCT_h_scaled_size = 10;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  189|      0|      cinfo->_min_DCT_v_scaled_size = 10;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  190|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (190:16): [True: 0, False: 0]
  ------------------
  191|       |      /* Provide 11/block_size scaling */
  192|      0|      cinfo->output_width = (JDIMENSION)
  193|      0|        jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  194|      0|      cinfo->output_height = (JDIMENSION)
  195|      0|        jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  196|      0|      cinfo->_min_DCT_h_scaled_size = 11;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  197|      0|      cinfo->_min_DCT_v_scaled_size = 11;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  198|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (198:16): [True: 0, False: 0]
  ------------------
  199|       |      /* Provide 12/block_size scaling */
  200|      0|      cinfo->output_width = (JDIMENSION)
  201|      0|        jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  202|      0|      cinfo->output_height = (JDIMENSION)
  203|      0|        jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  204|      0|      cinfo->_min_DCT_h_scaled_size = 12;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  205|      0|      cinfo->_min_DCT_v_scaled_size = 12;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  206|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (206:16): [True: 0, False: 0]
  ------------------
  207|       |      /* Provide 13/block_size scaling */
  208|      0|      cinfo->output_width = (JDIMENSION)
  209|      0|        jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  210|      0|      cinfo->output_height = (JDIMENSION)
  211|      0|        jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  212|      0|      cinfo->_min_DCT_h_scaled_size = 13;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  213|      0|      cinfo->_min_DCT_v_scaled_size = 13;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  214|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (214:16): [True: 0, False: 0]
  ------------------
  215|       |      /* Provide 14/block_size scaling */
  216|      0|      cinfo->output_width = (JDIMENSION)
  217|      0|        jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  218|      0|      cinfo->output_height = (JDIMENSION)
  219|      0|        jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  220|      0|      cinfo->_min_DCT_h_scaled_size = 14;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  221|      0|      cinfo->_min_DCT_v_scaled_size = 14;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  222|      0|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (222:16): [True: 0, False: 0]
  ------------------
  223|       |      /* Provide 15/block_size scaling */
  224|      0|      cinfo->output_width = (JDIMENSION)
  225|      0|        jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  226|      0|      cinfo->output_height = (JDIMENSION)
  227|      0|        jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  228|      0|      cinfo->_min_DCT_h_scaled_size = 15;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  229|      0|      cinfo->_min_DCT_v_scaled_size = 15;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  230|      0|    } else {
  231|       |      /* Provide 16/block_size scaling */
  232|      0|      cinfo->output_width = (JDIMENSION)
  233|      0|        jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  234|      0|      cinfo->output_height = (JDIMENSION)
  235|      0|        jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  236|      0|      cinfo->_min_DCT_h_scaled_size = 16;
  ------------------
  |  |   28|      0|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  237|      0|      cinfo->_min_DCT_v_scaled_size = 16;
  ------------------
  |  |   29|      0|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  238|      0|    }
  239|       |
  240|       |    /* Recompute dimensions of components */
  241|  45.7k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (241:46): [True: 22.9k, False: 22.8k]
  ------------------
  242|  22.9k|         ci++, compptr++) {
  243|  22.9k|      compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
  ------------------
  |  |   25|  22.9k|#define _DCT_h_scaled_size  DCT_scaled_size
  ------------------
                    compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
  ------------------
  |  |   28|  22.9k|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  244|  22.9k|      compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
  ------------------
  |  |   26|  22.9k|#define _DCT_v_scaled_size  DCT_scaled_size
  ------------------
                    compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
  ------------------
  |  |   29|  22.9k|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  245|  22.9k|    }
  246|  22.8k|  } else
  247|      9|#endif /* !IDCT_SCALING_SUPPORTED */
  248|      9|  {
  249|       |    /* Hardwire it to "no scaling" */
  250|      9|    cinfo->output_width = cinfo->image_width;
  251|      9|    cinfo->output_height = cinfo->image_height;
  252|       |    /* jdinput.c has already initialized DCT_scaled_size,
  253|       |     * and has computed unscaled downsampled_width and downsampled_height.
  254|       |     */
  255|      9|  }
  256|  22.8k|}
jdmaster.c:use_merged_upsample:
   39|  45.7k|{
   40|  45.7k|#ifdef UPSAMPLE_MERGING_SUPPORTED
   41|       |  /* Colorspace conversion is not supported with lossless JPEG images */
   42|  45.7k|  if (cinfo->master->lossless)
  ------------------
  |  Branch (42:7): [True: 18, False: 45.6k]
  ------------------
   43|     18|    return FALSE;
  ------------------
  |  |  207|     18|#define FALSE   0               /* values of boolean */
  ------------------
   44|       |  /* Merging is the equivalent of plain box-filter upsampling */
   45|  45.6k|  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
  ------------------
  |  Branch (45:7): [True: 45.6k, False: 0]
  |  Branch (45:37): [True: 0, False: 0]
  ------------------
   46|  45.6k|    return FALSE;
  ------------------
  |  |  207|  45.6k|#define FALSE   0               /* values of boolean */
  ------------------
   47|       |  /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
   48|      0|  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
  ------------------
  |  Branch (48:7): [True: 0, False: 0]
  |  Branch (48:47): [True: 0, False: 0]
  ------------------
   49|      0|      (cinfo->out_color_space != JCS_RGB &&
  ------------------
  |  Branch (49:8): [True: 0, False: 0]
  ------------------
   50|      0|       cinfo->out_color_space != JCS_RGB565 &&
  ------------------
  |  Branch (50:8): [True: 0, False: 0]
  ------------------
   51|      0|       cinfo->out_color_space != JCS_EXT_RGB &&
  ------------------
  |  Branch (51:8): [True: 0, False: 0]
  ------------------
   52|      0|       cinfo->out_color_space != JCS_EXT_RGBX &&
  ------------------
  |  Branch (52:8): [True: 0, False: 0]
  ------------------
   53|      0|       cinfo->out_color_space != JCS_EXT_BGR &&
  ------------------
  |  Branch (53:8): [True: 0, False: 0]
  ------------------
   54|      0|       cinfo->out_color_space != JCS_EXT_BGRX &&
  ------------------
  |  Branch (54:8): [True: 0, False: 0]
  ------------------
   55|      0|       cinfo->out_color_space != JCS_EXT_XBGR &&
  ------------------
  |  Branch (55:8): [True: 0, False: 0]
  ------------------
   56|      0|       cinfo->out_color_space != JCS_EXT_XRGB &&
  ------------------
  |  Branch (56:8): [True: 0, False: 0]
  ------------------
   57|      0|       cinfo->out_color_space != JCS_EXT_RGBA &&
  ------------------
  |  Branch (57:8): [True: 0, False: 0]
  ------------------
   58|      0|       cinfo->out_color_space != JCS_EXT_BGRA &&
  ------------------
  |  Branch (58:8): [True: 0, False: 0]
  ------------------
   59|      0|       cinfo->out_color_space != JCS_EXT_ABGR &&
  ------------------
  |  Branch (59:8): [True: 0, False: 0]
  ------------------
   60|      0|       cinfo->out_color_space != JCS_EXT_ARGB))
  ------------------
  |  Branch (60:8): [True: 0, False: 0]
  ------------------
   61|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   62|      0|  if ((cinfo->out_color_space == JCS_RGB565 &&
  ------------------
  |  Branch (62:8): [True: 0, False: 0]
  ------------------
   63|      0|       cinfo->out_color_components != 3) ||
  ------------------
  |  Branch (63:8): [True: 0, False: 0]
  ------------------
   64|      0|      (cinfo->out_color_space != JCS_RGB565 &&
  ------------------
  |  Branch (64:8): [True: 0, False: 0]
  ------------------
   65|      0|       cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
  ------------------
  |  Branch (65:8): [True: 0, False: 0]
  ------------------
   66|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   67|       |  /* and it only handles 2h1v or 2h2v sampling ratios */
   68|      0|  if (cinfo->comp_info[0].h_samp_factor != 2 ||
  ------------------
  |  Branch (68:7): [True: 0, False: 0]
  ------------------
   69|      0|      cinfo->comp_info[1].h_samp_factor != 1 ||
  ------------------
  |  Branch (69:7): [True: 0, False: 0]
  ------------------
   70|      0|      cinfo->comp_info[2].h_samp_factor != 1 ||
  ------------------
  |  Branch (70:7): [True: 0, False: 0]
  ------------------
   71|      0|      cinfo->comp_info[0].v_samp_factor >  2 ||
  ------------------
  |  Branch (71:7): [True: 0, False: 0]
  ------------------
   72|      0|      cinfo->comp_info[1].v_samp_factor != 1 ||
  ------------------
  |  Branch (72:7): [True: 0, False: 0]
  ------------------
   73|      0|      cinfo->comp_info[2].v_samp_factor != 1)
  ------------------
  |  Branch (73:7): [True: 0, False: 0]
  ------------------
   74|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   75|       |  /* furthermore, it doesn't work if we've scaled the IDCTs differently */
   76|      0|  if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
  ------------------
  |  |   24|      0|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
                if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (76:7): [True: 0, False: 0]
  ------------------
   77|      0|      cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
  ------------------
  |  |   24|      0|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
                    cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (77:7): [True: 0, False: 0]
  ------------------
   78|      0|      cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
  ------------------
  |  |   24|      0|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
                    cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (78:7): [True: 0, False: 0]
  ------------------
   79|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   80|       |  /* ??? also need to test for upsample-time rescaling, when & if supported */
   81|      0|  return TRUE;                  /* by golly, it'll work... */
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
   82|       |#else
   83|       |  return FALSE;
   84|       |#endif
   85|      0|}
jdmaster.c:prepare_for_output_pass:
  797|  22.8k|{
  798|  22.8k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  799|       |
  800|  22.8k|  if (master->pub.is_dummy_pass) {
  ------------------
  |  Branch (800:7): [True: 0, False: 22.8k]
  ------------------
  801|      0|#ifdef QUANT_2PASS_SUPPORTED
  802|       |    /* Final pass of 2-pass quantization */
  803|      0|    master->pub.is_dummy_pass = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  804|      0|    (*cinfo->cquantize->start_pass) (cinfo, FALSE);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  805|      0|    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
  806|      0|    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
  807|       |#else
  808|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  809|       |#endif /* QUANT_2PASS_SUPPORTED */
  810|  22.8k|  } else {
  811|  22.8k|    if (cinfo->quantize_colors && cinfo->colormap == NULL) {
  ------------------
  |  Branch (811:9): [True: 0, False: 22.8k]
  |  Branch (811:35): [True: 0, False: 0]
  ------------------
  812|       |      /* Select new quantization method */
  813|      0|      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
  ------------------
  |  Branch (813:11): [True: 0, False: 0]
  |  Branch (813:39): [True: 0, False: 0]
  ------------------
  814|      0|        cinfo->cquantize = master->quantizer_2pass;
  815|      0|        master->pub.is_dummy_pass = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  816|      0|      } else if (cinfo->enable_1pass_quant) {
  ------------------
  |  Branch (816:18): [True: 0, False: 0]
  ------------------
  817|      0|        cinfo->cquantize = master->quantizer_1pass;
  818|      0|      } else {
  819|      0|        ERREXIT(cinfo, JERR_MODE_CHANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  820|      0|      }
  821|      0|    }
  822|  22.8k|    (*cinfo->idct->start_pass) (cinfo);
  823|  22.8k|    (*cinfo->coef->start_output_pass) (cinfo);
  824|  22.8k|    if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (824:9): [True: 22.7k, False: 28]
  ------------------
  825|  22.7k|      if (!master->using_merged_upsample)
  ------------------
  |  Branch (825:11): [True: 22.7k, False: 0]
  ------------------
  826|  22.7k|        (*cinfo->cconvert->start_pass) (cinfo);
  827|  22.7k|      (*cinfo->upsample->start_pass) (cinfo);
  828|  22.7k|      if (cinfo->quantize_colors)
  ------------------
  |  Branch (828:11): [True: 0, False: 22.7k]
  ------------------
  829|      0|        (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
  830|  22.7k|      (*cinfo->post->start_pass) (cinfo,
  831|  22.7k|            (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  ------------------
  |  Branch (831:14): [True: 0, False: 22.7k]
  ------------------
  832|  22.7k|      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  833|  22.7k|    }
  834|  22.8k|  }
  835|       |
  836|       |  /* Set up progress monitor's pass info if present */
  837|  22.8k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (837:7): [True: 0, False: 22.8k]
  ------------------
  838|      0|    cinfo->progress->completed_passes = master->pass_number;
  839|      0|    cinfo->progress->total_passes = master->pass_number +
  840|      0|                                    (master->pub.is_dummy_pass ? 2 : 1);
  ------------------
  |  Branch (840:38): [True: 0, False: 0]
  ------------------
  841|       |    /* In buffered-image mode, we assume one more output pass if EOI not
  842|       |     * yet reached, but no more passes if EOI has been reached.
  843|       |     */
  844|      0|    if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
  ------------------
  |  Branch (844:9): [True: 0, False: 0]
  |  Branch (844:34): [True: 0, False: 0]
  ------------------
  845|      0|      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
  ------------------
  |  Branch (845:41): [True: 0, False: 0]
  ------------------
  846|      0|    }
  847|      0|  }
  848|  22.8k|}
jdmaster.c:master_selection:
  515|  22.8k|{
  516|  22.8k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  517|  22.8k|  boolean use_c_buffer;
  518|  22.8k|  long samplesperrow;
  519|  22.8k|  JDIMENSION jd_samplesperrow;
  520|       |
  521|       |  /* When decompressing an 8-bit-per-sample lossy JPEG image, we allow the
  522|       |   * caller to request 12-bit-per-sample output in order to facilitate shadow
  523|       |   * recovery in underexposed images.  However, in all other cases, setting the
  524|       |   * output data precision to a different value than the JPEG data precision
  525|       |   * will produce unexpected results, such as a bogus output image.
  526|       |   */
  527|  22.8k|  if (cinfo->master->jpeg_data_precision &&
  ------------------
  |  Branch (527:7): [True: 22.8k, False: 0]
  ------------------
  528|  22.8k|      cinfo->data_precision != cinfo->master->jpeg_data_precision &&
  ------------------
  |  Branch (528:7): [True: 0, False: 22.8k]
  ------------------
  529|      0|      (cinfo->master->lossless || cinfo->data_precision != 12))
  ------------------
  |  Branch (529:8): [True: 0, False: 0]
  |  Branch (529:35): [True: 0, False: 0]
  ------------------
  530|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  531|       |
  532|       |  /* Disable IDCT scaling and raw (downsampled) data output in lossless mode.
  533|       |   * IDCT scaling is not useful in lossless mode, and it must be disabled in
  534|       |   * order to properly calculate the output dimensions.  Raw data output isn't
  535|       |   * particularly useful without subsampling and has not been tested in
  536|       |   * lossless mode.
  537|       |   */
  538|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  539|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (539:7): [True: 9, False: 22.8k]
  ------------------
  540|      9|    cinfo->raw_data_out = FALSE;
  ------------------
  |  |  207|      9|#define FALSE   0               /* values of boolean */
  ------------------
  541|      9|    cinfo->scale_num = cinfo->scale_denom = 1;
  542|      9|  }
  543|  22.8k|#endif
  544|       |
  545|       |  /* Initialize dimensions and other stuff */
  546|  22.8k|  jpeg_calc_output_dimensions(cinfo);
  547|  22.8k|  prepare_range_limit_table(cinfo);
  548|       |
  549|       |  /* Width of an output scanline must be representable as JDIMENSION. */
  550|  22.8k|  samplesperrow = (long)cinfo->output_width *
  551|  22.8k|                  (long)cinfo->out_color_components;
  552|  22.8k|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  553|  22.8k|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (553:7): [True: 0, False: 22.8k]
  ------------------
  554|      0|    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  555|       |
  556|       |  /* Initialize my private state */
  557|  22.8k|  master->pass_number = 0;
  558|  22.8k|  master->using_merged_upsample = use_merged_upsample(cinfo);
  559|       |
  560|       |  /* Color quantizer selection */
  561|  22.8k|  master->quantizer_1pass = NULL;
  562|  22.8k|  master->quantizer_2pass = NULL;
  563|       |  /* No mode changes if not using buffered-image mode. */
  564|  22.8k|  if (!cinfo->quantize_colors || !cinfo->buffered_image) {
  ------------------
  |  Branch (564:7): [True: 22.8k, False: 0]
  |  Branch (564:34): [True: 0, False: 0]
  ------------------
  565|  22.8k|    cinfo->enable_1pass_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  566|  22.8k|    cinfo->enable_external_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  567|  22.8k|    cinfo->enable_2pass_quant = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  568|  22.8k|  }
  569|  22.8k|  if (cinfo->quantize_colors) {
  ------------------
  |  Branch (569:7): [True: 0, False: 22.8k]
  ------------------
  570|      0|    if (cinfo->raw_data_out)
  ------------------
  |  Branch (570:9): [True: 0, False: 0]
  ------------------
  571|      0|      ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  572|       |    /* 2-pass quantizer only works in 3-component color space. */
  573|      0|    if (cinfo->out_color_components != 3 ||
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  ------------------
  574|      0|        cinfo->out_color_space == JCS_RGB565) {
  ------------------
  |  Branch (574:9): [True: 0, False: 0]
  ------------------
  575|      0|      cinfo->enable_1pass_quant = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  576|      0|      cinfo->enable_external_quant = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  577|      0|      cinfo->enable_2pass_quant = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  578|      0|      cinfo->colormap = NULL;
  579|      0|    } else if (cinfo->colormap != NULL) {
  ------------------
  |  Branch (579:16): [True: 0, False: 0]
  ------------------
  580|      0|      cinfo->enable_external_quant = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  581|      0|    } else if (cinfo->two_pass_quantize) {
  ------------------
  |  Branch (581:16): [True: 0, False: 0]
  ------------------
  582|      0|      cinfo->enable_2pass_quant = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  583|      0|    } else {
  584|      0|      cinfo->enable_1pass_quant = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  585|      0|    }
  586|       |
  587|      0|    if (cinfo->enable_1pass_quant) {
  ------------------
  |  Branch (587:9): [True: 0, False: 0]
  ------------------
  588|      0|#ifdef QUANT_1PASS_SUPPORTED
  589|      0|      if (cinfo->data_precision == 8)
  ------------------
  |  Branch (589:11): [True: 0, False: 0]
  ------------------
  590|      0|        jinit_1pass_quantizer(cinfo);
  591|      0|      else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (591:16): [True: 0, False: 0]
  ------------------
  592|      0|        j12init_1pass_quantizer(cinfo);
  593|      0|      else
  594|      0|        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  595|      0|      master->quantizer_1pass = cinfo->cquantize;
  596|       |#else
  597|       |      ERREXIT(cinfo, JERR_NOT_COMPILED);
  598|       |#endif
  599|      0|    }
  600|       |
  601|       |    /* We use the 2-pass code to map to external colormaps. */
  602|      0|    if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
  ------------------
  |  Branch (602:9): [True: 0, False: 0]
  |  Branch (602:38): [True: 0, False: 0]
  ------------------
  603|      0|#ifdef QUANT_2PASS_SUPPORTED
  604|      0|      if (cinfo->data_precision == 8)
  ------------------
  |  Branch (604:11): [True: 0, False: 0]
  ------------------
  605|      0|        jinit_2pass_quantizer(cinfo);
  606|      0|      else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (606:16): [True: 0, False: 0]
  ------------------
  607|      0|        j12init_2pass_quantizer(cinfo);
  608|      0|      else
  609|      0|        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  610|      0|      master->quantizer_2pass = cinfo->cquantize;
  611|       |#else
  612|       |      ERREXIT(cinfo, JERR_NOT_COMPILED);
  613|       |#endif
  614|      0|    }
  615|       |    /* If both quantizers are initialized, the 2-pass one is left active;
  616|       |     * this is necessary for starting with quantization to an external map.
  617|       |     */
  618|      0|  }
  619|       |
  620|       |  /* Post-processing: in particular, color conversion first */
  621|  22.8k|  if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (621:7): [True: 22.8k, False: 40]
  ------------------
  622|  22.8k|    if (master->using_merged_upsample) {
  ------------------
  |  Branch (622:9): [True: 0, False: 22.8k]
  ------------------
  623|      0|#ifdef UPSAMPLE_MERGING_SUPPORTED
  624|      0|      if (cinfo->data_precision == 8)
  ------------------
  |  Branch (624:11): [True: 0, False: 0]
  ------------------
  625|      0|        jinit_merged_upsampler(cinfo); /* does color conversion too */
  626|      0|      else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (626:16): [True: 0, False: 0]
  ------------------
  627|      0|        j12init_merged_upsampler(cinfo); /* does color conversion too */
  628|      0|      else
  629|      0|        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|       |#else
  631|       |      ERREXIT(cinfo, JERR_NOT_COMPILED);
  632|       |#endif
  633|  22.8k|    } else {
  634|  22.8k|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (634:11): [True: 22.8k, False: 0]
  ------------------
  635|  22.8k|        jinit_color_deconverter(cinfo);
  636|  22.8k|        jinit_upsampler(cinfo);
  637|  22.8k|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (637:18): [True: 0, False: 0]
  ------------------
  638|      0|        j12init_color_deconverter(cinfo);
  639|      0|        j12init_upsampler(cinfo);
  640|      0|      } else {
  641|      0|#ifdef D_LOSSLESS_SUPPORTED
  642|      0|        j16init_color_deconverter(cinfo);
  643|      0|        j16init_upsampler(cinfo);
  644|       |#else
  645|       |        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  646|       |#endif
  647|      0|      }
  648|  22.8k|    }
  649|  22.8k|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (649:9): [True: 22.8k, False: 0]
  ------------------
  650|  22.8k|      jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
  651|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (651:14): [True: 0, False: 0]
  ------------------
  652|      0|      j12init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
  653|      0|    else
  654|      0|#ifdef D_LOSSLESS_SUPPORTED
  655|      0|      j16init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
  656|       |#else
  657|       |      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  658|       |#endif
  659|  22.8k|  }
  660|       |
  661|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (661:7): [True: 9, False: 22.8k]
  ------------------
  662|      9|#ifdef D_LOSSLESS_SUPPORTED
  663|       |    /* Prediction, sample undifferencing, point transform, and sample size
  664|       |     * scaling
  665|       |     */
  666|      9|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (666:9): [True: 9, False: 0]
  ------------------
  667|      9|      jinit_lossless_decompressor(cinfo);
  668|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (668:14): [True: 0, False: 0]
  ------------------
  669|      0|      j12init_lossless_decompressor(cinfo);
  670|      0|    else
  671|      0|      j16init_lossless_decompressor(cinfo);
  672|       |    /* Entropy decoding: either Huffman or arithmetic coding. */
  673|      9|    if (cinfo->arith_code) {
  ------------------
  |  Branch (673:9): [True: 0, False: 9]
  ------------------
  674|      0|      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  675|      9|    } else {
  676|      9|      jinit_lhuff_decoder(cinfo);
  677|      9|    }
  678|       |
  679|       |    /* Initialize principal buffer controllers. */
  680|      9|    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
  ------------------
  |  Branch (680:20): [True: 2, False: 7]
  ------------------
  681|      7|                   cinfo->buffered_image;
  ------------------
  |  Branch (681:20): [True: 0, False: 7]
  ------------------
  682|      9|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (682:9): [True: 9, False: 0]
  ------------------
  683|      9|      jinit_d_diff_controller(cinfo, use_c_buffer);
  684|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (684:14): [True: 0, False: 0]
  ------------------
  685|      0|      j12init_d_diff_controller(cinfo, use_c_buffer);
  686|      0|    else
  687|      0|      j16init_d_diff_controller(cinfo, use_c_buffer);
  688|       |#else
  689|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  690|       |#endif
  691|  22.8k|  } else {
  692|  22.8k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) || \
  693|  22.8k|    defined(DCT_FLOAT_SUPPORTED)
  694|       |    /* Inverse DCT */
  695|  22.8k|    if (cinfo->data_precision == 8)
  ------------------
  |  Branch (695:9): [True: 22.8k, False: 0]
  ------------------
  696|  22.8k|      jinit_inverse_dct(cinfo);
  697|      0|    else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (697:14): [True: 0, False: 0]
  ------------------
  698|      0|      j12init_inverse_dct(cinfo);
  699|      0|    else
  700|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  701|       |    /* Entropy decoding: either Huffman or arithmetic coding. */
  702|  22.8k|    if (cinfo->arith_code) {
  ------------------
  |  Branch (702:9): [True: 0, False: 22.8k]
  ------------------
  703|      0|#ifdef D_ARITH_CODING_SUPPORTED
  704|      0|      jinit_arith_decoder(cinfo);
  705|       |#else
  706|       |      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  707|       |#endif
  708|  22.8k|    } else {
  709|  22.8k|      if (cinfo->progressive_mode) {
  ------------------
  |  Branch (709:11): [True: 0, False: 22.8k]
  ------------------
  710|      0|#ifdef D_PROGRESSIVE_SUPPORTED
  711|      0|        jinit_phuff_decoder(cinfo);
  712|       |#else
  713|       |        ERREXIT(cinfo, JERR_NOT_COMPILED);
  714|       |#endif
  715|      0|      } else
  716|  22.8k|        jinit_huff_decoder(cinfo);
  717|  22.8k|    }
  718|       |
  719|       |    /* Initialize principal buffer controllers. */
  720|  22.8k|    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
  ------------------
  |  Branch (720:20): [True: 1, False: 22.8k]
  ------------------
  721|  22.8k|                   cinfo->buffered_image;
  ------------------
  |  Branch (721:20): [True: 0, False: 22.8k]
  ------------------
  722|  22.8k|    if (cinfo->data_precision == 12)
  ------------------
  |  Branch (722:9): [True: 0, False: 22.8k]
  ------------------
  723|      0|      j12init_d_coef_controller(cinfo, use_c_buffer);
  724|  22.8k|    else
  725|  22.8k|      jinit_d_coef_controller(cinfo, use_c_buffer);
  726|       |#else
  727|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  728|       |#endif
  729|  22.8k|  }
  730|       |
  731|  22.8k|  if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (731:7): [True: 22.8k, False: 40]
  ------------------
  732|  22.8k|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (732:9): [True: 22.8k, False: 0]
  ------------------
  733|  22.8k|      jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  734|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (734:14): [True: 0, False: 0]
  ------------------
  735|      0|      j12init_d_main_controller(cinfo,
  736|      0|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  737|      0|    else
  738|      0|#ifdef D_LOSSLESS_SUPPORTED
  739|      0|      j16init_d_main_controller(cinfo,
  740|      0|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  741|       |#else
  742|       |      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  743|       |#endif
  744|  22.8k|  }
  745|       |
  746|       |  /* We can now tell the memory manager to allocate virtual arrays. */
  747|  22.8k|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  748|       |
  749|       |  /* Initialize input side of decompressor to consume first scan. */
  750|  22.8k|  (*cinfo->inputctl->start_input_pass) (cinfo);
  751|       |
  752|       |  /* Set the first and last iMCU columns to decompress from single-scan images.
  753|       |   * By default, decompress all of the iMCU columns.
  754|       |   */
  755|  22.8k|  cinfo->master->first_iMCU_col = 0;
  756|  22.8k|  cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
  757|  22.8k|  cinfo->master->last_good_iMCU_row = 0;
  758|       |
  759|  22.8k|#ifdef D_MULTISCAN_FILES_SUPPORTED
  760|       |  /* If jpeg_start_decompress will read the whole file, initialize
  761|       |   * progress monitoring appropriately.  The input step is counted
  762|       |   * as one pass.
  763|       |   */
  764|  22.8k|  if (cinfo->progress != NULL && !cinfo->buffered_image &&
  ------------------
  |  Branch (764:7): [True: 0, False: 22.8k]
  |  Branch (764:34): [True: 0, False: 0]
  ------------------
  765|      0|      cinfo->inputctl->has_multiple_scans) {
  ------------------
  |  Branch (765:7): [True: 0, False: 0]
  ------------------
  766|      0|    int nscans;
  767|       |    /* Estimate number of scans to set pass_limit. */
  768|      0|    if (cinfo->progressive_mode) {
  ------------------
  |  Branch (768:9): [True: 0, False: 0]
  ------------------
  769|       |      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
  770|      0|      nscans = 2 + 3 * cinfo->num_components;
  771|      0|    } else {
  772|       |      /* For a nonprogressive multiscan file, estimate 1 scan per component. */
  773|      0|      nscans = cinfo->num_components;
  774|      0|    }
  775|      0|    cinfo->progress->pass_counter = 0L;
  776|      0|    cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
  777|      0|    cinfo->progress->completed_passes = 0;
  778|      0|    cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
  ------------------
  |  Branch (778:38): [True: 0, False: 0]
  ------------------
  779|       |    /* Count the input pass as done */
  780|      0|    master->pass_number++;
  781|      0|  }
  782|  22.8k|#endif /* D_MULTISCAN_FILES_SUPPORTED */
  783|  22.8k|}
jdmaster.c:prepare_range_limit_table:
  420|  22.8k|{
  421|  22.8k|  JSAMPLE *table;
  422|  22.8k|  J12SAMPLE *table12;
  423|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  424|  22.8k|  J16SAMPLE *table16;
  425|  22.8k|#endif
  426|  22.8k|  int i;
  427|       |
  428|  22.8k|  if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (428:7): [True: 22.8k, False: 0]
  ------------------
  429|  22.8k|    table = (JSAMPLE *)
  430|  22.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  431|  22.8k|                  (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
                                (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
  432|  22.8k|    table += (MAXJSAMPLE + 1);  /* allow negative subscripts of simple table */
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
  433|  22.8k|    cinfo->sample_range_limit = table;
  434|       |    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
  435|  22.8k|    memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
                  memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
  436|       |    /* Main part of "simple" table: limit[x] = x */
  437|  5.87M|    for (i = 0; i <= MAXJSAMPLE; i++)
  ------------------
  |  |   52|  5.87M|#define MAXJSAMPLE       255
  ------------------
  |  Branch (437:17): [True: 5.85M, False: 22.8k]
  ------------------
  438|  5.85M|      table[i] = (JSAMPLE)i;
  439|  22.8k|    table += CENTERJSAMPLE;     /* Point to where post-IDCT table starts */
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
  440|       |    /* End of simple table, rest of first half of post-IDCT table */
  441|  8.79M|    for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
                  for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
  ------------------
  |  |   52|  8.79M|#define MAXJSAMPLE       255
  ------------------
  |  Branch (441:29): [True: 8.77M, False: 22.8k]
  ------------------
  442|  8.77M|      table[i] = MAXJSAMPLE;
  ------------------
  |  |   52|  8.77M|#define MAXJSAMPLE       255
  ------------------
  443|       |    /* Second half of post-IDCT table */
  444|  22.8k|    memset(table + (2 * (MAXJSAMPLE + 1)), 0,
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
  445|  22.8k|           (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
                         (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
  446|  22.8k|    memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
  ------------------
  |  |   52|  22.8k|#define MAXJSAMPLE       255
  ------------------
                  memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
  447|  22.8k|           cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
  ------------------
  |  |   53|  22.8k|#define CENTERJSAMPLE    128
  ------------------
  448|  22.8k|  } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (448:14): [True: 0, False: 0]
  ------------------
  449|      0|    table12 = (J12SAMPLE *)
  450|      0|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  451|      0|                  (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
                                (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
  452|      0|                  sizeof(J12SAMPLE));
  453|      0|    table12 += (MAXJ12SAMPLE + 1);  /* allow negative subscripts of simple
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  454|       |                                       table */
  455|      0|    cinfo->sample_range_limit = (JSAMPLE *)table12;
  456|       |    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
  457|      0|    memset(table12 - (MAXJ12SAMPLE + 1), 0,
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  458|      0|           (MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  459|       |    /* Main part of "simple" table: limit[x] = x */
  460|      0|    for (i = 0; i <= MAXJ12SAMPLE; i++)
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  |  Branch (460:17): [True: 0, False: 0]
  ------------------
  461|      0|      table12[i] = (J12SAMPLE)i;
  462|      0|    table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
  463|       |    /* End of simple table, rest of first half of post-IDCT table */
  464|      0|    for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
                  for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  |  Branch (464:31): [True: 0, False: 0]
  ------------------
  465|      0|      table12[i] = MAXJ12SAMPLE;
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  466|       |    /* Second half of post-IDCT table */
  467|      0|    memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
  468|      0|           (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
                         (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
  469|      0|    memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
  ------------------
  |  |   60|      0|#define MAXJ12SAMPLE     4095
  ------------------
                  memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
  470|      0|           cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
  ------------------
  |  |   61|      0|#define CENTERJ12SAMPLE  2048
  ------------------
  471|      0|  } else {
  472|      0|#ifdef D_LOSSLESS_SUPPORTED
  473|      0|    table16 = (J16SAMPLE *)
  474|      0|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  475|      0|                  (5 * (MAXJ16SAMPLE + 1) + CENTERJ16SAMPLE) *
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
                                (5 * (MAXJ16SAMPLE + 1) + CENTERJ16SAMPLE) *
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
  476|      0|                  sizeof(J16SAMPLE));
  477|      0|    table16 += (MAXJ16SAMPLE + 1);  /* allow negative subscripts of simple
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  478|       |                                       table */
  479|      0|    cinfo->sample_range_limit = (JSAMPLE *)table16;
  480|       |    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
  481|      0|    memset(table16 - (MAXJ16SAMPLE + 1), 0,
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  482|      0|           (MAXJ16SAMPLE + 1) * sizeof(J16SAMPLE));
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  483|       |    /* Main part of "simple" table: limit[x] = x */
  484|      0|    for (i = 0; i <= MAXJ16SAMPLE; i++)
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  |  Branch (484:17): [True: 0, False: 0]
  ------------------
  485|      0|      table16[i] = (J16SAMPLE)i;
  486|      0|    table16 += CENTERJ16SAMPLE; /* Point to where post-IDCT table starts */
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
  487|       |    /* End of simple table, rest of first half of post-IDCT table */
  488|      0|    for (i = CENTERJ16SAMPLE; i < 2 * (MAXJ16SAMPLE + 1); i++)
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
                  for (i = CENTERJ16SAMPLE; i < 2 * (MAXJ16SAMPLE + 1); i++)
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  |  Branch (488:31): [True: 0, False: 0]
  ------------------
  489|      0|      table16[i] = MAXJ16SAMPLE;
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  490|       |    /* Second half of post-IDCT table */
  491|      0|    memset(table16 + (2 * (MAXJ16SAMPLE + 1)), 0,
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
  492|      0|           (2 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE) * sizeof(J16SAMPLE));
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
                         (2 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE) * sizeof(J16SAMPLE));
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
  493|      0|    memcpy(table16 + (4 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE),
  ------------------
  |  |   68|      0|#define MAXJ16SAMPLE     65535
  ------------------
                  memcpy(table16 + (4 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE),
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
  494|      0|           cinfo->sample_range_limit, CENTERJ16SAMPLE * sizeof(J16SAMPLE));
  ------------------
  |  |   69|      0|#define CENTERJ16SAMPLE  32768
  ------------------
  495|       |#else
  496|       |    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  497|       |#endif
  498|      0|  }
  499|  22.8k|}

jinit_d_post_controller:
  267|  22.8k|{
  268|  22.8k|  my_post_ptr post;
  269|       |
  270|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  271|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (271:7): [True: 9, False: 22.8k]
  ------------------
  272|      9|#if BITS_IN_JSAMPLE == 8
  273|      9|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (273:9): [True: 0, False: 9]
  |  Branch (273:52): [True: 0, False: 9]
  ------------------
  274|       |#else
  275|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  276|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  277|       |#endif
  278|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  279|      9|  } else
  280|  22.8k|#endif
  281|  22.8k|  {
  282|  22.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (282:9): [True: 0, False: 22.8k]
  ------------------
  283|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  284|  22.8k|  }
  285|       |
  286|  22.8k|  post = (my_post_ptr)
  287|  22.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  288|  22.8k|                                sizeof(my_post_controller));
  289|  22.8k|  cinfo->post = (struct jpeg_d_post_controller *)post;
  290|  22.8k|  post->pub.start_pass = start_pass_dpost;
  291|  22.8k|  post->whole_image = NULL;     /* flag for no virtual arrays */
  292|  22.8k|  post->buffer = NULL;          /* flag for no strip buffer */
  293|       |
  294|       |  /* Create the quantization buffer, if needed */
  295|  22.8k|  if (cinfo->quantize_colors) {
  ------------------
  |  Branch (295:7): [True: 0, False: 22.8k]
  ------------------
  296|      0|#if BITS_IN_JSAMPLE != 16
  297|       |    /* The buffer strip height is max_v_samp_factor, which is typically
  298|       |     * an efficient number of rows for upsampling to return.
  299|       |     * (In the presence of output rescaling, we might want to be smarter?)
  300|       |     */
  301|      0|    post->strip_height = (JDIMENSION)cinfo->max_v_samp_factor;
  302|      0|    if (need_full_buffer) {
  ------------------
  |  Branch (302:9): [True: 0, False: 0]
  ------------------
  303|       |      /* Two-pass color quantization: need full-image storage. */
  304|       |      /* We round up the number of rows to a multiple of the strip height. */
  305|      0|#ifdef QUANT_2PASS_SUPPORTED
  306|      0|      post->whole_image = (*cinfo->mem->request_virt_sarray)
  307|      0|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  308|      0|         cinfo->output_width * cinfo->out_color_components,
  309|      0|         (JDIMENSION)jround_up((long)cinfo->output_height,
  310|      0|                               (long)post->strip_height),
  311|      0|         post->strip_height);
  312|       |#else
  313|       |      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  314|       |#endif /* QUANT_2PASS_SUPPORTED */
  315|      0|    } else {
  316|       |      /* One-pass color quantization: just make a strip buffer. */
  317|      0|      post->buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  318|      0|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  319|      0|         cinfo->output_width * cinfo->out_color_components,
  320|      0|         post->strip_height);
  321|      0|    }
  322|       |#else
  323|       |    ERREXIT(cinfo, JERR_NOTIMPL);
  324|       |#endif
  325|      0|  }
  326|  22.8k|}
jdpostct-8.c:start_pass_dpost:
   85|  22.7k|{
   86|  22.7k|  my_post_ptr post = (my_post_ptr)cinfo->post;
   87|       |
   88|  22.7k|  switch (pass_mode) {
   89|  22.7k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (89:3): [True: 22.7k, False: 0]
  ------------------
   90|  22.7k|#if BITS_IN_JSAMPLE != 16
   91|  22.7k|    if (cinfo->quantize_colors) {
  ------------------
  |  Branch (91:9): [True: 0, False: 22.7k]
  ------------------
   92|       |      /* Single-pass processing with color quantization. */
   93|      0|      post->pub._post_process_data = post_process_1pass;
  ------------------
  |  |  260|      0|#define _post_process_data  post_process_data
  ------------------
   94|       |      /* We could be doing buffered-image output before starting a 2-pass
   95|       |       * color quantization; in that case, jinit_d_post_controller did not
   96|       |       * allocate a strip buffer.  Use the virtual-array buffer as workspace.
   97|       |       */
   98|      0|      if (post->buffer == NULL) {
  ------------------
  |  Branch (98:11): [True: 0, False: 0]
  ------------------
   99|      0|        post->buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
  100|      0|          ((j_common_ptr)cinfo, post->whole_image,
  101|      0|           (JDIMENSION)0, post->strip_height, TRUE);
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  102|      0|      }
  103|      0|    } else
  104|  22.7k|#endif
  105|  22.7k|    {
  106|       |      /* For single-pass processing without color quantization,
  107|       |       * I have no work to do; just call the upsampler directly.
  108|       |       */
  109|  22.7k|      post->pub._post_process_data = cinfo->upsample->_upsample;
  ------------------
  |  |  260|  22.7k|#define _post_process_data  post_process_data
  ------------------
                    post->pub._post_process_data = cinfo->upsample->_upsample;
  ------------------
  |  |  265|  22.7k|#define _upsample  upsample
  ------------------
  110|  22.7k|    }
  111|  22.7k|    break;
  112|      0|#if defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
  113|      0|  case JBUF_SAVE_AND_PASS:
  ------------------
  |  Branch (113:3): [True: 0, False: 22.7k]
  ------------------
  114|       |    /* First pass of 2-pass quantization */
  115|      0|    if (post->whole_image == NULL)
  ------------------
  |  Branch (115:9): [True: 0, False: 0]
  ------------------
  116|      0|      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  117|      0|    post->pub._post_process_data = post_process_prepass;
  ------------------
  |  |  260|      0|#define _post_process_data  post_process_data
  ------------------
  118|      0|    break;
  119|      0|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (119:3): [True: 0, False: 22.7k]
  ------------------
  120|       |    /* Second pass of 2-pass quantization */
  121|      0|    if (post->whole_image == NULL)
  ------------------
  |  Branch (121:9): [True: 0, False: 0]
  ------------------
  122|      0|      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  123|      0|    post->pub._post_process_data = post_process_2pass;
  ------------------
  |  |  260|      0|#define _post_process_data  post_process_data
  ------------------
  124|      0|    break;
  125|      0|#endif /* defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
  126|      0|  default:
  ------------------
  |  Branch (126:3): [True: 0, False: 22.7k]
  ------------------
  127|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  128|      0|    break;
  129|  22.7k|  }
  130|  22.7k|  post->starting_row = post->next_row = 0;
  131|  22.7k|}

jinit_upsampler:
  438|  22.8k|{
  439|  22.8k|  my_upsample_ptr upsample;
  440|  22.8k|  int ci;
  441|  22.8k|  jpeg_component_info *compptr;
  442|  22.8k|  boolean need_buffer, do_fancy;
  443|  22.8k|  int h_in_group, v_in_group, h_out_group, v_out_group;
  444|       |
  445|  22.8k|#ifdef D_LOSSLESS_SUPPORTED
  446|  22.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (446:7): [True: 9, False: 22.8k]
  ------------------
  447|      9|#if BITS_IN_JSAMPLE == 8
  448|      9|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|     18|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (448:9): [True: 0, False: 9]
  |  Branch (448:52): [True: 0, False: 9]
  ------------------
  449|       |#else
  450|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  451|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  452|       |#endif
  453|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  454|      9|  } else
  455|  22.8k|#endif
  456|  22.8k|  {
  457|  22.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (457:9): [True: 0, False: 22.8k]
  ------------------
  458|      0|      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  459|  22.8k|  }
  460|       |
  461|  22.8k|  if (!cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (461:7): [True: 22.8k, False: 0]
  ------------------
  462|  22.8k|    upsample = (my_upsample_ptr)
  463|  22.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  464|  22.8k|                                  sizeof(my_upsampler));
  465|  22.8k|    cinfo->upsample = (struct jpeg_upsampler *)upsample;
  466|  22.8k|    upsample->pub.start_pass = start_pass_upsample;
  467|  22.8k|    upsample->pub._upsample = sep_upsample;
  ------------------
  |  |  265|  22.8k|#define _upsample  upsample
  ------------------
  468|  22.8k|    upsample->pub.need_context_rows = FALSE; /* until we find out differently */
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  469|  22.8k|  } else
  470|      0|    upsample = (my_upsample_ptr)cinfo->upsample;
  471|       |
  472|  22.8k|  if (cinfo->CCIR601_sampling)  /* this isn't supported */
  ------------------
  |  Branch (472:7): [True: 0, False: 22.8k]
  ------------------
  473|      0|    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  474|       |
  475|       |  /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
  476|       |   * so don't ask for it.
  477|       |   */
  478|  22.8k|  do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;
  ------------------
  |  |   27|  22.8k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (478:14): [True: 22.8k, False: 0]
  |  Branch (478:44): [True: 22.8k, False: 9]
  ------------------
  479|       |
  480|       |  /* Verify we can handle the sampling factors, select per-component methods,
  481|       |   * and create storage as needed.
  482|       |   */
  483|  45.6k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (483:44): [True: 22.8k, False: 22.8k]
  ------------------
  484|  22.8k|       ci++, compptr++) {
  485|       |    /* Compute size of an "input group" after IDCT scaling.  This many samples
  486|       |     * are to be converted to max_h_samp_factor * max_v_samp_factor components.
  487|       |     */
  488|  22.8k|    h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  489|  22.8k|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  22.8k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  490|  22.8k|    v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|  22.8k|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  491|  22.8k|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|  22.8k|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  492|  22.8k|    h_out_group = cinfo->max_h_samp_factor;
  493|  22.8k|    v_out_group = cinfo->max_v_samp_factor;
  494|  22.8k|    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
  495|  22.8k|    need_buffer = TRUE;
  ------------------
  |  |  210|  22.8k|#define TRUE    1
  ------------------
  496|  22.8k|    if (!compptr->component_needed) {
  ------------------
  |  Branch (496:9): [True: 0, False: 22.8k]
  ------------------
  497|       |      /* Don't bother to upsample an uninteresting component. */
  498|      0|      upsample->methods[ci] = noop_upsample;
  499|      0|      need_buffer = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  500|  22.8k|    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (500:16): [True: 22.8k, False: 2]
  |  Branch (500:45): [True: 22.8k, False: 0]
  ------------------
  501|       |      /* Fullsize components can be processed without any work. */
  502|  22.8k|      upsample->methods[ci] = fullsize_upsample;
  503|  22.8k|      need_buffer = FALSE;
  ------------------
  |  |  207|  22.8k|#define FALSE   0               /* values of boolean */
  ------------------
  504|  22.8k|    } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (504:16): [True: 2, False: 0]
  |  Branch (504:49): [True: 0, False: 2]
  ------------------
  505|       |      /* Special cases for 2h1v upsampling */
  506|      0|      if (do_fancy && compptr->downsampled_width > 2) {
  ------------------
  |  Branch (506:11): [True: 0, False: 0]
  |  Branch (506:23): [True: 0, False: 0]
  ------------------
  507|      0|#ifdef WITH_SIMD
  508|      0|        if (jsimd_set_h2v1_fancy_upsample(cinfo))
  ------------------
  |  Branch (508:13): [True: 0, False: 0]
  ------------------
  509|      0|          upsample->methods[ci] = jsimd_h2v1_fancy_upsample;
  510|      0|        else
  511|      0|#endif
  512|      0|          upsample->methods[ci] = h2v1_fancy_upsample;
  513|      0|      } else {
  514|      0|#ifdef WITH_SIMD
  515|      0|        if (jsimd_set_h2v1_upsample(cinfo))
  ------------------
  |  Branch (515:13): [True: 0, False: 0]
  ------------------
  516|      0|          upsample->methods[ci] = jsimd_h2v1_upsample;
  517|      0|        else
  518|      0|#endif
  519|      0|          upsample->methods[ci] = h2v1_upsample;
  520|      0|      }
  521|      2|    } else if (h_in_group == h_out_group &&
  ------------------
  |  Branch (521:16): [True: 0, False: 2]
  ------------------
  522|      0|               v_in_group * 2 == v_out_group && do_fancy) {
  ------------------
  |  Branch (522:16): [True: 0, False: 0]
  |  Branch (522:49): [True: 0, False: 0]
  ------------------
  523|       |      /* Non-fancy upsampling is handled by the generic method */
  524|       |#if defined(WITH_SIMD) && (SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM)
  525|       |      if (jsimd_set_h1v2_fancy_upsample(cinfo))
  526|       |        upsample->methods[ci] = jsimd_h1v2_fancy_upsample;
  527|       |      else
  528|       |#endif
  529|      0|        upsample->methods[ci] = h1v2_fancy_upsample;
  530|      0|      upsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  531|      2|    } else if (h_in_group * 2 == h_out_group &&
  ------------------
  |  Branch (531:16): [True: 2, False: 0]
  ------------------
  532|      2|               v_in_group * 2 == v_out_group) {
  ------------------
  |  Branch (532:16): [True: 2, False: 0]
  ------------------
  533|       |      /* Special cases for 2h2v upsampling */
  534|      2|      if (do_fancy && compptr->downsampled_width > 2) {
  ------------------
  |  Branch (534:11): [True: 2, False: 0]
  |  Branch (534:23): [True: 2, False: 0]
  ------------------
  535|      2|#ifdef WITH_SIMD
  536|      2|        if (jsimd_set_h2v2_fancy_upsample(cinfo))
  ------------------
  |  Branch (536:13): [True: 2, False: 0]
  ------------------
  537|      2|          upsample->methods[ci] = jsimd_h2v2_fancy_upsample;
  538|      0|        else
  539|      0|#endif
  540|      0|          upsample->methods[ci] = h2v2_fancy_upsample;
  541|      2|        upsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      2|#define TRUE    1
  ------------------
  542|      2|      } else {
  543|      0|#ifdef WITH_SIMD
  544|      0|        if (jsimd_set_h2v2_upsample(cinfo))
  ------------------
  |  Branch (544:13): [True: 0, False: 0]
  ------------------
  545|      0|          upsample->methods[ci] = jsimd_h2v2_upsample;
  546|      0|        else
  547|      0|#endif
  548|      0|          upsample->methods[ci] = h2v2_upsample;
  549|      0|      }
  550|      2|    } else if ((h_out_group % h_in_group) == 0 &&
  ------------------
  |  Branch (550:16): [True: 0, False: 0]
  ------------------
  551|      0|               (v_out_group % v_in_group) == 0) {
  ------------------
  |  Branch (551:16): [True: 0, False: 0]
  ------------------
  552|       |      /* Generic integral-factors upsampling method */
  553|      0|      upsample->methods[ci] = int_upsample;
  554|      0|      upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group);
  555|      0|      upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group);
  556|      0|    } else
  557|      0|      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  558|  22.8k|    if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (558:9): [True: 2, False: 22.8k]
  |  Branch (558:24): [True: 2, False: 0]
  ------------------
  559|      2|      upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  560|      2|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      2|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  561|      2|         (JDIMENSION)jround_up((long)cinfo->output_width,
  562|      2|                               (long)cinfo->max_h_samp_factor),
  563|      2|         (JDIMENSION)cinfo->max_v_samp_factor);
  564|      2|    }
  565|  22.8k|  }
  566|  22.8k|}
jdsample-8.c:start_pass_upsample:
   47|  22.7k|{
   48|  22.7k|  my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
   49|       |
   50|       |  /* Mark the conversion buffer empty */
   51|  22.7k|  upsample->next_row_out = cinfo->max_v_samp_factor;
   52|       |  /* Initialize total-height counter for detecting bottom of image */
   53|  22.7k|  upsample->rows_to_go = cinfo->output_height;
   54|  22.7k|}
jdsample-8.c:sep_upsample:
   70|  9.03M|{
   71|  9.03M|  my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
   72|  9.03M|  int ci;
   73|  9.03M|  jpeg_component_info *compptr;
   74|  9.03M|  JDIMENSION num_rows;
   75|       |
   76|       |  /* Fill the conversion buffer, if it's empty */
   77|  9.03M|  if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (77:7): [True: 9.03M, False: 7.45k]
  ------------------
   78|  18.0M|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (78:46): [True: 9.03M, False: 9.03M]
  ------------------
   79|  9.03M|         ci++, compptr++) {
   80|       |      /* Invoke per-component upsample method.  Notice we pass a POINTER
   81|       |       * to color_buf[ci], so that fullsize_upsample can change it.
   82|       |       */
   83|       |#ifdef WITH_PROFILE
   84|       |      cinfo->master->start = getTime();
   85|       |#endif
   86|  9.03M|      (*upsample->methods[ci]) (cinfo, compptr,
   87|  9.03M|        input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
   88|  9.03M|        upsample->color_buf + ci);
   89|       |#ifdef WITH_PROFILE
   90|       |      cinfo->master->upsample_elapsed += getTime() - cinfo->master->start;
   91|       |      cinfo->master->upsample_msamples +=
   92|       |        (double)cinfo->output_width * cinfo->max_v_samp_factor / 1000000.;
   93|       |#endif
   94|  9.03M|    }
   95|  9.03M|    upsample->next_row_out = 0;
   96|  9.03M|  }
   97|       |
   98|       |  /* Color-convert and emit rows */
   99|       |
  100|       |  /* How many we have in the buffer: */
  101|  9.03M|  num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out);
  102|       |  /* Not more than the distance to the end of the image.  Need this test
  103|       |   * in case the image height is not a multiple of max_v_samp_factor:
  104|       |   */
  105|  9.03M|  if (num_rows > upsample->rows_to_go)
  ------------------
  |  Branch (105:7): [True: 5, False: 9.03M]
  ------------------
  106|      5|    num_rows = upsample->rows_to_go;
  107|       |  /* And not more than what the client can accept: */
  108|  9.03M|  out_rows_avail -= *out_row_ctr;
  109|  9.03M|  if (num_rows > out_rows_avail)
  ------------------
  |  Branch (109:7): [True: 7.45k, False: 9.03M]
  ------------------
  110|  7.45k|    num_rows = out_rows_avail;
  111|       |
  112|       |#ifdef WITH_PROFILE
  113|       |  cinfo->master->start = getTime();
  114|       |#endif
  115|  9.03M|  (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf,
  ------------------
  |  |  267|  9.03M|#define _color_convert  color_convert
  ------------------
  116|  9.03M|                                      (JDIMENSION)upsample->next_row_out,
  117|  9.03M|                                      output_buf + *out_row_ctr,
  118|  9.03M|                                      (int)num_rows);
  119|       |#ifdef WITH_PROFILE
  120|       |  cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start;
  121|       |  cinfo->master->cconvert_mpixels +=
  122|       |    (double)cinfo->output_width * num_rows / 1000000.;
  123|       |#endif
  124|       |
  125|       |  /* Adjust counts */
  126|  9.03M|  *out_row_ctr += num_rows;
  127|  9.03M|  upsample->rows_to_go -= num_rows;
  128|  9.03M|  upsample->next_row_out += num_rows;
  129|       |  /* When the buffer is emptied, declare this input row group consumed */
  130|  9.03M|  if (upsample->next_row_out >= cinfo->max_v_samp_factor)
  ------------------
  |  Branch (130:7): [True: 9.03M, False: 7.45k]
  ------------------
  131|  9.03M|    (*in_row_group_ctr)++;
  132|  9.03M|}
jdsample-8.c:fullsize_upsample:
  151|  9.03M|{
  152|  9.03M|  *output_data_ptr = input_data;
  153|  9.03M|}

jpeg_std_error:
  229|  23.3k|{
  230|  23.3k|  memset(err, 0, sizeof(struct jpeg_error_mgr));
  231|       |
  232|  23.3k|  err->error_exit = error_exit;
  233|  23.3k|  err->emit_message = emit_message;
  234|  23.3k|  err->output_message = output_message;
  235|  23.3k|  err->format_message = format_message;
  236|  23.3k|  err->reset_error_mgr = reset_error_mgr;
  237|       |
  238|       |  /* Initialize message table pointers */
  239|  23.3k|  err->jpeg_message_table = jpeg_std_message_table;
  240|  23.3k|  err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
  241|       |
  242|  23.3k|  return err;
  243|  23.3k|}
jerror.c:emit_message:
  126|   290M|{
  127|   290M|  struct jpeg_error_mgr *err = cinfo->err;
  128|       |
  129|   290M|  if (msg_level < 0) {
  ------------------
  |  Branch (129:7): [True: 290M, False: 290k]
  ------------------
  130|       |    /* It's a warning message.  Since corrupt files may generate many warnings,
  131|       |     * the policy implemented here is to show only the first warning,
  132|       |     * unless trace_level >= 3.
  133|       |     */
  134|   290M|    if (err->num_warnings == 0 || err->trace_level >= 3)
  ------------------
  |  Branch (134:9): [True: 36.1k, False: 290M]
  |  Branch (134:35): [True: 0, False: 290M]
  ------------------
  135|  36.1k|      (*err->output_message) (cinfo);
  136|       |    /* Always count warnings in num_warnings. */
  137|   290M|    err->num_warnings++;
  138|   290M|  } else {
  139|       |    /* It's a trace message.  Show it if trace_level >= msg_level. */
  140|   290k|    if (err->trace_level >= msg_level)
  ------------------
  |  Branch (140:9): [True: 0, False: 290k]
  ------------------
  141|      0|      (*err->output_message) (cinfo);
  142|   290k|  }
  143|   290M|}
jerror.c:format_message:
  155|  73.9k|{
  156|  73.9k|  struct jpeg_error_mgr *err = cinfo->err;
  157|  73.9k|  int msg_code = err->msg_code;
  158|  73.9k|  const char *msgtext = NULL;
  159|  73.9k|  const char *msgptr;
  160|  73.9k|  char ch;
  161|  73.9k|  boolean isstring;
  162|       |
  163|       |  /* Look up message string in proper table */
  164|  73.9k|  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
  ------------------
  |  Branch (164:7): [True: 73.9k, False: 0]
  |  Branch (164:23): [True: 73.9k, False: 0]
  ------------------
  165|  73.9k|    msgtext = err->jpeg_message_table[msg_code];
  166|  73.9k|  } else if (err->addon_message_table != NULL &&
  ------------------
  |  Branch (166:14): [True: 0, False: 0]
  ------------------
  167|      0|             msg_code >= err->first_addon_message &&
  ------------------
  |  Branch (167:14): [True: 0, False: 0]
  ------------------
  168|      0|             msg_code <= err->last_addon_message) {
  ------------------
  |  Branch (168:14): [True: 0, False: 0]
  ------------------
  169|      0|    msgtext = err->addon_message_table[msg_code - err->first_addon_message];
  170|      0|  }
  171|       |
  172|       |  /* Defend against bogus message number */
  173|  73.9k|  if (msgtext == NULL) {
  ------------------
  |  Branch (173:7): [True: 0, False: 73.9k]
  ------------------
  174|      0|    err->msg_parm.i[0] = msg_code;
  175|      0|    msgtext = err->jpeg_message_table[0];
  176|      0|  }
  177|       |
  178|       |  /* Check for string parameter, as indicated by %s in the message text */
  179|  73.9k|  isstring = FALSE;
  ------------------
  |  |  207|  73.9k|#define FALSE   0               /* values of boolean */
  ------------------
  180|  73.9k|  msgptr = msgtext;
  181|  2.36M|  while ((ch = *msgptr++) != '\0') {
  ------------------
  |  Branch (181:10): [True: 2.33M, False: 26.2k]
  ------------------
  182|  2.33M|    if (ch == '%') {
  ------------------
  |  Branch (182:9): [True: 47.7k, False: 2.29M]
  ------------------
  183|  47.7k|      if (*msgptr == 's') isstring = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  |  Branch (183:11): [True: 0, False: 47.7k]
  ------------------
  184|  47.7k|      break;
  185|  47.7k|    }
  186|  2.33M|  }
  187|       |
  188|       |  /* Format the message into the passed buffer */
  189|  73.9k|  if (isstring)
  ------------------
  |  Branch (189:7): [True: 0, False: 73.9k]
  ------------------
  190|      0|    SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext, err->msg_parm.s);
  ------------------
  |  |   55|      0|#define SNPRINTF  snprintf
  ------------------
                  SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext, err->msg_parm.s);
  ------------------
  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  191|  73.9k|  else
  192|  73.9k|    SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext,
  ------------------
  |  |   55|  73.9k|#define SNPRINTF  snprintf
  ------------------
                  SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext,
  ------------------
  |  |  792|  73.9k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  193|  73.9k|             err->msg_parm.i[0], err->msg_parm.i[1],
  194|  73.9k|             err->msg_parm.i[2], err->msg_parm.i[3],
  195|  73.9k|             err->msg_parm.i[4], err->msg_parm.i[5],
  196|  73.9k|             err->msg_parm.i[6], err->msg_parm.i[7]);
  197|  73.9k|}
jerror.c:reset_error_mgr:
  210|  60.6k|{
  211|  60.6k|  cinfo->err->num_warnings = 0;
  212|       |  /* trace_level is not reset since it is an application-supplied parameter */
  213|  60.6k|  cinfo->err->msg_code = 0;     /* may be useful as a flag for "no error" */
  214|  60.6k|}

jmemmgr.c:GETENV_S:
   80|  23.3k|{
   81|  23.3k|  char *env;
   82|       |
   83|  23.3k|  if (!buffer) {
  ------------------
  |  Branch (83:7): [True: 0, False: 23.3k]
  ------------------
   84|      0|    if (buffer_size == 0)
  ------------------
  |  Branch (84:9): [True: 0, False: 0]
  ------------------
   85|      0|      return 0;
   86|      0|    else
   87|      0|      return (errno = EINVAL);
   88|      0|  }
   89|  23.3k|  if (buffer_size == 0)
  ------------------
  |  Branch (89:7): [True: 0, False: 23.3k]
  ------------------
   90|      0|    return (errno = EINVAL);
   91|  23.3k|  if (!name) {
  ------------------
  |  Branch (91:7): [True: 0, False: 23.3k]
  ------------------
   92|      0|    *buffer = 0;
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  23.3k|  env = getenv(name);
   97|  23.3k|  if (!env)
  ------------------
  |  Branch (97:7): [True: 23.3k, False: 0]
  ------------------
   98|  23.3k|  {
   99|  23.3k|    *buffer = 0;
  100|  23.3k|    return 0;
  101|  23.3k|  }
  102|       |
  103|      0|  if (strlen(env) + 1 > buffer_size) {
  ------------------
  |  Branch (103:7): [True: 0, False: 0]
  ------------------
  104|      0|    *buffer = 0;
  105|      0|    return ERANGE;
  106|      0|  }
  107|       |
  108|      0|  strncpy(buffer, env, buffer_size);
  109|       |
  110|      0|  return 0;
  111|      0|}
jsimd.c:GETENV_S:
   80|  68.4k|{
   81|  68.4k|  char *env;
   82|       |
   83|  68.4k|  if (!buffer) {
  ------------------
  |  Branch (83:7): [True: 0, False: 68.4k]
  ------------------
   84|      0|    if (buffer_size == 0)
  ------------------
  |  Branch (84:9): [True: 0, False: 0]
  ------------------
   85|      0|      return 0;
   86|      0|    else
   87|      0|      return (errno = EINVAL);
   88|      0|  }
   89|  68.4k|  if (buffer_size == 0)
  ------------------
  |  Branch (89:7): [True: 0, False: 68.4k]
  ------------------
   90|      0|    return (errno = EINVAL);
   91|  68.4k|  if (!name) {
  ------------------
  |  Branch (91:7): [True: 0, False: 68.4k]
  ------------------
   92|      0|    *buffer = 0;
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  68.4k|  env = getenv(name);
   97|  68.4k|  if (!env)
  ------------------
  |  Branch (97:7): [True: 68.4k, False: 0]
  ------------------
   98|  68.4k|  {
   99|  68.4k|    *buffer = 0;
  100|  68.4k|    return 0;
  101|  68.4k|  }
  102|       |
  103|      0|  if (strlen(env) + 1 > buffer_size) {
  ------------------
  |  Branch (103:7): [True: 0, False: 0]
  ------------------
  104|      0|    *buffer = 0;
  105|      0|    return ERANGE;
  106|      0|  }
  107|       |
  108|      0|  strncpy(buffer, env, buffer_size);
  109|       |
  110|      0|  return 0;
  111|      0|}

jinit_memory_mgr:
 1196|  23.3k|{
 1197|  23.3k|  my_mem_ptr mem;
 1198|  23.3k|  long max_to_use;
 1199|  23.3k|  int pool;
 1200|  23.3k|  size_t test_mac;
 1201|       |
 1202|  23.3k|  cinfo->mem = NULL;            /* for safety if init fails */
 1203|       |
 1204|       |  /* Check for configuration errors.
 1205|       |   * sizeof(ALIGN_TYPE) should be a power of 2; otherwise, it probably
 1206|       |   * doesn't reflect any real hardware alignment requirement.
 1207|       |   * The test is a little tricky: for X>0, X and X-1 have no one-bits
 1208|       |   * in common if and only if X is a power of 2, ie has only one one-bit.
 1209|       |   * Some compilers may give an "unreachable code" warning here; ignore it.
 1210|       |   */
 1211|  23.3k|  if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  23.3k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  23.3k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (1211:7): [Folded, False: 23.3k]
  ------------------
 1212|      0|    ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1213|       |  /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
 1214|       |   * a multiple of ALIGN_SIZE.
 1215|       |   * Again, an "unreachable code" warning may be ignored here.
 1216|       |   * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
 1217|       |   */
 1218|  23.3k|  test_mac = (size_t)MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  23.3k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1219|  23.3k|  if ((long)test_mac != MAX_ALLOC_CHUNK ||
  ------------------
  |  |   62|  46.7k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (1219:7): [True: 0, False: 23.3k]
  ------------------
 1220|  23.3k|      (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   62|  23.3k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
                    (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|  23.3k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (1220:7): [Folded, False: 0]
  ------------------
 1221|      0|    ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1222|       |
 1223|  23.3k|  max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
 1224|       |
 1225|       |  /* Attempt to allocate memory manager's control block */
 1226|  23.3k|  mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
 1227|       |
 1228|  23.3k|  if (mem == NULL) {
  ------------------
  |  Branch (1228:7): [True: 0, False: 23.3k]
  ------------------
 1229|      0|    jpeg_mem_term(cinfo);       /* system-dependent cleanup */
 1230|      0|    ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1231|      0|  }
 1232|       |
 1233|       |  /* OK, fill in the method pointers */
 1234|  23.3k|  mem->pub.alloc_small = alloc_small;
 1235|  23.3k|  mem->pub.alloc_large = alloc_large;
 1236|  23.3k|  mem->pub.alloc_sarray = alloc_sarray;
 1237|  23.3k|  mem->pub.alloc_barray = alloc_barray;
 1238|  23.3k|  mem->pub.request_virt_sarray = request_virt_sarray;
 1239|  23.3k|  mem->pub.request_virt_barray = request_virt_barray;
 1240|  23.3k|  mem->pub.realize_virt_arrays = realize_virt_arrays;
 1241|  23.3k|  mem->pub.access_virt_sarray = access_virt_sarray;
 1242|  23.3k|  mem->pub.access_virt_barray = access_virt_barray;
 1243|  23.3k|  mem->pub.free_pool = free_pool;
 1244|  23.3k|  mem->pub.self_destruct = self_destruct;
 1245|       |
 1246|       |  /* Make MAX_ALLOC_CHUNK accessible to other modules */
 1247|  23.3k|  mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  23.3k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1248|       |
 1249|       |  /* Initialize working state */
 1250|  23.3k|  mem->pub.max_memory_to_use = max_to_use;
 1251|       |
 1252|  70.0k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  23.3k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|  70.0k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1252:35): [True: 46.7k, False: 23.3k]
  ------------------
 1253|  46.7k|    mem->small_list[pool] = NULL;
 1254|  46.7k|    mem->large_list[pool] = NULL;
 1255|  46.7k|  }
 1256|  23.3k|  mem->virt_sarray_list = NULL;
 1257|  23.3k|  mem->virt_barray_list = NULL;
 1258|       |
 1259|  23.3k|  mem->total_space_allocated = sizeof(my_memory_mgr);
 1260|       |
 1261|       |  /* Declare ourselves open for business */
 1262|  23.3k|  cinfo->mem = &mem->pub;
 1263|       |
 1264|       |  /* Check for an environment variable JPEGMEM; if found, override the
 1265|       |   * default max_memory setting from jpeg_mem_init.  Note that the
 1266|       |   * surrounding application may again override this value.
 1267|       |   * If your system doesn't support getenv(), define NO_GETENV to disable
 1268|       |   * this feature.
 1269|       |   */
 1270|  23.3k|#ifndef NO_GETENV
 1271|  23.3k|  {
 1272|  23.3k|    char memenv[30] = { 0 };
 1273|       |
 1274|  23.3k|    if (!GETENV_S(memenv, 30, "JPEGMEM") && strlen(memenv) > 0) {
  ------------------
  |  Branch (1274:9): [True: 23.3k, False: 0]
  |  Branch (1274:45): [True: 0, False: 23.3k]
  ------------------
 1275|      0|      char ch = 'x';
 1276|       |
 1277|       |#ifdef _MSC_VER
 1278|       |      if (sscanf_s(memenv, "%ld%c", &max_to_use, &ch, 1) > 0) {
 1279|       |#else
 1280|      0|      if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) {
  ------------------
  |  Branch (1280:11): [True: 0, False: 0]
  ------------------
 1281|      0|#endif
 1282|      0|        if (ch == 'm' || ch == 'M')
  ------------------
  |  Branch (1282:13): [True: 0, False: 0]
  |  Branch (1282:26): [True: 0, False: 0]
  ------------------
 1283|      0|          max_to_use *= 1000L;
 1284|      0|        mem->pub.max_memory_to_use = max_to_use * 1000L;
 1285|      0|      }
 1286|      0|    }
 1287|  23.3k|  }
 1288|  23.3k|#endif
 1289|       |
 1290|  23.3k|}
jmemmgr.c:alloc_small:
  269|   528k|{
  270|   528k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  271|   528k|  small_pool_ptr hdr_ptr, prev_hdr_ptr;
  272|   528k|  char *data_ptr;
  273|   528k|  size_t min_request, slop;
  274|       |
  275|       |  /*
  276|       |   * Round up the requested size to a multiple of ALIGN_SIZE in order
  277|       |   * to assure alignment for the next object allocated in the same pool
  278|       |   * and so that algorithms can straddle outside the proper area up
  279|       |   * to the next alignment.
  280|       |   */
  281|   528k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|   528k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (281:7): [True: 0, False: 528k]
  ------------------
  282|       |    /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
  283|       |       is close to SIZE_MAX. */
  284|      0|    out_of_memory(cinfo, 7);
  285|      0|  }
  286|   528k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|   528k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  287|       |
  288|       |  /* Check for unsatisfiable request (do now to ensure no overflow below) */
  289|   528k|  if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|   528k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (289:7): [True: 0, False: 528k]
  ------------------
  290|   528k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|   528k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  291|      0|    out_of_memory(cinfo, 1);    /* request exceeds malloc's ability */
  292|       |
  293|       |  /* See if space is available in any existing pool */
  294|   528k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|   528k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (294:7): [True: 0, False: 528k]
  |  Branch (294:22): [True: 0, False: 528k]
  ------------------
  295|      0|    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  296|   528k|  prev_hdr_ptr = NULL;
  297|   528k|  hdr_ptr = mem->small_list[pool_id];
  298|   528k|  while (hdr_ptr != NULL) {
  ------------------
  |  Branch (298:10): [True: 481k, False: 47.1k]
  ------------------
  299|   481k|    if (hdr_ptr->bytes_left >= sizeofobject)
  ------------------
  |  Branch (299:9): [True: 481k, False: 136]
  ------------------
  300|   481k|      break;                    /* found pool with enough space */
  301|    136|    prev_hdr_ptr = hdr_ptr;
  302|    136|    hdr_ptr = hdr_ptr->next;
  303|    136|  }
  304|       |
  305|       |  /* Time to make a new pool? */
  306|   528k|  if (hdr_ptr == NULL) {
  ------------------
  |  Branch (306:7): [True: 47.1k, False: 481k]
  ------------------
  307|       |    /* min_request is what we need now, slop is what will be leftover */
  308|  47.1k|    min_request = sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  47.1k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  309|  47.1k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (309:9): [True: 47.0k, False: 101]
  ------------------
  310|  47.0k|      slop = first_pool_slop[pool_id];
  311|    101|    else
  312|    101|      slop = extra_pool_slop[pool_id];
  313|       |    /* Don't ask for more than MAX_ALLOC_CHUNK */
  314|  47.1k|    if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
  ------------------
  |  |   62|  47.1k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (314:9): [True: 0, False: 47.1k]
  ------------------
  315|      0|      slop = (size_t)(MAX_ALLOC_CHUNK - min_request);
  ------------------
  |  |   62|      0|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  316|       |    /* Try to get space, if fail reduce slop and try again */
  317|  47.1k|    for (;;) {
  318|  47.1k|      hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
  319|  47.1k|      if (hdr_ptr != NULL)
  ------------------
  |  Branch (319:11): [True: 47.1k, False: 0]
  ------------------
  320|  47.1k|        break;
  321|      0|      slop /= 2;
  322|      0|      if (slop < MIN_SLOP)      /* give up when it gets real small */
  ------------------
  |  |  263|      0|#define MIN_SLOP  50            /* greater than 0 to avoid futile looping */
  ------------------
  |  Branch (322:11): [True: 0, False: 0]
  ------------------
  323|      0|        out_of_memory(cinfo, 2); /* jpeg_get_small failed */
  324|      0|    }
  325|  47.1k|    mem->total_space_allocated += min_request + slop;
  326|       |    /* Success, initialize the new pool header and add to end of list */
  327|  47.1k|    hdr_ptr->next = NULL;
  328|  47.1k|    hdr_ptr->bytes_used = 0;
  329|  47.1k|    hdr_ptr->bytes_left = sizeofobject + slop;
  330|  47.1k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (330:9): [True: 47.0k, False: 101]
  ------------------
  331|  47.0k|      mem->small_list[pool_id] = hdr_ptr;
  332|    101|    else
  333|    101|      prev_hdr_ptr->next = hdr_ptr;
  334|  47.1k|  }
  335|       |
  336|       |  /* OK, allocate the object from the current pool */
  337|   528k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  338|   528k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  339|   528k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|   528k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (339:7): [True: 528k, False: 0]
  ------------------
  340|   528k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   528k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   528k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  341|   528k|  data_ptr += hdr_ptr->bytes_used; /* point to place for object */
  342|   528k|  hdr_ptr->bytes_used += sizeofobject;
  343|   528k|  hdr_ptr->bytes_left -= sizeofobject;
  344|       |
  345|   528k|  return (void *)data_ptr;
  346|   528k|}
jmemmgr.c:round_up_pow2:
   45|   596k|{
   46|   596k|  return ((a + b - 1) & (~(b - 1)));
   47|   596k|}
jmemmgr.c:alloc_large:
  366|  45.6k|{
  367|  45.6k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  368|  45.6k|  large_pool_ptr hdr_ptr;
  369|  45.6k|  char *data_ptr;
  370|       |
  371|       |  /*
  372|       |   * Round up the requested size to a multiple of ALIGN_SIZE so that
  373|       |   * algorithms can straddle outside the proper area up to the next
  374|       |   * alignment.
  375|       |   */
  376|  45.6k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|  45.6k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (376:7): [True: 0, False: 45.6k]
  ------------------
  377|       |    /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
  378|       |       is close to SIZE_MAX. */
  379|      0|    out_of_memory(cinfo, 8);
  380|      0|  }
  381|  45.6k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  382|       |
  383|       |  /* Check for unsatisfiable request (do now to ensure no overflow below) */
  384|  45.6k|  if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (384:7): [True: 0, False: 45.6k]
  ------------------
  385|  45.6k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|  45.6k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  386|      0|    out_of_memory(cinfo, 3);    /* request exceeds malloc's ability */
  387|       |
  388|       |  /* Always make a new pool */
  389|  45.6k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|  45.6k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (389:7): [True: 0, False: 45.6k]
  |  Branch (389:22): [True: 0, False: 45.6k]
  ------------------
  390|      0|    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  391|       |
  392|  45.6k|  hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
  393|  45.6k|                                           sizeof(large_pool_hdr) +
  394|  45.6k|                                           ALIGN_SIZE - 1);
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  395|  45.6k|  if (hdr_ptr == NULL)
  ------------------
  |  Branch (395:7): [True: 0, False: 45.6k]
  ------------------
  396|      0|    out_of_memory(cinfo, 4);    /* jpeg_get_large failed */
  397|  45.6k|  mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
  398|  45.6k|                                ALIGN_SIZE - 1;
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  399|       |
  400|       |  /* Success, initialize the new pool header and add to list */
  401|  45.6k|  hdr_ptr->next = mem->large_list[pool_id];
  402|       |  /* We maintain space counts in each pool header for statistical purposes,
  403|       |   * even though they are not needed for allocation.
  404|       |   */
  405|  45.6k|  hdr_ptr->bytes_used = sizeofobject;
  406|  45.6k|  hdr_ptr->bytes_left = 0;
  407|  45.6k|  mem->large_list[pool_id] = hdr_ptr;
  408|       |
  409|  45.6k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  410|  45.6k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  411|  45.6k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (411:7): [True: 45.6k, False: 0]
  ------------------
  412|  45.6k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  413|       |
  414|  45.6k|  return (void *)data_ptr;
  415|  45.6k|}
jmemmgr.c:alloc_sarray:
  438|  22.8k|{
  439|  22.8k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  440|  22.8k|  JSAMPARRAY result;
  441|  22.8k|  JSAMPROW workspace;
  442|  22.8k|  JDIMENSION rowsperchunk, currow, i;
  443|  22.8k|  long ltemp;
  444|  22.8k|  J12SAMPARRAY result12;
  445|  22.8k|  J12SAMPROW workspace12;
  446|  22.8k|#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
  447|  22.8k|  J16SAMPARRAY result16;
  448|  22.8k|  J16SAMPROW workspace16;
  449|  22.8k|#endif
  450|  22.8k|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (450:24): [True: 22.8k, False: 0]
  ------------------
  451|  22.8k|                        ((j_decompress_ptr)cinfo)->data_precision :
  452|  22.8k|                        ((j_compress_ptr)cinfo)->data_precision;
  453|  22.8k|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (453:24): [True: 0, False: 22.8k]
  ------------------
  454|  22.8k|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (454:45): [True: 0, False: 22.8k]
  ------------------
  455|      0|                                            sizeof(J12SAMPLE) :
  456|  22.8k|                                            sizeof(JSAMPLE));
  457|       |
  458|       |  /* Make sure each row is properly aligned */
  459|  22.8k|  if ((ALIGN_SIZE % sample_size) != 0)
  ------------------
  |  |   89|  22.8k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (459:7): [True: 0, False: 22.8k]
  ------------------
  460|      0|    out_of_memory(cinfo, 5);    /* safety check */
  461|       |
  462|  22.8k|  if (samplesperrow == 0 || samplesperrow > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|  22.8k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (462:7): [True: 0, False: 22.8k]
  |  Branch (462:29): [True: 0, False: 22.8k]
  ------------------
  463|       |    /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
  464|       |       is close to SIZE_MAX. */
  465|      0|    out_of_memory(cinfo, 9);
  466|      0|  }
  467|  22.8k|  samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
  ------------------
  |  |   89|  22.8k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  468|  22.8k|                                                           sample_size);
  469|       |
  470|       |  /* Calculate max # of rows allowed in one allocation chunk */
  471|  22.8k|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|  22.8k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  472|  22.8k|          ((long)samplesperrow * (long)sample_size);
  473|  22.8k|  if (ltemp <= 0)
  ------------------
  |  Branch (473:7): [True: 0, False: 22.8k]
  ------------------
  474|      0|    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  475|  22.8k|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (475:7): [True: 0, False: 22.8k]
  ------------------
  476|      0|    rowsperchunk = (JDIMENSION)ltemp;
  477|  22.8k|  else
  478|  22.8k|    rowsperchunk = numrows;
  479|  22.8k|  mem->last_rowsperchunk = rowsperchunk;
  480|       |
  481|  22.8k|  if (data_precision <= 8) {
  ------------------
  |  Branch (481:7): [True: 22.8k, False: 0]
  ------------------
  482|       |    /* Get space for row pointers (small object) */
  483|  22.8k|    result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
  484|  22.8k|                                     (size_t)(numrows * sizeof(JSAMPROW)));
  485|       |
  486|       |    /* Get the rows themselves (large objects) */
  487|  22.8k|    currow = 0;
  488|  45.7k|    while (currow < numrows) {
  ------------------
  |  Branch (488:12): [True: 22.8k, False: 22.8k]
  ------------------
  489|  22.8k|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|  22.8k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 22.8k]
  |  |  ------------------
  ------------------
  490|  22.8k|      workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
  491|  22.8k|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  492|   389k|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (492:30): [True: 366k, False: 22.8k]
  ------------------
  493|   366k|        result[currow++] = workspace;
  494|   366k|        workspace += samplesperrow;
  495|   366k|      }
  496|  22.8k|    }
  497|       |
  498|  22.8k|    return result;
  499|  22.8k|  } else if (data_precision <= 12) {
  ------------------
  |  Branch (499:14): [True: 0, False: 0]
  ------------------
  500|       |    /* Get space for row pointers (small object) */
  501|      0|    result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
  502|      0|                                         (size_t)(numrows *
  503|      0|                                                  sizeof(J12SAMPROW)));
  504|       |
  505|       |    /* Get the rows themselves (large objects) */
  506|      0|    currow = 0;
  507|      0|    while (currow < numrows) {
  ------------------
  |  Branch (507:12): [True: 0, False: 0]
  ------------------
  508|      0|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|      0|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  509|      0|      workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
  510|      0|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  511|      0|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (511:30): [True: 0, False: 0]
  ------------------
  512|      0|        result12[currow++] = workspace12;
  513|      0|        workspace12 += samplesperrow;
  514|      0|      }
  515|      0|    }
  516|       |
  517|      0|    return (JSAMPARRAY)result12;
  518|      0|  } else {
  519|      0|#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
  520|       |    /* Get space for row pointers (small object) */
  521|      0|    result16 = (J16SAMPARRAY)alloc_small(cinfo, pool_id,
  522|      0|                                         (size_t)(numrows *
  523|      0|                                                  sizeof(J16SAMPROW)));
  524|       |
  525|       |    /* Get the rows themselves (large objects) */
  526|      0|    currow = 0;
  527|      0|    while (currow < numrows) {
  ------------------
  |  Branch (527:12): [True: 0, False: 0]
  ------------------
  528|      0|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|      0|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  529|      0|      workspace16 = (J16SAMPROW)alloc_large(cinfo, pool_id,
  530|      0|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  531|      0|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (531:30): [True: 0, False: 0]
  ------------------
  532|      0|        result16[currow++] = workspace16;
  533|      0|        workspace16 += samplesperrow;
  534|      0|      }
  535|      0|    }
  536|       |
  537|      0|    return (JSAMPARRAY)result16;
  538|       |#else
  539|       |    ERREXIT1(cinfo, JERR_BAD_PRECISION, data_precision);
  540|       |    return NULL;
  541|       |#endif
  542|      0|  }
  543|  22.8k|}
jmemmgr.c:alloc_barray:
  555|      3|{
  556|      3|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  557|      3|  JBLOCKARRAY result;
  558|      3|  JBLOCKROW workspace;
  559|      3|  JDIMENSION rowsperchunk, currow, i;
  560|      3|  long ltemp;
  561|       |
  562|       |  /* Make sure each row is properly aligned */
  563|      3|  if (blocksperrow == 0 || (sizeof(JBLOCK) % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|      3|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (563:7): [True: 0, False: 3]
  |  Branch (563:28): [Folded, False: 0]
  ------------------
  564|      0|    out_of_memory(cinfo, 6);    /* safety check */
  565|       |
  566|       |  /* Calculate max # of rows allowed in one allocation chunk */
  567|      3|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|      3|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  568|      3|          ((long)blocksperrow * sizeof(JBLOCK));
  569|      3|  if (ltemp <= 0)
  ------------------
  |  Branch (569:7): [True: 0, False: 3]
  ------------------
  570|      0|    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  571|      3|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (571:7): [True: 0, False: 3]
  ------------------
  572|      0|    rowsperchunk = (JDIMENSION)ltemp;
  573|      3|  else
  574|      3|    rowsperchunk = numrows;
  575|      3|  mem->last_rowsperchunk = rowsperchunk;
  576|       |
  577|       |  /* Get space for row pointers (small object) */
  578|      3|  result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
  579|      3|                                    (size_t)(numrows * sizeof(JBLOCKROW)));
  580|       |
  581|       |  /* Get the rows themselves (large objects) */
  582|      3|  currow = 0;
  583|      6|  while (currow < numrows) {
  ------------------
  |  Branch (583:10): [True: 3, False: 3]
  ------------------
  584|      3|    rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|      3|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 3]
  |  |  ------------------
  ------------------
  585|      3|    workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
  586|      3|        (size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
  587|      3|                  sizeof(JBLOCK)));
  588|      7|    for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (588:28): [True: 4, False: 3]
  ------------------
  589|      4|      result[currow++] = workspace;
  590|      4|      workspace += blocksperrow;
  591|      4|    }
  592|      3|  }
  593|       |
  594|      3|  return result;
  595|      3|}
jmemmgr.c:request_virt_sarray:
  640|      6|{
  641|      6|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  642|      6|  jvirt_sarray_ptr result;
  643|       |
  644|       |  /* Only IMAGE-lifetime virtual arrays are currently supported */
  645|      6|  if (pool_id != JPOOL_IMAGE)
  ------------------
  |  |  889|      6|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (645:7): [True: 0, False: 6]
  ------------------
  646|      0|    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  647|       |
  648|       |  /* get control block */
  649|      6|  result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
  650|      6|                                         sizeof(struct jvirt_sarray_control));
  651|       |
  652|      6|  result->mem_buffer = NULL;    /* marks array not yet realized */
  653|      6|  result->rows_in_array = numrows;
  654|      6|  result->samplesperrow = samplesperrow;
  655|      6|  result->maxaccess = maxaccess;
  656|      6|  result->pre_zero = pre_zero;
  657|      6|  result->b_s_open = FALSE;     /* no associated backing-store object */
  ------------------
  |  |  207|      6|#define FALSE   0               /* values of boolean */
  ------------------
  658|      6|  result->next = mem->virt_sarray_list; /* add to list of virtual arrays */
  659|      6|  mem->virt_sarray_list = result;
  660|       |
  661|      6|  return result;
  662|      6|}
jmemmgr.c:request_virt_barray:
  670|      3|{
  671|      3|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  672|      3|  jvirt_barray_ptr result;
  673|       |
  674|       |  /* Only IMAGE-lifetime virtual arrays are currently supported */
  675|      3|  if (pool_id != JPOOL_IMAGE)
  ------------------
  |  |  889|      3|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (675:7): [True: 0, False: 3]
  ------------------
  676|      0|    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  677|       |
  678|       |  /* get control block */
  679|      3|  result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
  680|      3|                                         sizeof(struct jvirt_barray_control));
  681|       |
  682|      3|  result->mem_buffer = NULL;    /* marks array not yet realized */
  683|      3|  result->rows_in_array = numrows;
  684|      3|  result->blocksperrow = blocksperrow;
  685|      3|  result->maxaccess = maxaccess;
  686|      3|  result->pre_zero = pre_zero;
  687|      3|  result->b_s_open = FALSE;     /* no associated backing-store object */
  ------------------
  |  |  207|      3|#define FALSE   0               /* values of boolean */
  ------------------
  688|      3|  result->next = mem->virt_barray_list; /* add to list of virtual arrays */
  689|      3|  mem->virt_barray_list = result;
  690|       |
  691|      3|  return result;
  692|      3|}
jmemmgr.c:realize_virt_arrays:
  698|  22.8k|{
  699|  22.8k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  700|  22.8k|  size_t space_per_minheight, maximum_space, avail_mem;
  701|  22.8k|  size_t minheights, max_minheights;
  702|  22.8k|  jvirt_sarray_ptr sptr;
  703|  22.8k|  jvirt_barray_ptr bptr;
  704|  22.8k|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (704:24): [True: 22.8k, False: 0]
  ------------------
  705|  22.8k|                        ((j_decompress_ptr)cinfo)->data_precision :
  706|  22.8k|                        ((j_compress_ptr)cinfo)->data_precision;
  707|  22.8k|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (707:24): [True: 0, False: 22.8k]
  ------------------
  708|  22.8k|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (708:45): [True: 0, False: 22.8k]
  ------------------
  709|      0|                                            sizeof(J12SAMPLE) :
  710|  22.8k|                                            sizeof(JSAMPLE));
  711|       |
  712|       |  /* Compute the minimum space needed (maxaccess rows in each buffer)
  713|       |   * and the maximum space needed (full image height in each buffer).
  714|       |   * These may be of use to the system-dependent jpeg_mem_available routine.
  715|       |   */
  716|  22.8k|  space_per_minheight = 0;
  717|  22.8k|  maximum_space = 0;
  718|  22.8k|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (718:38): [True: 6, False: 22.8k]
  ------------------
  719|      6|    if (sptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (719:9): [True: 6, False: 0]
  ------------------
  720|      6|      size_t new_space = (size_t)sptr->rows_in_array *
  721|      6|                         (size_t)sptr->samplesperrow * sample_size;
  722|       |
  723|      6|      space_per_minheight += (size_t)sptr->maxaccess *
  724|      6|                             (size_t)sptr->samplesperrow * sample_size;
  725|      6|      if (SIZE_MAX - maximum_space < new_space)
  ------------------
  |  Branch (725:11): [True: 0, False: 6]
  ------------------
  726|      0|        out_of_memory(cinfo, 10);
  727|      6|      maximum_space += new_space;
  728|      6|    }
  729|      6|  }
  730|  22.8k|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (730:38): [True: 3, False: 22.8k]
  ------------------
  731|      3|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (731:9): [True: 3, False: 0]
  ------------------
  732|      3|      size_t new_space = (size_t)bptr->rows_in_array *
  733|      3|                         (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  734|       |
  735|      3|      space_per_minheight += (size_t)bptr->maxaccess *
  736|      3|                             (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  737|      3|      if (SIZE_MAX - maximum_space < new_space)
  ------------------
  |  Branch (737:11): [True: 0, False: 3]
  ------------------
  738|      0|        out_of_memory(cinfo, 11);
  739|      3|      maximum_space += new_space;
  740|      3|    }
  741|      3|  }
  742|       |
  743|  22.8k|  if (space_per_minheight <= 0)
  ------------------
  |  Branch (743:7): [True: 22.8k, False: 3]
  ------------------
  744|  22.8k|    return;                     /* no unrealized arrays, no work */
  745|       |
  746|       |  /* Determine amount of memory to actually use; this is system-dependent. */
  747|      3|  avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
  748|      3|                                 mem->total_space_allocated);
  749|       |
  750|       |  /* If the maximum space needed is available, make all the buffers full
  751|       |   * height; otherwise parcel it out with the same number of minheights
  752|       |   * in each buffer.
  753|       |   */
  754|      3|  if (avail_mem >= maximum_space)
  ------------------
  |  Branch (754:7): [True: 3, False: 0]
  ------------------
  755|      3|    max_minheights = 1000000000L;
  756|      0|  else {
  757|      0|    max_minheights = avail_mem / space_per_minheight;
  758|       |    /* If there doesn't seem to be enough space, try to get the minimum
  759|       |     * anyway.  This allows a "stub" implementation of jpeg_mem_available().
  760|       |     */
  761|      0|    if (max_minheights <= 0)
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      0|      max_minheights = 1;
  763|      0|  }
  764|       |
  765|       |  /* Allocate the in-memory buffers and initialize backing store as needed. */
  766|       |
  767|      9|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (767:38): [True: 6, False: 3]
  ------------------
  768|      6|    if (sptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (768:9): [True: 6, False: 0]
  ------------------
  769|      6|      minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
  770|      6|      if (minheights <= max_minheights) {
  ------------------
  |  Branch (770:11): [True: 6, False: 0]
  ------------------
  771|       |        /* This buffer fits in memory */
  772|      6|        sptr->rows_in_mem = sptr->rows_in_array;
  773|      6|      } else {
  774|       |        /* It doesn't fit in memory, create backing store. */
  775|      0|        sptr->rows_in_mem = (JDIMENSION)(max_minheights * sptr->maxaccess);
  776|      0|        jpeg_open_backing_store(cinfo, &sptr->b_s_info,
  777|      0|                                (long)((size_t)sptr->rows_in_array *
  778|      0|                                       (size_t)sptr->samplesperrow *
  779|      0|                                       sample_size));
  780|      0|        sptr->b_s_open = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  781|      0|      }
  782|      6|      sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      6|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  783|      6|                                      sptr->samplesperrow, sptr->rows_in_mem);
  784|      6|      sptr->rowsperchunk = mem->last_rowsperchunk;
  785|      6|      sptr->cur_start_row = 0;
  786|      6|      sptr->first_undef_row = 0;
  787|      6|      sptr->dirty = FALSE;
  ------------------
  |  |  207|      6|#define FALSE   0               /* values of boolean */
  ------------------
  788|      6|    }
  789|      6|  }
  790|       |
  791|      6|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (791:38): [True: 3, False: 3]
  ------------------
  792|      3|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (792:9): [True: 3, False: 0]
  ------------------
  793|      3|      minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
  794|      3|      if (minheights <= max_minheights) {
  ------------------
  |  Branch (794:11): [True: 3, False: 0]
  ------------------
  795|       |        /* This buffer fits in memory */
  796|      3|        bptr->rows_in_mem = bptr->rows_in_array;
  797|      3|      } else {
  798|       |        /* It doesn't fit in memory, create backing store. */
  799|      0|        bptr->rows_in_mem = (JDIMENSION)(max_minheights * bptr->maxaccess);
  800|      0|        jpeg_open_backing_store(cinfo, &bptr->b_s_info,
  801|      0|                                (long)((size_t)bptr->rows_in_array *
  802|      0|                                       (size_t)bptr->blocksperrow *
  803|      0|                                       sizeof(JBLOCK)));
  804|      0|        bptr->b_s_open = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  805|      0|      }
  806|      3|      bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      3|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  807|      3|                                      bptr->blocksperrow, bptr->rows_in_mem);
  808|      3|      bptr->rowsperchunk = mem->last_rowsperchunk;
  809|      3|      bptr->cur_start_row = 0;
  810|      3|      bptr->first_undef_row = 0;
  811|      3|      bptr->dirty = FALSE;
  ------------------
  |  |  207|      3|#define FALSE   0               /* values of boolean */
  ------------------
  812|      3|    }
  813|      3|  }
  814|      3|}
jmemmgr.c:free_pool:
 1099|   122k|{
 1100|   122k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
 1101|   122k|  small_pool_ptr shdr_ptr;
 1102|   122k|  large_pool_ptr lhdr_ptr;
 1103|   122k|  size_t space_freed;
 1104|       |
 1105|   122k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|   122k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (1105:7): [True: 0, False: 122k]
  |  Branch (1105:22): [True: 0, False: 122k]
  ------------------
 1106|      0|    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1107|       |
 1108|       |#ifdef MEM_STATS
 1109|       |  if (cinfo->err->trace_level > 1)
 1110|       |    print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */
 1111|       |#endif
 1112|       |
 1113|       |  /* If freeing IMAGE pool, close any virtual arrays first */
 1114|   122k|  if (pool_id == JPOOL_IMAGE) {
  ------------------
  |  |  889|   122k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (1114:7): [True: 98.7k, False: 23.3k]
  ------------------
 1115|  98.7k|    jvirt_sarray_ptr sptr;
 1116|  98.7k|    jvirt_barray_ptr bptr;
 1117|       |
 1118|  98.7k|    for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (1118:40): [True: 6, False: 98.7k]
  ------------------
 1119|      6|      if (sptr->b_s_open) {     /* there may be no backing store */
  ------------------
  |  Branch (1119:11): [True: 0, False: 6]
  ------------------
 1120|      0|        sptr->b_s_open = FALSE; /* prevent recursive close if error */
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1121|      0|        (*sptr->b_s_info.close_backing_store) (cinfo, &sptr->b_s_info);
 1122|      0|      }
 1123|      6|    }
 1124|  98.7k|    mem->virt_sarray_list = NULL;
 1125|  98.7k|    for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (1125:40): [True: 3, False: 98.7k]
  ------------------
 1126|      3|      if (bptr->b_s_open) {     /* there may be no backing store */
  ------------------
  |  Branch (1126:11): [True: 0, False: 3]
  ------------------
 1127|      0|        bptr->b_s_open = FALSE; /* prevent recursive close if error */
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1128|      0|        (*bptr->b_s_info.close_backing_store) (cinfo, &bptr->b_s_info);
 1129|      0|      }
 1130|      3|    }
 1131|  98.7k|    mem->virt_barray_list = NULL;
 1132|  98.7k|  }
 1133|       |
 1134|       |  /* Release large objects */
 1135|   122k|  lhdr_ptr = mem->large_list[pool_id];
 1136|   122k|  mem->large_list[pool_id] = NULL;
 1137|       |
 1138|   167k|  while (lhdr_ptr != NULL) {
  ------------------
  |  Branch (1138:10): [True: 45.6k, False: 122k]
  ------------------
 1139|  45.6k|    large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
 1140|  45.6k|    space_freed = lhdr_ptr->bytes_used +
 1141|  45.6k|                  lhdr_ptr->bytes_left +
 1142|  45.6k|                  sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  45.6k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1143|  45.6k|    jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
 1144|  45.6k|    mem->total_space_allocated -= space_freed;
 1145|  45.6k|    lhdr_ptr = next_lhdr_ptr;
 1146|  45.6k|  }
 1147|       |
 1148|       |  /* Release small objects */
 1149|   122k|  shdr_ptr = mem->small_list[pool_id];
 1150|   122k|  mem->small_list[pool_id] = NULL;
 1151|       |
 1152|   169k|  while (shdr_ptr != NULL) {
  ------------------
  |  Branch (1152:10): [True: 47.1k, False: 122k]
  ------------------
 1153|  47.1k|    small_pool_ptr next_shdr_ptr = shdr_ptr->next;
 1154|  47.1k|    space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
 1155|  47.1k|                  sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  47.1k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1156|  47.1k|    jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
 1157|  47.1k|    mem->total_space_allocated -= space_freed;
 1158|  47.1k|    shdr_ptr = next_shdr_ptr;
 1159|  47.1k|  }
 1160|   122k|}
jmemmgr.c:self_destruct:
 1170|  23.3k|{
 1171|  23.3k|  int pool;
 1172|       |
 1173|       |  /* Close all backing store, release all memory.
 1174|       |   * Releasing pools in reverse order might help avoid fragmentation
 1175|       |   * with some (brain-damaged) malloc libraries.
 1176|       |   */
 1177|  70.0k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  23.3k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|  70.0k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1177:35): [True: 46.7k, False: 23.3k]
  ------------------
 1178|  46.7k|    free_pool(cinfo, pool);
 1179|  46.7k|  }
 1180|       |
 1181|       |  /* Release the memory manager control block too. */
 1182|  23.3k|  jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
 1183|  23.3k|  cinfo->mem = NULL;            /* ensures I will be called only once */
 1184|       |
 1185|  23.3k|  jpeg_mem_term(cinfo);         /* system-dependent cleanup */
 1186|  23.3k|}

jpeg_get_small:
   33|  70.4k|{
   34|  70.4k|  return (void *)MALLOC(sizeofobject);
  ------------------
  |  |  520|  70.4k|#define MALLOC(size)  malloc(size)
  ------------------
   35|  70.4k|}
jpeg_free_small:
   39|  70.4k|{
   40|  70.4k|  free(object);
   41|  70.4k|}
jpeg_get_large:
   50|  45.6k|{
   51|  45.6k|  return (void *)MALLOC(sizeofobject);
  ------------------
  |  |  520|  45.6k|#define MALLOC(size)  malloc(size)
  ------------------
   52|  45.6k|}
jpeg_free_large:
   56|  45.6k|{
   57|  45.6k|  free(object);
   58|  45.6k|}
jpeg_mem_available:
   68|      3|{
   69|      3|  if (cinfo->mem->max_memory_to_use) {
  ------------------
  |  Branch (69:7): [True: 0, False: 3]
  ------------------
   70|      0|    if ((size_t)cinfo->mem->max_memory_to_use > already_allocated)
  ------------------
  |  Branch (70:9): [True: 0, False: 0]
  ------------------
   71|      0|      return cinfo->mem->max_memory_to_use - already_allocated;
   72|      0|    else
   73|      0|      return 0;
   74|      3|  } else {
   75|       |    /* Here we always say, "we got all you want bud!" */
   76|      3|    return max_bytes_needed;
   77|      3|  }
   78|      3|}
jpeg_mem_init:
  102|  23.3k|{
  103|  23.3k|  return 0;                     /* just set max_memory_to_use to 0 */
  104|  23.3k|}
jpeg_mem_term:
  108|  23.3k|{
  109|       |  /* no work */
  110|  23.3k|}

jdhuff.c:std_huff_tables:
   57|  22.8k|{
   58|  22.8k|  JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs;
   59|       |
   60|  22.8k|  static const UINT8 bits_dc_luminance[17] = {
   61|  22.8k|    /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
   62|  22.8k|  };
   63|  22.8k|  static const UINT8 val_dc_luminance[] = {
   64|  22.8k|    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
   65|  22.8k|  };
   66|       |
   67|  22.8k|  static const UINT8 bits_dc_chrominance[17] = {
   68|  22.8k|    /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
   69|  22.8k|  };
   70|  22.8k|  static const UINT8 val_dc_chrominance[] = {
   71|  22.8k|    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
   72|  22.8k|  };
   73|       |
   74|  22.8k|  static const UINT8 bits_ac_luminance[17] = {
   75|  22.8k|    /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
   76|  22.8k|  };
   77|  22.8k|  static const UINT8 val_ac_luminance[] = {
   78|  22.8k|    0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
   79|  22.8k|    0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
   80|  22.8k|    0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
   81|  22.8k|    0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
   82|  22.8k|    0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
   83|  22.8k|    0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
   84|  22.8k|    0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
   85|  22.8k|    0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
   86|  22.8k|    0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
   87|  22.8k|    0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
   88|  22.8k|    0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
   89|  22.8k|    0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
   90|  22.8k|    0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
   91|  22.8k|    0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
   92|  22.8k|    0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
   93|  22.8k|    0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
   94|  22.8k|    0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
   95|  22.8k|    0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
   96|  22.8k|    0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
   97|  22.8k|    0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
   98|  22.8k|    0xf9, 0xfa
   99|  22.8k|  };
  100|       |
  101|  22.8k|  static const UINT8 bits_ac_chrominance[17] = {
  102|  22.8k|    /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
  103|  22.8k|  };
  104|  22.8k|  static const UINT8 val_ac_chrominance[] = {
  105|  22.8k|    0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
  106|  22.8k|    0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
  107|  22.8k|    0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
  108|  22.8k|    0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
  109|  22.8k|    0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
  110|  22.8k|    0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
  111|  22.8k|    0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
  112|  22.8k|    0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
  113|  22.8k|    0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
  114|  22.8k|    0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
  115|  22.8k|    0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
  116|  22.8k|    0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  117|  22.8k|    0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
  118|  22.8k|    0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
  119|  22.8k|    0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
  120|  22.8k|    0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
  121|  22.8k|    0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
  122|  22.8k|    0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
  123|  22.8k|    0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
  124|  22.8k|    0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
  125|  22.8k|    0xf9, 0xfa
  126|  22.8k|  };
  127|       |
  128|  22.8k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (128:7): [True: 22.8k, False: 0]
  ------------------
  129|  22.8k|    dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs;
  130|  22.8k|    ac_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->ac_huff_tbl_ptrs;
  131|  22.8k|  } else {
  132|      0|    dc_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->dc_huff_tbl_ptrs;
  133|      0|    ac_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->ac_huff_tbl_ptrs;
  134|      0|  }
  135|       |
  136|  22.8k|  add_huff_table(cinfo, &dc_huff_tbl_ptrs[0], bits_dc_luminance,
  137|  22.8k|                 val_dc_luminance);
  138|  22.8k|  add_huff_table(cinfo, &ac_huff_tbl_ptrs[0], bits_ac_luminance,
  139|  22.8k|                 val_ac_luminance);
  140|  22.8k|  add_huff_table(cinfo, &dc_huff_tbl_ptrs[1], bits_dc_chrominance,
  141|  22.8k|                 val_dc_chrominance);
  142|  22.8k|  add_huff_table(cinfo, &ac_huff_tbl_ptrs[1], bits_ac_chrominance,
  143|  22.8k|                 val_ac_chrominance);
  144|  22.8k|}
jdhuff.c:add_huff_table:
   23|  91.3k|{
   24|  91.3k|  int nsymbols, len;
   25|       |
   26|  91.3k|  if (*htblptr == NULL)
  ------------------
  |  Branch (26:7): [True: 91.2k, False: 126]
  ------------------
   27|  91.2k|    *htblptr = jpeg_alloc_huff_table(cinfo);
   28|    126|  else if (cinfo->is_decompressor)
  ------------------
  |  Branch (28:12): [True: 126, False: 0]
  ------------------
   29|    126|    return;
   30|       |
   31|       |  /* Copy the number-of-symbols-of-each-code-length counts */
   32|  91.2k|  memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
   33|       |
   34|       |  /* Validate the counts.  We do this here mainly so we can copy the right
   35|       |   * number of symbols from the val[] array, without risking marching off
   36|       |   * the end of memory.  jchuff.c will do a more thorough test later.
   37|       |   */
   38|  91.2k|  nsymbols = 0;
   39|  1.55M|  for (len = 1; len <= 16; len++)
  ------------------
  |  Branch (39:17): [True: 1.45M, False: 91.2k]
  ------------------
   40|  1.45M|    nsymbols += bits[len];
   41|  91.2k|  if (nsymbols < 1 || nsymbols > 256)
  ------------------
  |  Branch (41:7): [True: 0, False: 91.2k]
  |  Branch (41:23): [True: 0, False: 91.2k]
  ------------------
   42|      0|    ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   43|       |
   44|  91.2k|  memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
   45|  91.2k|  memset(&((*htblptr)->huffval[nsymbols]), 0,
   46|  91.2k|         (256 - nsymbols) * sizeof(UINT8));
   47|       |
   48|       |  /* Initialize sent_table FALSE so table will be written to JPEG file. */
   49|  91.2k|  (*htblptr)->sent_table = FALSE;
  ------------------
  |  |  207|  91.2k|#define FALSE   0               /* values of boolean */
  ------------------
   50|  91.2k|}

jdiv_round_up:
   81|   206k|{
   82|   206k|  return (a + b - 1L) / b;
   83|   206k|}
jround_up:
   90|     46|{
   91|     46|  a += b - 1L;
   92|     46|  return a - (a % b);
   93|     46|}
jzero_far:
  144|  1.28M|{
  145|  1.28M|  memset(target, 0, bytestozero);
  146|  1.28M|}

handle_error:
   45|   787k|{
   46|   787k|    return;
   47|   787k|}
LLVMFuzzerTestOneInput:
  125|  1.28k|{
  126|  1.28k|#ifndef STANDALONE
  127|  1.28k|    TIFFSetErrorHandler(handle_error);
  128|  1.28k|    TIFFSetWarningHandler(handle_error);
  129|  1.28k|#endif
  130|  1.28k|#if defined(__has_feature)
  131|       |#if __has_feature(memory_sanitizer)
  132|       |    // libjpeg-turbo has issues with MSAN and SIMD code
  133|       |    // See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7547
  134|       |    // and https://github.com/libjpeg-turbo/libjpeg-turbo/pull/365
  135|       |    setenv("JSIMD_FORCENONE", "1", 1);
  136|       |#endif
  137|  1.28k|#endif
  138|  1.28k|    std::istringstream s(std::string(Data, Data + Size));
  139|  1.28k|    TIFF *tif = TIFFStreamOpen("MemTIFF", &s);
  140|  1.28k|    if (!tif)
  ------------------
  |  Branch (140:9): [True: 287, False: 993]
  ------------------
  141|    287|    {
  142|    287|        return 0;
  143|    287|    }
  144|       |
  145|    993|    int dirs = 0;
  146|    993|    do
  147|  2.61k|    {
  148|  2.61k|        if (++dirs > MAX_DIRS)
  ------------------
  |  Branch (148:13): [True: 0, False: 2.61k]
  ------------------
  149|      0|        {
  150|      0|            break;
  151|      0|        }
  152|       |
  153|  2.61k|        read_striles(tif);
  154|       |
  155|  2.61k|        uint32_t w = 0, h = 0;
  156|  2.61k|        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
  ------------------
  |  |  178|  2.61k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  157|  2.61k|        TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
  ------------------
  |  |  179|  2.61k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  158|  2.61k|        uint32_t size = __TIFFSafeMultiply(uint32_t, w, h);
  ------------------
  |  |   35|  2.61k|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 2.61k, False: 0]
  |  |  |  Branch (35:27): [True: 2.56k, False: 48]
  |  |  ------------------
  |  |   36|  2.61k|         ? (t)((v) * (m))                                                      \
  |  |   37|  2.61k|         : (t)0)
  ------------------
  159|  2.61k|        if (size != 0 && size <= MAX_SIZE)
  ------------------
  |  Branch (159:13): [True: 2.56k, False: 48]
  |  Branch (159:26): [True: 2.55k, False: 7]
  ------------------
  160|  2.55k|        {
  161|  2.55k|            uint32_t *raster =
  162|  2.55k|                (uint32_t *)_TIFFmalloc(size * sizeof(uint32_t));
  163|  2.55k|            if (raster != NULL)
  ------------------
  |  Branch (163:17): [True: 2.55k, False: 0]
  ------------------
  164|  2.55k|            {
  165|  2.55k|                TIFFReadRGBAImageOriented(tif, w, h, raster,
  166|  2.55k|                                          ORIENTATION_TOPLEFT, 0);
  ------------------
  |  |  249|  2.55k|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  167|  2.55k|                _TIFFfree(raster);
  168|  2.55k|            }
  169|  2.55k|        }
  170|  2.61k|    } while (TIFFReadDirectory(tif));
  ------------------
  |  Branch (170:14): [True: 1.62k, False: 993]
  ------------------
  171|       |
  172|    993|    TIFFClose(tif);
  173|    993|    return 0;
  174|  1.28k|}
tiff_decode_fuzzer.cc:_ZL12read_strilesP4tiff:
   50|  2.61k|{
   51|  2.61k|    if (TIFFIsTiled(tif))
  ------------------
  |  Branch (51:9): [True: 661, False: 1.95k]
  ------------------
   52|    661|    {
   53|       |        /* another hack to work around an OOM in tif_fax3.c */
   54|    661|        uint32_t tilewidth = 0;
   55|    661|        uint32_t imagewidth = 0;
   56|    661|        TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth);
  ------------------
  |  |  311|    661|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
   57|    661|        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth);
  ------------------
  |  |  178|    661|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
   58|    661|        tilewidth = __TIFFSafeMultiply(uint32_t, tilewidth, 2);
  ------------------
  |  |   35|    661|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 661, Folded]
  |  |  |  Branch (35:27): [True: 626, False: 35]
  |  |  ------------------
  |  |   36|    661|         ? (t)((v) * (m))                                                      \
  |  |   37|    661|         : (t)0)
  ------------------
   59|    661|        imagewidth = __TIFFSafeMultiply(uint32_t, imagewidth, 2);
  ------------------
  |  |   35|    661|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 661, Folded]
  |  |  |  Branch (35:27): [True: 658, False: 3]
  |  |  ------------------
  |  |   36|    661|         ? (t)((v) * (m))                                                      \
  |  |   37|    661|         : (t)0)
  ------------------
   60|    661|        if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE ||
  ------------------
  |  Branch (60:13): [True: 6, False: 655]
  |  Branch (60:41): [True: 3, False: 652]
  ------------------
   61|    652|            tilewidth == 0 || imagewidth == 0)
  ------------------
  |  Branch (61:13): [True: 35, False: 617]
  |  Branch (61:31): [True: 3, False: 614]
  ------------------
   62|     47|        {
   63|     47|            return;
   64|     47|        }
   65|       |
   66|    614|        tmsize_t tilesize = TIFFTileSize(tif);
   67|    614|        if (tilesize <= 0 || (uint64_t)tilesize > MAX_SIZE)
  ------------------
  |  Branch (67:13): [True: 0, False: 614]
  |  Branch (67:30): [True: 6, False: 608]
  ------------------
   68|      6|        {
   69|      6|            return;
   70|      6|        }
   71|    608|        void *buf = _TIFFmalloc(tilesize);
   72|    608|        if (buf == NULL)
  ------------------
  |  Branch (72:13): [True: 0, False: 608]
  ------------------
   73|      0|        {
   74|      0|            return;
   75|      0|        }
   76|    608|        uint32_t ntiles = TIFFNumberOfTiles(tif);
   77|    608|        if (ntiles > MAX_STRILES)
  ------------------
  |  Branch (77:13): [True: 44, False: 564]
  ------------------
   78|     44|        {
   79|     44|            ntiles = MAX_STRILES;
   80|     44|        }
   81|   249k|        for (uint32_t tile = 0; tile < ntiles; tile++)
  ------------------
  |  Branch (81:33): [True: 248k, False: 608]
  ------------------
   82|   248k|        {
   83|   248k|            TIFFReadEncodedTile(tif, tile, buf, (tmsize_t)-1);
   84|   248k|        }
   85|    608|        _TIFFfree(buf);
   86|    608|    }
   87|  1.95k|    else
   88|  1.95k|    {
   89|       |        // check the size of the non-tiled image
   90|  1.95k|        uint32_t rowsize = 0;
   91|  1.95k|        TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsize);
  ------------------
  |  |  258|  1.95k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
   92|  1.95k|        uint32_t stripbytes = TIFFStripSize(tif);
   93|  1.95k|        rowsize = __TIFFSafeMultiply(uint32_t, rowsize, 2);
  ------------------
  |  |   35|  1.95k|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 1.95k, Folded]
  |  |  |  Branch (35:27): [True: 1.94k, False: 9]
  |  |  ------------------
  |  |   36|  1.95k|         ? (t)((v) * (m))                                                      \
  |  |   37|  1.95k|         : (t)0)
  ------------------
   94|  1.95k|        stripbytes = __TIFFSafeMultiply(uint32_t, stripbytes, 2);
  ------------------
  |  |   35|  1.95k|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 1.95k, Folded]
  |  |  |  Branch (35:27): [True: 1.93k, False: 18]
  |  |  ------------------
  |  |   36|  1.95k|         ? (t)((v) * (m))                                                      \
  |  |   37|  1.95k|         : (t)0)
  ------------------
   95|  1.95k|        if (rowsize * 2 > MAX_SIZE || stripbytes * 2 > MAX_SIZE ||
  ------------------
  |  Branch (95:13): [True: 4, False: 1.94k]
  |  Branch (95:39): [True: 31, False: 1.91k]
  ------------------
   96|  1.91k|            rowsize == 0 || stripbytes == 0)
  ------------------
  |  Branch (96:13): [True: 641, False: 1.27k]
  |  Branch (96:29): [True: 7, False: 1.26k]
  ------------------
   97|    683|        {
   98|    683|            return;
   99|    683|        }
  100|       |
  101|  1.26k|        tmsize_t stripsize = TIFFStripSize(tif);
  102|  1.26k|        if (stripsize <= 0 || (uint64_t)stripsize > MAX_SIZE)
  ------------------
  |  Branch (102:13): [True: 0, False: 1.26k]
  |  Branch (102:31): [True: 14, False: 1.25k]
  ------------------
  103|     14|        {
  104|     14|            return;
  105|     14|        }
  106|  1.25k|        void *buf = _TIFFmalloc(stripsize);
  107|  1.25k|        if (buf == NULL)
  ------------------
  |  Branch (107:13): [True: 0, False: 1.25k]
  ------------------
  108|      0|        {
  109|      0|            return;
  110|      0|        }
  111|  1.25k|        uint32_t nstrips = TIFFNumberOfStrips(tif);
  112|  1.25k|        if (nstrips > MAX_STRILES)
  ------------------
  |  Branch (112:13): [True: 4, False: 1.25k]
  ------------------
  113|      4|        {
  114|      4|            nstrips = MAX_STRILES;
  115|      4|        }
  116|  89.7k|        for (uint32_t strip = 0; strip < nstrips; strip++)
  ------------------
  |  Branch (116:34): [True: 88.5k, False: 1.25k]
  ------------------
  117|  88.5k|        {
  118|  88.5k|            TIFFReadEncodedStrip(tif, strip, buf, (tmsize_t)-1);
  119|  88.5k|        }
  120|  1.25k|        _TIFFfree(buf);
  121|  1.25k|    }
  122|  2.61k|}

_TIFFMultiply32:
   37|   375k|{
   38|   375k|    if (second && first > UINT32_MAX / second)
  ------------------
  |  Branch (38:9): [True: 375k, False: 2]
  |  Branch (38:19): [True: 0, False: 375k]
  ------------------
   39|      0|    {
   40|      0|        TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   41|      0|        return 0;
   42|      0|    }
   43|       |
   44|   375k|    return first * second;
   45|   375k|}
_TIFFMultiply64:
   49|   646k|{
   50|   646k|    if (second && first > UINT64_MAX / second)
  ------------------
  |  Branch (50:9): [True: 553k, False: 93.3k]
  |  Branch (50:19): [True: 0, False: 553k]
  ------------------
   51|      0|    {
   52|      0|        TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   53|      0|        return 0;
   54|      0|    }
   55|       |
   56|   646k|    return first * second;
   57|   646k|}
_TIFFAdd64:
   61|   178k|{
   62|   178k|    if (first > UINT64_MAX - second)
  ------------------
  |  Branch (62:9): [True: 0, False: 178k]
  ------------------
   63|      0|    {
   64|      0|        if (tif != NULL && where != NULL)
  ------------------
  |  Branch (64:13): [True: 0, False: 0]
  |  Branch (64:28): [True: 0, False: 0]
  ------------------
   65|      0|        {
   66|      0|            TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   67|      0|        }
   68|      0|        return 0;
   69|      0|    }
   70|       |
   71|   178k|    return first + second;
   72|   178k|}
_TIFFMultiplySSize:
   76|   228k|{
   77|   228k|    if (first <= 0 || second <= 0)
  ------------------
  |  Branch (77:9): [True: 58, False: 228k]
  |  Branch (77:23): [True: 0, False: 228k]
  ------------------
   78|     58|    {
   79|     58|        if (tif != NULL && where != NULL)
  ------------------
  |  Branch (79:13): [True: 58, False: 0]
  |  Branch (79:28): [True: 0, False: 58]
  ------------------
   80|      0|        {
   81|      0|            TIFFErrorExtR(tif, where,
   82|      0|                          "Invalid argument to _TIFFMultiplySSize() in %s",
   83|      0|                          where);
   84|      0|        }
   85|     58|        return 0;
   86|     58|    }
   87|       |
   88|   228k|    if (first > TIFF_TMSIZE_T_MAX / second)
  ------------------
  |  |   68|   228k|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (88:9): [True: 0, False: 228k]
  ------------------
   89|      0|    {
   90|      0|        if (tif != NULL && where != NULL)
  ------------------
  |  Branch (90:13): [True: 0, False: 0]
  |  Branch (90:28): [True: 0, False: 0]
  ------------------
   91|      0|        {
   92|      0|            TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   93|      0|        }
   94|      0|        return 0;
   95|      0|    }
   96|   228k|    return first * second;
   97|   228k|}
_TIFFCastUInt64ToSSize:
  124|   181k|{
  125|   181k|    if (val > (uint64_t)TIFF_TMSIZE_T_MAX)
  ------------------
  |  |   68|   181k|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (125:9): [True: 0, False: 181k]
  ------------------
  126|      0|    {
  127|      0|        if (tif != NULL && module != NULL)
  ------------------
  |  Branch (127:13): [True: 0, False: 0]
  |  Branch (127:28): [True: 0, False: 0]
  ------------------
  128|      0|        {
  129|      0|            TIFFErrorExtR(tif, module, "Integer overflow");
  130|      0|        }
  131|      0|        return 0;
  132|      0|    }
  133|   181k|    return (tmsize_t)val;
  134|   181k|}
_TIFFCastUInt64ToUInt32:
  137|  61.5k|{
  138|  61.5k|    if (val > UINT32_MAX)
  ------------------
  |  Branch (138:9): [True: 0, False: 61.5k]
  ------------------
  139|      0|    {
  140|      0|        if (tif != NULL && module != NULL)
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  |  Branch (140:28): [True: 0, False: 0]
  ------------------
  141|      0|        {
  142|      0|            TIFFErrorExtR(tif, module, "Integer overflow");
  143|      0|        }
  144|      0|        return 0;
  145|      0|    }
  146|  61.5k|    return (uint32_t)val;
  147|  61.5k|}
_TIFFCheckRealloc:
  187|   223k|{
  188|   223k|    void *cp = NULL;
  189|   223k|    tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
  190|       |    /*
  191|       |     * Check for integer overflow.
  192|       |     */
  193|   223k|    if (count != 0)
  ------------------
  |  Branch (193:9): [True: 223k, False: 58]
  ------------------
  194|   223k|    {
  195|   223k|        cp = _TIFFreallocExt(tif, buffer, count);
  196|   223k|    }
  197|       |
  198|   223k|    if (cp == NULL)
  ------------------
  |  Branch (198:9): [True: 58, False: 223k]
  ------------------
  199|     58|    {
  200|     58|        TIFFErrorExtR(tif, tif->tif_name,
  201|     58|                      "Failed to allocate memory for %s "
  202|     58|                      "(%" TIFF_SSIZE_FORMAT " elements of %" TIFF_SSIZE_FORMAT
  203|     58|                      " bytes each)",
  204|     58|                      what, nmemb, elem_size);
  205|     58|    }
  206|       |
  207|   223k|    return cp;
  208|   223k|}
_TIFFCheckMalloc:
  212|  35.2k|{
  213|       |    return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
  214|  35.2k|}
TIFFVGetFieldDefaulted:
  309|  28.5k|{
  310|  28.5k|    TIFFDirectory *td = &tif->tif_dir;
  311|       |
  312|  28.5k|    if (TIFFVGetField(tif, tag, ap))
  ------------------
  |  Branch (312:9): [True: 19.8k, False: 8.69k]
  ------------------
  313|  19.8k|        return (1);
  314|  8.69k|    switch (tag)
  315|  8.69k|    {
  316|      0|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|      0|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (316:9): [True: 0, False: 8.69k]
  ------------------
  317|      0|            *va_arg(ap, uint32_t *) = td->td_subfiletype;
  318|      0|            return (1);
  319|    262|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|    262|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (319:9): [True: 262, False: 8.43k]
  ------------------
  320|    262|            *va_arg(ap, uint16_t *) = td->td_bitspersample;
  321|    262|            return (1);
  322|      0|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|      0|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (322:9): [True: 0, False: 8.69k]
  ------------------
  323|      0|            *va_arg(ap, uint16_t *) = td->td_threshholding;
  324|      0|            return (1);
  325|      0|        case TIFFTAG_FILLORDER:
  ------------------
  |  |  240|      0|#define TIFFTAG_FILLORDER 266              /* data order within a byte */
  ------------------
  |  Branch (325:9): [True: 0, False: 8.69k]
  ------------------
  326|      0|            *va_arg(ap, uint16_t *) = td->td_fillorder;
  327|      0|            return (1);
  328|  1.53k|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|  1.53k|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (328:9): [True: 1.53k, False: 7.16k]
  ------------------
  329|  1.53k|            *va_arg(ap, uint16_t *) = td->td_orientation;
  330|  1.53k|            return (1);
  331|    302|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|    302|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (331:9): [True: 302, False: 8.39k]
  ------------------
  332|    302|            *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
  333|    302|            return (1);
  334|    473|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|    473|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (334:9): [True: 473, False: 8.22k]
  ------------------
  335|    473|            *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
  336|    473|            return (1);
  337|      0|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      0|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (337:9): [True: 0, False: 8.69k]
  ------------------
  338|      0|            *va_arg(ap, uint16_t *) = td->td_minsamplevalue;
  339|      0|            return (1);
  340|      0|        case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|      0|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (340:9): [True: 0, False: 8.69k]
  ------------------
  341|      0|        {
  342|      0|            uint16_t maxsamplevalue;
  343|       |            /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
  344|       |             * Therefore, td_maxsamplevalue has to be re-calculated in
  345|       |             * TIFFGetFieldDefaulted(). */
  346|      0|            if (td->td_bitspersample > 0)
  ------------------
  |  Branch (346:17): [True: 0, False: 0]
  ------------------
  347|      0|            {
  348|       |                /* This shift operation into a uint16_t limits the value to
  349|       |                 * 65535 even if td_bitspersamle is > 16 */
  350|      0|                if (td->td_bitspersample <= 16)
  ------------------
  |  Branch (350:21): [True: 0, False: 0]
  ------------------
  351|      0|                {
  352|      0|                    maxsamplevalue = (uint16_t)((1U << td->td_bitspersample) -
  353|      0|                                                1); /* 2**(BitsPerSample) - 1 */
  354|      0|                }
  355|      0|                else
  356|      0|                {
  357|      0|                    maxsamplevalue = 65535;
  358|      0|                }
  359|      0|            }
  360|      0|            else
  361|      0|            {
  362|      0|                maxsamplevalue = 0;
  363|      0|            }
  364|      0|            *va_arg(ap, uint16_t *) = maxsamplevalue;
  365|      0|            return (1);
  366|      0|        }
  367|      0|        case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|      0|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (367:9): [True: 0, False: 8.69k]
  ------------------
  368|      0|            *va_arg(ap, uint16_t *) = td->td_planarconfig;
  369|      0|            return (1);
  370|      0|        case TIFFTAG_RESOLUTIONUNIT:
  ------------------
  |  |  287|      0|#define TIFFTAG_RESOLUTIONUNIT 296         /* units of resolutions */
  ------------------
  |  Branch (370:9): [True: 0, False: 8.69k]
  ------------------
  371|      0|            *va_arg(ap, uint16_t *) = td->td_resolutionunit;
  372|      0|            return (1);
  373|      0|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (373:9): [True: 0, False: 8.69k]
  ------------------
  374|      0|        {
  375|      0|            TIFFPredictorState *sp = (TIFFPredictorState *)tif->tif_data;
  376|      0|            if (sp == NULL)
  ------------------
  |  Branch (376:17): [True: 0, False: 0]
  ------------------
  377|      0|            {
  378|      0|                TIFFErrorExtR(
  379|      0|                    tif, tif->tif_name,
  380|      0|                    "Cannot get \"Predictor\" tag as plugin is not configured");
  381|      0|                *va_arg(ap, uint16_t *) = 0;
  382|      0|                return 0;
  383|      0|            }
  384|      0|            *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor;
  385|      0|            return 1;
  386|      0|        }
  387|      0|        case TIFFTAG_DOTRANGE:
  ------------------
  |  |  327|      0|#define TIFFTAG_DOTRANGE 336               /* !0% and 100% dot codes */
  ------------------
  |  Branch (387:9): [True: 0, False: 8.69k]
  ------------------
  388|      0|            *va_arg(ap, uint16_t *) = 0;
  389|      0|            if (td->td_bitspersample <= 16)
  ------------------
  |  Branch (389:17): [True: 0, False: 0]
  ------------------
  390|      0|                *va_arg(ap, uint16_t *) =
  391|      0|                    (uint16_t)((1U << td->td_bitspersample) - 1);
  392|      0|            else
  393|      0|                *va_arg(ap, uint16_t *) = 65535;
  394|      0|            return (1);
  395|    158|        case TIFFTAG_INKSET:
  ------------------
  |  |  322|    158|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  |  Branch (395:9): [True: 158, False: 8.54k]
  ------------------
  396|    158|            *va_arg(ap, uint16_t *) = INKSET_CMYK;
  ------------------
  |  |  323|    158|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  397|    158|            return 1;
  398|      0|        case TIFFTAG_NUMBEROFINKS:
  ------------------
  |  |  326|      0|#define TIFFTAG_NUMBEROFINKS 334           /* !number of inks */
  ------------------
  |  Branch (398:9): [True: 0, False: 8.69k]
  ------------------
  399|      0|            *va_arg(ap, uint16_t *) = 4;
  400|      0|            return (1);
  401|  1.54k|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|  1.54k|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (401:9): [True: 1.54k, False: 7.14k]
  ------------------
  402|  1.54k|            *va_arg(ap, uint16_t *) = td->td_extrasamples;
  403|  1.54k|            *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
  404|  1.54k|            return (1);
  405|      0|        case TIFFTAG_MATTEING:
  ------------------
  |  |  405|      0|#define TIFFTAG_MATTEING 32995   /* $use ExtraSamples */
  ------------------
  |  Branch (405:9): [True: 0, False: 8.69k]
  ------------------
  406|      0|            *va_arg(ap, uint16_t *) =
  407|      0|                (td->td_extrasamples == 1 && td->td_sampleinfo &&
  ------------------
  |  Branch (407:18): [True: 0, False: 0]
  |  Branch (407:46): [True: 0, False: 0]
  ------------------
  408|      0|                 td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
  ------------------
  |  |  331|      0|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (408:18): [True: 0, False: 0]
  ------------------
  409|      0|            return (1);
  410|      0|        case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|      0|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (410:9): [True: 0, False: 8.69k]
  ------------------
  411|      0|            *va_arg(ap, uint32_t *) = td->td_tiledepth;
  412|      0|            return (1);
  413|      0|        case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|      0|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (413:9): [True: 0, False: 8.69k]
  ------------------
  414|      0|            *va_arg(ap, uint16_t *) = (uint16_t)(td->td_sampleformat - 1);
  415|      0|            return (1);
  416|      0|        case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (416:9): [True: 0, False: 8.69k]
  ------------------
  417|      0|            *va_arg(ap, uint16_t *) = td->td_sampleformat;
  418|      0|            return (1);
  419|      0|        case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|      0|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (419:9): [True: 0, False: 8.69k]
  ------------------
  420|      0|            *va_arg(ap, uint32_t *) = td->td_imagedepth;
  421|      0|            return (1);
  422|    795|        case TIFFTAG_YCBCRCOEFFICIENTS:
  ------------------
  |  |  387|    795|#define TIFFTAG_YCBCRCOEFFICIENTS 529      /* !RGB -> YCbCr transform */
  ------------------
  |  Branch (422:9): [True: 795, False: 7.90k]
  ------------------
  423|    795|        {
  424|       |            /* defaults are from CCIR Recommendation 601-1 */
  425|    795|            static const float ycbcrcoeffs[] = {0.299f, 0.587f, 0.114f};
  426|    795|            *va_arg(ap, const float **) = ycbcrcoeffs;
  427|    795|            return 1;
  428|      0|        }
  429|  2.90k|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|  2.90k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (429:9): [True: 2.90k, False: 5.79k]
  ------------------
  430|  2.90k|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
  431|  2.90k|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
  432|  2.90k|            return (1);
  433|      0|        case TIFFTAG_YCBCRPOSITIONING:
  ------------------
  |  |  389|      0|#define TIFFTAG_YCBCRPOSITIONING 531       /* !subsample positioning */
  ------------------
  |  Branch (433:9): [True: 0, False: 8.69k]
  ------------------
  434|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
  435|      0|            return (1);
  436|     22|        case TIFFTAG_WHITEPOINT:
  ------------------
  |  |  307|     22|#define TIFFTAG_WHITEPOINT 318             /* image white point */
  ------------------
  |  Branch (436:9): [True: 22, False: 8.67k]
  ------------------
  437|     22|        {
  438|       |            /* TIFF 6.0 specification tells that it is no default
  439|       |               value for the WhitePoint, but AdobePhotoshop TIFF
  440|       |               Technical Note tells that it should be CIE D50. */
  441|     22|            static const float whitepoint[] = {
  442|     22|                D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  132|     22|#define D50_X0 (96.4250f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  132|     22|#define D50_X0 (96.4250f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  133|     22|#define D50_Y0 (100.0f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  134|     22|#define D50_Z0 (82.4680f)
  ------------------
  443|     22|                D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  133|     22|#define D50_Y0 (100.0f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  132|     22|#define D50_X0 (96.4250f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  133|     22|#define D50_Y0 (100.0f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  134|     22|#define D50_Z0 (82.4680f)
  ------------------
  444|     22|            *va_arg(ap, const float **) = whitepoint;
  445|     22|            return 1;
  446|      0|        }
  447|      0|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      0|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (447:9): [True: 0, False: 8.69k]
  ------------------
  448|      0|            if (!td->td_transferfunction[0] &&
  ------------------
  |  Branch (448:17): [True: 0, False: 0]
  ------------------
  449|      0|                !TIFFDefaultTransferFunction(tif, td))
  ------------------
  |  Branch (449:17): [True: 0, False: 0]
  ------------------
  450|      0|            {
  451|      0|                TIFFErrorExtR(tif, tif->tif_name,
  452|      0|                              "No space for \"TransferFunction\" tag");
  453|      0|                return (0);
  454|      0|            }
  455|      0|            *va_arg(ap, const uint16_t **) = td->td_transferfunction[0];
  456|      0|            if (td->td_samplesperpixel - td->td_extrasamples > 1)
  ------------------
  |  Branch (456:17): [True: 0, False: 0]
  ------------------
  457|      0|            {
  458|      0|                *va_arg(ap, const uint16_t **) = td->td_transferfunction[1];
  459|      0|                *va_arg(ap, const uint16_t **) = td->td_transferfunction[2];
  460|      0|            }
  461|      0|            return (1);
  462|    694|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|    694|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (462:9): [True: 694, False: 8.00k]
  ------------------
  463|    694|            if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(tif, td))
  ------------------
  |  Branch (463:17): [True: 694, False: 0]
  |  Branch (463:42): [True: 0, False: 694]
  ------------------
  464|      0|                return (0);
  465|    694|            *va_arg(ap, const float **) = td->td_refblackwhite;
  466|    694|            return (1);
  467|      0|        default:
  ------------------
  |  Branch (467:9): [True: 0, False: 8.69k]
  ------------------
  468|      0|            break;
  469|  8.69k|    }
  470|      0|    return 0;
  471|  8.69k|}
TIFFGetFieldDefaulted:
  478|  28.5k|{
  479|  28.5k|    int ok;
  480|  28.5k|    va_list ap;
  481|       |
  482|  28.5k|    va_start(ap, tag);
  483|  28.5k|    ok = TIFFVGetFieldDefaulted(tif, tag, ap);
  484|       |    va_end(ap);
  485|  28.5k|    return (ok);
  486|  28.5k|}
_TIFFClampDoubleToFloat:
  489|  1.68k|{
  490|  1.68k|    if (val > (double)FLT_MAX)
  ------------------
  |  Branch (490:9): [True: 0, False: 1.68k]
  ------------------
  491|      0|        return FLT_MAX;
  492|  1.68k|    if (val < -(double)FLT_MAX)
  ------------------
  |  Branch (492:9): [True: 0, False: 1.68k]
  ------------------
  493|      0|        return -FLT_MAX;
  494|  1.68k|    return (float)val;
  495|  1.68k|}
_TIFFSeekOK:
  507|  66.3k|{
  508|       |    /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
  509|       |    /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
  510|  66.3k|    return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off;
  ------------------
  |  |  287|  66.3k|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
  |  Branch (510:12): [True: 66.3k, False: 14]
  |  Branch (510:41): [True: 62.7k, False: 3.54k]
  ------------------
  511|  66.3k|}
tif_aux.c:TIFFDefaultRefBlackWhite:
  265|    694|{
  266|    694|    int i;
  267|       |
  268|    694|    td->td_refblackwhite = (float *)_TIFFmallocExt(tif, 6 * sizeof(float));
  269|    694|    if (td->td_refblackwhite == NULL)
  ------------------
  |  Branch (269:9): [True: 0, False: 694]
  ------------------
  270|      0|        return 0;
  271|    694|    if (td->td_photometric == PHOTOMETRIC_YCBCR)
  ------------------
  |  |  227|    694|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (271:9): [True: 694, False: 0]
  ------------------
  272|    694|    {
  273|       |        /*
  274|       |         * YCbCr (Class Y) images must have the ReferenceBlackWhite
  275|       |         * tag set. Fix the broken images, which lacks that tag.
  276|       |         */
  277|    694|        td->td_refblackwhite[0] = 0.0f;
  278|    694|        td->td_refblackwhite[1] = td->td_refblackwhite[3] =
  279|    694|            td->td_refblackwhite[5] = 255.0f;
  280|    694|        td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0f;
  281|    694|    }
  282|      0|    else
  283|      0|    {
  284|       |        /*
  285|       |         * Assume RGB (Class R)
  286|       |         */
  287|      0|        for (i = 0; i < 3; i++)
  ------------------
  |  Branch (287:21): [True: 0, False: 0]
  ------------------
  288|      0|        {
  289|      0|            td->td_refblackwhite[2 * i + 0] = 0;
  290|      0|            if (td->td_bitspersample < 64)
  ------------------
  |  Branch (290:17): [True: 0, False: 0]
  ------------------
  291|      0|                td->td_refblackwhite[2 * i + 1] =
  292|      0|                    (float)((1ULL << td->td_bitspersample) - 1ULL);
  293|      0|            else
  294|      0|                td->td_refblackwhite[2 * i + 1] = (float)UINT64_MAX;
  295|      0|        }
  296|      0|    }
  297|    694|    return 1;
  298|    694|}

TIFFCleanup:
   45|  1.28k|{
   46|       |    /*
   47|       |     * Flush buffered data and directory (if dirty).
   48|       |     */
   49|  1.28k|    if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (49:9): [True: 0, False: 1.28k]
  ------------------
   50|      0|        TIFFFlush(tif);
   51|  1.28k|    TIFFFreeDirectory(tif);
   52|       |
   53|  1.28k|    _TIFFCleanupIFDOffsetAndNumberMaps(tif);
   54|       |
   55|       |    /*
   56|       |     * Clean up client info links.
   57|       |     */
   58|  1.28k|    while (tif->tif_clientinfo)
  ------------------
  |  Branch (58:12): [True: 0, False: 1.28k]
  ------------------
   59|      0|    {
   60|      0|        TIFFClientInfoLink *psLink = tif->tif_clientinfo;
   61|       |
   62|      0|        tif->tif_clientinfo = psLink->next;
   63|      0|        _TIFFfreeExt(tif, psLink->name);
   64|      0|        _TIFFfreeExt(tif, psLink);
   65|      0|    }
   66|       |
   67|  1.28k|    if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER))
  ------------------
  |  |  128|    530|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (67:9): [True: 530, False: 750]
  |  Branch (67:29): [True: 530, False: 0]
  ------------------
   68|    530|        _TIFFfreeExt(tif, tif->tif_rawdata);
   69|  1.28k|    if (isMapped(tif))
  ------------------
  |  |  279|  1.28k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  1.28k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 1.28k]
  |  |  ------------------
  ------------------
   70|      0|        TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
  ------------------
  |  |  293|      0|    ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))
  ------------------
   71|       |
   72|       |    /*
   73|       |     * Clean up custom fields.
   74|       |     */
   75|  1.28k|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (75:9): [True: 1.27k, False: 4]
  |  Branch (75:28): [True: 1.27k, False: 0]
  ------------------
   76|  1.27k|    {
   77|  1.27k|        uint32_t i;
   78|       |
   79|   297k|        for (i = 0; i < tif->tif_nfields; i++)
  ------------------
  |  Branch (79:21): [True: 295k, False: 1.27k]
  ------------------
   80|   295k|        {
   81|   295k|            TIFFField *fld = tif->tif_fields[i];
   82|   295k|            if (fld->field_name != NULL)
  ------------------
  |  Branch (82:17): [True: 295k, False: 0]
  ------------------
   83|   295k|            {
   84|   295k|                if (fld->field_bit == FIELD_CUSTOM &&
  ------------------
  |  |  346|   591k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (84:21): [True: 227k, False: 68.3k]
  ------------------
   85|       |                    /* caution: tif_fields[i] must not be the beginning of a
   86|       |                     * fields-array. Otherwise the following tags are also freed
   87|       |                     * with the first free().
   88|       |                     */
   89|   227k|                    TIFFFieldIsAnonymous(fld))
  ------------------
  |  Branch (89:21): [True: 96.1k, False: 131k]
  ------------------
   90|  96.1k|                {
   91|  96.1k|                    _TIFFfreeExt(tif, (void *)fld->field_name);
   92|  96.1k|                    _TIFFfreeExt(tif, fld);
   93|  96.1k|                }
   94|   295k|            }
   95|   295k|        }
   96|       |
   97|  1.27k|        _TIFFfreeExt(tif, tif->tif_fields);
   98|  1.27k|    }
   99|       |
  100|  1.28k|    if (tif->tif_nfieldscompat > 0)
  ------------------
  |  Branch (100:9): [True: 0, False: 1.28k]
  ------------------
  101|      0|    {
  102|      0|        uint32_t i;
  103|       |
  104|      0|        for (i = 0; i < tif->tif_nfieldscompat; i++)
  ------------------
  |  Branch (104:21): [True: 0, False: 0]
  ------------------
  105|      0|        {
  106|      0|            if (tif->tif_fieldscompat[i].allocated_size)
  ------------------
  |  Branch (106:17): [True: 0, False: 0]
  ------------------
  107|      0|                _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields);
  108|      0|        }
  109|      0|        _TIFFfreeExt(tif, tif->tif_fieldscompat);
  110|      0|    }
  111|       |
  112|  1.28k|    if (tif->tif_cur_cumulated_mem_alloc != 0)
  ------------------
  |  Branch (112:9): [True: 0, False: 1.28k]
  ------------------
  113|      0|    {
  114|      0|        TIFFErrorExtR(tif, "TIFFCleanup",
  115|      0|                      "tif_cur_cumulated_mem_alloc = %" PRIu64 " whereas it "
  116|      0|                      "should be 0",
  117|      0|                      (uint64_t)tif->tif_cur_cumulated_mem_alloc);
  118|      0|    }
  119|       |
  120|       |    _TIFFfreeExt(NULL, tif);
  121|  1.28k|}
_TIFFCleanupIFDOffsetAndNumberMaps:
  128|  1.28k|{
  129|  1.28k|    if (tif->tif_map_dir_offset_to_number)
  ------------------
  |  Branch (129:9): [True: 1.27k, False: 3]
  ------------------
  130|  1.27k|    {
  131|  1.27k|        TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
  132|  1.27k|        tif->tif_map_dir_offset_to_number = NULL;
  133|  1.27k|    }
  134|  1.28k|    if (tif->tif_map_dir_number_to_offset)
  ------------------
  |  Branch (134:9): [True: 1.27k, False: 3]
  ------------------
  135|  1.27k|    {
  136|  1.27k|        TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
  137|       |        tif->tif_map_dir_number_to_offset = NULL;
  138|  1.27k|    }
  139|  1.28k|}
TIFFClose:
  156|    993|{
  157|    993|    if (tif != NULL)
  ------------------
  |  Branch (157:9): [True: 993, False: 0]
  ------------------
  158|    993|    {
  159|    993|        TIFFCloseProc closeproc = tif->tif_closeproc;
  160|    993|        thandle_t fd = tif->tif_clientdata;
  161|       |
  162|    993|        TIFFCleanup(tif);
  163|    993|        (void)(*closeproc)(fd);
  164|    993|    }
  165|    993|}

TIFFIsCODECConfigured:
  147|  6.69k|{
  148|  6.69k|    const TIFFCodec *codec = TIFFFindCODEC(scheme);
  149|       |
  150|  6.69k|    if (codec == NULL)
  ------------------
  |  Branch (150:9): [True: 228, False: 6.46k]
  ------------------
  151|    228|    {
  152|    228|        return 0;
  153|    228|    }
  154|  6.46k|    if (codec->init == NULL)
  ------------------
  |  Branch (154:9): [True: 0, False: 6.46k]
  ------------------
  155|      0|    {
  156|      0|        return 0;
  157|      0|    }
  158|  6.46k|    if (codec->init != NotConfigured)
  ------------------
  |  Branch (158:9): [True: 6.46k, False: 8]
  ------------------
  159|  6.46k|    {
  160|  6.46k|        return 1;
  161|  6.46k|    }
  162|      8|    return 0;
  163|  6.46k|}
tif_codec.c:NotConfigured:
  124|      2|{
  125|      2|    (void)scheme;
  126|       |
  127|      2|    tif->tif_fixuptags = _notConfigured;
  128|      2|    tif->tif_decodestatus = FALSE;
  ------------------
  |  |   72|      2|#define FALSE 0
  ------------------
  129|      2|    tif->tif_setupdecode = _notConfigured;
  130|      2|    tif->tif_encodestatus = FALSE;
  ------------------
  |  |   72|      2|#define FALSE 0
  ------------------
  131|      2|    tif->tif_setupencode = _notConfigured;
  132|      2|    return (1);
  133|      2|}
tif_codec.c:_notConfigured:
  111|      2|{
  112|      2|    const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
  113|      2|    char compression_code[20];
  114|       |
  115|      2|    snprintf(compression_code, sizeof(compression_code), "%" PRIu16,
  116|      2|             tif->tif_dir.td_compression);
  117|      2|    TIFFErrorExtR(tif, tif->tif_name,
  118|      2|                  "%s compression support is not configured",
  119|      2|                  c ? c->name : compression_code);
  ------------------
  |  Branch (119:19): [True: 2, False: 0]
  ------------------
  120|      2|    return (0);
  121|      2|}

TIFFCIELabToXYZ:
   46|  2.24k|{
   47|       |    /*
   48|       |     * Keep the historical signed a * 256 and b * 256 scaling. Out-of-range
   49|       |     * callers may trigger UBSan signed-overflow reports here, but this
   50|       |     * per-pixel path intentionally does not add extra handling; see !926 for
   51|       |     * details.
   52|       |     */
   53|  2.24k|    TIFFCIELab16ToXYZ(cielab, l * 257U, a * 256, b * 256, X, Y, Z);
   54|  2.24k|}
TIFFCIELab16ToXYZ:
   64|  6.33k|{
   65|  6.33k|    float L = (float)l * 100.0f / 65535.0f;
   66|  6.33k|    float cby, tmp;
   67|       |
   68|  6.33k|    if (L < 8.856f)
  ------------------
  |  Branch (68:9): [True: 6.33k, False: 0]
  ------------------
   69|  6.33k|    {
   70|  6.33k|        *Y = (L * cielab->Y0) / 903.292f;
   71|  6.33k|        cby = 7.787f * (*Y / cielab->Y0) + 16.0f / 116.0f;
   72|  6.33k|    }
   73|      0|    else
   74|      0|    {
   75|      0|        cby = (L + 16.0f) / 116.0f;
   76|      0|        *Y = cielab->Y0 * cby * cby * cby;
   77|      0|    }
   78|       |
   79|  6.33k|    tmp = (float)a / 256.0f / 500.0f + cby;
   80|  6.33k|    if (tmp < 0.2069f)
  ------------------
  |  Branch (80:9): [True: 6.33k, False: 0]
  ------------------
   81|  6.33k|        *X = cielab->X0 * (tmp - 0.13793f) / 7.787f;
   82|      0|    else
   83|      0|        *X = cielab->X0 * tmp * tmp * tmp;
   84|       |
   85|  6.33k|    tmp = cby - (float)b / 256.0f / 200.0f;
   86|  6.33k|    if (tmp < 0.2069f)
  ------------------
  |  Branch (86:9): [True: 6.33k, False: 0]
  ------------------
   87|  6.33k|        *Z = cielab->Z0 * (tmp - 0.13793f) / 7.787f;
   88|      0|    else
   89|      0|        *Z = cielab->Z0 * tmp * tmp * tmp;
   90|  6.33k|}
TIFFXYZToRGB:
   98|  6.33k|{
   99|  6.33k|    size_t i;
  100|  6.33k|    float Yr, Yg, Yb;
  101|  6.33k|    float *matrix = &cielab->display.d_mat[0][0];
  102|       |
  103|       |    /* Multiply through the matrix to get luminosity values. */
  104|  6.33k|    Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
  105|  6.33k|    Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
  106|  6.33k|    Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
  107|       |
  108|       |    /* Clip input */
  109|  6.33k|    Yr = TIFFmax(Yr, cielab->display.d_Y0R);
  ------------------
  |  |  336|  6.33k|#define TIFFmax(A, B) ((A) > (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (336:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  110|  6.33k|    Yg = TIFFmax(Yg, cielab->display.d_Y0G);
  ------------------
  |  |  336|  6.33k|#define TIFFmax(A, B) ((A) > (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (336:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  111|  6.33k|    Yb = TIFFmax(Yb, cielab->display.d_Y0B);
  ------------------
  |  |  336|  6.33k|#define TIFFmax(A, B) ((A) > (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (336:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  112|       |
  113|       |    /* Avoid overflow in case of wrong input values */
  114|  6.33k|    Yr = TIFFmin(Yr, cielab->display.d_YCR);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  115|  6.33k|    Yg = TIFFmin(Yg, cielab->display.d_YCG);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  116|  6.33k|    Yb = TIFFmin(Yb, cielab->display.d_YCB);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  117|       |
  118|       |    /* Turn luminosity to colour value. */
  119|  6.33k|    i = (size_t)((Yr - cielab->display.d_Y0R) / cielab->rstep);
  120|  6.33k|    i = TIFFmin((size_t)cielab->range, i);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  121|  6.33k|    *r = RINT(cielab->Yr2r[i]);
  ------------------
  |  |   92|  6.33k|#define RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5f) : ((R) - 0.5f)))
  |  |  ------------------
  |  |  |  Branch (92:29): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  122|       |
  123|  6.33k|    i = (size_t)((Yg - cielab->display.d_Y0G) / cielab->gstep);
  124|  6.33k|    i = TIFFmin((size_t)cielab->range, i);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  125|  6.33k|    *g = RINT(cielab->Yg2g[i]);
  ------------------
  |  |   92|  6.33k|#define RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5f) : ((R) - 0.5f)))
  |  |  ------------------
  |  |  |  Branch (92:29): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  126|       |
  127|  6.33k|    i = (size_t)((Yb - cielab->display.d_Y0B) / cielab->bstep);
  128|  6.33k|    i = TIFFmin((size_t)cielab->range, i);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  129|  6.33k|    *b = RINT(cielab->Yb2b[i]);
  ------------------
  |  |   92|  6.33k|#define RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5f) : ((R) - 0.5f)))
  |  |  ------------------
  |  |  |  Branch (92:29): [True: 0, False: 6.33k]
  |  |  ------------------
  ------------------
  130|       |
  131|       |    /* Clip output. */
  132|  6.33k|    *r = TIFFmin(*r, cielab->display.d_Vrwr);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  133|  6.33k|    *g = TIFFmin(*g, cielab->display.d_Vrwg);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  134|  6.33k|    *b = TIFFmin(*b, cielab->display.d_Vrwb);
  ------------------
  |  |  337|  6.33k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 6.33k, False: 0]
  |  |  ------------------
  ------------------
  135|  6.33k|}
TIFFCIELabToRGBInit:
  144|     22|{
  145|     22|    size_t i;
  146|     22|    double dfGamma;
  147|       |
  148|     22|    cielab->range = CIELABTORGB_TABLE_RANGE;
  ------------------
  |  |  182|     22|#define CIELABTORGB_TABLE_RANGE 1500
  ------------------
  149|       |
  150|     22|    _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
  151|       |
  152|       |    /* Red */
  153|     22|    dfGamma = 1.0 / (double)cielab->display.d_gammaR;
  154|     22|    cielab->rstep =
  155|     22|        (cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
  156|  33.0k|    for (i = 0; i <= (size_t)cielab->range; i++)
  ------------------
  |  Branch (156:17): [True: 33.0k, False: 22]
  ------------------
  157|  33.0k|    {
  158|  33.0k|        cielab->Yr2r[i] = (float)cielab->display.d_Vrwr *
  159|  33.0k|                          ((float)pow((double)i / cielab->range, dfGamma));
  160|  33.0k|    }
  161|       |
  162|       |    /* Green */
  163|     22|    dfGamma = 1.0 / (double)cielab->display.d_gammaG;
  164|     22|    cielab->gstep =
  165|     22|        (cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
  166|  33.0k|    for (i = 0; i <= (size_t)cielab->range; i++)
  ------------------
  |  Branch (166:17): [True: 33.0k, False: 22]
  ------------------
  167|  33.0k|    {
  168|  33.0k|        cielab->Yg2g[i] = (float)cielab->display.d_Vrwg *
  169|  33.0k|                          ((float)pow((double)i / cielab->range, dfGamma));
  170|  33.0k|    }
  171|       |
  172|       |    /* Blue */
  173|     22|    dfGamma = 1.0 / (double)cielab->display.d_gammaB;
  174|     22|    cielab->bstep =
  175|     22|        (cielab->display.d_YCR - cielab->display.d_Y0R) / (float)cielab->range;
  176|  33.0k|    for (i = 0; i <= (size_t)cielab->range; i++)
  ------------------
  |  Branch (176:17): [True: 33.0k, False: 22]
  ------------------
  177|  33.0k|    {
  178|  33.0k|        cielab->Yb2b[i] = (float)cielab->display.d_Vrwb *
  179|  33.0k|                          ((float)pow((double)i / cielab->range, dfGamma));
  180|  33.0k|    }
  181|       |
  182|       |    /* Init reference white point */
  183|     22|    cielab->X0 = refWhite[0];
  184|     22|    cielab->Y0 = refWhite[1];
  185|     22|    cielab->Z0 = refWhite[2];
  186|       |
  187|     22|    return 0;
  188|     22|}
TIFFYCbCrtoRGB:
  208|   808k|{
  209|   808k|    int32_t i;
  210|       |
  211|       |    /* XXX: Only 8-bit YCbCr input supported for now */
  212|   808k|    Y = HICLAMP(Y, 255);
  ------------------
  |  |  204|   808k|#define HICLAMP(f, max) ((f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (204:26): [True: 0, False: 808k]
  |  |  ------------------
  ------------------
  213|   808k|    Cb = CLAMP(Cb, 0, 255);
  ------------------
  |  |  203|   808k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 0, False: 808k]
  |  |  |  Branch (203:34): [True: 0, False: 808k]
  |  |  ------------------
  ------------------
  214|   808k|    Cr = CLAMP(Cr, 0, 255);
  ------------------
  |  |  203|   808k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 0, False: 808k]
  |  |  |  Branch (203:34): [True: 0, False: 808k]
  |  |  ------------------
  ------------------
  215|       |
  216|   808k|    i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
  217|   808k|    *r = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|   808k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 321k, False: 486k]
  |  |  |  Branch (203:34): [True: 47.5k, False: 438k]
  |  |  ------------------
  ------------------
  218|   808k|    i = ycbcr->Y_tab[Y] +
  219|   808k|        ((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
  ------------------
  |  |  195|   808k|#define SHIFT 16
  ------------------
  220|   808k|    *g = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|   808k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 27.1k, False: 781k]
  |  |  |  Branch (203:34): [True: 136k, False: 644k]
  |  |  ------------------
  ------------------
  221|   808k|    i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
  222|   808k|    *b = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|   808k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 187k, False: 621k]
  |  |  |  Branch (203:34): [True: 130k, False: 490k]
  |  |  ------------------
  ------------------
  223|   808k|}
TIFFYCbCrToRGBInit:
  259|    709|{
  260|    709|    TIFFRGBValue *clamptab;
  261|    709|    int i;
  262|       |
  263|    709|#define LumaRed luma[0]
  264|    709|#define LumaGreen luma[1]
  265|    709|#define LumaBlue luma[2]
  266|       |
  267|    709|    clamptab =
  268|    709|        (uint8_t *)ycbcr + TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long));
  ------------------
  |  |  322|    709|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|    709|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 709, Folded]
  |  |  |  |  ------------------
  |  |  |  |  313|    709|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|    709|         : 0U)
  |  |  ------------------
  ------------------
  269|    709|    _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
  270|    709|    ycbcr->clamptab = (clamptab += 256);
  271|   182k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (271:17): [True: 181k, False: 709]
  ------------------
  272|   181k|        clamptab[i] = (TIFFRGBValue)i;
  273|    709|    _TIFFmemset(clamptab + 256, 255, 2 * 256); /* v > 255 => 255 */
  274|    709|    ycbcr->Cr_r_tab = (int *)(clamptab + 3 * 256);
  275|    709|    ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
  276|    709|    ycbcr->Cr_g_tab = (int32_t *)(ycbcr->Cb_b_tab + 256);
  277|    709|    ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
  278|    709|    ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
  279|       |
  280|    709|    {
  281|    709|        float f1 = 2 - 2 * LumaRed;
  ------------------
  |  |  263|    709|#define LumaRed luma[0]
  ------------------
  282|    709|        int32_t D1 = FIX(CLAMP(f1, 0.0f, 2.0f));
  ------------------
  |  |  196|  2.81k|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|    709|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 698]
  |  |  |  Branch (196:36): [True: 11, False: 698]
  |  |  ------------------
  ------------------
  283|    709|        float f2 = LumaRed * f1 / LumaGreen;
  ------------------
  |  |  263|    709|#define LumaRed luma[0]
  ------------------
                      float f2 = LumaRed * f1 / LumaGreen;
  ------------------
  |  |  264|    709|#define LumaGreen luma[1]
  ------------------
  284|    709|        int32_t D2 = -FIX(CLAMP(f2, 0.0f, 2.0f));
  ------------------
  |  |  196|  2.81k|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|    709|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 698]
  |  |  |  Branch (196:36): [True: 11, False: 698]
  |  |  ------------------
  ------------------
  285|    709|        float f3 = 2 - 2 * LumaBlue;
  ------------------
  |  |  265|    709|#define LumaBlue luma[2]
  ------------------
  286|    709|        int32_t D3 = FIX(CLAMP(f3, 0.0f, 2.0f));
  ------------------
  |  |  196|  2.82k|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|    709|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 702]
  |  |  |  Branch (196:36): [True: 7, False: 702]
  |  |  ------------------
  ------------------
  287|    709|        float f4 = LumaBlue * f3 / LumaGreen;
  ------------------
  |  |  265|    709|#define LumaBlue luma[2]
  ------------------
                      float f4 = LumaBlue * f3 / LumaGreen;
  ------------------
  |  |  264|    709|#define LumaGreen luma[1]
  ------------------
  288|    709|        int32_t D4 = -FIX(CLAMP(f4, 0.0f, 2.0f));
  ------------------
  |  |  196|  2.82k|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|    709|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 702]
  |  |  |  Branch (196:36): [True: 7, False: 702]
  |  |  ------------------
  ------------------
  289|    709|        int x;
  290|       |
  291|    709|#undef LumaBlue
  292|    709|#undef LumaGreen
  293|    709|#undef LumaRed
  294|       |
  295|       |        /*
  296|       |         * i is the actual input pixel value in the range 0..255
  297|       |         * Cb and Cr values are in the range -128..127 (actually
  298|       |         * they are in a range defined by the ReferenceBlackWhite
  299|       |         * tag) so there is some range shifting to do here when
  300|       |         * constructing tables indexed by the raw pixel data.
  301|       |         */
  302|   182k|        for (i = 0, x = -128; i < 256; i++, x++)
  ------------------
  |  Branch (302:31): [True: 181k, False: 709]
  ------------------
  303|   181k|        {
  304|   181k|            int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0f,
  ------------------
  |  |  199|   181k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|   181k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|   181k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 177k, False: 4.09k]
  |  |  ------------------
  ------------------
  305|   181k|                                                refBlackWhite[5] - 128.0f, 127),
  306|   181k|                                         -128.0f * 32, 128.0f * 32);
  307|   181k|            int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0f,
  ------------------
  |  |  199|   181k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|   181k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|   181k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 176k, False: 4.86k]
  |  |  ------------------
  ------------------
  308|   181k|                                                refBlackWhite[3] - 128.0f, 127),
  309|   181k|                                         -128.0f * 32, 128.0f * 32);
  310|       |
  311|   181k|            ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT);
  ------------------
  |  |  197|   181k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|   181k|#define SHIFT 16
  |  |  ------------------
  ------------------
                          ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT);
  ------------------
  |  |  195|   181k|#define SHIFT 16
  ------------------
  312|   181k|            ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT);
  ------------------
  |  |  197|   181k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|   181k|#define SHIFT 16
  |  |  ------------------
  ------------------
                          ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT);
  ------------------
  |  |  195|   181k|#define SHIFT 16
  ------------------
  313|   181k|            ycbcr->Cr_g_tab[i] = D2 * Cr;
  314|   181k|            ycbcr->Cb_g_tab[i] = D4 * Cb + ONE_HALF;
  ------------------
  |  |  197|   181k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|   181k|#define SHIFT 16
  |  |  ------------------
  ------------------
  315|   181k|            ycbcr->Y_tab[i] = (int32_t)CLAMPw(
  316|   181k|                Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
  ------------------
  |  |  199|   181k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|   181k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|   181k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 176k, False: 4.86k]
  |  |  ------------------
  ------------------
  317|   181k|                -128.0f * 32, 128.0f * 32);
  318|   181k|        }
  319|    709|    }
  320|       |
  321|    709|    return 0;
  322|    709|}
tif_color.c:CLAMPw:
  228|   544k|{
  229|   544k|    if (v < vmin)
  ------------------
  |  Branch (229:9): [True: 573, False: 543k]
  ------------------
  230|    573|    {
  231|       |        /* printf("%f clamped to %f\n", v, vmin); */
  232|    573|        return vmin;
  233|    573|    }
  234|   543k|    if (v > vmax)
  ------------------
  |  Branch (234:9): [True: 12.3k, False: 531k]
  ------------------
  235|  12.3k|    {
  236|       |        /* printf("%f clamped to %f\n", v, vmax); */
  237|  12.3k|        return vmax;
  238|  12.3k|    }
  239|   531k|    return v;
  240|   543k|}

_TIFFNoStripDecode:
  105|     40|{
  106|     40|    (void)pp;
  107|     40|    (void)cc;
  108|     40|    (void)s;
  109|     40|    return (TIFFNoDecode(tif, "strip"));
  110|     40|}
_TIFFNoTileDecode:
  113|     35|{
  114|     35|    (void)pp;
  115|     35|    (void)cc;
  116|     35|    (void)s;
  117|     35|    return (TIFFNoDecode(tif, "tile"));
  118|     35|}
_TIFFNoPreCode:
  129|  3.82k|{
  130|  3.82k|    (void)tif;
  131|  3.82k|    (void)s;
  132|  3.82k|    return (1);
  133|  3.82k|}
_TIFFSetDefaultCompressionState:
  155|  9.22k|{
  156|  9.22k|    tif->tif_fixuptags = _TIFFNoFixupTags;
  157|  9.22k|    tif->tif_decodestatus = TRUE;
  ------------------
  |  |   71|  9.22k|#define TRUE 1
  ------------------
  158|  9.22k|    tif->tif_setupdecode = _TIFFtrue;
  159|  9.22k|    tif->tif_predecode = _TIFFNoPreCode;
  160|  9.22k|    tif->tif_decoderow = _TIFFNoRowDecode;
  161|  9.22k|    tif->tif_decodestrip = _TIFFNoStripDecode;
  162|  9.22k|    tif->tif_decodetile = _TIFFNoTileDecode;
  163|  9.22k|    tif->tif_encodestatus = TRUE;
  ------------------
  |  |   71|  9.22k|#define TRUE 1
  ------------------
  164|  9.22k|    tif->tif_setupencode = _TIFFtrue;
  165|  9.22k|    tif->tif_preencode = _TIFFNoPreCode;
  166|  9.22k|    tif->tif_postencode = _TIFFtrue;
  167|  9.22k|    tif->tif_encoderow = _TIFFNoRowEncode;
  168|  9.22k|    tif->tif_encodestrip = _TIFFNoStripEncode;
  169|  9.22k|    tif->tif_encodetile = _TIFFNoTileEncode;
  170|  9.22k|    tif->tif_close = _TIFFvoid;
  171|  9.22k|    tif->tif_seek = _TIFFNoSeek;
  172|  9.22k|    tif->tif_cleanup = _TIFFvoid;
  173|  9.22k|    tif->tif_defstripsize = _TIFFDefaultStripSize;
  174|  9.22k|    tif->tif_deftilesize = _TIFFDefaultTileSize;
  175|  9.22k|    tif->tif_getmaxcompressionratio = _TIFFDefaultGetMaxCompressionRatio;
  176|  9.22k|    tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW);
  ------------------
  |  |  127|  9.22k|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
                  tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW);
  ------------------
  |  |  138|  9.22k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  177|  9.22k|}
TIFFSetCompressionScheme:
  180|  5.56k|{
  181|  5.56k|    const TIFFCodec *c = TIFFFindCODEC((uint16_t)scheme);
  182|       |
  183|  5.56k|    _TIFFSetDefaultCompressionState(tif);
  184|  5.56k|    if (scheme == COMPRESSION_NONE)
  ------------------
  |  |  182|  5.56k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (184:9): [True: 3.00k, False: 2.56k]
  ------------------
  185|  3.00k|        tif->tif_getmaxcompressionratio = _TIFFGetMaxCompressionRatioOne;
  186|       |    /*
  187|       |     * Don't treat an unknown compression scheme as an error.
  188|       |     * This permits applications to open files with data that
  189|       |     * the library does not have builtin support for, but which
  190|       |     * may still be meaningful.
  191|       |     */
  192|  5.56k|    return (c ? (*c->init)(tif, scheme) : 1);
  ------------------
  |  Branch (192:13): [True: 5.45k, False: 109]
  ------------------
  193|  5.56k|}
TIFFGetMaxCompressionRatio:
  196|     37|{
  197|     37|    if (tif->tif_getmaxcompressionratio)
  ------------------
  |  Branch (197:9): [True: 37, False: 0]
  ------------------
  198|     37|        return tif->tif_getmaxcompressionratio(tif);
  199|      0|    return 0;
  200|     37|}
TIFFFindCODEC:
  215|  12.3k|{
  216|  12.3k|    const TIFFCodec *c;
  217|  12.3k|    codec_t *cd;
  218|       |
  219|  12.3k|    for (cd = registeredCODECS; cd; cd = cd->next)
  ------------------
  |  Branch (219:33): [True: 0, False: 12.3k]
  ------------------
  220|      0|        if (cd->info->scheme == scheme)
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|      0|            return ((const TIFFCodec *)cd->info);
  222|  74.1k|    for (c = _TIFFBuiltinCODECS; c->name; c++)
  ------------------
  |  Branch (222:34): [True: 73.7k, False: 412]
  ------------------
  223|  73.7k|        if (c->scheme == scheme)
  ------------------
  |  Branch (223:13): [True: 11.9k, False: 61.8k]
  ------------------
  224|  11.9k|            return (c);
  225|    412|    return NULL;
  226|  12.3k|}
tif_compress.c:TIFFNoDecode:
   76|     75|{
   77|     75|    const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
   78|       |
   79|     75|    if (c)
  ------------------
  |  Branch (79:9): [True: 0, False: 75]
  ------------------
   80|      0|        TIFFErrorExtR(tif, tif->tif_name, "%s %s decoding is not implemented",
   81|      0|                      c->name, method);
   82|     75|    else
   83|     75|        TIFFErrorExtR(tif, tif->tif_name,
   84|     75|                      "Compression scheme %" PRIu16
   85|     75|                      " %s decoding is not implemented",
   86|     75|                      tif->tif_dir.td_compression, method);
   87|     75|    return (0);
   88|     75|}
tif_compress.c:_TIFFNoFixupTags:
   91|    156|{
   92|    156|    (void)tif;
   93|    156|    return (1);
   94|    156|}
tif_compress.c:_TIFFtrue:
  136|    124|{
  137|    124|    (void)tif;
  138|    124|    return (1);
  139|    124|}
tif_compress.c:_TIFFvoid:
  140|  4.46k|static void _TIFFvoid(TIFF *tif) { (void)tif; }
tif_compress.c:_TIFFDefaultGetMaxCompressionRatio:
  143|     15|{
  144|     15|    (void)tif;
  145|     15|    return 0; /* unknown */
  146|     15|}

_TIFFsetByteArrayExt:
   67|     10|{
   68|     10|    setByteArray(tif, vpp, vp, n, 1);
   69|     10|}
_TIFFsetShortArrayExt:
   82|  1.29k|{
   83|  1.29k|    setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t));
   84|  1.29k|}
_TIFFsetFloatArrayExt:
  107|    578|{
  108|    578|    setByteArray(tif, (void **)fpp, fp, n, sizeof(float));
  109|    578|}
_TIFFsetDoubleArrayExt:
  117|    229|{
  118|    229|    setByteArray(tif, (void **)dpp, dp, n, sizeof(double));
  119|    229|}
TIFFSetField:
 1168|  47.1k|{
 1169|  47.1k|    va_list ap;
 1170|  47.1k|    int status;
 1171|       |
 1172|  47.1k|    va_start(ap, tag);
 1173|  47.1k|    status = TIFFVSetField(tif, tag, ap);
 1174|       |    va_end(ap);
 1175|  47.1k|    return (status);
 1176|  47.1k|}
TIFFVSetField:
 1227|  47.1k|{
 1228|  47.1k|    return OkToChangeTag(tif, tag)
  ------------------
  |  Branch (1228:12): [True: 47.1k, False: 0]
  ------------------
 1229|  47.1k|               ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap)
 1230|  47.1k|               : 0;
 1231|  47.1k|}
TIFFGetField:
 1608|  20.4k|{
 1609|  20.4k|    int status;
 1610|  20.4k|    va_list ap;
 1611|       |
 1612|  20.4k|    va_start(ap, tag);
 1613|  20.4k|    status = TIFFVGetField(tif, tag, ap);
 1614|       |    va_end(ap);
 1615|  20.4k|    return (status);
 1616|  20.4k|}
TIFFVGetField:
 1625|  49.0k|{
 1626|  49.0k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  49.0k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1627|  49.0k|    return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
  ------------------
  |  |  276|  98.0k|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 49.0k]
  |  |  ------------------
  ------------------
                  return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
  ------------------
  |  |  248|  49.0k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  49.0k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  49.0k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 39.4k, False: 9.58k]
  |  |  ------------------
  ------------------
  |  Branch (1627:13): [True: 49.0k, False: 0]
  ------------------
 1628|  49.0k|                ? (*tif->tif_tagmethods.vgetfield)(tif, tag, ap)
 1629|  49.0k|                : 0);
 1630|  49.0k|}
_TIFFResetTifDirAndInitStrileCounters:
 1646|  4.28k|{
 1647|  4.28k|    _TIFFmemset(td, 0, sizeof(*td));
 1648|  4.28k|    td->td_curstrip = NOSTRIP;      /* invalid strip = NOSTRIP */
  ------------------
  |  |  111|  4.28k|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
 1649|  4.28k|    td->td_row = (uint32_t)-1;      /* read/write pre-increment */
 1650|  4.28k|    td->td_col = (uint32_t)-1;      /* read/write pre-increment */
 1651|  4.28k|    td->td_scanlinesize = 0;        /* initialize to zero */
 1652|  4.28k|    td->td_curtile = NOTILE;        /* invalid tile = NOTILE */
  ------------------
  |  |  116|  4.28k|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1653|  4.28k|    td->td_tilesize = (tmsize_t)-1; /* invalidate tilezize */
 1654|  4.28k|}
TIFFFreeDirectory:
 1660|  4.28k|{
 1661|  4.28k|    TIFFDirectory *td = &tif->tif_dir;
 1662|  4.28k|    int i;
 1663|       |
 1664|  4.28k|    (*tif->tif_cleanup)(tif);
 1665|  4.28k|    _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
 1666|  4.28k|    CleanupField(td_sminsamplevalue);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 122, False: 4.16k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|    122|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|    122|            td->member = 0;                                                    \
  |  | 1638|    122|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1667|  4.28k|    CleanupField(td_smaxsamplevalue);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 8, False: 4.27k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|      8|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      8|            td->member = 0;                                                    \
  |  | 1638|      8|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1668|  4.28k|    CleanupField(td_colormap[0]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 34, False: 4.24k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|     34|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     34|            td->member = 0;                                                    \
  |  | 1638|     34|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1669|  4.28k|    CleanupField(td_colormap[1]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 34, False: 4.24k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|     34|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     34|            td->member = 0;                                                    \
  |  | 1638|     34|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1670|  4.28k|    CleanupField(td_colormap[2]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 34, False: 4.24k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|     34|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     34|            td->member = 0;                                                    \
  |  | 1638|     34|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1671|  4.28k|    CleanupField(td_sampleinfo);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 1.05k, False: 3.22k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|  1.05k|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|  1.05k|            td->member = 0;                                                    \
  |  | 1638|  1.05k|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1672|  4.28k|    CleanupField(td_subifd);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 10, False: 4.27k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|     10|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     10|            td->member = 0;                                                    \
  |  | 1638|     10|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1673|  4.28k|    CleanupField(td_inknames);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 44, False: 4.23k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|     44|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     44|            td->member = 0;                                                    \
  |  | 1638|     44|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1674|  4.28k|    CleanupField(td_refblackwhite);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 1.27k, False: 3.01k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|  1.27k|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|  1.27k|            td->member = 0;                                                    \
  |  | 1638|  1.27k|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1675|  4.28k|    CleanupField(td_transferfunction[0]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 4, False: 4.27k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|      4|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      4|            td->member = 0;                                                    \
  |  | 1638|      4|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1676|  4.28k|    CleanupField(td_transferfunction[1]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 4, False: 4.27k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|      4|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      4|            td->member = 0;                                                    \
  |  | 1638|      4|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1677|  4.28k|    CleanupField(td_transferfunction[2]);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 4, False: 4.27k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|      4|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      4|            td->member = 0;                                                    \
  |  | 1638|      4|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1678|  4.28k|    CleanupField(td_stripoffset_p);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2.50k, False: 1.78k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|  2.50k|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|  2.50k|            td->member = 0;                                                    \
  |  | 1638|  2.50k|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1679|  4.28k|    CleanupField(td_stripbytecount_p);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2.27k, False: 2.01k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|  2.27k|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|  2.27k|            td->member = 0;                                                    \
  |  | 1638|  2.27k|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1680|  4.28k|    td->td_stripoffsetbyteallocsize = 0;
 1681|  4.28k|    TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
  ------------------
  |  |  250|  4.28k|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|  4.28k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|  4.28k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1682|  4.28k|    TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
  ------------------
  |  |  250|  4.28k|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|  4.28k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|  4.28k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1683|       |
 1684|       |    /* Cleanup custom tag values */
 1685|  14.6k|    for (i = 0; i < td->td_customValueCount; i++)
  ------------------
  |  Branch (1685:17): [True: 10.3k, False: 4.28k]
  ------------------
 1686|  10.3k|    {
 1687|  10.3k|        if (td->td_customValues[i].value)
  ------------------
  |  Branch (1687:13): [True: 8.72k, False: 1.66k]
  ------------------
 1688|  8.72k|            _TIFFfreeExt(tif, td->td_customValues[i].value);
 1689|  10.3k|    }
 1690|       |
 1691|  4.28k|    td->td_customValueCount = 0;
 1692|  4.28k|    CleanupField(td_customValues);
  ------------------
  |  | 1633|  4.28k|    {                                                                          \
  |  | 1634|  4.28k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2.64k, False: 1.63k]
  |  |  ------------------
  |  | 1635|  4.28k|        {                                                                      \
  |  | 1636|  2.64k|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|  2.64k|            td->member = 0;                                                    \
  |  | 1638|  2.64k|        }                                                                      \
  |  | 1639|  4.28k|    }
  ------------------
 1693|       |
 1694|  4.28k|    _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
 1695|  4.28k|    _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
 1696|       |
 1697|       |    /* Reset some internal parameters for IFD data size checking. */
 1698|  4.28k|    tif->tif_dir.td_dirdatasize_read = 0;
 1699|  4.28k|    tif->tif_dir.td_dirdatasize_write = 0;
 1700|  4.28k|    if (tif->tif_dir.td_dirdatasize_offsets != NULL)
  ------------------
  |  Branch (1700:9): [True: 3.00k, False: 1.28k]
  ------------------
 1701|  3.00k|    {
 1702|  3.00k|        _TIFFfreeExt(tif, tif->tif_dir.td_dirdatasize_offsets);
 1703|  3.00k|        tif->tif_dir.td_dirdatasize_offsets = NULL;
 1704|  3.00k|        tif->tif_dir.td_dirdatasize_Noffsets = 0;
 1705|  3.00k|    }
 1706|  4.28k|    tif->tif_dir.td_iswrittentofile = FALSE;
  ------------------
  |  |   72|  4.28k|#define FALSE 0
  ------------------
 1707|       |    /* Note: tif->tif_dir structure is set to zero in TIFFDefaultDirectory() */
 1708|  4.28k|}
TIFFDefaultDirectory:
 1788|  3.00k|{
 1789|  3.00k|    TIFFDirectory *td = &tif->tif_dir;
 1790|  3.00k|    const TIFFFieldArray *tiffFieldArray;
 1791|       |
 1792|  3.00k|    tiffFieldArray = _TIFFGetFields();
 1793|  3.00k|    _TIFFSetupFields(tif, tiffFieldArray);
 1794|       |    /* Reset tif->tif_dir structure to zero and
 1795|       |     * initialize some IFD strile counter and index parameters. */
 1796|  3.00k|    _TIFFResetTifDirAndInitStrileCounters(td);
 1797|  3.00k|    td->td_fillorder = FILLORDER_MSB2LSB;
  ------------------
  |  |  241|  3.00k|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
 1798|  3.00k|    td->td_bitspersample = 1;
 1799|  3.00k|    td->td_threshholding = THRESHHOLD_BILEVEL;
  ------------------
  |  |  235|  3.00k|#define THRESHHOLD_BILEVEL 1               /* b&w art scan */
  ------------------
 1800|  3.00k|    td->td_orientation = ORIENTATION_TOPLEFT;
  ------------------
  |  |  249|  3.00k|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
 1801|  3.00k|    td->td_samplesperpixel = 1;
 1802|  3.00k|    td->td_rowsperstrip = (uint32_t)-1;
 1803|  3.00k|    td->td_tilewidth = 0;
 1804|  3.00k|    td->td_tilelength = 0;
 1805|  3.00k|    td->td_tiledepth = 1;
 1806|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 1807|       |    td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
 1808|       |#endif
 1809|  3.00k|    td->td_resolutionunit = RESUNIT_INCH;
  ------------------
  |  |  289|  3.00k|#define RESUNIT_INCH 2                     /* english */
  ------------------
 1810|  3.00k|    td->td_sampleformat = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|  3.00k|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1811|  3.00k|    td->td_imagedepth = 1;
 1812|  3.00k|    td->td_ycbcrsubsampling[0] = 2;
 1813|  3.00k|    td->td_ycbcrsubsampling[1] = 2;
 1814|  3.00k|    td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
  ------------------
  |  |  390|  3.00k|#define YCBCRPOSITION_CENTERED 1           /* !as in PostScript Level 2 */
  ------------------
 1815|  3.00k|    tif->tif_postdecode = _TIFFNoPostDecode;
 1816|  3.00k|    tif->tif_foundfield = NULL;
 1817|  3.00k|    tif->tif_tagmethods.vsetfield = _TIFFVSetField;
 1818|  3.00k|    tif->tif_tagmethods.vgetfield = _TIFFVGetField;
 1819|  3.00k|    tif->tif_tagmethods.printdir = NULL;
 1820|       |    /* additional default values */
 1821|  3.00k|    td->td_planarconfig = PLANARCONFIG_CONTIG;
  ------------------
  |  |  265|  3.00k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
 1822|  3.00k|    td->td_compression = COMPRESSION_NONE;
  ------------------
  |  |  182|  3.00k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
 1823|  3.00k|    td->td_subfiletype = 0;
 1824|  3.00k|    td->td_minsamplevalue = 0;
 1825|       |    /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
 1826|       |     * Therefore, td_maxsamplevalue has to be re-calculated in
 1827|       |     * TIFFGetFieldDefaulted(). */
 1828|  3.00k|    td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */
 1829|  3.00k|    td->td_extrasamples = 0;
 1830|  3.00k|    td->td_sampleinfo = NULL;
 1831|       |
 1832|       |    /*
 1833|       |     *  Give client code a chance to install their own
 1834|       |     *  tag extensions & methods, prior to compression overloads,
 1835|       |     *  but do some prior cleanup first.
 1836|       |     * (http://trac.osgeo.org/gdal/ticket/5054)
 1837|       |     */
 1838|  3.00k|    if (tif->tif_nfieldscompat > 0)
  ------------------
  |  Branch (1838:9): [True: 0, False: 3.00k]
  ------------------
 1839|      0|    {
 1840|      0|        uint32_t i;
 1841|       |
 1842|      0|        for (i = 0; i < tif->tif_nfieldscompat; i++)
  ------------------
  |  Branch (1842:21): [True: 0, False: 0]
  ------------------
 1843|      0|        {
 1844|      0|            if (tif->tif_fieldscompat[i].allocated_size)
  ------------------
  |  Branch (1844:17): [True: 0, False: 0]
  ------------------
 1845|      0|                _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields);
 1846|      0|        }
 1847|      0|        _TIFFfreeExt(tif, tif->tif_fieldscompat);
 1848|      0|        tif->tif_nfieldscompat = 0;
 1849|      0|        tif->tif_fieldscompat = NULL;
 1850|      0|    }
 1851|  3.00k|    if (_TIFFextender)
  ------------------
  |  Branch (1851:9): [True: 0, False: 3.00k]
  ------------------
 1852|      0|        (*_TIFFextender)(tif);
 1853|  3.00k|    (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  ------------------
  |  |  181|  3.00k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
                  (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  ------------------
  |  |  182|  3.00k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
 1854|       |    /*
 1855|       |     * NB: The directory is marked dirty as a result of setting
 1856|       |     * up the default compression scheme.  However, this really
 1857|       |     * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
 1858|       |     * if the user does something.  We could just do the setup
 1859|       |     * by hand, but it seems better to use the normal mechanism
 1860|       |     * (i.e. TIFFSetField).
 1861|       |     */
 1862|  3.00k|    tif->tif_flags &= ~TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|  3.00k|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1863|       |
 1864|       |    /*
 1865|       |     * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
 1866|       |     * we clear the ISTILED flag when setting up a new directory.
 1867|       |     * Should we also be clearing stuff like INSUBIFD?
 1868|       |     */
 1869|  3.00k|    tif->tif_flags &= ~TIFF_ISTILED;
  ------------------
  |  |  129|  3.00k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 1870|       |
 1871|  3.00k|    return (1);
 1872|  3.00k|}
tif_dir.c:setByteArray:
   46|  3.97k|{
   47|  3.97k|    if (*vpp)
  ------------------
  |  Branch (47:9): [True: 116, False: 3.86k]
  ------------------
   48|    116|    {
   49|    116|        _TIFFfreeExt(tif, *vpp);
   50|    116|        *vpp = 0;
   51|    116|    }
   52|  3.97k|    if (vp)
  ------------------
  |  Branch (52:9): [True: 3.94k, False: 28]
  ------------------
   53|  3.94k|    {
   54|  3.94k|        tmsize_t bytes = _TIFFMultiplySSize(NULL, (tmsize_t)nmemb,
   55|  3.94k|                                            (tmsize_t)elem_size, NULL);
   56|  3.94k|        if (bytes)
  ------------------
  |  Branch (56:13): [True: 3.94k, False: 0]
  ------------------
   57|  3.94k|            *vpp = (void *)_TIFFmallocExt(tif, bytes);
   58|  3.94k|        if (*vpp)
  ------------------
  |  Branch (58:13): [True: 3.94k, False: 0]
  ------------------
   59|  3.94k|            _TIFFmemcpy(*vpp, vp, bytes);
   60|  3.94k|    }
   61|  3.97k|}
tif_dir.c:OkToChangeTag:
 1135|  47.1k|{
 1136|  47.1k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  47.1k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1137|  47.1k|    if (!fip)
  ------------------
  |  Branch (1137:9): [True: 0, False: 47.1k]
  ------------------
 1138|      0|    { /* unknown tag */
 1139|      0|        TIFFErrorExtR(tif, "TIFFSetField", "%s: Unknown %stag %" PRIu32,
 1140|      0|                      tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
  ------------------
  |  |  276|      0|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1141|      0|        return (0);
 1142|      0|    }
 1143|  47.1k|    if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
  ------------------
  |  |  179|  94.2k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
                  if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
  ------------------
  |  |  125|  44.4k|#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
  ------------------
  |  Branch (1143:9): [True: 44.4k, False: 2.72k]
  |  Branch (1143:39): [True: 0, False: 44.4k]
  ------------------
 1144|      0|        !fip->field_oktochange)
  ------------------
  |  Branch (1144:9): [True: 0, False: 0]
  ------------------
 1145|      0|    {
 1146|       |        /*
 1147|       |         * Consult info table to see if tag can be changed
 1148|       |         * after we've started writing.  We only allow changes
 1149|       |         * to those tags that don't/shouldn't affect the
 1150|       |         * compression and/or format of the data.
 1151|       |         */
 1152|      0|        TIFFErrorExtR(tif, "TIFFSetField",
 1153|      0|                      "%s: Cannot modify tag \"%s\" while writing",
 1154|      0|                      tif->tif_name, fip->field_name);
 1155|      0|        return (0);
 1156|      0|    }
 1157|  47.1k|    return (1);
 1158|  47.1k|}
tif_dir.c:_TIFFVSetField:
  224|  44.5k|{
  225|  44.5k|    static const char module[] = "_TIFFVSetField";
  226|       |
  227|  44.5k|    TIFFDirectory *td = &tif->tif_dir;
  228|  44.5k|    int status = 1;
  229|  44.5k|    uint32_t v32, v;
  230|  44.5k|    double dblval;
  231|  44.5k|    char *s;
  232|  44.5k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  44.5k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  233|  44.5k|    uint32_t standard_tag = tag;
  234|  44.5k|    if (fip == NULL) /* cannot happen since OkToChangeTag() already checks it */
  ------------------
  |  Branch (234:9): [True: 0, False: 44.5k]
  ------------------
  235|      0|        return 0;
  236|       |    /*
  237|       |     * We want to force the custom code to be used for custom
  238|       |     * fields even if the tag happens to match a well known
  239|       |     * one - important for reinterpreted handling of standard
  240|       |     * tag values in custom directories (i.e. EXIF)
  241|       |     */
  242|  44.5k|    if (fip->field_bit == FIELD_CUSTOM)
  ------------------
  |  |  346|  44.5k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (242:9): [True: 10.6k, False: 33.8k]
  ------------------
  243|  10.6k|    {
  244|  10.6k|        standard_tag = 0;
  245|  10.6k|    }
  246|       |
  247|  44.5k|    switch (standard_tag)
  248|  44.5k|    {
  249|     14|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|     14|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (249:9): [True: 14, False: 44.5k]
  ------------------
  250|     14|            td->td_subfiletype = (uint32_t)va_arg(ap, uint32_t);
  251|     14|            break;
  252|  2.97k|        case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|  2.97k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (252:9): [True: 2.97k, False: 41.5k]
  ------------------
  253|  2.97k|            td->td_imagewidth = (uint32_t)va_arg(ap, uint32_t);
  254|  2.97k|            break;
  255|  2.72k|        case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|  2.72k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (255:9): [True: 2.72k, False: 41.8k]
  ------------------
  256|  2.72k|            td->td_imagelength = (uint32_t)va_arg(ap, uint32_t);
  257|  2.72k|            break;
  258|  2.37k|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|  2.37k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (258:9): [True: 2.37k, False: 42.1k]
  ------------------
  259|  2.37k|            td->td_bitspersample = (uint16_t)va_arg(ap, uint16_vap);
  260|       |            /*
  261|       |             * If the data require post-decoding processing to byte-swap
  262|       |             * samples, set it up here.  Note that since tags are required
  263|       |             * to be ordered, compression code can override this behavior
  264|       |             * in the setup method if it wants to roll the post decoding
  265|       |             * work in with its normal work.
  266|       |             */
  267|  2.37k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  2.37k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (267:17): [True: 0, False: 2.37k]
  ------------------
  268|      0|            {
  269|      0|                if (td->td_bitspersample == 8)
  ------------------
  |  Branch (269:21): [True: 0, False: 0]
  ------------------
  270|      0|                    tif->tif_postdecode = _TIFFNoPostDecode;
  271|      0|                else if (td->td_bitspersample == 16)
  ------------------
  |  Branch (271:26): [True: 0, False: 0]
  ------------------
  272|      0|                    tif->tif_postdecode = _TIFFSwab16BitData;
  273|      0|                else if (td->td_bitspersample == 24)
  ------------------
  |  Branch (273:26): [True: 0, False: 0]
  ------------------
  274|      0|                    tif->tif_postdecode = _TIFFSwab24BitData;
  275|      0|                else if (td->td_bitspersample == 32)
  ------------------
  |  Branch (275:26): [True: 0, False: 0]
  ------------------
  276|      0|                    tif->tif_postdecode = _TIFFSwab32BitData;
  277|      0|                else if (td->td_bitspersample == 64)
  ------------------
  |  Branch (277:26): [True: 0, False: 0]
  ------------------
  278|      0|                    tif->tif_postdecode = _TIFFSwab64BitData;
  279|      0|                else if (td->td_bitspersample == 128) /* two 64's */
  ------------------
  |  Branch (279:26): [True: 0, False: 0]
  ------------------
  280|      0|                    tif->tif_postdecode = _TIFFSwab64BitData;
  281|      0|            }
  282|  2.37k|            break;
  283|  6.00k|        case TIFFTAG_COMPRESSION:
  ------------------
  |  |  181|  6.00k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (283:9): [True: 6.00k, False: 38.5k]
  ------------------
  284|  6.00k|            v = (uint16_t)va_arg(ap, uint16_vap);
  285|       |            /*
  286|       |             * If we're changing the compression scheme, notify the
  287|       |             * previous module so that it can cleanup any state it's
  288|       |             * setup.
  289|       |             */
  290|  6.00k|            if (TIFFFieldSet(tif, FIELD_COMPRESSION))
  ------------------
  |  |  248|  6.00k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  6.00k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  6.00k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 2.99k, False: 3.00k]
  |  |  ------------------
  ------------------
  291|  2.99k|            {
  292|  2.99k|                if ((uint32_t)td->td_compression == v)
  ------------------
  |  Branch (292:21): [True: 437, False: 2.56k]
  ------------------
  293|    437|                    break;
  294|  2.56k|                (*tif->tif_cleanup)(tif);
  295|  2.56k|                tif->tif_flags &= ~TIFF_CODERSETUP;
  ------------------
  |  |  124|  2.56k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  296|  2.56k|            }
  297|       |            /*
  298|       |             * Setup new compression routine state.
  299|       |             */
  300|  5.56k|            if ((status = TIFFSetCompressionScheme(tif, (int)v)) != 0)
  ------------------
  |  Branch (300:17): [True: 5.56k, False: 0]
  ------------------
  301|  5.56k|                td->td_compression = (uint16_t)v;
  302|      0|            else
  303|      0|                status = 0;
  304|  5.56k|            break;
  305|  2.19k|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|  2.19k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (305:9): [True: 2.19k, False: 42.3k]
  ------------------
  306|  2.19k|            td->td_photometric = (uint16_t)va_arg(ap, uint16_vap);
  307|  2.19k|            break;
  308|     20|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|     20|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (308:9): [True: 20, False: 44.5k]
  ------------------
  309|     20|            td->td_threshholding = (uint16_t)va_arg(ap, uint16_vap);
  310|     20|            break;
  311|  1.24k|        case TIFFTAG_FILLORDER:
  ------------------
  |  |  240|  1.24k|#define TIFFTAG_FILLORDER 266              /* data order within a byte */
  ------------------
  |  Branch (311:9): [True: 1.24k, False: 43.3k]
  ------------------
  312|  1.24k|            v = (uint16_t)va_arg(ap, uint16_vap);
  313|  1.24k|            if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
  ------------------
  |  |  242|  2.48k|#define FILLORDER_LSB2MSB 2                /* least significant -> most */
  ------------------
                          if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
  ------------------
  |  |  241|  1.19k|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  |  Branch (313:17): [True: 1.19k, False: 48]
  |  Branch (313:43): [True: 333, False: 861]
  ------------------
  314|    333|                goto badvalue;
  315|    909|            td->td_fillorder = (uint16_t)v;
  316|    909|            break;
  317|  1.02k|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|  1.02k|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (317:9): [True: 1.02k, False: 43.5k]
  ------------------
  318|  1.02k|            v = (uint16_t)va_arg(ap, uint16_vap);
  319|  1.02k|            if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
  ------------------
  |  |  249|  2.04k|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
                          if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
  ------------------
  |  |  256|  1.01k|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (319:17): [True: 4, False: 1.01k]
  |  Branch (319:44): [True: 202, False: 817]
  ------------------
  320|    206|                goto badvalue;
  321|    817|            else
  322|    817|                td->td_orientation = (uint16_t)v;
  323|    817|            break;
  324|  2.28k|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|  2.28k|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (324:9): [True: 2.28k, False: 42.2k]
  ------------------
  325|  2.28k|            v = (uint16_t)va_arg(ap, uint16_vap);
  326|  2.28k|            if (v == 0)
  ------------------
  |  Branch (326:17): [True: 0, False: 2.28k]
  ------------------
  327|      0|                goto badvalue;
  328|  2.28k|            if (v != td->td_samplesperpixel)
  ------------------
  |  Branch (328:17): [True: 2.15k, False: 134]
  ------------------
  329|  2.15k|            {
  330|       |                /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
  331|  2.15k|                if (td->td_sminsamplevalue != NULL)
  ------------------
  |  Branch (331:21): [True: 88, False: 2.06k]
  ------------------
  332|     88|                {
  333|     88|                    TIFFWarningExtR(tif, module,
  334|     88|                                    "SamplesPerPixel tag value is changing, "
  335|     88|                                    "but SMinSampleValue tag was read with a "
  336|     88|                                    "different value. Canceling it");
  337|     88|                    TIFFClrFieldBit(tif, FIELD_SMINSAMPLEVALUE);
  ------------------
  |  |  250|     88|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|     88|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|     88|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  338|     88|                    _TIFFfreeExt(tif, td->td_sminsamplevalue);
  339|     88|                    td->td_sminsamplevalue = NULL;
  340|     88|                }
  341|  2.15k|                if (td->td_smaxsamplevalue != NULL)
  ------------------
  |  Branch (341:21): [True: 11, False: 2.14k]
  ------------------
  342|     11|                {
  343|     11|                    TIFFWarningExtR(tif, module,
  344|     11|                                    "SamplesPerPixel tag value is changing, "
  345|     11|                                    "but SMaxSampleValue tag was read with a "
  346|     11|                                    "different value. Canceling it");
  347|     11|                    TIFFClrFieldBit(tif, FIELD_SMAXSAMPLEVALUE);
  ------------------
  |  |  250|     11|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|     11|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|     11|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  348|     11|                    _TIFFfreeExt(tif, td->td_smaxsamplevalue);
  349|     11|                    td->td_smaxsamplevalue = NULL;
  350|     11|                }
  351|       |                /* Test if 3 transfer functions instead of just one are now
  352|       |                   needed See http://bugzilla.maptools.org/show_bug.cgi?id=2820
  353|       |                 */
  354|  2.15k|                if (td->td_transferfunction[0] != NULL &&
  ------------------
  |  Branch (354:21): [True: 3, False: 2.14k]
  ------------------
  355|      3|                    (v - td->td_extrasamples > 1) &&
  ------------------
  |  Branch (355:21): [True: 3, False: 0]
  ------------------
  356|      3|                    !(td->td_samplesperpixel - td->td_extrasamples > 1))
  ------------------
  |  Branch (356:21): [True: 3, False: 0]
  ------------------
  357|      3|                {
  358|      3|                    TIFFWarningExtR(tif, module,
  359|      3|                                    "SamplesPerPixel tag value is changing, "
  360|      3|                                    "but TransferFunction was read with a "
  361|      3|                                    "different value. Canceling it");
  362|      3|                    TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION);
  ------------------
  |  |  250|      3|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|      3|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|      3|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  363|      3|                    _TIFFfreeExt(tif, td->td_transferfunction[0]);
  364|      3|                    td->td_transferfunction[0] = NULL;
  365|      3|                }
  366|  2.15k|            }
  367|  2.28k|            td->td_samplesperpixel = (uint16_t)v;
  368|  2.28k|            break;
  369|  2.09k|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|  2.09k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (369:9): [True: 2.09k, False: 42.4k]
  ------------------
  370|  2.09k|            v32 = (uint32_t)va_arg(ap, uint32_t);
  371|  2.09k|            if (v32 == 0)
  ------------------
  |  Branch (371:17): [True: 0, False: 2.09k]
  ------------------
  372|      0|                goto badvalue32;
  373|  2.09k|            td->td_rowsperstrip = v32;
  374|  2.09k|            if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
  ------------------
  |  |  248|  2.09k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  2.09k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  2.09k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (374:17): [True: 2.08k, False: 13]
  ------------------
  375|  2.08k|            {
  376|  2.08k|                td->td_tilelength = v32;
  377|  2.08k|                td->td_tilewidth = td->td_imagewidth;
  378|  2.08k|            }
  379|  2.09k|            break;
  380|     17|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|     17|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (380:9): [True: 17, False: 44.5k]
  ------------------
  381|     17|            td->td_minsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
  382|     17|            break;
  383|    110|        case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|    110|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (383:9): [True: 110, False: 44.4k]
  ------------------
  384|    110|            td->td_maxsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
  385|    110|            break;
  386|    210|        case TIFFTAG_SMINSAMPLEVALUE:
  ------------------
  |  |  340|    210|#define TIFFTAG_SMINSAMPLEVALUE 340        /* !variable MinSampleValue */
  ------------------
  |  Branch (386:9): [True: 210, False: 44.3k]
  ------------------
  387|    210|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|    210|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (387:17): [True: 210, False: 0]
  ------------------
  388|    210|                _TIFFsetDoubleArrayExt(tif, &td->td_sminsamplevalue,
  389|    210|                                       va_arg(ap, double *),
  390|    210|                                       td->td_samplesperpixel);
  391|      0|            else
  392|      0|                setDoubleArrayOneValue(tif, &td->td_sminsamplevalue,
  393|      0|                                       va_arg(ap, double),
  394|      0|                                       td->td_samplesperpixel);
  395|    210|            break;
  396|     19|        case TIFFTAG_SMAXSAMPLEVALUE:
  ------------------
  |  |  341|     19|#define TIFFTAG_SMAXSAMPLEVALUE 341        /* !variable MaxSampleValue */
  ------------------
  |  Branch (396:9): [True: 19, False: 44.5k]
  ------------------
  397|     19|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|     19|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (397:17): [True: 19, False: 0]
  ------------------
  398|     19|                _TIFFsetDoubleArrayExt(tif, &td->td_smaxsamplevalue,
  399|     19|                                       va_arg(ap, double *),
  400|     19|                                       td->td_samplesperpixel);
  401|      0|            else
  402|      0|                setDoubleArrayOneValue(tif, &td->td_smaxsamplevalue,
  403|      0|                                       va_arg(ap, double),
  404|      0|                                       td->td_samplesperpixel);
  405|     19|            break;
  406|    561|        case TIFFTAG_XRESOLUTION:
  ------------------
  |  |  262|    561|#define TIFFTAG_XRESOLUTION 282            /* pixels/resolution in x */
  ------------------
  |  Branch (406:9): [True: 561, False: 43.9k]
  ------------------
  407|    561|            dblval = va_arg(ap, double);
  408|    561|            if (isnan(dblval) || dblval < 0)
  ------------------
  |  Branch (408:17): [True: 0, False: 561]
  |  Branch (408:34): [True: 4, False: 557]
  ------------------
  409|      4|                goto badvaluedouble;
  410|    557|            td->td_xresolution = _TIFFClampDoubleToFloat(dblval);
  411|    557|            break;
  412|  1.09k|        case TIFFTAG_YRESOLUTION:
  ------------------
  |  |  263|  1.09k|#define TIFFTAG_YRESOLUTION 283            /* pixels/resolution in y */
  ------------------
  |  Branch (412:9): [True: 1.09k, False: 43.4k]
  ------------------
  413|  1.09k|            dblval = va_arg(ap, double);
  414|  1.09k|            if (isnan(dblval) || dblval < 0)
  ------------------
  |  Branch (414:17): [True: 7, False: 1.08k]
  |  Branch (414:34): [True: 4, False: 1.08k]
  ------------------
  415|     11|                goto badvaluedouble;
  416|  1.08k|            td->td_yresolution = _TIFFClampDoubleToFloat(dblval);
  417|  1.08k|            break;
  418|  4.05k|        case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|  4.05k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (418:9): [True: 4.05k, False: 40.4k]
  ------------------
  419|  4.05k|            v = (uint16_t)va_arg(ap, uint16_vap);
  420|  4.05k|            if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  265|  8.11k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
                          if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    802|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (420:17): [True: 802, False: 3.25k]
  |  Branch (420:45): [True: 0, False: 802]
  ------------------
  421|      0|                goto badvalue;
  422|  4.05k|            td->td_planarconfig = (uint16_t)v;
  423|  4.05k|            break;
  424|     30|        case TIFFTAG_XPOSITION:
  ------------------
  |  |  268|     30|#define TIFFTAG_XPOSITION 286              /* x page offset of image lhs */
  ------------------
  |  Branch (424:9): [True: 30, False: 44.5k]
  ------------------
  425|     30|            td->td_xposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
  426|     30|            break;
  427|     14|        case TIFFTAG_YPOSITION:
  ------------------
  |  |  269|     14|#define TIFFTAG_YPOSITION 287              /* y page offset of image lhs */
  ------------------
  |  Branch (427:9): [True: 14, False: 44.5k]
  ------------------
  428|     14|            td->td_yposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
  429|     14|            break;
  430|    289|        case TIFFTAG_RESOLUTIONUNIT:
  ------------------
  |  |  287|    289|#define TIFFTAG_RESOLUTIONUNIT 296         /* units of resolutions */
  ------------------
  |  Branch (430:9): [True: 289, False: 44.2k]
  ------------------
  431|    289|            v = (uint16_t)va_arg(ap, uint16_vap);
  432|    289|            if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
  ------------------
  |  |  288|    578|#define RESUNIT_NONE 1                     /* no meaningful units */
  ------------------
                          if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
  ------------------
  |  |  290|    271|#define RESUNIT_CENTIMETER 3               /* metric */
  ------------------
  |  Branch (432:17): [True: 18, False: 271]
  |  Branch (432:37): [True: 55, False: 216]
  ------------------
  433|     73|                goto badvalue;
  434|    216|            td->td_resolutionunit = (uint16_t)v;
  435|    216|            break;
  436|    314|        case TIFFTAG_PAGENUMBER:
  ------------------
  |  |  291|    314|#define TIFFTAG_PAGENUMBER 297             /* page numbers of multi-page */
  ------------------
  |  Branch (436:9): [True: 314, False: 44.2k]
  ------------------
  437|    314|            td->td_pagenumber[0] = (uint16_t)va_arg(ap, uint16_vap);
  438|    314|            td->td_pagenumber[1] = (uint16_t)va_arg(ap, uint16_vap);
  439|    314|            break;
  440|      4|        case TIFFTAG_HALFTONEHINTS:
  ------------------
  |  |  310|      4|#define TIFFTAG_HALFTONEHINTS 321          /* !highlight+shadow info */
  ------------------
  |  Branch (440:9): [True: 4, False: 44.5k]
  ------------------
  441|      4|            td->td_halftonehints[0] = (uint16_t)va_arg(ap, uint16_vap);
  442|      4|            td->td_halftonehints[1] = (uint16_t)va_arg(ap, uint16_vap);
  443|      4|            break;
  444|     34|        case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|     34|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (444:9): [True: 34, False: 44.5k]
  ------------------
  445|     34|            if (td->td_bitspersample >= 32)
  ------------------
  |  Branch (445:17): [True: 0, False: 34]
  ------------------
  446|      0|            {
  447|      0|                v = td->td_bitspersample;
  448|      0|                goto badvalue;
  449|      0|            }
  450|     34|            v32 = 1U << td->td_bitspersample;
  451|     34|            _TIFFsetShortArrayExt(tif, &td->td_colormap[0],
  452|     34|                                  va_arg(ap, uint16_t *), v32);
  453|     34|            _TIFFsetShortArrayExt(tif, &td->td_colormap[1],
  454|     34|                                  va_arg(ap, uint16_t *), v32);
  455|     34|            _TIFFsetShortArrayExt(tif, &td->td_colormap[2],
  456|     34|                                  va_arg(ap, uint16_t *), v32);
  457|     34|            break;
  458|    762|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|    762|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (458:9): [True: 762, False: 43.7k]
  ------------------
  459|    762|            if (!setExtraSamples(tif, ap, &v))
  ------------------
  |  Branch (459:17): [True: 0, False: 762]
  ------------------
  460|      0|                goto badvalue;
  461|    762|            break;
  462|    762|        case TIFFTAG_MATTEING:
  ------------------
  |  |  405|     11|#define TIFFTAG_MATTEING 32995   /* $use ExtraSamples */
  ------------------
  |  Branch (462:9): [True: 11, False: 44.5k]
  ------------------
  463|     11|            td->td_extrasamples = (((uint16_t)va_arg(ap, uint16_vap)) != 0);
  464|     11|            if (td->td_extrasamples)
  ------------------
  |  Branch (464:17): [True: 11, False: 0]
  ------------------
  465|     11|            {
  466|     11|                uint16_t sv = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|     11|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  467|     11|                _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, &sv, 1);
  468|     11|            }
  469|     11|            break;
  470|    590|        case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|    590|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (470:9): [True: 590, False: 43.9k]
  ------------------
  471|    590|            v32 = (uint32_t)va_arg(ap, uint32_t);
  472|    590|            if (v32 % 16)
  ------------------
  |  Branch (472:17): [True: 585, False: 5]
  ------------------
  473|    585|            {
  474|    585|                if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (474:21): [True: 0, False: 585]
  ------------------
  475|      0|                    goto badvalue32;
  476|    585|                TIFFWarningExtR(
  477|    585|                    tif, tif->tif_name,
  478|    585|                    "Nonstandard tile width %" PRIu32 ", convert file", v32);
  479|    585|            }
  480|    590|            td->td_tilewidth = v32;
  481|    590|            tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|    590|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  482|    590|            break;
  483|    111|        case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|    111|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (483:9): [True: 111, False: 44.4k]
  ------------------
  484|    111|            v32 = (uint32_t)va_arg(ap, uint32_t);
  485|    111|            if (v32 % 16)
  ------------------
  |  Branch (485:17): [True: 87, False: 24]
  ------------------
  486|     87|            {
  487|     87|                if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (487:21): [True: 0, False: 87]
  ------------------
  488|      0|                    goto badvalue32;
  489|     87|                TIFFWarningExtR(
  490|     87|                    tif, tif->tif_name,
  491|     87|                    "Nonstandard tile length %" PRIu32 ", convert file", v32);
  492|     87|            }
  493|    111|            td->td_tilelength = v32;
  494|    111|            tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|    111|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  495|    111|            break;
  496|      2|        case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|      2|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (496:9): [True: 2, False: 44.5k]
  ------------------
  497|      2|            v32 = (uint32_t)va_arg(ap, uint32_t);
  498|      2|            if (v32 == 0)
  ------------------
  |  Branch (498:17): [True: 0, False: 2]
  ------------------
  499|      0|                goto badvalue32;
  500|      2|            td->td_tiledepth = v32;
  501|      2|            break;
  502|     13|        case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|     13|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (502:9): [True: 13, False: 44.5k]
  ------------------
  503|     13|            v = (uint16_t)va_arg(ap, uint16_vap);
  504|     13|            switch (v)
  505|     13|            {
  506|      6|                case DATATYPE_VOID:
  ------------------
  |  |   39|      6|#define DATATYPE_VOID 0   /* !untyped data */
  ------------------
  |  Branch (506:17): [True: 6, False: 7]
  ------------------
  507|      6|                    v = SAMPLEFORMAT_VOID;
  ------------------
  |  |  337|      6|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
  508|      6|                    break;
  509|      3|                case DATATYPE_INT:
  ------------------
  |  |   40|      3|#define DATATYPE_INT 1    /* !signed integer data */
  ------------------
  |  Branch (509:17): [True: 3, False: 10]
  ------------------
  510|      3|                    v = SAMPLEFORMAT_INT;
  ------------------
  |  |  335|      3|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
  511|      3|                    break;
  512|      0|                case DATATYPE_UINT:
  ------------------
  |  |   41|      0|#define DATATYPE_UINT 2   /* !unsigned integer data */
  ------------------
  |  Branch (512:17): [True: 0, False: 13]
  ------------------
  513|      0|                    v = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  514|      0|                    break;
  515|      4|                case DATATYPE_IEEEFP:
  ------------------
  |  |   42|      4|#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
  ------------------
  |  Branch (515:17): [True: 4, False: 9]
  ------------------
  516|      4|                    v = SAMPLEFORMAT_IEEEFP;
  ------------------
  |  |  336|      4|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  517|      4|                    break;
  518|      0|                default:
  ------------------
  |  Branch (518:17): [True: 0, False: 13]
  ------------------
  519|      0|                    goto badvalue;
  520|     13|            }
  521|     13|            td->td_sampleformat = (uint16_t)v;
  522|     13|            break;
  523|    253|        case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|    253|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (523:9): [True: 253, False: 44.2k]
  ------------------
  524|    253|            v = (uint16_t)va_arg(ap, uint16_vap);
  525|    253|            if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
  ------------------
  |  |  334|    506|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
                          if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
  ------------------
  |  |  339|    253|#define SAMPLEFORMAT_COMPLEXIEEEFP 6       /* !complex ieee floating */
  ------------------
  |  Branch (525:17): [True: 0, False: 253]
  |  Branch (525:42): [True: 0, False: 253]
  ------------------
  526|      0|                goto badvalue;
  527|    253|            td->td_sampleformat = (uint16_t)v;
  528|       |
  529|       |            /*  Try to fix up the SWAB function for complex data. */
  530|    253|            if (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT &&
  ------------------
  |  |  338|    506|#define SAMPLEFORMAT_COMPLEXINT 5          /* !complex signed int */
  ------------------
  |  Branch (530:17): [True: 6, False: 247]
  ------------------
  531|      6|                td->td_bitspersample == 32 &&
  ------------------
  |  Branch (531:17): [True: 3, False: 3]
  ------------------
  532|      3|                tif->tif_postdecode == _TIFFSwab32BitData)
  ------------------
  |  Branch (532:17): [True: 0, False: 3]
  ------------------
  533|      0|                tif->tif_postdecode = _TIFFSwab16BitData;
  534|    253|            else if ((td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT ||
  ------------------
  |  |  338|    506|#define SAMPLEFORMAT_COMPLEXINT 5          /* !complex signed int */
  ------------------
  |  Branch (534:23): [True: 6, False: 247]
  ------------------
  535|    247|                      td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) &&
  ------------------
  |  |  339|    247|#define SAMPLEFORMAT_COMPLEXIEEEFP 6       /* !complex ieee floating */
  ------------------
  |  Branch (535:23): [True: 66, False: 181]
  ------------------
  536|     72|                     td->td_bitspersample == 64 &&
  ------------------
  |  Branch (536:22): [True: 3, False: 69]
  ------------------
  537|      3|                     tif->tif_postdecode == _TIFFSwab64BitData)
  ------------------
  |  Branch (537:22): [True: 0, False: 3]
  ------------------
  538|      0|                tif->tif_postdecode = _TIFFSwab32BitData;
  539|    253|            break;
  540|     16|        case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|     16|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (540:9): [True: 16, False: 44.5k]
  ------------------
  541|     16|            td->td_imagedepth = (uint32_t)va_arg(ap, uint32_t);
  542|     16|            break;
  543|     14|        case TIFFTAG_SUBIFD:
  ------------------
  |  |  321|     14|#define TIFFTAG_SUBIFD 330                 /* subimage descriptors */
  ------------------
  |  Branch (543:9): [True: 14, False: 44.5k]
  ------------------
  544|     14|            if ((tif->tif_flags & TIFF_INSUBIFD) == 0)
  ------------------
  |  |  132|     14|#define TIFF_INSUBIFD 0x02000U    /* currently writing a subifd */
  ------------------
  |  Branch (544:17): [True: 14, False: 0]
  ------------------
  545|     14|            {
  546|     14|                td->td_nsubifd = (uint16_t)va_arg(ap, uint16_vap);
  547|     14|                _TIFFsetLong8Array(tif, &td->td_subifd,
  548|     14|                                   (uint64_t *)va_arg(ap, uint64_t *),
  549|     14|                                   (uint32_t)td->td_nsubifd);
  550|     14|            }
  551|      0|            else
  552|      0|            {
  553|      0|                TIFFErrorExtR(tif, module, "%s: Sorry, cannot nest SubIFDs",
  554|      0|                              tif->tif_name);
  555|      0|                status = 0;
  556|      0|            }
  557|     14|            break;
  558|      8|        case TIFFTAG_YCBCRPOSITIONING:
  ------------------
  |  |  389|      8|#define TIFFTAG_YCBCRPOSITIONING 531       /* !subsample positioning */
  ------------------
  |  Branch (558:9): [True: 8, False: 44.5k]
  ------------------
  559|      8|            td->td_ycbcrpositioning = (uint16_t)va_arg(ap, uint16_vap);
  560|      8|            break;
  561|  1.43k|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|  1.43k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (561:9): [True: 1.43k, False: 43.1k]
  ------------------
  562|  1.43k|            td->td_ycbcrsubsampling[0] = (uint16_t)va_arg(ap, uint16_vap);
  563|  1.43k|            td->td_ycbcrsubsampling[1] = (uint16_t)va_arg(ap, uint16_vap);
  564|  1.43k|            break;
  565|      7|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      7|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (565:9): [True: 7, False: 44.5k]
  ------------------
  566|      7|        {
  567|      7|            uint32_t i;
  568|      7|            uint32_t count;
  569|      7|            if (td->td_bitspersample >= 32)
  ------------------
  |  Branch (569:17): [True: 0, False: 7]
  ------------------
  570|      0|            {
  571|      0|                v = td->td_bitspersample;
  572|      0|                goto badvalue;
  573|      0|            }
  574|      7|            count = 1U << td->td_bitspersample;
  575|      7|            v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
  ------------------
  |  Branch (575:17): [True: 4, False: 3]
  ------------------
  576|     22|            for (i = 0; i < v; i++)
  ------------------
  |  Branch (576:25): [True: 15, False: 7]
  ------------------
  577|     15|                _TIFFsetShortArrayExt(tif, &td->td_transferfunction[i],
  578|     15|                                      va_arg(ap, uint16_t *), count);
  579|      7|            break;
  580|      7|        }
  581|    578|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|    578|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (581:9): [True: 578, False: 43.9k]
  ------------------
  582|       |            /* XXX should check for null range */
  583|    578|            _TIFFsetFloatArrayExt(tif, &td->td_refblackwhite,
  584|    578|                                  va_arg(ap, float *), 6);
  585|    578|            break;
  586|     48|        case TIFFTAG_INKNAMES:
  ------------------
  |  |  325|     48|#define TIFFTAG_INKNAMES 333               /* !ascii names of inks */
  ------------------
  |  Branch (586:9): [True: 48, False: 44.4k]
  ------------------
  587|     48|        {
  588|     48|            v = (uint16_t)va_arg(ap, uint16_vap);
  589|     48|            s = va_arg(ap, char *);
  590|     48|            uint16_t ninksinstring;
  591|     48|            ninksinstring = countInkNamesString(tif, v, s);
  592|     48|            status = ninksinstring > 0;
  593|     48|            if (ninksinstring > 0)
  ------------------
  |  Branch (593:17): [True: 44, False: 4]
  ------------------
  594|     44|            {
  595|     44|                _TIFFsetNString(tif, &td->td_inknames, s, v);
  596|     44|                td->td_inknameslen = (int)v;
  597|       |                /* Set NumberOfInks to the value ninksinstring */
  598|     44|                if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
  ------------------
  |  |  248|     44|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|     44|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|     44|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 7, False: 37]
  |  |  ------------------
  ------------------
  599|      7|                {
  600|      7|                    if (td->td_numberofinks != ninksinstring)
  ------------------
  |  Branch (600:25): [True: 4, False: 3]
  ------------------
  601|      4|                    {
  602|      4|                        TIFFErrorExtR(
  603|      4|                            tif, module,
  604|      4|                            "Warning %s; Tag %s:\n  Value %" PRIu16
  605|      4|                            " of NumberOfInks is different from the number of "
  606|      4|                            "inks %" PRIu16
  607|      4|                            ".\n  -> NumberOfInks value adapted to %" PRIu16 "",
  608|      4|                            tif->tif_name, fip->field_name, td->td_numberofinks,
  609|      4|                            ninksinstring, ninksinstring);
  610|      4|                        td->td_numberofinks = ninksinstring;
  611|      4|                    }
  612|      7|                }
  613|     37|                else
  614|     37|                {
  615|     37|                    td->td_numberofinks = ninksinstring;
  616|     37|                    TIFFSetFieldBit(tif, FIELD_NUMBEROFINKS);
  ------------------
  |  |  249|     37|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     37|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     37|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  617|     37|                }
  618|     44|                if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|     44|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|     44|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|     44|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 23, False: 21]
  |  |  ------------------
  ------------------
  619|     23|                {
  620|     23|                    if (td->td_numberofinks != td->td_samplesperpixel)
  ------------------
  |  Branch (620:25): [True: 23, False: 0]
  ------------------
  621|     23|                    {
  622|     23|                        TIFFErrorExtR(tif, module,
  623|     23|                                      "Warning %s; Tag %s:\n  Value %" PRIu16
  624|     23|                                      " of NumberOfInks is different from the "
  625|     23|                                      "SamplesPerPixel value %" PRIu16 "",
  626|     23|                                      tif->tif_name, fip->field_name,
  627|     23|                                      td->td_numberofinks,
  628|     23|                                      td->td_samplesperpixel);
  629|     23|                    }
  630|     23|                }
  631|     44|            }
  632|     48|        }
  633|     48|        break;
  634|    328|        case TIFFTAG_NUMBEROFINKS:
  ------------------
  |  |  326|    328|#define TIFFTAG_NUMBEROFINKS 334           /* !number of inks */
  ------------------
  |  Branch (634:9): [True: 328, False: 44.2k]
  ------------------
  635|    328|            v = (uint16_t)va_arg(ap, uint16_vap);
  636|       |            /* If InkNames already set also NumberOfInks is set accordingly and
  637|       |             * should be equal */
  638|    328|            if (TIFFFieldSet(tif, FIELD_INKNAMES))
  ------------------
  |  |  248|    328|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    328|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    328|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 7, False: 321]
  |  |  ------------------
  ------------------
  639|      7|            {
  640|      7|                if (v != td->td_numberofinks)
  ------------------
  |  Branch (640:21): [True: 4, False: 3]
  ------------------
  641|      4|                {
  642|      4|                    TIFFErrorExtR(
  643|      4|                        tif, module,
  644|      4|                        "Error %s; Tag %s:\n  It is not possible to set the "
  645|      4|                        "value %" PRIu32
  646|      4|                        " for NumberOfInks\n  which is different from the "
  647|      4|                        "number of inks in the InkNames tag (%" PRIu16 ")",
  648|      4|                        tif->tif_name, fip->field_name, v, td->td_numberofinks);
  649|       |                    /* Do not set / overwrite number of inks already set by
  650|       |                     * InkNames case accordingly. */
  651|      4|                    status = 0;
  652|      4|                }
  653|      7|            }
  654|    321|            else
  655|    321|            {
  656|    321|                td->td_numberofinks = (uint16_t)v;
  657|    321|                if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|    321|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    321|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    321|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 178, False: 143]
  |  |  ------------------
  ------------------
  658|    178|                {
  659|    178|                    if (td->td_numberofinks != td->td_samplesperpixel)
  ------------------
  |  Branch (659:25): [True: 150, False: 28]
  ------------------
  660|    150|                    {
  661|    150|                        TIFFErrorExtR(tif, module,
  662|    150|                                      "Warning %s; Tag %s:\n  Value %" PRIu32
  663|    150|                                      " of NumberOfInks is different from the "
  664|    150|                                      "SamplesPerPixel value %" PRIu16 "",
  665|    150|                                      tif->tif_name, fip->field_name, v,
  666|    150|                                      td->td_samplesperpixel);
  667|    150|                    }
  668|    178|                }
  669|    321|            }
  670|    328|            break;
  671|      0|        case TIFFTAG_PERSAMPLE:
  ------------------
  |  |  752|      0|#define TIFFTAG_PERSAMPLE 65563        /* interface for per sample tags */
  ------------------
  |  Branch (671:9): [True: 0, False: 44.5k]
  ------------------
  672|      0|            v = (uint16_t)va_arg(ap, uint16_vap);
  673|      0|            if (v == PERSAMPLE_MULTI)
  ------------------
  |  |  754|      0|#define PERSAMPLE_MULTI 1              /* present as multiple values */
  ------------------
  |  Branch (673:17): [True: 0, False: 0]
  ------------------
  674|      0|                tif->tif_flags |= TIFF_PERSAMPLE;
  ------------------
  |  |  143|      0|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  675|      0|            else
  676|      0|                tif->tif_flags &= ~TIFF_PERSAMPLE;
  ------------------
  |  |  143|      0|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  677|      0|            break;
  678|  10.6k|        default:
  ------------------
  |  Branch (678:9): [True: 10.6k, False: 33.8k]
  ------------------
  679|  10.6k|        {
  680|  10.6k|            TIFFTagValue *tv;
  681|  10.6k|            int tv_size, iCustom;
  682|       |
  683|       |            /*
  684|       |             * This can happen if multiple images are open with different
  685|       |             * codecs which have private tags.  The global tag information
  686|       |             * table may then have tags that are valid for one file but not
  687|       |             * the other. If the client tries to set a tag that is not valid
  688|       |             * for the image's codec then we'll arrive here.  This
  689|       |             * happens, for example, when tiffcp is used to convert between
  690|       |             * compression schemes and codec-specific tags are blindly copied.
  691|       |             *
  692|       |             * This also happens when a FIELD_IGNORE tag is written.
  693|       |             */
  694|  10.6k|            if (fip->field_bit == FIELD_IGNORE)
  ------------------
  |  |  190|  10.6k|#define FIELD_IGNORE 0
  ------------------
  |  Branch (694:17): [True: 0, False: 10.6k]
  ------------------
  695|      0|            {
  696|      0|                TIFFErrorExtR(
  697|      0|                    tif, module,
  698|      0|                    "%s: Ignored %stag \"%s\" (not supported by libtiff)",
  699|      0|                    tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
  ------------------
  |  |  276|      0|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  700|      0|                    fip->field_name);
  701|      0|                status = 0;
  702|      0|                break;
  703|      0|            }
  704|  10.6k|            if (fip->field_bit != FIELD_CUSTOM)
  ------------------
  |  |  346|  10.6k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (704:17): [True: 0, False: 10.6k]
  ------------------
  705|      0|            {
  706|      0|                TIFFErrorExtR(
  707|      0|                    tif, module,
  708|      0|                    "%s: Invalid %stag \"%s\" (not supported by codec)",
  709|      0|                    tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
  ------------------
  |  |  276|      0|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  710|      0|                    fip->field_name);
  711|      0|                status = 0;
  712|      0|                break;
  713|      0|            }
  714|       |
  715|       |            /*
  716|       |             * Find the existing entry for this custom value.
  717|       |             */
  718|  10.6k|            tv = NULL;
  719|  34.6k|            for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++)
  ------------------
  |  Branch (719:31): [True: 24.0k, False: 10.6k]
  ------------------
  720|  24.0k|            {
  721|  24.0k|                if (td->td_customValues[iCustom].info->field_tag == tag)
  ------------------
  |  Branch (721:21): [True: 0, False: 24.0k]
  ------------------
  722|      0|                {
  723|      0|                    tv = td->td_customValues + iCustom;
  724|      0|                    if (tv->value != NULL)
  ------------------
  |  Branch (724:25): [True: 0, False: 0]
  ------------------
  725|      0|                    {
  726|      0|                        _TIFFfreeExt(tif, tv->value);
  727|      0|                        tv->value = NULL;
  728|      0|                    }
  729|      0|                    break;
  730|      0|                }
  731|  24.0k|            }
  732|       |
  733|       |            /*
  734|       |             * Grow the custom list if the entry was not found.
  735|       |             */
  736|  10.6k|            if (tv == NULL)
  ------------------
  |  Branch (736:17): [True: 10.6k, False: 0]
  ------------------
  737|  10.6k|            {
  738|  10.6k|                TIFFTagValue *new_customValues;
  739|       |
  740|  10.6k|                new_customValues = (TIFFTagValue *)_TIFFreallocExt(
  741|  10.6k|                    tif, td->td_customValues,
  742|  10.6k|                    (tmsize_t)(sizeof(TIFFTagValue) *
  743|  10.6k|                               (size_t)(td->td_customValueCount + 1)));
  744|  10.6k|                if (!new_customValues)
  ------------------
  |  Branch (744:21): [True: 0, False: 10.6k]
  ------------------
  745|      0|                {
  746|      0|                    TIFFErrorExtR(tif, module,
  747|      0|                                  "%s: Failed to allocate space for list of "
  748|      0|                                  "custom values",
  749|      0|                                  tif->tif_name);
  750|      0|                    status = 0;
  751|      0|                    goto end;
  752|      0|                }
  753|       |
  754|  10.6k|                td->td_customValueCount++;
  755|  10.6k|                td->td_customValues = new_customValues;
  756|       |
  757|  10.6k|                tv = td->td_customValues + (td->td_customValueCount - 1);
  758|  10.6k|                tv->info = fip;
  759|  10.6k|                tv->value = NULL;
  760|  10.6k|                tv->count = 0;
  761|  10.6k|            }
  762|       |
  763|       |            /*
  764|       |             * Set custom value ... save a copy of the custom tag value.
  765|       |             */
  766|       |            /*--: Rational2Double: For Rationals evaluate "set_get_field_type"
  767|       |             * to determine internal storage size. */
  768|  10.6k|            tv_size = TIFFFieldSetGetSize(fip);
  769|  10.6k|            if (tv_size == 0)
  ------------------
  |  Branch (769:17): [True: 0, False: 10.6k]
  ------------------
  770|      0|            {
  771|      0|                status = 0;
  772|      0|                TIFFErrorExtR(tif, module, "%s: Bad field type %u for \"%s\"",
  773|      0|                              tif->tif_name, fip->field_type, fip->field_name);
  774|      0|                goto end;
  775|      0|            }
  776|       |
  777|  10.6k|            if (fip->field_type == TIFF_ASCII)
  ------------------
  |  Branch (777:17): [True: 1.80k, False: 8.86k]
  ------------------
  778|  1.80k|            {
  779|  1.80k|                uint32_t ma;
  780|  1.80k|                const char *mb;
  781|  1.80k|                if (fip->field_passcount)
  ------------------
  |  Branch (781:21): [True: 399, False: 1.40k]
  ------------------
  782|    399|                {
  783|    399|                    assert(fip->field_writecount == TIFF_VARIABLE2);
  ------------------
  |  Branch (783:21): [True: 0, False: 399]
  |  Branch (783:21): [True: 399, False: 0]
  ------------------
  784|    399|                    ma = (uint32_t)va_arg(ap, uint32_t);
  785|    399|                    mb = (const char *)va_arg(ap, const char *);
  786|    399|                }
  787|  1.40k|                else
  788|  1.40k|                {
  789|  1.40k|                    mb = (const char *)va_arg(ap, const char *);
  790|  1.40k|                    size_t len = strlen(mb) + 1;
  791|  1.40k|                    if (len >= 0x80000000U)
  ------------------
  |  Branch (791:25): [True: 0, False: 1.40k]
  ------------------
  792|      0|                    {
  793|      0|                        status = 0;
  794|      0|                        TIFFErrorExtR(tif, module,
  795|      0|                                      "%s: Too long string value for \"%s\". "
  796|      0|                                      "Maximum supported is 2147483647 bytes",
  797|      0|                                      tif->tif_name, fip->field_name);
  798|      0|                        goto end;
  799|      0|                    }
  800|  1.40k|                    ma = (uint32_t)len;
  801|  1.40k|                }
  802|  1.80k|                tv->count = (int)ma;
  803|  1.80k|                setByteArray(tif, &tv->value, mb, ma, 1);
  804|  1.80k|            }
  805|  8.86k|            else
  806|  8.86k|            {
  807|  8.86k|                if (fip->field_passcount)
  ------------------
  |  Branch (807:21): [True: 8.01k, False: 848]
  ------------------
  808|  8.01k|                {
  809|  8.01k|                    if (fip->field_writecount == TIFF_VARIABLE2)
  ------------------
  |  |  344|  8.01k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (809:25): [True: 7.67k, False: 344]
  ------------------
  810|  7.67k|                        tv->count = (int)va_arg(ap, uint32_t);
  811|    344|                    else
  812|    344|                        tv->count = va_arg(ap, int);
  813|  8.01k|                }
  814|    848|                else if (fip->field_writecount == TIFF_VARIABLE ||
  ------------------
  |  |  342|  1.69k|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (814:26): [True: 0, False: 848]
  ------------------
  815|    848|                         fip->field_writecount == TIFF_VARIABLE2)
  ------------------
  |  |  344|    848|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (815:26): [True: 0, False: 848]
  ------------------
  816|      0|                    tv->count = 1;
  817|    848|                else if (fip->field_writecount == TIFF_SPP)
  ------------------
  |  |  343|    848|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (817:26): [True: 0, False: 848]
  ------------------
  818|      0|                    tv->count = td->td_samplesperpixel;
  819|    848|                else
  820|    848|                    tv->count = fip->field_writecount;
  821|       |
  822|  8.86k|                if (tv->count == 0)
  ------------------
  |  Branch (822:21): [True: 1.65k, False: 7.21k]
  ------------------
  823|  1.65k|                {
  824|  1.65k|                    TIFFWarningExtR(tif, module,
  825|  1.65k|                                    "%s: Null count for \"%s\" (type "
  826|  1.65k|                                    "%u, writecount %d, passcount %d)",
  827|  1.65k|                                    tif->tif_name, fip->field_name,
  828|  1.65k|                                    fip->field_type, fip->field_writecount,
  829|  1.65k|                                    fip->field_passcount);
  830|  1.65k|                    break;
  831|  1.65k|                }
  832|       |
  833|  7.21k|                tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
  834|  7.21k|                                             "custom tag binary object");
  835|  7.21k|                if (!tv->value)
  ------------------
  |  Branch (835:21): [True: 0, False: 7.21k]
  ------------------
  836|      0|                {
  837|      0|                    status = 0;
  838|      0|                    goto end;
  839|      0|                }
  840|       |
  841|  7.21k|                if (fip->field_tag == TIFFTAG_DOTRANGE &&
  ------------------
  |  |  327|  14.4k|#define TIFFTAG_DOTRANGE 336               /* !0% and 100% dot codes */
  ------------------
  |  Branch (841:21): [True: 4, False: 7.21k]
  ------------------
  842|      4|                    strcmp(fip->field_name, "DotRange") == 0)
  ------------------
  |  Branch (842:21): [True: 4, False: 0]
  ------------------
  843|      4|                {
  844|       |                    /* TODO: This is an evil exception and should not have been
  845|       |                       handled this way ... likely best if we move it into
  846|       |                       the directory structure with an explicit field in
  847|       |                       libtiff 4.1 and assign it a FIELD_ value */
  848|      4|                    uint16_t v2[2];
  849|      4|                    v2[0] = (uint16_t)va_arg(ap, int);
  850|      4|                    v2[1] = (uint16_t)va_arg(ap, int);
  851|      4|                    _TIFFmemcpy(tv->value, &v2, 4);
  852|      4|                }
  853|       |
  854|  7.21k|                else if (fip->field_passcount ||
  ------------------
  |  Branch (854:26): [True: 6.36k, False: 844]
  ------------------
  855|    844|                         fip->field_writecount == TIFF_VARIABLE ||
  ------------------
  |  |  342|  8.05k|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (855:26): [True: 0, False: 844]
  ------------------
  856|    844|                         fip->field_writecount == TIFF_VARIABLE2 ||
  ------------------
  |  |  344|  8.05k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (856:26): [True: 0, False: 844]
  ------------------
  857|    844|                         fip->field_writecount == TIFF_SPP || tv->count > 1)
  ------------------
  |  |  343|  8.05k|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (857:26): [True: 0, False: 844]
  |  Branch (857:63): [True: 123, False: 721]
  ------------------
  858|  6.48k|                {
  859|       |                    /*--: Rational2Double: For Rationals tv_size is set above to
  860|       |                     * 4 or 8 according to fip->set_get_field_type! */
  861|  6.48k|                    _TIFFmemcpy(tv->value, va_arg(ap, void *),
  862|  6.48k|                                tv->count * tv_size);
  863|       |                    /* Test here for too big values for LONG8, IFD8, SLONG8 in
  864|       |                     * ClassicTIFF and delete custom field from custom list */
  865|  6.48k|                    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  6.48k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (865:25): [True: 6.38k, False: 102]
  ------------------
  866|  6.38k|                    {
  867|  6.38k|                        if (tv->info->field_type == TIFF_LONG8 ||
  ------------------
  |  Branch (867:29): [True: 193, False: 6.19k]
  ------------------
  868|  6.19k|                            tv->info->field_type == TIFF_IFD8)
  ------------------
  |  Branch (868:29): [True: 47, False: 6.14k]
  ------------------
  869|    240|                        {
  870|    240|                            uint64_t *pui64 = (uint64_t *)tv->value;
  871|    368|                            for (int i = 0; i < tv->count; i++)
  ------------------
  |  Branch (871:45): [True: 368, False: 0]
  ------------------
  872|    368|                            {
  873|    368|                                if (pui64[i] > 0xffffffffu)
  ------------------
  |  Branch (873:37): [True: 240, False: 128]
  ------------------
  874|    240|                                {
  875|    240|                                    TIFFErrorExtR(
  876|    240|                                        tif, module,
  877|    240|                                        "%s: Bad %s value %" PRIu64
  878|    240|                                        " at %d. array position for \"%s\" tag "
  879|    240|                                        "%u in ClassicTIFF. Tag won't be "
  880|    240|                                        "written to file",
  881|    240|                                        tif->tif_name,
  882|    240|                                        (tv->info->field_type == TIFF_LONG8
  ------------------
  |  Branch (882:42): [True: 193, False: 47]
  ------------------
  883|    240|                                             ? "LONG8"
  884|    240|                                             : "IFD8"),
  885|    240|                                        pui64[i], i, fip->field_name, tag);
  886|    240|                                    goto badvalueifd8long8;
  887|    240|                                }
  888|    368|                            }
  889|    240|                        }
  890|  6.14k|                        else if (tv->info->field_type == TIFF_SLONG8)
  ------------------
  |  Branch (890:34): [True: 11, False: 6.13k]
  ------------------
  891|     11|                        {
  892|     11|                            int64_t *pi64 = (int64_t *)tv->value;
  893|     11|                            for (int i = 0; i < tv->count; i++)
  ------------------
  |  Branch (893:45): [True: 11, False: 0]
  ------------------
  894|     11|                            {
  895|     11|                                if (pi64[i] > 2147483647 ||
  ------------------
  |  Branch (895:37): [True: 11, False: 0]
  ------------------
  896|      0|                                    pi64[i] < (-2147483647 - 1))
  ------------------
  |  Branch (896:37): [True: 0, False: 0]
  ------------------
  897|     11|                                {
  898|     11|                                    TIFFErrorExtR(
  899|     11|                                        tif, module,
  900|     11|                                        "%s: Bad SLONG8 value %" PRIi64
  901|     11|                                        " at %d. array position for \"%s\" tag "
  902|     11|                                        "%u in ClassicTIFF. Tag won't be "
  903|     11|                                        "written to file",
  904|     11|                                        tif->tif_name, pi64[i], i,
  905|     11|                                        fip->field_name, tag);
  906|     11|                                    goto badvalueifd8long8;
  907|     11|                                }
  908|     11|                            }
  909|     11|                        }
  910|  6.38k|                    }
  911|  6.48k|                }
  912|    721|                else
  913|    721|                {
  914|    721|                    char *val = (char *)tv->value;
  915|    721|                    assert(tv->count == 1);
  ------------------
  |  Branch (915:21): [True: 0, False: 721]
  |  Branch (915:21): [True: 721, False: 0]
  ------------------
  916|       |
  917|    721|                    switch (fip->field_type)
  918|    721|                    {
  919|    169|                        case TIFF_BYTE:
  ------------------
  |  Branch (919:25): [True: 169, False: 552]
  ------------------
  920|    169|                        case TIFF_UNDEFINED:
  ------------------
  |  Branch (920:25): [True: 0, False: 721]
  ------------------
  921|    169|                        {
  922|    169|                            uint8_t v2 = (uint8_t)va_arg(ap, int);
  923|    169|                            _TIFFmemcpy(val, &v2, tv_size);
  924|    169|                        }
  925|    169|                        break;
  926|      0|                        case TIFF_SBYTE:
  ------------------
  |  Branch (926:25): [True: 0, False: 721]
  ------------------
  927|      0|                        {
  928|      0|                            int8_t v2 = (int8_t)va_arg(ap, int);
  929|      0|                            _TIFFmemcpy(val, &v2, tv_size);
  930|      0|                        }
  931|      0|                        break;
  932|    106|                        case TIFF_SHORT:
  ------------------
  |  Branch (932:25): [True: 106, False: 615]
  ------------------
  933|    106|                        {
  934|    106|                            uint16_t v2 = (uint16_t)va_arg(ap, int);
  935|    106|                            _TIFFmemcpy(val, &v2, tv_size);
  936|    106|                        }
  937|    106|                        break;
  938|      0|                        case TIFF_SSHORT:
  ------------------
  |  Branch (938:25): [True: 0, False: 721]
  ------------------
  939|      0|                        {
  940|      0|                            int16_t v2 = (int16_t)va_arg(ap, int);
  941|      0|                            _TIFFmemcpy(val, &v2, tv_size);
  942|      0|                        }
  943|      0|                        break;
  944|    327|                        case TIFF_LONG:
  ------------------
  |  Branch (944:25): [True: 327, False: 394]
  ------------------
  945|    327|                        case TIFF_IFD:
  ------------------
  |  Branch (945:25): [True: 0, False: 721]
  ------------------
  946|    327|                        {
  947|    327|                            uint32_t v2 = va_arg(ap, uint32_t);
  948|    327|                            _TIFFmemcpy(val, &v2, tv_size);
  949|    327|                        }
  950|    327|                        break;
  951|      0|                        case TIFF_SLONG:
  ------------------
  |  Branch (951:25): [True: 0, False: 721]
  ------------------
  952|      0|                        {
  953|      0|                            int32_t v2 = va_arg(ap, int32_t);
  954|      0|                            _TIFFmemcpy(val, &v2, tv_size);
  955|      0|                        }
  956|      0|                        break;
  957|     15|                        case TIFF_LONG8:
  ------------------
  |  Branch (957:25): [True: 15, False: 706]
  ------------------
  958|     54|                        case TIFF_IFD8:
  ------------------
  |  Branch (958:25): [True: 39, False: 682]
  ------------------
  959|     54|                        {
  960|     54|                            uint64_t v2 = va_arg(ap, uint64_t);
  961|     54|                            _TIFFmemcpy(val, &v2, tv_size);
  962|       |                            /* Test here for too big values for ClassicTIFF and
  963|       |                             * delete custom field from custom list */
  964|     54|                            if (!(tif->tif_flags & TIFF_BIGTIFF) &&
  ------------------
  |  |  140|     54|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (964:33): [True: 54, False: 0]
  ------------------
  965|     54|                                (v2 > 0xffffffffu))
  ------------------
  |  Branch (965:33): [True: 23, False: 31]
  ------------------
  966|     23|                            {
  967|     23|                                TIFFErrorExtR(
  968|     23|                                    tif, module,
  969|     23|                                    "%s: Bad LONG8 or IFD8 value %" PRIu64
  970|     23|                                    " for \"%s\" tag %u in ClassicTIFF. Tag "
  971|     23|                                    "won't be written to file",
  972|     23|                                    tif->tif_name, v2, fip->field_name, tag);
  973|     23|                                goto badvalueifd8long8;
  974|     23|                            }
  975|     54|                        }
  976|     31|                        break;
  977|     31|                        case TIFF_SLONG8:
  ------------------
  |  Branch (977:25): [True: 0, False: 721]
  ------------------
  978|      0|                        {
  979|      0|                            int64_t v2 = va_arg(ap, int64_t);
  980|      0|                            _TIFFmemcpy(val, &v2, tv_size);
  981|       |                            /* Test here for too big values for ClassicTIFF and
  982|       |                             * delete custom field from custom list */
  983|      0|                            if (!(tif->tif_flags & TIFF_BIGTIFF) &&
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (983:33): [True: 0, False: 0]
  ------------------
  984|      0|                                ((v2 > 2147483647) || (v2 < (-2147483647 - 1))))
  ------------------
  |  Branch (984:34): [True: 0, False: 0]
  |  Branch (984:55): [True: 0, False: 0]
  ------------------
  985|      0|                            {
  986|      0|                                TIFFErrorExtR(
  987|      0|                                    tif, module,
  988|      0|                                    "%s: Bad SLONG8 value %" PRIi64
  989|      0|                                    " for \"%s\" tag %u in ClassicTIFF. Tag "
  990|      0|                                    "won't be written to file",
  991|      0|                                    tif->tif_name, v2, fip->field_name, tag);
  992|      0|                                goto badvalueifd8long8;
  993|      0|                            }
  994|      0|                        }
  995|      0|                        break;
  996|      0|                        case TIFF_RATIONAL:
  ------------------
  |  Branch (996:25): [True: 0, False: 721]
  ------------------
  997|      5|                        case TIFF_SRATIONAL:
  ------------------
  |  Branch (997:25): [True: 5, False: 716]
  ------------------
  998|       |                            /*-- Rational2Double: For Rationals tv_size is set
  999|       |                             * above to 4 or 8 according to
 1000|       |                             * fip->set_get_field_type!
 1001|       |                             */
 1002|      5|                            {
 1003|      5|                                if (tv_size == 8)
  ------------------
  |  Branch (1003:37): [True: 0, False: 5]
  ------------------
 1004|      0|                                {
 1005|      0|                                    double v2 = va_arg(ap, double);
 1006|      0|                                    _TIFFmemcpy(val, &v2, tv_size);
 1007|      0|                                }
 1008|      5|                                else
 1009|      5|                                {
 1010|       |                                    /*-- default should be tv_size == 4 */
 1011|      5|                                    float v3 = (float)va_arg(ap, double);
 1012|      5|                                    _TIFFmemcpy(val, &v3, tv_size);
 1013|       |                                    /*-- ToDo: After Testing, this should be
 1014|       |                                     * removed and tv_size==4 should be set as
 1015|       |                                     * default. */
 1016|      5|                                    if (tv_size != 4)
  ------------------
  |  Branch (1016:41): [True: 0, False: 5]
  ------------------
 1017|      0|                                    {
 1018|      0|                                        TIFFErrorExtR(tif, module,
 1019|      0|                                                      "Rational2Double: "
 1020|      0|                                                      ".set_get_field_type "
 1021|      0|                                                      "in not 4 but %d",
 1022|      0|                                                      tv_size);
 1023|      0|                                    }
 1024|      5|                                }
 1025|      5|                            }
 1026|      5|                            break;
 1027|      4|                        case TIFF_FLOAT:
  ------------------
  |  Branch (1027:25): [True: 4, False: 717]
  ------------------
 1028|      4|                        {
 1029|      4|                            float v2 =
 1030|      4|                                _TIFFClampDoubleToFloat(va_arg(ap, double));
 1031|      4|                            _TIFFmemcpy(val, &v2, tv_size);
 1032|      4|                        }
 1033|      4|                        break;
 1034|     56|                        case TIFF_DOUBLE:
  ------------------
  |  Branch (1034:25): [True: 56, False: 665]
  ------------------
 1035|     56|                        {
 1036|     56|                            double v2 = va_arg(ap, double);
 1037|     56|                            _TIFFmemcpy(val, &v2, tv_size);
 1038|     56|                        }
 1039|     56|                        break;
 1040|      0|                        case TIFF_NOTYPE:
  ------------------
  |  Branch (1040:25): [True: 0, False: 721]
  ------------------
 1041|      0|                        case TIFF_ASCII:
  ------------------
  |  Branch (1041:25): [True: 0, False: 721]
  ------------------
 1042|      0|                        default:
  ------------------
  |  Branch (1042:25): [True: 0, False: 721]
  ------------------
 1043|      0|                            _TIFFmemset(val, 0, tv_size);
 1044|      0|                            status = 0;
 1045|      0|                            break;
 1046|    721|                    }
 1047|    721|                }
 1048|  7.21k|            }
 1049|  10.6k|        }
 1050|  44.5k|    }
 1051|  43.6k|    if (status)
  ------------------
  |  Branch (1051:9): [True: 43.6k, False: 8]
  ------------------
 1052|  43.6k|    {
 1053|  43.6k|        const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1054|  43.6k|        if (fip2)
  ------------------
  |  Branch (1054:13): [True: 43.6k, False: 0]
  ------------------
 1055|  43.6k|            TIFFSetFieldBit(tif, fip2->field_bit);
  ------------------
  |  |  249|  43.6k|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|  43.6k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|  43.6k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1056|  43.6k|        tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|  43.6k|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1057|  43.6k|    }
 1058|       |
 1059|  43.6k|end:
 1060|  43.6k|    va_end(ap);
 1061|  43.6k|    return (status);
 1062|    612|badvalue:
 1063|    612|{
 1064|    612|    const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1065|    612|    TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
 1066|    612|                  tif->tif_name, v, fip2 ? fip2->field_name : "Unknown");
  ------------------
  |  Branch (1066:37): [True: 612, False: 0]
  ------------------
 1067|    612|    va_end(ap);
 1068|    612|}
 1069|    612|    return (0);
 1070|      0|badvalue32:
 1071|      0|{
 1072|      0|    const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1073|      0|    TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
 1074|      0|                  tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown");
  ------------------
  |  Branch (1074:39): [True: 0, False: 0]
  ------------------
 1075|      0|    va_end(ap);
 1076|      0|}
 1077|      0|    return (0);
 1078|     15|badvaluedouble:
 1079|     15|{
 1080|     15|    const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1081|     15|    TIFFErrorExtR(tif, module, "%s: Bad value %f for \"%s\" tag", tif->tif_name,
 1082|     15|                  dblval, fip2 ? fip2->field_name : "Unknown");
  ------------------
  |  Branch (1082:27): [True: 15, False: 0]
  ------------------
 1083|     15|    va_end(ap);
 1084|     15|}
 1085|     15|    return (0);
 1086|    274|badvalueifd8long8:
 1087|    274|{
 1088|       |    /* Error message issued already above. */
 1089|    274|    TIFFTagValue *tv2 = NULL;
 1090|    274|    int iCustom2, iC2;
 1091|       |    /* Find the existing entry for this custom value. */
 1092|    912|    for (iCustom2 = 0; iCustom2 < td->td_customValueCount; iCustom2++)
  ------------------
  |  Branch (1092:24): [True: 912, False: 0]
  ------------------
 1093|    912|    {
 1094|    912|        if (td->td_customValues[iCustom2].info->field_tag == tag)
  ------------------
  |  Branch (1094:13): [True: 274, False: 638]
  ------------------
 1095|    274|        {
 1096|    274|            tv2 = td->td_customValues + (iCustom2);
 1097|    274|            break;
 1098|    274|        }
 1099|    912|    }
 1100|    274|    if (tv2 != NULL)
  ------------------
  |  Branch (1100:9): [True: 274, False: 0]
  ------------------
 1101|    274|    {
 1102|       |        /* Remove custom field from custom list */
 1103|    274|        if (tv2->value != NULL)
  ------------------
  |  Branch (1103:13): [True: 274, False: 0]
  ------------------
 1104|    274|        {
 1105|    274|            _TIFFfreeExt(tif, tv2->value);
 1106|    274|            tv2->value = NULL;
 1107|    274|        }
 1108|       |        /* Shorten list and close gap in customValues list.
 1109|       |         * Re-allocation of td_customValues not necessary here. */
 1110|    274|        td->td_customValueCount--;
 1111|    274|        for (iC2 = iCustom2; iC2 < td->td_customValueCount; iC2++)
  ------------------
  |  Branch (1111:30): [True: 0, False: 274]
  ------------------
 1112|      0|        {
 1113|      0|            td->td_customValues[iC2] = td->td_customValues[iC2 + 1];
 1114|      0|        }
 1115|    274|    }
 1116|      0|    else
 1117|      0|    {
 1118|      0|        assert(0);
  ------------------
  |  Branch (1118:9): [Folded, False: 0]
  |  Branch (1118:9): [Folded, False: 0]
  ------------------
 1119|      0|    }
 1120|    274|    va_end(ap);
 1121|    274|}
 1122|    274|    return (0);
 1123|    274|} /*-- _TIFFVSetField() --*/
tif_dir.c:setExtraSamples:
  139|    762|{
  140|       |/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
  141|    762|#define EXTRASAMPLE_COREL_UNASSALPHA 999
  142|       |
  143|    762|    uint16_t *va;
  144|    762|    uint32_t i;
  145|    762|    TIFFDirectory *td = &tif->tif_dir;
  146|    762|    static const char module[] = "setExtraSamples";
  147|       |
  148|    762|    *v = (uint16_t)va_arg(ap, uint16_vap);
  149|    762|    if ((uint16_t)*v > td->td_samplesperpixel)
  ------------------
  |  Branch (149:9): [True: 0, False: 762]
  ------------------
  150|      0|        return 0;
  151|    762|    va = va_arg(ap, uint16_t *);
  152|    762|    if (*v > 0 && va == NULL) /* typically missing param */
  ------------------
  |  Branch (152:9): [True: 756, False: 6]
  |  Branch (152:19): [True: 0, False: 756]
  ------------------
  153|      0|        return 0;
  154|  1.53k|    for (i = 0; i < *v; i++)
  ------------------
  |  Branch (154:17): [True: 776, False: 762]
  ------------------
  155|    776|    {
  156|    776|        if (va[i] > EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|    776|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (156:13): [True: 0, False: 776]
  ------------------
  157|      0|        {
  158|       |            /*
  159|       |             * XXX: Corel Draw is known to produce incorrect
  160|       |             * ExtraSamples tags which must be patched here if we
  161|       |             * want to be able to open some of the damaged TIFF
  162|       |             * files:
  163|       |             */
  164|      0|            if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
  ------------------
  |  |  141|      0|#define EXTRASAMPLE_COREL_UNASSALPHA 999
  ------------------
  |  Branch (164:17): [True: 0, False: 0]
  ------------------
  165|      0|                va[i] = EXTRASAMPLE_UNASSALPHA;
  ------------------
  |  |  332|      0|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  166|      0|            else
  167|      0|                return 0;
  168|      0|        }
  169|    776|    }
  170|       |
  171|    762|    if (td->td_transferfunction[0] != NULL &&
  ------------------
  |  Branch (171:9): [True: 0, False: 762]
  ------------------
  172|      0|        (td->td_samplesperpixel - *v > 1) &&
  ------------------
  |  Branch (172:9): [True: 0, False: 0]
  ------------------
  173|      0|        !(td->td_samplesperpixel - td->td_extrasamples > 1))
  ------------------
  |  Branch (173:9): [True: 0, False: 0]
  ------------------
  174|      0|    {
  175|      0|        TIFFWarningExtR(tif, module,
  176|      0|                        "ExtraSamples tag value is changing, "
  177|      0|                        "but TransferFunction was read with a different value. "
  178|      0|                        "Canceling it");
  179|      0|        TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION);
  ------------------
  |  |  250|      0|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|      0|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|      0|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  180|      0|        _TIFFfreeExt(tif, td->td_transferfunction[0]);
  181|      0|        td->td_transferfunction[0] = NULL;
  182|      0|    }
  183|       |
  184|    762|    td->td_extrasamples = (uint16_t)*v;
  185|    762|    _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, va, td->td_extrasamples);
  186|    762|    return 1;
  187|       |
  188|    762|#undef EXTRASAMPLE_COREL_UNASSALPHA
  189|    762|}
tif_dir.c:_TIFFsetLong8Array:
   98|     14|{
   99|     14|    setByteArray(tif, (void **)lpp, lp, n, sizeof(uint64_t));
  100|     14|}
tif_dir.c:countInkNamesString:
  196|     48|{
  197|     48|    uint16_t i = 0;
  198|       |
  199|     48|    if (slen > 0)
  ------------------
  |  Branch (199:9): [True: 44, False: 4]
  ------------------
  200|     44|    {
  201|     44|        const char *ep = s + slen;
  202|     44|        const char *cp = s;
  203|     44|        do
  204|    713|        {
  205|  1.15k|            for (; cp < ep && *cp != '\0'; cp++)
  ------------------
  |  Branch (205:20): [True: 1.15k, False: 0]
  |  Branch (205:31): [True: 442, False: 713]
  ------------------
  206|    442|            {
  207|    442|            }
  208|    713|            if (cp >= ep)
  ------------------
  |  Branch (208:17): [True: 0, False: 713]
  ------------------
  209|      0|                goto bad;
  210|    713|            cp++; /* skip \0 */
  211|    713|            i++;
  212|    713|        } while (cp < ep);
  ------------------
  |  Branch (212:18): [True: 669, False: 44]
  ------------------
  213|     44|        return (i);
  214|     44|    }
  215|      4|bad:
  216|      4|    TIFFErrorExtR(tif, "TIFFSetField",
  217|      4|                  "%s: Invalid InkNames value; no null at given buffer end "
  218|      4|                  "location %" PRIu32 ", after %" PRIu16 " ink",
  219|      4|                  tif->tif_name, slen, i);
  220|      4|    return (0);
  221|     48|}
tif_dir.c:_TIFFsetNString:
   72|     44|{
   73|     44|    setByteArray(tif, (void **)cpp, cp, n, 1);
   74|     44|}
tif_dir.c:_TIFFVGetField:
 1234|  29.5k|{
 1235|  29.5k|    TIFFDirectory *td = &tif->tif_dir;
 1236|  29.5k|    int ret_val = 1;
 1237|  29.5k|    uint32_t standard_tag = tag;
 1238|  29.5k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  29.5k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1239|  29.5k|    if (fip == NULL) /* cannot happen since TIFFGetField() already checks it */
  ------------------
  |  Branch (1239:9): [True: 0, False: 29.5k]
  ------------------
 1240|      0|        return 0;
 1241|       |
 1242|       |    /*
 1243|       |     * We want to force the custom code to be used for custom
 1244|       |     * fields even if the tag happens to match a well known
 1245|       |     * one - important for reinterpreted handling of standard
 1246|       |     * tag values in custom directories (i.e. EXIF)
 1247|       |     */
 1248|  29.5k|    if (fip->field_bit == FIELD_CUSTOM)
  ------------------
  |  |  346|  29.5k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (1248:9): [True: 901, False: 28.6k]
  ------------------
 1249|    901|    {
 1250|    901|        standard_tag = 0;
 1251|    901|    }
 1252|       |
 1253|  29.5k|    switch (standard_tag)
 1254|  29.5k|    {
 1255|      0|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|      0|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (1255:9): [True: 0, False: 29.5k]
  ------------------
 1256|      0|            *va_arg(ap, uint32_t *) = td->td_subfiletype;
 1257|      0|            break;
 1258|  5.38k|        case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|  5.38k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (1258:9): [True: 5.38k, False: 24.1k]
  ------------------
 1259|  5.38k|            *va_arg(ap, uint32_t *) = td->td_imagewidth;
 1260|  5.38k|            break;
 1261|  4.72k|        case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|  4.72k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (1261:9): [True: 4.72k, False: 24.8k]
  ------------------
 1262|  4.72k|            *va_arg(ap, uint32_t *) = td->td_imagelength;
 1263|  4.72k|            break;
 1264|  1.85k|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|  1.85k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (1264:9): [True: 1.85k, False: 27.7k]
  ------------------
 1265|  1.85k|            *va_arg(ap, uint16_t *) = td->td_bitspersample;
 1266|  1.85k|            break;
 1267|  2.46k|        case TIFFTAG_COMPRESSION:
  ------------------
  |  |  181|  2.46k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (1267:9): [True: 2.46k, False: 27.0k]
  ------------------
 1268|  2.46k|            *va_arg(ap, uint16_t *) = td->td_compression;
 1269|  2.46k|            break;
 1270|  5.50k|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|  5.50k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (1270:9): [True: 5.50k, False: 24.0k]
  ------------------
 1271|  5.50k|            *va_arg(ap, uint16_t *) = td->td_photometric;
 1272|  5.50k|            break;
 1273|      0|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|      0|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (1273:9): [True: 0, False: 29.5k]
  ------------------
 1274|      0|            *va_arg(ap, uint16_t *) = td->td_threshholding;
 1275|      0|            break;
 1276|      0|        case TIFFTAG_FILLORDER:
  ------------------
  |  |  240|      0|#define TIFFTAG_FILLORDER 266              /* data order within a byte */
  ------------------
  |  Branch (1276:9): [True: 0, False: 29.5k]
  ------------------
 1277|      0|            *va_arg(ap, uint16_t *) = td->td_fillorder;
 1278|      0|            break;
 1279|    578|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|    578|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (1279:9): [True: 578, False: 28.9k]
  ------------------
 1280|    578|            *va_arg(ap, uint16_t *) = td->td_orientation;
 1281|    578|            break;
 1282|  1.81k|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|  1.81k|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (1282:9): [True: 1.81k, False: 27.7k]
  ------------------
 1283|  1.81k|            *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
 1284|  1.81k|            break;
 1285|  2.09k|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|  2.09k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (1285:9): [True: 2.09k, False: 27.4k]
  ------------------
 1286|  2.09k|            *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
 1287|  2.09k|            break;
 1288|      0|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      0|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (1288:9): [True: 0, False: 29.5k]
  ------------------
 1289|      0|            *va_arg(ap, uint16_t *) = td->td_minsamplevalue;
 1290|      0|            break;
 1291|      0|        case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|      0|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (1291:9): [True: 0, False: 29.5k]
  ------------------
 1292|      0|            *va_arg(ap, uint16_t *) = td->td_maxsamplevalue;
 1293|      0|            break;
 1294|      0|        case TIFFTAG_SMINSAMPLEVALUE:
  ------------------
  |  |  340|      0|#define TIFFTAG_SMINSAMPLEVALUE 340        /* !variable MinSampleValue */
  ------------------
  |  Branch (1294:9): [True: 0, False: 29.5k]
  ------------------
 1295|      0|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|      0|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (1295:17): [True: 0, False: 0]
  ------------------
 1296|      0|                *va_arg(ap, double **) = td->td_sminsamplevalue;
 1297|      0|            else
 1298|      0|            {
 1299|       |                /* libtiff historically treats this as a single value. */
 1300|      0|                uint16_t i;
 1301|      0|                double v = td->td_sminsamplevalue[0];
 1302|      0|                for (i = 1; i < td->td_samplesperpixel; ++i)
  ------------------
  |  Branch (1302:29): [True: 0, False: 0]
  ------------------
 1303|      0|                    if (td->td_sminsamplevalue[i] < v)
  ------------------
  |  Branch (1303:25): [True: 0, False: 0]
  ------------------
 1304|      0|                        v = td->td_sminsamplevalue[i];
 1305|      0|                *va_arg(ap, double *) = v;
 1306|      0|            }
 1307|      0|            break;
 1308|      0|        case TIFFTAG_SMAXSAMPLEVALUE:
  ------------------
  |  |  341|      0|#define TIFFTAG_SMAXSAMPLEVALUE 341        /* !variable MaxSampleValue */
  ------------------
  |  Branch (1308:9): [True: 0, False: 29.5k]
  ------------------
 1309|      0|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|      0|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (1309:17): [True: 0, False: 0]
  ------------------
 1310|      0|                *va_arg(ap, double **) = td->td_smaxsamplevalue;
 1311|      0|            else
 1312|      0|            {
 1313|       |                /* libtiff historically treats this as a single value. */
 1314|      0|                uint16_t i;
 1315|      0|                double v = td->td_smaxsamplevalue[0];
 1316|      0|                for (i = 1; i < td->td_samplesperpixel; ++i)
  ------------------
  |  Branch (1316:29): [True: 0, False: 0]
  ------------------
 1317|      0|                    if (td->td_smaxsamplevalue[i] > v)
  ------------------
  |  Branch (1317:25): [True: 0, False: 0]
  ------------------
 1318|      0|                        v = td->td_smaxsamplevalue[i];
 1319|      0|                *va_arg(ap, double *) = v;
 1320|      0|            }
 1321|      0|            break;
 1322|      0|        case TIFFTAG_XRESOLUTION:
  ------------------
  |  |  262|      0|#define TIFFTAG_XRESOLUTION 282            /* pixels/resolution in x */
  ------------------
  |  Branch (1322:9): [True: 0, False: 29.5k]
  ------------------
 1323|      0|            *va_arg(ap, float *) = td->td_xresolution;
 1324|      0|            break;
 1325|      0|        case TIFFTAG_YRESOLUTION:
  ------------------
  |  |  263|      0|#define TIFFTAG_YRESOLUTION 283            /* pixels/resolution in y */
  ------------------
  |  Branch (1325:9): [True: 0, False: 29.5k]
  ------------------
 1326|      0|            *va_arg(ap, float *) = td->td_yresolution;
 1327|      0|            break;
 1328|  2.11k|        case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|  2.11k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (1328:9): [True: 2.11k, False: 27.4k]
  ------------------
 1329|  2.11k|            *va_arg(ap, uint16_t *) = td->td_planarconfig;
 1330|  2.11k|            break;
 1331|      0|        case TIFFTAG_XPOSITION:
  ------------------
  |  |  268|      0|#define TIFFTAG_XPOSITION 286              /* x page offset of image lhs */
  ------------------
  |  Branch (1331:9): [True: 0, False: 29.5k]
  ------------------
 1332|      0|            *va_arg(ap, float *) = td->td_xposition;
 1333|      0|            break;
 1334|      0|        case TIFFTAG_YPOSITION:
  ------------------
  |  |  269|      0|#define TIFFTAG_YPOSITION 287              /* y page offset of image lhs */
  ------------------
  |  Branch (1334:9): [True: 0, False: 29.5k]
  ------------------
 1335|      0|            *va_arg(ap, float *) = td->td_yposition;
 1336|      0|            break;
 1337|      0|        case TIFFTAG_RESOLUTIONUNIT:
  ------------------
  |  |  287|      0|#define TIFFTAG_RESOLUTIONUNIT 296         /* units of resolutions */
  ------------------
  |  Branch (1337:9): [True: 0, False: 29.5k]
  ------------------
 1338|      0|            *va_arg(ap, uint16_t *) = td->td_resolutionunit;
 1339|      0|            break;
 1340|      0|        case TIFFTAG_PAGENUMBER:
  ------------------
  |  |  291|      0|#define TIFFTAG_PAGENUMBER 297             /* page numbers of multi-page */
  ------------------
  |  Branch (1340:9): [True: 0, False: 29.5k]
  ------------------
 1341|      0|            *va_arg(ap, uint16_t *) = td->td_pagenumber[0];
 1342|      0|            *va_arg(ap, uint16_t *) = td->td_pagenumber[1];
 1343|      0|            break;
 1344|      0|        case TIFFTAG_HALFTONEHINTS:
  ------------------
  |  |  310|      0|#define TIFFTAG_HALFTONEHINTS 321          /* !highlight+shadow info */
  ------------------
  |  Branch (1344:9): [True: 0, False: 29.5k]
  ------------------
 1345|      0|            *va_arg(ap, uint16_t *) = td->td_halftonehints[0];
 1346|      0|            *va_arg(ap, uint16_t *) = td->td_halftonehints[1];
 1347|      0|            break;
 1348|     25|        case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|     25|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (1348:9): [True: 25, False: 29.5k]
  ------------------
 1349|     25|            *va_arg(ap, const uint16_t **) = td->td_colormap[0];
 1350|     25|            *va_arg(ap, const uint16_t **) = td->td_colormap[1];
 1351|     25|            *va_arg(ap, const uint16_t **) = td->td_colormap[2];
 1352|     25|            break;
 1353|      0|        case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|      0|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (1353:9): [True: 0, False: 29.5k]
  ------------------
 1354|      0|        case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|      0|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (1354:9): [True: 0, False: 29.5k]
  ------------------
 1355|      0|            _TIFFFillStriles(tif);
 1356|      0|            *va_arg(ap, const uint64_t **) = td->td_stripoffset_p;
 1357|      0|            if (td->td_stripoffset_p == NULL)
  ------------------
  |  Branch (1357:17): [True: 0, False: 0]
  ------------------
 1358|      0|                ret_val = 0;
 1359|      0|            break;
 1360|      0|        case TIFFTAG_STRIPBYTECOUNTS:
  ------------------
  |  |  259|      0|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
  |  Branch (1360:9): [True: 0, False: 29.5k]
  ------------------
 1361|      0|        case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|      0|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (1361:9): [True: 0, False: 29.5k]
  ------------------
 1362|      0|            _TIFFFillStriles(tif);
 1363|      0|            *va_arg(ap, const uint64_t **) = td->td_stripbytecount_p;
 1364|      0|            if (td->td_stripbytecount_p == NULL)
  ------------------
  |  Branch (1364:17): [True: 0, False: 0]
  ------------------
 1365|      0|                ret_val = 0;
 1366|      0|            break;
 1367|      0|        case TIFFTAG_MATTEING:
  ------------------
  |  |  405|      0|#define TIFFTAG_MATTEING 32995   /* $use ExtraSamples */
  ------------------
  |  Branch (1367:9): [True: 0, False: 29.5k]
  ------------------
 1368|      0|            *va_arg(ap, uint16_t *) =
 1369|      0|                (td->td_extrasamples == 1 && td->td_sampleinfo &&
  ------------------
  |  Branch (1369:18): [True: 0, False: 0]
  |  Branch (1369:46): [True: 0, False: 0]
  ------------------
 1370|      0|                 td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
  ------------------
  |  |  331|      0|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (1370:18): [True: 0, False: 0]
  ------------------
 1371|      0|            break;
 1372|    565|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|    565|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (1372:9): [True: 565, False: 28.9k]
  ------------------
 1373|    565|            *va_arg(ap, uint16_t *) = td->td_extrasamples;
 1374|    565|            *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
 1375|    565|            break;
 1376|  1.02k|        case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|  1.02k|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (1376:9): [True: 1.02k, False: 28.5k]
  ------------------
 1377|  1.02k|            *va_arg(ap, uint32_t *) = td->td_tilewidth;
 1378|  1.02k|            break;
 1379|    359|        case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|    359|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (1379:9): [True: 359, False: 29.1k]
  ------------------
 1380|    359|            *va_arg(ap, uint32_t *) = td->td_tilelength;
 1381|    359|            break;
 1382|      0|        case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|      0|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (1382:9): [True: 0, False: 29.5k]
  ------------------
 1383|      0|            *va_arg(ap, uint32_t *) = td->td_tiledepth;
 1384|      0|            break;
 1385|      0|        case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|      0|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (1385:9): [True: 0, False: 29.5k]
  ------------------
 1386|      0|            switch (td->td_sampleformat)
 1387|      0|            {
 1388|      0|                case SAMPLEFORMAT_UINT:
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (1388:17): [True: 0, False: 0]
  ------------------
 1389|      0|                    *va_arg(ap, uint16_t *) = DATATYPE_UINT;
  ------------------
  |  |   41|      0|#define DATATYPE_UINT 2   /* !unsigned integer data */
  ------------------
 1390|      0|                    break;
 1391|      0|                case SAMPLEFORMAT_INT:
  ------------------
  |  |  335|      0|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
  |  Branch (1391:17): [True: 0, False: 0]
  ------------------
 1392|      0|                    *va_arg(ap, uint16_t *) = DATATYPE_INT;
  ------------------
  |  |   40|      0|#define DATATYPE_INT 1    /* !signed integer data */
  ------------------
 1393|      0|                    break;
 1394|      0|                case SAMPLEFORMAT_IEEEFP:
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (1394:17): [True: 0, False: 0]
  ------------------
 1395|      0|                    *va_arg(ap, uint16_t *) = DATATYPE_IEEEFP;
  ------------------
  |  |   42|      0|#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
  ------------------
 1396|      0|                    break;
 1397|      0|                case SAMPLEFORMAT_VOID:
  ------------------
  |  |  337|      0|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
  |  Branch (1397:17): [True: 0, False: 0]
  ------------------
 1398|      0|                    *va_arg(ap, uint16_t *) = DATATYPE_VOID;
  ------------------
  |  |   39|      0|#define DATATYPE_VOID 0   /* !untyped data */
  ------------------
 1399|      0|                    break;
 1400|      0|                default:
  ------------------
  |  Branch (1400:17): [True: 0, False: 0]
  ------------------
 1401|      0|                    break;
 1402|      0|            }
 1403|      0|            break;
 1404|      0|        case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (1404:9): [True: 0, False: 29.5k]
  ------------------
 1405|      0|            *va_arg(ap, uint16_t *) = td->td_sampleformat;
 1406|      0|            break;
 1407|      0|        case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|      0|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (1407:9): [True: 0, False: 29.5k]
  ------------------
 1408|      0|            *va_arg(ap, uint32_t *) = td->td_imagedepth;
 1409|      0|            break;
 1410|      0|        case TIFFTAG_SUBIFD:
  ------------------
  |  |  321|      0|#define TIFFTAG_SUBIFD 330                 /* subimage descriptors */
  ------------------
  |  Branch (1410:9): [True: 0, False: 29.5k]
  ------------------
 1411|      0|            *va_arg(ap, uint16_t *) = td->td_nsubifd;
 1412|      0|            *va_arg(ap, const uint64_t **) = td->td_subifd;
 1413|      0|            break;
 1414|      0|        case TIFFTAG_YCBCRPOSITIONING:
  ------------------
  |  |  389|      0|#define TIFFTAG_YCBCRPOSITIONING 531       /* !subsample positioning */
  ------------------
  |  Branch (1414:9): [True: 0, False: 29.5k]
  ------------------
 1415|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
 1416|      0|            break;
 1417|     32|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|     32|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (1417:9): [True: 32, False: 29.5k]
  ------------------
 1418|     32|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
 1419|     32|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
 1420|     32|            break;
 1421|      0|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      0|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (1421:9): [True: 0, False: 29.5k]
  ------------------
 1422|      0|            *va_arg(ap, const uint16_t **) = td->td_transferfunction[0];
 1423|      0|            if (td->td_samplesperpixel - td->td_extrasamples > 1)
  ------------------
  |  Branch (1423:17): [True: 0, False: 0]
  ------------------
 1424|      0|            {
 1425|      0|                *va_arg(ap, const uint16_t **) = td->td_transferfunction[1];
 1426|      0|                *va_arg(ap, const uint16_t **) = td->td_transferfunction[2];
 1427|      0|            }
 1428|      0|            else
 1429|      0|            {
 1430|      0|                *va_arg(ap, const uint16_t **) = NULL;
 1431|      0|                *va_arg(ap, const uint16_t **) = NULL;
 1432|      0|            }
 1433|      0|            break;
 1434|    120|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|    120|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (1434:9): [True: 120, False: 29.4k]
  ------------------
 1435|    120|            *va_arg(ap, const float **) = td->td_refblackwhite;
 1436|    120|            break;
 1437|      0|        case TIFFTAG_INKNAMES:
  ------------------
  |  |  325|      0|#define TIFFTAG_INKNAMES 333               /* !ascii names of inks */
  ------------------
  |  Branch (1437:9): [True: 0, False: 29.5k]
  ------------------
 1438|      0|            *va_arg(ap, const char **) = td->td_inknames;
 1439|      0|            break;
 1440|      0|        case TIFFTAG_NUMBEROFINKS:
  ------------------
  |  |  326|      0|#define TIFFTAG_NUMBEROFINKS 334           /* !number of inks */
  ------------------
  |  Branch (1440:9): [True: 0, False: 29.5k]
  ------------------
 1441|      0|            *va_arg(ap, uint16_t *) = td->td_numberofinks;
 1442|      0|            break;
 1443|    901|        default:
  ------------------
  |  Branch (1443:9): [True: 901, False: 28.6k]
  ------------------
 1444|    901|        {
 1445|    901|            int i;
 1446|       |
 1447|       |            /*
 1448|       |             * This can happen if multiple images are open
 1449|       |             * with different codecs which have private
 1450|       |             * tags.  The global tag information table may
 1451|       |             * then have tags that are valid for one file
 1452|       |             * but not the other. If the client tries to
 1453|       |             * get a tag that is not valid for the image's
 1454|       |             * codec then we'll arrive here.
 1455|       |             */
 1456|    901|            if (fip->field_bit != FIELD_CUSTOM)
  ------------------
  |  |  346|    901|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (1456:17): [True: 0, False: 901]
  ------------------
 1457|      0|            {
 1458|      0|                TIFFErrorExtR(tif, "_TIFFVGetField",
 1459|      0|                              "%s: Invalid %stag \"%s\" "
 1460|      0|                              "(not supported by codec)",
 1461|      0|                              tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
  ------------------
  |  |  276|      0|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1462|      0|                              fip->field_name);
 1463|      0|                ret_val = 0;
 1464|      0|                break;
 1465|      0|            }
 1466|       |
 1467|       |            /*
 1468|       |             * Do we have a custom value?
 1469|       |             */
 1470|    901|            ret_val = 0;
 1471|  4.25k|            for (i = 0; i < td->td_customValueCount; i++)
  ------------------
  |  Branch (1471:25): [True: 3.38k, False: 868]
  ------------------
 1472|  3.38k|            {
 1473|  3.38k|                TIFFTagValue *tv = td->td_customValues + i;
 1474|       |
 1475|  3.38k|                if (tv->info->field_tag != tag)
  ------------------
  |  Branch (1475:21): [True: 3.35k, False: 33]
  ------------------
 1476|  3.35k|                    continue;
 1477|       |
 1478|     33|                if (fip->field_passcount)
  ------------------
  |  Branch (1478:21): [True: 0, False: 33]
  ------------------
 1479|      0|                {
 1480|      0|                    if (fip->field_readcount == TIFF_VARIABLE2)
  ------------------
  |  |  344|      0|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (1480:25): [True: 0, False: 0]
  ------------------
 1481|      0|                        *va_arg(ap, uint32_t *) = (uint32_t)tv->count;
 1482|      0|                    else /* Assume TIFF_VARIABLE */
 1483|      0|                        *va_arg(ap, uint16_t *) = (uint16_t)tv->count;
 1484|      0|                    *va_arg(ap, const void **) = tv->value;
 1485|      0|                    ret_val = 1;
 1486|      0|                }
 1487|     33|                else if (fip->field_tag == TIFFTAG_DOTRANGE &&
  ------------------
  |  |  327|     66|#define TIFFTAG_DOTRANGE 336               /* !0% and 100% dot codes */
  ------------------
  |  Branch (1487:26): [True: 0, False: 33]
  ------------------
 1488|      0|                         strcmp(fip->field_name, "DotRange") == 0)
  ------------------
  |  Branch (1488:26): [True: 0, False: 0]
  ------------------
 1489|      0|                {
 1490|       |                    /* TODO: This is an evil exception and should not have been
 1491|       |                       handled this way ... likely best if we move it into
 1492|       |                       the directory structure with an explicit field in
 1493|       |                       libtiff 4.1 and assign it a FIELD_ value */
 1494|      0|                    *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[0];
 1495|      0|                    *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[1];
 1496|      0|                    ret_val = 1;
 1497|      0|                }
 1498|     33|                else
 1499|     33|                {
 1500|     33|                    if (fip->field_type == TIFF_ASCII ||
  ------------------
  |  Branch (1500:25): [True: 0, False: 33]
  ------------------
 1501|     33|                        fip->field_readcount == TIFF_VARIABLE ||
  ------------------
  |  |  342|     66|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (1501:25): [True: 0, False: 33]
  ------------------
 1502|     33|                        fip->field_readcount == TIFF_VARIABLE2 ||
  ------------------
  |  |  344|     66|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (1502:25): [True: 0, False: 33]
  ------------------
 1503|     33|                        fip->field_readcount == TIFF_SPP || tv->count > 1)
  ------------------
  |  |  343|     66|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (1503:25): [True: 0, False: 33]
  |  Branch (1503:61): [True: 19, False: 14]
  ------------------
 1504|     19|                    {
 1505|     19|                        *va_arg(ap, void **) = tv->value;
 1506|     19|                        ret_val = 1;
 1507|     19|                    }
 1508|     14|                    else
 1509|     14|                    {
 1510|     14|                        char *val = (char *)tv->value;
 1511|     14|                        assert(tv->count == 1);
  ------------------
  |  Branch (1511:25): [True: 0, False: 14]
  |  Branch (1511:25): [True: 14, False: 0]
  ------------------
 1512|     14|                        switch (fip->field_type)
 1513|     14|                        {
 1514|      0|                            case TIFF_BYTE:
  ------------------
  |  Branch (1514:29): [True: 0, False: 14]
  ------------------
 1515|      0|                            case TIFF_UNDEFINED:
  ------------------
  |  Branch (1515:29): [True: 0, False: 14]
  ------------------
 1516|      0|                                *va_arg(ap, uint8_t *) = *(uint8_t *)val;
 1517|      0|                                ret_val = 1;
 1518|      0|                                break;
 1519|      0|                            case TIFF_SBYTE:
  ------------------
  |  Branch (1519:29): [True: 0, False: 14]
  ------------------
 1520|      0|                                *va_arg(ap, int8_t *) = *(int8_t *)val;
 1521|      0|                                ret_val = 1;
 1522|      0|                                break;
 1523|     14|                            case TIFF_SHORT:
  ------------------
  |  Branch (1523:29): [True: 14, False: 0]
  ------------------
 1524|     14|                                *va_arg(ap, uint16_t *) = *(uint16_t *)val;
 1525|     14|                                ret_val = 1;
 1526|     14|                                break;
 1527|      0|                            case TIFF_SSHORT:
  ------------------
  |  Branch (1527:29): [True: 0, False: 14]
  ------------------
 1528|      0|                                *va_arg(ap, int16_t *) = *(int16_t *)val;
 1529|      0|                                ret_val = 1;
 1530|      0|                                break;
 1531|      0|                            case TIFF_LONG:
  ------------------
  |  Branch (1531:29): [True: 0, False: 14]
  ------------------
 1532|      0|                            case TIFF_IFD:
  ------------------
  |  Branch (1532:29): [True: 0, False: 14]
  ------------------
 1533|      0|                                *va_arg(ap, uint32_t *) = *(uint32_t *)val;
 1534|      0|                                ret_val = 1;
 1535|      0|                                break;
 1536|      0|                            case TIFF_SLONG:
  ------------------
  |  Branch (1536:29): [True: 0, False: 14]
  ------------------
 1537|      0|                                *va_arg(ap, int32_t *) = *(int32_t *)val;
 1538|      0|                                ret_val = 1;
 1539|      0|                                break;
 1540|      0|                            case TIFF_LONG8:
  ------------------
  |  Branch (1540:29): [True: 0, False: 14]
  ------------------
 1541|      0|                            case TIFF_IFD8:
  ------------------
  |  Branch (1541:29): [True: 0, False: 14]
  ------------------
 1542|      0|                                *va_arg(ap, uint64_t *) = *(uint64_t *)val;
 1543|      0|                                ret_val = 1;
 1544|      0|                                break;
 1545|      0|                            case TIFF_SLONG8:
  ------------------
  |  Branch (1545:29): [True: 0, False: 14]
  ------------------
 1546|      0|                                *va_arg(ap, int64_t *) = *(int64_t *)val;
 1547|      0|                                ret_val = 1;
 1548|      0|                                break;
 1549|      0|                            case TIFF_RATIONAL:
  ------------------
  |  Branch (1549:29): [True: 0, False: 14]
  ------------------
 1550|      0|                            case TIFF_SRATIONAL:
  ------------------
  |  Branch (1550:29): [True: 0, False: 14]
  ------------------
 1551|      0|                            {
 1552|       |                                /*-- Rational2Double: For Rationals evaluate
 1553|       |                                 * "set_get_field_type" to determine internal
 1554|       |                                 * storage size and return value size. */
 1555|      0|                                int tv_size = TIFFFieldSetGetSize(fip);
 1556|      0|                                if (tv_size == 8)
  ------------------
  |  Branch (1556:37): [True: 0, False: 0]
  ------------------
 1557|      0|                                {
 1558|      0|                                    *va_arg(ap, double *) = *(double *)val;
 1559|      0|                                    ret_val = 1;
 1560|      0|                                }
 1561|      0|                                else
 1562|      0|                                {
 1563|       |                                    /*-- default should be tv_size == 4  */
 1564|      0|                                    *va_arg(ap, float *) = *(float *)val;
 1565|      0|                                    ret_val = 1;
 1566|       |                                    /*-- ToDo: After Testing, this should be
 1567|       |                                     * removed and tv_size==4 should be set as
 1568|       |                                     * default. */
 1569|      0|                                    if (tv_size != 4)
  ------------------
  |  Branch (1569:41): [True: 0, False: 0]
  ------------------
 1570|      0|                                    {
 1571|      0|                                        TIFFErrorExtR(tif, "_TIFFVGetField",
 1572|      0|                                                      "Rational2Double: "
 1573|      0|                                                      ".set_get_field_type "
 1574|      0|                                                      "in not 4 but %d",
 1575|      0|                                                      tv_size);
 1576|      0|                                    }
 1577|      0|                                }
 1578|      0|                            }
 1579|      0|                            break;
 1580|      0|                            case TIFF_FLOAT:
  ------------------
  |  Branch (1580:29): [True: 0, False: 14]
  ------------------
 1581|      0|                                *va_arg(ap, float *) = *(float *)val;
 1582|      0|                                ret_val = 1;
 1583|      0|                                break;
 1584|      0|                            case TIFF_DOUBLE:
  ------------------
  |  Branch (1584:29): [True: 0, False: 14]
  ------------------
 1585|      0|                                *va_arg(ap, double *) = *(double *)val;
 1586|      0|                                ret_val = 1;
 1587|      0|                                break;
 1588|      0|                            case TIFF_NOTYPE:
  ------------------
  |  Branch (1588:29): [True: 0, False: 14]
  ------------------
 1589|      0|                            case TIFF_ASCII:
  ------------------
  |  Branch (1589:29): [True: 0, False: 14]
  ------------------
 1590|      0|                            default:
  ------------------
  |  Branch (1590:29): [True: 0, False: 14]
  ------------------
 1591|      0|                                ret_val = 0;
 1592|      0|                                break;
 1593|     14|                        }
 1594|     14|                    }
 1595|     33|                }
 1596|     33|                break;
 1597|     33|            }
 1598|    901|        }
 1599|  29.5k|    }
 1600|  29.5k|    return (ret_val);
 1601|  29.5k|}

_TIFFGetFields:
  561|  3.00k|const TIFFFieldArray *_TIFFGetFields(void) { return (&tiffFieldArray); }
_TIFFSetupFields:
  568|  3.00k|{
  569|  3.00k|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (569:9): [True: 1.72k, False: 1.27k]
  |  Branch (569:28): [True: 1.72k, False: 0]
  ------------------
  570|  1.72k|    {
  571|  1.72k|        uint32_t i;
  572|       |
  573|   364k|        for (i = 0; i < tif->tif_nfields; i++)
  ------------------
  |  Branch (573:21): [True: 362k, False: 1.72k]
  ------------------
  574|   362k|        {
  575|   362k|            TIFFField *fld = tif->tif_fields[i];
  576|   362k|            if (fld->field_name != NULL)
  ------------------
  |  Branch (576:17): [True: 362k, False: 0]
  ------------------
  577|   362k|            {
  578|   362k|                if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld))
  ------------------
  |  |  346|   724k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (578:21): [True: 267k, False: 95.1k]
  |  Branch (578:55): [True: 89.4k, False: 177k]
  ------------------
  579|  89.4k|                {
  580|  89.4k|                    _TIFFfreeExt(tif, (void *)fld->field_name);
  581|       |                    /* caution: tif_fields[i] must not be the beginning of a
  582|       |                     * fields-array. Otherwise the following tags are also freed
  583|       |                     * with the first free().
  584|       |                     */
  585|  89.4k|                    _TIFFfreeExt(tif, fld);
  586|  89.4k|                }
  587|   362k|            }
  588|   362k|        }
  589|       |
  590|  1.72k|        _TIFFfreeExt(tif, tif->tif_fields);
  591|  1.72k|        tif->tif_fields = NULL;
  592|  1.72k|        tif->tif_nfields = 0;
  593|  1.72k|    }
  594|  3.00k|    if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
  ------------------
  |  Branch (594:9): [True: 0, False: 3.00k]
  ------------------
  595|      0|    {
  596|      0|        TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
  597|      0|    }
  598|  3.00k|}
_TIFFMergeFields:
  628|   191k|{
  629|   191k|    static const char module[] = "_TIFFMergeFields";
  630|   191k|    static const char reason[] = "for fields array";
  631|       |    /* TIFFField** tp; */
  632|   191k|    uint32_t i;
  633|       |
  634|   191k|    tif->tif_foundfield = NULL;
  635|       |
  636|   191k|    TIFFField **tif_newfields = NULL;
  637|       |
  638|   191k|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (638:9): [True: 188k, False: 3.00k]
  |  Branch (638:28): [True: 188k, False: 0]
  ------------------
  639|   188k|    {
  640|   188k|        tif_newfields = (TIFFField **)_TIFFCheckRealloc(
  641|   188k|            tif, tif->tif_fields, (tmsize_t)tif->tif_nfields + n,
  642|   188k|            (tmsize_t)sizeof(TIFFField *), reason);
  643|   188k|    }
  644|  3.00k|    else
  645|  3.00k|    {
  646|  3.00k|        tif_newfields =
  647|  3.00k|            (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
  648|  3.00k|    }
  649|   191k|    if (!tif_newfields)
  ------------------
  |  Branch (649:9): [True: 0, False: 191k]
  ------------------
  650|      0|    {
  651|      0|        tif->tif_nfields = 0;
  652|      0|        TIFFErrorExtR(tif, module, "Failed to allocate fields array");
  653|      0|        return 0;
  654|      0|    }
  655|   191k|    tif->tif_fields = tif_newfields;
  656|       |
  657|       |    /* tp = tif->tif_fields + tif->tif_nfields; */
  658|   849k|    for (i = 0; i < n; i++)
  ------------------
  |  Branch (658:17): [True: 658k, False: 191k]
  ------------------
  659|   658k|    {
  660|   658k|        const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
  ------------------
  |  |  341|   658k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  661|       |
  662|       |        /* only add definitions that aren't already present */
  663|   658k|        if (!fip)
  ------------------
  |  Branch (663:13): [True: 658k, False: 0]
  ------------------
  664|   658k|        {
  665|   658k|            tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
  666|   658k|            tif->tif_nfields++;
  667|   658k|        }
  668|   658k|    }
  669|       |
  670|       |    /* Sort the field info by tag number */
  671|   191k|    qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
  672|       |
  673|   191k|    return (int)n;
  674|   191k|}
TIFFDataWidth:
  696|  54.9k|{
  697|  54.9k|    switch (type)
  698|  54.9k|    {
  699|  1.94k|        case 0: /* nothing */
  ------------------
  |  Branch (699:9): [True: 1.94k, False: 53.0k]
  ------------------
  700|  8.42k|        case TIFF_BYTE:
  ------------------
  |  Branch (700:9): [True: 6.47k, False: 48.5k]
  ------------------
  701|  12.7k|        case TIFF_ASCII:
  ------------------
  |  Branch (701:9): [True: 4.36k, False: 50.6k]
  ------------------
  702|  14.1k|        case TIFF_SBYTE:
  ------------------
  |  Branch (702:9): [True: 1.36k, False: 53.6k]
  ------------------
  703|  14.5k|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (703:9): [True: 401, False: 54.5k]
  ------------------
  704|  14.5k|            return 1;
  705|  22.3k|        case TIFF_SHORT:
  ------------------
  |  Branch (705:9): [True: 22.3k, False: 32.6k]
  ------------------
  706|  22.9k|        case TIFF_SSHORT:
  ------------------
  |  Branch (706:9): [True: 556, False: 54.4k]
  ------------------
  707|  22.9k|            return 2;
  708|  10.1k|        case TIFF_LONG:
  ------------------
  |  Branch (708:9): [True: 10.1k, False: 44.7k]
  ------------------
  709|  10.9k|        case TIFF_SLONG:
  ------------------
  |  Branch (709:9): [True: 793, False: 54.1k]
  ------------------
  710|  11.0k|        case TIFF_FLOAT:
  ------------------
  |  Branch (710:9): [True: 73, False: 54.9k]
  ------------------
  711|  11.1k|        case TIFF_IFD:
  ------------------
  |  Branch (711:9): [True: 58, False: 54.9k]
  ------------------
  712|  11.1k|            return 4;
  713|  2.55k|        case TIFF_RATIONAL:
  ------------------
  |  Branch (713:9): [True: 2.55k, False: 52.4k]
  ------------------
  714|  2.91k|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (714:9): [True: 355, False: 54.6k]
  ------------------
  715|  4.21k|        case TIFF_DOUBLE:
  ------------------
  |  Branch (715:9): [True: 1.30k, False: 53.6k]
  ------------------
  716|  5.37k|        case TIFF_LONG8:
  ------------------
  |  Branch (716:9): [True: 1.16k, False: 53.8k]
  ------------------
  717|  6.00k|        case TIFF_SLONG8:
  ------------------
  |  Branch (717:9): [True: 634, False: 54.3k]
  ------------------
  718|  6.29k|        case TIFF_IFD8:
  ------------------
  |  Branch (718:9): [True: 288, False: 54.6k]
  ------------------
  719|  6.29k|            return 8;
  720|     81|        default:
  ------------------
  |  Branch (720:9): [True: 81, False: 54.9k]
  ------------------
  721|     81|            return 0; /* will return 0 for unknown types */
  722|  54.9k|    }
  723|  54.9k|}
TIFFFieldSetGetSize:
  732|  10.6k|{
  733|       |    /*
  734|       |     * TIFFSetField() and TIFFGetField() must provide the parameter accordingly
  735|       |     * to the definition of "set_get_field_type" of the tag definition in
  736|       |     * dir_info.c. This function returns the data size for that purpose.
  737|       |     *
  738|       |     * Furthermore, this data size is also used for the internal storage,
  739|       |     * even for TIFF_RATIONAL values for FIELD_CUSTOM, which are stored
  740|       |     * internally as 4-byte float, but some of them should be stored internally
  741|       |     * as 8-byte double, depending on the "set_get_field_type" _FLOAT_ or
  742|       |     * _DOUBLE_.
  743|       |     */
  744|  10.6k|    if (fip == NULL)
  ------------------
  |  Branch (744:9): [True: 0, False: 10.6k]
  ------------------
  745|      0|        return 0;
  746|       |
  747|  10.6k|    switch (fip->set_get_field_type)
  748|  10.6k|    {
  749|      0|        case TIFF_SETGET_UNDEFINED:
  ------------------
  |  Branch (749:9): [True: 0, False: 10.6k]
  ------------------
  750|  1.40k|        case TIFF_SETGET_ASCII:
  ------------------
  |  Branch (750:9): [True: 1.40k, False: 9.26k]
  ------------------
  751|  1.40k|        case TIFF_SETGET_C0_ASCII:
  ------------------
  |  Branch (751:9): [True: 0, False: 10.6k]
  ------------------
  752|  1.40k|        case TIFF_SETGET_C16_ASCII:
  ------------------
  |  Branch (752:9): [True: 0, False: 10.6k]
  ------------------
  753|  1.80k|        case TIFF_SETGET_C32_ASCII:
  ------------------
  |  Branch (753:9): [True: 399, False: 10.2k]
  ------------------
  754|  1.80k|        case TIFF_SETGET_OTHER:
  ------------------
  |  Branch (754:9): [True: 0, False: 10.6k]
  ------------------
  755|  1.80k|            return 1;
  756|    169|        case TIFF_SETGET_UINT8:
  ------------------
  |  Branch (756:9): [True: 169, False: 10.5k]
  ------------------
  757|    169|        case TIFF_SETGET_SINT8:
  ------------------
  |  Branch (757:9): [True: 0, False: 10.6k]
  ------------------
  758|    173|        case TIFF_SETGET_C0_UINT8:
  ------------------
  |  Branch (758:9): [True: 4, False: 10.6k]
  ------------------
  759|    173|        case TIFF_SETGET_C0_SINT8:
  ------------------
  |  Branch (759:9): [True: 0, False: 10.6k]
  ------------------
  760|    176|        case TIFF_SETGET_C16_UINT8:
  ------------------
  |  Branch (760:9): [True: 3, False: 10.6k]
  ------------------
  761|    176|        case TIFF_SETGET_C16_SINT8:
  ------------------
  |  Branch (761:9): [True: 0, False: 10.6k]
  ------------------
  762|  1.75k|        case TIFF_SETGET_C32_UINT8:
  ------------------
  |  Branch (762:9): [True: 1.58k, False: 9.08k]
  ------------------
  763|  2.01k|        case TIFF_SETGET_C32_SINT8:
  ------------------
  |  Branch (763:9): [True: 256, False: 10.4k]
  ------------------
  764|  2.01k|            return 1;
  765|    106|        case TIFF_SETGET_UINT16:
  ------------------
  |  Branch (765:9): [True: 106, False: 10.5k]
  ------------------
  766|    106|        case TIFF_SETGET_SINT16:
  ------------------
  |  Branch (766:9): [True: 0, False: 10.6k]
  ------------------
  767|    106|        case TIFF_SETGET_C0_UINT16:
  ------------------
  |  Branch (767:9): [True: 0, False: 10.6k]
  ------------------
  768|    106|        case TIFF_SETGET_C0_SINT16:
  ------------------
  |  Branch (768:9): [True: 0, False: 10.6k]
  ------------------
  769|    236|        case TIFF_SETGET_C16_UINT16:
  ------------------
  |  Branch (769:9): [True: 130, False: 10.5k]
  ------------------
  770|    236|        case TIFF_SETGET_C16_SINT16:
  ------------------
  |  Branch (770:9): [True: 0, False: 10.6k]
  ------------------
  771|  3.99k|        case TIFF_SETGET_C32_UINT16:
  ------------------
  |  Branch (771:9): [True: 3.76k, False: 6.91k]
  ------------------
  772|  4.02k|        case TIFF_SETGET_C32_SINT16:
  ------------------
  |  Branch (772:9): [True: 29, False: 10.6k]
  ------------------
  773|  4.02k|            return 2;
  774|      0|        case TIFF_SETGET_INT:
  ------------------
  |  Branch (774:9): [True: 0, False: 10.6k]
  ------------------
  775|    327|        case TIFF_SETGET_UINT32:
  ------------------
  |  Branch (775:9): [True: 327, False: 10.3k]
  ------------------
  776|    327|        case TIFF_SETGET_SINT32:
  ------------------
  |  Branch (776:9): [True: 0, False: 10.6k]
  ------------------
  777|    336|        case TIFF_SETGET_FLOAT:
  ------------------
  |  Branch (777:9): [True: 9, False: 10.6k]
  ------------------
  778|    340|        case TIFF_SETGET_UINT16_PAIR:
  ------------------
  |  Branch (778:9): [True: 4, False: 10.6k]
  ------------------
  779|    347|        case TIFF_SETGET_C0_UINT32:
  ------------------
  |  Branch (779:9): [True: 7, False: 10.6k]
  ------------------
  780|    347|        case TIFF_SETGET_C0_SINT32:
  ------------------
  |  Branch (780:9): [True: 0, False: 10.6k]
  ------------------
  781|    459|        case TIFF_SETGET_C0_FLOAT:
  ------------------
  |  Branch (781:9): [True: 112, False: 10.5k]
  ------------------
  782|    611|        case TIFF_SETGET_C16_UINT32:
  ------------------
  |  Branch (782:9): [True: 152, False: 10.5k]
  ------------------
  783|    611|        case TIFF_SETGET_C16_SINT32:
  ------------------
  |  Branch (783:9): [True: 0, False: 10.6k]
  ------------------
  784|    670|        case TIFF_SETGET_C16_FLOAT:
  ------------------
  |  Branch (784:9): [True: 59, False: 10.6k]
  ------------------
  785|  1.79k|        case TIFF_SETGET_C32_UINT32:
  ------------------
  |  Branch (785:9): [True: 1.12k, False: 9.54k]
  ------------------
  786|  1.93k|        case TIFF_SETGET_C32_SINT32:
  ------------------
  |  Branch (786:9): [True: 143, False: 10.5k]
  ------------------
  787|  2.31k|        case TIFF_SETGET_C32_FLOAT:
  ------------------
  |  Branch (787:9): [True: 380, False: 10.2k]
  ------------------
  788|  2.31k|            return 4;
  789|     15|        case TIFF_SETGET_UINT64:
  ------------------
  |  Branch (789:9): [True: 15, False: 10.6k]
  ------------------
  790|     15|        case TIFF_SETGET_SINT64:
  ------------------
  |  Branch (790:9): [True: 0, False: 10.6k]
  ------------------
  791|     71|        case TIFF_SETGET_DOUBLE:
  ------------------
  |  Branch (791:9): [True: 56, False: 10.6k]
  ------------------
  792|    110|        case TIFF_SETGET_IFD8:
  ------------------
  |  Branch (792:9): [True: 39, False: 10.6k]
  ------------------
  793|    110|        case TIFF_SETGET_C0_UINT64:
  ------------------
  |  Branch (793:9): [True: 0, False: 10.6k]
  ------------------
  794|    110|        case TIFF_SETGET_C0_SINT64:
  ------------------
  |  Branch (794:9): [True: 0, False: 10.6k]
  ------------------
  795|    110|        case TIFF_SETGET_C0_DOUBLE:
  ------------------
  |  Branch (795:9): [True: 0, False: 10.6k]
  ------------------
  796|    110|        case TIFF_SETGET_C0_IFD8:
  ------------------
  |  Branch (796:9): [True: 0, False: 10.6k]
  ------------------
  797|    110|        case TIFF_SETGET_C16_UINT64:
  ------------------
  |  Branch (797:9): [True: 0, False: 10.6k]
  ------------------
  798|    110|        case TIFF_SETGET_C16_SINT64:
  ------------------
  |  Branch (798:9): [True: 0, False: 10.6k]
  ------------------
  799|    110|        case TIFF_SETGET_C16_DOUBLE:
  ------------------
  |  Branch (799:9): [True: 0, False: 10.6k]
  ------------------
  800|    110|        case TIFF_SETGET_C16_IFD8:
  ------------------
  |  Branch (800:9): [True: 0, False: 10.6k]
  ------------------
  801|    319|        case TIFF_SETGET_C32_UINT64:
  ------------------
  |  Branch (801:9): [True: 209, False: 10.4k]
  ------------------
  802|    343|        case TIFF_SETGET_C32_SINT64:
  ------------------
  |  Branch (802:9): [True: 24, False: 10.6k]
  ------------------
  803|    432|        case TIFF_SETGET_C32_DOUBLE:
  ------------------
  |  Branch (803:9): [True: 89, False: 10.5k]
  ------------------
  804|    510|        case TIFF_SETGET_C32_IFD8:
  ------------------
  |  Branch (804:9): [True: 78, False: 10.5k]
  ------------------
  805|    510|            return 8;
  806|      0|        default:
  ------------------
  |  Branch (806:9): [True: 0, False: 10.6k]
  ------------------
  807|      0|            return 0;
  808|  10.6k|    }
  809|  10.6k|} /*-- TIFFFieldSetGetSize() --- */
TIFFFindField:
  882|   877k|{
  883|   877k|    TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0,   TIFF_SETGET_UNDEFINED,
  884|   877k|                     0, 0, 0, NULL,        NULL};
  885|   877k|    TIFFField *pkey = &key;
  886|   877k|    const TIFFField **ret;
  887|   877k|    if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
  ------------------
  |  Branch (887:9): [True: 204k, False: 672k]
  |  Branch (887:32): [True: 127k, False: 77.3k]
  ------------------
  888|   127k|        (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
  ------------------
  |  |  341|   254k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  |  Branch (888:10): [True: 127k, False: 0]
  |  Branch (888:28): [True: 0, False: 0]
  ------------------
  889|   127k|        return tif->tif_foundfield;
  890|       |
  891|       |    /* If we are invoked with no field information, then just return. */
  892|   750k|    if (!tif->tif_fields)
  ------------------
  |  Branch (892:9): [True: 0, False: 750k]
  ------------------
  893|      0|        return NULL;
  894|       |
  895|       |    /* NB: use sorted search (e.g. binary search) */
  896|       |
  897|   750k|    key.field_tag = tag;
  898|   750k|    key.field_type = dt;
  899|       |
  900|   750k|    ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
  901|   750k|                                      sizeof(TIFFField *), tagCompare);
  902|   750k|    return tif->tif_foundfield = (ret ? *ret : NULL);
  ------------------
  |  Branch (902:35): [True: 91.7k, False: 658k]
  ------------------
  903|   750k|}
TIFFFieldWithTag:
  934|  48.7k|{
  935|  48.7k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  48.7k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  936|  48.7k|    if (!fip)
  ------------------
  |  Branch (936:9): [True: 0, False: 48.7k]
  ------------------
  937|      0|    {
  938|      0|        if (tif->tif_warn_about_unknown_tags)
  ------------------
  |  Branch (938:13): [True: 0, False: 0]
  ------------------
  939|      0|        {
  940|      0|            TIFFWarningExtR(tif, "TIFFFieldWithTag",
  941|      0|                            "Warning, unknown tag 0x%x", (unsigned int)tag);
  942|      0|        }
  943|      0|    }
  944|  48.7k|    return (fip);
  945|  48.7k|}
TIFFFieldIsAnonymous:
  974|   494k|{
  975|   494k|    return (int)fip->field_anonymous;
  976|   494k|}
_TIFFCreateAnonField:
  997|   185k|{
  998|   185k|    TIFFField *fld;
  999|   185k|    (void)tif;
 1000|       |
 1001|   185k|    fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
 1002|   185k|    if (fld == NULL)
  ------------------
  |  Branch (1002:9): [True: 0, False: 185k]
  ------------------
 1003|      0|        return NULL;
 1004|   185k|    _TIFFmemset(fld, 0, sizeof(TIFFField));
 1005|       |
 1006|   185k|    fld->field_tag = tag;
 1007|   185k|    fld->field_readcount = TIFF_VARIABLE2;
  ------------------
  |  |  344|   185k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
 1008|   185k|    fld->field_writecount = TIFF_VARIABLE2;
  ------------------
  |  |  344|   185k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
 1009|   185k|    fld->field_type = field_type;
 1010|   185k|    fld->field_anonymous =
 1011|   185k|        1; /* indicate that this is an anonymous / unknown tag */
 1012|   185k|    switch (field_type)
 1013|   185k|    {
 1014|  3.55k|        case TIFF_BYTE:
  ------------------
  |  Branch (1014:9): [True: 3.55k, False: 182k]
  ------------------
 1015|  3.76k|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1015:9): [True: 213, False: 185k]
  ------------------
 1016|  3.76k|            fld->set_get_field_type = TIFF_SETGET_C32_UINT8;
 1017|  3.76k|            break;
 1018|    732|        case TIFF_ASCII:
  ------------------
  |  Branch (1018:9): [True: 732, False: 184k]
  ------------------
 1019|    732|            fld->set_get_field_type = TIFF_SETGET_C32_ASCII;
 1020|    732|            break;
 1021|  6.68k|        case TIFF_SHORT:
  ------------------
  |  Branch (1021:9): [True: 6.68k, False: 178k]
  ------------------
 1022|  6.68k|            fld->set_get_field_type = TIFF_SETGET_C32_UINT16;
 1023|  6.68k|            break;
 1024|  2.00k|        case TIFF_LONG:
  ------------------
  |  Branch (1024:9): [True: 2.00k, False: 183k]
  ------------------
 1025|  2.00k|            fld->set_get_field_type = TIFF_SETGET_C32_UINT32;
 1026|  2.00k|            break;
 1027|    573|        case TIFF_RATIONAL:
  ------------------
  |  Branch (1027:9): [True: 573, False: 185k]
  ------------------
 1028|    613|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (1028:9): [True: 40, False: 185k]
  ------------------
 1029|    637|        case TIFF_FLOAT:
  ------------------
  |  Branch (1029:9): [True: 24, False: 185k]
  ------------------
 1030|    637|            fld->set_get_field_type = TIFF_SETGET_C32_FLOAT;
 1031|    637|            break;
 1032|    441|        case TIFF_SBYTE:
  ------------------
  |  Branch (1032:9): [True: 441, False: 185k]
  ------------------
 1033|    441|            fld->set_get_field_type = TIFF_SETGET_C32_SINT8;
 1034|    441|            break;
 1035|     95|        case TIFF_SSHORT:
  ------------------
  |  Branch (1035:9): [True: 95, False: 185k]
  ------------------
 1036|     95|            fld->set_get_field_type = TIFF_SETGET_C32_SINT16;
 1037|     95|            break;
 1038|    480|        case TIFF_SLONG:
  ------------------
  |  Branch (1038:9): [True: 480, False: 185k]
  ------------------
 1039|    480|            fld->set_get_field_type = TIFF_SETGET_C32_SINT32;
 1040|    480|            break;
 1041|    120|        case TIFF_DOUBLE:
  ------------------
  |  Branch (1041:9): [True: 120, False: 185k]
  ------------------
 1042|    120|            fld->set_get_field_type = TIFF_SETGET_C32_DOUBLE;
 1043|    120|            break;
 1044|     19|        case TIFF_IFD:
  ------------------
  |  Branch (1044:9): [True: 19, False: 185k]
  ------------------
 1045|    226|        case TIFF_IFD8:
  ------------------
  |  Branch (1045:9): [True: 207, False: 185k]
  ------------------
 1046|    226|            fld->set_get_field_type = TIFF_SETGET_C32_IFD8;
 1047|    226|            break;
 1048|    915|        case TIFF_LONG8:
  ------------------
  |  Branch (1048:9): [True: 915, False: 184k]
  ------------------
 1049|    915|            fld->set_get_field_type = TIFF_SETGET_C32_UINT64;
 1050|    915|            break;
 1051|    458|        case TIFF_SLONG8:
  ------------------
  |  Branch (1051:9): [True: 458, False: 185k]
  ------------------
 1052|    458|            fld->set_get_field_type = TIFF_SETGET_C32_SINT64;
 1053|    458|            break;
 1054|  25.4k|        case TIFF_NOTYPE:
  ------------------
  |  Branch (1054:9): [True: 25.4k, False: 160k]
  ------------------
 1055|   169k|        default:
  ------------------
  |  Branch (1055:9): [True: 143k, False: 41.9k]
  ------------------
 1056|   169k|            fld->set_get_field_type = TIFF_SETGET_UNDEFINED;
 1057|   169k|            break;
 1058|   185k|    }
 1059|   185k|    fld->field_bit = FIELD_CUSTOM;
  ------------------
  |  |  346|   185k|#define FIELD_CUSTOM 65
  ------------------
 1060|   185k|    fld->field_oktochange = TRUE;
  ------------------
  |  |   71|   185k|#define TRUE 1
  ------------------
 1061|   185k|    fld->field_passcount = TRUE;
  ------------------
  |  |   71|   185k|#define TRUE 1
  ------------------
 1062|   185k|    char *field_name_buf = (char *)_TIFFmallocExt(tif, 32);
 1063|   185k|    if (field_name_buf == NULL)
  ------------------
  |  Branch (1063:9): [True: 0, False: 185k]
  ------------------
 1064|      0|    {
 1065|      0|        _TIFFfreeExt(tif, fld);
 1066|      0|        return NULL;
 1067|      0|    }
 1068|   185k|    fld->field_subfields = NULL;
 1069|       |
 1070|       |    /*
 1071|       |     * note that this name is a special sign to TIFFClose() and
 1072|       |     * _TIFFSetupFields() to free the field
 1073|       |     * Update:
 1074|       |     *   This special sign is replaced by fld->field_anonymous  flag.
 1075|       |     */
 1076|   185k|    (void)snprintf(field_name_buf, 32, "Tag %d", (int)tag);
 1077|   185k|    fld->field_name = field_name_buf;
 1078|       |
 1079|   185k|    return fld;
 1080|   185k|}
_TIFFCheckFieldIsValidForCodec:
 1354|   211k|{
 1355|       |    /* Filter out non-codec specific tags */
 1356|   211k|    switch (tag)
 1357|   211k|    {
 1358|       |        /* Shared tags */
 1359|    270|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|    270|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1359:9): [True: 270, False: 211k]
  ------------------
 1360|       |        /* JPEG tags */
 1361|    437|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|    437|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (1361:9): [True: 167, False: 211k]
  ------------------
 1362|       |        /* OJPEG tags */
 1363|  1.04k|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|  1.04k|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (1363:9): [True: 605, False: 211k]
  ------------------
 1364|  1.17k|        case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|  1.17k|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (1364:9): [True: 132, False: 211k]
  ------------------
 1365|  2.09k|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|  2.09k|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (1365:9): [True: 923, False: 210k]
  ------------------
 1366|  2.88k|        case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|  2.88k|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (1366:9): [True: 790, False: 210k]
  ------------------
 1367|  3.82k|        case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|  3.82k|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (1367:9): [True: 937, False: 210k]
  ------------------
 1368|  5.52k|        case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|  5.52k|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (1368:9): [True: 1.70k, False: 209k]
  ------------------
 1369|  5.60k|        case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|  5.60k|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (1369:9): [True: 73, False: 211k]
  ------------------
 1370|       |        /* CCITT* */
 1371|  5.67k|        case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|  5.67k|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1371:9): [True: 75, False: 211k]
  ------------------
 1372|  5.68k|        case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|  5.68k|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1372:9): [True: 9, False: 211k]
  ------------------
 1373|  5.72k|        case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|  5.72k|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1373:9): [True: 34, False: 211k]
  ------------------
 1374|  6.52k|        case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|  6.52k|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1374:9): [True: 805, False: 210k]
  ------------------
 1375|  6.69k|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|  6.69k|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1375:9): [True: 167, False: 211k]
  ------------------
 1376|       |        /* LERC */
 1377|  6.69k|        case TIFFTAG_LERC_PARAMETERS:
  ------------------
  |  |  502|  6.69k|#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */
  ------------------
  |  Branch (1377:9): [True: 4, False: 211k]
  ------------------
 1378|  6.69k|            break;
 1379|   205k|        default:
  ------------------
  |  Branch (1379:9): [True: 205k, False: 6.69k]
  ------------------
 1380|   205k|            return 1;
 1381|   211k|    }
 1382|  6.69k|    if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression))
  ------------------
  |  Branch (1382:9): [True: 236, False: 6.46k]
  ------------------
 1383|    236|    {
 1384|    236|        return 0;
 1385|    236|    }
 1386|       |    /* Check if codec specific tags are allowed for the current
 1387|       |     * compression scheme (codec) */
 1388|  6.46k|    switch (tif->tif_dir.td_compression)
 1389|  6.46k|    {
 1390|    142|        case COMPRESSION_LZW:
  ------------------
  |  |  188|    142|#define COMPRESSION_LZW 5             /* Lempel-Ziv  & Welch */
  ------------------
  |  Branch (1390:9): [True: 142, False: 6.31k]
  ------------------
 1391|    142|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|    142|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1391:17): [True: 25, False: 117]
  ------------------
 1392|     25|                return 1;
 1393|    117|            break;
 1394|    117|        case COMPRESSION_PACKBITS:
  ------------------
  |  |  195|     84|#define COMPRESSION_PACKBITS 32773    /* Macintosh RLE */
  ------------------
  |  Branch (1394:9): [True: 84, False: 6.37k]
  ------------------
 1395|       |            /* No codec-specific tags */
 1396|     84|            break;
 1397|     30|        case COMPRESSION_THUNDERSCAN:
  ------------------
  |  |  196|     30|#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */
  ------------------
  |  Branch (1397:9): [True: 30, False: 6.43k]
  ------------------
 1398|       |            /* No codec-specific tags */
 1399|     30|            break;
 1400|      4|        case COMPRESSION_NEXT:
  ------------------
  |  |  193|      4|#define COMPRESSION_NEXT 32766        /* NeXT 2-bit RLE */
  ------------------
  |  Branch (1400:9): [True: 4, False: 6.45k]
  ------------------
 1401|       |            /* No codec-specific tags */
 1402|      4|            break;
 1403|    312|        case COMPRESSION_JPEG:
  ------------------
  |  |  190|    312|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
  |  Branch (1403:9): [True: 312, False: 6.14k]
  ------------------
 1404|    312|            if (tag == TIFFTAG_JPEGTABLES)
  ------------------
  |  |  346|    312|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (1404:17): [True: 11, False: 301]
  ------------------
 1405|     11|                return 1;
 1406|    301|            break;
 1407|  4.31k|        case COMPRESSION_OJPEG:
  ------------------
  |  |  189|  4.31k|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (1407:9): [True: 4.31k, False: 2.14k]
  ------------------
 1408|  4.31k|            switch (tag)
 1409|  4.31k|            {
 1410|    362|                case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|    362|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (1410:17): [True: 362, False: 3.95k]
  ------------------
 1411|    452|                case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|    452|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (1411:17): [True: 90, False: 4.22k]
  ------------------
 1412|  1.13k|                case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|  1.13k|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (1412:17): [True: 687, False: 3.63k]
  ------------------
 1413|  1.75k|                case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|  1.75k|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (1413:17): [True: 616, False: 3.70k]
  ------------------
 1414|  2.48k|                case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|  2.48k|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (1414:17): [True: 731, False: 3.58k]
  ------------------
 1415|  3.43k|                case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|  3.43k|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (1415:17): [True: 944, False: 3.37k]
  ------------------
 1416|  3.46k|                case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|  3.46k|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (1416:17): [True: 38, False: 4.28k]
  ------------------
 1417|  3.46k|                    return 1;
 1418|    850|                default:
  ------------------
  |  Branch (1418:17): [True: 850, False: 3.46k]
  ------------------
 1419|    850|                    break;
 1420|  4.31k|            }
 1421|    850|            break;
 1422|    850|        case COMPRESSION_CCITTRLE:
  ------------------
  |  |  183|     95|#define COMPRESSION_CCITTRLE 2        /* CCITT modified Huffman RLE */
  ------------------
  |  Branch (1422:9): [True: 95, False: 6.36k]
  ------------------
 1423|    127|        case COMPRESSION_CCITTRLEW:
  ------------------
  |  |  194|    127|#define COMPRESSION_CCITTRLEW 32771   /* #1 w/ word alignment */
  ------------------
  |  Branch (1423:9): [True: 32, False: 6.42k]
  ------------------
 1424|    359|        case COMPRESSION_CCITTFAX3:
  ------------------
  |  |  184|    359|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1424:9): [True: 232, False: 6.22k]
  ------------------
 1425|    492|        case COMPRESSION_CCITTFAX4:
  ------------------
  |  |  186|    492|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1425:9): [True: 133, False: 6.32k]
  ------------------
 1426|    492|            switch (tag)
 1427|    492|            {
 1428|      4|                case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|      4|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1428:17): [True: 4, False: 488]
  ------------------
 1429|      8|                case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|      8|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1429:17): [True: 4, False: 488]
  ------------------
 1430|     34|                case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|     34|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1430:17): [True: 26, False: 466]
  ------------------
 1431|     34|                    return 1;
 1432|     82|                case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|     82|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1432:17): [True: 82, False: 410]
  ------------------
 1433|     82|                    if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
  ------------------
  |  |  184|     82|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1433:25): [True: 56, False: 26]
  ------------------
 1434|     56|                        return 1;
 1435|     26|                    break;
 1436|     34|                case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|     34|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1436:17): [True: 34, False: 458]
  ------------------
 1437|     34|                    if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
  ------------------
  |  |  186|     34|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1437:25): [True: 17, False: 17]
  ------------------
 1438|     17|                        return 1;
 1439|     17|                    break;
 1440|    342|                default:
  ------------------
  |  Branch (1440:17): [True: 342, False: 150]
  ------------------
 1441|    342|                    break;
 1442|    492|            }
 1443|    385|            break;
 1444|    385|        case COMPRESSION_JBIG:
  ------------------
  |  |  209|      9|#define COMPRESSION_JBIG 34661     /* ISO JBIG */
  ------------------
  |  Branch (1444:9): [True: 9, False: 6.45k]
  ------------------
 1445|       |            /* No codec-specific tags */
 1446|      9|            break;
 1447|     27|        case COMPRESSION_DEFLATE:
  ------------------
  |  |  205|     27|#define COMPRESSION_DEFLATE 32946   /* Deflate compression, legacy tag */
  ------------------
  |  Branch (1447:9): [True: 27, False: 6.43k]
  ------------------
 1448|    118|        case COMPRESSION_ADOBE_DEFLATE:
  ------------------
  |  |  206|    118|#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, as recognized by Adobe */
  ------------------
  |  Branch (1448:9): [True: 91, False: 6.36k]
  ------------------
 1449|    118|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|    118|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1449:17): [True: 20, False: 98]
  ------------------
 1450|     20|                return 1;
 1451|     98|            break;
 1452|    126|        case COMPRESSION_PIXARLOG:
  ------------------
  |  |  204|    126|#define COMPRESSION_PIXARLOG 32909  /* Pixar companded 11bit ZIP */
  ------------------
  |  Branch (1452:9): [True: 126, False: 6.33k]
  ------------------
 1453|    126|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|    126|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1453:17): [True: 21, False: 105]
  ------------------
 1454|     21|                return 1;
 1455|    105|            break;
 1456|    105|        case COMPRESSION_SGILOG:
  ------------------
  |  |  210|     58|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (1456:9): [True: 58, False: 6.40k]
  ------------------
 1457|    139|        case COMPRESSION_SGILOG24:
  ------------------
  |  |  211|    139|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (1457:9): [True: 81, False: 6.37k]
  ------------------
 1458|       |            /* No codec-specific tags */
 1459|    139|            break;
 1460|      0|        case COMPRESSION_LZMA:
  ------------------
  |  |  215|      0|#define COMPRESSION_LZMA 34925             /* LZMA2 */
  ------------------
  |  Branch (1460:9): [True: 0, False: 6.46k]
  ------------------
 1461|      0|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1461:17): [True: 0, False: 0]
  ------------------
 1462|      0|                return 1;
 1463|      0|            break;
 1464|      0|        case COMPRESSION_ZSTD:
  ------------------
  |  |  216|      0|#define COMPRESSION_ZSTD 50000             /* ZSTD: WARNING not registered in Adobe-maintained registry */
  ------------------
  |  Branch (1464:9): [True: 0, False: 6.46k]
  ------------------
 1465|      0|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1465:17): [True: 0, False: 0]
  ------------------
 1466|      0|                return 1;
 1467|      0|            break;
 1468|      0|        case COMPRESSION_LERC:
  ------------------
  |  |  213|      0|#define COMPRESSION_LERC 34887     /* ESRI Lerc codec: https://github.com/Esri/lerc */
  ------------------
  |  Branch (1468:9): [True: 0, False: 6.46k]
  ------------------
 1469|      0|            if (tag == TIFFTAG_LERC_PARAMETERS)
  ------------------
  |  |  502|      0|#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */
  ------------------
  |  Branch (1469:17): [True: 0, False: 0]
  ------------------
 1470|      0|                return 1;
 1471|      0|            break;
 1472|    686|        default:
  ------------------
  |  Branch (1472:9): [True: 686, False: 5.77k]
  ------------------
 1473|    686|            break;
 1474|  6.46k|    }
 1475|  2.80k|    return 0;
 1476|  6.46k|}
tif_dirinfo.c:tagCompare:
  601|   210M|{
  602|   210M|    const TIFFField *ta = *(const TIFFField **)a;
  603|   210M|    const TIFFField *tb = *(const TIFFField **)b;
  604|       |    /* NB: be careful of return values for 16-bit platforms */
  605|   210M|    if (ta->field_tag != tb->field_tag)
  ------------------
  |  Branch (605:9): [True: 210M, False: 91.7k]
  ------------------
  606|   210M|        return (int)ta->field_tag - (int)tb->field_tag;
  607|  91.7k|    else
  608|  91.7k|        return (ta->field_type == TIFF_ANY)
  ------------------
  |  |  341|  91.7k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  |  Branch (608:16): [True: 91.7k, False: 0]
  ------------------
  609|  91.7k|                   ? 0
  610|  91.7k|                   : ((int)tb->field_type - (int)ta->field_type);
  611|   210M|}

TIFFReadDirectory:
 4336|  3.89k|{
 4337|  3.89k|    static const char module[] = "TIFFReadDirectory";
 4338|  3.89k|    TIFFDirEntry *dir;
 4339|  3.89k|    uint16_t dircount;
 4340|  3.89k|    TIFFDirEntry *dp;
 4341|  3.89k|    uint16_t di;
 4342|  3.89k|    const TIFFField *fip;
 4343|  3.89k|    uint32_t fii = FAILED_FII;
  ------------------
  |  |   44|  3.89k|#define FAILED_FII ((uint32_t)-1)
  ------------------
 4344|  3.89k|    toff_t nextdiroff;
 4345|  3.89k|    int bitspersample_read = FALSE;
  ------------------
  |  |   72|  3.89k|#define FALSE 0
  ------------------
 4346|  3.89k|    int color_channels;
 4347|       |
 4348|  3.89k|    if (tif->tif_nextdiroff == 0)
  ------------------
  |  Branch (4348:9): [True: 62, False: 3.82k]
  ------------------
 4349|     62|    {
 4350|       |        /* In this special case, tif_diroff needs also to be set to 0.
 4351|       |         * This is behind the last IFD, thus no checking or reading necessary.
 4352|       |         */
 4353|     62|        tif->tif_diroff = tif->tif_nextdiroff;
 4354|     62|        return 0;
 4355|     62|    }
 4356|       |
 4357|  3.82k|    nextdiroff = tif->tif_nextdiroff;
 4358|       |    /* tif_curdir++ and tif_nextdiroff should only be updated after SUCCESSFUL
 4359|       |     * reading of the directory. Otherwise, invalid IFD offsets could corrupt
 4360|       |     * the IFD list. */
 4361|  3.82k|    if (!_TIFFCheckDirNumberAndOffset(tif,
  ------------------
  |  Branch (4361:9): [True: 2, False: 3.82k]
  ------------------
 4362|  3.82k|                                      tif->tif_curdir ==
  ------------------
  |  Branch (4362:39): [True: 1.27k, False: 2.55k]
  ------------------
 4363|  3.82k|                                              TIFF_NON_EXISTENT_DIR_NUMBER
  ------------------
  |  |   65|  3.82k|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
 4364|  3.82k|                                          ? 0
 4365|  3.82k|                                          : tif->tif_curdir + 1,
 4366|  3.82k|                                      nextdiroff))
 4367|      2|    {
 4368|      2|        return 0; /* bad offset (IFD looping or more than TIFF_MAX_DIR_COUNT
 4369|       |                     IFDs) */
 4370|      2|    }
 4371|  3.82k|    dircount = TIFFFetchDirectory(tif, nextdiroff, &dir, &tif->tif_nextdiroff);
 4372|  3.82k|    if (!dircount)
  ------------------
  |  Branch (4372:9): [True: 824, False: 3.00k]
  ------------------
 4373|    824|    {
 4374|    824|        TIFFErrorExtR(tif, module,
 4375|    824|                      "Failed to read directory at offset %" PRIu64,
 4376|    824|                      nextdiroff);
 4377|    824|        return 0;
 4378|    824|    }
 4379|       |    /* Set global values after a valid directory has been fetched.
 4380|       |     * tif_diroff is already set to nextdiroff in TIFFFetchDirectory() in the
 4381|       |     * beginning. */
 4382|  3.00k|    if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
  ------------------
  |  |   65|  3.00k|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  |  Branch (4382:9): [True: 1.27k, False: 1.72k]
  ------------------
 4383|  1.27k|        tif->tif_curdir = 0;
 4384|  1.72k|    else
 4385|  1.72k|        tif->tif_curdir++;
 4386|       |
 4387|  3.00k|    TIFFReadDirectoryCheckOrder(tif, dir, dircount);
 4388|       |
 4389|       |    /*
 4390|       |     * Mark duplicates of any tag to be ignored (bugzilla 1994)
 4391|       |     * to avoid certain pathological problems.
 4392|       |     */
 4393|  3.00k|    {
 4394|  3.00k|        TIFFDirEntry *ma;
 4395|  3.00k|        uint16_t mb;
 4396|   487k|        for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
  ------------------
  |  Branch (4396:32): [True: 484k, False: 3.00k]
  ------------------
 4397|   484k|        {
 4398|   484k|            TIFFDirEntry *na;
 4399|   484k|            uint16_t nb;
 4400|  83.6M|            for (na = ma + 1, nb = (uint16_t)(mb + 1); nb < dircount;
  ------------------
  |  Branch (4400:56): [True: 83.2M, False: 484k]
  ------------------
 4401|  83.2M|                 na++, nb++)
 4402|  83.2M|            {
 4403|  83.2M|                if (ma->tdir_tag == na->tdir_tag)
  ------------------
  |  Branch (4403:21): [True: 6.62M, False: 76.5M]
  ------------------
 4404|  6.62M|                {
 4405|  6.62M|                    na->tdir_ignore = TRUE;
  ------------------
  |  |   71|  6.62M|#define TRUE 1
  ------------------
 4406|  6.62M|                }
 4407|  83.2M|            }
 4408|   484k|        }
 4409|  3.00k|    }
 4410|       |
 4411|  3.00k|    tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */
  ------------------
  |  |  125|  3.00k|#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
  ------------------
 4412|  3.00k|    tif->tif_flags &= ~TIFF_BUF4WRITE;   /* reset before new dir */
  ------------------
  |  |  141|  3.00k|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 4413|  3.00k|    tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
  ------------------
  |  |  153|  3.00k|    0x4000000U /* set when allocChoppedUpStripArrays() has modified strip      \
  ------------------
 4414|       |
 4415|       |    /* When changing directory, in deferred strile loading mode, we must also
 4416|       |     * unset the TIFF_LAZYSTRILELOAD_DONE bit if it was initially set,
 4417|       |     * to make sure the strile offset/bytecount are read again (when they fit
 4418|       |     * in the tag data area).
 4419|       |     */
 4420|  3.00k|    tif->tif_flags &= ~TIFF_LAZYSTRILELOAD_DONE;
  ------------------
  |  |  149|  3.00k|    0x2000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
 4421|       |
 4422|       |    /* Free any old stuff and reinit i/o and other parameters within
 4423|       |     * TIFFDefaultDirectory() since we are starting on a new directory. */
 4424|  3.00k|    TIFFFreeDirectory(tif);
 4425|  3.00k|    TIFFDefaultDirectory(tif);
 4426|       |
 4427|       |    /* After setup a fresh directory indicate that now active IFD is also
 4428|       |     * present on file, even if its entries could not be read successfully
 4429|       |     * below.  */
 4430|  3.00k|    tif->tif_dir.td_iswrittentofile = TRUE;
  ------------------
  |  |   71|  3.00k|#define TRUE 1
  ------------------
 4431|       |
 4432|       |    /* Allocate arrays for offset values outside IFD entry for IFD data size
 4433|       |     * checking. Note: Counter are reset within TIFFFreeDirectory(). */
 4434|  3.00k|    tif->tif_dir.td_dirdatasize_offsets =
 4435|  3.00k|        (TIFFEntryOffsetAndLength *)_TIFFmallocExt(
 4436|  3.00k|            tif,
 4437|  3.00k|            (tmsize_t)((size_t)dircount * sizeof(TIFFEntryOffsetAndLength)));
 4438|  3.00k|    if (tif->tif_dir.td_dirdatasize_offsets == NULL)
  ------------------
  |  Branch (4438:9): [True: 0, False: 3.00k]
  ------------------
 4439|      0|    {
 4440|      0|        TIFFErrorExtR(
 4441|      0|            tif, module,
 4442|      0|            "Failed to allocate memory for counting IFD data size at reading");
 4443|      0|        goto bad;
 4444|      0|    }
 4445|       |    /*
 4446|       |     * Electronic Arts writes gray-scale TIFF files
 4447|       |     * without a PlanarConfiguration directory entry.
 4448|       |     * Thus we setup a default value here, even though
 4449|       |     * the TIFF spec says there is no default value.
 4450|       |     * After PlanarConfiguration is preset in TIFFDefaultDirectory()
 4451|       |     * the following setting is not needed, but does not harm either.
 4452|       |     */
 4453|  3.00k|    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  ------------------
  |  |  264|  3.00k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
                  TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  ------------------
  |  |  265|  3.00k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
 4454|       |    /*
 4455|       |     * Setup default value and then make a pass over
 4456|       |     * the fields to check type and tag information,
 4457|       |     * and to extract info required to size data
 4458|       |     * structures.  A second pass is made afterwards
 4459|       |     * to read in everything not taken in the first pass.
 4460|       |     * But we must process the Compression tag first
 4461|       |     * in order to merge in codec-private tag definitions (otherwise
 4462|       |     * we may get complaints about unknown tags).  However, the
 4463|       |     * Compression tag may be dependent on the SamplesPerPixel
 4464|       |     * tag value because older TIFF specs permitted Compression
 4465|       |     * to be written as a SamplesPerPixel-count tag entry.
 4466|       |     * Thus if we don't first figure out the correct SamplesPerPixel
 4467|       |     * tag value then we may end up ignoring the Compression tag
 4468|       |     * value because it has an incorrect count value (if the
 4469|       |     * true value of SamplesPerPixel is not 1).
 4470|       |     */
 4471|  3.00k|    dp =
 4472|  3.00k|        TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_SAMPLESPERPIXEL);
  ------------------
  |  |  257|  3.00k|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
 4473|  3.00k|    if (dp)
  ------------------
  |  Branch (4473:9): [True: 1.63k, False: 1.37k]
  ------------------
 4474|  1.63k|    {
 4475|  1.63k|        if (!TIFFFetchNormalTag(tif, dp, 0))
  ------------------
  |  Branch (4475:13): [True: 1, False: 1.63k]
  ------------------
 4476|      1|            goto bad;
 4477|  1.63k|        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  1.63k|#define TRUE 1
  ------------------
 4478|  1.63k|    }
 4479|  3.00k|    dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_COMPRESSION);
  ------------------
  |  |  181|  3.00k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
 4480|  3.00k|    if (dp)
  ------------------
  |  Branch (4480:9): [True: 2.56k, False: 435]
  ------------------
 4481|  2.56k|    {
 4482|       |        /*
 4483|       |         * The 5.0 spec says the Compression tag has one value, while
 4484|       |         * earlier specs say it has one value per sample.  Because of
 4485|       |         * this, we accept the tag if one value is supplied with either
 4486|       |         * count.
 4487|       |         */
 4488|  2.56k|        uint16_t value;
 4489|  2.56k|        enum TIFFReadDirEntryErr err;
 4490|  2.56k|        err = TIFFReadDirEntryShort(tif, dp, &value);
 4491|  2.56k|        if (err == TIFFReadDirEntryErrCount)
  ------------------
  |  Branch (4491:13): [True: 16, False: 2.55k]
  ------------------
 4492|     16|            err = TIFFReadDirEntryPersampleShort(tif, dp, &value);
 4493|  2.56k|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4493:13): [True: 3, False: 2.56k]
  ------------------
 4494|      3|        {
 4495|      3|            TIFFReadDirEntryOutputErr(tif, err, module, "Compression", 0);
 4496|      3|            goto bad;
 4497|      3|        }
 4498|  2.56k|        if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, value))
  ------------------
  |  |  181|  2.56k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (4498:13): [True: 0, False: 2.56k]
  ------------------
 4499|      0|            goto bad;
 4500|  2.56k|        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  2.56k|#define TRUE 1
  ------------------
 4501|  2.56k|    }
 4502|    435|    else
 4503|    435|    {
 4504|    435|        if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE))
  ------------------
  |  |  181|    435|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
                      if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE))
  ------------------
  |  |  182|    435|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (4504:13): [True: 0, False: 435]
  ------------------
 4505|      0|            goto bad;
 4506|    435|    }
 4507|       |    /*
 4508|       |     * First real pass over the directory.
 4509|       |     */
 4510|   478k|    for (di = 0, dp = dir; di < dircount; di++, dp++)
  ------------------
  |  Branch (4510:28): [True: 475k, False: 2.98k]
  ------------------
 4511|   475k|    {
 4512|   475k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4512:13): [True: 228k, False: 246k]
  ------------------
 4513|   228k|        {
 4514|   228k|            TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 4515|   228k|            if (fii == FAILED_FII)
  ------------------
  |  |   44|   228k|#define FAILED_FII ((uint32_t)-1)
  ------------------
  |  Branch (4515:17): [True: 185k, False: 43.0k]
  ------------------
 4516|   185k|            {
 4517|   185k|                if (tif->tif_warn_about_unknown_tags)
  ------------------
  |  Branch (4517:21): [True: 0, False: 185k]
  ------------------
 4518|      0|                {
 4519|      0|                    TIFFWarningExtR(tif, module,
 4520|      0|                                    "Unknown field with tag %" PRIu16
 4521|      0|                                    " (0x%" PRIx16 ") encountered",
 4522|      0|                                    dp->tdir_tag, dp->tdir_tag);
 4523|      0|                }
 4524|       |                /* the following knowingly leaks the
 4525|       |                   anonymous field structure */
 4526|   185k|                const TIFFField *fld = _TIFFCreateAnonField(
 4527|   185k|                    tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
 4528|   185k|                if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
  ------------------
  |  Branch (4528:21): [True: 0, False: 185k]
  |  Branch (4528:36): [True: 0, False: 185k]
  ------------------
 4529|      0|                {
 4530|      0|                    TIFFWarningExtR(
 4531|      0|                        tif, module,
 4532|      0|                        "Registering anonymous field with tag %" PRIu16
 4533|      0|                        " (0x%" PRIx16 ") failed",
 4534|      0|                        dp->tdir_tag, dp->tdir_tag);
 4535|      0|                    dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 4536|      0|                }
 4537|   185k|                else
 4538|   185k|                {
 4539|   185k|                    TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 4540|   185k|                    assert(fii != FAILED_FII);
  ------------------
  |  Branch (4540:21): [True: 0, False: 185k]
  |  Branch (4540:21): [True: 185k, False: 0]
  ------------------
 4541|   185k|                }
 4542|   185k|            }
 4543|   228k|        }
 4544|   475k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4544:13): [True: 228k, False: 246k]
  ------------------
 4545|   228k|        {
 4546|   228k|            fip = tif->tif_fields[fii];
 4547|   228k|            if (fip->field_bit == FIELD_IGNORE)
  ------------------
  |  |  190|   228k|#define FIELD_IGNORE 0
  ------------------
  |  Branch (4547:17): [True: 1.79k, False: 226k]
  ------------------
 4548|  1.79k|                dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  1.79k|#define TRUE 1
  ------------------
 4549|   226k|            else
 4550|   226k|            {
 4551|   226k|                switch (dp->tdir_tag)
 4552|   226k|                {
 4553|  2.62k|                    case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|  2.62k|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (4553:21): [True: 2.62k, False: 224k]
  ------------------
 4554|  4.56k|                    case TIFFTAG_STRIPBYTECOUNTS:
  ------------------
  |  |  259|  4.56k|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
  |  Branch (4554:21): [True: 1.93k, False: 224k]
  ------------------
 4555|  4.62k|                    case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|  4.62k|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (4555:21): [True: 68, False: 226k]
  ------------------
 4556|  4.87k|                    case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|  4.87k|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (4556:21): [True: 245, False: 226k]
  ------------------
 4557|  4.87k|                        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|  4.87k|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|  4.87k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|  4.87k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 4558|  4.87k|                        break;
 4559|  2.98k|                    case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|  2.98k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (4559:21): [True: 2.98k, False: 223k]
  ------------------
 4560|  5.70k|                    case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|  5.70k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (4560:21): [True: 2.72k, False: 224k]
  ------------------
 4561|  5.72k|                    case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|  5.72k|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (4561:21): [True: 16, False: 226k]
  ------------------
 4562|  5.83k|                    case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|  5.83k|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (4562:21): [True: 111, False: 226k]
  ------------------
 4563|  6.42k|                    case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|  6.42k|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (4563:21): [True: 591, False: 226k]
  ------------------
 4564|  6.42k|                    case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|  6.42k|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (4564:21): [True: 2, False: 226k]
  ------------------
 4565|  7.48k|                    case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|  7.48k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (4565:21): [True: 1.05k, False: 225k]
  ------------------
 4566|  9.53k|                    case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|  9.53k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (4566:21): [True: 2.04k, False: 224k]
  ------------------
 4567|  10.2k|                    case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|  10.2k|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (4567:21): [True: 762, False: 226k]
  ------------------
 4568|  10.2k|                        if (!TIFFFetchNormalTag(tif, dp, 0))
  ------------------
  |  Branch (4568:29): [True: 18, False: 10.2k]
  ------------------
 4569|     18|                            goto bad;
 4570|  10.2k|                        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  10.2k|#define TRUE 1
  ------------------
 4571|  10.2k|                        break;
 4572|   211k|                    default:
  ------------------
  |  Branch (4572:21): [True: 211k, False: 15.1k]
  ------------------
 4573|   211k|                        if (!_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag))
  ------------------
  |  Branch (4573:29): [True: 3.04k, False: 208k]
  ------------------
 4574|  3.04k|                            dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  3.04k|#define TRUE 1
  ------------------
 4575|   211k|                        break;
 4576|   226k|                }
 4577|   226k|            }
 4578|   228k|        }
 4579|   475k|    }
 4580|       |    /*
 4581|       |     * XXX: OJPEG hack.
 4582|       |     * If a) compression is OJPEG, b) planarconfig tag says it's separate,
 4583|       |     * c) strip offsets/bytecounts tag are both present and
 4584|       |     * d) both contain exactly one value, then we consistently find
 4585|       |     * that the buggy implementation of the buggy compression scheme
 4586|       |     * matches contig planarconfig best. So we 'fix-up' the tag here
 4587|       |     */
 4588|  2.98k|    if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
  ------------------
  |  |  189|  2.98k|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (4588:9): [True: 1.42k, False: 1.55k]
  ------------------
 4589|  1.42k|        (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE))
  ------------------
  |  |  266|  1.42k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (4589:9): [True: 625, False: 800]
  ------------------
 4590|    625|    {
 4591|    625|        if (!_TIFFFillStriles(tif))
  ------------------
  |  Branch (4591:13): [True: 0, False: 625]
  ------------------
 4592|      0|            goto bad;
 4593|    625|        dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
 4594|    625|                                        TIFFTAG_STRIPOFFSETS);
  ------------------
  |  |  247|    625|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
 4595|    625|        if ((dp != 0) && (dp->tdir_count == 1))
  ------------------
  |  Branch (4595:13): [True: 621, False: 4]
  |  Branch (4595:26): [True: 201, False: 420]
  ------------------
 4596|    201|        {
 4597|    201|            dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
 4598|    201|                                            TIFFTAG_STRIPBYTECOUNTS);
  ------------------
  |  |  259|    201|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
 4599|    201|            if ((dp != 0) && (dp->tdir_count == 1))
  ------------------
  |  Branch (4599:17): [True: 178, False: 23]
  |  Branch (4599:30): [True: 89, False: 89]
  ------------------
 4600|     89|            {
 4601|     89|                tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
  ------------------
  |  |  265|     89|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
 4602|     89|                TIFFWarningExtR(tif, module,
 4603|     89|                                "Planarconfig tag value assumed incorrect, "
 4604|     89|                                "assuming data is contig instead of chunky");
 4605|     89|            }
 4606|    201|        }
 4607|    625|    }
 4608|       |    /*
 4609|       |     * Allocate directory structure and setup defaults.
 4610|       |     */
 4611|  2.98k|    if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
  ------------------
  |  |  248|  2.98k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  2.98k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  2.98k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4611:9): [True: 9, False: 2.97k]
  ------------------
 4612|      9|    {
 4613|      9|        MissingRequired(tif, "ImageLength");
 4614|      9|        goto bad;
 4615|      9|    }
 4616|       |
 4617|       |    /*
 4618|       |     * Second pass: extract other information.
 4619|       |     */
 4620|   464k|    for (di = 0, dp = dir; di < dircount; di++, dp++)
  ------------------
  |  Branch (4620:28): [True: 461k, False: 2.91k]
  ------------------
 4621|   461k|    {
 4622|   461k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4622:13): [True: 202k, False: 259k]
  ------------------
 4623|   202k|        {
 4624|   202k|            switch (dp->tdir_tag)
 4625|   202k|            {
 4626|     19|                case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|     19|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (4626:17): [True: 19, False: 202k]
  ------------------
 4627|    130|                case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|    130|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (4627:17): [True: 111, False: 202k]
  ------------------
 4628|  1.42k|                case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|  1.42k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4628:17): [True: 1.29k, False: 201k]
  ------------------
 4629|  1.44k|                case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|  1.44k|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (4629:17): [True: 13, False: 202k]
  ------------------
 4630|  1.65k|                case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|  1.65k|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (4630:17): [True: 217, False: 202k]
  ------------------
 4631|       |                    /*
 4632|       |                     * The MinSampleValue, MaxSampleValue, BitsPerSample
 4633|       |                     * DataType and SampleFormat tags are supposed to be
 4634|       |                     * written as one value/sample, but some vendors
 4635|       |                     * incorrectly write one value only -- so we accept
 4636|       |                     * that as well (yuck). Other vendors write correct
 4637|       |                     * value for NumberOfSamples, but incorrect one for
 4638|       |                     * BitsPerSample and friends, and we will read this
 4639|       |                     * too.
 4640|       |                     */
 4641|  1.65k|                    {
 4642|  1.65k|                        uint16_t value;
 4643|  1.65k|                        enum TIFFReadDirEntryErr err;
 4644|  1.65k|                        err = TIFFReadDirEntryShort(tif, dp, &value);
 4645|  1.65k|                        if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4645:29): [True: 5, False: 1.65k]
  ------------------
 4646|      5|                            goto bad;
 4647|  1.65k|                        if (err == TIFFReadDirEntryErrCount)
  ------------------
  |  Branch (4647:29): [True: 43, False: 1.61k]
  ------------------
 4648|     43|                            err =
 4649|     43|                                TIFFReadDirEntryPersampleShort(tif, dp, &value);
 4650|  1.65k|                        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4650:29): [True: 27, False: 1.62k]
  ------------------
 4651|     27|                        {
 4652|     27|                            fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4653|     27|                            TIFFReadDirEntryOutputErr(
 4654|     27|                                tif, err, module,
 4655|     27|                                fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (4655:33): [True: 27, False: 0]
  ------------------
 4656|     27|                            goto bad;
 4657|     27|                        }
 4658|  1.62k|                        if (!TIFFSetField(tif, dp->tdir_tag, value))
  ------------------
  |  Branch (4658:29): [True: 0, False: 1.62k]
  ------------------
 4659|      0|                            goto bad;
 4660|  1.62k|                        if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE)
  ------------------
  |  |  180|  1.62k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4660:29): [True: 1.27k, False: 356]
  ------------------
 4661|  1.27k|                            bitspersample_read = TRUE;
  ------------------
  |  |   71|  1.27k|#define TRUE 1
  ------------------
 4662|  1.62k|                    }
 4663|      0|                    break;
 4664|    217|                case TIFFTAG_SMINSAMPLEVALUE:
  ------------------
  |  |  340|    217|#define TIFFTAG_SMINSAMPLEVALUE 340        /* !variable MinSampleValue */
  ------------------
  |  Branch (4664:17): [True: 217, False: 202k]
  ------------------
 4665|    244|                case TIFFTAG_SMAXSAMPLEVALUE:
  ------------------
  |  |  341|    244|#define TIFFTAG_SMAXSAMPLEVALUE 341        /* !variable MaxSampleValue */
  ------------------
  |  Branch (4665:17): [True: 27, False: 202k]
  ------------------
 4666|    244|                {
 4667|       |
 4668|    244|                    double *data = NULL;
 4669|    244|                    enum TIFFReadDirEntryErr err;
 4670|    244|                    uint32_t saved_flags;
 4671|    244|                    int m;
 4672|    244|                    if (dp->tdir_count !=
  ------------------
  |  Branch (4672:25): [True: 14, False: 230]
  ------------------
 4673|    244|                        (uint64_t)tif->tif_dir.td_samplesperpixel)
 4674|     14|                        err = TIFFReadDirEntryErrCount;
 4675|    230|                    else
 4676|    230|                        err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 4677|    244|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4677:25): [True: 1, False: 243]
  ------------------
 4678|      1|                        goto bad;
 4679|    243|                    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4679:25): [True: 14, False: 229]
  ------------------
 4680|     14|                    {
 4681|     14|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4682|     14|                        TIFFReadDirEntryOutputErr(
 4683|     14|                            tif, err, module,
 4684|     14|                            fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (4684:29): [True: 14, False: 0]
  ------------------
 4685|     14|                        goto bad;
 4686|     14|                    }
 4687|    229|                    saved_flags = tif->tif_flags;
 4688|    229|                    tif->tif_flags |= TIFF_PERSAMPLE;
  ------------------
  |  |  143|    229|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
 4689|    229|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 4690|    229|                    tif->tif_flags = saved_flags;
 4691|    229|                    _TIFFfreeExt(tif, data);
 4692|    229|                    if (!m)
  ------------------
  |  Branch (4692:25): [True: 0, False: 229]
  ------------------
 4693|      0|                        goto bad;
 4694|    229|                }
 4695|    229|                break;
 4696|  2.61k|                case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|  2.61k|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (4696:17): [True: 2.61k, False: 200k]
  ------------------
 4697|  2.68k|                case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|  2.68k|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (4697:17): [True: 68, False: 202k]
  ------------------
 4698|  2.68k|                {
 4699|  2.68k|                    switch (dp->tdir_type)
 4700|  2.68k|                    {
 4701|     82|                        case TIFF_SHORT:
  ------------------
  |  Branch (4701:25): [True: 82, False: 2.60k]
  ------------------
 4702|  2.26k|                        case TIFF_LONG:
  ------------------
  |  Branch (4702:25): [True: 2.18k, False: 500]
  ------------------
 4703|  2.26k|                        case TIFF_LONG8:
  ------------------
  |  Branch (4703:25): [True: 2, False: 2.68k]
  ------------------
 4704|  2.26k|                            break;
 4705|    416|                        default:
  ------------------
  |  Branch (4705:25): [True: 416, False: 2.26k]
  ------------------
 4706|       |                            /* Warn except if directory typically created with
 4707|       |                             * TIFFDeferStrileArrayWriting() */
 4708|    416|                            if (!(tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (4708:35): [True: 0, False: 416]
  ------------------
 4709|      0|                                  dp->tdir_count == 0 && dp->tdir_type == 0 &&
  ------------------
  |  Branch (4709:35): [True: 0, False: 0]
  |  Branch (4709:58): [True: 0, False: 0]
  ------------------
 4710|      0|                                  dp->tdir_offset.toff_long8 == 0))
  ------------------
  |  Branch (4710:35): [True: 0, False: 0]
  ------------------
 4711|    416|                            {
 4712|    416|                                fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4713|    416|                                TIFFWarningExtR(
 4714|    416|                                    tif, module, "Invalid data type for tag %s",
 4715|    416|                                    fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4715:37): [True: 416, False: 0]
  ------------------
 4716|    416|                            }
 4717|    416|                            break;
 4718|  2.68k|                    }
 4719|  2.68k|                    _TIFFmemcpy(&(tif->tif_dir.td_stripoffset_entry), dp,
 4720|  2.68k|                                sizeof(TIFFDirEntry));
 4721|  2.68k|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4721:25): [True: 3, False: 2.68k]
  ------------------
 4722|      3|                        goto bad;
 4723|  2.68k|                }
 4724|  2.68k|                break;
 4725|  2.68k|                case TIFFTAG_STRIPBYTECOUNTS:
  ------------------
  |  |  259|  1.93k|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
  |  Branch (4725:17): [True: 1.93k, False: 201k]
  ------------------
 4726|  2.17k|                case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|  2.17k|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (4726:17): [True: 245, False: 202k]
  ------------------
 4727|  2.17k|                {
 4728|  2.17k|                    switch (dp->tdir_type)
 4729|  2.17k|                    {
 4730|    496|                        case TIFF_SHORT:
  ------------------
  |  Branch (4730:25): [True: 496, False: 1.68k]
  ------------------
 4731|  1.44k|                        case TIFF_LONG:
  ------------------
  |  Branch (4731:25): [True: 947, False: 1.23k]
  ------------------
 4732|  1.62k|                        case TIFF_LONG8:
  ------------------
  |  Branch (4732:25): [True: 181, False: 1.99k]
  ------------------
 4733|  1.62k|                            break;
 4734|    553|                        default:
  ------------------
  |  Branch (4734:25): [True: 553, False: 1.62k]
  ------------------
 4735|       |                            /* Warn except if directory typically created with
 4736|       |                             * TIFFDeferStrileArrayWriting() */
 4737|    553|                            if (!(tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (4737:35): [True: 0, False: 553]
  ------------------
 4738|      0|                                  dp->tdir_count == 0 && dp->tdir_type == 0 &&
  ------------------
  |  Branch (4738:35): [True: 0, False: 0]
  |  Branch (4738:58): [True: 0, False: 0]
  ------------------
 4739|      0|                                  dp->tdir_offset.toff_long8 == 0))
  ------------------
  |  Branch (4739:35): [True: 0, False: 0]
  ------------------
 4740|    553|                            {
 4741|    553|                                fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4742|    553|                                TIFFWarningExtR(
 4743|    553|                                    tif, module, "Invalid data type for tag %s",
 4744|    553|                                    fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4744:37): [True: 553, False: 0]
  ------------------
 4745|    553|                            }
 4746|    553|                            break;
 4747|  2.17k|                    }
 4748|  2.17k|                    _TIFFmemcpy(&(tif->tif_dir.td_stripbytecount_entry), dp,
 4749|  2.17k|                                sizeof(TIFFDirEntry));
 4750|  2.17k|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4750:25): [True: 2, False: 2.17k]
  ------------------
 4751|      2|                        goto bad;
 4752|  2.17k|                }
 4753|  2.17k|                break;
 4754|  2.17k|                case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|    386|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (4754:17): [True: 386, False: 202k]
  ------------------
 4755|    626|                case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|    626|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (4755:17): [True: 240, False: 202k]
  ------------------
 4756|    626|                {
 4757|    626|                    enum TIFFReadDirEntryErr err;
 4758|    626|                    uint32_t countpersample;
 4759|    626|                    uint32_t countrequired;
 4760|    626|                    uint32_t incrementpersample;
 4761|    626|                    uint16_t *value = NULL;
 4762|       |                    /* It would be dangerous to instantiate those tag values */
 4763|       |                    /* since if td_bitspersample has not yet been read (due to
 4764|       |                     */
 4765|       |                    /* unordered tags), it could be read afterwards with a */
 4766|       |                    /* values greater than the default one (1), which may cause
 4767|       |                     */
 4768|       |                    /* crashes in user code */
 4769|    626|                    if (!bitspersample_read)
  ------------------
  |  Branch (4769:25): [True: 410, False: 216]
  ------------------
 4770|    410|                    {
 4771|    410|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4772|    410|                        TIFFWarningExtR(
 4773|    410|                            tif, module,
 4774|    410|                            "Ignoring %s since BitsPerSample tag not found",
 4775|    410|                            fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4775:29): [True: 410, False: 0]
  ------------------
 4776|    410|                        continue;
 4777|    410|                    }
 4778|       |                    /* ColorMap or TransferFunction for high bit */
 4779|       |                    /* depths do not make much sense and could be */
 4780|       |                    /* used as a denial of service vector */
 4781|    216|                    if (tif->tif_dir.td_bitspersample > 24)
  ------------------
  |  Branch (4781:25): [True: 22, False: 194]
  ------------------
 4782|     22|                    {
 4783|     22|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4784|     22|                        TIFFWarningExtR(
 4785|     22|                            tif, module,
 4786|     22|                            "Ignoring %s because BitsPerSample=%" PRIu16 ">24",
 4787|     22|                            fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (4787:29): [True: 22, False: 0]
  ------------------
 4788|     22|                            tif->tif_dir.td_bitspersample);
 4789|     22|                        continue;
 4790|     22|                    }
 4791|    194|                    countpersample = (1U << tif->tif_dir.td_bitspersample);
 4792|    194|                    if ((dp->tdir_tag == TIFFTAG_TRANSFERFUNCTION) &&
  ------------------
  |  |  298|    194|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (4792:25): [True: 32, False: 162]
  ------------------
 4793|     32|                        (dp->tdir_count == (uint64_t)countpersample))
  ------------------
  |  Branch (4793:25): [True: 7, False: 25]
  ------------------
 4794|      7|                    {
 4795|      7|                        countrequired = countpersample;
 4796|      7|                        incrementpersample = 0;
 4797|      7|                    }
 4798|    187|                    else
 4799|    187|                    {
 4800|    187|                        countrequired = 3 * countpersample;
 4801|    187|                        incrementpersample = countpersample;
 4802|    187|                    }
 4803|    194|                    if (dp->tdir_count != (uint64_t)countrequired)
  ------------------
  |  Branch (4803:25): [True: 153, False: 41]
  ------------------
 4804|    153|                        err = TIFFReadDirEntryErrCount;
 4805|     41|                    else
 4806|     41|                        err = TIFFReadDirEntryShortArray(tif, dp, &value);
 4807|    194|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4807:25): [True: 0, False: 194]
  ------------------
 4808|      0|                        goto bad;
 4809|    194|                    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4809:25): [True: 153, False: 41]
  ------------------
 4810|    153|                    {
 4811|    153|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4812|    153|                        TIFFReadDirEntryOutputErr(
 4813|    153|                            tif, err, module,
 4814|    153|                            fip ? fip->field_name : "unknown tagname", 1);
  ------------------
  |  Branch (4814:29): [True: 153, False: 0]
  ------------------
 4815|    153|                    }
 4816|     41|                    else
 4817|     41|                    {
 4818|     41|                        TIFFSetField(tif, dp->tdir_tag, value,
 4819|     41|                                     value + incrementpersample,
 4820|     41|                                     value + 2 * incrementpersample);
 4821|     41|                        _TIFFfreeExt(tif, value);
 4822|     41|                    }
 4823|    194|                }
 4824|      0|                break;
 4825|       |                    /* BEGIN REV 4.0 COMPATIBILITY */
 4826|      0|                case TIFFTAG_OSUBFILETYPE:
  ------------------
  |  |  174|      0|#define TIFFTAG_OSUBFILETYPE 255      /* +kind of data in subfile */
  ------------------
  |  Branch (4826:17): [True: 0, False: 202k]
  ------------------
 4827|      0|                {
 4828|      0|                    uint16_t valueo;
 4829|      0|                    uint32_t value;
 4830|      0|                    if (TIFFReadDirEntryShort(tif, dp, &valueo) ==
  ------------------
  |  Branch (4830:25): [True: 0, False: 0]
  ------------------
 4831|      0|                        TIFFReadDirEntryErrOk)
 4832|      0|                    {
 4833|      0|                        switch (valueo)
 4834|      0|                        {
 4835|      0|                            case OFILETYPE_REDUCEDIMAGE:
  ------------------
  |  |  176|      0|#define OFILETYPE_REDUCEDIMAGE 2      /* reduced size image data */
  ------------------
  |  Branch (4835:29): [True: 0, False: 0]
  ------------------
 4836|      0|                                value = FILETYPE_REDUCEDIMAGE;
  ------------------
  |  |  171|      0|#define FILETYPE_REDUCEDIMAGE 0x1     /* reduced resolution version */
  ------------------
 4837|      0|                                break;
 4838|      0|                            case OFILETYPE_PAGE:
  ------------------
  |  |  177|      0|#define OFILETYPE_PAGE 3              /* one page of many */
  ------------------
  |  Branch (4838:29): [True: 0, False: 0]
  ------------------
 4839|      0|                                value = FILETYPE_PAGE;
  ------------------
  |  |  172|      0|#define FILETYPE_PAGE 0x2             /* one page of many */
  ------------------
 4840|      0|                                break;
 4841|      0|                            default:
  ------------------
  |  Branch (4841:29): [True: 0, False: 0]
  ------------------
 4842|      0|                                value = 0;
 4843|      0|                                break;
 4844|      0|                        }
 4845|      0|                        if (value != 0)
  ------------------
  |  Branch (4845:29): [True: 0, False: 0]
  ------------------
 4846|      0|                            TIFFSetField(tif, TIFFTAG_SUBFILETYPE, value);
  ------------------
  |  |  170|      0|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
 4847|      0|                    }
 4848|      0|                }
 4849|      0|                break;
 4850|       |                /* END REV 4.0 COMPATIBILITY */
 4851|       |#if 0
 4852|       |                case TIFFTAG_EP_BATTERYLEVEL:
 4853|       |                    /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII.
 4854|       |                     * LibTiff defines it as ASCII and converts RATIONAL to an
 4855|       |                     * ASCII string. */
 4856|       |                    switch (dp->tdir_type)
 4857|       |                    {
 4858|       |                        case TIFF_RATIONAL:
 4859|       |                        {
 4860|       |                            /* Read rational and convert to ASCII*/
 4861|       |                            enum TIFFReadDirEntryErr err;
 4862|       |                            TIFFRational_t rValue;
 4863|       |                            err = TIFFReadDirEntryCheckedRationalDirect(
 4864|       |                                tif, dp, &rValue);
 4865|       |                            if (err != TIFFReadDirEntryErrOk)
 4866|       |                            {
 4867|       |                                fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4868|       |                                TIFFReadDirEntryOutputErr(
 4869|       |                                    tif, err, module,
 4870|       |                                    fip ? fip->field_name : "unknown tagname",
 4871|       |                                    1);
 4872|       |                            }
 4873|       |                            else
 4874|       |                            {
 4875|       |                                char szAux[32];
 4876|       |                                snprintf(szAux, sizeof(szAux) - 1, "%d/%d",
 4877|       |                                         rValue.uNum, rValue.uDenom);
 4878|       |                                TIFFSetField(tif, dp->tdir_tag, szAux);
 4879|       |                            }
 4880|       |                        }
 4881|       |                        break;
 4882|       |                        case TIFF_ASCII:
 4883|       |                            (void)TIFFFetchNormalTag(tif, dp, TRUE);
 4884|       |                            break;
 4885|       |                        default:
 4886|       |                            fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4887|       |                            TIFFWarningExtR(tif, module,
 4888|       |                                            "Invalid data type for tag %s. "
 4889|       |                                            "ASCII or RATIONAL expected",
 4890|       |                                            fip ? fip->field_name
 4891|       |                                                : "unknown tagname");
 4892|       |                            break;
 4893|       |                    }
 4894|       |                    break;
 4895|       |#endif
 4896|   195k|                default:
  ------------------
  |  Branch (4896:17): [True: 195k, False: 7.38k]
  ------------------
 4897|   195k|                    (void)TIFFFetchNormalTag(tif, dp, TRUE);
  ------------------
  |  |   71|   195k|#define TRUE 1
  ------------------
 4898|   195k|                    break;
 4899|   202k|            } /* -- switch (dp->tdir_tag) -- */
 4900|   202k|        } /* -- if (!dp->tdir_ignore) */
 4901|   461k|    } /* -- for-loop -- */
 4902|       |
 4903|       |    /* Evaluate final IFD data size. */
 4904|  2.91k|    CalcFinalIFDdatasizeReading(tif, dircount);
 4905|       |
 4906|       |    /*
 4907|       |     * OJPEG hack:
 4908|       |     * - If a) compression is OJPEG, and b) photometric tag is missing,
 4909|       |     * then we consistently find that photometric should be YCbCr
 4910|       |     * - If a) compression is OJPEG, and b) photometric tag says it's RGB,
 4911|       |     * then we consistently find that the buggy implementation of the
 4912|       |     * buggy compression scheme matches photometric YCbCr instead.
 4913|       |     * - If a) compression is OJPEG, and b) bitspersample tag is missing,
 4914|       |     * then we consistently find bitspersample should be 8.
 4915|       |     * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
 4916|       |     * and c) photometric is RGB or YCbCr, then we consistently find
 4917|       |     * samplesperpixel should be 3
 4918|       |     * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
 4919|       |     * and c) photometric is MINISWHITE or MINISBLACK, then we consistently
 4920|       |     * find samplesperpixel should be 3
 4921|       |     */
 4922|  2.91k|    if (tif->tif_dir.td_compression == COMPRESSION_OJPEG)
  ------------------
  |  |  189|  2.91k|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (4922:9): [True: 1.42k, False: 1.49k]
  ------------------
 4923|  1.42k|    {
 4924|  1.42k|        if (!TIFFFieldSet(tif, FIELD_PHOTOMETRIC))
  ------------------
  |  |  248|  1.42k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.42k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.42k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4924:13): [True: 879, False: 543]
  ------------------
 4925|    879|        {
 4926|    879|            TIFFWarningExtR(
 4927|    879|                tif, module,
 4928|    879|                "Photometric tag is missing, assuming data is YCbCr");
 4929|    879|            if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR))
  ------------------
  |  |  220|    879|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
                          if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR))
  ------------------
  |  |  227|    879|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4929:17): [True: 0, False: 879]
  ------------------
 4930|      0|                goto bad;
 4931|    879|        }
 4932|    543|        else if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|    543|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4932:18): [True: 10, False: 533]
  ------------------
 4933|     10|        {
 4934|     10|            tif->tif_dir.td_photometric = PHOTOMETRIC_YCBCR;
  ------------------
  |  |  227|     10|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
 4935|     10|            TIFFWarningExtR(tif, module,
 4936|     10|                            "Photometric tag value assumed incorrect, "
 4937|     10|                            "assuming data is YCbCr instead of RGB");
 4938|     10|        }
 4939|  1.42k|        if (!TIFFFieldSet(tif, FIELD_BITSPERSAMPLE))
  ------------------
  |  |  248|  1.42k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.42k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.42k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4939:13): [True: 1.06k, False: 354]
  ------------------
 4940|  1.06k|        {
 4941|  1.06k|            TIFFWarningExtR(
 4942|  1.06k|                tif, module,
 4943|  1.06k|                "BitsPerSample tag is missing, assuming 8 bits per sample");
 4944|  1.06k|            if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8))
  ------------------
  |  |  180|  1.06k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4944:17): [True: 0, False: 1.06k]
  ------------------
 4945|      0|                goto bad;
 4946|  1.06k|        }
 4947|  1.42k|        if (!TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|  1.42k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.42k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.42k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4947:13): [True: 760, False: 662]
  ------------------
 4948|    760|        {
 4949|    760|            if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|    760|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4949:17): [True: 0, False: 760]
  ------------------
 4950|      0|            {
 4951|      0|                TIFFWarningExtR(tif, module,
 4952|      0|                                "SamplesPerPixel tag is missing, "
 4953|      0|                                "assuming correct SamplesPerPixel value is 3");
 4954|      0|                if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3))
  ------------------
  |  |  257|      0|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (4954:21): [True: 0, False: 0]
  ------------------
 4955|      0|                    goto bad;
 4956|      0|            }
 4957|    760|            if (tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR)
  ------------------
  |  |  227|    760|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4957:17): [True: 620, False: 140]
  ------------------
 4958|    620|            {
 4959|    620|                TIFFWarningExtR(tif, module,
 4960|    620|                                "SamplesPerPixel tag is missing, "
 4961|    620|                                "applying correct SamplesPerPixel value of 3");
 4962|    620|                if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3))
  ------------------
  |  |  257|    620|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (4962:21): [True: 0, False: 620]
  ------------------
 4963|      0|                    goto bad;
 4964|    620|            }
 4965|    140|            else if ((tif->tif_dir.td_photometric == PHOTOMETRIC_MINISWHITE) ||
  ------------------
  |  |  221|    140|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (4965:22): [True: 25, False: 115]
  ------------------
 4966|    115|                     (tif->tif_dir.td_photometric == PHOTOMETRIC_MINISBLACK))
  ------------------
  |  |  222|    115|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (4966:22): [True: 10, False: 105]
  ------------------
 4967|     35|            {
 4968|       |                /*
 4969|       |                 * SamplesPerPixel tag is missing, but is not required
 4970|       |                 * by spec.  Assume correct SamplesPerPixel value of 1.
 4971|       |                 */
 4972|     35|                if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1))
  ------------------
  |  |  257|     35|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (4972:21): [True: 0, False: 35]
  ------------------
 4973|      0|                    goto bad;
 4974|     35|            }
 4975|    760|        }
 4976|  1.42k|    }
 4977|       |
 4978|       |    /*
 4979|       |     * Setup appropriate structures (by strip or by tile)
 4980|       |     * We do that only after the above OJPEG hack which alters SamplesPerPixel
 4981|       |     * and thus influences the number of strips in the separate planarconfig.
 4982|       |     */
 4983|  2.91k|    if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
  ------------------
  |  |  248|  2.91k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  2.91k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  2.91k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4983:9): [True: 2.23k, False: 680]
  ------------------
 4984|  2.23k|    {
 4985|  2.23k|        tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif);
 4986|  2.23k|        tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth;
 4987|  2.23k|        tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip;
 4988|  2.23k|        tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth;
 4989|  2.23k|        tif->tif_flags &= ~TIFF_ISTILED;
  ------------------
  |  |  129|  2.23k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 4990|  2.23k|    }
 4991|    680|    else
 4992|    680|    {
 4993|    680|        tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif);
 4994|    680|        tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|    680|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 4995|    680|    }
 4996|  2.91k|    if (!tif->tif_dir.td_nstrips)
  ------------------
  |  Branch (4996:9): [True: 5, False: 2.91k]
  ------------------
 4997|      5|    {
 4998|      5|        TIFFErrorExtR(tif, module, "Cannot handle zero number of %s",
 4999|      5|                      isTiled(tif) ? "tiles" : "strips");
  ------------------
  |  |  278|      5|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      5|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 4, False: 1]
  |  |  ------------------
  ------------------
 5000|      5|        goto bad;
 5001|      5|    }
 5002|  2.91k|    tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips;
 5003|  2.91k|    if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|  2.91k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5003:9): [True: 708, False: 2.20k]
  ------------------
 5004|    708|        tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel;
 5005|  2.91k|    if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS))
  ------------------
  |  |  248|  2.91k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  2.91k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  2.91k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5005:9): [True: 313, False: 2.60k]
  ------------------
 5006|    313|    {
 5007|    313|#ifdef OJPEG_SUPPORT
 5008|    313|        if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
  ------------------
  |  |  189|    313|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (5008:13): [True: 204, False: 109]
  ------------------
 5009|    204|            (isTiled(tif) == 0) && (tif->tif_dir.td_nstrips == 1))
  ------------------
  |  |  278|    204|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    204|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (5009:13): [True: 204, False: 0]
  |  Branch (5009:36): [True: 203, False: 1]
  ------------------
 5010|    203|        {
 5011|       |            /*
 5012|       |             * XXX: OJPEG hack.
 5013|       |             * If a) compression is OJPEG, b) it's not a tiled TIFF,
 5014|       |             * and c) the number of strips is 1,
 5015|       |             * then we tolerate the absence of stripoffsets tag,
 5016|       |             * because, presumably, all required data is in the
 5017|       |             * JpegInterchangeFormat stream.
 5018|       |             */
 5019|    203|            TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
  ------------------
  |  |  249|    203|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|    203|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|    203|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 5020|    203|        }
 5021|    110|        else
 5022|    110|#endif
 5023|    110|        {
 5024|    110|            MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets");
  ------------------
  |  |  278|    110|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    110|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 110]
  |  |  ------------------
  ------------------
 5025|    110|            goto bad;
 5026|    110|        }
 5027|    313|    }
 5028|       |
 5029|  2.80k|    if (tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (5029:9): [True: 0, False: 2.80k]
  ------------------
 5030|      0|        tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
  ------------------
  |  Branch (5030:9): [True: 0, False: 0]
  ------------------
 5031|      0|        tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
  ------------------
  |  Branch (5031:9): [True: 0, False: 0]
  ------------------
 5032|      0|        tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
  ------------------
  |  Branch (5032:9): [True: 0, False: 0]
  ------------------
 5033|      0|        tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
  ------------------
  |  Branch (5033:9): [True: 0, False: 0]
  ------------------
 5034|      0|        tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
  ------------------
  |  Branch (5034:9): [True: 0, False: 0]
  ------------------
 5035|      0|        tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
  ------------------
  |  Branch (5035:9): [True: 0, False: 0]
  ------------------
 5036|      0|        tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
  ------------------
  |  Branch (5036:9): [True: 0, False: 0]
  ------------------
 5037|      0|        tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0)
  ------------------
  |  Branch (5037:9): [True: 0, False: 0]
  ------------------
 5038|      0|    {
 5039|       |        /* Directory typically created with TIFFDeferStrileArrayWriting() */
 5040|      0|        TIFFSetupStrips(tif);
 5041|      0|    }
 5042|  2.80k|    else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD))
  ------------------
  |  |  147|  2.80k|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (5042:14): [True: 2.80k, False: 0]
  ------------------
 5043|  2.80k|    {
 5044|  2.80k|        if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0)
  ------------------
  |  Branch (5044:13): [True: 2.60k, False: 203]
  ------------------
 5045|  2.60k|        {
 5046|  2.60k|            if (!TIFFFetchStripThing(tif, &(tif->tif_dir.td_stripoffset_entry),
  ------------------
  |  Branch (5046:17): [True: 100, False: 2.50k]
  ------------------
 5047|  2.60k|                                     tif->tif_dir.td_nstrips,
 5048|  2.60k|                                     &tif->tif_dir.td_stripoffset_p))
 5049|    100|            {
 5050|    100|                goto bad;
 5051|    100|            }
 5052|  2.60k|        }
 5053|  2.70k|        if (tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0)
  ------------------
  |  Branch (5053:13): [True: 1.87k, False: 831]
  ------------------
 5054|  1.87k|        {
 5055|  1.87k|            if (!TIFFFetchStripThing(
  ------------------
  |  Branch (5055:17): [True: 36, False: 1.83k]
  ------------------
 5056|  1.87k|                    tif, &(tif->tif_dir.td_stripbytecount_entry),
 5057|  1.87k|                    tif->tif_dir.td_nstrips, &tif->tif_dir.td_stripbytecount_p))
 5058|     36|            {
 5059|     36|                goto bad;
 5060|     36|            }
 5061|  1.87k|        }
 5062|  2.70k|    }
 5063|       |
 5064|       |    /*
 5065|       |     * Make sure all non-color channels are extrasamples.
 5066|       |     * If it's not the case, define them as such.
 5067|       |     */
 5068|  2.66k|    color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric);
 5069|  2.66k|    if (color_channels &&
  ------------------
  |  Branch (5069:9): [True: 2.54k, False: 120]
  ------------------
 5070|  2.54k|        tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples >
  ------------------
  |  Branch (5070:9): [True: 405, False: 2.14k]
  ------------------
 5071|  2.54k|            color_channels)
 5072|    405|    {
 5073|    405|        uint16_t old_extrasamples;
 5074|    405|        uint16_t *new_sampleinfo;
 5075|       |
 5076|    405|        TIFFWarningExtR(
 5077|    405|            tif, module,
 5078|    405|            "Sum of Photometric type-related "
 5079|    405|            "color channels and ExtraSamples doesn't match SamplesPerPixel. "
 5080|    405|            "Defining non-color channels as ExtraSamples.");
 5081|       |
 5082|    405|        old_extrasamples = tif->tif_dir.td_extrasamples;
 5083|    405|        tif->tif_dir.td_extrasamples =
 5084|    405|            (uint16_t)(tif->tif_dir.td_samplesperpixel - color_channels);
 5085|       |
 5086|       |        // sampleinfo should contain information relative to these new extra
 5087|       |        // samples
 5088|    405|        new_sampleinfo = (uint16_t *)_TIFFcallocExt(
 5089|    405|            tif, tif->tif_dir.td_extrasamples, sizeof(uint16_t));
 5090|    405|        if (!new_sampleinfo)
  ------------------
  |  Branch (5090:13): [True: 0, False: 405]
  ------------------
 5091|      0|        {
 5092|      0|            TIFFErrorExtR(tif, module,
 5093|      0|                          "Failed to allocate memory for "
 5094|      0|                          "temporary new sampleinfo array "
 5095|      0|                          "(%" PRIu16 " 16 bit elements)",
 5096|      0|                          tif->tif_dir.td_extrasamples);
 5097|      0|            goto bad;
 5098|      0|        }
 5099|       |
 5100|    405|        if (old_extrasamples > 0)
  ------------------
  |  Branch (5100:13): [True: 108, False: 297]
  ------------------
 5101|    108|            memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo,
 5102|    108|                   old_extrasamples * sizeof(uint16_t));
 5103|    405|        _TIFFsetShortArrayExt(tif, &tif->tif_dir.td_sampleinfo, new_sampleinfo,
 5104|    405|                              tif->tif_dir.td_extrasamples);
 5105|    405|        _TIFFfreeExt(tif, new_sampleinfo);
 5106|    405|    }
 5107|       |
 5108|       |    /*
 5109|       |     * Verify Palette image has a Colormap.
 5110|       |     */
 5111|  2.66k|    if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE &&
  ------------------
  |  |  224|  5.33k|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (5111:9): [True: 228, False: 2.44k]
  ------------------
 5112|    228|        !TIFFFieldSet(tif, FIELD_COLORMAP))
  ------------------
  |  |  248|    228|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    228|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    228|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5112:9): [True: 199, False: 29]
  ------------------
 5113|    199|    {
 5114|    199|        if (tif->tif_dir.td_bitspersample >= 8 &&
  ------------------
  |  Branch (5114:13): [True: 197, False: 2]
  ------------------
 5115|    197|            tif->tif_dir.td_samplesperpixel == 3)
  ------------------
  |  Branch (5115:13): [True: 10, False: 187]
  ------------------
 5116|     10|            tif->tif_dir.td_photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|     10|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
 5117|    189|        else if (tif->tif_dir.td_bitspersample >= 8)
  ------------------
  |  Branch (5117:18): [True: 187, False: 2]
  ------------------
 5118|    187|            tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|    187|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
 5119|      2|        else
 5120|      2|        {
 5121|      2|            MissingRequired(tif, "Colormap");
 5122|      2|            goto bad;
 5123|      2|        }
 5124|    199|    }
 5125|       |    /*
 5126|       |     * OJPEG hack:
 5127|       |     * We do no further messing with strip/tile offsets/bytecounts in OJPEG
 5128|       |     * TIFFs
 5129|       |     */
 5130|  2.66k|    if (tif->tif_dir.td_compression != COMPRESSION_OJPEG)
  ------------------
  |  |  189|  2.66k|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (5130:9): [True: 1.27k, False: 1.38k]
  ------------------
 5131|  1.27k|    {
 5132|       |        /*
 5133|       |         * Attempt to deal with a missing StripByteCounts tag.
 5134|       |         */
 5135|  1.27k|        if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS))
  ------------------
  |  |  248|  1.27k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.27k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.27k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5135:13): [True: 433, False: 845]
  ------------------
 5136|    433|        {
 5137|       |            /*
 5138|       |             * Some manufacturers violate the spec by not giving
 5139|       |             * the size of the strips.  In this case, assume there
 5140|       |             * is one uncompressed strip of data.
 5141|       |             */
 5142|    433|            if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|    866|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5142:18): [True: 418, False: 15]
  ------------------
 5143|    418|                 tif->tif_dir.td_nstrips > 1) ||
  ------------------
  |  Branch (5143:18): [True: 0, False: 418]
  ------------------
 5144|    433|                (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE &&
  ------------------
  |  |  266|    866|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5144:18): [True: 15, False: 418]
  ------------------
 5145|     15|                 tif->tif_dir.td_nstrips !=
  ------------------
  |  Branch (5145:18): [True: 0, False: 15]
  ------------------
 5146|     15|                     (uint32_t)tif->tif_dir.td_samplesperpixel))
 5147|      0|            {
 5148|      0|                MissingRequired(tif, "StripByteCounts");
 5149|      0|                goto bad;
 5150|      0|            }
 5151|    433|            TIFFWarningExtR(
 5152|    433|                tif, module,
 5153|    433|                "TIFF directory is missing required "
 5154|    433|                "\"StripByteCounts\" field, calculating from imagelength");
 5155|    433|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5155:17): [True: 26, False: 407]
  ------------------
 5156|     26|                goto bad;
 5157|    433|        }
 5158|    845|        else if (tif->tif_dir.td_nstrips == 1 &&
  ------------------
  |  Branch (5158:18): [True: 438, False: 407]
  ------------------
 5159|    438|                 !(tif->tif_flags & TIFF_ISTILED) && ByteCountLooksBad(tif))
  ------------------
  |  |  129|    438|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  |  Branch (5159:18): [True: 421, False: 17]
  |  Branch (5159:54): [True: 58, False: 363]
  ------------------
 5160|     58|        {
 5161|       |            /*
 5162|       |             * XXX: Plexus (and others) sometimes give a value of
 5163|       |             * zero for a tag when they don't know what the
 5164|       |             * correct value is!  Try and handle the simple case
 5165|       |             * of estimating the size of a one strip image.
 5166|       |             */
 5167|     58|            TIFFWarningExtR(tif, module,
 5168|     58|                            "Bogus \"StripByteCounts\" field, ignoring and "
 5169|     58|                            "calculating from imagelength");
 5170|     58|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5170:17): [True: 9, False: 49]
  ------------------
 5171|      9|                goto bad;
 5172|     58|        }
 5173|    787|        else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
  ------------------
  |  |  147|    787|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (5173:18): [True: 787, False: 0]
  ------------------
 5174|    787|                 tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|  1.57k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5174:18): [True: 633, False: 154]
  ------------------
 5175|    633|                 tif->tif_dir.td_nstrips > 2 &&
  ------------------
  |  Branch (5175:18): [True: 192, False: 441]
  ------------------
 5176|    192|                 tif->tif_dir.td_compression == COMPRESSION_NONE &&
  ------------------
  |  |  182|    979|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5176:18): [True: 42, False: 150]
  ------------------
 5177|     42|                 TIFFGetStrileByteCount(tif, 0) !=
  ------------------
  |  Branch (5177:18): [True: 39, False: 3]
  ------------------
 5178|     42|                     TIFFGetStrileByteCount(tif, 1) &&
 5179|     39|                 TIFFGetStrileByteCount(tif, 0) != 0 &&
  ------------------
  |  Branch (5179:18): [True: 39, False: 0]
  ------------------
 5180|     39|                 TIFFGetStrileByteCount(tif, 1) != 0)
  ------------------
  |  Branch (5180:18): [True: 1, False: 38]
  ------------------
 5181|      1|        {
 5182|       |            /*
 5183|       |             * XXX: Some vendors fill StripByteCount array with
 5184|       |             * absolutely wrong values (it can be equal to
 5185|       |             * StripOffset array, for example). Catch this case
 5186|       |             * here.
 5187|       |             *
 5188|       |             * We avoid this check if deferring strile loading
 5189|       |             * as it would always force us to load the strip/tile
 5190|       |             * information.
 5191|       |             */
 5192|      1|            TIFFWarningExtR(tif, module,
 5193|      1|                            "Wrong \"StripByteCounts\" field, ignoring and "
 5194|      1|                            "calculating from imagelength");
 5195|      1|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5195:17): [True: 0, False: 1]
  ------------------
 5196|      0|                goto bad;
 5197|      1|        }
 5198|  1.27k|    }
 5199|  2.63k|    if (dir)
  ------------------
  |  Branch (5199:9): [True: 2.63k, False: 0]
  ------------------
 5200|  2.63k|    {
 5201|  2.63k|        _TIFFfreeExt(tif, dir);
 5202|  2.63k|        dir = NULL;
 5203|  2.63k|    }
 5204|  2.63k|    if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE))
  ------------------
  |  |  248|  2.63k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  2.63k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  2.63k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5204:9): [True: 2.52k, False: 110]
  ------------------
 5205|  2.52k|    {
 5206|  2.52k|        if (tif->tif_dir.td_bitspersample >= 16)
  ------------------
  |  Branch (5206:13): [True: 656, False: 1.86k]
  ------------------
 5207|    656|            tif->tif_dir.td_maxsamplevalue = 0xFFFF;
 5208|  1.86k|        else
 5209|  1.86k|            tif->tif_dir.td_maxsamplevalue =
 5210|  1.86k|                (uint16_t)((1 << tif->tif_dir.td_bitspersample) - 1);
 5211|  2.52k|    }
 5212|       |
 5213|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 5214|       |    /*
 5215|       |     * XXX: We can optimize checking for the strip bounds using the sorted
 5216|       |     * bytecounts array. See also comments for TIFFAppendToStrip()
 5217|       |     * function in tif_write.c.
 5218|       |     */
 5219|       |    if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1)
 5220|       |    {
 5221|       |        uint32_t strip;
 5222|       |
 5223|       |        tif->tif_dir.td_stripbytecountsorted = 1;
 5224|       |        for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++)
 5225|       |        {
 5226|       |            if (TIFFGetStrileOffset(tif, strip - 1) >
 5227|       |                TIFFGetStrileOffset(tif, strip))
 5228|       |            {
 5229|       |                tif->tif_dir.td_stripbytecountsorted = 0;
 5230|       |                break;
 5231|       |            }
 5232|       |        }
 5233|       |    }
 5234|       |#endif
 5235|       |
 5236|       |    /*
 5237|       |     * An opportunity for compression mode dependent tag fixup
 5238|       |     */
 5239|  2.63k|    (*tif->tif_fixuptags)(tif);
 5240|       |
 5241|       |    /*
 5242|       |     * Some manufacturers make life difficult by writing
 5243|       |     * large amounts of uncompressed data as a single strip.
 5244|       |     * This is contrary to the recommendations of the spec.
 5245|       |     * The following makes an attempt at breaking such images
 5246|       |     * into strips closer to the recommended 8k bytes.  A
 5247|       |     * side effect, however, is that the RowsPerStrip tag
 5248|       |     * value may be changed.
 5249|       |     */
 5250|  2.63k|    if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|  2.63k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5250:9): [True: 1.94k, False: 685]
  ------------------
 5251|  1.94k|        (tif->tif_dir.td_nstrips == 1) &&
  ------------------
  |  Branch (5251:9): [True: 1.41k, False: 528]
  ------------------
 5252|  1.41k|        (tif->tif_dir.td_compression == COMPRESSION_NONE) &&
  ------------------
  |  |  182|  1.41k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5252:9): [True: 111, False: 1.30k]
  ------------------
 5253|    111|        ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  134|    111|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
                      ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  129|    111|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
                      ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  134|    111|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  |  Branch (5253:9): [True: 107, False: 4]
  ------------------
 5254|    107|    {
 5255|    107|        ChopUpSingleUncompressedStrip(tif);
 5256|    107|    }
 5257|       |
 5258|       |    /* There are also uncompressed striped files with strips larger than */
 5259|       |    /* 2 GB, which make them unfriendly with a lot of code. If possible, */
 5260|       |    /* try to expose smaller "virtual" strips. */
 5261|  2.63k|    if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|  5.26k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5261:9): [True: 1.94k, False: 685]
  ------------------
 5262|  1.94k|        tif->tif_dir.td_compression == COMPRESSION_NONE &&
  ------------------
  |  |  182|  4.57k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5262:9): [True: 158, False: 1.78k]
  ------------------
 5263|    158|        (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  134|    158|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
                      (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  129|    158|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
                      (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  134|  2.78k|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  |  Branch (5263:9): [True: 120, False: 38]
  ------------------
 5264|    120|        TIFFStripSize64(tif) > 0x7FFFFFFFUL)
  ------------------
  |  Branch (5264:9): [True: 27, False: 93]
  ------------------
 5265|     27|    {
 5266|     27|        TryChopUpUncompressedBigTiff(tif);
 5267|     27|    }
 5268|       |
 5269|       |    /*
 5270|       |     * Clear the dirty directory flag.
 5271|       |     */
 5272|  2.63k|    tif->tif_flags &= ~TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|  2.63k|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 5273|  2.63k|    tif->tif_flags &= ~TIFF_DIRTYSTRIP;
  ------------------
  |  |  142|  2.63k|#define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/
  ------------------
 5274|       |
 5275|       |    /*
 5276|       |     * Reinitialize some further i/o since we are starting on a new directory.
 5277|       |     */
 5278|  2.63k|    tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 5279|  2.63k|    if (!tif->tif_dir.td_scanlinesize)
  ------------------
  |  Branch (5279:9): [True: 16, False: 2.61k]
  ------------------
 5280|     16|    {
 5281|     16|        TIFFErrorExtR(tif, module, "Cannot handle zero scanline size");
 5282|     16|        return (0);
 5283|     16|    }
 5284|       |
 5285|  2.61k|    if (isTiled(tif))
  ------------------
  |  |  278|  2.61k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  2.61k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 661, False: 1.95k]
  |  |  ------------------
  ------------------
 5286|    661|    {
 5287|    661|        tif->tif_dir.td_tilesize = TIFFTileSize(tif);
 5288|    661|        if (!tif->tif_dir.td_tilesize)
  ------------------
  |  Branch (5288:13): [True: 0, False: 661]
  ------------------
 5289|      0|        {
 5290|      0|            TIFFErrorExtR(tif, module, "Cannot handle zero tile size");
 5291|      0|            return (0);
 5292|      0|        }
 5293|    661|    }
 5294|  1.95k|    else
 5295|  1.95k|    {
 5296|  1.95k|        if (!TIFFStripSize(tif))
  ------------------
  |  Branch (5296:13): [True: 2, False: 1.95k]
  ------------------
 5297|      2|        {
 5298|      2|            TIFFErrorExtR(tif, module, "Cannot handle zero strip size");
 5299|      2|            return (0);
 5300|      2|        }
 5301|  1.95k|    }
 5302|  2.61k|    return (1);
 5303|    371|bad:
 5304|    371|    if (dir)
  ------------------
  |  Branch (5304:9): [True: 371, False: 0]
  ------------------
 5305|    371|        _TIFFfreeExt(tif, dir);
 5306|    371|    return (0);
 5307|  2.61k|} /*-- TIFFReadDirectory() --*/
_TIFFCheckDirNumberAndOffset:
 5773|  3.82k|{
 5774|  3.82k|    if (diroff == 0) /* no more directories */
  ------------------
  |  Branch (5774:9): [True: 0, False: 3.82k]
  ------------------
 5775|      0|        return 0;
 5776|       |
 5777|  3.82k|    if (tif->tif_map_dir_offset_to_number == NULL)
  ------------------
  |  Branch (5777:9): [True: 1.27k, False: 2.55k]
  ------------------
 5778|  1.27k|    {
 5779|  1.27k|        tif->tif_map_dir_offset_to_number = TIFFHashSetNew(
 5780|  1.27k|            hashFuncOffsetToNumber, equalFuncOffsetToNumber, free);
 5781|  1.27k|        if (tif->tif_map_dir_offset_to_number == NULL)
  ------------------
  |  Branch (5781:13): [True: 0, False: 1.27k]
  ------------------
 5782|      0|        {
 5783|      0|            TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5784|      0|                          "Not enough memory");
 5785|      0|            return 1;
 5786|      0|        }
 5787|  1.27k|    }
 5788|       |
 5789|  3.82k|    if (tif->tif_map_dir_number_to_offset == NULL)
  ------------------
  |  Branch (5789:9): [True: 1.27k, False: 2.55k]
  ------------------
 5790|  1.27k|    {
 5791|       |        /* No free callback for this map, as it shares the same items as
 5792|       |         * tif->tif_map_dir_offset_to_number. */
 5793|  1.27k|        tif->tif_map_dir_number_to_offset = TIFFHashSetNew(
 5794|  1.27k|            hashFuncNumberToOffset, equalFuncNumberToOffset, NULL);
 5795|  1.27k|        if (tif->tif_map_dir_number_to_offset == NULL)
  ------------------
  |  Branch (5795:13): [True: 0, False: 1.27k]
  ------------------
 5796|      0|        {
 5797|      0|            TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5798|      0|                          "Not enough memory");
 5799|      0|            return 1;
 5800|      0|        }
 5801|  1.27k|    }
 5802|       |
 5803|       |    /* Check if offset is already in the list:
 5804|       |     * - yes: check, if offset is at the same IFD number - if not, it is an IFD
 5805|       |     * loop
 5806|       |     * -  no: add to list or update offset at that IFD number
 5807|       |     */
 5808|  3.82k|    TIFFOffsetAndDirNumber entry;
 5809|  3.82k|    entry.offset = diroff;
 5810|  3.82k|    entry.dirNumber = dirn;
 5811|       |
 5812|  3.82k|    TIFFOffsetAndDirNumber *foundEntry =
 5813|  3.82k|        (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5814|  3.82k|            tif->tif_map_dir_offset_to_number, &entry);
 5815|  3.82k|    if (foundEntry)
  ------------------
  |  Branch (5815:9): [True: 2, False: 3.82k]
  ------------------
 5816|      2|    {
 5817|      2|        if (foundEntry->dirNumber == dirn)
  ------------------
  |  Branch (5817:13): [True: 0, False: 2]
  ------------------
 5818|      0|        {
 5819|      0|            return 1;
 5820|      0|        }
 5821|      2|        else
 5822|      2|        {
 5823|      2|            TIFFWarningExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5824|      2|                            "TIFF directory %d has IFD looping to directory %u "
 5825|      2|                            "at offset 0x%" PRIx64 " (%" PRIu64 ")",
 5826|      2|                            (int)dirn - 1, foundEntry->dirNumber, diroff,
 5827|      2|                            diroff);
 5828|      2|            return 0;
 5829|      2|        }
 5830|      2|    }
 5831|       |
 5832|       |    /* Check if offset of an IFD has been changed and update offset of that IFD
 5833|       |     * number. */
 5834|  3.82k|    foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5835|  3.82k|        tif->tif_map_dir_number_to_offset, &entry);
 5836|  3.82k|    if (foundEntry)
  ------------------
  |  Branch (5836:9): [True: 0, False: 3.82k]
  ------------------
 5837|      0|    {
 5838|      0|        if (foundEntry->offset != diroff)
  ------------------
  |  Branch (5838:13): [True: 0, False: 0]
  ------------------
 5839|      0|        {
 5840|      0|            TIFFOffsetAndDirNumber entryOld;
 5841|      0|            entryOld.offset = foundEntry->offset;
 5842|      0|            entryOld.dirNumber = dirn;
 5843|       |            /* We must remove first from tif_map_dir_number_to_offset as the */
 5844|       |            /* entry is owned (and thus freed) by */
 5845|       |            /* tif_map_dir_offset_to_number */
 5846|      0|            TIFFOffsetAndDirNumber *foundEntryOld =
 5847|      0|                (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5848|      0|                    tif->tif_map_dir_number_to_offset, &entryOld);
 5849|      0|            if (foundEntryOld)
  ------------------
  |  Branch (5849:17): [True: 0, False: 0]
  ------------------
 5850|      0|            {
 5851|      0|                TIFFHashSetRemove(tif->tif_map_dir_number_to_offset,
 5852|      0|                                  foundEntryOld);
 5853|      0|            }
 5854|      0|            foundEntryOld = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5855|      0|                tif->tif_map_dir_offset_to_number, &entryOld);
 5856|      0|            if (foundEntryOld)
  ------------------
  |  Branch (5856:17): [True: 0, False: 0]
  ------------------
 5857|      0|            {
 5858|      0|                TIFFHashSetRemove(tif->tif_map_dir_offset_to_number,
 5859|      0|                                  foundEntryOld);
 5860|      0|            }
 5861|       |
 5862|      0|            TIFFOffsetAndDirNumber *entryPtr = (TIFFOffsetAndDirNumber *)malloc(
 5863|      0|                sizeof(TIFFOffsetAndDirNumber));
 5864|      0|            if (entryPtr == NULL)
  ------------------
  |  Branch (5864:17): [True: 0, False: 0]
  ------------------
 5865|      0|            {
 5866|      0|                return 0;
 5867|      0|            }
 5868|       |
 5869|       |            /* Add IFD offset and dirn to IFD directory list */
 5870|      0|            *entryPtr = entry;
 5871|       |
 5872|      0|            if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr))
  ------------------
  |  Branch (5872:17): [True: 0, False: 0]
  ------------------
 5873|      0|            {
 5874|      0|                TIFFErrorExtR(
 5875|      0|                    tif, "_TIFFCheckDirNumberAndOffset",
 5876|      0|                    "Insertion in tif_map_dir_offset_to_number failed");
 5877|      0|                return 0;
 5878|      0|            }
 5879|      0|            if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr))
  ------------------
  |  Branch (5879:17): [True: 0, False: 0]
  ------------------
 5880|      0|            {
 5881|      0|                TIFFErrorExtR(
 5882|      0|                    tif, "_TIFFCheckDirNumberAndOffset",
 5883|      0|                    "Insertion in tif_map_dir_number_to_offset failed");
 5884|      0|                return 0;
 5885|      0|            }
 5886|      0|        }
 5887|      0|        return 1;
 5888|      0|    }
 5889|       |
 5890|       |    /* Arbitrary (hopefully big enough) limit */
 5891|  3.82k|    if (TIFFHashSetSize(tif->tif_map_dir_offset_to_number) >=
  ------------------
  |  Branch (5891:9): [True: 0, False: 3.82k]
  ------------------
 5892|  3.82k|        TIFF_MAX_DIR_COUNT)
  ------------------
  |  |  122|  3.82k|#define TIFF_MAX_DIR_COUNT 1048576
  ------------------
 5893|      0|    {
 5894|      0|        TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5895|      0|                      "Cannot handle more than %u TIFF directories",
 5896|      0|                      (unsigned)TIFF_MAX_DIR_COUNT);
  ------------------
  |  |  122|      0|#define TIFF_MAX_DIR_COUNT 1048576
  ------------------
 5897|      0|        return 0;
 5898|      0|    }
 5899|       |
 5900|  3.82k|    TIFFOffsetAndDirNumber *entryPtr =
 5901|  3.82k|        (TIFFOffsetAndDirNumber *)malloc(sizeof(TIFFOffsetAndDirNumber));
 5902|  3.82k|    if (entryPtr == NULL)
  ------------------
  |  Branch (5902:9): [True: 0, False: 3.82k]
  ------------------
 5903|      0|    {
 5904|      0|        TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5905|      0|                      "malloc(sizeof(TIFFOffsetAndDirNumber)) failed");
 5906|      0|        return 0;
 5907|      0|    }
 5908|       |
 5909|       |    /* Add IFD offset and dirn to IFD directory list */
 5910|  3.82k|    *entryPtr = entry;
 5911|       |
 5912|  3.82k|    if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr))
  ------------------
  |  Branch (5912:9): [True: 0, False: 3.82k]
  ------------------
 5913|      0|    {
 5914|      0|        TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5915|      0|                      "Insertion in tif_map_dir_offset_to_number failed");
 5916|      0|        return 0;
 5917|      0|    }
 5918|  3.82k|    if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr))
  ------------------
  |  Branch (5918:9): [True: 0, False: 3.82k]
  ------------------
 5919|      0|    {
 5920|      0|        TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5921|      0|                      "Insertion in tif_map_dir_number_to_offset failed");
 5922|      0|        return 0;
 5923|      0|    }
 5924|       |
 5925|  3.82k|    return 1;
 5926|  3.82k|} /* --- _TIFFCheckDirNumberAndOffset() ---*/
TIFFGetStrileOffset:
 8522|  53.3k|{
 8523|       |    return TIFFGetStrileOffsetWithErr(tif, strile, NULL);
 8524|  53.3k|}
TIFFGetStrileOffsetWithErr:
 8529|  41.8M|{
 8530|  41.8M|    TIFFDirectory *td = &tif->tif_dir;
 8531|  41.8M|    return _TIFFGetStrileOffsetOrByteCountValue(tif, strile,
 8532|  41.8M|                                                &(td->td_stripoffset_entry),
 8533|  41.8M|                                                &(td->td_stripoffset_p), pbErr);
 8534|  41.8M|}
TIFFGetStrileByteCount:
 8539|   193k|{
 8540|       |    return TIFFGetStrileByteCountWithErr(tif, strile, NULL);
 8541|   193k|}
TIFFGetStrileByteCountWithErr:
 8546|  1.45M|{
 8547|  1.45M|    TIFFDirectory *td = &tif->tif_dir;
 8548|  1.45M|    return _TIFFGetStrileOffsetOrByteCountValue(
 8549|  1.45M|        tif, strile, &(td->td_stripbytecount_entry), &(td->td_stripbytecount_p),
 8550|  1.45M|        pbErr);
 8551|  1.45M|}
_TIFFFillStriles:
 8553|    625|int _TIFFFillStriles(TIFF *tif) { return _TIFFFillStrilesInternal(tif, 1); }
tif_dirread.c:TIFFReadDirEntryShort:
  486|  14.8k|{
  487|  14.8k|    enum TIFFReadDirEntryErr err;
  488|  14.8k|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (488:9): [True: 3.08k, False: 11.7k]
  ------------------
  489|  3.08k|        return (TIFFReadDirEntryErrCount);
  490|  11.7k|    switch (direntry->tdir_type)
  491|  11.7k|    {
  492|     17|        case TIFF_BYTE:
  ------------------
  |  Branch (492:9): [True: 17, False: 11.7k]
  ------------------
  493|     17|        {
  494|     17|            uint8_t m;
  495|     17|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  496|     17|            *value = (uint16_t)m;
  497|     17|            return (TIFFReadDirEntryErrOk);
  498|      0|        }
  499|      9|        case TIFF_SBYTE:
  ------------------
  |  Branch (499:9): [True: 9, False: 11.7k]
  ------------------
  500|      9|        {
  501|      9|            int8_t m;
  502|      9|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  503|      9|            err = TIFFReadDirEntryCheckRangeShortSbyte(m);
  504|      9|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (504:17): [True: 4, False: 5]
  ------------------
  505|      4|                return (err);
  506|      5|            *value = (uint16_t)m;
  507|      5|            return (TIFFReadDirEntryErrOk);
  508|      9|        }
  509|  10.8k|        case TIFF_SHORT:
  ------------------
  |  Branch (509:9): [True: 10.8k, False: 946]
  ------------------
  510|  10.8k|            TIFFReadDirEntryCheckedShort(tif, direntry, value);
  511|  10.8k|            return (TIFFReadDirEntryErrOk);
  512|      3|        case TIFF_SSHORT:
  ------------------
  |  Branch (512:9): [True: 3, False: 11.7k]
  ------------------
  513|      3|        {
  514|      3|            int16_t m;
  515|      3|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  516|      3|            err = TIFFReadDirEntryCheckRangeShortSshort(m);
  517|      3|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (517:17): [True: 0, False: 3]
  ------------------
  518|      0|                return (err);
  519|      3|            *value = (uint16_t)m;
  520|      3|            return (TIFFReadDirEntryErrOk);
  521|      3|        }
  522|    606|        case TIFF_LONG:
  ------------------
  |  Branch (522:9): [True: 606, False: 11.1k]
  ------------------
  523|    606|        {
  524|    606|            uint32_t m;
  525|    606|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  526|    606|            err = TIFFReadDirEntryCheckRangeShortLong(m);
  527|    606|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (527:17): [True: 163, False: 443]
  ------------------
  528|    163|                return (err);
  529|    443|            *value = (uint16_t)m;
  530|    443|            return (TIFFReadDirEntryErrOk);
  531|    606|        }
  532|     32|        case TIFF_SLONG:
  ------------------
  |  Branch (532:9): [True: 32, False: 11.7k]
  ------------------
  533|     32|        {
  534|     32|            int32_t m;
  535|     32|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  536|     32|            err = TIFFReadDirEntryCheckRangeShortSlong(m);
  537|     32|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (537:17): [True: 12, False: 20]
  ------------------
  538|     12|                return (err);
  539|     20|            *value = (uint16_t)m;
  540|     20|            return (TIFFReadDirEntryErrOk);
  541|     32|        }
  542|     13|        case TIFF_LONG8:
  ------------------
  |  Branch (542:9): [True: 13, False: 11.7k]
  ------------------
  543|     13|        {
  544|     13|            uint64_t m;
  545|     13|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  546|     13|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (546:17): [True: 0, False: 13]
  ------------------
  547|      0|                return (err);
  548|     13|            err = TIFFReadDirEntryCheckRangeShortLong8(m);
  549|     13|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (549:17): [True: 9, False: 4]
  ------------------
  550|      9|                return (err);
  551|      4|            *value = (uint16_t)m;
  552|      4|            return (TIFFReadDirEntryErrOk);
  553|     13|        }
  554|     12|        case TIFF_SLONG8:
  ------------------
  |  Branch (554:9): [True: 12, False: 11.7k]
  ------------------
  555|     12|        {
  556|     12|            int64_t m;
  557|     12|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  558|     12|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (558:17): [True: 0, False: 12]
  ------------------
  559|      0|                return (err);
  560|     12|            err = TIFFReadDirEntryCheckRangeShortSlong8(m);
  561|     12|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (561:17): [True: 8, False: 4]
  ------------------
  562|      8|                return (err);
  563|      4|            *value = (uint16_t)m;
  564|      4|            return (TIFFReadDirEntryErrOk);
  565|     12|        }
  566|    254|        default:
  ------------------
  |  Branch (566:9): [True: 254, False: 11.5k]
  ------------------
  567|    254|            return (TIFFReadDirEntryErrType);
  568|  11.7k|    }
  569|  11.7k|} /*-- TIFFReadDirEntryShort() --*/
tif_dirread.c:TIFFReadDirEntryCheckedByte:
 3406|    180|{
 3407|    180|    (void)tif;
 3408|    180|    *value = *(uint8_t *)(&direntry->tdir_offset);
 3409|    180|}
tif_dirread.c:TIFFReadDirEntryCheckedSbyte:
 3413|    231|{
 3414|    231|    (void)tif;
 3415|    231|    *value = *(int8_t *)(&direntry->tdir_offset);
 3416|    231|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSbyte:
 3772|     84|{
 3773|     84|    if (value < 0)
  ------------------
  |  Branch (3773:9): [True: 11, False: 73]
  ------------------
 3774|     11|        return (TIFFReadDirEntryErrRange);
 3775|     73|    else
 3776|     73|        return (TIFFReadDirEntryErrOk);
 3777|     84|}
tif_dirread.c:TIFFReadDirEntryCheckedShort:
 3420|  19.0k|{
 3421|  19.0k|    *value = direntry->tdir_offset.toff_short;
 3422|       |    /* *value=*(uint16_t*)(&direntry->tdir_offset); */
 3423|  19.0k|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  19.0k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3423:9): [True: 0, False: 19.0k]
  ------------------
 3424|      0|        TIFFSwabShort(value);
 3425|  19.0k|}
tif_dirread.c:TIFFReadDirEntryCheckedSshort:
 3429|     71|{
 3430|     71|    *value = *(int16_t *)(&direntry->tdir_offset);
 3431|     71|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     71|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3431:9): [True: 0, False: 71]
  ------------------
 3432|      0|        TIFFSwabShort((uint16_t *)value);
 3433|     71|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSshort:
 3781|     14|{
 3782|     14|    if (value < 0)
  ------------------
  |  Branch (3782:9): [True: 4, False: 10]
  ------------------
 3783|      4|        return (TIFFReadDirEntryErrRange);
 3784|     10|    else
 3785|     10|        return (TIFFReadDirEntryErrOk);
 3786|     14|}
tif_dirread.c:TIFFReadDirEntryCheckedLong:
 3437|  1.18k|{
 3438|  1.18k|    *value = *(uint32_t *)(&direntry->tdir_offset);
 3439|  1.18k|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.18k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3439:9): [True: 0, False: 1.18k]
  ------------------
 3440|      0|        TIFFSwabLong(value);
 3441|  1.18k|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortLong:
 3790|    639|{
 3791|    639|    if (value > 0xFFFF)
  ------------------
  |  Branch (3791:9): [True: 171, False: 468]
  ------------------
 3792|    171|        return (TIFFReadDirEntryErrRange);
 3793|    468|    else
 3794|    468|        return (TIFFReadDirEntryErrOk);
 3795|    639|}
tif_dirread.c:TIFFReadDirEntryCheckedSlong:
 3445|    117|{
 3446|    117|    *value = *(int32_t *)(&direntry->tdir_offset);
 3447|    117|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    117|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3447:9): [True: 0, False: 117]
  ------------------
 3448|      0|        TIFFSwabLong((uint32_t *)value);
 3449|    117|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSlong:
 3799|     64|{
 3800|     64|    if ((value < 0) || (value > 0xFFFF))
  ------------------
  |  Branch (3800:9): [True: 4, False: 60]
  |  Branch (3800:24): [True: 16, False: 44]
  ------------------
 3801|     20|        return (TIFFReadDirEntryErrRange);
 3802|     44|    else
 3803|     44|        return (TIFFReadDirEntryErrOk);
 3804|     64|}
tif_dirread.c:TIFFReadDirEntryCheckedLong8:
 3453|    131|{
 3454|    131|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    131|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3454:9): [True: 131, False: 0]
  ------------------
 3455|    131|    {
 3456|    131|        enum TIFFReadDirEntryErr err;
 3457|    131|        uint32_t offset = direntry->tdir_offset.toff_long;
 3458|    131|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    131|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3458:13): [True: 0, False: 131]
  ------------------
 3459|      0|            TIFFSwabLong(&offset);
 3460|    131|        err = TIFFReadDirEntryData(tif, offset, 8, value);
 3461|    131|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3461:13): [True: 0, False: 131]
  ------------------
 3462|      0|            return (err);
 3463|    131|    }
 3464|      0|    else
 3465|      0|        *value = direntry->tdir_offset.toff_long8;
 3466|    131|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    131|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3466:9): [True: 0, False: 131]
  ------------------
 3467|      0|        TIFFSwabLong8(value);
 3468|    131|    return (TIFFReadDirEntryErrOk);
 3469|    131|}
tif_dirread.c:TIFFReadDirEntryData:
 3990|  1.76k|{
 3991|  1.76k|    assert(size > 0);
  ------------------
  |  Branch (3991:5): [True: 0, False: 1.76k]
  |  Branch (3991:5): [True: 1.76k, False: 0]
  ------------------
 3992|  1.76k|    if (!isMapped(tif))
  ------------------
  |  |  279|  1.76k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  1.76k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (3992:9): [True: 1.76k, False: 0]
  ------------------
 3993|  1.76k|    {
 3994|  1.76k|        if (!SeekOK(tif, offset))
  ------------------
  |  |  303|  1.76k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (3994:13): [True: 15, False: 1.74k]
  ------------------
 3995|     15|            return (TIFFReadDirEntryErrIo);
 3996|  1.74k|        if (!ReadOK(tif, dest, size))
  ------------------
  |  |  300|  1.74k|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|  1.74k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (3996:13): [True: 0, False: 1.74k]
  ------------------
 3997|      0|            return (TIFFReadDirEntryErrIo);
 3998|  1.74k|    }
 3999|      0|    else
 4000|      0|    {
 4001|      0|        size_t ma, mb;
 4002|      0|        ma = (size_t)offset;
 4003|      0|        if ((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size)
  ------------------
  |  Branch (4003:13): [True: 0, False: 0]
  |  Branch (4003:39): [True: 0, False: 0]
  ------------------
 4004|      0|        {
 4005|      0|            return TIFFReadDirEntryErrIo;
 4006|      0|        }
 4007|      0|        mb = (uint64_t)ma + (uint64_t)size;
 4008|      0|        if (mb > (uint64_t)tif->tif_size)
  ------------------
  |  Branch (4008:13): [True: 0, False: 0]
  ------------------
 4009|      0|            return (TIFFReadDirEntryErrIo);
 4010|      0|        _TIFFmemcpy(dest, tif->tif_base + ma, size);
 4011|      0|    }
 4012|  1.74k|    return (TIFFReadDirEntryErrOk);
 4013|  1.76k|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortLong8:
 3808|     24|{
 3809|     24|    if (value > 0xFFFF)
  ------------------
  |  Branch (3809:9): [True: 13, False: 11]
  ------------------
 3810|     13|        return (TIFFReadDirEntryErrRange);
 3811|     11|    else
 3812|     11|        return (TIFFReadDirEntryErrOk);
 3813|     24|}
tif_dirread.c:TIFFReadDirEntryCheckedSlong8:
 3473|     54|{
 3474|     54|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|     54|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3474:9): [True: 54, False: 0]
  ------------------
 3475|     54|    {
 3476|     54|        enum TIFFReadDirEntryErr err;
 3477|     54|        uint32_t offset = direntry->tdir_offset.toff_long;
 3478|     54|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     54|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3478:13): [True: 0, False: 54]
  ------------------
 3479|      0|            TIFFSwabLong(&offset);
 3480|     54|        err = TIFFReadDirEntryData(tif, offset, 8, value);
 3481|     54|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3481:13): [True: 0, False: 54]
  ------------------
 3482|      0|            return (err);
 3483|     54|    }
 3484|      0|    else
 3485|      0|        *value = *(int64_t *)(&direntry->tdir_offset);
 3486|     54|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     54|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3486:9): [True: 0, False: 54]
  ------------------
 3487|      0|        TIFFSwabLong8((uint64_t *)value);
 3488|     54|    return (TIFFReadDirEntryErrOk);
 3489|     54|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSlong8:
 3817|     20|{
 3818|     20|    if ((value < 0) || (value > 0xFFFF))
  ------------------
  |  Branch (3818:9): [True: 8, False: 12]
  |  Branch (3818:24): [True: 8, False: 4]
  ------------------
 3819|     16|        return (TIFFReadDirEntryErrRange);
 3820|      4|    else
 3821|      4|        return (TIFFReadDirEntryErrOk);
 3822|     20|}
tif_dirread.c:TIFFReadDirEntryPersampleShort:
 3348|     59|{
 3349|     59|    enum TIFFReadDirEntryErr err;
 3350|     59|    uint16_t *m;
 3351|     59|    uint16_t *na;
 3352|     59|    uint16_t nb;
 3353|     59|    if (direntry->tdir_count != (uint64_t)tif->tif_dir.td_samplesperpixel)
  ------------------
  |  Branch (3353:9): [True: 59, False: 0]
  ------------------
 3354|     59|    {
 3355|     59|        const TIFFField *fip = TIFFFieldWithTag(tif, direntry->tdir_tag);
 3356|     59|        if (direntry->tdir_count == 0)
  ------------------
  |  Branch (3356:13): [True: 0, False: 59]
  ------------------
 3357|      0|        {
 3358|      0|            return TIFFReadDirEntryErrCount;
 3359|      0|        }
 3360|     59|        else if (direntry->tdir_count <
  ------------------
  |  Branch (3360:18): [True: 0, False: 59]
  ------------------
 3361|     59|                 (uint64_t)tif->tif_dir.td_samplesperpixel)
 3362|      0|        {
 3363|      0|            TIFFWarningExtR(
 3364|      0|                tif, "TIFFReadDirEntryPersampleShort",
 3365|      0|                "Tag %s entry count is %" PRIu64
 3366|      0|                " , whereas it should be SamplesPerPixel=%d. Assuming that "
 3367|      0|                "missing entries are all at the value of the first one",
 3368|      0|                fip ? fip->field_name : "unknown tagname", direntry->tdir_count,
  ------------------
  |  Branch (3368:17): [True: 0, False: 0]
  ------------------
 3369|      0|                tif->tif_dir.td_samplesperpixel);
 3370|      0|        }
 3371|     59|        else
 3372|     59|        {
 3373|     59|            TIFFWarningExtR(tif, "TIFFReadDirEntryPersampleShort",
 3374|     59|                            "Tag %s entry count is %" PRIu64
 3375|     59|                            " , whereas it should be SamplesPerPixel=%d. "
 3376|     59|                            "Ignoring extra entries",
 3377|     59|                            fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (3377:29): [True: 59, False: 0]
  ------------------
 3378|     59|                            direntry->tdir_count,
 3379|     59|                            tif->tif_dir.td_samplesperpixel);
 3380|     59|        }
 3381|     59|    }
 3382|     59|    err = TIFFReadDirEntryShortArray(tif, direntry, &m);
 3383|     59|    if (err != TIFFReadDirEntryErrOk || m == NULL)
  ------------------
  |  Branch (3383:9): [True: 30, False: 29]
  |  Branch (3383:41): [True: 0, False: 29]
  ------------------
 3384|     30|        return (err);
 3385|     29|    na = m;
 3386|     29|    nb = tif->tif_dir.td_samplesperpixel;
 3387|     29|    if (direntry->tdir_count < nb)
  ------------------
  |  Branch (3387:9): [True: 0, False: 29]
  ------------------
 3388|      0|        nb = (uint16_t)direntry->tdir_count;
 3389|     29|    *value = *na++;
 3390|     29|    nb--;
 3391|     37|    while (nb > 0)
  ------------------
  |  Branch (3391:12): [True: 8, False: 29]
  ------------------
 3392|      8|    {
 3393|      8|        if (*na++ != *value)
  ------------------
  |  Branch (3393:13): [True: 0, False: 8]
  ------------------
 3394|      0|        {
 3395|      0|            err = TIFFReadDirEntryErrPsdif;
 3396|      0|            break;
 3397|      0|        }
 3398|      8|        nb--;
 3399|      8|    }
 3400|     29|    _TIFFfreeExt(tif, m);
 3401|     29|    return (err);
 3402|     59|}
tif_dirread.c:TIFFReadDirEntryOutputErr:
 4018|  18.1k|{
 4019|  18.1k|    if (!recover)
  ------------------
  |  Branch (4019:9): [True: 199, False: 17.9k]
  ------------------
 4020|    199|    {
 4021|    199|        switch (err)
 4022|    199|        {
 4023|     32|            case TIFFReadDirEntryErrCount:
  ------------------
  |  Branch (4023:13): [True: 32, False: 167]
  ------------------
 4024|     32|                TIFFErrorExtR(tif, module, "Incorrect count for \"%s\"",
 4025|     32|                              tagname);
 4026|     32|                break;
 4027|     45|            case TIFFReadDirEntryErrType:
  ------------------
  |  Branch (4027:13): [True: 45, False: 154]
  ------------------
 4028|     45|                TIFFErrorExtR(tif, module, "Incompatible type for \"%s\"",
 4029|     45|                              tagname);
 4030|     45|                break;
 4031|    106|            case TIFFReadDirEntryErrIo:
  ------------------
  |  Branch (4031:13): [True: 106, False: 93]
  ------------------
 4032|    106|                TIFFErrorExtR(tif, module, "IO error during reading of \"%s\"",
 4033|    106|                              tagname);
 4034|    106|                break;
 4035|      1|            case TIFFReadDirEntryErrRange:
  ------------------
  |  Branch (4035:13): [True: 1, False: 198]
  ------------------
 4036|      1|                TIFFErrorExtR(tif, module, "Incorrect value for \"%s\"",
 4037|      1|                              tagname);
 4038|      1|                break;
 4039|      0|            case TIFFReadDirEntryErrPsdif:
  ------------------
  |  Branch (4039:13): [True: 0, False: 199]
  ------------------
 4040|      0|                TIFFErrorExtR(
 4041|      0|                    tif, module,
 4042|      0|                    "Cannot handle different values per sample for \"%s\"",
 4043|      0|                    tagname);
 4044|      0|                break;
 4045|     15|            case TIFFReadDirEntryErrSizesan:
  ------------------
  |  Branch (4045:13): [True: 15, False: 184]
  ------------------
 4046|     15|                TIFFErrorExtR(tif, module,
 4047|     15|                              "Sanity check on size of \"%s\" value failed",
 4048|     15|                              tagname);
 4049|     15|                break;
 4050|      0|            case TIFFReadDirEntryErrAlloc:
  ------------------
  |  Branch (4050:13): [True: 0, False: 199]
  ------------------
 4051|      0|                TIFFErrorExtR(tif, module, "Out of memory reading of \"%s\"",
 4052|      0|                              tagname);
 4053|      0|                break;
 4054|      0|            case TIFFReadDirEntryErrOk:
  ------------------
  |  Branch (4054:13): [True: 0, False: 199]
  ------------------
 4055|      0|            default:
  ------------------
  |  Branch (4055:13): [True: 0, False: 199]
  ------------------
 4056|      0|                assert(0); /* we should never get here */
  ------------------
  |  Branch (4056:17): [Folded, False: 0]
  |  Branch (4056:17): [Folded, False: 0]
  ------------------
 4057|      0|                break;
 4058|    199|        }
 4059|    199|    }
 4060|  17.9k|    else
 4061|  17.9k|    {
 4062|  17.9k|        switch (err)
 4063|  17.9k|        {
 4064|  7.62k|            case TIFFReadDirEntryErrCount:
  ------------------
  |  Branch (4064:13): [True: 7.62k, False: 10.2k]
  ------------------
 4065|  7.62k|                TIFFWarningExtR(tif, module,
 4066|  7.62k|                                "Incorrect count for \"%s\"; tag ignored",
 4067|  7.62k|                                tagname);
 4068|  7.62k|                break;
 4069|  1.70k|            case TIFFReadDirEntryErrType:
  ------------------
  |  Branch (4069:13): [True: 1.70k, False: 16.1k]
  ------------------
 4070|  1.70k|                TIFFWarningExtR(tif, module,
 4071|  1.70k|                                "Incompatible type for \"%s\"; tag ignored",
 4072|  1.70k|                                tagname);
 4073|  1.70k|                break;
 4074|    379|            case TIFFReadDirEntryErrIo:
  ------------------
  |  Branch (4074:13): [True: 379, False: 17.5k]
  ------------------
 4075|    379|                TIFFWarningExtR(
 4076|    379|                    tif, module,
 4077|    379|                    "IO error during reading of \"%s\"; tag ignored", tagname);
 4078|    379|                break;
 4079|  1.00k|            case TIFFReadDirEntryErrRange:
  ------------------
  |  Branch (4079:13): [True: 1.00k, False: 16.9k]
  ------------------
 4080|  1.00k|                TIFFWarningExtR(tif, module,
 4081|  1.00k|                                "Incorrect value for \"%s\"; tag ignored",
 4082|  1.00k|                                tagname);
 4083|  1.00k|                break;
 4084|      0|            case TIFFReadDirEntryErrPsdif:
  ------------------
  |  Branch (4084:13): [True: 0, False: 17.9k]
  ------------------
 4085|      0|                TIFFWarningExtR(tif, module,
 4086|      0|                                "Cannot handle different values per sample for "
 4087|      0|                                "\"%s\"; tag ignored",
 4088|      0|                                tagname);
 4089|      0|                break;
 4090|  4.77k|            case TIFFReadDirEntryErrSizesan:
  ------------------
  |  Branch (4090:13): [True: 4.77k, False: 13.1k]
  ------------------
 4091|  4.77k|                TIFFWarningExtR(
 4092|  4.77k|                    tif, module,
 4093|  4.77k|                    "Sanity check on size of \"%s\" value failed; tag ignored",
 4094|  4.77k|                    tagname);
 4095|  4.77k|                break;
 4096|  2.42k|            case TIFFReadDirEntryErrAlloc:
  ------------------
  |  Branch (4096:13): [True: 2.42k, False: 15.4k]
  ------------------
 4097|  2.42k|                TIFFWarningExtR(tif, module,
 4098|  2.42k|                                "Out of memory reading of \"%s\"; tag ignored",
 4099|  2.42k|                                tagname);
 4100|  2.42k|                break;
 4101|      0|            case TIFFReadDirEntryErrOk:
  ------------------
  |  Branch (4101:13): [True: 0, False: 17.9k]
  ------------------
 4102|      0|            default:
  ------------------
  |  Branch (4102:13): [True: 0, False: 17.9k]
  ------------------
 4103|      0|                assert(0); /* we should never get here */
  ------------------
  |  Branch (4103:17): [Folded, False: 0]
  |  Branch (4103:17): [Folded, False: 0]
  ------------------
 4104|      0|                break;
 4105|  17.9k|        }
 4106|  17.9k|    }
 4107|  18.1k|}
tif_dirread.c:EvaluateIFDdatasizeReading:
 4186|  21.8k|{
 4187|  21.8k|    const uint64_t data_width =
 4188|  21.8k|        (uint64_t)TIFFDataWidth((TIFFDataType)dp->tdir_type);
 4189|  21.8k|    if (data_width != 0 && dp->tdir_count > UINT64_MAX / data_width)
  ------------------
  |  Branch (4189:9): [True: 21.7k, False: 52]
  |  Branch (4189:28): [True: 8, False: 21.7k]
  ------------------
 4190|      8|    {
 4191|      8|        TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
 4192|      8|                      "Too large IFD data size");
 4193|      8|        return false;
 4194|      8|    }
 4195|  21.8k|    const uint64_t datalength = dp->tdir_count * data_width;
 4196|  21.8k|    if (datalength > ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
  ------------------
  |  |  140|  21.8k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4196:9): [True: 9.69k, False: 12.1k]
  |  Branch (4196:23): [True: 355, False: 21.4k]
  ------------------
 4197|  9.69k|    {
 4198|  9.69k|        if (tif->tif_dir.td_dirdatasize_read > UINT64_MAX - datalength)
  ------------------
  |  Branch (4198:13): [True: 39, False: 9.65k]
  ------------------
 4199|     39|        {
 4200|     39|            TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
 4201|     39|                          "Too large IFD data size");
 4202|     39|            return false;
 4203|     39|        }
 4204|  9.65k|        tif->tif_dir.td_dirdatasize_read += datalength;
 4205|  9.65k|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  9.65k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4205:13): [True: 9.46k, False: 184]
  ------------------
 4206|  9.46k|        {
 4207|       |            /* The offset of TIFFDirEntry are not swapped when read in. That has
 4208|       |             * to be done when used. */
 4209|  9.46k|            uint32_t offset = dp->tdir_offset.toff_long;
 4210|  9.46k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  9.46k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (4210:17): [True: 1, False: 9.46k]
  ------------------
 4211|      1|                TIFFSwabLong(&offset);
 4212|  9.46k|            tif->tif_dir
 4213|  9.46k|                .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4214|  9.46k|                .offset = (uint64_t)offset;
 4215|  9.46k|        }
 4216|    184|        else
 4217|    184|        {
 4218|    184|            tif->tif_dir
 4219|    184|                .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4220|    184|                .offset = dp->tdir_offset.toff_long8;
 4221|    184|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    184|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (4221:17): [True: 0, False: 184]
  ------------------
 4222|      0|                TIFFSwabLong8(
 4223|      0|                    &tif->tif_dir
 4224|      0|                         .td_dirdatasize_offsets[tif->tif_dir
 4225|      0|                                                     .td_dirdatasize_Noffsets]
 4226|      0|                         .offset);
 4227|    184|        }
 4228|  9.65k|        tif->tif_dir
 4229|  9.65k|            .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4230|  9.65k|            .length = datalength;
 4231|  9.65k|        tif->tif_dir.td_dirdatasize_Noffsets++;
 4232|  9.65k|    }
 4233|  21.7k|    return true;
 4234|  21.8k|}
tif_dirread.c:TIFFReadDirEntryDoubleArray:
 3046|    345|{
 3047|    345|    enum TIFFReadDirEntryErr err;
 3048|    345|    uint32_t count;
 3049|    345|    void *origdata;
 3050|    345|    double *data;
 3051|    345|    switch (direntry->tdir_type)
 3052|    345|    {
 3053|      7|        case TIFF_BYTE:
  ------------------
  |  Branch (3053:9): [True: 7, False: 338]
  ------------------
 3054|     11|        case TIFF_SBYTE:
  ------------------
  |  Branch (3054:9): [True: 4, False: 341]
  ------------------
 3055|     18|        case TIFF_SHORT:
  ------------------
  |  Branch (3055:9): [True: 7, False: 338]
  ------------------
 3056|     27|        case TIFF_SSHORT:
  ------------------
  |  Branch (3056:9): [True: 9, False: 336]
  ------------------
 3057|     41|        case TIFF_LONG:
  ------------------
  |  Branch (3057:9): [True: 14, False: 331]
  ------------------
 3058|     48|        case TIFF_SLONG:
  ------------------
  |  Branch (3058:9): [True: 7, False: 338]
  ------------------
 3059|     59|        case TIFF_LONG8:
  ------------------
  |  Branch (3059:9): [True: 11, False: 334]
  ------------------
 3060|     66|        case TIFF_SLONG8:
  ------------------
  |  Branch (3060:9): [True: 7, False: 338]
  ------------------
 3061|     77|        case TIFF_RATIONAL:
  ------------------
  |  Branch (3061:9): [True: 11, False: 334]
  ------------------
 3062|    222|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (3062:9): [True: 145, False: 200]
  ------------------
 3063|    230|        case TIFF_FLOAT:
  ------------------
  |  Branch (3063:9): [True: 8, False: 337]
  ------------------
 3064|    345|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3064:9): [True: 115, False: 230]
  ------------------
 3065|    345|            break;
 3066|      0|        default:
  ------------------
  |  Branch (3066:9): [True: 0, False: 345]
  ------------------
 3067|      0|            return (TIFFReadDirEntryErrType);
 3068|    345|    }
 3069|    345|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 3070|    345|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (3070:9): [True: 26, False: 319]
  |  Branch (3070:43): [True: 20, False: 299]
  ------------------
 3071|     46|    {
 3072|     46|        *value = 0;
 3073|     46|        return (err);
 3074|     46|    }
 3075|    299|    switch (direntry->tdir_type)
 3076|    299|    {
 3077|     70|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3077:9): [True: 70, False: 229]
  ------------------
 3078|     70|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     70|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3078:17): [True: 0, False: 70]
  ------------------
 3079|      0|                TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
 3080|     70|            TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
 3081|     70|            *value = (double *)origdata;
 3082|     70|            return (TIFFReadDirEntryErrOk);
 3083|    229|        default:
  ------------------
  |  Branch (3083:9): [True: 229, False: 70]
  ------------------
 3084|    229|            break;
 3085|    299|    }
 3086|    229|    data = (double *)_TIFFmallocExt(tif,
 3087|    229|                                    (tmsize_t)((size_t)count * sizeof(double)));
 3088|    229|    if (data == 0)
  ------------------
  |  Branch (3088:9): [True: 0, False: 229]
  ------------------
 3089|      0|    {
 3090|      0|        _TIFFfreeExt(tif, origdata);
 3091|      0|        return (TIFFReadDirEntryErrAlloc);
 3092|      0|    }
 3093|    229|    switch (direntry->tdir_type)
 3094|    229|    {
 3095|      7|        case TIFF_BYTE:
  ------------------
  |  Branch (3095:9): [True: 7, False: 222]
  ------------------
 3096|      7|        {
 3097|      7|            uint8_t *ma;
 3098|      7|            double *mb;
 3099|      7|            uint32_t n;
 3100|      7|            ma = (uint8_t *)origdata;
 3101|      7|            mb = data;
 3102|     38|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3102:25): [True: 31, False: 7]
  ------------------
 3103|     31|                *mb++ = (double)(*ma++);
 3104|      7|        }
 3105|      7|        break;
 3106|      4|        case TIFF_SBYTE:
  ------------------
  |  Branch (3106:9): [True: 4, False: 225]
  ------------------
 3107|      4|        {
 3108|      4|            int8_t *ma;
 3109|      4|            double *mb;
 3110|      4|            uint32_t n;
 3111|      4|            ma = (int8_t *)origdata;
 3112|      4|            mb = data;
 3113|      8|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3113:25): [True: 4, False: 4]
  ------------------
 3114|      4|                *mb++ = (double)(*ma++);
 3115|      4|        }
 3116|      4|        break;
 3117|      7|        case TIFF_SHORT:
  ------------------
  |  Branch (3117:9): [True: 7, False: 222]
  ------------------
 3118|      7|        {
 3119|      7|            uint16_t *ma;
 3120|      7|            double *mb;
 3121|      7|            uint32_t n;
 3122|      7|            ma = (uint16_t *)origdata;
 3123|      7|            mb = data;
 3124|    203|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3124:25): [True: 196, False: 7]
  ------------------
 3125|    196|            {
 3126|    196|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    196|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3126:21): [True: 0, False: 196]
  ------------------
 3127|      0|                    TIFFSwabShort(ma);
 3128|    196|                *mb++ = (double)(*ma++);
 3129|    196|            }
 3130|      7|        }
 3131|      7|        break;
 3132|      9|        case TIFF_SSHORT:
  ------------------
  |  Branch (3132:9): [True: 9, False: 220]
  ------------------
 3133|      9|        {
 3134|      9|            int16_t *ma;
 3135|      9|            double *mb;
 3136|      9|            uint32_t n;
 3137|      9|            ma = (int16_t *)origdata;
 3138|      9|            mb = data;
 3139|    229|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3139:25): [True: 220, False: 9]
  ------------------
 3140|    220|            {
 3141|    220|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    220|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3141:21): [True: 0, False: 220]
  ------------------
 3142|      0|                    TIFFSwabShort((uint16_t *)ma);
 3143|    220|                *mb++ = (double)(*ma++);
 3144|    220|            }
 3145|      9|        }
 3146|      9|        break;
 3147|     14|        case TIFF_LONG:
  ------------------
  |  Branch (3147:9): [True: 14, False: 215]
  ------------------
 3148|     14|        {
 3149|     14|            uint32_t *ma;
 3150|     14|            double *mb;
 3151|     14|            uint32_t n;
 3152|     14|            ma = (uint32_t *)origdata;
 3153|     14|            mb = data;
 3154|     50|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3154:25): [True: 36, False: 14]
  ------------------
 3155|     36|            {
 3156|     36|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     36|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3156:21): [True: 0, False: 36]
  ------------------
 3157|      0|                    TIFFSwabLong(ma);
 3158|     36|                *mb++ = (double)(*ma++);
 3159|     36|            }
 3160|     14|        }
 3161|     14|        break;
 3162|      7|        case TIFF_SLONG:
  ------------------
  |  Branch (3162:9): [True: 7, False: 222]
  ------------------
 3163|      7|        {
 3164|      7|            int32_t *ma;
 3165|      7|            double *mb;
 3166|      7|            uint32_t n;
 3167|      7|            ma = (int32_t *)origdata;
 3168|      7|            mb = data;
 3169|    203|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3169:25): [True: 196, False: 7]
  ------------------
 3170|    196|            {
 3171|    196|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    196|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3171:21): [True: 0, False: 196]
  ------------------
 3172|      0|                    TIFFSwabLong((uint32_t *)ma);
 3173|    196|                *mb++ = (double)(*ma++);
 3174|    196|            }
 3175|      7|        }
 3176|      7|        break;
 3177|     11|        case TIFF_LONG8:
  ------------------
  |  Branch (3177:9): [True: 11, False: 218]
  ------------------
 3178|     11|        {
 3179|     11|            uint64_t *ma;
 3180|     11|            double *mb;
 3181|     11|            uint32_t n;
 3182|     11|            ma = (uint64_t *)origdata;
 3183|     11|            mb = data;
 3184|    359|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3184:25): [True: 348, False: 11]
  ------------------
 3185|    348|            {
 3186|    348|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    348|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3186:21): [True: 0, False: 348]
  ------------------
 3187|      0|                    TIFFSwabLong8(ma);
 3188|    348|                *mb++ = (double)(*ma++);
 3189|    348|            }
 3190|     11|        }
 3191|     11|        break;
 3192|      7|        case TIFF_SLONG8:
  ------------------
  |  Branch (3192:9): [True: 7, False: 222]
  ------------------
 3193|      7|        {
 3194|      7|            int64_t *ma;
 3195|      7|            double *mb;
 3196|      7|            uint32_t n;
 3197|      7|            ma = (int64_t *)origdata;
 3198|      7|            mb = data;
 3199|    203|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3199:25): [True: 196, False: 7]
  ------------------
 3200|    196|            {
 3201|    196|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    196|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3201:21): [True: 0, False: 196]
  ------------------
 3202|      0|                    TIFFSwabLong8((uint64_t *)ma);
 3203|    196|                *mb++ = (double)(*ma++);
 3204|    196|            }
 3205|      7|        }
 3206|      7|        break;
 3207|     11|        case TIFF_RATIONAL:
  ------------------
  |  Branch (3207:9): [True: 11, False: 218]
  ------------------
 3208|     11|        {
 3209|     11|            uint32_t *ma;
 3210|     11|            uint32_t maa;
 3211|     11|            uint32_t mab;
 3212|     11|            double *mb;
 3213|     11|            uint32_t n;
 3214|     11|            ma = (uint32_t *)origdata;
 3215|     11|            mb = data;
 3216|    211|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3216:25): [True: 200, False: 11]
  ------------------
 3217|    200|            {
 3218|    200|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    200|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3218:21): [True: 0, False: 200]
  ------------------
 3219|      0|                    TIFFSwabLong(ma);
 3220|    200|                maa = *ma++;
 3221|    200|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    200|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3221:21): [True: 0, False: 200]
  ------------------
 3222|      0|                    TIFFSwabLong(ma);
 3223|    200|                mab = *ma++;
 3224|    200|                if (mab == 0)
  ------------------
  |  Branch (3224:21): [True: 3, False: 197]
  ------------------
 3225|      3|                    *mb++ = 0.0;
 3226|    197|                else
 3227|    197|                    *mb++ = (double)maa / (double)mab;
 3228|    200|            }
 3229|     11|        }
 3230|     11|        break;
 3231|    144|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (3231:9): [True: 144, False: 85]
  ------------------
 3232|    144|        {
 3233|    144|            uint32_t *ma;
 3234|    144|            int32_t maa;
 3235|    144|            uint32_t mab;
 3236|    144|            double *mb;
 3237|    144|            uint32_t n;
 3238|    144|            ma = (uint32_t *)origdata;
 3239|    144|            mb = data;
 3240|    436|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3240:25): [True: 292, False: 144]
  ------------------
 3241|    292|            {
 3242|    292|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    292|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3242:21): [True: 0, False: 292]
  ------------------
 3243|      0|                    TIFFSwabLong(ma);
 3244|    292|                maa = *(int32_t *)ma;
 3245|    292|                ma++;
 3246|    292|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    292|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3246:21): [True: 0, False: 292]
  ------------------
 3247|      0|                    TIFFSwabLong(ma);
 3248|    292|                mab = *ma++;
 3249|    292|                if (mab == 0)
  ------------------
  |  Branch (3249:21): [True: 32, False: 260]
  ------------------
 3250|     32|                    *mb++ = 0.0;
 3251|    260|                else
 3252|    260|                    *mb++ = (double)maa / (double)mab;
 3253|    292|            }
 3254|    144|        }
 3255|    144|        break;
 3256|      8|        case TIFF_FLOAT:
  ------------------
  |  Branch (3256:9): [True: 8, False: 221]
  ------------------
 3257|      8|        {
 3258|      8|            float *ma;
 3259|      8|            double *mb;
 3260|      8|            uint32_t n;
 3261|      8|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      8|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3261:17): [True: 0, False: 8]
  ------------------
 3262|      0|                TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 3263|      8|            TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata);
 3264|      8|            ma = (float *)origdata;
 3265|      8|            mb = data;
 3266|     20|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3266:25): [True: 12, False: 8]
  ------------------
 3267|     12|                *mb++ = (double)(*ma++);
 3268|      8|        }
 3269|      8|        break;
 3270|      0|        default:
  ------------------
  |  Branch (3270:9): [True: 0, False: 229]
  ------------------
 3271|      0|            break;
 3272|    229|    }
 3273|    229|    _TIFFfreeExt(tif, origdata);
 3274|    229|    *value = data;
 3275|    229|    return (TIFFReadDirEntryErrOk);
 3276|    229|}
tif_dirread.c:TIFFReadDirEntryArray:
 1390|  19.7k|{
 1391|  19.7k|    return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, desttypesize,
 1392|  19.7k|                                          value, ~((uint64_t)0));
 1393|  19.7k|}
tif_dirread.c:TIFFReadDirEntryArrayWithLimit:
 1263|  26.3k|{
 1264|  26.3k|    int typesize;
 1265|  26.3k|    uint32_t datasize;
 1266|  26.3k|    void *data;
 1267|  26.3k|    uint64_t target_count64;
 1268|  26.3k|    int original_datasize_clamped;
 1269|  26.3k|    typesize = TIFFDataWidth((TIFFDataType)direntry->tdir_type);
 1270|       |
 1271|  26.3k|    target_count64 =
 1272|  26.3k|        (direntry->tdir_count > maxcount) ? maxcount : direntry->tdir_count;
  ------------------
  |  Branch (1272:9): [True: 2.06k, False: 24.3k]
  ------------------
 1273|       |
 1274|  26.3k|    if ((target_count64 == 0) || (typesize == 0))
  ------------------
  |  Branch (1274:9): [True: 1.78k, False: 24.6k]
  |  Branch (1274:34): [True: 0, False: 24.6k]
  ------------------
 1275|  1.78k|    {
 1276|  1.78k|        *value = 0;
 1277|  1.78k|        return (TIFFReadDirEntryErrOk);
 1278|  1.78k|    }
 1279|  24.6k|    (void)desttypesize;
 1280|       |
 1281|       |    /* We just want to know if the original tag size is more than 4 bytes
 1282|       |     * (classic TIFF) or 8 bytes (BigTIFF)
 1283|       |     */
 1284|  24.6k|    original_datasize_clamped =
 1285|  24.6k|        ((direntry->tdir_count > 10) ? 10 : (int)direntry->tdir_count) *
  ------------------
  |  Branch (1285:10): [True: 11.0k, False: 13.5k]
  ------------------
 1286|  24.6k|        typesize;
 1287|       |
 1288|       |    /*
 1289|       |     * As a sanity check, make sure we have no more than a 2GB tag array
 1290|       |     * in either the current data type or the dest data type.  This also
 1291|       |     * avoids problems with overflow of tmsize_t on 32bit systems.
 1292|       |     */
 1293|  24.6k|    if ((uint64_t)(MAX_SIZE_TAG_DATA / (unsigned int)typesize) < target_count64)
  ------------------
  |  | 1257|  24.6k|#define MAX_SIZE_TAG_DATA 2147483647U
  ------------------
  |  Branch (1293:9): [True: 4.77k, False: 19.8k]
  ------------------
 1294|  4.77k|        return (TIFFReadDirEntryErrSizesan);
 1295|  19.8k|    if ((uint64_t)(MAX_SIZE_TAG_DATA / desttypesize) < target_count64)
  ------------------
  |  | 1257|  19.8k|#define MAX_SIZE_TAG_DATA 2147483647U
  ------------------
  |  Branch (1295:9): [True: 7, False: 19.8k]
  ------------------
 1296|      7|        return (TIFFReadDirEntryErrSizesan);
 1297|       |
 1298|  19.8k|    *count = (uint32_t)target_count64;
 1299|  19.8k|    datasize = (uint32_t)(*count) * (unsigned int)typesize;
 1300|  19.8k|    assert((tmsize_t)datasize > 0);
  ------------------
  |  Branch (1300:5): [True: 0, False: 19.8k]
  |  Branch (1300:5): [True: 19.8k, False: 0]
  ------------------
 1301|       |
 1302|  19.8k|    if (datasize > 100 * 1024 * 1024)
  ------------------
  |  Branch (1302:9): [True: 2.42k, False: 17.3k]
  ------------------
 1303|  2.42k|    {
 1304|       |        /* Before allocating a huge amount of memory for corrupted files, check
 1305|       |         * if size of requested memory is not greater than file size.
 1306|       |         */
 1307|  2.42k|        const uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|  2.42k|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 1308|  2.42k|        if (datasize > filesize)
  ------------------
  |  Branch (1308:13): [True: 2.42k, False: 0]
  ------------------
 1309|  2.42k|        {
 1310|  2.42k|            TIFFWarningExtR(tif, "ReadDirEntryArray",
 1311|  2.42k|                            "Requested memory size for tag %d (0x%x) %" PRIu32
 1312|  2.42k|                            " is greater than filesize %" PRIu64
 1313|  2.42k|                            ". Memory not allocated, tag not read",
 1314|  2.42k|                            direntry->tdir_tag, direntry->tdir_tag, datasize,
 1315|  2.42k|                            filesize);
 1316|  2.42k|            return (TIFFReadDirEntryErrAlloc);
 1317|  2.42k|        }
 1318|  2.42k|    }
 1319|       |
 1320|  17.3k|    if (isMapped(tif) && datasize > (uint64_t)tif->tif_size)
  ------------------
  |  |  279|  34.7k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  17.3k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 17.3k]
  |  |  ------------------
  ------------------
  |  Branch (1320:26): [True: 0, False: 0]
  ------------------
 1321|      0|        return TIFFReadDirEntryErrIo;
 1322|       |
 1323|  17.3k|    if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) ||
  ------------------
  |  |  279|  34.7k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  17.3k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
                  if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) ||
  ------------------
  |  |  140|  17.3k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1323:9): [True: 17.3k, False: 0]
  |  Branch (1323:29): [True: 253, False: 17.1k]
  |  Branch (1323:64): [True: 88, False: 165]
  ------------------
 1324|  17.3k|                           (!(tif->tif_flags & TIFF_BIGTIFF) && datasize > 4)))
  ------------------
  |  |  140|  17.3k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1324:29): [True: 17.1k, False: 165]
  |  Branch (1324:65): [True: 7.35k, False: 9.79k]
  ------------------
 1325|  7.44k|    {
 1326|  7.44k|        data = NULL;
 1327|  7.44k|    }
 1328|  9.95k|    else
 1329|  9.95k|    {
 1330|  9.95k|        data = _TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray");
 1331|  9.95k|        if (data == 0)
  ------------------
  |  Branch (1331:13): [True: 0, False: 9.95k]
  ------------------
 1332|      0|            return (TIFFReadDirEntryErrAlloc);
 1333|  9.95k|    }
 1334|  17.3k|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  17.3k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1334:9): [True: 17.1k, False: 253]
  ------------------
 1335|  17.1k|    {
 1336|       |        /* Only the condition on original_datasize_clamped. The second
 1337|       |         * one is implied, but Coverity Scan cannot see it. */
 1338|  17.1k|        if (original_datasize_clamped <= 4 && datasize <= 4)
  ------------------
  |  Branch (1338:13): [True: 8.86k, False: 8.28k]
  |  Branch (1338:47): [True: 8.86k, False: 0]
  ------------------
 1339|  8.86k|            _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
 1340|  8.28k|        else
 1341|  8.28k|        {
 1342|  8.28k|            enum TIFFReadDirEntryErr err;
 1343|  8.28k|            uint32_t offset = direntry->tdir_offset.toff_long;
 1344|  8.28k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  8.28k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1344:17): [True: 2, False: 8.28k]
  ------------------
 1345|      2|                TIFFSwabLong(&offset);
 1346|  8.28k|            if (isMapped(tif))
  ------------------
  |  |  279|  8.28k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  8.28k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 8.28k]
  |  |  ------------------
  ------------------
 1347|      0|                err = TIFFReadDirEntryData(tif, (uint64_t)offset,
 1348|      0|                                           (tmsize_t)datasize, data);
 1349|  8.28k|            else
 1350|  8.28k|                err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
 1351|  8.28k|                                                     (tmsize_t)datasize, &data);
 1352|  8.28k|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1352:17): [True: 397, False: 7.88k]
  ------------------
 1353|    397|            {
 1354|    397|                _TIFFfreeExt(tif, data);
 1355|    397|                return (err);
 1356|    397|            }
 1357|  8.28k|        }
 1358|  17.1k|    }
 1359|    253|    else
 1360|    253|    {
 1361|       |        /* See above comment for the Classic TIFF case */
 1362|    253|        if (original_datasize_clamped <= 8 && datasize <= 8)
  ------------------
  |  Branch (1362:13): [True: 94, False: 159]
  |  Branch (1362:47): [True: 94, False: 0]
  ------------------
 1363|     94|            _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
 1364|    159|        else
 1365|    159|        {
 1366|    159|            enum TIFFReadDirEntryErr err;
 1367|    159|            uint64_t offset = direntry->tdir_offset.toff_long8;
 1368|    159|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    159|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1368:17): [True: 0, False: 159]
  ------------------
 1369|      0|                TIFFSwabLong8(&offset);
 1370|    159|            if (isMapped(tif))
  ------------------
  |  |  279|    159|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|    159|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 159]
  |  |  ------------------
  ------------------
 1371|      0|                err = TIFFReadDirEntryData(tif, (uint64_t)offset,
 1372|      0|                                           (tmsize_t)datasize, data);
 1373|    159|            else
 1374|    159|                err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
 1375|    159|                                                     (tmsize_t)datasize, &data);
 1376|    159|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1376:17): [True: 73, False: 86]
  ------------------
 1377|     73|            {
 1378|     73|                _TIFFfreeExt(tif, data);
 1379|     73|                return (err);
 1380|     73|            }
 1381|    159|        }
 1382|    253|    }
 1383|  16.9k|    *value = data;
 1384|  16.9k|    return (TIFFReadDirEntryErrOk);
 1385|  17.3k|}
tif_dirread.c:TIFFReadDirEntryDataAndRealloc:
 1199|  8.44k|{
 1200|  8.44k|#if SIZEOF_SIZE_T == 8
 1201|  8.44k|    tmsize_t threshold = INITIAL_THRESHOLD;
  ------------------
  |  | 1189|  8.44k|#define INITIAL_THRESHOLD (1024 * 1024)
  ------------------
 1202|  8.44k|#endif
 1203|  8.44k|    tmsize_t already_read = 0;
 1204|       |
 1205|  8.44k|    assert(!isMapped(tif));
  ------------------
  |  Branch (1205:5): [True: 0, False: 8.44k]
  |  Branch (1205:5): [True: 8.44k, False: 0]
  ------------------
 1206|       |
 1207|  8.44k|    if (!SeekOK(tif, offset))
  ------------------
  |  |  303|  8.44k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (1207:9): [True: 437, False: 8.00k]
  ------------------
 1208|    437|        return (TIFFReadDirEntryErrIo);
 1209|       |
 1210|       |    /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */
 1211|       |    /* so as to avoid allocating too much memory in case the file is too */
 1212|       |    /* short. We could ask for the file size, but this might be */
 1213|       |    /* expensive with some I/O layers (think of reading a gzipped file) */
 1214|       |    /* Restrict to 64 bit processes, so as to avoid reallocs() */
 1215|       |    /* on 32 bit processes where virtual memory is scarce.  */
 1216|  15.9k|    while (already_read < size)
  ------------------
  |  Branch (1216:12): [True: 8.00k, False: 7.97k]
  ------------------
 1217|  8.00k|    {
 1218|  8.00k|        void *new_dest;
 1219|  8.00k|        tmsize_t bytes_read;
 1220|  8.00k|        tmsize_t to_read = size - already_read;
 1221|  8.00k|#if SIZEOF_SIZE_T == 8
 1222|  8.00k|        if (to_read >= threshold && threshold < MAX_THRESHOLD)
  ------------------
  |  | 1192|     28|    (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|     28|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|     28|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|     28|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  | 1193|     28|     INITIAL_THRESHOLD)
  |  |  ------------------
  |  |  |  | 1189|     28|#define INITIAL_THRESHOLD (1024 * 1024)
  |  |  ------------------
  ------------------
  |  Branch (1222:13): [True: 28, False: 7.97k]
  |  Branch (1222:37): [True: 28, False: 0]
  ------------------
 1223|     28|        {
 1224|     28|            to_read = threshold;
 1225|     28|            threshold *= THRESHOLD_MULTIPLIER;
  ------------------
  |  | 1190|     28|#define THRESHOLD_MULTIPLIER 10
  ------------------
 1226|     28|        }
 1227|  8.00k|#endif
 1228|       |
 1229|  8.00k|        new_dest =
 1230|  8.00k|            (uint8_t *)_TIFFreallocExt(tif, *pdest, already_read + to_read);
 1231|  8.00k|        if (new_dest == NULL)
  ------------------
  |  Branch (1231:13): [True: 0, False: 8.00k]
  ------------------
 1232|      0|        {
 1233|      0|            TIFFErrorExtR(tif, tif->tif_name,
 1234|      0|                          "Failed to allocate memory for %s "
 1235|      0|                          "(%" TIFF_SSIZE_FORMAT
 1236|      0|                          " elements of %" TIFF_SSIZE_FORMAT " bytes each)",
 1237|      0|                          "TIFFReadDirEntryArray", (tmsize_t)1,
 1238|      0|                          already_read + to_read);
 1239|      0|            return TIFFReadDirEntryErrAlloc;
 1240|      0|        }
 1241|  8.00k|        *pdest = new_dest;
 1242|       |
 1243|  8.00k|        bytes_read = TIFFReadFile(tif, (char *)*pdest + already_read, to_read);
  ------------------
  |  |  283|  8.00k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 1244|  8.00k|        if (bytes_read < 0)
  ------------------
  |  Branch (1244:13): [True: 0, False: 8.00k]
  ------------------
 1245|      0|            return TIFFReadDirEntryErrIo;
 1246|  8.00k|        already_read += bytes_read;
 1247|  8.00k|        if (bytes_read != to_read)
  ------------------
  |  Branch (1247:13): [True: 33, False: 7.97k]
  ------------------
 1248|     33|        {
 1249|     33|            return TIFFReadDirEntryErrIo;
 1250|     33|        }
 1251|  8.00k|    }
 1252|  7.97k|    return TIFFReadDirEntryErrOk;
 1253|  8.00k|}
tif_dirread.c:TIFFReadDirEntryShortArray:
 1767|  7.35k|{
 1768|  7.35k|    enum TIFFReadDirEntryErr err;
 1769|  7.35k|    uint32_t count;
 1770|  7.35k|    void *origdata;
 1771|  7.35k|    uint16_t *data;
 1772|  7.35k|    switch (direntry->tdir_type)
 1773|  7.35k|    {
 1774|    136|        case TIFF_BYTE:
  ------------------
  |  Branch (1774:9): [True: 136, False: 7.22k]
  ------------------
 1775|    151|        case TIFF_SBYTE:
  ------------------
  |  Branch (1775:9): [True: 15, False: 7.34k]
  ------------------
 1776|  7.21k|        case TIFF_SHORT:
  ------------------
  |  Branch (1776:9): [True: 7.06k, False: 289]
  ------------------
 1777|  7.23k|        case TIFF_SSHORT:
  ------------------
  |  Branch (1777:9): [True: 11, False: 7.34k]
  ------------------
 1778|  7.26k|        case TIFF_LONG:
  ------------------
  |  Branch (1778:9): [True: 33, False: 7.32k]
  ------------------
 1779|  7.27k|        case TIFF_SLONG:
  ------------------
  |  Branch (1779:9): [True: 16, False: 7.34k]
  ------------------
 1780|  7.28k|        case TIFF_LONG8:
  ------------------
  |  Branch (1780:9): [True: 8, False: 7.34k]
  ------------------
 1781|  7.30k|        case TIFF_SLONG8:
  ------------------
  |  Branch (1781:9): [True: 20, False: 7.33k]
  ------------------
 1782|  7.30k|            break;
 1783|     50|        default:
  ------------------
  |  Branch (1783:9): [True: 50, False: 7.30k]
  ------------------
 1784|     50|            return (TIFFReadDirEntryErrType);
 1785|  7.35k|    }
 1786|  7.30k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
 1787|  7.30k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1787:9): [True: 2.10k, False: 5.20k]
  |  Branch (1787:43): [True: 180, False: 5.02k]
  ------------------
 1788|  2.28k|    {
 1789|  2.28k|        *value = 0;
 1790|  2.28k|        return (err);
 1791|  2.28k|    }
 1792|  5.02k|    switch (direntry->tdir_type)
 1793|  5.02k|    {
 1794|  4.80k|        case TIFF_SHORT:
  ------------------
  |  Branch (1794:9): [True: 4.80k, False: 225]
  ------------------
 1795|  4.80k|            *value = (uint16_t *)origdata;
 1796|  4.80k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  4.80k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1796:17): [True: 0, False: 4.80k]
  ------------------
 1797|      0|                TIFFSwabArrayOfShort(*value, count);
 1798|  4.80k|            return (TIFFReadDirEntryErrOk);
 1799|     11|        case TIFF_SSHORT:
  ------------------
  |  Branch (1799:9): [True: 11, False: 5.01k]
  ------------------
 1800|     11|        {
 1801|     11|            int16_t *m;
 1802|     11|            uint32_t n;
 1803|     11|            m = (int16_t *)origdata;
 1804|     18|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1804:25): [True: 11, False: 7]
  ------------------
 1805|     11|            {
 1806|     11|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1806:21): [True: 0, False: 11]
  ------------------
 1807|      0|                    TIFFSwabShort((uint16_t *)m);
 1808|     11|                err = TIFFReadDirEntryCheckRangeShortSshort(*m);
 1809|     11|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1809:21): [True: 4, False: 7]
  ------------------
 1810|      4|                {
 1811|      4|                    _TIFFfreeExt(tif, origdata);
 1812|      4|                    return (err);
 1813|      4|                }
 1814|      7|                m++;
 1815|      7|            }
 1816|      7|            *value = (uint16_t *)origdata;
 1817|      7|            return (TIFFReadDirEntryErrOk);
 1818|     11|        }
 1819|    214|        default:
  ------------------
  |  Branch (1819:9): [True: 214, False: 4.81k]
  ------------------
 1820|    214|            break;
 1821|  5.02k|    }
 1822|    214|    data = (uint16_t *)_TIFFCheckMalloc(tif, count, sizeof(uint16_t),
 1823|    214|                                        "TIFFReadDirEntryShortArray");
 1824|    214|    if (data == 0)
  ------------------
  |  Branch (1824:9): [True: 0, False: 214]
  ------------------
 1825|      0|    {
 1826|      0|        _TIFFfreeExt(tif, origdata);
 1827|      0|        return (TIFFReadDirEntryErrAlloc);
 1828|      0|    }
 1829|    214|    switch (direntry->tdir_type)
 1830|    214|    {
 1831|    134|        case TIFF_BYTE:
  ------------------
  |  Branch (1831:9): [True: 134, False: 80]
  ------------------
 1832|    134|        {
 1833|    134|            uint8_t *ma;
 1834|    134|            uint16_t *mb;
 1835|    134|            uint32_t n;
 1836|    134|            ma = (uint8_t *)origdata;
 1837|    134|            mb = data;
 1838|    920|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1838:25): [True: 786, False: 134]
  ------------------
 1839|    786|                *mb++ = (uint16_t)(*ma++);
 1840|    134|        }
 1841|    134|        break;
 1842|     15|        case TIFF_SBYTE:
  ------------------
  |  Branch (1842:9): [True: 15, False: 199]
  ------------------
 1843|     15|        {
 1844|     15|            int8_t *ma;
 1845|     15|            uint16_t *mb;
 1846|     15|            uint32_t n;
 1847|     15|            ma = (int8_t *)origdata;
 1848|     15|            mb = data;
 1849|     83|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1849:25): [True: 75, False: 8]
  ------------------
 1850|     75|            {
 1851|     75|                err = TIFFReadDirEntryCheckRangeShortSbyte(*ma);
 1852|     75|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1852:21): [True: 7, False: 68]
  ------------------
 1853|      7|                    break;
 1854|     68|                *mb++ = (uint16_t)(*ma++);
 1855|     68|            }
 1856|     15|        }
 1857|     15|        break;
 1858|     33|        case TIFF_LONG:
  ------------------
  |  Branch (1858:9): [True: 33, False: 181]
  ------------------
 1859|     33|        {
 1860|     33|            uint32_t *ma;
 1861|     33|            uint16_t *mb;
 1862|     33|            uint32_t n;
 1863|     33|            ma = (uint32_t *)origdata;
 1864|     33|            mb = data;
 1865|     58|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1865:25): [True: 33, False: 25]
  ------------------
 1866|     33|            {
 1867|     33|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     33|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1867:21): [True: 0, False: 33]
  ------------------
 1868|      0|                    TIFFSwabLong(ma);
 1869|     33|                err = TIFFReadDirEntryCheckRangeShortLong(*ma);
 1870|     33|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1870:21): [True: 8, False: 25]
  ------------------
 1871|      8|                    break;
 1872|     25|                *mb++ = (uint16_t)(*ma++);
 1873|     25|            }
 1874|     33|        }
 1875|     33|        break;
 1876|     16|        case TIFF_SLONG:
  ------------------
  |  Branch (1876:9): [True: 16, False: 198]
  ------------------
 1877|     16|        {
 1878|     16|            int32_t *ma;
 1879|     16|            uint16_t *mb;
 1880|     16|            uint32_t n;
 1881|     16|            ma = (int32_t *)origdata;
 1882|     16|            mb = data;
 1883|     40|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1883:25): [True: 32, False: 8]
  ------------------
 1884|     32|            {
 1885|     32|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     32|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1885:21): [True: 0, False: 32]
  ------------------
 1886|      0|                    TIFFSwabLong((uint32_t *)ma);
 1887|     32|                err = TIFFReadDirEntryCheckRangeShortSlong(*ma);
 1888|     32|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1888:21): [True: 8, False: 24]
  ------------------
 1889|      8|                    break;
 1890|     24|                *mb++ = (uint16_t)(*ma++);
 1891|     24|            }
 1892|     16|        }
 1893|     16|        break;
 1894|      8|        case TIFF_LONG8:
  ------------------
  |  Branch (1894:9): [True: 8, False: 206]
  ------------------
 1895|      8|        {
 1896|      8|            uint64_t *ma;
 1897|      8|            uint16_t *mb;
 1898|      8|            uint32_t n;
 1899|      8|            ma = (uint64_t *)origdata;
 1900|      8|            mb = data;
 1901|     15|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1901:25): [True: 11, False: 4]
  ------------------
 1902|     11|            {
 1903|     11|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1903:21): [True: 0, False: 11]
  ------------------
 1904|      0|                    TIFFSwabLong8(ma);
 1905|     11|                err = TIFFReadDirEntryCheckRangeShortLong8(*ma);
 1906|     11|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1906:21): [True: 4, False: 7]
  ------------------
 1907|      4|                    break;
 1908|      7|                *mb++ = (uint16_t)(*ma++);
 1909|      7|            }
 1910|      8|        }
 1911|      8|        break;
 1912|      8|        case TIFF_SLONG8:
  ------------------
  |  Branch (1912:9): [True: 8, False: 206]
  ------------------
 1913|      8|        {
 1914|      8|            int64_t *ma;
 1915|      8|            uint16_t *mb;
 1916|      8|            uint32_t n;
 1917|      8|            ma = (int64_t *)origdata;
 1918|      8|            mb = data;
 1919|      8|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1919:25): [True: 8, False: 0]
  ------------------
 1920|      8|            {
 1921|      8|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      8|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1921:21): [True: 0, False: 8]
  ------------------
 1922|      0|                    TIFFSwabLong8((uint64_t *)ma);
 1923|      8|                err = TIFFReadDirEntryCheckRangeShortSlong8(*ma);
 1924|      8|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1924:21): [True: 8, False: 0]
  ------------------
 1925|      8|                    break;
 1926|      0|                *mb++ = (uint16_t)(*ma++);
 1927|      0|            }
 1928|      8|        }
 1929|      8|        break;
 1930|      0|        default:
  ------------------
  |  Branch (1930:9): [True: 0, False: 214]
  ------------------
 1931|      0|            break;
 1932|    214|    }
 1933|    214|    _TIFFfreeExt(tif, origdata);
 1934|    214|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1934:9): [True: 35, False: 179]
  ------------------
 1935|     35|    {
 1936|     35|        _TIFFfreeExt(tif, data);
 1937|     35|        return (err);
 1938|     35|    }
 1939|    179|    *value = data;
 1940|    179|    return (TIFFReadDirEntryErrOk);
 1941|    214|}
tif_dirread.c:CalcFinalIFDdatasizeReading:
 4260|  2.91k|{
 4261|       |    /* IFD data size is only needed if file-writing is enabled.
 4262|       |     * This also avoids the seek() to EOF to determine the file size, which
 4263|       |     * causes the stdin-streaming-friendly mode of libtiff for GDAL to fail. */
 4264|  2.91k|    if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (4264:9): [True: 2.91k, False: 0]
  ------------------
 4265|  2.91k|        return;
 4266|       |
 4267|       |    /* Sort TIFFEntryOffsetAndLength array in ascending order. */
 4268|      0|    qsort(tif->tif_dir.td_dirdatasize_offsets,
 4269|      0|          tif->tif_dir.td_dirdatasize_Noffsets,
 4270|      0|          sizeof(TIFFEntryOffsetAndLength), cmpTIFFEntryOffsetAndLength);
 4271|       |
 4272|       |    /* Get offset of end of IFD entry space. */
 4273|      0|    uint64_t IFDendoffset;
 4274|      0|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4274:9): [True: 0, False: 0]
  ------------------
 4275|      0|        IFDendoffset = tif->tif_diroff + 2 + (uint64_t)dircount * 12 + 4;
 4276|      0|    else
 4277|      0|        IFDendoffset = tif->tif_diroff + 8 + (uint64_t)dircount * 20 + 8;
 4278|       |
 4279|       |    /* Check which offsets are right behind IFD entries. However, LibTIFF
 4280|       |     * increments the writing address for every external data to an even offset.
 4281|       |     * Thus gaps of 1 byte can occur. */
 4282|      0|    uint64_t size = 0;
 4283|      0|    uint64_t offset;
 4284|      0|    uint32_t i;
 4285|      0|    for (i = 0; i < tif->tif_dir.td_dirdatasize_Noffsets; i++)
  ------------------
  |  Branch (4285:17): [True: 0, False: 0]
  ------------------
 4286|      0|    {
 4287|      0|        offset = tif->tif_dir.td_dirdatasize_offsets[i].offset;
 4288|      0|        if (offset == IFDendoffset)
  ------------------
  |  Branch (4288:13): [True: 0, False: 0]
  ------------------
 4289|      0|        {
 4290|      0|            size += tif->tif_dir.td_dirdatasize_offsets[i].length;
 4291|      0|            IFDendoffset += tif->tif_dir.td_dirdatasize_offsets[i].length;
 4292|      0|        }
 4293|      0|        else if (offset == IFDendoffset + 1)
  ------------------
  |  Branch (4293:18): [True: 0, False: 0]
  ------------------
 4294|      0|        {
 4295|       |            /* Add gap byte after previous IFD data set. */
 4296|      0|            size += tif->tif_dir.td_dirdatasize_offsets[i].length + 1;
 4297|      0|            IFDendoffset += tif->tif_dir.td_dirdatasize_offsets[i].length;
 4298|      0|        }
 4299|      0|        else
 4300|      0|        {
 4301|       |            /* Further data is no more continuously after IFD */
 4302|      0|            break;
 4303|      0|        }
 4304|      0|    }
 4305|       |    /* Check for gap byte of some easy cases. This should cover 90% of cases.
 4306|       |     * Otherwise, IFD will be re-written even it might be safely overwritten. */
 4307|      0|    if (tif->tif_nextdiroff != 0)
  ------------------
  |  Branch (4307:9): [True: 0, False: 0]
  ------------------
 4308|      0|    {
 4309|      0|        if (tif->tif_nextdiroff == IFDendoffset + 1)
  ------------------
  |  Branch (4309:13): [True: 0, False: 0]
  ------------------
 4310|      0|            size++;
 4311|      0|    }
 4312|      0|    else
 4313|      0|    {
 4314|       |        /* Check for IFD data ends at EOF. Then IFD can always be safely
 4315|       |         * overwritten. */
 4316|      0|        offset = TIFFSeekFile(tif, 0, SEEK_END);
  ------------------
  |  |  287|      0|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 4317|      0|        if (offset == IFDendoffset)
  ------------------
  |  Branch (4317:13): [True: 0, False: 0]
  ------------------
 4318|      0|        {
 4319|      0|            tif->tif_dir.td_dirdatasize_read = UINT64_MAX;
 4320|      0|            return;
 4321|      0|        }
 4322|      0|    }
 4323|       |
 4324|       |    /* Finally, add the size of the IFD tag entries themselves. */
 4325|      0|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4325:9): [True: 0, False: 0]
  ------------------
 4326|      0|        tif->tif_dir.td_dirdatasize_read = 2U + dircount * 12U + 4U + size;
 4327|      0|    else
 4328|      0|        tif->tif_dir.td_dirdatasize_read = 8U + dircount * 20U + 8U + size;
 4329|      0|} /*-- CalcFinalIFDdatasizeReading() --*/
tif_dirread.c:_TIFFGetMaxColorChannels:
 4115|  2.66k|{
 4116|  2.66k|    switch (photometric)
 4117|  2.66k|    {
 4118|    228|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|    228|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (4118:9): [True: 228, False: 2.44k]
  ------------------
 4119|    799|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    799|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (4119:9): [True: 571, False: 2.09k]
  ------------------
 4120|    875|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    875|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (4120:9): [True: 76, False: 2.59k]
  ------------------
 4121|    875|            return 1;
 4122|  1.33k|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|  1.33k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4122:9): [True: 1.33k, False: 1.32k]
  ------------------
 4123|  1.39k|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|  1.39k|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4123:9): [True: 56, False: 2.61k]
  ------------------
 4124|  1.47k|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|  1.47k|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (4124:9): [True: 79, False: 2.58k]
  ------------------
 4125|  1.53k|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|  1.53k|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (4125:9): [True: 64, False: 2.60k]
  ------------------
 4126|  1.54k|        case PHOTOMETRIC_ITULAB:
  ------------------
  |  |  230|  1.54k|#define PHOTOMETRIC_ITULAB 10              /* ITU L*a*b* */
  ------------------
  |  Branch (4126:9): [True: 10, False: 2.65k]
  ------------------
 4127|  1.56k|        case PHOTOMETRIC_ICCLAB:
  ------------------
  |  |  229|  1.56k|#define PHOTOMETRIC_ICCLAB 9               /* ICC L*a*b* [Adobe TIFF Technote 4] */
  ------------------
  |  Branch (4127:9): [True: 17, False: 2.65k]
  ------------------
 4128|  1.56k|            return 3;
 4129|    104|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|    104|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (4129:9): [True: 104, False: 2.56k]
  ------------------
 4130|    108|        case PHOTOMETRIC_MASK:
  ------------------
  |  |  225|    108|#define PHOTOMETRIC_MASK 4                 /* $holdout mask */
  ------------------
  |  Branch (4130:9): [True: 4, False: 2.66k]
  ------------------
 4131|    108|            return 4;
 4132|     30|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|     30|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (4132:9): [True: 30, False: 2.63k]
  ------------------
 4133|     30|        case PHOTOMETRIC_CFA:
  ------------------
  |  |  231|     30|#define PHOTOMETRIC_CFA 32803              /* color filter array */
  ------------------
  |  Branch (4133:9): [True: 0, False: 2.66k]
  ------------------
 4134|    120|        default:
  ------------------
  |  Branch (4134:9): [True: 90, False: 2.57k]
  ------------------
 4135|    120|            return 0;
 4136|  2.66k|    }
 4137|  2.66k|}
tif_dirread.c:ByteCountLooksBad:
 4140|    421|{
 4141|       |    /*
 4142|       |     * Assume we have wrong StripByteCount value (in case
 4143|       |     * of single strip) in following cases:
 4144|       |     *   - it is equal to zero along with StripOffset;
 4145|       |     *   - it is larger than file itself (in case of uncompressed
 4146|       |     *     image);
 4147|       |     *   - it is smaller than the size of the bytes per row
 4148|       |     *     multiplied on the number of rows.  The last case should
 4149|       |     *     not be checked in the case of writing new image,
 4150|       |     *     because we may do not know the exact strip size
 4151|       |     *     until the whole image will be written and directory
 4152|       |     *     dumped out.
 4153|       |     */
 4154|    421|    uint64_t bytecount = TIFFGetStrileByteCount(tif, 0);
 4155|    421|    uint64_t offset = TIFFGetStrileOffset(tif, 0);
 4156|    421|    uint64_t filesize;
 4157|       |
 4158|    421|    if (offset == 0)
  ------------------
  |  Branch (4158:9): [True: 95, False: 326]
  ------------------
 4159|     95|        return 0;
 4160|    326|    if (bytecount == 0)
  ------------------
  |  Branch (4160:9): [True: 17, False: 309]
  ------------------
 4161|     17|        return 1;
 4162|    309|    if (tif->tif_dir.td_compression != COMPRESSION_NONE)
  ------------------
  |  |  182|    309|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (4162:9): [True: 262, False: 47]
  ------------------
 4163|    262|        return 0;
 4164|     47|    filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|     47|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 4165|     47|    if (offset <= filesize && bytecount > filesize - offset)
  ------------------
  |  Branch (4165:9): [True: 46, False: 1]
  |  Branch (4165:31): [True: 7, False: 39]
  ------------------
 4166|      7|        return 1;
 4167|     40|    if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (4167:9): [True: 40, False: 0]
  ------------------
 4168|     40|    {
 4169|     40|        uint64_t scanlinesize = TIFFScanlineSize64(tif);
 4170|     40|        if (tif->tif_dir.td_imagelength > 0 &&
  ------------------
  |  Branch (4170:13): [True: 40, False: 0]
  ------------------
 4171|     40|            scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength)
  ------------------
  |  Branch (4171:13): [True: 0, False: 40]
  ------------------
 4172|      0|        {
 4173|      0|            return 1;
 4174|      0|        }
 4175|     40|        if (bytecount < scanlinesize * tif->tif_dir.td_imagelength)
  ------------------
  |  Branch (4175:13): [True: 34, False: 6]
  ------------------
 4176|     34|            return 1;
 4177|     40|    }
 4178|      6|    return 0;
 4179|     40|}
tif_dirread.c:TIFFReadDirectoryCheckOrder:
 5311|  3.00k|{
 5312|  3.00k|    static const char module[] = "TIFFReadDirectoryCheckOrder";
 5313|  3.00k|    uint32_t m;
 5314|  3.00k|    uint16_t n;
 5315|  3.00k|    TIFFDirEntry *o;
 5316|  3.00k|    m = 0;
 5317|  10.8k|    for (n = 0, o = dir; n < dircount; n++, o++)
  ------------------
  |  Branch (5317:26): [True: 10.8k, False: 4]
  ------------------
 5318|  10.8k|    {
 5319|  10.8k|        if (o->tdir_tag < m)
  ------------------
  |  Branch (5319:13): [True: 2.99k, False: 7.82k]
  ------------------
 5320|  2.99k|        {
 5321|  2.99k|            TIFFWarningExtR(tif, module,
 5322|  2.99k|                            "Invalid TIFF directory; tags are not sorted in "
 5323|  2.99k|                            "ascending order");
 5324|  2.99k|            break;
 5325|  2.99k|        }
 5326|  7.82k|        m = o->tdir_tag + 1U;
 5327|  7.82k|    }
 5328|  3.00k|}
tif_dirread.c:TIFFReadDirectoryFindEntry:
 5333|  6.82k|{
 5334|  6.82k|    TIFFDirEntry *m;
 5335|  6.82k|    uint16_t n;
 5336|  6.82k|    (void)tif;
 5337|   496k|    for (m = dir, n = 0; n < dircount; m++, n++)
  ------------------
  |  Branch (5337:26): [True: 494k, False: 1.83k]
  ------------------
 5338|   494k|    {
 5339|   494k|        if (m->tdir_tag == tagid)
  ------------------
  |  Branch (5339:13): [True: 4.99k, False: 489k]
  ------------------
 5340|  4.99k|            return (m);
 5341|   494k|    }
 5342|  1.83k|    return (0);
 5343|  6.82k|}
tif_dirread.c:TIFFReadDirectoryFindFieldInfo:
 5347|   621k|{
 5348|   621k|    int32_t ma, mb, mc;
 5349|   621k|    ma = -1;
 5350|   621k|    mc = (int32_t)tif->tif_nfields;
 5351|  4.65M|    while (1)
  ------------------
  |  Branch (5351:12): [True: 4.65M, Folded]
  ------------------
 5352|  4.65M|    {
 5353|  4.65M|        if (ma + 1 == mc)
  ------------------
  |  Branch (5353:13): [True: 185k, False: 4.47M]
  ------------------
 5354|   185k|        {
 5355|   185k|            *fii = FAILED_FII;
  ------------------
  |  |   44|   185k|#define FAILED_FII ((uint32_t)-1)
  ------------------
 5356|   185k|            return;
 5357|   185k|        }
 5358|  4.47M|        mb = (ma + mc) / 2;
 5359|  4.47M|        if (tif->tif_fields[mb]->field_tag == (uint32_t)tagid)
  ------------------
  |  Branch (5359:13): [True: 436k, False: 4.03M]
  ------------------
 5360|   436k|            break;
 5361|  4.03M|        if (tif->tif_fields[mb]->field_tag < (uint32_t)tagid)
  ------------------
  |  Branch (5361:13): [True: 2.03M, False: 2.00M]
  ------------------
 5362|  2.03M|            ma = mb;
 5363|  2.00M|        else
 5364|  2.00M|            mc = mb;
 5365|  4.03M|    }
 5366|   436k|    while (1)
  ------------------
  |  Branch (5366:12): [True: 436k, Folded]
  ------------------
 5367|   436k|    {
 5368|   436k|        if (mb == 0)
  ------------------
  |  Branch (5368:13): [True: 6.40k, False: 429k]
  ------------------
 5369|  6.40k|            break;
 5370|   429k|        if (tif->tif_fields[mb - 1]->field_tag != (uint32_t)tagid)
  ------------------
  |  Branch (5370:13): [True: 429k, False: 0]
  ------------------
 5371|   429k|            break;
 5372|      0|        mb--;
 5373|      0|    }
 5374|   436k|    *fii = (uint32_t)mb;
 5375|   436k|}
tif_dirread.c:EstimateStripByteCounts:
 5582|    492|{
 5583|    492|    static const char module[] = "EstimateStripByteCounts";
 5584|       |
 5585|    492|    TIFFDirEntry *dp;
 5586|    492|    TIFFDirectory *td = &tif->tif_dir;
 5587|    492|    uint32_t strip;
 5588|       |
 5589|       |    /* Do not try to load stripbytecount as we will compute it */
 5590|    492|    if (!_TIFFFillStrilesInternal(tif, 0))
  ------------------
  |  Branch (5590:9): [True: 0, False: 492]
  ------------------
 5591|      0|        return -1;
 5592|       |
 5593|    492|    const uint64_t allocsize = (uint64_t)td->td_nstrips * sizeof(uint64_t);
 5594|    492|    uint64_t filesize = 0;
 5595|    492|    if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (5595:9): [True: 0, False: 492]
  ------------------
 5596|      0|    {
 5597|       |        /* Before allocating a huge amount of memory for corrupted files, check
 5598|       |         * if size of requested memory is not greater than file size. */
 5599|      0|        filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      0|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 5600|      0|        if (allocsize > filesize)
  ------------------
  |  Branch (5600:13): [True: 0, False: 0]
  ------------------
 5601|      0|        {
 5602|      0|            TIFFWarningExtR(
 5603|      0|                tif, module,
 5604|      0|                "Requested memory size for StripByteCounts of %" PRIu64
 5605|      0|                " is greater than filesize %" PRIu64 ". Memory not allocated",
 5606|      0|                allocsize, filesize);
 5607|      0|            return -1;
 5608|      0|        }
 5609|      0|    }
 5610|       |
 5611|    492|    if (td->td_stripbytecount_p)
  ------------------
  |  Branch (5611:9): [True: 59, False: 433]
  ------------------
 5612|     59|        _TIFFfreeExt(tif, td->td_stripbytecount_p);
 5613|    492|    td->td_stripbytecount_p = (uint64_t *)_TIFFCheckMalloc(
 5614|    492|        tif, td->td_nstrips, sizeof(uint64_t), "for \"StripByteCounts\" array");
 5615|    492|    if (td->td_stripbytecount_p == NULL)
  ------------------
  |  Branch (5615:9): [True: 0, False: 492]
  ------------------
 5616|      0|        return -1;
 5617|       |
 5618|    492|    if (td->td_compression != COMPRESSION_NONE)
  ------------------
  |  |  182|    492|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5618:9): [True: 391, False: 101]
  ------------------
 5619|    391|    {
 5620|    391|        uint64_t space;
 5621|    391|        uint16_t n;
 5622|    391|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    391|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (5622:13): [True: 371, False: 20]
  ------------------
 5623|    371|            space = sizeof(TIFFHeaderClassic) + 2 +
 5624|    371|                    (unsigned long)dircount * 12 + 4;
 5625|     20|        else
 5626|     20|            space =
 5627|     20|                sizeof(TIFFHeaderBig) + 8 + (unsigned long)dircount * 20 + 8;
 5628|       |        /* calculate amount of space used by indirect values */
 5629|  7.11k|        for (dp = dir, n = dircount; n > 0; n--, dp++)
  ------------------
  |  Branch (5629:38): [True: 6.76k, False: 356]
  ------------------
 5630|  6.76k|        {
 5631|  6.76k|            uint32_t typewidth;
 5632|  6.76k|            uint64_t datasize;
 5633|  6.76k|            typewidth = (uint32_t)TIFFDataWidth((TIFFDataType)dp->tdir_type);
 5634|  6.76k|            if (typewidth == 0)
  ------------------
  |  Branch (5634:17): [True: 29, False: 6.73k]
  ------------------
 5635|     29|            {
 5636|     29|                TIFFErrorExtR(
 5637|     29|                    tif, module,
 5638|     29|                    "Cannot determine size of unknown tag type %" PRIu16,
 5639|     29|                    dp->tdir_type);
 5640|     29|                return -1;
 5641|     29|            }
 5642|  6.73k|            if (dp->tdir_count > UINT64_MAX / typewidth)
  ------------------
  |  Branch (5642:17): [True: 1, False: 6.73k]
  ------------------
 5643|      1|                return -1;
 5644|  6.73k|            datasize = (uint64_t)typewidth * dp->tdir_count;
 5645|  6.73k|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  6.73k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (5645:17): [True: 6.57k, False: 156]
  ------------------
 5646|  6.57k|            {
 5647|  6.57k|                if (datasize <= 4)
  ------------------
  |  Branch (5647:21): [True: 4.79k, False: 1.78k]
  ------------------
 5648|  4.79k|                    datasize = 0;
 5649|  6.57k|            }
 5650|    156|            else
 5651|    156|            {
 5652|    156|                if (datasize <= 8)
  ------------------
  |  Branch (5652:21): [True: 115, False: 41]
  ------------------
 5653|    115|                    datasize = 0;
 5654|    156|            }
 5655|  6.73k|            if (space > UINT64_MAX - datasize)
  ------------------
  |  Branch (5655:17): [True: 5, False: 6.72k]
  ------------------
 5656|      5|                return -1;
 5657|  6.72k|            space += datasize;
 5658|  6.72k|        }
 5659|    356|        if (filesize == 0)
  ------------------
  |  Branch (5659:13): [True: 356, False: 0]
  ------------------
 5660|    356|            filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|    356|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 5661|    356|        if (filesize < space)
  ------------------
  |  Branch (5661:13): [True: 319, False: 37]
  ------------------
 5662|       |            /* we should perhaps return in error ? */
 5663|    319|            space = filesize;
 5664|     37|        else
 5665|     37|            space = filesize - space;
 5666|    356|        if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    356|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5666:13): [True: 0, False: 356]
  ------------------
 5667|      0|            space /= td->td_samplesperpixel;
 5668|    712|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5668:25): [True: 356, False: 356]
  ------------------
 5669|    356|            td->td_stripbytecount_p[strip] = space;
 5670|       |        /*
 5671|       |         * This gross hack handles the case were the offset to
 5672|       |         * the last strip is past the place where we think the strip
 5673|       |         * should begin.  Since a strip of data must be contiguous,
 5674|       |         * it's safe to assume that we've overestimated the amount
 5675|       |         * of data in the strip and trim this number back accordingly.
 5676|       |         */
 5677|    356|        strip--;
 5678|    356|        if (td->td_stripoffset_p[strip] >
  ------------------
  |  Branch (5678:13): [True: 0, False: 356]
  ------------------
 5679|    356|            UINT64_MAX - td->td_stripbytecount_p[strip])
 5680|      0|            return -1;
 5681|    356|        if (td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip] >
  ------------------
  |  Branch (5681:13): [True: 317, False: 39]
  ------------------
 5682|    356|            filesize)
 5683|    317|        {
 5684|    317|            if (td->td_stripoffset_p[strip] >= filesize)
  ------------------
  |  Branch (5684:17): [True: 3, False: 314]
  ------------------
 5685|      3|            {
 5686|       |                /* Not sure what we should in that case... */
 5687|      3|                td->td_stripbytecount_p[strip] = 0;
 5688|      3|            }
 5689|    314|            else
 5690|    314|            {
 5691|    314|                td->td_stripbytecount_p[strip] =
 5692|    314|                    filesize - td->td_stripoffset_p[strip];
 5693|    314|            }
 5694|    317|        }
 5695|    356|    }
 5696|    101|    else if (isTiled(tif))
  ------------------
  |  |  278|    101|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    101|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 1, False: 100]
  |  |  ------------------
  ------------------
 5697|      1|    {
 5698|      1|        uint64_t bytespertile = TIFFTileSize64(tif);
 5699|       |
 5700|    339|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5700:25): [True: 338, False: 1]
  ------------------
 5701|    338|            td->td_stripbytecount_p[strip] = bytespertile;
 5702|      1|    }
 5703|    100|    else
 5704|    100|    {
 5705|    100|        uint64_t rowbytes = TIFFScanlineSize64(tif);
 5706|    100|        uint32_t rowsperstrip = td->td_imagelength / td->td_stripsperimage;
 5707|  2.27k|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5707:25): [True: 2.17k, False: 100]
  ------------------
 5708|  2.17k|        {
 5709|  2.17k|            if (rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes)
  ------------------
  |  Branch (5709:17): [True: 2.15k, False: 12]
  |  Branch (5709:33): [True: 0, False: 2.15k]
  ------------------
 5710|      0|                return -1;
 5711|  2.17k|            td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip;
 5712|  2.17k|        }
 5713|    100|    }
 5714|    457|    TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
  ------------------
  |  |  249|    457|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|    457|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|    457|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 5715|    457|    if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
  ------------------
  |  |  248|    457|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    457|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    457|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5715:9): [True: 289, False: 168]
  ------------------
 5716|    289|        td->td_rowsperstrip = td->td_imagelength;
 5717|    457|    return 1;
 5718|    492|}
tif_dirread.c:MissingRequired:
 5721|    121|{
 5722|    121|    static const char module[] = "MissingRequired";
 5723|       |
 5724|    121|    TIFFErrorExtR(tif, module,
 5725|    121|                  "TIFF directory is missing required \"%s\" field", tagname);
 5726|    121|}
tif_dirread.c:hashFuncOffsetToNumber:
 5729|  11.4k|{
 5730|  11.4k|    const TIFFOffsetAndDirNumber *offsetAndDirNumber =
 5731|  11.4k|        (const TIFFOffsetAndDirNumber *)elt;
 5732|  11.4k|    const uint32_t hash = (uint32_t)(offsetAndDirNumber->offset >> 32) ^
 5733|  11.4k|                          ((uint32_t)offsetAndDirNumber->offset & 0xFFFFFFFFU);
 5734|  11.4k|    return hash;
 5735|  11.4k|}
tif_dirread.c:equalFuncOffsetToNumber:
 5738|     92|{
 5739|     92|    const TIFFOffsetAndDirNumber *offsetAndDirNumber1 =
 5740|     92|        (const TIFFOffsetAndDirNumber *)elt1;
 5741|     92|    const TIFFOffsetAndDirNumber *offsetAndDirNumber2 =
 5742|     92|        (const TIFFOffsetAndDirNumber *)elt2;
 5743|     92|    return offsetAndDirNumber1->offset == offsetAndDirNumber2->offset;
 5744|     92|}
tif_dirread.c:hashFuncNumberToOffset:
 5747|  11.4k|{
 5748|  11.4k|    const TIFFOffsetAndDirNumber *offsetAndDirNumber =
 5749|  11.4k|        (const TIFFOffsetAndDirNumber *)elt;
 5750|  11.4k|    return offsetAndDirNumber->dirNumber;
 5751|  11.4k|}
tif_dirread.c:TIFFFetchDirectory:
 6087|  3.82k|{
 6088|  3.82k|    static const char module[] = "TIFFFetchDirectory";
 6089|       |
 6090|  3.82k|    void *origdir;
 6091|  3.82k|    uint16_t dircount16;
 6092|  3.82k|    uint32_t dirsize;
 6093|  3.82k|    TIFFDirEntry *dir;
 6094|  3.82k|    uint8_t *ma;
 6095|  3.82k|    TIFFDirEntry *mb;
 6096|  3.82k|    uint16_t n;
 6097|       |
 6098|  3.82k|    assert(pdir);
  ------------------
  |  Branch (6098:5): [True: 0, False: 3.82k]
  |  Branch (6098:5): [True: 3.82k, False: 0]
  ------------------
 6099|       |
 6100|  3.82k|    tif->tif_diroff = diroff;
 6101|  3.82k|    if (nextdiroff)
  ------------------
  |  Branch (6101:9): [True: 3.82k, False: 0]
  ------------------
 6102|  3.82k|        *nextdiroff = 0;
 6103|  3.82k|    if (!isMapped(tif))
  ------------------
  |  |  279|  3.82k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  3.82k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (6103:9): [True: 3.82k, False: 0]
  ------------------
 6104|  3.82k|    {
 6105|  3.82k|        if (!SeekOK(tif, tif->tif_diroff))
  ------------------
  |  |  303|  3.82k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (6105:13): [True: 727, False: 3.09k]
  ------------------
 6106|    727|        {
 6107|    727|            TIFFErrorExtR(tif, module,
 6108|    727|                          "%s: Seek error accessing TIFF directory",
 6109|    727|                          tif->tif_name);
 6110|    727|            return 0;
 6111|    727|        }
 6112|  3.09k|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  3.09k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6112:13): [True: 2.84k, False: 255]
  ------------------
 6113|  2.84k|        {
 6114|  2.84k|            if (!ReadOK(tif, &dircount16, sizeof(uint16_t)))
  ------------------
  |  |  300|  2.84k|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|  2.84k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6114:17): [True: 1, False: 2.84k]
  ------------------
 6115|      1|            {
 6116|      1|                TIFFErrorExtR(tif, module,
 6117|      1|                              "%s: Can not read TIFF directory count",
 6118|      1|                              tif->tif_name);
 6119|      1|                return 0;
 6120|      1|            }
 6121|  2.84k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  2.84k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6121:17): [True: 2, False: 2.84k]
  ------------------
 6122|      2|                TIFFSwabShort(&dircount16);
 6123|  2.84k|            if (dircount16 > 4096)
  ------------------
  |  Branch (6123:17): [True: 30, False: 2.81k]
  ------------------
 6124|     30|            {
 6125|     30|                TIFFErrorExtR(tif, module,
 6126|     30|                              "Sanity check on directory count failed, this is "
 6127|     30|                              "probably not a valid IFD offset");
 6128|     30|                return 0;
 6129|     30|            }
 6130|  2.81k|            dirsize = 12;
 6131|  2.81k|        }
 6132|    255|        else
 6133|    255|        {
 6134|    255|            uint64_t dircount64;
 6135|    255|            if (!ReadOK(tif, &dircount64, sizeof(uint64_t)))
  ------------------
  |  |  300|    255|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    255|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6135:17): [True: 0, False: 255]
  ------------------
 6136|      0|            {
 6137|      0|                TIFFErrorExtR(tif, module,
 6138|      0|                              "%s: Can not read TIFF directory count",
 6139|      0|                              tif->tif_name);
 6140|      0|                return 0;
 6141|      0|            }
 6142|    255|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    255|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6142:17): [True: 0, False: 255]
  ------------------
 6143|      0|                TIFFSwabLong8(&dircount64);
 6144|    255|            if (dircount64 > 4096)
  ------------------
  |  Branch (6144:17): [True: 0, False: 255]
  ------------------
 6145|      0|            {
 6146|      0|                TIFFErrorExtR(tif, module,
 6147|      0|                              "Sanity check on directory count failed, this is "
 6148|      0|                              "probably not a valid IFD offset");
 6149|      0|                return 0;
 6150|      0|            }
 6151|    255|            dircount16 = (uint16_t)dircount64;
 6152|    255|            dirsize = 20;
 6153|    255|        }
 6154|  3.06k|        origdir = _TIFFCheckMalloc(tif, dircount16, dirsize,
 6155|  3.06k|                                   "to read TIFF directory");
 6156|  3.06k|        if (origdir == NULL)
  ------------------
  |  Branch (6156:13): [True: 58, False: 3.01k]
  ------------------
 6157|     58|            return 0;
 6158|  3.01k|        if (!ReadOK(tif, origdir, (tmsize_t)dircount16 * dirsize))
  ------------------
  |  |  300|  3.01k|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|  3.01k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6158:13): [True: 8, False: 3.00k]
  ------------------
 6159|      8|        {
 6160|      8|            TIFFErrorExtR(tif, module, "%.100s: Can not read TIFF directory",
 6161|      8|                          tif->tif_name);
 6162|      8|            _TIFFfreeExt(tif, origdir);
 6163|      8|            return 0;
 6164|      8|        }
 6165|       |        /*
 6166|       |         * Read offset to next directory for sequential scans if
 6167|       |         * needed.
 6168|       |         */
 6169|  3.00k|        if (nextdiroff)
  ------------------
  |  Branch (6169:13): [True: 3.00k, False: 0]
  ------------------
 6170|  3.00k|        {
 6171|  3.00k|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  3.00k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6171:17): [True: 2.74k, False: 255]
  ------------------
 6172|  2.74k|            {
 6173|  2.74k|                uint32_t nextdiroff32;
 6174|  2.74k|                if (!ReadOK(tif, &nextdiroff32, sizeof(uint32_t)))
  ------------------
  |  |  300|  2.74k|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|  2.74k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6174:21): [True: 4, False: 2.74k]
  ------------------
 6175|      4|                    nextdiroff32 = 0;
 6176|  2.74k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  2.74k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6176:21): [True: 2, False: 2.74k]
  ------------------
 6177|      2|                    TIFFSwabLong(&nextdiroff32);
 6178|  2.74k|                *nextdiroff = nextdiroff32;
 6179|  2.74k|            }
 6180|    255|            else
 6181|    255|            {
 6182|    255|                if (!ReadOK(tif, nextdiroff, sizeof(uint64_t)))
  ------------------
  |  |  300|    255|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    255|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6182:21): [True: 21, False: 234]
  ------------------
 6183|     21|                    *nextdiroff = 0;
 6184|    255|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    255|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6184:21): [True: 0, False: 255]
  ------------------
 6185|      0|                    TIFFSwabLong8(nextdiroff);
 6186|    255|            }
 6187|  3.00k|        }
 6188|  3.00k|    }
 6189|      0|    else
 6190|      0|    {
 6191|      0|        tmsize_t m;
 6192|      0|        tmsize_t off;
 6193|      0|        if (tif->tif_diroff > (uint64_t)INT64_MAX)
  ------------------
  |  Branch (6193:13): [True: 0, False: 0]
  ------------------
 6194|      0|        {
 6195|      0|            TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
 6196|      0|            return (0);
 6197|      0|        }
 6198|      0|        off = (tmsize_t)tif->tif_diroff;
 6199|       |
 6200|       |        /*
 6201|       |         * Check for integer overflow when validating the dir_off,
 6202|       |         * otherwise a very high offset may cause an OOB read and
 6203|       |         * crash the client. Make two comparisons instead of
 6204|       |         *
 6205|       |         *  off + sizeof(uint16_t) > tif->tif_size
 6206|       |         *
 6207|       |         * to avoid overflow.
 6208|       |         */
 6209|      0|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6209:13): [True: 0, False: 0]
  ------------------
 6210|      0|        {
 6211|      0|            m = (tmsize_t)((uint64_t)off + sizeof(uint16_t));
 6212|      0|            if ((m < off) || ((uint64_t)m < sizeof(uint16_t)) ||
  ------------------
  |  Branch (6212:17): [True: 0, False: 0]
  |  Branch (6212:30): [True: 0, False: 0]
  ------------------
 6213|      0|                ((uint64_t)m > (uint64_t)tif->tif_size))
  ------------------
  |  Branch (6213:17): [True: 0, False: 0]
  ------------------
 6214|      0|            {
 6215|      0|                TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
 6216|      0|                return 0;
 6217|      0|            }
 6218|      0|            else
 6219|      0|            {
 6220|      0|                _TIFFmemcpy(&dircount16, tif->tif_base + off, sizeof(uint16_t));
 6221|      0|            }
 6222|      0|            off = (tmsize_t)((uint64_t)off + sizeof(uint16_t));
 6223|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6223:17): [True: 0, False: 0]
  ------------------
 6224|      0|                TIFFSwabShort(&dircount16);
 6225|      0|            if (dircount16 > 4096)
  ------------------
  |  Branch (6225:17): [True: 0, False: 0]
  ------------------
 6226|      0|            {
 6227|      0|                TIFFErrorExtR(tif, module,
 6228|      0|                              "Sanity check on directory count failed, this is "
 6229|      0|                              "probably not a valid IFD offset");
 6230|      0|                return 0;
 6231|      0|            }
 6232|      0|            dirsize = 12;
 6233|      0|        }
 6234|      0|        else
 6235|      0|        {
 6236|      0|            uint64_t dircount64;
 6237|      0|            m = (tmsize_t)((uint64_t)off + sizeof(uint64_t));
 6238|      0|            if ((m < off) || ((uint64_t)m < sizeof(uint64_t)) ||
  ------------------
  |  Branch (6238:17): [True: 0, False: 0]
  |  Branch (6238:30): [True: 0, False: 0]
  ------------------
 6239|      0|                ((uint64_t)m > (uint64_t)tif->tif_size))
  ------------------
  |  Branch (6239:17): [True: 0, False: 0]
  ------------------
 6240|      0|            {
 6241|      0|                TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
 6242|      0|                return 0;
 6243|      0|            }
 6244|      0|            else
 6245|      0|            {
 6246|      0|                _TIFFmemcpy(&dircount64, tif->tif_base + off, sizeof(uint64_t));
 6247|      0|            }
 6248|      0|            off = (tmsize_t)((uint64_t)off + sizeof(uint64_t));
 6249|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6249:17): [True: 0, False: 0]
  ------------------
 6250|      0|                TIFFSwabLong8(&dircount64);
 6251|      0|            if (dircount64 > 4096)
  ------------------
  |  Branch (6251:17): [True: 0, False: 0]
  ------------------
 6252|      0|            {
 6253|      0|                TIFFErrorExtR(tif, module,
 6254|      0|                              "Sanity check on directory count failed, this is "
 6255|      0|                              "probably not a valid IFD offset");
 6256|      0|                return 0;
 6257|      0|            }
 6258|      0|            dircount16 = (uint16_t)dircount64;
 6259|      0|            dirsize = 20;
 6260|      0|        }
 6261|      0|        if (dircount16 == 0)
  ------------------
  |  Branch (6261:13): [True: 0, False: 0]
  ------------------
 6262|      0|        {
 6263|      0|            TIFFErrorExtR(tif, module,
 6264|      0|                          "Sanity check on directory count failed, zero tag "
 6265|      0|                          "directories not supported");
 6266|      0|            return 0;
 6267|      0|        }
 6268|       |        /* Before allocating a huge amount of memory for corrupted files, check
 6269|       |         * if size of requested memory is not greater than file size. */
 6270|      0|        uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      0|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 6271|      0|        uint64_t allocsize = (uint64_t)dircount16 * dirsize;
 6272|      0|        if (allocsize > filesize)
  ------------------
  |  Branch (6272:13): [True: 0, False: 0]
  ------------------
 6273|      0|        {
 6274|      0|            TIFFWarningExtR(
 6275|      0|                tif, module,
 6276|      0|                "Requested memory size for TIFF directory of %" PRIu64
 6277|      0|                " is greater than filesize %" PRIu64
 6278|      0|                ". Memory not allocated, TIFF directory not read",
 6279|      0|                allocsize, filesize);
 6280|      0|            return 0;
 6281|      0|        }
 6282|      0|        origdir = _TIFFCheckMalloc(tif, dircount16, dirsize,
 6283|      0|                                   "to read TIFF directory");
 6284|      0|        if (origdir == NULL)
  ------------------
  |  Branch (6284:13): [True: 0, False: 0]
  ------------------
 6285|      0|            return 0;
 6286|      0|        m = off + dircount16 * dirsize;
 6287|      0|        if ((m < off) || (m < (tmsize_t)dircount16 * (tmsize_t)dirsize) ||
  ------------------
  |  Branch (6287:13): [True: 0, False: 0]
  |  Branch (6287:26): [True: 0, False: 0]
  ------------------
 6288|      0|            (m > tif->tif_size))
  ------------------
  |  Branch (6288:13): [True: 0, False: 0]
  ------------------
 6289|      0|        {
 6290|      0|            TIFFErrorExtR(tif, module, "Can not read TIFF directory");
 6291|      0|            _TIFFfreeExt(tif, origdir);
 6292|      0|            return 0;
 6293|      0|        }
 6294|      0|        else
 6295|      0|        {
 6296|      0|            _TIFFmemcpy(origdir, tif->tif_base + off,
 6297|      0|                        (tmsize_t)dircount16 * dirsize);
 6298|      0|        }
 6299|      0|        if (nextdiroff)
  ------------------
  |  Branch (6299:13): [True: 0, False: 0]
  ------------------
 6300|      0|        {
 6301|      0|            off += dircount16 * dirsize;
 6302|      0|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6302:17): [True: 0, False: 0]
  ------------------
 6303|      0|            {
 6304|      0|                uint32_t nextdiroff32;
 6305|      0|                m = (tmsize_t)((uint64_t)off + sizeof(uint32_t));
 6306|      0|                if ((m < off) || ((uint64_t)m < sizeof(uint32_t)) ||
  ------------------
  |  Branch (6306:21): [True: 0, False: 0]
  |  Branch (6306:34): [True: 0, False: 0]
  ------------------
 6307|      0|                    ((uint64_t)m > (uint64_t)tif->tif_size))
  ------------------
  |  Branch (6307:21): [True: 0, False: 0]
  ------------------
 6308|      0|                    nextdiroff32 = 0;
 6309|      0|                else
 6310|      0|                    _TIFFmemcpy(&nextdiroff32, tif->tif_base + off,
 6311|      0|                                sizeof(uint32_t));
 6312|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6312:21): [True: 0, False: 0]
  ------------------
 6313|      0|                    TIFFSwabLong(&nextdiroff32);
 6314|      0|                *nextdiroff = nextdiroff32;
 6315|      0|            }
 6316|      0|            else
 6317|      0|            {
 6318|      0|                m = (tmsize_t)((uint64_t)off + sizeof(uint64_t));
 6319|      0|                if ((m < off) || ((uint64_t)m < sizeof(uint64_t)) ||
  ------------------
  |  Branch (6319:21): [True: 0, False: 0]
  |  Branch (6319:34): [True: 0, False: 0]
  ------------------
 6320|      0|                    ((uint64_t)m > (uint64_t)tif->tif_size))
  ------------------
  |  Branch (6320:21): [True: 0, False: 0]
  ------------------
 6321|      0|                    *nextdiroff = 0;
 6322|      0|                else
 6323|      0|                    _TIFFmemcpy(nextdiroff, tif->tif_base + off,
 6324|      0|                                sizeof(uint64_t));
 6325|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6325:21): [True: 0, False: 0]
  ------------------
 6326|      0|                    TIFFSwabLong8(nextdiroff);
 6327|      0|            }
 6328|      0|        }
 6329|      0|    }
 6330|       |    /* No check against filesize needed here because "dir" should have same size
 6331|       |     * than "origdir" checked above. */
 6332|  3.00k|    dir = (TIFFDirEntry *)_TIFFCheckMalloc(
 6333|  3.00k|        tif, dircount16, sizeof(TIFFDirEntry), "to read TIFF directory");
 6334|  3.00k|    if (dir == 0)
  ------------------
  |  Branch (6334:9): [True: 0, False: 3.00k]
  ------------------
 6335|      0|    {
 6336|      0|        _TIFFfreeExt(tif, origdir);
 6337|      0|        return 0;
 6338|      0|    }
 6339|  3.00k|    ma = (uint8_t *)origdir;
 6340|  3.00k|    mb = dir;
 6341|   487k|    for (n = 0; n < dircount16; n++)
  ------------------
  |  Branch (6341:17): [True: 484k, False: 3.00k]
  ------------------
 6342|   484k|    {
 6343|   484k|        mb->tdir_ignore = FALSE;
  ------------------
  |  |   72|   484k|#define FALSE 0
  ------------------
 6344|   484k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|   484k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6344:13): [True: 2.07k, False: 482k]
  ------------------
 6345|  2.07k|            TIFFSwabShort((uint16_t *)ma);
 6346|   484k|        mb->tdir_tag = *(uint16_t *)ma;
 6347|   484k|        ma += sizeof(uint16_t);
 6348|   484k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|   484k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6348:13): [True: 2.07k, False: 482k]
  ------------------
 6349|  2.07k|            TIFFSwabShort((uint16_t *)ma);
 6350|   484k|        mb->tdir_type = *(uint16_t *)ma;
 6351|   484k|        ma += sizeof(uint16_t);
 6352|   484k|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|   484k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6352:13): [True: 439k, False: 45.2k]
  ------------------
 6353|   439k|        {
 6354|   439k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|   439k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6354:17): [True: 2.07k, False: 437k]
  ------------------
 6355|  2.07k|                TIFFSwabLong((uint32_t *)ma);
 6356|   439k|            mb->tdir_count = (uint64_t)(*(uint32_t *)ma);
 6357|   439k|            ma += sizeof(uint32_t);
 6358|   439k|            mb->tdir_offset.toff_long8 = 0;
 6359|   439k|            *(uint32_t *)(&mb->tdir_offset) = *(uint32_t *)ma;
 6360|   439k|            ma += sizeof(uint32_t);
 6361|   439k|        }
 6362|  45.2k|        else
 6363|  45.2k|        {
 6364|  45.2k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  45.2k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6364:17): [True: 0, False: 45.2k]
  ------------------
 6365|      0|                TIFFSwabLong8((uint64_t *)ma);
 6366|  45.2k|            mb->tdir_count = TIFFReadUInt64(ma);
 6367|  45.2k|            ma += sizeof(uint64_t);
 6368|  45.2k|            mb->tdir_offset.toff_long8 = TIFFReadUInt64(ma);
 6369|  45.2k|            ma += sizeof(uint64_t);
 6370|  45.2k|        }
 6371|   484k|        mb++;
 6372|   484k|    }
 6373|  3.00k|    _TIFFfreeExt(tif, origdir);
 6374|  3.00k|    *pdir = dir;
 6375|  3.00k|    return dircount16;
 6376|  3.00k|}
tif_dirread.c:TIFFReadUInt64:
  283|  90.4k|{
  284|  90.4k|    UInt64Aligned_t result;
  285|       |
  286|  90.4k|    result.c[0] = value[0];
  287|  90.4k|    result.c[1] = value[1];
  288|  90.4k|    result.c[2] = value[2];
  289|  90.4k|    result.c[3] = value[3];
  290|  90.4k|    result.c[4] = value[4];
  291|  90.4k|    result.c[5] = value[5];
  292|  90.4k|    result.c[6] = value[6];
  293|  90.4k|    result.c[7] = value[7];
  294|       |
  295|  90.4k|    return result.l;
  296|  90.4k|}
tif_dirread.c:TIFFFetchNormalTag:
 6382|   207k|{
 6383|   207k|    static const char module[] = "TIFFFetchNormalTag";
 6384|   207k|    enum TIFFReadDirEntryErr err;
 6385|   207k|    uint32_t fii;
 6386|   207k|    const TIFFField *fip = NULL;
 6387|   207k|    TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 6388|   207k|    if (fii == FAILED_FII)
  ------------------
  |  |   44|   207k|#define FAILED_FII ((uint32_t)-1)
  ------------------
  |  Branch (6388:9): [True: 0, False: 207k]
  ------------------
 6389|      0|    {
 6390|      0|        TIFFErrorExtR(tif, "TIFFFetchNormalTag",
 6391|      0|                      "No definition found for tag %" PRIu16, dp->tdir_tag);
 6392|      0|        return 0;
 6393|      0|    }
 6394|   207k|    fip = tif->tif_fields[fii];
 6395|   207k|    assert(fip != NULL); /* should not happen */
  ------------------
  |  Branch (6395:5): [True: 0, False: 207k]
  |  Branch (6395:5): [True: 207k, False: 0]
  ------------------
 6396|   207k|    assert(fip->set_get_field_type !=
  ------------------
  |  Branch (6396:5): [True: 0, False: 207k]
  |  Branch (6396:5): [True: 207k, False: 0]
  ------------------
 6397|   207k|           TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with
 6398|       |                                  this in specialized code */
 6399|   207k|    assert(fip->set_get_field_type !=
  ------------------
  |  Branch (6399:5): [True: 0, False: 207k]
  |  Branch (6399:5): [True: 207k, False: 0]
  ------------------
 6400|   207k|           TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only
 6401|       |                                the case for pseudo-tags */
 6402|   207k|    err = TIFFReadDirEntryErrOk;
 6403|   207k|    switch (fip->set_get_field_type)
 6404|   207k|    {
 6405|   157k|        case TIFF_SETGET_UNDEFINED:
  ------------------
  |  Branch (6405:9): [True: 157k, False: 50.1k]
  ------------------
 6406|   157k|            TIFFErrorExtR(
 6407|   157k|                tif, "TIFFFetchNormalTag",
 6408|   157k|                "Defined set_get_field_type of custom tag %u (%s) is "
 6409|   157k|                "TIFF_SETGET_UNDEFINED and thus tag is not read from file",
 6410|   157k|                fip->field_tag, fip->field_name);
 6411|   157k|            break;
 6412|  2.97k|        case TIFF_SETGET_ASCII:
  ------------------
  |  Branch (6412:9): [True: 2.97k, False: 204k]
  ------------------
 6413|  2.97k|        {
 6414|  2.97k|            uint8_t *data;
 6415|  2.97k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6415:13): [True: 0, False: 2.97k]
  |  Branch (6415:13): [True: 2.97k, False: 0]
  ------------------
 6416|  2.97k|            err = TIFFReadDirEntryByteArray(tif, dp, &data);
 6417|  2.97k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6417:17): [True: 1.40k, False: 1.57k]
  ------------------
 6418|  1.40k|            {
 6419|  1.40k|                size_t mb = 0;
 6420|  1.40k|                int n;
 6421|  1.40k|                if (data != NULL)
  ------------------
  |  Branch (6421:21): [True: 1.34k, False: 60]
  ------------------
 6422|  1.34k|                {
 6423|  1.34k|                    if (dp->tdir_count > 0 && data[dp->tdir_count - 1] == 0)
  ------------------
  |  Branch (6423:25): [True: 1.34k, False: 0]
  |  Branch (6423:47): [True: 886, False: 463]
  ------------------
 6424|    886|                    {
 6425|       |                        /* optimization: if data is known to be 0 terminated, we
 6426|       |                         * can use strlen() */
 6427|    886|                        mb = strlen((const char *)data);
 6428|    886|                    }
 6429|    463|                    else
 6430|    463|                    {
 6431|       |                        /* general case. equivalent to non-portable */
 6432|       |                        /* mb = strnlen((const char*)data,
 6433|       |                         * (uint32_t)dp->tdir_count); */
 6434|    463|                        uint8_t *ma = data;
 6435|  1.14k|                        while (mb < (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6435:32): [True: 929, False: 212]
  ------------------
 6436|    929|                        {
 6437|    929|                            if (*ma == 0)
  ------------------
  |  Branch (6437:33): [True: 251, False: 678]
  ------------------
 6438|    251|                                break;
 6439|    678|                            ma++;
 6440|    678|                            mb++;
 6441|    678|                        }
 6442|    463|                    }
 6443|  1.34k|                }
 6444|  1.40k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6444:21): [True: 1, False: 1.40k]
  ------------------
 6445|      1|                {
 6446|      1|                    if (data != NULL)
  ------------------
  |  Branch (6446:25): [True: 1, False: 0]
  ------------------
 6447|      1|                        _TIFFfreeExt(tif, data);
 6448|      1|                    return (0);
 6449|      1|                }
 6450|  1.40k|                if (mb + 1 < (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6450:21): [True: 1.13k, False: 276]
  ------------------
 6451|  1.13k|                    TIFFWarningExtR(
 6452|  1.13k|                        tif, module,
 6453|  1.13k|                        "ASCII value for tag \"%s\" contains null byte in "
 6454|  1.13k|                        "value; value incorrectly truncated during reading due "
 6455|  1.13k|                        "to implementation limitations",
 6456|  1.13k|                        fip->field_name);
 6457|    276|                else if (mb + 1 > (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6457:26): [True: 272, False: 4]
  ------------------
 6458|    272|                {
 6459|    272|                    TIFFWarningExtR(tif, module,
 6460|    272|                                    "ASCII value for tag \"%s\" does not end "
 6461|    272|                                    "in null byte. Forcing it to be null",
 6462|    272|                                    fip->field_name);
 6463|       |                    /* TIFFReadDirEntryArrayWithLimit() ensures this can't be
 6464|       |                     * larger than MAX_SIZE_TAG_DATA */
 6465|    272|                    assert((uint32_t)dp->tdir_count + 1 == dp->tdir_count + 1);
  ------------------
  |  Branch (6465:21): [True: 0, False: 272]
  |  Branch (6465:21): [True: 272, False: 0]
  ------------------
 6466|    272|                    uint8_t *o = (uint8_t *)_TIFFmallocExt(
 6467|    272|                        tif, (uint32_t)dp->tdir_count + 1);
 6468|    272|                    if (o == NULL)
  ------------------
  |  Branch (6468:25): [True: 0, False: 272]
  ------------------
 6469|      0|                    {
 6470|      0|                        if (data != NULL)
  ------------------
  |  Branch (6470:29): [True: 0, False: 0]
  ------------------
 6471|      0|                            _TIFFfreeExt(tif, data);
 6472|      0|                        return (0);
 6473|      0|                    }
 6474|    272|                    if (dp->tdir_count > 0)
  ------------------
  |  Branch (6474:25): [True: 212, False: 60]
  ------------------
 6475|    212|                    {
 6476|    212|                        _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 6477|    212|                    }
 6478|    272|                    o[(uint32_t)dp->tdir_count] = 0;
 6479|    272|                    if (data != 0)
  ------------------
  |  Branch (6479:25): [True: 212, False: 60]
  ------------------
 6480|    212|                        _TIFFfreeExt(tif, data);
 6481|    272|                    data = o;
 6482|    272|                }
 6483|  1.40k|                n = TIFFSetField(tif, dp->tdir_tag, data);
 6484|  1.40k|                if (data != 0)
  ------------------
  |  Branch (6484:21): [True: 1.40k, False: 0]
  ------------------
 6485|  1.40k|                    _TIFFfreeExt(tif, data);
 6486|  1.40k|                if (!n)
  ------------------
  |  Branch (6486:21): [True: 0, False: 1.40k]
  ------------------
 6487|      0|                    return (0);
 6488|  1.40k|            }
 6489|  2.97k|        }
 6490|  2.97k|        break;
 6491|  2.97k|        case TIFF_SETGET_UINT8:
  ------------------
  |  Branch (6491:9): [True: 274, False: 207k]
  ------------------
 6492|    274|        {
 6493|    274|            uint8_t data = 0;
 6494|    274|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6494:13): [True: 0, False: 274]
  |  Branch (6494:13): [True: 274, False: 0]
  ------------------
 6495|    274|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6495:13): [True: 0, False: 274]
  |  Branch (6495:13): [True: 274, False: 0]
  ------------------
 6496|    274|            err = TIFFReadDirEntryByte(tif, dp, &data);
 6497|    274|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6497:17): [True: 169, False: 105]
  ------------------
 6498|    169|            {
 6499|    169|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6499:21): [True: 0, False: 169]
  ------------------
 6500|      0|                    return (0);
 6501|    169|            }
 6502|    274|        }
 6503|    274|        break;
 6504|    274|        case TIFF_SETGET_SINT8:
  ------------------
  |  Branch (6504:9): [True: 0, False: 207k]
  ------------------
 6505|      0|        {
 6506|      0|            int8_t data = 0;
 6507|      0|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6507:13): [True: 0, False: 0]
  |  Branch (6507:13): [True: 0, False: 0]
  ------------------
 6508|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6508:13): [True: 0, False: 0]
  |  Branch (6508:13): [True: 0, False: 0]
  ------------------
 6509|      0|            err = TIFFReadDirEntrySbyte(tif, dp, &data);
 6510|      0|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6510:17): [True: 0, False: 0]
  ------------------
 6511|      0|            {
 6512|      0|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6512:21): [True: 0, False: 0]
  ------------------
 6513|      0|                    return (0);
 6514|      0|            }
 6515|      0|        }
 6516|      0|        break;
 6517|  10.6k|        case TIFF_SETGET_UINT16:
  ------------------
  |  Branch (6517:9): [True: 10.6k, False: 196k]
  ------------------
 6518|  10.6k|        {
 6519|  10.6k|            uint16_t data;
 6520|  10.6k|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6520:13): [True: 0, False: 10.6k]
  |  Branch (6520:13): [True: 10.6k, False: 0]
  ------------------
 6521|  10.6k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6521:13): [True: 0, False: 10.6k]
  |  Branch (6521:13): [True: 10.6k, False: 0]
  ------------------
 6522|  10.6k|            err = TIFFReadDirEntryShort(tif, dp, &data);
 6523|  10.6k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6523:17): [True: 7.16k, False: 3.47k]
  ------------------
 6524|  7.16k|            {
 6525|  7.16k|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6525:21): [True: 616, False: 6.54k]
  ------------------
 6526|    616|                    return (0);
 6527|  7.16k|            }
 6528|  10.6k|        }
 6529|  10.0k|        break;
 6530|  10.0k|        case TIFF_SETGET_SINT16:
  ------------------
  |  Branch (6530:9): [True: 0, False: 207k]
  ------------------
 6531|      0|        {
 6532|      0|            int16_t data;
 6533|      0|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6533:13): [True: 0, False: 0]
  |  Branch (6533:13): [True: 0, False: 0]
  ------------------
 6534|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6534:13): [True: 0, False: 0]
  |  Branch (6534:13): [True: 0, False: 0]
  ------------------
 6535|      0|            err = TIFFReadDirEntrySshort(tif, dp, &data);
 6536|      0|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6536:17): [True: 0, False: 0]
  ------------------
 6537|      0|            {
 6538|      0|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6538:21): [True: 0, False: 0]
  ------------------
 6539|      0|                    return (0);
 6540|      0|            }
 6541|      0|        }
 6542|      0|        break;
 6543|  9.38k|        case TIFF_SETGET_UINT32:
  ------------------
  |  Branch (6543:9): [True: 9.38k, False: 198k]
  ------------------
 6544|  9.38k|        {
 6545|  9.38k|            uint32_t data;
 6546|  9.38k|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6546:13): [True: 0, False: 9.38k]
  |  Branch (6546:13): [True: 9.38k, False: 0]
  ------------------
 6547|  9.38k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6547:13): [True: 0, False: 9.38k]
  |  Branch (6547:13): [True: 9.38k, False: 0]
  ------------------
 6548|  9.38k|            err = TIFFReadDirEntryLong(tif, dp, &data);
 6549|  9.38k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6549:17): [True: 8.83k, False: 548]
  ------------------
 6550|  8.83k|            {
 6551|  8.83k|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6551:21): [True: 0, False: 8.83k]
  ------------------
 6552|      0|                    return (0);
 6553|  8.83k|            }
 6554|  9.38k|        }
 6555|  9.38k|        break;
 6556|  9.38k|        case TIFF_SETGET_SINT32:
  ------------------
  |  Branch (6556:9): [True: 0, False: 207k]
  ------------------
 6557|      0|        {
 6558|      0|            int32_t data;
 6559|      0|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6559:13): [True: 0, False: 0]
  |  Branch (6559:13): [True: 0, False: 0]
  ------------------
 6560|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6560:13): [True: 0, False: 0]
  |  Branch (6560:13): [True: 0, False: 0]
  ------------------
 6561|      0|            err = TIFFReadDirEntrySlong(tif, dp, &data);
 6562|      0|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6562:17): [True: 0, False: 0]
  ------------------
 6563|      0|            {
 6564|      0|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6564:21): [True: 0, False: 0]
  ------------------
 6565|      0|                    return (0);
 6566|      0|            }
 6567|      0|        }
 6568|      0|        break;
 6569|    467|        case TIFF_SETGET_UINT64:
  ------------------
  |  Branch (6569:9): [True: 467, False: 207k]
  ------------------
 6570|    467|        {
 6571|    467|            uint64_t data;
 6572|    467|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6572:13): [True: 0, False: 467]
  |  Branch (6572:13): [True: 467, False: 0]
  ------------------
 6573|    467|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6573:13): [True: 0, False: 467]
  |  Branch (6573:13): [True: 467, False: 0]
  ------------------
 6574|    467|            err = TIFFReadDirEntryLong8(tif, dp, &data);
 6575|    467|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6575:17): [True: 117, False: 350]
  ------------------
 6576|    117|            {
 6577|    117|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6577:21): [True: 0, False: 117]
  ------------------
 6578|      0|                    return 0;
 6579|    117|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6579:21): [True: 11, False: 106]
  ------------------
 6580|     11|                    return (0);
 6581|    117|            }
 6582|    467|        }
 6583|    456|        break;
 6584|    456|        case TIFF_SETGET_SINT64:
  ------------------
  |  Branch (6584:9): [True: 0, False: 207k]
  ------------------
 6585|      0|        {
 6586|      0|            int64_t data;
 6587|      0|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6587:13): [True: 0, False: 0]
  |  Branch (6587:13): [True: 0, False: 0]
  ------------------
 6588|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6588:13): [True: 0, False: 0]
  |  Branch (6588:13): [True: 0, False: 0]
  ------------------
 6589|      0|            err = TIFFReadDirEntrySlong8(tif, dp, &data);
 6590|      0|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6590:17): [True: 0, False: 0]
  ------------------
 6591|      0|            {
 6592|      0|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6592:21): [True: 0, False: 0]
  ------------------
 6593|      0|                    return 0;
 6594|      0|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6594:21): [True: 0, False: 0]
  ------------------
 6595|      0|                    return (0);
 6596|      0|            }
 6597|      0|        }
 6598|      0|        break;
 6599|  4.46k|        case TIFF_SETGET_FLOAT:
  ------------------
  |  Branch (6599:9): [True: 4.46k, False: 203k]
  ------------------
 6600|  4.46k|        {
 6601|  4.46k|            float data;
 6602|  4.46k|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6602:13): [True: 0, False: 4.46k]
  |  Branch (6602:13): [True: 4.46k, False: 0]
  ------------------
 6603|  4.46k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6603:13): [True: 0, False: 4.46k]
  |  Branch (6603:13): [True: 4.46k, False: 0]
  ------------------
 6604|  4.46k|            err = TIFFReadDirEntryFloat(tif, dp, &data);
 6605|  4.46k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6605:17): [True: 1.70k, False: 2.75k]
  ------------------
 6606|  1.70k|            {
 6607|  1.70k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6607:21): [True: 0, False: 1.70k]
  ------------------
 6608|      0|                    return 0;
 6609|  1.70k|                if (!TIFFSetField(tif, dp->tdir_tag, (double)data))
  ------------------
  |  Branch (6609:21): [True: 15, False: 1.69k]
  ------------------
 6610|     15|                    return (0);
 6611|  1.70k|            }
 6612|  4.46k|        }
 6613|  4.44k|        break;
 6614|  4.44k|        case TIFF_SETGET_DOUBLE:
  ------------------
  |  Branch (6614:9): [True: 68, False: 207k]
  ------------------
 6615|     68|        {
 6616|     68|            double data;
 6617|     68|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6617:13): [True: 0, False: 68]
  |  Branch (6617:13): [True: 68, False: 0]
  ------------------
 6618|     68|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6618:13): [True: 0, False: 68]
  |  Branch (6618:13): [True: 68, False: 0]
  ------------------
 6619|     68|            err = TIFFReadDirEntryDouble(tif, dp, &data);
 6620|     68|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6620:17): [True: 56, False: 12]
  ------------------
 6621|     56|            {
 6622|     56|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6622:21): [True: 0, False: 56]
  ------------------
 6623|      0|                    return 0;
 6624|     56|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6624:21): [True: 0, False: 56]
  ------------------
 6625|      0|                    return (0);
 6626|     56|            }
 6627|     68|        }
 6628|     68|        break;
 6629|    192|        case TIFF_SETGET_IFD8:
  ------------------
  |  Branch (6629:9): [True: 192, False: 207k]
  ------------------
 6630|    192|        {
 6631|    192|            uint64_t data;
 6632|    192|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6632:13): [True: 0, False: 192]
  |  Branch (6632:13): [True: 192, False: 0]
  ------------------
 6633|    192|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6633:13): [True: 0, False: 192]
  |  Branch (6633:13): [True: 192, False: 0]
  ------------------
 6634|    192|            err = TIFFReadDirEntryIfd8(tif, dp, &data);
 6635|    192|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6635:17): [True: 39, False: 153]
  ------------------
 6636|     39|            {
 6637|     39|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6637:21): [True: 0, False: 39]
  ------------------
 6638|      0|                    return 0;
 6639|     39|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6639:21): [True: 12, False: 27]
  ------------------
 6640|     12|                    return (0);
 6641|     39|            }
 6642|    192|        }
 6643|    180|        break;
 6644|  1.55k|        case TIFF_SETGET_UINT16_PAIR:
  ------------------
  |  Branch (6644:9): [True: 1.55k, False: 205k]
  ------------------
 6645|  1.55k|        {
 6646|  1.55k|            uint16_t *data;
 6647|  1.55k|            assert(fip->field_readcount == 2);
  ------------------
  |  Branch (6647:13): [True: 0, False: 1.55k]
  |  Branch (6647:13): [True: 1.55k, False: 0]
  ------------------
 6648|  1.55k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6648:13): [True: 0, False: 1.55k]
  |  Branch (6648:13): [True: 1.55k, False: 0]
  ------------------
 6649|  1.55k|            if (dp->tdir_count != 2)
  ------------------
  |  Branch (6649:17): [True: 1.07k, False: 477]
  ------------------
 6650|  1.07k|            {
 6651|  1.07k|                TIFFWarningExtR(tif, module,
 6652|  1.07k|                                "incorrect count for field \"%s\", expected 2, "
 6653|  1.07k|                                "got %" PRIu64,
 6654|  1.07k|                                fip->field_name, dp->tdir_count);
 6655|  1.07k|                return (0);
 6656|  1.07k|            }
 6657|    477|            err = TIFFReadDirEntryShortArray(tif, dp, &data);
 6658|    477|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6658:17): [True: 445, False: 32]
  ------------------
 6659|    445|            {
 6660|    445|                int m;
 6661|    445|                assert(data); /* avoid CLang static Analyzer false positive */
  ------------------
  |  Branch (6661:17): [True: 0, False: 445]
  |  Branch (6661:17): [True: 445, False: 0]
  ------------------
 6662|    445|                m = TIFFSetField(tif, dp->tdir_tag, data[0], data[1]);
 6663|    445|                _TIFFfreeExt(tif, data);
 6664|    445|                if (!m)
  ------------------
  |  Branch (6664:21): [True: 0, False: 445]
  ------------------
 6665|      0|                    return (0);
 6666|    445|            }
 6667|    477|        }
 6668|    477|        break;
 6669|    477|        case TIFF_SETGET_C0_UINT8:
  ------------------
  |  Branch (6669:9): [True: 33, False: 207k]
  ------------------
 6670|     33|        {
 6671|     33|            uint8_t *data;
 6672|     33|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6672:13): [True: 0, False: 33]
  |  Branch (6672:13): [True: 33, False: 0]
  ------------------
 6673|     33|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6673:13): [True: 0, False: 33]
  |  Branch (6673:13): [True: 33, False: 0]
  ------------------
 6674|     33|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6674:17): [True: 25, False: 8]
  ------------------
 6675|     25|            {
 6676|     25|                TIFFWarningExtR(tif, module,
 6677|     25|                                "incorrect count for field \"%s\", expected "
 6678|     25|                                "%d, got %" PRIu64,
 6679|     25|                                fip->field_name, (int)fip->field_readcount,
 6680|     25|                                dp->tdir_count);
 6681|     25|                return (0);
 6682|     25|            }
 6683|      8|            else
 6684|      8|            {
 6685|      8|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 6686|      8|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6686:21): [True: 4, False: 4]
  ------------------
 6687|      4|                {
 6688|      4|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6688:25): [True: 0, False: 4]
  ------------------
 6689|      0|                    {
 6690|      0|                        if (data != 0)
  ------------------
  |  Branch (6690:29): [True: 0, False: 0]
  ------------------
 6691|      0|                            _TIFFfreeExt(tif, data);
 6692|      0|                        return 0;
 6693|      0|                    }
 6694|      4|                    int m;
 6695|      4|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6696|      4|                    if (data != 0)
  ------------------
  |  Branch (6696:25): [True: 4, False: 0]
  ------------------
 6697|      4|                        _TIFFfreeExt(tif, data);
 6698|      4|                    if (!m)
  ------------------
  |  Branch (6698:25): [True: 0, False: 4]
  ------------------
 6699|      0|                        return (0);
 6700|      4|                }
 6701|      8|            }
 6702|     33|        }
 6703|      8|        break;
 6704|      8|        case TIFF_SETGET_C0_SINT8:
  ------------------
  |  Branch (6704:9): [True: 0, False: 207k]
  ------------------
 6705|      0|        {
 6706|      0|            int8_t *data;
 6707|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6707:13): [True: 0, False: 0]
  |  Branch (6707:13): [True: 0, False: 0]
  ------------------
 6708|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6708:13): [True: 0, False: 0]
  |  Branch (6708:13): [True: 0, False: 0]
  ------------------
 6709|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6709:17): [True: 0, False: 0]
  ------------------
 6710|      0|            {
 6711|      0|                TIFFWarningExtR(tif, module,
 6712|      0|                                "incorrect count for field \"%s\", expected "
 6713|      0|                                "%d, got %" PRIu64,
 6714|      0|                                fip->field_name, (int)fip->field_readcount,
 6715|      0|                                dp->tdir_count);
 6716|      0|                return (0);
 6717|      0|            }
 6718|      0|            else
 6719|      0|            {
 6720|      0|                err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
 6721|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6721:21): [True: 0, False: 0]
  ------------------
 6722|      0|                {
 6723|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6723:25): [True: 0, False: 0]
  ------------------
 6724|      0|                    {
 6725|      0|                        if (data != 0)
  ------------------
  |  Branch (6725:29): [True: 0, False: 0]
  ------------------
 6726|      0|                            _TIFFfreeExt(tif, data);
 6727|      0|                        return 0;
 6728|      0|                    }
 6729|      0|                    int m;
 6730|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6731|      0|                    if (data != 0)
  ------------------
  |  Branch (6731:25): [True: 0, False: 0]
  ------------------
 6732|      0|                        _TIFFfreeExt(tif, data);
 6733|      0|                    if (!m)
  ------------------
  |  Branch (6733:25): [True: 0, False: 0]
  ------------------
 6734|      0|                        return (0);
 6735|      0|                }
 6736|      0|            }
 6737|      0|        }
 6738|      0|        break;
 6739|     33|        case TIFF_SETGET_C0_UINT16:
  ------------------
  |  Branch (6739:9): [True: 33, False: 207k]
  ------------------
 6740|     33|        {
 6741|     33|            uint16_t *data;
 6742|     33|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6742:13): [True: 0, False: 33]
  |  Branch (6742:13): [True: 33, False: 0]
  ------------------
 6743|     33|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6743:13): [True: 0, False: 33]
  |  Branch (6743:13): [True: 33, False: 0]
  ------------------
 6744|     33|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6744:17): [True: 23, False: 10]
  ------------------
 6745|     23|            {
 6746|     23|                TIFFWarningExtR(tif, module,
 6747|     23|                                "incorrect count for field \"%s\", expected "
 6748|     23|                                "%d, got %" PRIu64,
 6749|     23|                                fip->field_name, (int)fip->field_readcount,
 6750|     23|                                dp->tdir_count);
 6751|     23|                return (0);
 6752|     23|            }
 6753|     10|            else
 6754|     10|            {
 6755|     10|                err = TIFFReadDirEntryShortArray(tif, dp, &data);
 6756|     10|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6756:21): [True: 0, False: 10]
  ------------------
 6757|      0|                {
 6758|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6758:25): [True: 0, False: 0]
  ------------------
 6759|      0|                    {
 6760|      0|                        if (data != 0)
  ------------------
  |  Branch (6760:29): [True: 0, False: 0]
  ------------------
 6761|      0|                            _TIFFfreeExt(tif, data);
 6762|      0|                        return 0;
 6763|      0|                    }
 6764|      0|                    int m;
 6765|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6766|      0|                    if (data != 0)
  ------------------
  |  Branch (6766:25): [True: 0, False: 0]
  ------------------
 6767|      0|                        _TIFFfreeExt(tif, data);
 6768|      0|                    if (!m)
  ------------------
  |  Branch (6768:25): [True: 0, False: 0]
  ------------------
 6769|      0|                        return (0);
 6770|      0|                }
 6771|     10|            }
 6772|     33|        }
 6773|     10|        break;
 6774|     10|        case TIFF_SETGET_C0_SINT16:
  ------------------
  |  Branch (6774:9): [True: 0, False: 207k]
  ------------------
 6775|      0|        {
 6776|      0|            int16_t *data;
 6777|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6777:13): [True: 0, False: 0]
  |  Branch (6777:13): [True: 0, False: 0]
  ------------------
 6778|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6778:13): [True: 0, False: 0]
  |  Branch (6778:13): [True: 0, False: 0]
  ------------------
 6779|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6779:17): [True: 0, False: 0]
  ------------------
 6780|      0|            {
 6781|      0|                TIFFWarningExtR(tif, module,
 6782|      0|                                "incorrect count for field \"%s\", expected "
 6783|      0|                                "%d, got %" PRIu64,
 6784|      0|                                fip->field_name, (int)fip->field_readcount,
 6785|      0|                                dp->tdir_count);
 6786|      0|                return (0);
 6787|      0|            }
 6788|      0|            else
 6789|      0|            {
 6790|      0|                err = TIFFReadDirEntrySshortArray(tif, dp, &data);
 6791|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6791:21): [True: 0, False: 0]
  ------------------
 6792|      0|                {
 6793|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6793:25): [True: 0, False: 0]
  ------------------
 6794|      0|                    {
 6795|      0|                        if (data != 0)
  ------------------
  |  Branch (6795:29): [True: 0, False: 0]
  ------------------
 6796|      0|                            _TIFFfreeExt(tif, data);
 6797|      0|                        return 0;
 6798|      0|                    }
 6799|      0|                    int m;
 6800|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6801|      0|                    if (data != 0)
  ------------------
  |  Branch (6801:25): [True: 0, False: 0]
  ------------------
 6802|      0|                        _TIFFfreeExt(tif, data);
 6803|      0|                    if (!m)
  ------------------
  |  Branch (6803:25): [True: 0, False: 0]
  ------------------
 6804|      0|                        return (0);
 6805|      0|                }
 6806|      0|            }
 6807|      0|        }
 6808|      0|        break;
 6809|     22|        case TIFF_SETGET_C0_UINT32:
  ------------------
  |  Branch (6809:9): [True: 22, False: 207k]
  ------------------
 6810|     22|        {
 6811|     22|            uint32_t *data;
 6812|     22|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6812:13): [True: 0, False: 22]
  |  Branch (6812:13): [True: 22, False: 0]
  ------------------
 6813|     22|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6813:13): [True: 0, False: 22]
  |  Branch (6813:13): [True: 22, False: 0]
  ------------------
 6814|     22|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6814:17): [True: 7, False: 15]
  ------------------
 6815|      7|            {
 6816|      7|                TIFFWarningExtR(tif, module,
 6817|      7|                                "incorrect count for field \"%s\", expected "
 6818|      7|                                "%d, got %" PRIu64,
 6819|      7|                                fip->field_name, (int)fip->field_readcount,
 6820|      7|                                dp->tdir_count);
 6821|      7|                return (0);
 6822|      7|            }
 6823|     15|            else
 6824|     15|            {
 6825|     15|                err = TIFFReadDirEntryLongArray(tif, dp, &data);
 6826|     15|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6826:21): [True: 7, False: 8]
  ------------------
 6827|      7|                {
 6828|      7|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6828:25): [True: 0, False: 7]
  ------------------
 6829|      0|                    {
 6830|      0|                        if (data != 0)
  ------------------
  |  Branch (6830:29): [True: 0, False: 0]
  ------------------
 6831|      0|                            _TIFFfreeExt(tif, data);
 6832|      0|                        return 0;
 6833|      0|                    }
 6834|      7|                    int m;
 6835|      7|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6836|      7|                    if (data != 0)
  ------------------
  |  Branch (6836:25): [True: 7, False: 0]
  ------------------
 6837|      7|                        _TIFFfreeExt(tif, data);
 6838|      7|                    if (!m)
  ------------------
  |  Branch (6838:25): [True: 0, False: 7]
  ------------------
 6839|      0|                        return (0);
 6840|      7|                }
 6841|     15|            }
 6842|     22|        }
 6843|     15|        break;
 6844|     15|        case TIFF_SETGET_C0_SINT32:
  ------------------
  |  Branch (6844:9): [True: 0, False: 207k]
  ------------------
 6845|      0|        {
 6846|      0|            int32_t *data;
 6847|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6847:13): [True: 0, False: 0]
  |  Branch (6847:13): [True: 0, False: 0]
  ------------------
 6848|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6848:13): [True: 0, False: 0]
  |  Branch (6848:13): [True: 0, False: 0]
  ------------------
 6849|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6849:17): [True: 0, False: 0]
  ------------------
 6850|      0|            {
 6851|      0|                TIFFWarningExtR(tif, module,
 6852|      0|                                "incorrect count for field \"%s\", expected "
 6853|      0|                                "%d, got %" PRIu64,
 6854|      0|                                fip->field_name, (int)fip->field_readcount,
 6855|      0|                                dp->tdir_count);
 6856|      0|                return (0);
 6857|      0|            }
 6858|      0|            else
 6859|      0|            {
 6860|      0|                err = TIFFReadDirEntrySlongArray(tif, dp, &data);
 6861|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6861:21): [True: 0, False: 0]
  ------------------
 6862|      0|                {
 6863|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6863:25): [True: 0, False: 0]
  ------------------
 6864|      0|                    {
 6865|      0|                        if (data != 0)
  ------------------
  |  Branch (6865:29): [True: 0, False: 0]
  ------------------
 6866|      0|                            _TIFFfreeExt(tif, data);
 6867|      0|                        return 0;
 6868|      0|                    }
 6869|      0|                    int m;
 6870|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6871|      0|                    if (data != 0)
  ------------------
  |  Branch (6871:25): [True: 0, False: 0]
  ------------------
 6872|      0|                        _TIFFfreeExt(tif, data);
 6873|      0|                    if (!m)
  ------------------
  |  Branch (6873:25): [True: 0, False: 0]
  ------------------
 6874|      0|                        return (0);
 6875|      0|                }
 6876|      0|            }
 6877|      0|        }
 6878|      0|        break;
 6879|      0|        case TIFF_SETGET_C0_UINT64:
  ------------------
  |  Branch (6879:9): [True: 0, False: 207k]
  ------------------
 6880|      0|        {
 6881|      0|            uint64_t *data;
 6882|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6882:13): [True: 0, False: 0]
  |  Branch (6882:13): [True: 0, False: 0]
  ------------------
 6883|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6883:13): [True: 0, False: 0]
  |  Branch (6883:13): [True: 0, False: 0]
  ------------------
 6884|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6884:17): [True: 0, False: 0]
  ------------------
 6885|      0|            {
 6886|      0|                TIFFWarningExtR(tif, module,
 6887|      0|                                "incorrect count for field \"%s\", expected "
 6888|      0|                                "%d, got %" PRIu64,
 6889|      0|                                fip->field_name, (int)fip->field_readcount,
 6890|      0|                                dp->tdir_count);
 6891|      0|                return (0);
 6892|      0|            }
 6893|      0|            else
 6894|      0|            {
 6895|      0|                err = TIFFReadDirEntryLong8Array(tif, dp, &data);
 6896|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6896:21): [True: 0, False: 0]
  ------------------
 6897|      0|                {
 6898|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6898:25): [True: 0, False: 0]
  ------------------
 6899|      0|                    {
 6900|      0|                        if (data != 0)
  ------------------
  |  Branch (6900:29): [True: 0, False: 0]
  ------------------
 6901|      0|                            _TIFFfreeExt(tif, data);
 6902|      0|                        return 0;
 6903|      0|                    }
 6904|      0|                    int m;
 6905|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6906|      0|                    if (data != 0)
  ------------------
  |  Branch (6906:25): [True: 0, False: 0]
  ------------------
 6907|      0|                        _TIFFfreeExt(tif, data);
 6908|      0|                    if (!m)
  ------------------
  |  Branch (6908:25): [True: 0, False: 0]
  ------------------
 6909|      0|                        return (0);
 6910|      0|                }
 6911|      0|            }
 6912|      0|        }
 6913|      0|        break;
 6914|      0|        case TIFF_SETGET_C0_SINT64:
  ------------------
  |  Branch (6914:9): [True: 0, False: 207k]
  ------------------
 6915|      0|        {
 6916|      0|            int64_t *data;
 6917|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6917:13): [True: 0, False: 0]
  |  Branch (6917:13): [True: 0, False: 0]
  ------------------
 6918|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6918:13): [True: 0, False: 0]
  |  Branch (6918:13): [True: 0, False: 0]
  ------------------
 6919|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6919:17): [True: 0, False: 0]
  ------------------
 6920|      0|            {
 6921|      0|                TIFFWarningExtR(tif, module,
 6922|      0|                                "incorrect count for field \"%s\", expected "
 6923|      0|                                "%d, got %" PRIu64,
 6924|      0|                                fip->field_name, (int)fip->field_readcount,
 6925|      0|                                dp->tdir_count);
 6926|      0|                return (0);
 6927|      0|            }
 6928|      0|            else
 6929|      0|            {
 6930|      0|                err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
 6931|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6931:21): [True: 0, False: 0]
  ------------------
 6932|      0|                {
 6933|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6933:25): [True: 0, False: 0]
  ------------------
 6934|      0|                    {
 6935|      0|                        if (data != 0)
  ------------------
  |  Branch (6935:29): [True: 0, False: 0]
  ------------------
 6936|      0|                            _TIFFfreeExt(tif, data);
 6937|      0|                        return 0;
 6938|      0|                    }
 6939|      0|                    int m;
 6940|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6941|      0|                    if (data != 0)
  ------------------
  |  Branch (6941:25): [True: 0, False: 0]
  ------------------
 6942|      0|                        _TIFFfreeExt(tif, data);
 6943|      0|                    if (!m)
  ------------------
  |  Branch (6943:25): [True: 0, False: 0]
  ------------------
 6944|      0|                        return (0);
 6945|      0|                }
 6946|      0|            }
 6947|      0|        }
 6948|      0|        break;
 6949|  1.48k|        case TIFF_SETGET_C0_FLOAT:
  ------------------
  |  Branch (6949:9): [True: 1.48k, False: 206k]
  ------------------
 6950|  1.48k|        {
 6951|  1.48k|            float *data;
 6952|  1.48k|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6952:13): [True: 0, False: 1.48k]
  |  Branch (6952:13): [True: 1.48k, False: 0]
  ------------------
 6953|  1.48k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6953:13): [True: 0, False: 1.48k]
  |  Branch (6953:13): [True: 1.48k, False: 0]
  ------------------
 6954|  1.48k|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6954:17): [True: 777, False: 708]
  ------------------
 6955|    777|            {
 6956|    777|                TIFFWarningExtR(tif, module,
 6957|    777|                                "incorrect count for field \"%s\", expected "
 6958|    777|                                "%d, got %" PRIu64,
 6959|    777|                                fip->field_name, (int)fip->field_readcount,
 6960|    777|                                dp->tdir_count);
 6961|    777|                return (0);
 6962|    777|            }
 6963|    708|            else
 6964|    708|            {
 6965|    708|                err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 6966|    708|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6966:21): [True: 690, False: 18]
  ------------------
 6967|    690|                {
 6968|    690|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6968:25): [True: 0, False: 690]
  ------------------
 6969|      0|                    {
 6970|      0|                        if (data != 0)
  ------------------
  |  Branch (6970:29): [True: 0, False: 0]
  ------------------
 6971|      0|                            _TIFFfreeExt(tif, data);
 6972|      0|                        return 0;
 6973|      0|                    }
 6974|    690|                    int m;
 6975|    690|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6976|    690|                    if (data != 0)
  ------------------
  |  Branch (6976:25): [True: 690, False: 0]
  ------------------
 6977|    690|                        _TIFFfreeExt(tif, data);
 6978|    690|                    if (!m)
  ------------------
  |  Branch (6978:25): [True: 0, False: 690]
  ------------------
 6979|      0|                        return (0);
 6980|    690|                }
 6981|    708|            }
 6982|  1.48k|        }
 6983|    708|        break;
 6984|       |        /*--: Rational2Double: Extend for Double Arrays and Rational-Arrays read
 6985|       |         * into Double-Arrays. */
 6986|    708|        case TIFF_SETGET_C0_DOUBLE:
  ------------------
  |  Branch (6986:9): [True: 0, False: 207k]
  ------------------
 6987|      0|        {
 6988|      0|            double *data;
 6989|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6989:13): [True: 0, False: 0]
  |  Branch (6989:13): [True: 0, False: 0]
  ------------------
 6990|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6990:13): [True: 0, False: 0]
  |  Branch (6990:13): [True: 0, False: 0]
  ------------------
 6991|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6991:17): [True: 0, False: 0]
  ------------------
 6992|      0|            {
 6993|      0|                TIFFWarningExtR(tif, module,
 6994|      0|                                "incorrect count for field \"%s\", expected "
 6995|      0|                                "%d, got %" PRIu64,
 6996|      0|                                fip->field_name, (int)fip->field_readcount,
 6997|      0|                                dp->tdir_count);
 6998|      0|                return (0);
 6999|      0|            }
 7000|      0|            else
 7001|      0|            {
 7002|      0|                err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 7003|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7003:21): [True: 0, False: 0]
  ------------------
 7004|      0|                {
 7005|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7005:25): [True: 0, False: 0]
  ------------------
 7006|      0|                    {
 7007|      0|                        if (data != 0)
  ------------------
  |  Branch (7007:29): [True: 0, False: 0]
  ------------------
 7008|      0|                            _TIFFfreeExt(tif, data);
 7009|      0|                        return 0;
 7010|      0|                    }
 7011|      0|                    int m;
 7012|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 7013|      0|                    if (data != 0)
  ------------------
  |  Branch (7013:25): [True: 0, False: 0]
  ------------------
 7014|      0|                        _TIFFfreeExt(tif, data);
 7015|      0|                    if (!m)
  ------------------
  |  Branch (7015:25): [True: 0, False: 0]
  ------------------
 7016|      0|                        return (0);
 7017|      0|                }
 7018|      0|            }
 7019|      0|        }
 7020|      0|        break;
 7021|      0|        case TIFF_SETGET_C0_IFD8:
  ------------------
  |  Branch (7021:9): [True: 0, False: 207k]
  ------------------
 7022|      0|        {
 7023|      0|            uint64_t *data;
 7024|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (7024:13): [True: 0, False: 0]
  |  Branch (7024:13): [True: 0, False: 0]
  ------------------
 7025|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (7025:13): [True: 0, False: 0]
  |  Branch (7025:13): [True: 0, False: 0]
  ------------------
 7026|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (7026:17): [True: 0, False: 0]
  ------------------
 7027|      0|            {
 7028|      0|                TIFFWarningExtR(tif, module,
 7029|      0|                                "incorrect count for field \"%s\", expected "
 7030|      0|                                "%d, got %" PRIu64,
 7031|      0|                                fip->field_name, (int)fip->field_readcount,
 7032|      0|                                dp->tdir_count);
 7033|      0|                return (0);
 7034|      0|            }
 7035|      0|            else
 7036|      0|            {
 7037|      0|                err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
 7038|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7038:21): [True: 0, False: 0]
  ------------------
 7039|      0|                {
 7040|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7040:25): [True: 0, False: 0]
  ------------------
 7041|      0|                    {
 7042|      0|                        if (data != 0)
  ------------------
  |  Branch (7042:29): [True: 0, False: 0]
  ------------------
 7043|      0|                            _TIFFfreeExt(tif, data);
 7044|      0|                        return 0;
 7045|      0|                    }
 7046|      0|                    int m;
 7047|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 7048|      0|                    if (data != 0)
  ------------------
  |  Branch (7048:25): [True: 0, False: 0]
  ------------------
 7049|      0|                        _TIFFfreeExt(tif, data);
 7050|      0|                    if (!m)
  ------------------
  |  Branch (7050:25): [True: 0, False: 0]
  ------------------
 7051|      0|                        return (0);
 7052|      0|                }
 7053|      0|            }
 7054|      0|        }
 7055|      0|        break;
 7056|    173|        case TIFF_SETGET_C16_ASCII:
  ------------------
  |  Branch (7056:9): [True: 173, False: 207k]
  ------------------
 7057|    173|        {
 7058|    173|            uint8_t *data;
 7059|    173|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7059:13): [True: 0, False: 173]
  |  Branch (7059:13): [True: 173, False: 0]
  ------------------
 7060|    173|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7060:13): [True: 0, False: 173]
  |  Branch (7060:13): [True: 173, False: 0]
  ------------------
 7061|    173|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7061:17): [True: 100, False: 73]
  ------------------
 7062|    100|                err = TIFFReadDirEntryErrCount;
 7063|     73|            else
 7064|     73|            {
 7065|     73|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7066|     73|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7066:21): [True: 49, False: 24]
  ------------------
 7067|     49|                {
 7068|     49|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7068:25): [True: 1, False: 48]
  ------------------
 7069|      1|                    {
 7070|      1|                        if (data != 0)
  ------------------
  |  Branch (7070:29): [True: 1, False: 0]
  ------------------
 7071|      1|                            _TIFFfreeExt(tif, data);
 7072|      1|                        return 0;
 7073|      1|                    }
 7074|     48|                    int m;
 7075|     48|                    if (data != 0 && dp->tdir_count > 0 &&
  ------------------
  |  Branch (7075:25): [True: 44, False: 4]
  |  Branch (7075:38): [True: 44, False: 0]
  ------------------
 7076|     44|                        data[dp->tdir_count - 1] != '\0')
  ------------------
  |  Branch (7076:25): [True: 26, False: 18]
  ------------------
 7077|     26|                    {
 7078|     26|                        TIFFWarningExtR(tif, module,
 7079|     26|                                        "ASCII value for ASCII array tag "
 7080|     26|                                        "\"%s\" does not end in null "
 7081|     26|                                        "byte. Forcing it to be null",
 7082|     26|                                        fip->field_name);
 7083|       |                        /* Enlarge buffer and add terminating null. */
 7084|     26|                        uint8_t *o = (uint8_t *)_TIFFmallocExt(
 7085|     26|                            tif, (uint32_t)dp->tdir_count + 1);
 7086|     26|                        if (o == NULL)
  ------------------
  |  Branch (7086:29): [True: 0, False: 26]
  ------------------
 7087|      0|                        {
 7088|      0|                            if (data != NULL)
  ------------------
  |  Branch (7088:33): [True: 0, False: 0]
  ------------------
 7089|      0|                                _TIFFfreeExt(tif, data);
 7090|      0|                            return (0);
 7091|      0|                        }
 7092|     26|                        if (dp->tdir_count > 0)
  ------------------
  |  Branch (7092:29): [True: 26, False: 0]
  ------------------
 7093|     26|                        {
 7094|     26|                            _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 7095|     26|                        }
 7096|     26|                        o[(uint32_t)dp->tdir_count] = 0;
 7097|     26|                        dp->tdir_count++; /* Increment for added null. */
 7098|     26|                        if (data != 0)
  ------------------
  |  Branch (7098:29): [True: 26, False: 0]
  ------------------
 7099|     26|                            _TIFFfreeExt(tif, data);
 7100|     26|                        data = o;
 7101|     26|                    }
 7102|     48|                    m = TIFFSetField(tif, dp->tdir_tag,
 7103|     48|                                     (uint16_t)(dp->tdir_count), data);
 7104|     48|                    if (data != 0)
  ------------------
  |  Branch (7104:25): [True: 44, False: 4]
  ------------------
 7105|     44|                        _TIFFfreeExt(tif, data);
 7106|     48|                    if (!m)
  ------------------
  |  Branch (7106:25): [True: 4, False: 44]
  ------------------
 7107|      4|                        return (0);
 7108|     48|                }
 7109|     73|            }
 7110|    173|        }
 7111|    168|        break;
 7112|    168|        case TIFF_SETGET_C16_UINT8:
  ------------------
  |  Branch (7112:9): [True: 36, False: 207k]
  ------------------
 7113|     36|        {
 7114|     36|            uint8_t *data;
 7115|     36|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7115:13): [True: 0, False: 36]
  |  Branch (7115:13): [True: 36, False: 0]
  ------------------
 7116|     36|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7116:13): [True: 0, False: 36]
  |  Branch (7116:13): [True: 36, False: 0]
  ------------------
 7117|     36|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7117:17): [True: 11, False: 25]
  ------------------
 7118|     11|                err = TIFFReadDirEntryErrCount;
 7119|     25|            else
 7120|     25|            {
 7121|     25|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7122|     25|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7122:21): [True: 3, False: 22]
  ------------------
 7123|      3|                {
 7124|      3|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7124:25): [True: 0, False: 3]
  ------------------
 7125|      0|                    {
 7126|      0|                        if (data != 0)
  ------------------
  |  Branch (7126:29): [True: 0, False: 0]
  ------------------
 7127|      0|                            _TIFFfreeExt(tif, data);
 7128|      0|                        return 0;
 7129|      0|                    }
 7130|      3|                    int m;
 7131|      3|                    m = TIFFSetField(tif, dp->tdir_tag,
 7132|      3|                                     (uint16_t)(dp->tdir_count), data);
 7133|      3|                    if (data != 0)
  ------------------
  |  Branch (7133:25): [True: 3, False: 0]
  ------------------
 7134|      3|                        _TIFFfreeExt(tif, data);
 7135|      3|                    if (!m)
  ------------------
  |  Branch (7135:25): [True: 0, False: 3]
  ------------------
 7136|      0|                        return (0);
 7137|      3|                }
 7138|     25|            }
 7139|     36|        }
 7140|     36|        break;
 7141|     36|        case TIFF_SETGET_C16_SINT8:
  ------------------
  |  Branch (7141:9): [True: 0, False: 207k]
  ------------------
 7142|      0|        {
 7143|      0|            int8_t *data;
 7144|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7144:13): [True: 0, False: 0]
  |  Branch (7144:13): [True: 0, False: 0]
  ------------------
 7145|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7145:13): [True: 0, False: 0]
  |  Branch (7145:13): [True: 0, False: 0]
  ------------------
 7146|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7146:17): [True: 0, False: 0]
  ------------------
 7147|      0|                err = TIFFReadDirEntryErrCount;
 7148|      0|            else
 7149|      0|            {
 7150|      0|                err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
 7151|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7151:21): [True: 0, False: 0]
  ------------------
 7152|      0|                {
 7153|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7153:25): [True: 0, False: 0]
  ------------------
 7154|      0|                    {
 7155|      0|                        if (data != 0)
  ------------------
  |  Branch (7155:29): [True: 0, False: 0]
  ------------------
 7156|      0|                            _TIFFfreeExt(tif, data);
 7157|      0|                        return 0;
 7158|      0|                    }
 7159|      0|                    int m;
 7160|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7161|      0|                                     (uint16_t)(dp->tdir_count), data);
 7162|      0|                    if (data != 0)
  ------------------
  |  Branch (7162:25): [True: 0, False: 0]
  ------------------
 7163|      0|                        _TIFFfreeExt(tif, data);
 7164|      0|                    if (!m)
  ------------------
  |  Branch (7164:25): [True: 0, False: 0]
  ------------------
 7165|      0|                        return (0);
 7166|      0|                }
 7167|      0|            }
 7168|      0|        }
 7169|      0|        break;
 7170|    948|        case TIFF_SETGET_C16_UINT16:
  ------------------
  |  Branch (7170:9): [True: 948, False: 206k]
  ------------------
 7171|    948|        {
 7172|    948|            uint16_t *data;
 7173|    948|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7173:13): [True: 0, False: 948]
  |  Branch (7173:13): [True: 948, False: 0]
  ------------------
 7174|    948|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7174:13): [True: 0, False: 948]
  |  Branch (7174:13): [True: 948, False: 0]
  ------------------
 7175|    948|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7175:17): [True: 22, False: 926]
  ------------------
 7176|     22|                err = TIFFReadDirEntryErrCount;
 7177|    926|            else
 7178|    926|            {
 7179|    926|                err = TIFFReadDirEntryShortArray(tif, dp, &data);
 7180|    926|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7180:21): [True: 892, False: 34]
  ------------------
 7181|    892|                {
 7182|    892|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7182:25): [True: 0, False: 892]
  ------------------
 7183|      0|                    {
 7184|      0|                        if (data != 0)
  ------------------
  |  Branch (7184:29): [True: 0, False: 0]
  ------------------
 7185|      0|                            _TIFFfreeExt(tif, data);
 7186|      0|                        return 0;
 7187|      0|                    }
 7188|    892|                    int m;
 7189|    892|                    m = TIFFSetField(tif, dp->tdir_tag,
 7190|    892|                                     (uint16_t)(dp->tdir_count), data);
 7191|    892|                    if (data != 0)
  ------------------
  |  Branch (7191:25): [True: 874, False: 18]
  ------------------
 7192|    874|                        _TIFFfreeExt(tif, data);
 7193|    892|                    if (!m)
  ------------------
  |  Branch (7193:25): [True: 0, False: 892]
  ------------------
 7194|      0|                        return (0);
 7195|    892|                }
 7196|    926|            }
 7197|    948|        }
 7198|    948|        break;
 7199|    948|        case TIFF_SETGET_C16_SINT16:
  ------------------
  |  Branch (7199:9): [True: 0, False: 207k]
  ------------------
 7200|      0|        {
 7201|      0|            int16_t *data;
 7202|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7202:13): [True: 0, False: 0]
  |  Branch (7202:13): [True: 0, False: 0]
  ------------------
 7203|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7203:13): [True: 0, False: 0]
  |  Branch (7203:13): [True: 0, False: 0]
  ------------------
 7204|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7204:17): [True: 0, False: 0]
  ------------------
 7205|      0|                err = TIFFReadDirEntryErrCount;
 7206|      0|            else
 7207|      0|            {
 7208|      0|                err = TIFFReadDirEntrySshortArray(tif, dp, &data);
 7209|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7209:21): [True: 0, False: 0]
  ------------------
 7210|      0|                {
 7211|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7211:25): [True: 0, False: 0]
  ------------------
 7212|      0|                    {
 7213|      0|                        if (data != 0)
  ------------------
  |  Branch (7213:29): [True: 0, False: 0]
  ------------------
 7214|      0|                            _TIFFfreeExt(tif, data);
 7215|      0|                        return 0;
 7216|      0|                    }
 7217|      0|                    int m;
 7218|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7219|      0|                                     (uint16_t)(dp->tdir_count), data);
 7220|      0|                    if (data != 0)
  ------------------
  |  Branch (7220:25): [True: 0, False: 0]
  ------------------
 7221|      0|                        _TIFFfreeExt(tif, data);
 7222|      0|                    if (!m)
  ------------------
  |  Branch (7222:25): [True: 0, False: 0]
  ------------------
 7223|      0|                        return (0);
 7224|      0|                }
 7225|      0|            }
 7226|      0|        }
 7227|      0|        break;
 7228|    364|        case TIFF_SETGET_C16_UINT32:
  ------------------
  |  Branch (7228:9): [True: 364, False: 207k]
  ------------------
 7229|    364|        {
 7230|    364|            uint32_t *data;
 7231|    364|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7231:13): [True: 0, False: 364]
  |  Branch (7231:13): [True: 364, False: 0]
  ------------------
 7232|    364|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7232:13): [True: 0, False: 364]
  |  Branch (7232:13): [True: 364, False: 0]
  ------------------
 7233|    364|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7233:17): [True: 33, False: 331]
  ------------------
 7234|     33|                err = TIFFReadDirEntryErrCount;
 7235|    331|            else
 7236|    331|            {
 7237|    331|                err = TIFFReadDirEntryLongArray(tif, dp, &data);
 7238|    331|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7238:21): [True: 152, False: 179]
  ------------------
 7239|    152|                {
 7240|    152|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7240:25): [True: 0, False: 152]
  ------------------
 7241|      0|                    {
 7242|      0|                        if (data != 0)
  ------------------
  |  Branch (7242:29): [True: 0, False: 0]
  ------------------
 7243|      0|                            _TIFFfreeExt(tif, data);
 7244|      0|                        return 0;
 7245|      0|                    }
 7246|    152|                    int m;
 7247|    152|                    m = TIFFSetField(tif, dp->tdir_tag,
 7248|    152|                                     (uint16_t)(dp->tdir_count), data);
 7249|    152|                    if (data != 0)
  ------------------
  |  Branch (7249:25): [True: 142, False: 10]
  ------------------
 7250|    142|                        _TIFFfreeExt(tif, data);
 7251|    152|                    if (!m)
  ------------------
  |  Branch (7251:25): [True: 0, False: 152]
  ------------------
 7252|      0|                        return (0);
 7253|    152|                }
 7254|    331|            }
 7255|    364|        }
 7256|    364|        break;
 7257|    364|        case TIFF_SETGET_C16_SINT32:
  ------------------
  |  Branch (7257:9): [True: 0, False: 207k]
  ------------------
 7258|      0|        {
 7259|      0|            int32_t *data;
 7260|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7260:13): [True: 0, False: 0]
  |  Branch (7260:13): [True: 0, False: 0]
  ------------------
 7261|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7261:13): [True: 0, False: 0]
  |  Branch (7261:13): [True: 0, False: 0]
  ------------------
 7262|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7262:17): [True: 0, False: 0]
  ------------------
 7263|      0|                err = TIFFReadDirEntryErrCount;
 7264|      0|            else
 7265|      0|            {
 7266|      0|                err = TIFFReadDirEntrySlongArray(tif, dp, &data);
 7267|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7267:21): [True: 0, False: 0]
  ------------------
 7268|      0|                {
 7269|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7269:25): [True: 0, False: 0]
  ------------------
 7270|      0|                    {
 7271|      0|                        if (data != 0)
  ------------------
  |  Branch (7271:29): [True: 0, False: 0]
  ------------------
 7272|      0|                            _TIFFfreeExt(tif, data);
 7273|      0|                        return 0;
 7274|      0|                    }
 7275|      0|                    int m;
 7276|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7277|      0|                                     (uint16_t)(dp->tdir_count), data);
 7278|      0|                    if (data != 0)
  ------------------
  |  Branch (7278:25): [True: 0, False: 0]
  ------------------
 7279|      0|                        _TIFFfreeExt(tif, data);
 7280|      0|                    if (!m)
  ------------------
  |  Branch (7280:25): [True: 0, False: 0]
  ------------------
 7281|      0|                        return (0);
 7282|      0|                }
 7283|      0|            }
 7284|      0|        }
 7285|      0|        break;
 7286|      0|        case TIFF_SETGET_C16_UINT64:
  ------------------
  |  Branch (7286:9): [True: 0, False: 207k]
  ------------------
 7287|      0|        {
 7288|      0|            uint64_t *data;
 7289|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7289:13): [True: 0, False: 0]
  |  Branch (7289:13): [True: 0, False: 0]
  ------------------
 7290|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7290:13): [True: 0, False: 0]
  |  Branch (7290:13): [True: 0, False: 0]
  ------------------
 7291|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7291:17): [True: 0, False: 0]
  ------------------
 7292|      0|                err = TIFFReadDirEntryErrCount;
 7293|      0|            else
 7294|      0|            {
 7295|      0|                err = TIFFReadDirEntryLong8Array(tif, dp, &data);
 7296|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7296:21): [True: 0, False: 0]
  ------------------
 7297|      0|                {
 7298|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7298:25): [True: 0, False: 0]
  ------------------
 7299|      0|                    {
 7300|      0|                        if (data != 0)
  ------------------
  |  Branch (7300:29): [True: 0, False: 0]
  ------------------
 7301|      0|                            _TIFFfreeExt(tif, data);
 7302|      0|                        return 0;
 7303|      0|                    }
 7304|      0|                    int m;
 7305|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7306|      0|                                     (uint16_t)(dp->tdir_count), data);
 7307|      0|                    if (data != 0)
  ------------------
  |  Branch (7307:25): [True: 0, False: 0]
  ------------------
 7308|      0|                        _TIFFfreeExt(tif, data);
 7309|      0|                    if (!m)
  ------------------
  |  Branch (7309:25): [True: 0, False: 0]
  ------------------
 7310|      0|                        return (0);
 7311|      0|                }
 7312|      0|            }
 7313|      0|        }
 7314|      0|        break;
 7315|      0|        case TIFF_SETGET_C16_SINT64:
  ------------------
  |  Branch (7315:9): [True: 0, False: 207k]
  ------------------
 7316|      0|        {
 7317|      0|            int64_t *data;
 7318|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7318:13): [True: 0, False: 0]
  |  Branch (7318:13): [True: 0, False: 0]
  ------------------
 7319|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7319:13): [True: 0, False: 0]
  |  Branch (7319:13): [True: 0, False: 0]
  ------------------
 7320|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7320:17): [True: 0, False: 0]
  ------------------
 7321|      0|                err = TIFFReadDirEntryErrCount;
 7322|      0|            else
 7323|      0|            {
 7324|      0|                err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
 7325|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7325:21): [True: 0, False: 0]
  ------------------
 7326|      0|                {
 7327|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7327:25): [True: 0, False: 0]
  ------------------
 7328|      0|                    {
 7329|      0|                        if (data != 0)
  ------------------
  |  Branch (7329:29): [True: 0, False: 0]
  ------------------
 7330|      0|                            _TIFFfreeExt(tif, data);
 7331|      0|                        return 0;
 7332|      0|                    }
 7333|      0|                    int m;
 7334|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7335|      0|                                     (uint16_t)(dp->tdir_count), data);
 7336|      0|                    if (data != 0)
  ------------------
  |  Branch (7336:25): [True: 0, False: 0]
  ------------------
 7337|      0|                        _TIFFfreeExt(tif, data);
 7338|      0|                    if (!m)
  ------------------
  |  Branch (7338:25): [True: 0, False: 0]
  ------------------
 7339|      0|                        return (0);
 7340|      0|                }
 7341|      0|            }
 7342|      0|        }
 7343|      0|        break;
 7344|     94|        case TIFF_SETGET_C16_FLOAT:
  ------------------
  |  Branch (7344:9): [True: 94, False: 207k]
  ------------------
 7345|     94|        {
 7346|     94|            float *data;
 7347|     94|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7347:13): [True: 0, False: 94]
  |  Branch (7347:13): [True: 94, False: 0]
  ------------------
 7348|     94|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7348:13): [True: 0, False: 94]
  |  Branch (7348:13): [True: 94, False: 0]
  ------------------
 7349|     94|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7349:17): [True: 34, False: 60]
  ------------------
 7350|     34|                err = TIFFReadDirEntryErrCount;
 7351|     60|            else
 7352|     60|            {
 7353|     60|                err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 7354|     60|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7354:21): [True: 60, False: 0]
  ------------------
 7355|     60|                {
 7356|     60|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7356:25): [True: 1, False: 59]
  ------------------
 7357|      1|                    {
 7358|      1|                        if (data != 0)
  ------------------
  |  Branch (7358:29): [True: 1, False: 0]
  ------------------
 7359|      1|                            _TIFFfreeExt(tif, data);
 7360|      1|                        return 0;
 7361|      1|                    }
 7362|     59|                    int m;
 7363|     59|                    m = TIFFSetField(tif, dp->tdir_tag,
 7364|     59|                                     (uint16_t)(dp->tdir_count), data);
 7365|     59|                    if (data != 0)
  ------------------
  |  Branch (7365:25): [True: 51, False: 8]
  ------------------
 7366|     51|                        _TIFFfreeExt(tif, data);
 7367|     59|                    if (!m)
  ------------------
  |  Branch (7367:25): [True: 0, False: 59]
  ------------------
 7368|      0|                        return (0);
 7369|     59|                }
 7370|     60|            }
 7371|     94|        }
 7372|     93|        break;
 7373|     93|        case TIFF_SETGET_C16_DOUBLE:
  ------------------
  |  Branch (7373:9): [True: 0, False: 207k]
  ------------------
 7374|      0|        {
 7375|      0|            double *data;
 7376|      0|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7376:13): [True: 0, False: 0]
  |  Branch (7376:13): [True: 0, False: 0]
  ------------------
 7377|      0|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7377:13): [True: 0, False: 0]
  |  Branch (7377:13): [True: 0, False: 0]
  ------------------
 7378|      0|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7378:17): [True: 0, False: 0]
  ------------------
 7379|      0|                err = TIFFReadDirEntryErrCount;
 7380|      0|            else
 7381|      0|            {
 7382|      0|                err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 7383|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7383:21): [True: 0, False: 0]
  ------------------
 7384|      0|                {
 7385|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7385:25): [True: 0, False: 0]
  ------------------
 7386|      0|                    {
 7387|      0|                        if (data != 0)
  ------------------
  |  Branch (7387:29): [True: 0, False: 0]
  ------------------
 7388|      0|                            _TIFFfreeExt(tif, data);
 7389|      0|                        return 0;
 7390|      0|                    }
 7391|      0|                    int m;
 7392|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7393|      0|                                     (uint16_t)(dp->tdir_count), data);
 7394|      0|                    if (data != 0)
  ------------------
  |  Branch (7394:25): [True: 0, False: 0]
  ------------------
 7395|      0|                        _TIFFfreeExt(tif, data);
 7396|      0|                    if (!m)
  ------------------
  |  Branch (7396:25): [True: 0, False: 0]
  ------------------
 7397|      0|                        return (0);
 7398|      0|                }
 7399|      0|            }
 7400|      0|        }
 7401|      0|        break;
 7402|    145|        case TIFF_SETGET_C16_IFD8:
  ------------------
  |  Branch (7402:9): [True: 145, False: 207k]
  ------------------
 7403|    145|        {
 7404|    145|            uint64_t *data;
 7405|    145|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7405:13): [True: 0, False: 145]
  |  Branch (7405:13): [True: 145, False: 0]
  ------------------
 7406|    145|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7406:13): [True: 0, False: 145]
  |  Branch (7406:13): [True: 145, False: 0]
  ------------------
 7407|    145|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7407:17): [True: 19, False: 126]
  ------------------
 7408|     19|                err = TIFFReadDirEntryErrCount;
 7409|    126|            else
 7410|    126|            {
 7411|    126|                err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
 7412|    126|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7412:21): [True: 14, False: 112]
  ------------------
 7413|     14|                {
 7414|     14|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7414:25): [True: 0, False: 14]
  ------------------
 7415|      0|                    {
 7416|      0|                        if (data != 0)
  ------------------
  |  Branch (7416:29): [True: 0, False: 0]
  ------------------
 7417|      0|                            _TIFFfreeExt(tif, data);
 7418|      0|                        return 0;
 7419|      0|                    }
 7420|     14|                    int m;
 7421|     14|                    m = TIFFSetField(tif, dp->tdir_tag,
 7422|     14|                                     (uint16_t)(dp->tdir_count), data);
 7423|     14|                    if (data != 0)
  ------------------
  |  Branch (7423:25): [True: 10, False: 4]
  ------------------
 7424|     10|                        _TIFFfreeExt(tif, data);
 7425|     14|                    if (!m)
  ------------------
  |  Branch (7425:25): [True: 0, False: 14]
  ------------------
 7426|      0|                        return (0);
 7427|     14|                }
 7428|    126|            }
 7429|    145|        }
 7430|    145|        break;
 7431|    724|        case TIFF_SETGET_C32_ASCII:
  ------------------
  |  Branch (7431:9): [True: 724, False: 206k]
  ------------------
 7432|    724|        {
 7433|    724|            uint8_t *data;
 7434|    724|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7434:13): [True: 0, False: 724]
  |  Branch (7434:13): [True: 724, False: 0]
  ------------------
 7435|    724|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7435:13): [True: 0, False: 724]
  |  Branch (7435:13): [True: 724, False: 0]
  ------------------
 7436|    724|            err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7437|    724|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7437:17): [True: 403, False: 321]
  ------------------
 7438|    403|            {
 7439|    403|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7439:21): [True: 4, False: 399]
  ------------------
 7440|      4|                {
 7441|      4|                    if (data != 0)
  ------------------
  |  Branch (7441:25): [True: 4, False: 0]
  ------------------
 7442|      4|                        _TIFFfreeExt(tif, data);
 7443|      4|                    return 0;
 7444|      4|                }
 7445|    399|                int m;
 7446|    399|                if (data != 0 && dp->tdir_count > 0 &&
  ------------------
  |  Branch (7446:21): [True: 381, False: 18]
  |  Branch (7446:34): [True: 381, False: 0]
  ------------------
 7447|    381|                    data[dp->tdir_count - 1] != '\0')
  ------------------
  |  Branch (7447:21): [True: 217, False: 164]
  ------------------
 7448|    217|                {
 7449|    217|                    TIFFWarningExtR(
 7450|    217|                        tif, module,
 7451|    217|                        "ASCII value for ASCII array tag \"%s\" does not end "
 7452|    217|                        "in null byte. Forcing it to be null",
 7453|    217|                        fip->field_name);
 7454|       |                    /* Enlarge buffer and add terminating null. */
 7455|    217|                    uint8_t *o = (uint8_t *)_TIFFmallocExt(
 7456|    217|                        tif, (uint32_t)dp->tdir_count + 1);
 7457|    217|                    if (o == NULL)
  ------------------
  |  Branch (7457:25): [True: 0, False: 217]
  ------------------
 7458|      0|                    {
 7459|      0|                        if (data != NULL)
  ------------------
  |  Branch (7459:29): [True: 0, False: 0]
  ------------------
 7460|      0|                            _TIFFfreeExt(tif, data);
 7461|      0|                        return (0);
 7462|      0|                    }
 7463|    217|                    if (dp->tdir_count > 0)
  ------------------
  |  Branch (7463:25): [True: 217, False: 0]
  ------------------
 7464|    217|                    {
 7465|    217|                        _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 7466|    217|                    }
 7467|    217|                    o[(uint32_t)dp->tdir_count] = 0;
 7468|    217|                    dp->tdir_count++; /* Increment for added null. */
 7469|    217|                    if (data != 0)
  ------------------
  |  Branch (7469:25): [True: 217, False: 0]
  ------------------
 7470|    217|                        _TIFFfreeExt(tif, data);
 7471|    217|                    data = o;
 7472|    217|                }
 7473|    399|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7474|    399|                                 data);
 7475|    399|                if (data != 0)
  ------------------
  |  Branch (7475:21): [True: 381, False: 18]
  ------------------
 7476|    381|                    _TIFFfreeExt(tif, data);
 7477|    399|                if (!m)
  ------------------
  |  Branch (7477:21): [True: 0, False: 399]
  ------------------
 7478|      0|                    return (0);
 7479|    399|            }
 7480|    724|        }
 7481|    720|        break;
 7482|  3.71k|        case TIFF_SETGET_C32_UINT8:
  ------------------
  |  Branch (7482:9): [True: 3.71k, False: 203k]
  ------------------
 7483|  3.71k|        {
 7484|  3.71k|            uint8_t *data;
 7485|  3.71k|            uint32_t count = 0;
 7486|  3.71k|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7486:13): [True: 0, False: 3.71k]
  |  Branch (7486:13): [True: 3.71k, False: 0]
  ------------------
 7487|  3.71k|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7487:13): [True: 0, False: 3.71k]
  |  Branch (7487:13): [True: 3.71k, False: 0]
  ------------------
 7488|  3.71k|            if (fip->field_tag == TIFFTAG_RICHTIFFIPTC &&
  ------------------
  |  |  448|  7.42k|#define TIFFTAG_RICHTIFFIPTC 33723
  ------------------
  |  Branch (7488:17): [True: 11, False: 3.70k]
  ------------------
 7489|     11|                dp->tdir_type == TIFF_LONG)
  ------------------
  |  Branch (7489:17): [True: 9, False: 2]
  ------------------
 7490|      9|            {
 7491|       |                /* Adobe's software (wrongly) writes RichTIFFIPTC tag with
 7492|       |                 * data type LONG instead of UNDEFINED. Work around this
 7493|       |                 * frequently found issue */
 7494|      9|                void *origdata;
 7495|      9|                err = TIFFReadDirEntryArray(tif, dp, &count, 4, &origdata);
 7496|      9|                if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (7496:21): [True: 5, False: 4]
  |  Branch (7496:55): [True: 0, False: 4]
  ------------------
 7497|      5|                {
 7498|      5|                    data = NULL;
 7499|      5|                }
 7500|      4|                else
 7501|      4|                {
 7502|      4|                    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      4|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (7502:25): [True: 0, False: 4]
  ------------------
 7503|      0|                        TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 7504|      4|                    data = (uint8_t *)origdata;
 7505|      4|                    count = (uint32_t)(count * 4);
 7506|      4|                }
 7507|      9|            }
 7508|  3.70k|            else
 7509|  3.70k|            {
 7510|  3.70k|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7511|  3.70k|                count = (uint32_t)(dp->tdir_count);
 7512|  3.70k|            }
 7513|  3.71k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7513:17): [True: 1.60k, False: 2.11k]
  ------------------
 7514|  1.60k|            {
 7515|  1.60k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7515:21): [True: 8, False: 1.59k]
  ------------------
 7516|      8|                {
 7517|      8|                    if (data != 0)
  ------------------
  |  Branch (7517:25): [True: 8, False: 0]
  ------------------
 7518|      8|                        _TIFFfreeExt(tif, data);
 7519|      8|                    return 0;
 7520|      8|                }
 7521|  1.59k|                int m;
 7522|  1.59k|                m = TIFFSetField(tif, dp->tdir_tag, count, data);
 7523|  1.59k|                if (data != 0)
  ------------------
  |  Branch (7523:21): [True: 676, False: 916]
  ------------------
 7524|    676|                    _TIFFfreeExt(tif, data);
 7525|  1.59k|                if (!m)
  ------------------
  |  Branch (7525:21): [True: 0, False: 1.59k]
  ------------------
 7526|      0|                    return (0);
 7527|  1.59k|            }
 7528|  3.71k|        }
 7529|  3.70k|        break;
 7530|  3.70k|        case TIFF_SETGET_C32_SINT8:
  ------------------
  |  Branch (7530:9): [True: 438, False: 207k]
  ------------------
 7531|    438|        {
 7532|    438|            int8_t *data = NULL;
 7533|    438|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7533:13): [True: 0, False: 438]
  |  Branch (7533:13): [True: 438, False: 0]
  ------------------
 7534|    438|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7534:13): [True: 0, False: 438]
  |  Branch (7534:13): [True: 438, False: 0]
  ------------------
 7535|    438|            err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
 7536|    438|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7536:17): [True: 259, False: 179]
  ------------------
 7537|    259|            {
 7538|    259|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7538:21): [True: 3, False: 256]
  ------------------
 7539|      3|                {
 7540|      3|                    if (data != 0)
  ------------------
  |  Branch (7540:25): [True: 3, False: 0]
  ------------------
 7541|      3|                        _TIFFfreeExt(tif, data);
 7542|      3|                    return 0;
 7543|      3|                }
 7544|    256|                int m;
 7545|    256|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7546|    256|                                 data);
 7547|    256|                if (data != 0)
  ------------------
  |  Branch (7547:21): [True: 220, False: 36]
  ------------------
 7548|    220|                    _TIFFfreeExt(tif, data);
 7549|    256|                if (!m)
  ------------------
  |  Branch (7549:21): [True: 0, False: 256]
  ------------------
 7550|      0|                    return (0);
 7551|    256|            }
 7552|    438|        }
 7553|    435|        break;
 7554|  5.84k|        case TIFF_SETGET_C32_UINT16:
  ------------------
  |  Branch (7554:9): [True: 5.84k, False: 201k]
  ------------------
 7555|  5.84k|        {
 7556|  5.84k|            uint16_t *data;
 7557|  5.84k|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7557:13): [True: 0, False: 5.84k]
  |  Branch (7557:13): [True: 5.84k, False: 0]
  ------------------
 7558|  5.84k|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7558:13): [True: 0, False: 5.84k]
  |  Branch (7558:13): [True: 5.84k, False: 0]
  ------------------
 7559|  5.84k|            err = TIFFReadDirEntryShortArray(tif, dp, &data);
 7560|  5.84k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7560:17): [True: 3.76k, False: 2.08k]
  ------------------
 7561|  3.76k|            {
 7562|  3.76k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7562:21): [True: 0, False: 3.76k]
  ------------------
 7563|      0|                {
 7564|      0|                    if (data != 0)
  ------------------
  |  Branch (7564:25): [True: 0, False: 0]
  ------------------
 7565|      0|                        _TIFFfreeExt(tif, data);
 7566|      0|                    return 0;
 7567|      0|                }
 7568|  3.76k|                int m;
 7569|  3.76k|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7570|  3.76k|                                 data);
 7571|  3.76k|                if (data != 0)
  ------------------
  |  Branch (7571:21): [True: 3.59k, False: 162]
  ------------------
 7572|  3.59k|                    _TIFFfreeExt(tif, data);
 7573|  3.76k|                if (!m)
  ------------------
  |  Branch (7573:21): [True: 0, False: 3.76k]
  ------------------
 7574|      0|                    return (0);
 7575|  3.76k|            }
 7576|  5.84k|        }
 7577|  5.84k|        break;
 7578|  5.84k|        case TIFF_SETGET_C32_SINT16:
  ------------------
  |  Branch (7578:9): [True: 88, False: 207k]
  ------------------
 7579|     88|        {
 7580|     88|            int16_t *data = NULL;
 7581|     88|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7581:13): [True: 0, False: 88]
  |  Branch (7581:13): [True: 88, False: 0]
  ------------------
 7582|     88|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7582:13): [True: 0, False: 88]
  |  Branch (7582:13): [True: 88, False: 0]
  ------------------
 7583|     88|            err = TIFFReadDirEntrySshortArray(tif, dp, &data);
 7584|     88|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7584:17): [True: 32, False: 56]
  ------------------
 7585|     32|            {
 7586|     32|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7586:21): [True: 3, False: 29]
  ------------------
 7587|      3|                {
 7588|      3|                    if (data != 0)
  ------------------
  |  Branch (7588:25): [True: 3, False: 0]
  ------------------
 7589|      3|                        _TIFFfreeExt(tif, data);
 7590|      3|                    return 0;
 7591|      3|                }
 7592|     29|                int m;
 7593|     29|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7594|     29|                                 data);
 7595|     29|                if (data != 0)
  ------------------
  |  Branch (7595:21): [True: 19, False: 10]
  ------------------
 7596|     19|                    _TIFFfreeExt(tif, data);
 7597|     29|                if (!m)
  ------------------
  |  Branch (7597:21): [True: 0, False: 29]
  ------------------
 7598|      0|                    return (0);
 7599|     29|            }
 7600|     88|        }
 7601|     85|        break;
 7602|  1.90k|        case TIFF_SETGET_C32_UINT32:
  ------------------
  |  Branch (7602:9): [True: 1.90k, False: 205k]
  ------------------
 7603|  1.90k|        {
 7604|  1.90k|            uint32_t *data;
 7605|  1.90k|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7605:13): [True: 0, False: 1.90k]
  |  Branch (7605:13): [True: 1.90k, False: 0]
  ------------------
 7606|  1.90k|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7606:13): [True: 0, False: 1.90k]
  |  Branch (7606:13): [True: 1.90k, False: 0]
  ------------------
 7607|  1.90k|            err = TIFFReadDirEntryLongArray(tif, dp, &data);
 7608|  1.90k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7608:17): [True: 1.12k, False: 784]
  ------------------
 7609|  1.12k|            {
 7610|  1.12k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7610:21): [True: 0, False: 1.12k]
  ------------------
 7611|      0|                {
 7612|      0|                    if (data != 0)
  ------------------
  |  Branch (7612:25): [True: 0, False: 0]
  ------------------
 7613|      0|                        _TIFFfreeExt(tif, data);
 7614|      0|                    return 0;
 7615|      0|                }
 7616|  1.12k|                int m;
 7617|  1.12k|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7618|  1.12k|                                 data);
 7619|  1.12k|                if (data != 0)
  ------------------
  |  Branch (7619:21): [True: 833, False: 289]
  ------------------
 7620|    833|                    _TIFFfreeExt(tif, data);
 7621|  1.12k|                if (!m)
  ------------------
  |  Branch (7621:21): [True: 0, False: 1.12k]
  ------------------
 7622|      0|                    return (0);
 7623|  1.12k|            }
 7624|  1.90k|        }
 7625|  1.90k|        break;
 7626|  1.90k|        case TIFF_SETGET_C32_SINT32:
  ------------------
  |  Branch (7626:9): [True: 478, False: 207k]
  ------------------
 7627|    478|        {
 7628|    478|            int32_t *data = NULL;
 7629|    478|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7629:13): [True: 0, False: 478]
  |  Branch (7629:13): [True: 478, False: 0]
  ------------------
 7630|    478|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7630:13): [True: 0, False: 478]
  |  Branch (7630:13): [True: 478, False: 0]
  ------------------
 7631|    478|            err = TIFFReadDirEntrySlongArray(tif, dp, &data);
 7632|    478|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7632:17): [True: 143, False: 335]
  ------------------
 7633|    143|            {
 7634|    143|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7634:21): [True: 0, False: 143]
  ------------------
 7635|      0|                {
 7636|      0|                    if (data != 0)
  ------------------
  |  Branch (7636:25): [True: 0, False: 0]
  ------------------
 7637|      0|                        _TIFFfreeExt(tif, data);
 7638|      0|                    return 0;
 7639|      0|                }
 7640|    143|                int m;
 7641|    143|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7642|    143|                                 data);
 7643|    143|                if (data != 0)
  ------------------
  |  Branch (7643:21): [True: 39, False: 104]
  ------------------
 7644|     39|                    _TIFFfreeExt(tif, data);
 7645|    143|                if (!m)
  ------------------
  |  Branch (7645:21): [True: 0, False: 143]
  ------------------
 7646|      0|                    return (0);
 7647|    143|            }
 7648|    478|        }
 7649|    478|        break;
 7650|  2.32k|        case TIFF_SETGET_C32_UINT64:
  ------------------
  |  Branch (7650:9): [True: 2.32k, False: 205k]
  ------------------
 7651|  2.32k|        {
 7652|  2.32k|            uint64_t *data;
 7653|  2.32k|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7653:13): [True: 0, False: 2.32k]
  |  Branch (7653:13): [True: 2.32k, False: 0]
  ------------------
 7654|  2.32k|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7654:13): [True: 0, False: 2.32k]
  |  Branch (7654:13): [True: 2.32k, False: 0]
  ------------------
 7655|  2.32k|            err = TIFFReadDirEntryLong8Array(tif, dp, &data);
 7656|  2.32k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7656:17): [True: 1.77k, False: 547]
  ------------------
 7657|  1.77k|            {
 7658|  1.77k|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7658:21): [True: 0, False: 1.77k]
  ------------------
 7659|      0|                {
 7660|      0|                    if (data != 0)
  ------------------
  |  Branch (7660:25): [True: 0, False: 0]
  ------------------
 7661|      0|                        _TIFFfreeExt(tif, data);
 7662|      0|                    return 0;
 7663|      0|                }
 7664|  1.77k|                int m;
 7665|  1.77k|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7666|  1.77k|                                 data);
 7667|  1.77k|                if (data != 0)
  ------------------
  |  Branch (7667:21): [True: 1.74k, False: 24]
  ------------------
 7668|  1.74k|                    _TIFFfreeExt(tif, data);
 7669|  1.77k|                if (!m)
  ------------------
  |  Branch (7669:21): [True: 484, False: 1.28k]
  ------------------
 7670|    484|                    return (0);
 7671|  1.77k|            }
 7672|  2.32k|        }
 7673|  1.83k|        break;
 7674|  1.83k|        case TIFF_SETGET_C32_SINT64:
  ------------------
  |  Branch (7674:9): [True: 455, False: 207k]
  ------------------
 7675|    455|        {
 7676|    455|            int64_t *data = NULL;
 7677|    455|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7677:13): [True: 0, False: 455]
  |  Branch (7677:13): [True: 455, False: 0]
  ------------------
 7678|    455|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7678:13): [True: 0, False: 455]
  |  Branch (7678:13): [True: 455, False: 0]
  ------------------
 7679|    455|            err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
 7680|    455|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7680:17): [True: 25, False: 430]
  ------------------
 7681|     25|            {
 7682|     25|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7682:21): [True: 1, False: 24]
  ------------------
 7683|      1|                {
 7684|      1|                    if (data != 0)
  ------------------
  |  Branch (7684:25): [True: 1, False: 0]
  ------------------
 7685|      1|                        _TIFFfreeExt(tif, data);
 7686|      1|                    return 0;
 7687|      1|                }
 7688|     24|                int m;
 7689|     24|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7690|     24|                                 data);
 7691|     24|                if (data != 0)
  ------------------
  |  Branch (7691:21): [True: 11, False: 13]
  ------------------
 7692|     11|                    _TIFFfreeExt(tif, data);
 7693|     24|                if (!m)
  ------------------
  |  Branch (7693:21): [True: 11, False: 13]
  ------------------
 7694|     11|                    return (0);
 7695|     24|            }
 7696|    455|        }
 7697|    443|        break;
 7698|    481|        case TIFF_SETGET_C32_FLOAT:
  ------------------
  |  Branch (7698:9): [True: 481, False: 207k]
  ------------------
 7699|    481|        {
 7700|    481|            float *data;
 7701|    481|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7701:13): [True: 0, False: 481]
  |  Branch (7701:13): [True: 481, False: 0]
  ------------------
 7702|    481|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7702:13): [True: 0, False: 481]
  |  Branch (7702:13): [True: 481, False: 0]
  ------------------
 7703|    481|            err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 7704|    481|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7704:17): [True: 388, False: 93]
  ------------------
 7705|    388|            {
 7706|    388|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7706:21): [True: 8, False: 380]
  ------------------
 7707|      8|                {
 7708|      8|                    if (data != 0)
  ------------------
  |  Branch (7708:25): [True: 8, False: 0]
  ------------------
 7709|      8|                        _TIFFfreeExt(tif, data);
 7710|      8|                    return 0;
 7711|      8|                }
 7712|    380|                int m;
 7713|    380|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7714|    380|                                 data);
 7715|    380|                if (data != 0)
  ------------------
  |  Branch (7715:21): [True: 348, False: 32]
  ------------------
 7716|    348|                    _TIFFfreeExt(tif, data);
 7717|    380|                if (!m)
  ------------------
  |  Branch (7717:21): [True: 0, False: 380]
  ------------------
 7718|      0|                    return (0);
 7719|    380|            }
 7720|    481|        }
 7721|    473|        break;
 7722|    473|        case TIFF_SETGET_C32_DOUBLE:
  ------------------
  |  Branch (7722:9): [True: 115, False: 207k]
  ------------------
 7723|    115|        {
 7724|    115|            double *data;
 7725|    115|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7725:13): [True: 0, False: 115]
  |  Branch (7725:13): [True: 115, False: 0]
  ------------------
 7726|    115|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7726:13): [True: 0, False: 115]
  |  Branch (7726:13): [True: 115, False: 0]
  ------------------
 7727|    115|            err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 7728|    115|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7728:17): [True: 90, False: 25]
  ------------------
 7729|     90|            {
 7730|     90|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7730:21): [True: 1, False: 89]
  ------------------
 7731|      1|                {
 7732|      1|                    if (data != 0)
  ------------------
  |  Branch (7732:25): [True: 1, False: 0]
  ------------------
 7733|      1|                        _TIFFfreeExt(tif, data);
 7734|      1|                    return 0;
 7735|      1|                }
 7736|     89|                int m;
 7737|     89|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7738|     89|                                 data);
 7739|     89|                if (data != 0)
  ------------------
  |  Branch (7739:21): [True: 69, False: 20]
  ------------------
 7740|     69|                    _TIFFfreeExt(tif, data);
 7741|     89|                if (!m)
  ------------------
  |  Branch (7741:21): [True: 0, False: 89]
  ------------------
 7742|      0|                    return (0);
 7743|     89|            }
 7744|    115|        }
 7745|    114|        break;
 7746|    216|        case TIFF_SETGET_C32_IFD8:
  ------------------
  |  Branch (7746:9): [True: 216, False: 207k]
  ------------------
 7747|    216|        {
 7748|    216|            uint64_t *data;
 7749|    216|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7749:13): [True: 0, False: 216]
  |  Branch (7749:13): [True: 216, False: 0]
  ------------------
 7750|    216|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7750:13): [True: 0, False: 216]
  |  Branch (7750:13): [True: 216, False: 0]
  ------------------
 7751|    216|            err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
 7752|    216|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7752:17): [True: 83, False: 133]
  ------------------
 7753|     83|            {
 7754|     83|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7754:21): [True: 5, False: 78]
  ------------------
 7755|      5|                {
 7756|      5|                    if (data != 0)
  ------------------
  |  Branch (7756:25): [True: 5, False: 0]
  ------------------
 7757|      5|                        _TIFFfreeExt(tif, data);
 7758|      5|                    return 0;
 7759|      5|                }
 7760|     78|                int m;
 7761|     78|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7762|     78|                                 data);
 7763|     78|                if (data != 0)
  ------------------
  |  Branch (7763:21): [True: 56, False: 22]
  ------------------
 7764|     56|                    _TIFFfreeExt(tif, data);
 7765|     78|                if (!m)
  ------------------
  |  Branch (7765:21): [True: 47, False: 31]
  ------------------
 7766|     47|                    return (0);
 7767|     78|            }
 7768|    216|        }
 7769|    164|        break;
 7770|    164|        case TIFF_SETGET_INT:
  ------------------
  |  Branch (7770:9): [True: 0, False: 207k]
  ------------------
 7771|      0|        case TIFF_SETGET_C0_ASCII:
  ------------------
  |  Branch (7771:9): [True: 0, False: 207k]
  ------------------
 7772|      0|        case TIFF_SETGET_OTHER:
  ------------------
  |  Branch (7772:9): [True: 0, False: 207k]
  ------------------
 7773|      0|            assert(0); /* these should not arrive here */
  ------------------
  |  Branch (7773:13): [Folded, False: 0]
  |  Branch (7773:13): [Folded, False: 0]
  ------------------
 7774|      0|            break;
 7775|      0|        default:
  ------------------
  |  Branch (7775:9): [True: 0, False: 207k]
  ------------------
 7776|      0|            assert(0); /* we should never get here */
  ------------------
  |  Branch (7776:13): [Folded, False: 0]
  |  Branch (7776:13): [Folded, False: 0]
  ------------------
 7777|      0|            break;
 7778|   207k|    }
 7779|   204k|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7779:9): [True: 16.7k, False: 187k]
  ------------------
 7780|  16.7k|    {
 7781|  16.7k|        TIFFReadDirEntryOutputErr(tif, err, module, fip->field_name, recover);
 7782|  16.7k|        return (0);
 7783|  16.7k|    }
 7784|   187k|    return (1);
 7785|   204k|}
tif_dirread.c:TIFFReadDirEntryByteArray:
 1397|  7.51k|{
 1398|  7.51k|    enum TIFFReadDirEntryErr err;
 1399|  7.51k|    uint32_t count;
 1400|  7.51k|    void *origdata;
 1401|  7.51k|    uint8_t *data;
 1402|  7.51k|    switch (direntry->tdir_type)
 1403|  7.51k|    {
 1404|  2.40k|        case TIFF_ASCII:
  ------------------
  |  Branch (1404:9): [True: 2.40k, False: 5.10k]
  ------------------
 1405|  2.62k|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1405:9): [True: 215, False: 7.29k]
  ------------------
 1406|  6.12k|        case TIFF_BYTE:
  ------------------
  |  Branch (1406:9): [True: 3.50k, False: 4.00k]
  ------------------
 1407|  6.14k|        case TIFF_SBYTE:
  ------------------
  |  Branch (1407:9): [True: 20, False: 7.49k]
  ------------------
 1408|  6.58k|        case TIFF_SHORT:
  ------------------
  |  Branch (1408:9): [True: 436, False: 7.07k]
  ------------------
 1409|  6.60k|        case TIFF_SSHORT:
  ------------------
  |  Branch (1409:9): [True: 23, False: 7.48k]
  ------------------
 1410|  6.76k|        case TIFF_LONG:
  ------------------
  |  Branch (1410:9): [True: 160, False: 7.35k]
  ------------------
 1411|  6.77k|        case TIFF_SLONG:
  ------------------
  |  Branch (1411:9): [True: 11, False: 7.50k]
  ------------------
 1412|  6.95k|        case TIFF_LONG8:
  ------------------
  |  Branch (1412:9): [True: 175, False: 7.33k]
  ------------------
 1413|  6.97k|        case TIFF_SLONG8:
  ------------------
  |  Branch (1413:9): [True: 22, False: 7.48k]
  ------------------
 1414|  6.97k|            break;
 1415|    538|        default:
  ------------------
  |  Branch (1415:9): [True: 538, False: 6.97k]
  ------------------
 1416|    538|            return (TIFFReadDirEntryErrType);
 1417|  7.51k|    }
 1418|  6.97k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
 1419|  6.97k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1419:9): [True: 3.05k, False: 3.91k]
  |  Branch (1419:43): [True: 998, False: 2.91k]
  ------------------
 1420|  4.05k|    {
 1421|  4.05k|        *value = 0;
 1422|  4.05k|        return (err);
 1423|  4.05k|    }
 1424|  2.91k|    switch (direntry->tdir_type)
 1425|  2.91k|    {
 1426|  1.51k|        case TIFF_ASCII:
  ------------------
  |  Branch (1426:9): [True: 1.51k, False: 1.40k]
  ------------------
 1427|  1.69k|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1427:9): [True: 183, False: 2.73k]
  ------------------
 1428|  2.19k|        case TIFF_BYTE:
  ------------------
  |  Branch (1428:9): [True: 500, False: 2.41k]
  ------------------
 1429|  2.19k|            *value = (uint8_t *)origdata;
 1430|  2.19k|            return (TIFFReadDirEntryErrOk);
 1431|     12|        case TIFF_SBYTE:
  ------------------
  |  Branch (1431:9): [True: 12, False: 2.90k]
  ------------------
 1432|     12|        {
 1433|     12|            int8_t *m;
 1434|     12|            uint32_t n;
 1435|     12|            m = (int8_t *)origdata;
 1436|     52|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1436:25): [True: 40, False: 12]
  ------------------
 1437|     40|            {
 1438|     40|                err = TIFFReadDirEntryCheckRangeByteSbyte(*m);
 1439|     40|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1439:21): [True: 0, False: 40]
  ------------------
 1440|      0|                {
 1441|      0|                    _TIFFfreeExt(tif, origdata);
 1442|      0|                    return (err);
 1443|      0|                }
 1444|     40|                m++;
 1445|     40|            }
 1446|     12|            *value = (uint8_t *)origdata;
 1447|     12|            return (TIFFReadDirEntryErrOk);
 1448|     12|        }
 1449|    707|        default:
  ------------------
  |  Branch (1449:9): [True: 707, False: 2.20k]
  ------------------
 1450|    707|            break;
 1451|  2.91k|    }
 1452|    707|    data = (uint8_t *)_TIFFmallocExt(tif, count);
 1453|    707|    if (data == 0)
  ------------------
  |  Branch (1453:9): [True: 0, False: 707]
  ------------------
 1454|      0|    {
 1455|      0|        _TIFFfreeExt(tif, origdata);
 1456|      0|        return (TIFFReadDirEntryErrAlloc);
 1457|      0|    }
 1458|    707|    switch (direntry->tdir_type)
 1459|    707|    {
 1460|    400|        case TIFF_SHORT:
  ------------------
  |  Branch (1460:9): [True: 400, False: 307]
  ------------------
 1461|    400|        {
 1462|    400|            uint16_t *ma;
 1463|    400|            uint8_t *mb;
 1464|    400|            uint32_t n;
 1465|    400|            ma = (uint16_t *)origdata;
 1466|    400|            mb = data;
 1467|    672|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1467:25): [True: 484, False: 188]
  ------------------
 1468|    484|            {
 1469|    484|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    484|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1469:21): [True: 0, False: 484]
  ------------------
 1470|      0|                    TIFFSwabShort(ma);
 1471|    484|                err = TIFFReadDirEntryCheckRangeByteShort(*ma);
 1472|    484|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1472:21): [True: 212, False: 272]
  ------------------
 1473|    212|                    break;
 1474|    272|                *mb++ = (uint8_t)(*ma++);
 1475|    272|            }
 1476|    400|        }
 1477|    400|        break;
 1478|     23|        case TIFF_SSHORT:
  ------------------
  |  Branch (1478:9): [True: 23, False: 684]
  ------------------
 1479|     23|        {
 1480|     23|            int16_t *ma;
 1481|     23|            uint8_t *mb;
 1482|     23|            uint32_t n;
 1483|     23|            ma = (int16_t *)origdata;
 1484|     23|            mb = data;
 1485|  1.22k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1485:25): [True: 1.22k, False: 7]
  ------------------
 1486|  1.22k|            {
 1487|  1.22k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.22k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1487:21): [True: 1.19k, False: 22]
  ------------------
 1488|  1.19k|                    TIFFSwabShort((uint16_t *)ma);
 1489|  1.22k|                err = TIFFReadDirEntryCheckRangeByteSshort(*ma);
 1490|  1.22k|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1490:21): [True: 16, False: 1.20k]
  ------------------
 1491|     16|                    break;
 1492|  1.20k|                *mb++ = (uint8_t)(*ma++);
 1493|  1.20k|            }
 1494|     23|        }
 1495|     23|        break;
 1496|     98|        case TIFF_LONG:
  ------------------
  |  Branch (1496:9): [True: 98, False: 609]
  ------------------
 1497|     98|        {
 1498|     98|            uint32_t *ma;
 1499|     98|            uint8_t *mb;
 1500|     98|            uint32_t n;
 1501|     98|            ma = (uint32_t *)origdata;
 1502|     98|            mb = data;
 1503|    141|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1503:25): [True: 98, False: 43]
  ------------------
 1504|     98|            {
 1505|     98|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     98|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1505:21): [True: 0, False: 98]
  ------------------
 1506|      0|                    TIFFSwabLong(ma);
 1507|     98|                err = TIFFReadDirEntryCheckRangeByteLong(*ma);
 1508|     98|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1508:21): [True: 55, False: 43]
  ------------------
 1509|     55|                    break;
 1510|     43|                *mb++ = (uint8_t)(*ma++);
 1511|     43|            }
 1512|     98|        }
 1513|     98|        break;
 1514|     11|        case TIFF_SLONG:
  ------------------
  |  Branch (1514:9): [True: 11, False: 696]
  ------------------
 1515|     11|        {
 1516|     11|            int32_t *ma;
 1517|     11|            uint8_t *mb;
 1518|     11|            uint32_t n;
 1519|     11|            ma = (int32_t *)origdata;
 1520|     11|            mb = data;
 1521|     23|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1521:25): [True: 19, False: 4]
  ------------------
 1522|     19|            {
 1523|     19|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     19|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1523:21): [True: 0, False: 19]
  ------------------
 1524|      0|                    TIFFSwabLong((uint32_t *)ma);
 1525|     19|                err = TIFFReadDirEntryCheckRangeByteSlong(*ma);
 1526|     19|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1526:21): [True: 7, False: 12]
  ------------------
 1527|      7|                    break;
 1528|     12|                *mb++ = (uint8_t)(*ma++);
 1529|     12|            }
 1530|     11|        }
 1531|     11|        break;
 1532|    164|        case TIFF_LONG8:
  ------------------
  |  Branch (1532:9): [True: 164, False: 543]
  ------------------
 1533|    164|        {
 1534|    164|            uint64_t *ma;
 1535|    164|            uint8_t *mb;
 1536|    164|            uint32_t n;
 1537|    164|            ma = (uint64_t *)origdata;
 1538|    164|            mb = data;
 1539|    233|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1539:25): [True: 225, False: 8]
  ------------------
 1540|    225|            {
 1541|    225|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    225|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1541:21): [True: 0, False: 225]
  ------------------
 1542|      0|                    TIFFSwabLong8(ma);
 1543|    225|                err = TIFFReadDirEntryCheckRangeByteLong8(*ma);
 1544|    225|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1544:21): [True: 156, False: 69]
  ------------------
 1545|    156|                    break;
 1546|     69|                *mb++ = (uint8_t)(*ma++);
 1547|     69|            }
 1548|    164|        }
 1549|    164|        break;
 1550|     11|        case TIFF_SLONG8:
  ------------------
  |  Branch (1550:9): [True: 11, False: 696]
  ------------------
 1551|     11|        {
 1552|     11|            int64_t *ma;
 1553|     11|            uint8_t *mb;
 1554|     11|            uint32_t n;
 1555|     11|            ma = (int64_t *)origdata;
 1556|     11|            mb = data;
 1557|     18|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1557:25): [True: 11, False: 7]
  ------------------
 1558|     11|            {
 1559|     11|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1559:21): [True: 0, False: 11]
  ------------------
 1560|      0|                    TIFFSwabLong8((uint64_t *)ma);
 1561|     11|                err = TIFFReadDirEntryCheckRangeByteSlong8(*ma);
 1562|     11|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1562:21): [True: 4, False: 7]
  ------------------
 1563|      4|                    break;
 1564|      7|                *mb++ = (uint8_t)(*ma++);
 1565|      7|            }
 1566|     11|        }
 1567|     11|        break;
 1568|      0|        default:
  ------------------
  |  Branch (1568:9): [True: 0, False: 707]
  ------------------
 1569|      0|            break;
 1570|    707|    }
 1571|    707|    _TIFFfreeExt(tif, origdata);
 1572|    707|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1572:9): [True: 450, False: 257]
  ------------------
 1573|    450|    {
 1574|    450|        _TIFFfreeExt(tif, data);
 1575|    450|        return (err);
 1576|    450|    }
 1577|    257|    *value = data;
 1578|    257|    return (TIFFReadDirEntryErrOk);
 1579|    707|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSbyte:
 3646|     52|{
 3647|     52|    if (value < 0)
  ------------------
  |  Branch (3647:9): [True: 8, False: 44]
  ------------------
 3648|      8|        return (TIFFReadDirEntryErrRange);
 3649|     44|    else
 3650|     44|        return (TIFFReadDirEntryErrOk);
 3651|     52|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteShort:
 3655|    613|{
 3656|    613|    if (value > 0xFF)
  ------------------
  |  Branch (3656:9): [True: 224, False: 389]
  ------------------
 3657|    224|        return (TIFFReadDirEntryErrRange);
 3658|    389|    else
 3659|    389|        return (TIFFReadDirEntryErrOk);
 3660|    613|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSshort:
 3664|  1.23k|{
 3665|  1.23k|    if ((value < 0) || (value > 0xFF))
  ------------------
  |  Branch (3665:9): [True: 8, False: 1.22k]
  |  Branch (3665:24): [True: 15, False: 1.20k]
  ------------------
 3666|     23|        return (TIFFReadDirEntryErrRange);
 3667|  1.20k|    else
 3668|  1.20k|        return (TIFFReadDirEntryErrOk);
 3669|  1.23k|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteLong:
 3673|    117|{
 3674|    117|    if (value > 0xFF)
  ------------------
  |  Branch (3674:9): [True: 59, False: 58]
  ------------------
 3675|     59|        return (TIFFReadDirEntryErrRange);
 3676|     58|    else
 3677|     58|        return (TIFFReadDirEntryErrOk);
 3678|    117|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSlong:
 3682|     27|{
 3683|     27|    if ((value < 0) || (value > 0xFF))
  ------------------
  |  Branch (3683:9): [True: 3, False: 24]
  |  Branch (3683:24): [True: 8, False: 16]
  ------------------
 3684|     11|        return (TIFFReadDirEntryErrRange);
 3685|     16|    else
 3686|     16|        return (TIFFReadDirEntryErrOk);
 3687|     27|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteLong8:
 3691|    236|{
 3692|    236|    if (value > 0xFF)
  ------------------
  |  Branch (3692:9): [True: 159, False: 77]
  ------------------
 3693|    159|        return (TIFFReadDirEntryErrRange);
 3694|     77|    else
 3695|     77|        return (TIFFReadDirEntryErrOk);
 3696|    236|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSlong8:
 3700|     24|{
 3701|     24|    if ((value < 0) || (value > 0xFF))
  ------------------
  |  Branch (3701:9): [True: 4, False: 20]
  |  Branch (3701:24): [True: 10, False: 10]
  ------------------
 3702|     14|        return (TIFFReadDirEntryErrRange);
 3703|     10|    else
 3704|     10|        return (TIFFReadDirEntryErrOk);
 3705|     24|}
tif_dirread.c:TIFFReadDirEntryByte:
  300|    274|{
  301|    274|    enum TIFFReadDirEntryErr err;
  302|    274|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (302:9): [True: 45, False: 229]
  ------------------
  303|     45|        return (TIFFReadDirEntryErrCount);
  304|    229|    switch (direntry->tdir_type)
  305|    229|    {
  306|      7|        case TIFF_BYTE:
  ------------------
  |  Branch (306:9): [True: 7, False: 222]
  ------------------
  307|     14|        case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with
  ------------------
  |  Branch (307:9): [True: 7, False: 222]
  ------------------
  308|       |                                field_readcount==1 */
  309|     14|            TIFFReadDirEntryCheckedByte(tif, direntry, value);
  310|     14|            return (TIFFReadDirEntryErrOk);
  311|     12|        case TIFF_SBYTE:
  ------------------
  |  Branch (311:9): [True: 12, False: 217]
  ------------------
  312|     12|        {
  313|     12|            int8_t m;
  314|     12|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  315|     12|            err = TIFFReadDirEntryCheckRangeByteSbyte(m);
  316|     12|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (316:17): [True: 8, False: 4]
  ------------------
  317|      8|                return (err);
  318|      4|            *value = (uint8_t)m;
  319|      4|            return (TIFFReadDirEntryErrOk);
  320|     12|        }
  321|    129|        case TIFF_SHORT:
  ------------------
  |  Branch (321:9): [True: 129, False: 100]
  ------------------
  322|    129|        {
  323|    129|            uint16_t m;
  324|    129|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  325|    129|            err = TIFFReadDirEntryCheckRangeByteShort(m);
  326|    129|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (326:17): [True: 12, False: 117]
  ------------------
  327|     12|                return (err);
  328|    117|            *value = (uint8_t)m;
  329|    117|            return (TIFFReadDirEntryErrOk);
  330|    129|        }
  331|     11|        case TIFF_SSHORT:
  ------------------
  |  Branch (331:9): [True: 11, False: 218]
  ------------------
  332|     11|        {
  333|     11|            int16_t m;
  334|     11|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  335|     11|            err = TIFFReadDirEntryCheckRangeByteSshort(m);
  336|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (336:17): [True: 7, False: 4]
  ------------------
  337|      7|                return (err);
  338|      4|            *value = (uint8_t)m;
  339|      4|            return (TIFFReadDirEntryErrOk);
  340|     11|        }
  341|     19|        case TIFF_LONG:
  ------------------
  |  Branch (341:9): [True: 19, False: 210]
  ------------------
  342|     19|        {
  343|     19|            uint32_t m;
  344|     19|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  345|     19|            err = TIFFReadDirEntryCheckRangeByteLong(m);
  346|     19|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (346:17): [True: 4, False: 15]
  ------------------
  347|      4|                return (err);
  348|     15|            *value = (uint8_t)m;
  349|     15|            return (TIFFReadDirEntryErrOk);
  350|     19|        }
  351|      8|        case TIFF_SLONG:
  ------------------
  |  Branch (351:9): [True: 8, False: 221]
  ------------------
  352|      8|        {
  353|      8|            int32_t m;
  354|      8|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  355|      8|            err = TIFFReadDirEntryCheckRangeByteSlong(m);
  356|      8|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (356:17): [True: 4, False: 4]
  ------------------
  357|      4|                return (err);
  358|      4|            *value = (uint8_t)m;
  359|      4|            return (TIFFReadDirEntryErrOk);
  360|      8|        }
  361|     11|        case TIFF_LONG8:
  ------------------
  |  Branch (361:9): [True: 11, False: 218]
  ------------------
  362|     11|        {
  363|     11|            uint64_t m;
  364|     11|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  365|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (365:17): [True: 0, False: 11]
  ------------------
  366|      0|                return (err);
  367|     11|            err = TIFFReadDirEntryCheckRangeByteLong8(m);
  368|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (368:17): [True: 3, False: 8]
  ------------------
  369|      3|                return (err);
  370|      8|            *value = (uint8_t)m;
  371|      8|            return (TIFFReadDirEntryErrOk);
  372|     11|        }
  373|     13|        case TIFF_SLONG8:
  ------------------
  |  Branch (373:9): [True: 13, False: 216]
  ------------------
  374|     13|        {
  375|     13|            int64_t m;
  376|     13|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  377|     13|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (377:17): [True: 0, False: 13]
  ------------------
  378|      0|                return (err);
  379|     13|            err = TIFFReadDirEntryCheckRangeByteSlong8(m);
  380|     13|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (380:17): [True: 10, False: 3]
  ------------------
  381|     10|                return (err);
  382|      3|            *value = (uint8_t)m;
  383|      3|            return (TIFFReadDirEntryErrOk);
  384|     13|        }
  385|     12|        default:
  ------------------
  |  Branch (385:9): [True: 12, False: 217]
  ------------------
  386|     12|            return (TIFFReadDirEntryErrType);
  387|    229|    }
  388|    229|}
tif_dirread.c:TIFFReadDirEntryLong:
  657|  9.38k|{
  658|  9.38k|    enum TIFFReadDirEntryErr err;
  659|  9.38k|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (659:9): [True: 459, False: 8.92k]
  ------------------
  660|    459|        return (TIFFReadDirEntryErrCount);
  661|  8.92k|    switch (direntry->tdir_type)
  662|  8.92k|    {
  663|    125|        case TIFF_BYTE:
  ------------------
  |  Branch (663:9): [True: 125, False: 8.80k]
  ------------------
  664|    125|        {
  665|    125|            uint8_t m;
  666|    125|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  667|    125|            *value = (uint32_t)m;
  668|    125|            return (TIFFReadDirEntryErrOk);
  669|      0|        }
  670|    191|        case TIFF_SBYTE:
  ------------------
  |  Branch (670:9): [True: 191, False: 8.73k]
  ------------------
  671|    191|        {
  672|    191|            int8_t m;
  673|    191|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  674|    191|            err = TIFFReadDirEntryCheckRangeLongSbyte(m);
  675|    191|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (675:17): [True: 0, False: 191]
  ------------------
  676|      0|                return (err);
  677|    191|            *value = (uint32_t)m;
  678|    191|            return (TIFFReadDirEntryErrOk);
  679|    191|        }
  680|  7.98k|        case TIFF_SHORT:
  ------------------
  |  Branch (680:9): [True: 7.98k, False: 941]
  ------------------
  681|  7.98k|        {
  682|  7.98k|            uint16_t m;
  683|  7.98k|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  684|  7.98k|            *value = (uint32_t)m;
  685|  7.98k|            return (TIFFReadDirEntryErrOk);
  686|    191|        }
  687|     28|        case TIFF_SSHORT:
  ------------------
  |  Branch (687:9): [True: 28, False: 8.89k]
  ------------------
  688|     28|        {
  689|     28|            int16_t m;
  690|     28|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  691|     28|            err = TIFFReadDirEntryCheckRangeLongSshort(m);
  692|     28|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (692:17): [True: 7, False: 21]
  ------------------
  693|      7|                return (err);
  694|     21|            *value = (uint32_t)m;
  695|     21|            return (TIFFReadDirEntryErrOk);
  696|     28|        }
  697|    468|        case TIFF_LONG:
  ------------------
  |  Branch (697:9): [True: 468, False: 8.45k]
  ------------------
  698|    488|        case TIFF_IFD:
  ------------------
  |  Branch (698:9): [True: 20, False: 8.90k]
  ------------------
  699|    488|            TIFFReadDirEntryCheckedLong(tif, direntry, value);
  700|    488|            return (TIFFReadDirEntryErrOk);
  701|     23|        case TIFF_SLONG:
  ------------------
  |  Branch (701:9): [True: 23, False: 8.90k]
  ------------------
  702|     23|        {
  703|     23|            int32_t m;
  704|     23|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  705|     23|            err = TIFFReadDirEntryCheckRangeLongSlong(m);
  706|     23|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (706:17): [True: 4, False: 19]
  ------------------
  707|      4|                return (err);
  708|     19|            *value = (uint32_t)m;
  709|     19|            return (TIFFReadDirEntryErrOk);
  710|     23|        }
  711|     43|        case TIFF_LONG8:
  ------------------
  |  Branch (711:9): [True: 43, False: 8.88k]
  ------------------
  712|     47|        case TIFF_IFD8:
  ------------------
  |  Branch (712:9): [True: 4, False: 8.92k]
  ------------------
  713|     47|        {
  714|     47|            uint64_t m;
  715|     47|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  716|     47|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (716:17): [True: 0, False: 47]
  ------------------
  717|      0|                return (err);
  718|     47|            err = TIFFReadDirEntryCheckRangeLongLong8(m);
  719|     47|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (719:17): [True: 39, False: 8]
  ------------------
  720|     39|                return (err);
  721|      8|            *value = (uint32_t)m;
  722|      8|            return (TIFFReadDirEntryErrOk);
  723|     47|        }
  724|     11|        case TIFF_SLONG8:
  ------------------
  |  Branch (724:9): [True: 11, False: 8.91k]
  ------------------
  725|     11|        {
  726|     11|            int64_t m;
  727|     11|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  728|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (728:17): [True: 0, False: 11]
  ------------------
  729|      0|                return (err);
  730|     11|            err = TIFFReadDirEntryCheckRangeLongSlong8(m);
  731|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (731:17): [True: 11, False: 0]
  ------------------
  732|     11|                return (err);
  733|      0|            *value = (uint32_t)m;
  734|      0|            return (TIFFReadDirEntryErrOk);
  735|     11|        }
  736|     28|        default:
  ------------------
  |  Branch (736:9): [True: 28, False: 8.89k]
  ------------------
  737|     28|            return (TIFFReadDirEntryErrType);
  738|  8.92k|    }
  739|  8.92k|} /*-- TIFFReadDirEntryLong() --*/
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSbyte:
 3871|    246|{
 3872|    246|    if (value < 0)
  ------------------
  |  Branch (3872:9): [True: 11, False: 235]
  ------------------
 3873|     11|        return (TIFFReadDirEntryErrRange);
 3874|    235|    else
 3875|    235|        return (TIFFReadDirEntryErrOk);
 3876|    246|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSshort:
 3880|    485|{
 3881|    485|    if (value < 0)
  ------------------
  |  Branch (3881:9): [True: 132, False: 353]
  ------------------
 3882|    132|        return (TIFFReadDirEntryErrRange);
 3883|    353|    else
 3884|    353|        return (TIFFReadDirEntryErrOk);
 3885|    485|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSlong:
 3889|     48|{
 3890|     48|    if (value < 0)
  ------------------
  |  Branch (3890:9): [True: 8, False: 40]
  ------------------
 3891|      8|        return (TIFFReadDirEntryErrRange);
 3892|     40|    else
 3893|     40|        return (TIFFReadDirEntryErrOk);
 3894|     48|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongLong8:
 3898|     65|{
 3899|     65|    if (value > UINT32_MAX)
  ------------------
  |  Branch (3899:9): [True: 48, False: 17]
  ------------------
 3900|     48|        return (TIFFReadDirEntryErrRange);
 3901|     17|    else
 3902|     17|        return (TIFFReadDirEntryErrOk);
 3903|     65|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSlong8:
 3907|     43|{
 3908|     43|    if ((value < 0) || (value > (int64_t)UINT32_MAX))
  ------------------
  |  Branch (3908:9): [True: 7, False: 36]
  |  Branch (3908:24): [True: 15, False: 21]
  ------------------
 3909|     22|        return (TIFFReadDirEntryErrRange);
 3910|     21|    else
 3911|     21|        return (TIFFReadDirEntryErrOk);
 3912|     43|}
tif_dirread.c:TIFFReadDirEntryLong8:
  821|    467|{
  822|    467|    enum TIFFReadDirEntryErr err;
  823|    467|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (823:9): [True: 325, False: 142]
  ------------------
  824|    325|        return (TIFFReadDirEntryErrCount);
  825|    142|    switch (direntry->tdir_type)
  826|    142|    {
  827|      3|        case TIFF_BYTE:
  ------------------
  |  Branch (827:9): [True: 3, False: 139]
  ------------------
  828|      3|        {
  829|      3|            uint8_t m;
  830|      3|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  831|      3|            *value = (uint64_t)m;
  832|      3|            return (TIFFReadDirEntryErrOk);
  833|      0|        }
  834|      8|        case TIFF_SBYTE:
  ------------------
  |  Branch (834:9): [True: 8, False: 134]
  ------------------
  835|      8|        {
  836|      8|            int8_t m;
  837|      8|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  838|      8|            err = TIFFReadDirEntryCheckRangeLong8Sbyte(m);
  839|      8|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (839:17): [True: 4, False: 4]
  ------------------
  840|      4|                return (err);
  841|      4|            *value = (uint64_t)m;
  842|      4|            return (TIFFReadDirEntryErrOk);
  843|      8|        }
  844|     45|        case TIFF_SHORT:
  ------------------
  |  Branch (844:9): [True: 45, False: 97]
  ------------------
  845|     45|        {
  846|     45|            uint16_t m;
  847|     45|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  848|     45|            *value = (uint64_t)m;
  849|     45|            return (TIFFReadDirEntryErrOk);
  850|      8|        }
  851|     14|        case TIFF_SSHORT:
  ------------------
  |  Branch (851:9): [True: 14, False: 128]
  ------------------
  852|     14|        {
  853|     14|            int16_t m;
  854|     14|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  855|     14|            err = TIFFReadDirEntryCheckRangeLong8Sshort(m);
  856|     14|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (856:17): [True: 7, False: 7]
  ------------------
  857|      7|                return (err);
  858|      7|            *value = (uint64_t)m;
  859|      7|            return (TIFFReadDirEntryErrOk);
  860|     14|        }
  861|      3|        case TIFF_LONG:
  ------------------
  |  Branch (861:9): [True: 3, False: 139]
  ------------------
  862|     11|        case TIFF_IFD:
  ------------------
  |  Branch (862:9): [True: 8, False: 134]
  ------------------
  863|     11|        {
  864|     11|            uint32_t m;
  865|     11|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  866|     11|            *value = (uint64_t)m;
  867|     11|            return (TIFFReadDirEntryErrOk);
  868|      3|        }
  869|     31|        case TIFF_SLONG:
  ------------------
  |  Branch (869:9): [True: 31, False: 111]
  ------------------
  870|     31|        {
  871|     31|            int32_t m;
  872|     31|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  873|     31|            err = TIFFReadDirEntryCheckRangeLong8Slong(m);
  874|     31|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (874:17): [True: 8, False: 23]
  ------------------
  875|      8|                return (err);
  876|     23|            *value = (uint64_t)m;
  877|     23|            return (TIFFReadDirEntryErrOk);
  878|     31|        }
  879|     13|        case TIFF_LONG8:
  ------------------
  |  Branch (879:9): [True: 13, False: 129]
  ------------------
  880|     13|        case TIFF_IFD8:
  ------------------
  |  Branch (880:9): [True: 0, False: 142]
  ------------------
  881|     13|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
  882|     13|            return (err);
  883|     11|        case TIFF_SLONG8:
  ------------------
  |  Branch (883:9): [True: 11, False: 131]
  ------------------
  884|     11|        {
  885|     11|            int64_t m;
  886|     11|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  887|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (887:17): [True: 0, False: 11]
  ------------------
  888|      0|                return (err);
  889|     11|            err = TIFFReadDirEntryCheckRangeLong8Slong8(m);
  890|     11|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (890:17): [True: 0, False: 11]
  ------------------
  891|      0|                return (err);
  892|     11|            *value = (uint64_t)m;
  893|     11|            return (TIFFReadDirEntryErrOk);
  894|     11|        }
  895|      6|        default:
  ------------------
  |  Branch (895:9): [True: 6, False: 136]
  ------------------
  896|      6|            return (TIFFReadDirEntryErrType);
  897|    142|    }
  898|    142|} /*-- TIFFReadDirEntryLong8() --*/
tif_dirread.c:TIFFReadDirEntryCheckRangeLong8Sbyte:
 3945|    164|{
 3946|    164|    if (value < 0)
  ------------------
  |  Branch (3946:9): [True: 17, False: 147]
  ------------------
 3947|     17|        return (TIFFReadDirEntryErrRange);
 3948|    147|    else
 3949|    147|        return (TIFFReadDirEntryErrOk);
 3950|    164|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLong8Sshort:
 3954|    290|{
 3955|    290|    if (value < 0)
  ------------------
  |  Branch (3955:9): [True: 7, False: 283]
  ------------------
 3956|      7|        return (TIFFReadDirEntryErrRange);
 3957|    283|    else
 3958|    283|        return (TIFFReadDirEntryErrOk);
 3959|    290|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLong8Slong:
 3963|     63|{
 3964|     63|    if (value < 0)
  ------------------
  |  Branch (3964:9): [True: 16, False: 47]
  ------------------
 3965|     16|        return (TIFFReadDirEntryErrRange);
 3966|     47|    else
 3967|     47|        return (TIFFReadDirEntryErrOk);
 3968|     63|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLong8Slong8:
 3972|     37|{
 3973|     37|    if (value < 0)
  ------------------
  |  Branch (3973:9): [True: 4, False: 33]
  ------------------
 3974|      4|        return (TIFFReadDirEntryErrRange);
 3975|     33|    else
 3976|     33|        return (TIFFReadDirEntryErrOk);
 3977|     37|}
tif_dirread.c:TIFFReadDirEntryFloat:
  972|  4.46k|{
  973|  4.46k|    enum TIFFReadDirEntryErr err;
  974|  4.46k|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (974:9): [True: 2.32k, False: 2.13k]
  ------------------
  975|  2.32k|        return (TIFFReadDirEntryErrCount);
  976|  2.13k|    switch (direntry->tdir_type)
  977|  2.13k|    {
  978|     14|        case TIFF_BYTE:
  ------------------
  |  Branch (978:9): [True: 14, False: 2.12k]
  ------------------
  979|     14|        {
  980|     14|            uint8_t m;
  981|     14|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  982|     14|            *value = (float)m;
  983|     14|            return (TIFFReadDirEntryErrOk);
  984|      0|        }
  985|      4|        case TIFF_SBYTE:
  ------------------
  |  Branch (985:9): [True: 4, False: 2.13k]
  ------------------
  986|      4|        {
  987|      4|            int8_t m;
  988|      4|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  989|      4|            *value = (float)m;
  990|      4|            return (TIFFReadDirEntryErrOk);
  991|      0|        }
  992|     33|        case TIFF_SHORT:
  ------------------
  |  Branch (992:9): [True: 33, False: 2.10k]
  ------------------
  993|     33|        {
  994|     33|            uint16_t m;
  995|     33|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  996|     33|            *value = (float)m;
  997|     33|            return (TIFFReadDirEntryErrOk);
  998|      0|        }
  999|      8|        case TIFF_SSHORT:
  ------------------
  |  Branch (999:9): [True: 8, False: 2.13k]
  ------------------
 1000|      8|        {
 1001|      8|            int16_t m;
 1002|      8|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
 1003|      8|            *value = (float)m;
 1004|      8|            return (TIFFReadDirEntryErrOk);
 1005|      0|        }
 1006|     40|        case TIFF_LONG:
  ------------------
  |  Branch (1006:9): [True: 40, False: 2.09k]
  ------------------
 1007|     40|        {
 1008|     40|            uint32_t m;
 1009|     40|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
 1010|     40|            *value = (float)m;
 1011|     40|            return (TIFFReadDirEntryErrOk);
 1012|      0|        }
 1013|     19|        case TIFF_SLONG:
  ------------------
  |  Branch (1013:9): [True: 19, False: 2.12k]
  ------------------
 1014|     19|        {
 1015|     19|            int32_t m;
 1016|     19|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
 1017|     19|            *value = (float)m;
 1018|     19|            return (TIFFReadDirEntryErrOk);
 1019|      0|        }
 1020|     18|        case TIFF_LONG8:
  ------------------
  |  Branch (1020:9): [True: 18, False: 2.12k]
  ------------------
 1021|     18|        {
 1022|     18|            uint64_t m;
 1023|     18|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
 1024|     18|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1024:17): [True: 0, False: 18]
  ------------------
 1025|      0|                return (err);
 1026|     18|            *value = (float)m;
 1027|     18|            return (TIFFReadDirEntryErrOk);
 1028|     18|        }
 1029|      7|        case TIFF_SLONG8:
  ------------------
  |  Branch (1029:9): [True: 7, False: 2.13k]
  ------------------
 1030|      7|        {
 1031|      7|            int64_t m;
 1032|      7|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
 1033|      7|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1033:17): [True: 0, False: 7]
  ------------------
 1034|      0|                return (err);
 1035|      7|            *value = (float)m;
 1036|      7|            return (TIFFReadDirEntryErrOk);
 1037|      7|        }
 1038|  1.56k|        case TIFF_RATIONAL:
  ------------------
  |  Branch (1038:9): [True: 1.56k, False: 577]
  ------------------
 1039|  1.56k|        {
 1040|  1.56k|            double m;
 1041|  1.56k|            err = TIFFReadDirEntryCheckedRational(tif, direntry, &m);
 1042|  1.56k|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1042:17): [True: 15, False: 1.54k]
  ------------------
 1043|     15|                return (err);
 1044|  1.54k|            *value = (float)m;
 1045|  1.54k|            return (TIFFReadDirEntryErrOk);
 1046|  1.56k|        }
 1047|      3|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (1047:9): [True: 3, False: 2.13k]
  ------------------
 1048|      3|        {
 1049|      3|            double m;
 1050|      3|            err = TIFFReadDirEntryCheckedSrational(tif, direntry, &m);
 1051|      3|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1051:17): [True: 0, False: 3]
  ------------------
 1052|      0|                return (err);
 1053|      3|            *value = (float)m;
 1054|      3|            return (TIFFReadDirEntryErrOk);
 1055|      3|        }
 1056|     11|        case TIFF_FLOAT:
  ------------------
  |  Branch (1056:9): [True: 11, False: 2.12k]
  ------------------
 1057|     11|            TIFFReadDirEntryCheckedFloat(tif, direntry, value);
 1058|     11|            return (TIFFReadDirEntryErrOk);
 1059|      6|        case TIFF_DOUBLE:
  ------------------
  |  Branch (1059:9): [True: 6, False: 2.13k]
  ------------------
 1060|      6|        {
 1061|      6|            double m;
 1062|      6|            err = TIFFReadDirEntryCheckedDouble(tif, direntry, &m);
 1063|      6|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1063:17): [True: 0, False: 6]
  ------------------
 1064|      0|                return (err);
 1065|      6|            if ((m > (double)FLT_MAX) || (m < -(double)FLT_MAX))
  ------------------
  |  Branch (1065:17): [True: 0, False: 6]
  |  Branch (1065:42): [True: 5, False: 1]
  ------------------
 1066|      5|                return (TIFFReadDirEntryErrRange);
 1067|      1|            *value = (float)m;
 1068|      1|            return (TIFFReadDirEntryErrOk);
 1069|      6|        }
 1070|    414|        default:
  ------------------
  |  Branch (1070:9): [True: 414, False: 1.72k]
  ------------------
 1071|    414|            return (TIFFReadDirEntryErrType);
 1072|  2.13k|    }
 1073|  2.13k|}
tif_dirread.c:TIFFReadDirEntryCheckedRational:
 3494|  1.56k|{
 3495|  1.56k|    UInt64Aligned_t m;
 3496|       |
 3497|  1.56k|    assert(sizeof(double) == 8);
  ------------------
  |  Branch (3497:5): [True: 0, Folded]
  |  Branch (3497:5): [True: 1.56k, Folded]
  ------------------
 3498|  1.56k|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (3498:5): [True: 0, Folded]
  |  Branch (3498:5): [True: 1.56k, Folded]
  ------------------
 3499|  1.56k|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (3499:5): [True: 0, Folded]
  |  Branch (3499:5): [True: 1.56k, Folded]
  ------------------
 3500|  1.56k|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  1.56k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3500:9): [True: 1.56k, False: 3]
  ------------------
 3501|  1.56k|    {
 3502|  1.56k|        enum TIFFReadDirEntryErr err;
 3503|  1.56k|        uint32_t offset = direntry->tdir_offset.toff_long;
 3504|  1.56k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.56k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3504:13): [True: 0, False: 1.56k]
  ------------------
 3505|      0|            TIFFSwabLong(&offset);
 3506|  1.56k|        err = TIFFReadDirEntryData(tif, offset, 8, m.i);
 3507|  1.56k|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3507:13): [True: 15, False: 1.54k]
  ------------------
 3508|     15|            return (err);
 3509|  1.56k|    }
 3510|      3|    else
 3511|      3|        m.l = direntry->tdir_offset.toff_long8;
 3512|  1.55k|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.55k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3512:9): [True: 0, False: 1.55k]
  ------------------
 3513|      0|        TIFFSwabArrayOfLong(m.i, 2);
 3514|       |    /* Not completely sure what we should do when m.i[1]==0, but some */
 3515|       |    /* sanitizers do not like division by 0.0: */
 3516|       |    /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
 3517|  1.55k|    if (m.i[0] == 0 || m.i[1] == 0)
  ------------------
  |  Branch (3517:9): [True: 39, False: 1.51k]
  |  Branch (3517:24): [True: 206, False: 1.30k]
  ------------------
 3518|    245|        *value = 0.0;
 3519|  1.30k|    else
 3520|  1.30k|        *value = (double)m.i[0] / (double)m.i[1];
 3521|  1.55k|    return (TIFFReadDirEntryErrOk);
 3522|  1.56k|}
tif_dirread.c:TIFFReadDirEntryCheckedSrational:
 3527|      7|{
 3528|      7|    UInt64Aligned_t m;
 3529|      7|    assert(sizeof(double) == 8);
  ------------------
  |  Branch (3529:5): [True: 0, Folded]
  |  Branch (3529:5): [True: 7, Folded]
  ------------------
 3530|      7|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (3530:5): [True: 0, Folded]
  |  Branch (3530:5): [True: 7, Folded]
  ------------------
 3531|      7|    assert(sizeof(int32_t) == 4);
  ------------------
  |  Branch (3531:5): [True: 0, Folded]
  |  Branch (3531:5): [True: 7, Folded]
  ------------------
 3532|      7|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (3532:5): [True: 0, Folded]
  |  Branch (3532:5): [True: 7, Folded]
  ------------------
 3533|      7|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      7|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3533:9): [True: 7, False: 0]
  ------------------
 3534|      7|    {
 3535|      7|        enum TIFFReadDirEntryErr err;
 3536|      7|        uint32_t offset = direntry->tdir_offset.toff_long;
 3537|      7|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      7|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3537:13): [True: 0, False: 7]
  ------------------
 3538|      0|            TIFFSwabLong(&offset);
 3539|      7|        err = TIFFReadDirEntryData(tif, offset, 8, m.i);
 3540|      7|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3540:13): [True: 0, False: 7]
  ------------------
 3541|      0|            return (err);
 3542|      7|    }
 3543|      0|    else
 3544|      0|        m.l = direntry->tdir_offset.toff_long8;
 3545|      7|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      7|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3545:9): [True: 0, False: 7]
  ------------------
 3546|      0|        TIFFSwabArrayOfLong(m.i, 2);
 3547|       |    /* Not completely sure what we should do when m.i[1]==0, but some */
 3548|       |    /* sanitizers do not like division by 0.0: */
 3549|       |    /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
 3550|      7|    if ((int32_t)m.i[0] == 0 || m.i[1] == 0)
  ------------------
  |  Branch (3550:9): [True: 0, False: 7]
  |  Branch (3550:33): [True: 0, False: 7]
  ------------------
 3551|      0|        *value = 0.0;
 3552|      7|    else
 3553|      7|        *value = (double)((int32_t)m.i[0]) / (double)m.i[1];
 3554|      7|    return (TIFFReadDirEntryErrOk);
 3555|      7|}
tif_dirread.c:TIFFReadDirEntryCheckedFloat:
 3602|     22|{
 3603|     22|    union
 3604|     22|    {
 3605|     22|        float f;
 3606|     22|        uint32_t i;
 3607|     22|    } float_union;
 3608|     22|    assert(sizeof(float) == 4);
  ------------------
  |  Branch (3608:5): [True: 0, Folded]
  |  Branch (3608:5): [True: 22, Folded]
  ------------------
 3609|     22|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (3609:5): [True: 0, Folded]
  |  Branch (3609:5): [True: 22, Folded]
  ------------------
 3610|     22|    assert(sizeof(float_union) == 4);
  ------------------
  |  Branch (3610:5): [True: 0, Folded]
  |  Branch (3610:5): [True: 22, Folded]
  ------------------
 3611|     22|    float_union.i = *(uint32_t *)(&direntry->tdir_offset);
 3612|     22|    *value = float_union.f;
 3613|     22|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     22|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3613:9): [True: 0, False: 22]
  ------------------
 3614|      0|        TIFFSwabLong((uint32_t *)value);
 3615|     22|}
tif_dirread.c:TIFFReadDirEntryCheckedDouble:
 3619|      6|{
 3620|      6|    assert(sizeof(double) == 8);
  ------------------
  |  Branch (3620:5): [True: 0, Folded]
  |  Branch (3620:5): [True: 6, Folded]
  ------------------
 3621|      6|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (3621:5): [True: 0, Folded]
  |  Branch (3621:5): [True: 6, Folded]
  ------------------
 3622|      6|    assert(sizeof(UInt64Aligned_t) == 8);
  ------------------
  |  Branch (3622:5): [True: 0, Folded]
  |  Branch (3622:5): [True: 6, Folded]
  ------------------
 3623|      6|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      6|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3623:9): [True: 5, False: 1]
  ------------------
 3624|      5|    {
 3625|      5|        enum TIFFReadDirEntryErr err;
 3626|      5|        uint32_t offset = direntry->tdir_offset.toff_long;
 3627|      5|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      5|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3627:13): [True: 0, False: 5]
  ------------------
 3628|      0|            TIFFSwabLong(&offset);
 3629|      5|        err = TIFFReadDirEntryData(tif, offset, 8, value);
 3630|      5|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3630:13): [True: 0, False: 5]
  ------------------
 3631|      0|            return (err);
 3632|      5|    }
 3633|      1|    else
 3634|      1|    {
 3635|      1|        UInt64Aligned_t uint64_union;
 3636|      1|        uint64_union.l = direntry->tdir_offset.toff_long8;
 3637|      1|        *value = uint64_union.d;
 3638|      1|    }
 3639|      6|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      6|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3639:9): [True: 0, False: 6]
  ------------------
 3640|      0|        TIFFSwabLong8((uint64_t *)value);
 3641|      6|    return (TIFFReadDirEntryErrOk);
 3642|      6|}
tif_dirread.c:TIFFReadDirEntryDouble:
 1077|     68|{
 1078|     68|    enum TIFFReadDirEntryErr err;
 1079|     68|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (1079:9): [True: 8, False: 60]
  ------------------
 1080|      8|        return (TIFFReadDirEntryErrCount);
 1081|     60|    switch (direntry->tdir_type)
 1082|     60|    {
 1083|      7|        case TIFF_BYTE:
  ------------------
  |  Branch (1083:9): [True: 7, False: 53]
  ------------------
 1084|      7|        {
 1085|      7|            uint8_t m;
 1086|      7|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
 1087|      7|            *value = (double)m;
 1088|      7|            return (TIFFReadDirEntryErrOk);
 1089|      0|        }
 1090|      7|        case TIFF_SBYTE:
  ------------------
  |  Branch (1090:9): [True: 7, False: 53]
  ------------------
 1091|      7|        {
 1092|      7|            int8_t m;
 1093|      7|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
 1094|      7|            *value = (double)m;
 1095|      7|            return (TIFFReadDirEntryErrOk);
 1096|      0|        }
 1097|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1097:9): [True: 0, False: 60]
  ------------------
 1098|      0|        {
 1099|      0|            uint16_t m;
 1100|      0|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
 1101|      0|            *value = (double)m;
 1102|      0|            return (TIFFReadDirEntryErrOk);
 1103|      0|        }
 1104|      7|        case TIFF_SSHORT:
  ------------------
  |  Branch (1104:9): [True: 7, False: 53]
  ------------------
 1105|      7|        {
 1106|      7|            int16_t m;
 1107|      7|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
 1108|      7|            *value = (double)m;
 1109|      7|            return (TIFFReadDirEntryErrOk);
 1110|      0|        }
 1111|      3|        case TIFF_LONG:
  ------------------
  |  Branch (1111:9): [True: 3, False: 57]
  ------------------
 1112|      3|        {
 1113|      3|            uint32_t m;
 1114|      3|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
 1115|      3|            *value = (double)m;
 1116|      3|            return (TIFFReadDirEntryErrOk);
 1117|      0|        }
 1118|      4|        case TIFF_SLONG:
  ------------------
  |  Branch (1118:9): [True: 4, False: 56]
  ------------------
 1119|      4|        {
 1120|      4|            int32_t m;
 1121|      4|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
 1122|      4|            *value = (double)m;
 1123|      4|            return (TIFFReadDirEntryErrOk);
 1124|      0|        }
 1125|      9|        case TIFF_LONG8:
  ------------------
  |  Branch (1125:9): [True: 9, False: 51]
  ------------------
 1126|      9|        {
 1127|      9|            uint64_t m;
 1128|      9|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
 1129|      9|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1129:17): [True: 0, False: 9]
  ------------------
 1130|      0|                return (err);
 1131|      9|            *value = (double)m;
 1132|      9|            return (TIFFReadDirEntryErrOk);
 1133|      9|        }
 1134|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (1134:9): [True: 0, False: 60]
  ------------------
 1135|      0|        {
 1136|      0|            int64_t m;
 1137|      0|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
 1138|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1138:17): [True: 0, False: 0]
  ------------------
 1139|      0|                return (err);
 1140|      0|            *value = (double)m;
 1141|      0|            return (TIFFReadDirEntryErrOk);
 1142|      0|        }
 1143|      4|        case TIFF_RATIONAL:
  ------------------
  |  Branch (1143:9): [True: 4, False: 56]
  ------------------
 1144|      4|            err = TIFFReadDirEntryCheckedRational(tif, direntry, value);
 1145|      4|            return (err);
 1146|      4|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (1146:9): [True: 4, False: 56]
  ------------------
 1147|      4|            err = TIFFReadDirEntryCheckedSrational(tif, direntry, value);
 1148|      4|            return (err);
 1149|     11|        case TIFF_FLOAT:
  ------------------
  |  Branch (1149:9): [True: 11, False: 49]
  ------------------
 1150|     11|        {
 1151|     11|            float m;
 1152|     11|            TIFFReadDirEntryCheckedFloat(tif, direntry, &m);
 1153|     11|            *value = (double)m;
 1154|     11|            return (TIFFReadDirEntryErrOk);
 1155|      0|        }
 1156|      0|        case TIFF_DOUBLE:
  ------------------
  |  Branch (1156:9): [True: 0, False: 60]
  ------------------
 1157|      0|            err = TIFFReadDirEntryCheckedDouble(tif, direntry, value);
 1158|      0|            return (err);
 1159|      4|        default:
  ------------------
  |  Branch (1159:9): [True: 4, False: 56]
  ------------------
 1160|      4|            return (TIFFReadDirEntryErrType);
 1161|     60|    }
 1162|     60|}
tif_dirread.c:TIFFReadDirEntryIfd8:
 1166|    192|{
 1167|    192|    enum TIFFReadDirEntryErr err;
 1168|    192|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (1168:9): [True: 47, False: 145]
  ------------------
 1169|     47|        return (TIFFReadDirEntryErrCount);
 1170|    145|    switch (direntry->tdir_type)
 1171|    145|    {
 1172|     15|        case TIFF_LONG:
  ------------------
  |  Branch (1172:9): [True: 15, False: 130]
  ------------------
 1173|     19|        case TIFF_IFD:
  ------------------
  |  Branch (1173:9): [True: 4, False: 141]
  ------------------
 1174|     19|        {
 1175|     19|            uint32_t m;
 1176|     19|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
 1177|     19|            *value = (uint64_t)m;
 1178|     19|            return (TIFFReadDirEntryErrOk);
 1179|     15|        }
 1180|     20|        case TIFF_LONG8:
  ------------------
  |  Branch (1180:9): [True: 20, False: 125]
  ------------------
 1181|     20|        case TIFF_IFD8:
  ------------------
  |  Branch (1181:9): [True: 0, False: 145]
  ------------------
 1182|     20|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
 1183|     20|            return (err);
 1184|    106|        default:
  ------------------
  |  Branch (1184:9): [True: 106, False: 39]
  ------------------
 1185|    106|            return (TIFFReadDirEntryErrType);
 1186|    145|    }
 1187|    145|}
tif_dirread.c:TIFFReadDirEntrySbyteArray:
 1583|    438|{
 1584|    438|    enum TIFFReadDirEntryErr err;
 1585|    438|    uint32_t count;
 1586|    438|    void *origdata;
 1587|    438|    int8_t *data;
 1588|    438|    switch (direntry->tdir_type)
 1589|    438|    {
 1590|      0|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1590:9): [True: 0, False: 438]
  ------------------
 1591|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1591:9): [True: 0, False: 438]
  ------------------
 1592|    438|        case TIFF_SBYTE:
  ------------------
  |  Branch (1592:9): [True: 438, False: 0]
  ------------------
 1593|    438|        case TIFF_SHORT:
  ------------------
  |  Branch (1593:9): [True: 0, False: 438]
  ------------------
 1594|    438|        case TIFF_SSHORT:
  ------------------
  |  Branch (1594:9): [True: 0, False: 438]
  ------------------
 1595|    438|        case TIFF_LONG:
  ------------------
  |  Branch (1595:9): [True: 0, False: 438]
  ------------------
 1596|    438|        case TIFF_SLONG:
  ------------------
  |  Branch (1596:9): [True: 0, False: 438]
  ------------------
 1597|    438|        case TIFF_LONG8:
  ------------------
  |  Branch (1597:9): [True: 0, False: 438]
  ------------------
 1598|    438|        case TIFF_SLONG8:
  ------------------
  |  Branch (1598:9): [True: 0, False: 438]
  ------------------
 1599|    438|            break;
 1600|      0|        default:
  ------------------
  |  Branch (1600:9): [True: 0, False: 438]
  ------------------
 1601|      0|            return (TIFFReadDirEntryErrType);
 1602|    438|    }
 1603|    438|    err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
 1604|    438|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1604:9): [True: 179, False: 259]
  |  Branch (1604:43): [True: 36, False: 223]
  ------------------
 1605|    215|    {
 1606|    215|        *value = 0;
 1607|    215|        return (err);
 1608|    215|    }
 1609|    223|    switch (direntry->tdir_type)
 1610|    223|    {
 1611|      0|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1611:9): [True: 0, False: 223]
  ------------------
 1612|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1612:9): [True: 0, False: 223]
  ------------------
 1613|      0|        {
 1614|      0|            uint8_t *m;
 1615|      0|            uint32_t n;
 1616|      0|            m = (uint8_t *)origdata;
 1617|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1617:25): [True: 0, False: 0]
  ------------------
 1618|      0|            {
 1619|      0|                err = TIFFReadDirEntryCheckRangeSbyteByte(*m);
 1620|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1620:21): [True: 0, False: 0]
  ------------------
 1621|      0|                {
 1622|      0|                    _TIFFfreeExt(tif, origdata);
 1623|      0|                    return (err);
 1624|      0|                }
 1625|      0|                m++;
 1626|      0|            }
 1627|      0|            *value = (int8_t *)origdata;
 1628|      0|            return (TIFFReadDirEntryErrOk);
 1629|      0|        }
 1630|    223|        case TIFF_SBYTE:
  ------------------
  |  Branch (1630:9): [True: 223, False: 0]
  ------------------
 1631|    223|            *value = (int8_t *)origdata;
 1632|    223|            return (TIFFReadDirEntryErrOk);
 1633|      0|        default:
  ------------------
  |  Branch (1633:9): [True: 0, False: 223]
  ------------------
 1634|      0|            break;
 1635|    223|    }
 1636|      0|    data = (int8_t *)_TIFFmallocExt(tif, count);
 1637|      0|    if (data == 0)
  ------------------
  |  Branch (1637:9): [True: 0, False: 0]
  ------------------
 1638|      0|    {
 1639|      0|        _TIFFfreeExt(tif, origdata);
 1640|      0|        return (TIFFReadDirEntryErrAlloc);
 1641|      0|    }
 1642|      0|    switch (direntry->tdir_type)
 1643|      0|    {
 1644|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1644:9): [True: 0, False: 0]
  ------------------
 1645|      0|        {
 1646|      0|            uint16_t *ma;
 1647|      0|            int8_t *mb;
 1648|      0|            uint32_t n;
 1649|      0|            ma = (uint16_t *)origdata;
 1650|      0|            mb = data;
 1651|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1651:25): [True: 0, False: 0]
  ------------------
 1652|      0|            {
 1653|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1653:21): [True: 0, False: 0]
  ------------------
 1654|      0|                    TIFFSwabShort(ma);
 1655|      0|                err = TIFFReadDirEntryCheckRangeSbyteShort(*ma);
 1656|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1656:21): [True: 0, False: 0]
  ------------------
 1657|      0|                    break;
 1658|      0|                *mb++ = (int8_t)(*ma++);
 1659|      0|            }
 1660|      0|        }
 1661|      0|        break;
 1662|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (1662:9): [True: 0, False: 0]
  ------------------
 1663|      0|        {
 1664|      0|            int16_t *ma;
 1665|      0|            int8_t *mb;
 1666|      0|            uint32_t n;
 1667|      0|            ma = (int16_t *)origdata;
 1668|      0|            mb = data;
 1669|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1669:25): [True: 0, False: 0]
  ------------------
 1670|      0|            {
 1671|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1671:21): [True: 0, False: 0]
  ------------------
 1672|      0|                    TIFFSwabShort((uint16_t *)ma);
 1673|      0|                err = TIFFReadDirEntryCheckRangeSbyteSshort(*ma);
 1674|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1674:21): [True: 0, False: 0]
  ------------------
 1675|      0|                    break;
 1676|      0|                *mb++ = (int8_t)(*ma++);
 1677|      0|            }
 1678|      0|        }
 1679|      0|        break;
 1680|      0|        case TIFF_LONG:
  ------------------
  |  Branch (1680:9): [True: 0, False: 0]
  ------------------
 1681|      0|        {
 1682|      0|            uint32_t *ma;
 1683|      0|            int8_t *mb;
 1684|      0|            uint32_t n;
 1685|      0|            ma = (uint32_t *)origdata;
 1686|      0|            mb = data;
 1687|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1687:25): [True: 0, False: 0]
  ------------------
 1688|      0|            {
 1689|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1689:21): [True: 0, False: 0]
  ------------------
 1690|      0|                    TIFFSwabLong(ma);
 1691|      0|                err = TIFFReadDirEntryCheckRangeSbyteLong(*ma);
 1692|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1692:21): [True: 0, False: 0]
  ------------------
 1693|      0|                    break;
 1694|      0|                *mb++ = (int8_t)(*ma++);
 1695|      0|            }
 1696|      0|        }
 1697|      0|        break;
 1698|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (1698:9): [True: 0, False: 0]
  ------------------
 1699|      0|        {
 1700|      0|            int32_t *ma;
 1701|      0|            int8_t *mb;
 1702|      0|            uint32_t n;
 1703|      0|            ma = (int32_t *)origdata;
 1704|      0|            mb = data;
 1705|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1705:25): [True: 0, False: 0]
  ------------------
 1706|      0|            {
 1707|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1707:21): [True: 0, False: 0]
  ------------------
 1708|      0|                    TIFFSwabLong((uint32_t *)ma);
 1709|      0|                err = TIFFReadDirEntryCheckRangeSbyteSlong(*ma);
 1710|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1710:21): [True: 0, False: 0]
  ------------------
 1711|      0|                    break;
 1712|      0|                *mb++ = (int8_t)(*ma++);
 1713|      0|            }
 1714|      0|        }
 1715|      0|        break;
 1716|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (1716:9): [True: 0, False: 0]
  ------------------
 1717|      0|        {
 1718|      0|            uint64_t *ma;
 1719|      0|            int8_t *mb;
 1720|      0|            uint32_t n;
 1721|      0|            ma = (uint64_t *)origdata;
 1722|      0|            mb = data;
 1723|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1723:25): [True: 0, False: 0]
  ------------------
 1724|      0|            {
 1725|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1725:21): [True: 0, False: 0]
  ------------------
 1726|      0|                    TIFFSwabLong8(ma);
 1727|      0|                err = TIFFReadDirEntryCheckRangeSbyteLong8(*ma);
 1728|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1728:21): [True: 0, False: 0]
  ------------------
 1729|      0|                    break;
 1730|      0|                *mb++ = (int8_t)(*ma++);
 1731|      0|            }
 1732|      0|        }
 1733|      0|        break;
 1734|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (1734:9): [True: 0, False: 0]
  ------------------
 1735|      0|        {
 1736|      0|            int64_t *ma;
 1737|      0|            int8_t *mb;
 1738|      0|            uint32_t n;
 1739|      0|            ma = (int64_t *)origdata;
 1740|      0|            mb = data;
 1741|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1741:25): [True: 0, False: 0]
  ------------------
 1742|      0|            {
 1743|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1743:21): [True: 0, False: 0]
  ------------------
 1744|      0|                    TIFFSwabLong8((uint64_t *)ma);
 1745|      0|                err = TIFFReadDirEntryCheckRangeSbyteSlong8(*ma);
 1746|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1746:21): [True: 0, False: 0]
  ------------------
 1747|      0|                    break;
 1748|      0|                *mb++ = (int8_t)(*ma++);
 1749|      0|            }
 1750|      0|        }
 1751|      0|        break;
 1752|      0|        default:
  ------------------
  |  Branch (1752:9): [True: 0, False: 0]
  ------------------
 1753|      0|            break;
 1754|      0|    }
 1755|      0|    _TIFFfreeExt(tif, origdata);
 1756|      0|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1756:9): [True: 0, False: 0]
  ------------------
 1757|      0|    {
 1758|      0|        _TIFFfreeExt(tif, data);
 1759|      0|        return (err);
 1760|      0|    }
 1761|      0|    *value = data;
 1762|      0|    return (TIFFReadDirEntryErrOk);
 1763|      0|}
tif_dirread.c:TIFFReadDirEntrySshortArray:
 1945|     88|{
 1946|     88|    enum TIFFReadDirEntryErr err;
 1947|     88|    uint32_t count;
 1948|     88|    void *origdata;
 1949|     88|    int16_t *data;
 1950|     88|    switch (direntry->tdir_type)
 1951|     88|    {
 1952|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1952:9): [True: 0, False: 88]
  ------------------
 1953|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (1953:9): [True: 0, False: 88]
  ------------------
 1954|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1954:9): [True: 0, False: 88]
  ------------------
 1955|     88|        case TIFF_SSHORT:
  ------------------
  |  Branch (1955:9): [True: 88, False: 0]
  ------------------
 1956|     88|        case TIFF_LONG:
  ------------------
  |  Branch (1956:9): [True: 0, False: 88]
  ------------------
 1957|     88|        case TIFF_SLONG:
  ------------------
  |  Branch (1957:9): [True: 0, False: 88]
  ------------------
 1958|     88|        case TIFF_LONG8:
  ------------------
  |  Branch (1958:9): [True: 0, False: 88]
  ------------------
 1959|     88|        case TIFF_SLONG8:
  ------------------
  |  Branch (1959:9): [True: 0, False: 88]
  ------------------
 1960|     88|            break;
 1961|      0|        default:
  ------------------
  |  Branch (1961:9): [True: 0, False: 88]
  ------------------
 1962|      0|            return (TIFFReadDirEntryErrType);
 1963|     88|    }
 1964|     88|    err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
 1965|     88|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1965:9): [True: 56, False: 32]
  |  Branch (1965:43): [True: 10, False: 22]
  ------------------
 1966|     66|    {
 1967|     66|        *value = 0;
 1968|     66|        return (err);
 1969|     66|    }
 1970|     22|    switch (direntry->tdir_type)
 1971|     22|    {
 1972|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1972:9): [True: 0, False: 22]
  ------------------
 1973|      0|        {
 1974|      0|            uint16_t *m;
 1975|      0|            uint32_t n;
 1976|      0|            m = (uint16_t *)origdata;
 1977|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1977:25): [True: 0, False: 0]
  ------------------
 1978|      0|            {
 1979|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1979:21): [True: 0, False: 0]
  ------------------
 1980|      0|                    TIFFSwabShort(m);
 1981|      0|                err = TIFFReadDirEntryCheckRangeSshortShort(*m);
 1982|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1982:21): [True: 0, False: 0]
  ------------------
 1983|      0|                {
 1984|      0|                    _TIFFfreeExt(tif, origdata);
 1985|      0|                    return (err);
 1986|      0|                }
 1987|      0|                m++;
 1988|      0|            }
 1989|      0|            *value = (int16_t *)origdata;
 1990|      0|            return (TIFFReadDirEntryErrOk);
 1991|      0|        }
 1992|     22|        case TIFF_SSHORT:
  ------------------
  |  Branch (1992:9): [True: 22, False: 0]
  ------------------
 1993|     22|            *value = (int16_t *)origdata;
 1994|     22|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     22|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1994:17): [True: 0, False: 22]
  ------------------
 1995|      0|                TIFFSwabArrayOfShort((uint16_t *)(*value), count);
 1996|     22|            return (TIFFReadDirEntryErrOk);
 1997|      0|        default:
  ------------------
  |  Branch (1997:9): [True: 0, False: 22]
  ------------------
 1998|      0|            break;
 1999|     22|    }
 2000|      0|    data = (int16_t *)_TIFFCheckMalloc(tif, count, sizeof(int16_t),
 2001|      0|                                       "TIFFReadDirEntrySshortArray");
 2002|      0|    if (data == 0)
  ------------------
  |  Branch (2002:9): [True: 0, False: 0]
  ------------------
 2003|      0|    {
 2004|      0|        _TIFFfreeExt(tif, origdata);
 2005|      0|        return (TIFFReadDirEntryErrAlloc);
 2006|      0|    }
 2007|      0|    switch (direntry->tdir_type)
 2008|      0|    {
 2009|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2009:9): [True: 0, False: 0]
  ------------------
 2010|      0|        {
 2011|      0|            uint8_t *ma;
 2012|      0|            int16_t *mb;
 2013|      0|            uint32_t n;
 2014|      0|            ma = (uint8_t *)origdata;
 2015|      0|            mb = data;
 2016|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2016:25): [True: 0, False: 0]
  ------------------
 2017|      0|                *mb++ = (int16_t)(*ma++);
 2018|      0|        }
 2019|      0|        break;
 2020|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2020:9): [True: 0, False: 0]
  ------------------
 2021|      0|        {
 2022|      0|            int8_t *ma;
 2023|      0|            int16_t *mb;
 2024|      0|            uint32_t n;
 2025|      0|            ma = (int8_t *)origdata;
 2026|      0|            mb = data;
 2027|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2027:25): [True: 0, False: 0]
  ------------------
 2028|      0|                *mb++ = (int16_t)(*ma++);
 2029|      0|        }
 2030|      0|        break;
 2031|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2031:9): [True: 0, False: 0]
  ------------------
 2032|      0|        {
 2033|      0|            uint32_t *ma;
 2034|      0|            int16_t *mb;
 2035|      0|            uint32_t n;
 2036|      0|            ma = (uint32_t *)origdata;
 2037|      0|            mb = data;
 2038|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2038:25): [True: 0, False: 0]
  ------------------
 2039|      0|            {
 2040|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2040:21): [True: 0, False: 0]
  ------------------
 2041|      0|                    TIFFSwabLong(ma);
 2042|      0|                err = TIFFReadDirEntryCheckRangeSshortLong(*ma);
 2043|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2043:21): [True: 0, False: 0]
  ------------------
 2044|      0|                    break;
 2045|      0|                *mb++ = (int16_t)(*ma++);
 2046|      0|            }
 2047|      0|        }
 2048|      0|        break;
 2049|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2049:9): [True: 0, False: 0]
  ------------------
 2050|      0|        {
 2051|      0|            int32_t *ma;
 2052|      0|            int16_t *mb;
 2053|      0|            uint32_t n;
 2054|      0|            ma = (int32_t *)origdata;
 2055|      0|            mb = data;
 2056|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2056:25): [True: 0, False: 0]
  ------------------
 2057|      0|            {
 2058|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2058:21): [True: 0, False: 0]
  ------------------
 2059|      0|                    TIFFSwabLong((uint32_t *)ma);
 2060|      0|                err = TIFFReadDirEntryCheckRangeSshortSlong(*ma);
 2061|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2061:21): [True: 0, False: 0]
  ------------------
 2062|      0|                    break;
 2063|      0|                *mb++ = (int16_t)(*ma++);
 2064|      0|            }
 2065|      0|        }
 2066|      0|        break;
 2067|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2067:9): [True: 0, False: 0]
  ------------------
 2068|      0|        {
 2069|      0|            uint64_t *ma;
 2070|      0|            int16_t *mb;
 2071|      0|            uint32_t n;
 2072|      0|            ma = (uint64_t *)origdata;
 2073|      0|            mb = data;
 2074|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2074:25): [True: 0, False: 0]
  ------------------
 2075|      0|            {
 2076|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2076:21): [True: 0, False: 0]
  ------------------
 2077|      0|                    TIFFSwabLong8(ma);
 2078|      0|                err = TIFFReadDirEntryCheckRangeSshortLong8(*ma);
 2079|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2079:21): [True: 0, False: 0]
  ------------------
 2080|      0|                    break;
 2081|      0|                *mb++ = (int16_t)(*ma++);
 2082|      0|            }
 2083|      0|        }
 2084|      0|        break;
 2085|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2085:9): [True: 0, False: 0]
  ------------------
 2086|      0|        {
 2087|      0|            int64_t *ma;
 2088|      0|            int16_t *mb;
 2089|      0|            uint32_t n;
 2090|      0|            ma = (int64_t *)origdata;
 2091|      0|            mb = data;
 2092|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2092:25): [True: 0, False: 0]
  ------------------
 2093|      0|            {
 2094|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2094:21): [True: 0, False: 0]
  ------------------
 2095|      0|                    TIFFSwabLong8((uint64_t *)ma);
 2096|      0|                err = TIFFReadDirEntryCheckRangeSshortSlong8(*ma);
 2097|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2097:21): [True: 0, False: 0]
  ------------------
 2098|      0|                    break;
 2099|      0|                *mb++ = (int16_t)(*ma++);
 2100|      0|            }
 2101|      0|        }
 2102|      0|        break;
 2103|      0|        default:
  ------------------
  |  Branch (2103:9): [True: 0, False: 0]
  ------------------
 2104|      0|            break;
 2105|      0|    }
 2106|      0|    _TIFFfreeExt(tif, origdata);
 2107|      0|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2107:9): [True: 0, False: 0]
  ------------------
 2108|      0|    {
 2109|      0|        _TIFFfreeExt(tif, data);
 2110|      0|        return (err);
 2111|      0|    }
 2112|      0|    *value = data;
 2113|      0|    return (TIFFReadDirEntryErrOk);
 2114|      0|}
tif_dirread.c:TIFFReadDirEntryLongArray:
 2118|  2.25k|{
 2119|  2.25k|    enum TIFFReadDirEntryErr err;
 2120|  2.25k|    uint32_t count;
 2121|  2.25k|    void *origdata;
 2122|  2.25k|    uint32_t *data;
 2123|  2.25k|    switch (direntry->tdir_type)
 2124|  2.25k|    {
 2125|     15|        case TIFF_BYTE:
  ------------------
  |  Branch (2125:9): [True: 15, False: 2.23k]
  ------------------
 2126|     37|        case TIFF_SBYTE:
  ------------------
  |  Branch (2126:9): [True: 22, False: 2.23k]
  ------------------
 2127|     77|        case TIFF_SHORT:
  ------------------
  |  Branch (2127:9): [True: 40, False: 2.21k]
  ------------------
 2128|    271|        case TIFF_SSHORT:
  ------------------
  |  Branch (2128:9): [True: 194, False: 2.05k]
  ------------------
 2129|  2.18k|        case TIFF_LONG:
  ------------------
  |  Branch (2129:9): [True: 1.90k, False: 343]
  ------------------
 2130|  2.19k|        case TIFF_SLONG:
  ------------------
  |  Branch (2130:9): [True: 11, False: 2.24k]
  ------------------
 2131|  2.20k|        case TIFF_LONG8:
  ------------------
  |  Branch (2131:9): [True: 11, False: 2.24k]
  ------------------
 2132|  2.22k|        case TIFF_SLONG8:
  ------------------
  |  Branch (2132:9): [True: 18, False: 2.23k]
  ------------------
 2133|  2.22k|        case TIFF_IFD:
  ------------------
  |  Branch (2133:9): [True: 4, False: 2.24k]
  ------------------
 2134|  2.22k|        case TIFF_IFD8:
  ------------------
  |  Branch (2134:9): [True: 3, False: 2.24k]
  ------------------
 2135|  2.22k|            break;
 2136|     25|        default:
  ------------------
  |  Branch (2136:9): [True: 25, False: 2.22k]
  ------------------
 2137|     25|            return (TIFFReadDirEntryErrType);
 2138|  2.25k|    }
 2139|  2.22k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2140|  2.22k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2140:9): [True: 786, False: 1.44k]
  |  Branch (2140:43): [True: 299, False: 1.14k]
  ------------------
 2141|  1.08k|    {
 2142|  1.08k|        *value = 0;
 2143|  1.08k|        return (err);
 2144|  1.08k|    }
 2145|  1.14k|    switch (direntry->tdir_type)
 2146|  1.14k|    {
 2147|    833|        case TIFF_LONG:
  ------------------
  |  Branch (2147:9): [True: 833, False: 309]
  ------------------
 2148|    837|        case TIFF_IFD:
  ------------------
  |  Branch (2148:9): [True: 4, False: 1.13k]
  ------------------
 2149|    837|            *value = (uint32_t *)origdata;
 2150|    837|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    837|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2150:17): [True: 0, False: 837]
  ------------------
 2151|      0|                TIFFSwabArrayOfLong(*value, count);
 2152|    837|            return (TIFFReadDirEntryErrOk);
 2153|     11|        case TIFF_SLONG:
  ------------------
  |  Branch (2153:9): [True: 11, False: 1.13k]
  ------------------
 2154|     11|        {
 2155|     11|            int32_t *m;
 2156|     11|            uint32_t n;
 2157|     11|            m = (int32_t *)origdata;
 2158|     32|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2158:25): [True: 25, False: 7]
  ------------------
 2159|     25|            {
 2160|     25|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     25|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2160:21): [True: 0, False: 25]
  ------------------
 2161|      0|                    TIFFSwabLong((uint32_t *)m);
 2162|     25|                err = TIFFReadDirEntryCheckRangeLongSlong(*m);
 2163|     25|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2163:21): [True: 4, False: 21]
  ------------------
 2164|      4|                {
 2165|      4|                    _TIFFfreeExt(tif, origdata);
 2166|      4|                    return (err);
 2167|      4|                }
 2168|     21|                m++;
 2169|     21|            }
 2170|      7|            *value = (uint32_t *)origdata;
 2171|      7|            return (TIFFReadDirEntryErrOk);
 2172|     11|        }
 2173|    294|        default:
  ------------------
  |  Branch (2173:9): [True: 294, False: 848]
  ------------------
 2174|    294|            break;
 2175|  1.14k|    }
 2176|    294|    data = (uint32_t *)_TIFFCheckMalloc(tif, count, sizeof(uint32_t),
 2177|    294|                                        "TIFFReadDirEntryLongArray");
 2178|    294|    if (data == 0)
  ------------------
  |  Branch (2178:9): [True: 0, False: 294]
  ------------------
 2179|      0|    {
 2180|      0|        _TIFFfreeExt(tif, origdata);
 2181|      0|        return (TIFFReadDirEntryErrAlloc);
 2182|      0|    }
 2183|    294|    switch (direntry->tdir_type)
 2184|    294|    {
 2185|     15|        case TIFF_BYTE:
  ------------------
  |  Branch (2185:9): [True: 15, False: 279]
  ------------------
 2186|     15|        {
 2187|     15|            uint8_t *ma;
 2188|     15|            uint32_t *mb;
 2189|     15|            uint32_t n;
 2190|     15|            ma = (uint8_t *)origdata;
 2191|     15|            mb = data;
 2192|     63|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2192:25): [True: 48, False: 15]
  ------------------
 2193|     48|                *mb++ = (uint32_t)(*ma++);
 2194|     15|        }
 2195|     15|        break;
 2196|     22|        case TIFF_SBYTE:
  ------------------
  |  Branch (2196:9): [True: 22, False: 272]
  ------------------
 2197|     22|        {
 2198|     22|            int8_t *ma;
 2199|     22|            uint32_t *mb;
 2200|     22|            uint32_t n;
 2201|     22|            ma = (int8_t *)origdata;
 2202|     22|            mb = data;
 2203|     66|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2203:25): [True: 55, False: 11]
  ------------------
 2204|     55|            {
 2205|     55|                err = TIFFReadDirEntryCheckRangeLongSbyte(*ma);
 2206|     55|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2206:21): [True: 11, False: 44]
  ------------------
 2207|     11|                    break;
 2208|     44|                *mb++ = (uint32_t)(*ma++);
 2209|     44|            }
 2210|     22|        }
 2211|     22|        break;
 2212|     40|        case TIFF_SHORT:
  ------------------
  |  Branch (2212:9): [True: 40, False: 254]
  ------------------
 2213|     40|        {
 2214|     40|            uint16_t *ma;
 2215|     40|            uint32_t *mb;
 2216|     40|            uint32_t n;
 2217|     40|            ma = (uint16_t *)origdata;
 2218|     40|            mb = data;
 2219|    160|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2219:25): [True: 120, False: 40]
  ------------------
 2220|    120|            {
 2221|    120|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    120|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2221:21): [True: 0, False: 120]
  ------------------
 2222|      0|                    TIFFSwabShort(ma);
 2223|    120|                *mb++ = (uint32_t)(*ma++);
 2224|    120|            }
 2225|     40|        }
 2226|     40|        break;
 2227|    187|        case TIFF_SSHORT:
  ------------------
  |  Branch (2227:9): [True: 187, False: 107]
  ------------------
 2228|    187|        {
 2229|    187|            int16_t *ma;
 2230|    187|            uint32_t *mb;
 2231|    187|            uint32_t n;
 2232|    187|            ma = (int16_t *)origdata;
 2233|    187|            mb = data;
 2234|    519|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2234:25): [True: 457, False: 62]
  ------------------
 2235|    457|            {
 2236|    457|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    457|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2236:21): [True: 0, False: 457]
  ------------------
 2237|      0|                    TIFFSwabShort((uint16_t *)ma);
 2238|    457|                err = TIFFReadDirEntryCheckRangeLongSshort(*ma);
 2239|    457|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2239:21): [True: 125, False: 332]
  ------------------
 2240|    125|                    break;
 2241|    332|                *mb++ = (uint32_t)(*ma++);
 2242|    332|            }
 2243|    187|        }
 2244|    187|        break;
 2245|      9|        case TIFF_LONG8:
  ------------------
  |  Branch (2245:9): [True: 9, False: 285]
  ------------------
 2246|     12|        case TIFF_IFD8:
  ------------------
  |  Branch (2246:9): [True: 3, False: 291]
  ------------------
 2247|     12|        {
 2248|     12|            uint64_t *ma;
 2249|     12|            uint32_t *mb;
 2250|     12|            uint32_t n;
 2251|     12|            ma = (uint64_t *)origdata;
 2252|     12|            mb = data;
 2253|     21|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2253:25): [True: 18, False: 3]
  ------------------
 2254|     18|            {
 2255|     18|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     18|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2255:21): [True: 0, False: 18]
  ------------------
 2256|      0|                    TIFFSwabLong8(ma);
 2257|     18|                err = TIFFReadDirEntryCheckRangeLongLong8(*ma);
 2258|     18|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2258:21): [True: 9, False: 9]
  ------------------
 2259|      9|                    break;
 2260|      9|                *mb++ = (uint32_t)(*ma++);
 2261|      9|            }
 2262|     12|        }
 2263|     12|        break;
 2264|     18|        case TIFF_SLONG8:
  ------------------
  |  Branch (2264:9): [True: 18, False: 276]
  ------------------
 2265|     18|        {
 2266|     18|            int64_t *ma;
 2267|     18|            uint32_t *mb;
 2268|     18|            uint32_t n;
 2269|     18|            ma = (int64_t *)origdata;
 2270|     18|            mb = data;
 2271|     39|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2271:25): [True: 32, False: 7]
  ------------------
 2272|     32|            {
 2273|     32|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     32|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2273:21): [True: 0, False: 32]
  ------------------
 2274|      0|                    TIFFSwabLong8((uint64_t *)ma);
 2275|     32|                err = TIFFReadDirEntryCheckRangeLongSlong8(*ma);
 2276|     32|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2276:21): [True: 11, False: 21]
  ------------------
 2277|     11|                    break;
 2278|     21|                *mb++ = (uint32_t)(*ma++);
 2279|     21|            }
 2280|     18|        }
 2281|     18|        break;
 2282|      0|        default:
  ------------------
  |  Branch (2282:9): [True: 0, False: 294]
  ------------------
 2283|      0|            break;
 2284|    294|    }
 2285|    294|    _TIFFfreeExt(tif, origdata);
 2286|    294|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2286:9): [True: 156, False: 138]
  ------------------
 2287|    156|    {
 2288|    156|        _TIFFfreeExt(tif, data);
 2289|    156|        return (err);
 2290|    156|    }
 2291|    138|    *value = data;
 2292|    138|    return (TIFFReadDirEntryErrOk);
 2293|    294|}
tif_dirread.c:TIFFReadDirEntrySlongArray:
 2297|    478|{
 2298|    478|    enum TIFFReadDirEntryErr err;
 2299|    478|    uint32_t count;
 2300|    478|    void *origdata;
 2301|    478|    int32_t *data;
 2302|    478|    switch (direntry->tdir_type)
 2303|    478|    {
 2304|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2304:9): [True: 0, False: 478]
  ------------------
 2305|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2305:9): [True: 0, False: 478]
  ------------------
 2306|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2306:9): [True: 0, False: 478]
  ------------------
 2307|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2307:9): [True: 0, False: 478]
  ------------------
 2308|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2308:9): [True: 0, False: 478]
  ------------------
 2309|    478|        case TIFF_SLONG:
  ------------------
  |  Branch (2309:9): [True: 478, False: 0]
  ------------------
 2310|    478|        case TIFF_LONG8:
  ------------------
  |  Branch (2310:9): [True: 0, False: 478]
  ------------------
 2311|    478|        case TIFF_SLONG8:
  ------------------
  |  Branch (2311:9): [True: 0, False: 478]
  ------------------
 2312|    478|            break;
 2313|      0|        default:
  ------------------
  |  Branch (2313:9): [True: 0, False: 478]
  ------------------
 2314|      0|            return (TIFFReadDirEntryErrType);
 2315|    478|    }
 2316|    478|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2317|    478|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2317:9): [True: 335, False: 143]
  |  Branch (2317:43): [True: 104, False: 39]
  ------------------
 2318|    439|    {
 2319|    439|        *value = 0;
 2320|    439|        return (err);
 2321|    439|    }
 2322|     39|    switch (direntry->tdir_type)
 2323|     39|    {
 2324|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2324:9): [True: 0, False: 39]
  ------------------
 2325|      0|        {
 2326|      0|            uint32_t *m;
 2327|      0|            uint32_t n;
 2328|      0|            m = (uint32_t *)origdata;
 2329|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2329:25): [True: 0, False: 0]
  ------------------
 2330|      0|            {
 2331|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2331:21): [True: 0, False: 0]
  ------------------
 2332|      0|                    TIFFSwabLong((uint32_t *)m);
 2333|      0|                err = TIFFReadDirEntryCheckRangeSlongLong(*m);
 2334|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2334:21): [True: 0, False: 0]
  ------------------
 2335|      0|                {
 2336|      0|                    _TIFFfreeExt(tif, origdata);
 2337|      0|                    return (err);
 2338|      0|                }
 2339|      0|                m++;
 2340|      0|            }
 2341|      0|            *value = (int32_t *)origdata;
 2342|      0|            return (TIFFReadDirEntryErrOk);
 2343|      0|        }
 2344|     39|        case TIFF_SLONG:
  ------------------
  |  Branch (2344:9): [True: 39, False: 0]
  ------------------
 2345|     39|            *value = (int32_t *)origdata;
 2346|     39|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     39|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2346:17): [True: 0, False: 39]
  ------------------
 2347|      0|                TIFFSwabArrayOfLong((uint32_t *)(*value), count);
 2348|     39|            return (TIFFReadDirEntryErrOk);
 2349|      0|        default:
  ------------------
  |  Branch (2349:9): [True: 0, False: 39]
  ------------------
 2350|      0|            break;
 2351|     39|    }
 2352|      0|    data = (int32_t *)_TIFFCheckMalloc(tif, count, sizeof(int32_t),
 2353|      0|                                       "TIFFReadDirEntrySlongArray");
 2354|      0|    if (data == 0)
  ------------------
  |  Branch (2354:9): [True: 0, False: 0]
  ------------------
 2355|      0|    {
 2356|      0|        _TIFFfreeExt(tif, origdata);
 2357|      0|        return (TIFFReadDirEntryErrAlloc);
 2358|      0|    }
 2359|      0|    switch (direntry->tdir_type)
 2360|      0|    {
 2361|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2361:9): [True: 0, False: 0]
  ------------------
 2362|      0|        {
 2363|      0|            uint8_t *ma;
 2364|      0|            int32_t *mb;
 2365|      0|            uint32_t n;
 2366|      0|            ma = (uint8_t *)origdata;
 2367|      0|            mb = data;
 2368|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2368:25): [True: 0, False: 0]
  ------------------
 2369|      0|                *mb++ = (int32_t)(*ma++);
 2370|      0|        }
 2371|      0|        break;
 2372|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2372:9): [True: 0, False: 0]
  ------------------
 2373|      0|        {
 2374|      0|            int8_t *ma;
 2375|      0|            int32_t *mb;
 2376|      0|            uint32_t n;
 2377|      0|            ma = (int8_t *)origdata;
 2378|      0|            mb = data;
 2379|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2379:25): [True: 0, False: 0]
  ------------------
 2380|      0|                *mb++ = (int32_t)(*ma++);
 2381|      0|        }
 2382|      0|        break;
 2383|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2383:9): [True: 0, False: 0]
  ------------------
 2384|      0|        {
 2385|      0|            uint16_t *ma;
 2386|      0|            int32_t *mb;
 2387|      0|            uint32_t n;
 2388|      0|            ma = (uint16_t *)origdata;
 2389|      0|            mb = data;
 2390|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2390:25): [True: 0, False: 0]
  ------------------
 2391|      0|            {
 2392|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2392:21): [True: 0, False: 0]
  ------------------
 2393|      0|                    TIFFSwabShort(ma);
 2394|      0|                *mb++ = (int32_t)(*ma++);
 2395|      0|            }
 2396|      0|        }
 2397|      0|        break;
 2398|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2398:9): [True: 0, False: 0]
  ------------------
 2399|      0|        {
 2400|      0|            int16_t *ma;
 2401|      0|            int32_t *mb;
 2402|      0|            uint32_t n;
 2403|      0|            ma = (int16_t *)origdata;
 2404|      0|            mb = data;
 2405|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2405:25): [True: 0, False: 0]
  ------------------
 2406|      0|            {
 2407|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2407:21): [True: 0, False: 0]
  ------------------
 2408|      0|                    TIFFSwabShort((uint16_t *)ma);
 2409|      0|                *mb++ = (int32_t)(*ma++);
 2410|      0|            }
 2411|      0|        }
 2412|      0|        break;
 2413|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2413:9): [True: 0, False: 0]
  ------------------
 2414|      0|        {
 2415|      0|            uint64_t *ma;
 2416|      0|            int32_t *mb;
 2417|      0|            uint32_t n;
 2418|      0|            ma = (uint64_t *)origdata;
 2419|      0|            mb = data;
 2420|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2420:25): [True: 0, False: 0]
  ------------------
 2421|      0|            {
 2422|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2422:21): [True: 0, False: 0]
  ------------------
 2423|      0|                    TIFFSwabLong8(ma);
 2424|      0|                err = TIFFReadDirEntryCheckRangeSlongLong8(*ma);
 2425|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2425:21): [True: 0, False: 0]
  ------------------
 2426|      0|                    break;
 2427|      0|                *mb++ = (int32_t)(*ma++);
 2428|      0|            }
 2429|      0|        }
 2430|      0|        break;
 2431|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2431:9): [True: 0, False: 0]
  ------------------
 2432|      0|        {
 2433|      0|            int64_t *ma;
 2434|      0|            int32_t *mb;
 2435|      0|            uint32_t n;
 2436|      0|            ma = (int64_t *)origdata;
 2437|      0|            mb = data;
 2438|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2438:25): [True: 0, False: 0]
  ------------------
 2439|      0|            {
 2440|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2440:21): [True: 0, False: 0]
  ------------------
 2441|      0|                    TIFFSwabLong8((uint64_t *)ma);
 2442|      0|                err = TIFFReadDirEntryCheckRangeSlongSlong8(*ma);
 2443|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2443:21): [True: 0, False: 0]
  ------------------
 2444|      0|                    break;
 2445|      0|                *mb++ = (int32_t)(*ma++);
 2446|      0|            }
 2447|      0|        }
 2448|      0|        break;
 2449|      0|        default:
  ------------------
  |  Branch (2449:9): [True: 0, False: 0]
  ------------------
 2450|      0|            break;
 2451|      0|    }
 2452|      0|    _TIFFfreeExt(tif, origdata);
 2453|      0|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2453:9): [True: 0, False: 0]
  ------------------
 2454|      0|    {
 2455|      0|        _TIFFfreeExt(tif, data);
 2456|      0|        return (err);
 2457|      0|    }
 2458|      0|    *value = data;
 2459|      0|    return (TIFFReadDirEntryErrOk);
 2460|      0|}
tif_dirread.c:TIFFReadDirEntryLong8Array:
 2642|  2.32k|{
 2643|  2.32k|    return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value,
 2644|  2.32k|                                               ~((uint64_t)0));
 2645|  2.32k|}
tif_dirread.c:TIFFReadDirEntryLong8ArrayWithLimit:
 2465|  6.79k|{
 2466|  6.79k|    enum TIFFReadDirEntryErr err;
 2467|  6.79k|    uint32_t count;
 2468|  6.79k|    void *origdata;
 2469|  6.79k|    uint64_t *data;
 2470|  6.79k|    switch (direntry->tdir_type)
 2471|  6.79k|    {
 2472|    546|        case TIFF_BYTE:
  ------------------
  |  Branch (2472:9): [True: 546, False: 6.24k]
  ------------------
 2473|    704|        case TIFF_SBYTE:
  ------------------
  |  Branch (2473:9): [True: 158, False: 6.63k]
  ------------------
 2474|  3.02k|        case TIFF_SHORT:
  ------------------
  |  Branch (2474:9): [True: 2.31k, False: 4.47k]
  ------------------
 2475|  3.04k|        case TIFF_SSHORT:
  ------------------
  |  Branch (2475:9): [True: 24, False: 6.77k]
  ------------------
 2476|  6.10k|        case TIFF_LONG:
  ------------------
  |  Branch (2476:9): [True: 3.05k, False: 3.73k]
  ------------------
 2477|  6.12k|        case TIFF_SLONG:
  ------------------
  |  Branch (2477:9): [True: 16, False: 6.77k]
  ------------------
 2478|  6.58k|        case TIFF_LONG8:
  ------------------
  |  Branch (2478:9): [True: 466, False: 6.32k]
  ------------------
 2479|  6.60k|        case TIFF_SLONG8:
  ------------------
  |  Branch (2479:9): [True: 14, False: 6.78k]
  ------------------
 2480|  6.60k|        case TIFF_IFD:
  ------------------
  |  Branch (2480:9): [True: 2, False: 6.79k]
  ------------------
 2481|  6.60k|        case TIFF_IFD8:
  ------------------
  |  Branch (2481:9): [True: 7, False: 6.78k]
  ------------------
 2482|  6.60k|            break;
 2483|    185|        default:
  ------------------
  |  Branch (2483:9): [True: 185, False: 6.60k]
  ------------------
 2484|    185|            return (TIFFReadDirEntryErrType);
 2485|  6.79k|    }
 2486|  6.60k|    err = TIFFReadDirEntryArrayWithLimit(tif, direntry, &count, 8, &origdata,
 2487|  6.60k|                                         maxcount);
 2488|  6.60k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2488:9): [True: 473, False: 6.13k]
  |  Branch (2488:43): [True: 61, False: 6.07k]
  ------------------
 2489|    534|    {
 2490|    534|        *value = 0;
 2491|    534|        return (err);
 2492|    534|    }
 2493|  6.07k|    switch (direntry->tdir_type)
 2494|  6.07k|    {
 2495|    350|        case TIFF_LONG8:
  ------------------
  |  Branch (2495:9): [True: 350, False: 5.72k]
  ------------------
 2496|    357|        case TIFF_IFD8:
  ------------------
  |  Branch (2496:9): [True: 7, False: 6.06k]
  ------------------
 2497|    357|            *value = (uint64_t *)origdata;
 2498|    357|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    357|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2498:17): [True: 0, False: 357]
  ------------------
 2499|      0|                TIFFSwabArrayOfLong8(*value, count);
 2500|    357|            return (TIFFReadDirEntryErrOk);
 2501|     10|        case TIFF_SLONG8:
  ------------------
  |  Branch (2501:9): [True: 10, False: 6.06k]
  ------------------
 2502|     10|        {
 2503|     10|            int64_t *m;
 2504|     10|            uint32_t n;
 2505|     10|            m = (int64_t *)origdata;
 2506|     32|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2506:25): [True: 26, False: 6]
  ------------------
 2507|     26|            {
 2508|     26|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     26|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2508:21): [True: 0, False: 26]
  ------------------
 2509|      0|                    TIFFSwabLong8((uint64_t *)m);
 2510|     26|                err = TIFFReadDirEntryCheckRangeLong8Slong8(*m);
 2511|     26|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2511:21): [True: 4, False: 22]
  ------------------
 2512|      4|                {
 2513|      4|                    _TIFFfreeExt(tif, origdata);
 2514|      4|                    return (err);
 2515|      4|                }
 2516|     22|                m++;
 2517|     22|            }
 2518|      6|            *value = (uint64_t *)origdata;
 2519|      6|            return (TIFFReadDirEntryErrOk);
 2520|     10|        }
 2521|  5.70k|        default:
  ------------------
  |  Branch (2521:9): [True: 5.70k, False: 367]
  ------------------
 2522|  5.70k|            break;
 2523|  6.07k|    }
 2524|  5.70k|    data = (uint64_t *)_TIFFCheckMalloc(tif, count, sizeof(uint64_t),
 2525|  5.70k|                                        "TIFFReadDirEntryLong8ArrayWithLimit");
 2526|  5.70k|    if (data == 0)
  ------------------
  |  Branch (2526:9): [True: 0, False: 5.70k]
  ------------------
 2527|      0|    {
 2528|      0|        _TIFFfreeExt(tif, origdata);
 2529|      0|        return (TIFFReadDirEntryErrAlloc);
 2530|      0|    }
 2531|  5.70k|    switch (direntry->tdir_type)
 2532|  5.70k|    {
 2533|    537|        case TIFF_BYTE:
  ------------------
  |  Branch (2533:9): [True: 537, False: 5.17k]
  ------------------
 2534|    537|        {
 2535|    537|            uint8_t *ma;
 2536|    537|            uint64_t *mb;
 2537|    537|            uint32_t n;
 2538|    537|            ma = (uint8_t *)origdata;
 2539|    537|            mb = data;
 2540|   117k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2540:25): [True: 117k, False: 537]
  ------------------
 2541|   117k|                *mb++ = (uint64_t)(*ma++);
 2542|    537|        }
 2543|    537|        break;
 2544|    152|        case TIFF_SBYTE:
  ------------------
  |  Branch (2544:9): [True: 152, False: 5.55k]
  ------------------
 2545|    152|        {
 2546|    152|            int8_t *ma;
 2547|    152|            uint64_t *mb;
 2548|    152|            uint32_t n;
 2549|    152|            ma = (int8_t *)origdata;
 2550|    152|            mb = data;
 2551|    295|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2551:25): [True: 156, False: 139]
  ------------------
 2552|    156|            {
 2553|    156|                err = TIFFReadDirEntryCheckRangeLong8Sbyte(*ma);
 2554|    156|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2554:21): [True: 13, False: 143]
  ------------------
 2555|     13|                    break;
 2556|    143|                *mb++ = (uint64_t)(*ma++);
 2557|    143|            }
 2558|    152|        }
 2559|    152|        break;
 2560|  2.01k|        case TIFF_SHORT:
  ------------------
  |  Branch (2560:9): [True: 2.01k, False: 3.68k]
  ------------------
 2561|  2.01k|        {
 2562|  2.01k|            uint16_t *ma;
 2563|  2.01k|            uint64_t *mb;
 2564|  2.01k|            uint32_t n;
 2565|  2.01k|            ma = (uint16_t *)origdata;
 2566|  2.01k|            mb = data;
 2567|   302k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2567:25): [True: 300k, False: 2.01k]
  ------------------
 2568|   300k|            {
 2569|   300k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|   300k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2569:21): [True: 0, False: 300k]
  ------------------
 2570|      0|                    TIFFSwabShort(ma);
 2571|   300k|                *mb++ = (uint64_t)(*ma++);
 2572|   300k|            }
 2573|  2.01k|        }
 2574|  2.01k|        break;
 2575|     23|        case TIFF_SSHORT:
  ------------------
  |  Branch (2575:9): [True: 23, False: 5.68k]
  ------------------
 2576|     23|        {
 2577|     23|            int16_t *ma;
 2578|     23|            uint64_t *mb;
 2579|     23|            uint32_t n;
 2580|     23|            ma = (int16_t *)origdata;
 2581|     23|            mb = data;
 2582|    299|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2582:25): [True: 276, False: 23]
  ------------------
 2583|    276|            {
 2584|    276|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    276|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2584:21): [True: 0, False: 276]
  ------------------
 2585|      0|                    TIFFSwabShort((uint16_t *)ma);
 2586|    276|                err = TIFFReadDirEntryCheckRangeLong8Sshort(*ma);
 2587|    276|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2587:21): [True: 0, False: 276]
  ------------------
 2588|      0|                    break;
 2589|    276|                *mb++ = (uint64_t)(*ma++);
 2590|    276|            }
 2591|     23|        }
 2592|     23|        break;
 2593|  2.95k|        case TIFF_LONG:
  ------------------
  |  Branch (2593:9): [True: 2.95k, False: 2.74k]
  ------------------
 2594|  2.96k|        case TIFF_IFD:
  ------------------
  |  Branch (2594:9): [True: 2, False: 5.70k]
  ------------------
 2595|  2.96k|        {
 2596|  2.96k|            uint32_t *ma;
 2597|  2.96k|            uint64_t *mb;
 2598|  2.96k|            uint32_t n;
 2599|  2.96k|            ma = (uint32_t *)origdata;
 2600|  2.96k|            mb = data;
 2601|  28.0k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2601:25): [True: 25.0k, False: 2.96k]
  ------------------
 2602|  25.0k|            {
 2603|  25.0k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  25.0k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2603:21): [True: 0, False: 25.0k]
  ------------------
 2604|      0|                    TIFFSwabLong(ma);
 2605|  25.0k|                *mb++ = (uint64_t)(*ma++);
 2606|  25.0k|            }
 2607|  2.96k|        }
 2608|  2.96k|        break;
 2609|     16|        case TIFF_SLONG:
  ------------------
  |  Branch (2609:9): [True: 16, False: 5.69k]
  ------------------
 2610|     16|        {
 2611|     16|            int32_t *ma;
 2612|     16|            uint64_t *mb;
 2613|     16|            uint32_t n;
 2614|     16|            ma = (int32_t *)origdata;
 2615|     16|            mb = data;
 2616|     40|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2616:25): [True: 32, False: 8]
  ------------------
 2617|     32|            {
 2618|     32|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     32|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2618:21): [True: 0, False: 32]
  ------------------
 2619|      0|                    TIFFSwabLong((uint32_t *)ma);
 2620|     32|                err = TIFFReadDirEntryCheckRangeLong8Slong(*ma);
 2621|     32|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2621:21): [True: 8, False: 24]
  ------------------
 2622|      8|                    break;
 2623|     24|                *mb++ = (uint64_t)(*ma++);
 2624|     24|            }
 2625|     16|        }
 2626|     16|        break;
 2627|      0|        default:
  ------------------
  |  Branch (2627:9): [True: 0, False: 5.70k]
  ------------------
 2628|      0|            break;
 2629|  5.70k|    }
 2630|  5.70k|    _TIFFfreeExt(tif, origdata);
 2631|  5.70k|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2631:9): [True: 21, False: 5.68k]
  ------------------
 2632|     21|    {
 2633|     21|        _TIFFfreeExt(tif, data);
 2634|     21|        return (err);
 2635|     21|    }
 2636|  5.68k|    *value = data;
 2637|  5.68k|    return (TIFFReadDirEntryErrOk);
 2638|  5.70k|}
tif_dirread.c:TIFFReadDirEntrySlong8Array:
 2649|    455|{
 2650|    455|    enum TIFFReadDirEntryErr err;
 2651|    455|    uint32_t count;
 2652|    455|    void *origdata;
 2653|    455|    int64_t *data;
 2654|    455|    switch (direntry->tdir_type)
 2655|    455|    {
 2656|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2656:9): [True: 0, False: 455]
  ------------------
 2657|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2657:9): [True: 0, False: 455]
  ------------------
 2658|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2658:9): [True: 0, False: 455]
  ------------------
 2659|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2659:9): [True: 0, False: 455]
  ------------------
 2660|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2660:9): [True: 0, False: 455]
  ------------------
 2661|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2661:9): [True: 0, False: 455]
  ------------------
 2662|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2662:9): [True: 0, False: 455]
  ------------------
 2663|    455|        case TIFF_SLONG8:
  ------------------
  |  Branch (2663:9): [True: 455, False: 0]
  ------------------
 2664|    455|            break;
 2665|      0|        default:
  ------------------
  |  Branch (2665:9): [True: 0, False: 455]
  ------------------
 2666|      0|            return (TIFFReadDirEntryErrType);
 2667|    455|    }
 2668|    455|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 2669|    455|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2669:9): [True: 430, False: 25]
  |  Branch (2669:43): [True: 13, False: 12]
  ------------------
 2670|    443|    {
 2671|    443|        *value = 0;
 2672|    443|        return (err);
 2673|    443|    }
 2674|     12|    switch (direntry->tdir_type)
 2675|     12|    {
 2676|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2676:9): [True: 0, False: 12]
  ------------------
 2677|      0|        {
 2678|      0|            uint64_t *m;
 2679|      0|            uint32_t n;
 2680|      0|            m = (uint64_t *)origdata;
 2681|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2681:25): [True: 0, False: 0]
  ------------------
 2682|      0|            {
 2683|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2683:21): [True: 0, False: 0]
  ------------------
 2684|      0|                    TIFFSwabLong8(m);
 2685|      0|                err = TIFFReadDirEntryCheckRangeSlong8Long8(*m);
 2686|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2686:21): [True: 0, False: 0]
  ------------------
 2687|      0|                {
 2688|      0|                    _TIFFfreeExt(tif, origdata);
 2689|      0|                    return (err);
 2690|      0|                }
 2691|      0|                m++;
 2692|      0|            }
 2693|      0|            *value = (int64_t *)origdata;
 2694|      0|            return (TIFFReadDirEntryErrOk);
 2695|      0|        }
 2696|     12|        case TIFF_SLONG8:
  ------------------
  |  Branch (2696:9): [True: 12, False: 0]
  ------------------
 2697|     12|            *value = (int64_t *)origdata;
 2698|     12|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     12|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2698:17): [True: 0, False: 12]
  ------------------
 2699|      0|                TIFFSwabArrayOfLong8((uint64_t *)(*value), count);
 2700|     12|            return (TIFFReadDirEntryErrOk);
 2701|      0|        default:
  ------------------
  |  Branch (2701:9): [True: 0, False: 12]
  ------------------
 2702|      0|            break;
 2703|     12|    }
 2704|      0|    data = (int64_t *)_TIFFCheckMalloc(tif, count, sizeof(int64_t),
 2705|      0|                                       "TIFFReadDirEntrySlong8Array");
 2706|      0|    if (data == 0)
  ------------------
  |  Branch (2706:9): [True: 0, False: 0]
  ------------------
 2707|      0|    {
 2708|      0|        _TIFFfreeExt(tif, origdata);
 2709|      0|        return (TIFFReadDirEntryErrAlloc);
 2710|      0|    }
 2711|      0|    switch (direntry->tdir_type)
 2712|      0|    {
 2713|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2713:9): [True: 0, False: 0]
  ------------------
 2714|      0|        {
 2715|      0|            uint8_t *ma;
 2716|      0|            int64_t *mb;
 2717|      0|            uint32_t n;
 2718|      0|            ma = (uint8_t *)origdata;
 2719|      0|            mb = data;
 2720|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2720:25): [True: 0, False: 0]
  ------------------
 2721|      0|                *mb++ = (int64_t)(*ma++);
 2722|      0|        }
 2723|      0|        break;
 2724|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2724:9): [True: 0, False: 0]
  ------------------
 2725|      0|        {
 2726|      0|            int8_t *ma;
 2727|      0|            int64_t *mb;
 2728|      0|            uint32_t n;
 2729|      0|            ma = (int8_t *)origdata;
 2730|      0|            mb = data;
 2731|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2731:25): [True: 0, False: 0]
  ------------------
 2732|      0|                *mb++ = (int64_t)(*ma++);
 2733|      0|        }
 2734|      0|        break;
 2735|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2735:9): [True: 0, False: 0]
  ------------------
 2736|      0|        {
 2737|      0|            uint16_t *ma;
 2738|      0|            int64_t *mb;
 2739|      0|            uint32_t n;
 2740|      0|            ma = (uint16_t *)origdata;
 2741|      0|            mb = data;
 2742|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2742:25): [True: 0, False: 0]
  ------------------
 2743|      0|            {
 2744|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2744:21): [True: 0, False: 0]
  ------------------
 2745|      0|                    TIFFSwabShort(ma);
 2746|      0|                *mb++ = (int64_t)(*ma++);
 2747|      0|            }
 2748|      0|        }
 2749|      0|        break;
 2750|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2750:9): [True: 0, False: 0]
  ------------------
 2751|      0|        {
 2752|      0|            int16_t *ma;
 2753|      0|            int64_t *mb;
 2754|      0|            uint32_t n;
 2755|      0|            ma = (int16_t *)origdata;
 2756|      0|            mb = data;
 2757|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2757:25): [True: 0, False: 0]
  ------------------
 2758|      0|            {
 2759|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2759:21): [True: 0, False: 0]
  ------------------
 2760|      0|                    TIFFSwabShort((uint16_t *)ma);
 2761|      0|                *mb++ = (int64_t)(*ma++);
 2762|      0|            }
 2763|      0|        }
 2764|      0|        break;
 2765|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2765:9): [True: 0, False: 0]
  ------------------
 2766|      0|        {
 2767|      0|            uint32_t *ma;
 2768|      0|            int64_t *mb;
 2769|      0|            uint32_t n;
 2770|      0|            ma = (uint32_t *)origdata;
 2771|      0|            mb = data;
 2772|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2772:25): [True: 0, False: 0]
  ------------------
 2773|      0|            {
 2774|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2774:21): [True: 0, False: 0]
  ------------------
 2775|      0|                    TIFFSwabLong(ma);
 2776|      0|                *mb++ = (int64_t)(*ma++);
 2777|      0|            }
 2778|      0|        }
 2779|      0|        break;
 2780|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2780:9): [True: 0, False: 0]
  ------------------
 2781|      0|        {
 2782|      0|            int32_t *ma;
 2783|      0|            int64_t *mb;
 2784|      0|            uint32_t n;
 2785|      0|            ma = (int32_t *)origdata;
 2786|      0|            mb = data;
 2787|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2787:25): [True: 0, False: 0]
  ------------------
 2788|      0|            {
 2789|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2789:21): [True: 0, False: 0]
  ------------------
 2790|      0|                    TIFFSwabLong((uint32_t *)ma);
 2791|      0|                *mb++ = (int64_t)(*ma++);
 2792|      0|            }
 2793|      0|        }
 2794|      0|        break;
 2795|      0|        default:
  ------------------
  |  Branch (2795:9): [True: 0, False: 0]
  ------------------
 2796|      0|            break;
 2797|      0|    }
 2798|      0|    _TIFFfreeExt(tif, origdata);
 2799|      0|    *value = data;
 2800|      0|    return (TIFFReadDirEntryErrOk);
 2801|      0|}
tif_dirread.c:TIFFReadDirEntryFloatArray:
 2805|  1.24k|{
 2806|  1.24k|    enum TIFFReadDirEntryErr err;
 2807|  1.24k|    uint32_t count;
 2808|  1.24k|    void *origdata;
 2809|  1.24k|    float *data;
 2810|  1.24k|    switch (direntry->tdir_type)
 2811|  1.24k|    {
 2812|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2812:9): [True: 0, False: 1.24k]
  ------------------
 2813|     28|        case TIFF_SBYTE:
  ------------------
  |  Branch (2813:9): [True: 28, False: 1.22k]
  ------------------
 2814|    164|        case TIFF_SHORT:
  ------------------
  |  Branch (2814:9): [True: 136, False: 1.11k]
  ------------------
 2815|    179|        case TIFF_SSHORT:
  ------------------
  |  Branch (2815:9): [True: 15, False: 1.23k]
  ------------------
 2816|    196|        case TIFF_LONG:
  ------------------
  |  Branch (2816:9): [True: 17, False: 1.23k]
  ------------------
 2817|    200|        case TIFF_SLONG:
  ------------------
  |  Branch (2817:9): [True: 4, False: 1.24k]
  ------------------
 2818|    204|        case TIFF_LONG8:
  ------------------
  |  Branch (2818:9): [True: 4, False: 1.24k]
  ------------------
 2819|    204|        case TIFF_SLONG8:
  ------------------
  |  Branch (2819:9): [True: 0, False: 1.24k]
  ------------------
 2820|    625|        case TIFF_RATIONAL:
  ------------------
  |  Branch (2820:9): [True: 421, False: 828]
  ------------------
 2821|    663|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (2821:9): [True: 38, False: 1.21k]
  ------------------
 2822|    685|        case TIFF_FLOAT:
  ------------------
  |  Branch (2822:9): [True: 22, False: 1.22k]
  ------------------
 2823|  1.23k|        case TIFF_DOUBLE:
  ------------------
  |  Branch (2823:9): [True: 548, False: 701]
  ------------------
 2824|  1.23k|            break;
 2825|     16|        default:
  ------------------
  |  Branch (2825:9): [True: 16, False: 1.23k]
  ------------------
 2826|     16|            return (TIFFReadDirEntryErrType);
 2827|  1.24k|    }
 2828|  1.23k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2829|  1.23k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2829:9): [True: 95, False: 1.13k]
  |  Branch (2829:43): [True: 40, False: 1.09k]
  ------------------
 2830|    135|    {
 2831|    135|        *value = 0;
 2832|    135|        return (err);
 2833|    135|    }
 2834|  1.09k|    switch (direntry->tdir_type)
 2835|  1.09k|    {
 2836|      9|        case TIFF_FLOAT:
  ------------------
  |  Branch (2836:9): [True: 9, False: 1.08k]
  ------------------
 2837|      9|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      9|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2837:17): [True: 0, False: 9]
  ------------------
 2838|      0|                TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 2839|      9|            TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata);
 2840|      9|            *value = (float *)origdata;
 2841|      9|            return (TIFFReadDirEntryErrOk);
 2842|  1.08k|        default:
  ------------------
  |  Branch (2842:9): [True: 1.08k, False: 9]
  ------------------
 2843|  1.08k|            break;
 2844|  1.09k|    }
 2845|  1.08k|    data = (float *)_TIFFCheckMalloc(tif, count, sizeof(float),
 2846|  1.08k|                                     "TIFFReadDirEntryFloatArray");
 2847|  1.08k|    if (data == 0)
  ------------------
  |  Branch (2847:9): [True: 0, False: 1.08k]
  ------------------
 2848|      0|    {
 2849|      0|        _TIFFfreeExt(tif, origdata);
 2850|      0|        return (TIFFReadDirEntryErrAlloc);
 2851|      0|    }
 2852|  1.08k|    switch (direntry->tdir_type)
 2853|  1.08k|    {
 2854|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2854:9): [True: 0, False: 1.08k]
  ------------------
 2855|      0|        {
 2856|      0|            uint8_t *ma;
 2857|      0|            float *mb;
 2858|      0|            uint32_t n;
 2859|      0|            ma = (uint8_t *)origdata;
 2860|      0|            mb = data;
 2861|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2861:25): [True: 0, False: 0]
  ------------------
 2862|      0|                *mb++ = (float)(*ma++);
 2863|      0|        }
 2864|      0|        break;
 2865|     24|        case TIFF_SBYTE:
  ------------------
  |  Branch (2865:9): [True: 24, False: 1.06k]
  ------------------
 2866|     24|        {
 2867|     24|            int8_t *ma;
 2868|     24|            float *mb;
 2869|     24|            uint32_t n;
 2870|     24|            ma = (int8_t *)origdata;
 2871|     24|            mb = data;
 2872|    968|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2872:25): [True: 944, False: 24]
  ------------------
 2873|    944|                *mb++ = (float)(*ma++);
 2874|     24|        }
 2875|     24|        break;
 2876|    131|        case TIFF_SHORT:
  ------------------
  |  Branch (2876:9): [True: 131, False: 958]
  ------------------
 2877|    131|        {
 2878|    131|            uint16_t *ma;
 2879|    131|            float *mb;
 2880|    131|            uint32_t n;
 2881|    131|            ma = (uint16_t *)origdata;
 2882|    131|            mb = data;
 2883|  1.57k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2883:25): [True: 1.44k, False: 131]
  ------------------
 2884|  1.44k|            {
 2885|  1.44k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.44k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2885:21): [True: 0, False: 1.44k]
  ------------------
 2886|      0|                    TIFFSwabShort(ma);
 2887|  1.44k|                *mb++ = (float)(*ma++);
 2888|  1.44k|            }
 2889|    131|        }
 2890|    131|        break;
 2891|     15|        case TIFF_SSHORT:
  ------------------
  |  Branch (2891:9): [True: 15, False: 1.07k]
  ------------------
 2892|     15|        {
 2893|     15|            int16_t *ma;
 2894|     15|            float *mb;
 2895|     15|            uint32_t n;
 2896|     15|            ma = (int16_t *)origdata;
 2897|     15|            mb = data;
 2898|    908|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2898:25): [True: 893, False: 15]
  ------------------
 2899|    893|            {
 2900|    893|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    893|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2900:21): [True: 0, False: 893]
  ------------------
 2901|      0|                    TIFFSwabShort((uint16_t *)ma);
 2902|    893|                *mb++ = (float)(*ma++);
 2903|    893|            }
 2904|     15|        }
 2905|     15|        break;
 2906|     17|        case TIFF_LONG:
  ------------------
  |  Branch (2906:9): [True: 17, False: 1.07k]
  ------------------
 2907|     17|        {
 2908|     17|            uint32_t *ma;
 2909|     17|            float *mb;
 2910|     17|            uint32_t n;
 2911|     17|            ma = (uint32_t *)origdata;
 2912|     17|            mb = data;
 2913|     74|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2913:25): [True: 57, False: 17]
  ------------------
 2914|     57|            {
 2915|     57|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     57|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2915:21): [True: 0, False: 57]
  ------------------
 2916|      0|                    TIFFSwabLong(ma);
 2917|     57|                *mb++ = (float)(*ma++);
 2918|     57|            }
 2919|     17|        }
 2920|     17|        break;
 2921|      4|        case TIFF_SLONG:
  ------------------
  |  Branch (2921:9): [True: 4, False: 1.08k]
  ------------------
 2922|      4|        {
 2923|      4|            int32_t *ma;
 2924|      4|            float *mb;
 2925|      4|            uint32_t n;
 2926|      4|            ma = (int32_t *)origdata;
 2927|      4|            mb = data;
 2928|      8|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2928:25): [True: 4, False: 4]
  ------------------
 2929|      4|            {
 2930|      4|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      4|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2930:21): [True: 0, False: 4]
  ------------------
 2931|      0|                    TIFFSwabLong((uint32_t *)ma);
 2932|      4|                *mb++ = (float)(*ma++);
 2933|      4|            }
 2934|      4|        }
 2935|      4|        break;
 2936|      4|        case TIFF_LONG8:
  ------------------
  |  Branch (2936:9): [True: 4, False: 1.08k]
  ------------------
 2937|      4|        {
 2938|      4|            uint64_t *ma;
 2939|      4|            float *mb;
 2940|      4|            uint32_t n;
 2941|      4|            ma = (uint64_t *)origdata;
 2942|      4|            mb = data;
 2943|     28|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2943:25): [True: 24, False: 4]
  ------------------
 2944|     24|            {
 2945|     24|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     24|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2945:21): [True: 0, False: 24]
  ------------------
 2946|      0|                    TIFFSwabLong8(ma);
 2947|     24|                *mb++ = (float)(*ma++);
 2948|     24|            }
 2949|      4|        }
 2950|      4|        break;
 2951|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2951:9): [True: 0, False: 1.08k]
  ------------------
 2952|      0|        {
 2953|      0|            int64_t *ma;
 2954|      0|            float *mb;
 2955|      0|            uint32_t n;
 2956|      0|            ma = (int64_t *)origdata;
 2957|      0|            mb = data;
 2958|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2958:25): [True: 0, False: 0]
  ------------------
 2959|      0|            {
 2960|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2960:21): [True: 0, False: 0]
  ------------------
 2961|      0|                    TIFFSwabLong8((uint64_t *)ma);
 2962|      0|                *mb++ = (float)(*ma++);
 2963|      0|            }
 2964|      0|        }
 2965|      0|        break;
 2966|    340|        case TIFF_RATIONAL:
  ------------------
  |  Branch (2966:9): [True: 340, False: 749]
  ------------------
 2967|    340|        {
 2968|    340|            uint32_t *ma;
 2969|    340|            uint32_t maa;
 2970|    340|            uint32_t mab;
 2971|    340|            float *mb;
 2972|    340|            uint32_t n;
 2973|    340|            ma = (uint32_t *)origdata;
 2974|    340|            mb = data;
 2975|  2.12k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2975:25): [True: 1.78k, False: 340]
  ------------------
 2976|  1.78k|            {
 2977|  1.78k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.78k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2977:21): [True: 0, False: 1.78k]
  ------------------
 2978|      0|                    TIFFSwabLong(ma);
 2979|  1.78k|                maa = *ma++;
 2980|  1.78k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.78k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2980:21): [True: 0, False: 1.78k]
  ------------------
 2981|      0|                    TIFFSwabLong(ma);
 2982|  1.78k|                mab = *ma++;
 2983|  1.78k|                if (mab == 0)
  ------------------
  |  Branch (2983:21): [True: 162, False: 1.62k]
  ------------------
 2984|    162|                    *mb++ = 0.0;
 2985|  1.62k|                else
 2986|  1.62k|                    *mb++ = (float)maa / (float)mab;
 2987|  1.78k|            }
 2988|    340|        }
 2989|    340|        break;
 2990|      7|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (2990:9): [True: 7, False: 1.08k]
  ------------------
 2991|      7|        {
 2992|      7|            uint32_t *ma;
 2993|      7|            int32_t maa;
 2994|      7|            uint32_t mab;
 2995|      7|            float *mb;
 2996|      7|            uint32_t n;
 2997|      7|            ma = (uint32_t *)origdata;
 2998|      7|            mb = data;
 2999|     55|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2999:25): [True: 48, False: 7]
  ------------------
 3000|     48|            {
 3001|     48|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     48|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3001:21): [True: 0, False: 48]
  ------------------
 3002|      0|                    TIFFSwabLong(ma);
 3003|     48|                maa = *(int32_t *)ma;
 3004|     48|                ma++;
 3005|     48|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     48|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3005:21): [True: 0, False: 48]
  ------------------
 3006|      0|                    TIFFSwabLong(ma);
 3007|     48|                mab = *ma++;
 3008|     48|                if (mab == 0)
  ------------------
  |  Branch (3008:21): [True: 9, False: 39]
  ------------------
 3009|      9|                    *mb++ = 0.0;
 3010|     39|                else
 3011|     39|                    *mb++ = (float)maa / (float)mab;
 3012|     48|            }
 3013|      7|        }
 3014|      7|        break;
 3015|    547|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3015:9): [True: 547, False: 542]
  ------------------
 3016|    547|        {
 3017|    547|            double *ma;
 3018|    547|            float *mb;
 3019|    547|            uint32_t n;
 3020|    547|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    547|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3020:17): [True: 0, False: 547]
  ------------------
 3021|      0|                TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
 3022|    547|            TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
 3023|    547|            ma = (double *)origdata;
 3024|    547|            mb = data;
 3025|  3.80k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3025:25): [True: 3.26k, False: 547]
  ------------------
 3026|  3.26k|            {
 3027|  3.26k|                double val = *ma++;
 3028|  3.26k|                if (val > (double)FLT_MAX)
  ------------------
  |  Branch (3028:21): [True: 298, False: 2.96k]
  ------------------
 3029|    298|                    val = (double)FLT_MAX;
 3030|  2.96k|                else if (val < -(double)FLT_MAX)
  ------------------
  |  Branch (3030:26): [True: 560, False: 2.40k]
  ------------------
 3031|    560|                    val = -(double)FLT_MAX;
 3032|  3.26k|                *mb++ = (float)val;
 3033|  3.26k|            }
 3034|    547|        }
 3035|    547|        break;
 3036|      0|        default:
  ------------------
  |  Branch (3036:9): [True: 0, False: 1.08k]
  ------------------
 3037|      0|            break;
 3038|  1.08k|    }
 3039|  1.08k|    _TIFFfreeExt(tif, origdata);
 3040|  1.08k|    *value = data;
 3041|  1.08k|    return (TIFFReadDirEntryErrOk);
 3042|  1.08k|}
tif_dirread.c:TIFFReadDirEntryIfd8Array:
 3280|    342|{
 3281|    342|    enum TIFFReadDirEntryErr err;
 3282|    342|    uint32_t count;
 3283|    342|    void *origdata;
 3284|    342|    uint64_t *data;
 3285|    342|    switch (direntry->tdir_type)
 3286|    342|    {
 3287|     14|        case TIFF_LONG:
  ------------------
  |  Branch (3287:9): [True: 14, False: 328]
  ------------------
 3288|     14|        case TIFF_LONG8:
  ------------------
  |  Branch (3288:9): [True: 0, False: 342]
  ------------------
 3289|     32|        case TIFF_IFD:
  ------------------
  |  Branch (3289:9): [True: 18, False: 324]
  ------------------
 3290|    230|        case TIFF_IFD8:
  ------------------
  |  Branch (3290:9): [True: 198, False: 144]
  ------------------
 3291|    230|            break;
 3292|    112|        default:
  ------------------
  |  Branch (3292:9): [True: 112, False: 230]
  ------------------
 3293|    112|            return (TIFFReadDirEntryErrType);
 3294|    342|    }
 3295|    230|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 3296|    230|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (3296:9): [True: 133, False: 97]
  |  Branch (3296:43): [True: 26, False: 71]
  ------------------
 3297|    159|    {
 3298|    159|        *value = 0;
 3299|    159|        return (err);
 3300|    159|    }
 3301|     71|    switch (direntry->tdir_type)
 3302|     71|    {
 3303|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (3303:9): [True: 0, False: 71]
  ------------------
 3304|     47|        case TIFF_IFD8:
  ------------------
  |  Branch (3304:9): [True: 47, False: 24]
  ------------------
 3305|     47|            *value = (uint64_t *)origdata;
 3306|     47|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     47|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3306:17): [True: 0, False: 47]
  ------------------
 3307|      0|                TIFFSwabArrayOfLong8(*value, count);
 3308|     47|            return (TIFFReadDirEntryErrOk);
 3309|     24|        default:
  ------------------
  |  Branch (3309:9): [True: 24, False: 47]
  ------------------
 3310|     24|            break;
 3311|     71|    }
 3312|     24|    data = (uint64_t *)_TIFFCheckMalloc(tif, count, sizeof(uint64_t),
 3313|     24|                                        "TIFFReadDirEntryIfd8Array");
 3314|     24|    if (data == 0)
  ------------------
  |  Branch (3314:9): [True: 0, False: 24]
  ------------------
 3315|      0|    {
 3316|      0|        _TIFFfreeExt(tif, origdata);
 3317|      0|        return (TIFFReadDirEntryErrAlloc);
 3318|      0|    }
 3319|     24|    switch (direntry->tdir_type)
 3320|     24|    {
 3321|     10|        case TIFF_LONG:
  ------------------
  |  Branch (3321:9): [True: 10, False: 14]
  ------------------
 3322|     24|        case TIFF_IFD:
  ------------------
  |  Branch (3322:9): [True: 14, False: 10]
  ------------------
 3323|     24|        {
 3324|     24|            uint32_t *ma;
 3325|     24|            uint64_t *mb;
 3326|     24|            uint32_t n;
 3327|     24|            ma = (uint32_t *)origdata;
 3328|     24|            mb = data;
 3329|     63|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3329:25): [True: 39, False: 24]
  ------------------
 3330|     39|            {
 3331|     39|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     39|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3331:21): [True: 0, False: 39]
  ------------------
 3332|      0|                    TIFFSwabLong(ma);
 3333|     39|                *mb++ = (uint64_t)(*ma++);
 3334|     39|            }
 3335|     24|        }
 3336|     24|        break;
 3337|      0|        default:
  ------------------
  |  Branch (3337:9): [True: 0, False: 24]
  ------------------
 3338|      0|            break;
 3339|     24|    }
 3340|     24|    _TIFFfreeExt(tif, origdata);
 3341|     24|    *value = data;
 3342|     24|    return (TIFFReadDirEntryErrOk);
 3343|     24|}
tif_dirread.c:TIFFFetchStripThing:
 7793|  4.47k|{
 7794|  4.47k|    static const char module[] = "TIFFFetchStripThing";
 7795|  4.47k|    enum TIFFReadDirEntryErr err;
 7796|  4.47k|    uint64_t *data;
 7797|  4.47k|    err = TIFFReadDirEntryLong8ArrayWithLimit(tif, dir, &data, nstrips);
 7798|  4.47k|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7798:9): [True: 136, False: 4.33k]
  ------------------
 7799|    136|    {
 7800|    136|        const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
 7801|    136|        TIFFReadDirEntryOutputErr(tif, err, module,
 7802|    136|                                  fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (7802:35): [True: 136, False: 0]
  ------------------
 7803|    136|        return (0);
 7804|    136|    }
 7805|  4.33k|    if (dir->tdir_count < (uint64_t)nstrips)
  ------------------
  |  Branch (7805:9): [True: 1.04k, False: 3.29k]
  ------------------
 7806|  1.04k|    {
 7807|  1.04k|        uint64_t *resizeddata;
 7808|  1.04k|        const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
 7809|  1.04k|        const char *pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT");
 7810|  1.04k|        uint32_t max_nstrips = 1000000;
 7811|  1.04k|        if (pszMax)
  ------------------
  |  Branch (7811:13): [True: 0, False: 1.04k]
  ------------------
 7812|      0|            max_nstrips = (uint32_t)atoi(pszMax);
 7813|  1.04k|        TIFFReadDirEntryOutputErr(tif, TIFFReadDirEntryErrCount, module,
 7814|  1.04k|                                  fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (7814:35): [True: 1.04k, False: 0]
  ------------------
 7815|  1.04k|                                  (nstrips <= max_nstrips));
 7816|       |
 7817|  1.04k|        if (nstrips > max_nstrips)
  ------------------
  |  Branch (7817:13): [True: 0, False: 1.04k]
  ------------------
 7818|      0|        {
 7819|      0|            _TIFFfreeExt(tif, data);
 7820|      0|            return (0);
 7821|      0|        }
 7822|       |
 7823|  1.04k|        const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t);
 7824|  1.04k|        if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (7824:13): [True: 0, False: 1.04k]
  ------------------
 7825|      0|        {
 7826|       |            /* Before allocating a huge amount of memory for corrupted files,
 7827|       |             * check if size of requested memory is not greater than file size.
 7828|       |             */
 7829|      0|            const uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      0|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 7830|      0|            if (allocsize > filesize)
  ------------------
  |  Branch (7830:17): [True: 0, False: 0]
  ------------------
 7831|      0|            {
 7832|      0|                TIFFWarningExtR(
 7833|      0|                    tif, module,
 7834|      0|                    "Requested memory size for StripArray of %" PRIu64
 7835|      0|                    " is greater than filesize %" PRIu64
 7836|      0|                    ". Memory not allocated",
 7837|      0|                    allocsize, filesize);
 7838|      0|                _TIFFfreeExt(tif, data);
 7839|      0|                return (0);
 7840|      0|            }
 7841|      0|        }
 7842|  1.04k|        resizeddata = (uint64_t *)_TIFFCheckMalloc(
 7843|  1.04k|            tif, nstrips, sizeof(uint64_t), "for strip array");
 7844|  1.04k|        if (resizeddata == 0)
  ------------------
  |  Branch (7844:13): [True: 0, False: 1.04k]
  ------------------
 7845|      0|        {
 7846|      0|            _TIFFfreeExt(tif, data);
 7847|      0|            return (0);
 7848|      0|        }
 7849|  1.04k|        if (dir->tdir_count)
  ------------------
  |  Branch (7849:13): [True: 1.00k, False: 37]
  ------------------
 7850|  1.00k|            _TIFFmemcpy(resizeddata, data,
 7851|  1.00k|                        (tmsize_t)((size_t)dir->tdir_count * sizeof(uint64_t)));
 7852|  1.04k|        _TIFFmemset(resizeddata + (uint32_t)dir->tdir_count, 0,
 7853|  1.04k|                    (tmsize_t)((size_t)(nstrips - (uint32_t)dir->tdir_count) *
 7854|  1.04k|                               sizeof(uint64_t)));
 7855|  1.04k|        _TIFFfreeExt(tif, data);
 7856|  1.04k|        data = resizeddata;
 7857|  1.04k|    }
 7858|  4.33k|    *lpp = data;
 7859|  4.33k|    return (1);
 7860|  4.33k|}
tif_dirread.c:ChopUpSingleUncompressedStrip:
 8017|    107|{
 8018|    107|    TIFFDirectory *td = &tif->tif_dir;
 8019|    107|    uint64_t bytecount;
 8020|    107|    uint64_t offset;
 8021|    107|    uint32_t rowblock;
 8022|    107|    uint64_t rowblockbytes;
 8023|    107|    uint64_t stripbytes;
 8024|    107|    uint32_t nstrips;
 8025|    107|    uint32_t rowsperstrip;
 8026|       |
 8027|    107|    bytecount = TIFFGetStrileByteCount(tif, 0);
 8028|       |    /* On a newly created file, just re-opened to be filled, we */
 8029|       |    /* don't want strip chop to trigger as it is going to cause issues */
 8030|       |    /* later ( StripOffsets and StripByteCounts improperly filled) . */
 8031|    107|    if (bytecount == 0 && tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (8031:9): [True: 37, False: 70]
  |  Branch (8031:27): [True: 0, False: 37]
  ------------------
 8032|      0|        return;
 8033|    107|    offset = TIFFGetStrileOffset(tif, 0);
 8034|    107|    assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
  ------------------
  |  Branch (8034:5): [True: 0, False: 107]
  |  Branch (8034:5): [True: 107, False: 0]
  ------------------
 8035|    107|    if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|    107|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
                  if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  281|      8|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|      8|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (8035:9): [True: 8, False: 99]
  |  Branch (8035:54): [True: 8, False: 0]
  ------------------
 8036|      8|        rowblock = td->td_ycbcrsubsampling[1];
 8037|     99|    else
 8038|     99|        rowblock = 1;
 8039|    107|    rowblockbytes = TIFFVTileSize64(tif, rowblock);
 8040|       |    /*
 8041|       |     * Make the rows hold at least one scanline, but fill specified amount
 8042|       |     * of data if possible.
 8043|       |     */
 8044|    107|    if (rowblockbytes > STRIP_SIZE_DEFAULT)
  ------------------
  |  |  119|    107|#define STRIP_SIZE_DEFAULT 8192
  ------------------
  |  Branch (8044:9): [True: 15, False: 92]
  ------------------
 8045|     15|    {
 8046|     15|        stripbytes = rowblockbytes;
 8047|     15|        rowsperstrip = rowblock;
 8048|     15|    }
 8049|     92|    else if (rowblockbytes > 0)
  ------------------
  |  Branch (8049:14): [True: 79, False: 13]
  ------------------
 8050|     79|    {
 8051|     79|        uint32_t rowblocksperstrip;
 8052|     79|        rowblocksperstrip = (uint32_t)(STRIP_SIZE_DEFAULT / rowblockbytes);
  ------------------
  |  |  119|     79|#define STRIP_SIZE_DEFAULT 8192
  ------------------
 8053|     79|        rowsperstrip = rowblocksperstrip * rowblock;
 8054|     79|        stripbytes = rowblocksperstrip * rowblockbytes;
 8055|     79|    }
 8056|     13|    else
 8057|     13|        return;
 8058|       |
 8059|       |    /*
 8060|       |     * never increase the number of rows per strip
 8061|       |     */
 8062|     94|    if (rowsperstrip >= td->td_rowsperstrip || rowsperstrip == 0)
  ------------------
  |  Branch (8062:9): [True: 29, False: 65]
  |  Branch (8062:48): [True: 0, False: 65]
  ------------------
 8063|     29|        return;
 8064|     65|    nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  312|     65|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 61, False: 4]
  |  |  ------------------
  |  |  313|     65|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|     65|         : 0U)
  ------------------
 8065|     65|    if (nstrips == 0)
  ------------------
  |  Branch (8065:9): [True: 5, False: 60]
  ------------------
 8066|      5|        return;
 8067|       |
 8068|       |    /* If we are going to allocate a lot of memory, make sure that the */
 8069|       |    /* file is as big as needed */
 8070|     60|    if (tif->tif_mode == O_RDONLY && nstrips > 1000000 &&
  ------------------
  |  Branch (8070:9): [True: 60, False: 0]
  |  Branch (8070:38): [True: 17, False: 43]
  ------------------
 8071|     17|        (offset >= TIFFGetFileSize(tif) ||
  ------------------
  |  |  289|     34|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
  |  Branch (8071:10): [True: 10, False: 7]
  ------------------
 8072|      7|         stripbytes > (TIFFGetFileSize(tif) - offset) / (nstrips - 1)))
  ------------------
  |  |  289|      7|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
  |  Branch (8072:10): [True: 7, False: 0]
  ------------------
 8073|     17|    {
 8074|     17|        return;
 8075|     17|    }
 8076|       |
 8077|     43|    allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
 8078|     43|}
tif_dirread.c:allocChoppedUpStripArrays:
 7922|     53|{
 7923|     53|    TIFFDirectory *td = &tif->tif_dir;
 7924|     53|    uint64_t bytecount;
 7925|     53|    uint64_t offset;
 7926|     53|    uint64_t last_offset;
 7927|     53|    uint64_t last_bytecount;
 7928|     53|    uint32_t i;
 7929|     53|    uint64_t *newcounts;
 7930|     53|    uint64_t *newoffsets;
 7931|       |
 7932|     53|    offset = TIFFGetStrileOffset(tif, 0);
 7933|     53|    last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
 7934|     53|    last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
 7935|     53|    if (last_offset > UINT64_MAX - last_bytecount ||
  ------------------
  |  Branch (7935:9): [True: 0, False: 53]
  ------------------
 7936|     53|        last_offset + last_bytecount < offset)
  ------------------
  |  Branch (7936:9): [True: 0, False: 53]
  ------------------
 7937|      0|    {
 7938|      0|        return;
 7939|      0|    }
 7940|     53|    bytecount = last_offset + last_bytecount - offset;
 7941|       |
 7942|       |    /* Before allocating a huge amount of memory for corrupted files, check if
 7943|       |     * size of StripByteCount and StripOffset tags is not greater than
 7944|       |     * file size.
 7945|       |     */
 7946|     53|    const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t) * 2;
 7947|     53|    if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (7947:9): [True: 0, False: 53]
  ------------------
 7948|      0|    {
 7949|      0|        const uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      0|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 7950|      0|        if (allocsize > filesize)
  ------------------
  |  Branch (7950:13): [True: 0, False: 0]
  ------------------
 7951|      0|        {
 7952|      0|            TIFFWarningExtR(tif, "allocChoppedUpStripArrays",
 7953|      0|                            "Requested memory size for StripByteCount and "
 7954|      0|                            "StripOffsets %" PRIu64
 7955|      0|                            " is greater than filesize %" PRIu64
 7956|      0|                            ". Memory not allocated",
 7957|      0|                            allocsize, filesize);
 7958|      0|            return;
 7959|      0|        }
 7960|      0|    }
 7961|       |
 7962|     53|    newcounts =
 7963|     53|        (uint64_t *)_TIFFCheckMalloc(tif, nstrips, sizeof(uint64_t),
 7964|     53|                                     "for chopped \"StripByteCounts\" array");
 7965|     53|    newoffsets = (uint64_t *)_TIFFCheckMalloc(
 7966|     53|        tif, nstrips, sizeof(uint64_t), "for chopped \"StripOffsets\" array");
 7967|     53|    if (newcounts == NULL || newoffsets == NULL)
  ------------------
  |  Branch (7967:9): [True: 0, False: 53]
  |  Branch (7967:30): [True: 0, False: 53]
  ------------------
 7968|      0|    {
 7969|       |        /*
 7970|       |         * Unable to allocate new strip information, give up and use
 7971|       |         * the original one strip information.
 7972|       |         */
 7973|      0|        if (newcounts != NULL)
  ------------------
  |  Branch (7973:13): [True: 0, False: 0]
  ------------------
 7974|      0|            _TIFFfreeExt(tif, newcounts);
 7975|      0|        if (newoffsets != NULL)
  ------------------
  |  Branch (7975:13): [True: 0, False: 0]
  ------------------
 7976|      0|            _TIFFfreeExt(tif, newoffsets);
 7977|      0|        return;
 7978|      0|    }
 7979|       |
 7980|       |    /*
 7981|       |     * Fill the strip information arrays with new bytecounts and offsets
 7982|       |     * that reflect the broken-up format.
 7983|       |     */
 7984|   166k|    for (i = 0; i < nstrips; i++)
  ------------------
  |  Branch (7984:17): [True: 166k, False: 53]
  ------------------
 7985|   166k|    {
 7986|   166k|        if (stripbytes > bytecount)
  ------------------
  |  Branch (7986:13): [True: 50, False: 165k]
  ------------------
 7987|     50|            stripbytes = bytecount;
 7988|   166k|        newcounts[i] = stripbytes;
 7989|   166k|        newoffsets[i] = stripbytes ? offset : 0;
  ------------------
  |  Branch (7989:25): [True: 100k, False: 65.6k]
  ------------------
 7990|   166k|        offset += stripbytes;
 7991|   166k|        bytecount -= stripbytes;
 7992|   166k|    }
 7993|       |
 7994|       |    /*
 7995|       |     * Replace old single strip info with multi-strip info.
 7996|       |     */
 7997|     53|    td->td_stripsperimage = td->td_nstrips = nstrips;
 7998|     53|    TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
  ------------------
  |  |  258|     53|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 7999|       |
 8000|     53|    _TIFFfreeExt(tif, td->td_stripbytecount_p);
 8001|     53|    _TIFFfreeExt(tif, td->td_stripoffset_p);
 8002|     53|    td->td_stripbytecount_p = newcounts;
 8003|     53|    td->td_stripoffset_p = newoffsets;
 8004|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 8005|       |    td->td_stripbytecountsorted = 1;
 8006|       |#endif
 8007|     53|    tif->tif_flags |= TIFF_CHOPPEDUPARRAYS;
  ------------------
  |  |  153|     53|    0x4000000U /* set when allocChoppedUpStripArrays() has modified strip      \
  ------------------
 8008|     53|}
tif_dirread.c:TryChopUpUncompressedBigTiff:
 8087|     27|{
 8088|     27|    TIFFDirectory *td = &tif->tif_dir;
 8089|     27|    uint32_t rowblock;
 8090|     27|    uint64_t rowblockbytes;
 8091|     27|    uint32_t i;
 8092|     27|    uint64_t stripsize;
 8093|     27|    uint32_t rowblocksperstrip;
 8094|     27|    uint32_t rowsperstrip;
 8095|     27|    uint64_t stripbytes;
 8096|     27|    uint32_t nstrips;
 8097|       |
 8098|     27|    stripsize = TIFFStripSize64(tif);
 8099|       |
 8100|     27|    assert(tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG);
  ------------------
  |  Branch (8100:5): [True: 0, False: 27]
  |  Branch (8100:5): [True: 27, False: 0]
  ------------------
 8101|     27|    assert(tif->tif_dir.td_compression == COMPRESSION_NONE);
  ------------------
  |  Branch (8101:5): [True: 0, False: 27]
  |  Branch (8101:5): [True: 27, False: 0]
  ------------------
 8102|     27|    assert((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) ==
  ------------------
  |  Branch (8102:5): [True: 0, False: 27]
  |  Branch (8102:5): [True: 27, False: 0]
  ------------------
 8103|     27|           TIFF_STRIPCHOP);
 8104|     27|    assert(stripsize > 0x7FFFFFFFUL);
  ------------------
  |  Branch (8104:5): [True: 0, False: 27]
  |  Branch (8104:5): [True: 27, False: 0]
  ------------------
 8105|       |
 8106|       |    /* On a newly created file, just re-opened to be filled, we */
 8107|       |    /* don't want strip chop to trigger as it is going to cause issues */
 8108|       |    /* later ( StripOffsets and StripByteCounts improperly filled) . */
 8109|     27|    if (TIFFGetStrileByteCount(tif, 0) == 0 && tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (8109:9): [True: 8, False: 19]
  |  Branch (8109:48): [True: 0, False: 8]
  ------------------
 8110|      0|        return;
 8111|       |
 8112|     27|    if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|     27|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
                  if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  281|      0|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|      0|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (8112:9): [True: 0, False: 27]
  |  Branch (8112:54): [True: 0, False: 0]
  ------------------
 8113|      0|        rowblock = td->td_ycbcrsubsampling[1];
 8114|     27|    else
 8115|     27|        rowblock = 1;
 8116|     27|    rowblockbytes = TIFFVStripSize64(tif, rowblock);
 8117|     27|    if (rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL)
  ------------------
  |  Branch (8117:9): [True: 0, False: 27]
  |  Branch (8117:31): [True: 4, False: 23]
  ------------------
 8118|      4|    {
 8119|       |        /* In case of file with gigantic width */
 8120|      4|        return;
 8121|      4|    }
 8122|       |
 8123|       |    /* Check that the strips are contiguous and of the expected size */
 8124|     40|    for (i = 0; i < td->td_nstrips; i++)
  ------------------
  |  Branch (8124:17): [True: 23, False: 17]
  ------------------
 8125|     23|    {
 8126|     23|        if (i == td->td_nstrips - 1)
  ------------------
  |  Branch (8126:13): [True: 21, False: 2]
  ------------------
 8127|     21|        {
 8128|     21|            if (TIFFGetStrileByteCount(tif, i) <
  ------------------
  |  Branch (8128:17): [True: 4, False: 17]
  ------------------
 8129|     21|                TIFFVStripSize64(tif,
 8130|     21|                                 td->td_imagelength - i * td->td_rowsperstrip))
 8131|      4|            {
 8132|      4|                return;
 8133|      4|            }
 8134|     21|        }
 8135|      2|        else
 8136|      2|        {
 8137|      2|            if (TIFFGetStrileByteCount(tif, i) != stripsize)
  ------------------
  |  Branch (8137:17): [True: 2, False: 0]
  ------------------
 8138|      2|            {
 8139|      2|                return;
 8140|      2|            }
 8141|      0|            if (i > 0 && TIFFGetStrileOffset(tif, i) !=
  ------------------
  |  Branch (8141:17): [True: 0, False: 0]
  |  Branch (8141:26): [True: 0, False: 0]
  ------------------
 8142|      0|                             TIFFGetStrileOffset(tif, i - 1) +
 8143|      0|                                 TIFFGetStrileByteCount(tif, i - 1))
 8144|      0|            {
 8145|      0|                return;
 8146|      0|            }
 8147|      0|        }
 8148|     23|    }
 8149|       |
 8150|       |    /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */
 8151|     17|    rowblocksperstrip = (uint32_t)(512 * 1024 * 1024 / rowblockbytes);
 8152|     17|    if (rowblocksperstrip == 0)
  ------------------
  |  Branch (8152:9): [True: 0, False: 17]
  ------------------
 8153|      0|        rowblocksperstrip = 1;
 8154|     17|    rowsperstrip = rowblocksperstrip * rowblock;
 8155|     17|    stripbytes = rowblocksperstrip * rowblockbytes;
 8156|     17|    assert(stripbytes <= 0x7FFFFFFFUL);
  ------------------
  |  Branch (8156:5): [True: 0, False: 17]
  |  Branch (8156:5): [True: 17, False: 0]
  ------------------
 8157|       |
 8158|     17|    if (rowsperstrip == 0)
  ------------------
  |  Branch (8158:9): [True: 0, False: 17]
  ------------------
 8159|      0|        return;
 8160|     17|    nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  312|     17|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 17, False: 0]
  |  |  ------------------
  |  |  313|     17|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|     17|         : 0U)
  ------------------
 8161|     17|    if (nstrips == 0)
  ------------------
  |  Branch (8161:9): [True: 0, False: 17]
  ------------------
 8162|      0|        return;
 8163|       |
 8164|       |    /* If we are going to allocate a lot of memory, make sure that the */
 8165|       |    /* file is as big as needed */
 8166|     17|    if (tif->tif_mode == O_RDONLY && nstrips > 1000000)
  ------------------
  |  Branch (8166:9): [True: 17, False: 0]
  |  Branch (8166:38): [True: 7, False: 10]
  ------------------
 8167|      7|    {
 8168|      7|        uint64_t last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
 8169|      7|        uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      7|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 8170|      7|        uint64_t last_bytecount =
 8171|      7|            TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
 8172|      7|        if (last_offset > filesize || last_bytecount > filesize - last_offset)
  ------------------
  |  Branch (8172:13): [True: 0, False: 7]
  |  Branch (8172:39): [True: 7, False: 0]
  ------------------
 8173|      7|        {
 8174|      7|            return;
 8175|      7|        }
 8176|      7|    }
 8177|       |
 8178|     10|    allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
 8179|     10|}
tif_dirread.c:_TIFFGetStrileOffsetOrByteCountValue:
 8456|  43.3M|{
 8457|  43.3M|    TIFFDirectory *td = &tif->tif_dir;
 8458|  43.3M|    if (pbErr)
  ------------------
  |  Branch (8458:9): [True: 43.0M, False: 246k]
  ------------------
 8459|  43.0M|        *pbErr = 0;
 8460|       |
 8461|  43.3M|    if (strile >= td->td_nstrips)
  ------------------
  |  Branch (8461:9): [True: 0, False: 43.3M]
  ------------------
 8462|      0|    {
 8463|      0|        if (pbErr)
  ------------------
  |  Branch (8463:13): [True: 0, False: 0]
  ------------------
 8464|      0|            *pbErr = 1;
 8465|      0|        return 0;
 8466|      0|    }
 8467|       |
 8468|       |    /* Avoid the "dirent->tdir_count <= 4" code path for one of
 8469|       |     * StripOffsets/StripByteCounts, and the other code path for the other one,
 8470|       |     * which will lead to inconsistencies and potential out-of-bounds reads.
 8471|       |     */
 8472|  43.3M|    if ((td->td_stripoffset_entry.tdir_count <= 4) !=
  ------------------
  |  Branch (8472:9): [True: 5.88k, False: 43.2M]
  ------------------
 8473|  43.3M|        (td->td_stripbytecount_entry.tdir_count <= 4))
 8474|  5.88k|    {
 8475|  5.88k|        TIFFErrorExtR(tif, "_TIFFGetStrileOffsetOrByteCountValue",
 8476|  5.88k|                      "Inconsistent directory count between StripOffsets and "
 8477|  5.88k|                      "StripByteCounts");
 8478|  5.88k|        if (pbErr)
  ------------------
  |  Branch (8478:13): [True: 1.89k, False: 3.99k]
  ------------------
 8479|  1.89k|            *pbErr = 1;
 8480|  5.88k|        return 0;
 8481|  5.88k|    }
 8482|       |
 8483|  43.2M|    if ((tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
  ------------------
  |  |  147|  43.2M|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (8483:9): [True: 0, False: 43.2M]
  ------------------
 8484|      0|        !(tif->tif_flags & TIFF_CHOPPEDUPARRAYS))
  ------------------
  |  |  153|      0|    0x4000000U /* set when allocChoppedUpStripArrays() has modified strip      \
  ------------------
  |  Branch (8484:9): [True: 0, False: 0]
  ------------------
 8485|      0|    {
 8486|      0|        if (!(tif->tif_flags & TIFF_LAZYSTRILELOAD_ASKED) ||
  ------------------
  |  |  156|      0|    0x8000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
  |  Branch (8486:13): [True: 0, False: 0]
  ------------------
 8487|       |            /* If the values may fit in the toff_long/toff_long8 member */
 8488|       |            /* then use _TIFFFillStriles to simplify _TIFFFetchStrileValue */
 8489|      0|            dirent->tdir_count <= 4)
  ------------------
  |  Branch (8489:13): [True: 0, False: 0]
  ------------------
 8490|      0|        {
 8491|      0|            if (!_TIFFFillStriles(tif))
  ------------------
  |  Branch (8491:17): [True: 0, False: 0]
  ------------------
 8492|      0|            {
 8493|      0|                if (pbErr)
  ------------------
  |  Branch (8493:21): [True: 0, False: 0]
  ------------------
 8494|      0|                    *pbErr = 1;
 8495|       |                /* Do not return, as we want this function to always */
 8496|       |                /* return the same value if called several times with */
 8497|       |                /* the same arguments */
 8498|      0|            }
 8499|      0|        }
 8500|      0|        else
 8501|      0|        {
 8502|      0|            if (!_TIFFFetchStrileValue(tif, strile, dirent, parray))
  ------------------
  |  Branch (8502:17): [True: 0, False: 0]
  ------------------
 8503|      0|            {
 8504|      0|                if (pbErr)
  ------------------
  |  Branch (8504:21): [True: 0, False: 0]
  ------------------
 8505|      0|                    *pbErr = 1;
 8506|      0|                return 0;
 8507|      0|            }
 8508|      0|        }
 8509|      0|    }
 8510|  43.2M|    if (*parray == NULL)
  ------------------
  |  Branch (8510:9): [True: 911, False: 43.2M]
  ------------------
 8511|    911|    {
 8512|    911|        if (pbErr)
  ------------------
  |  Branch (8512:13): [True: 911, False: 0]
  ------------------
 8513|    911|            *pbErr = 1;
 8514|    911|        return 0;
 8515|    911|    }
 8516|  43.2M|    return (*parray)[strile];
 8517|  43.2M|}
tif_dirread.c:_TIFFFillStrilesInternal:
 8556|  1.11k|{
 8557|  1.11k|    TIFFDirectory *td = &tif->tif_dir;
 8558|  1.11k|    int return_value = 1;
 8559|       |
 8560|       |    /* Do not do anything if TIFF_DEFERSTRILELOAD is not set */
 8561|  1.11k|    if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) ||
  ------------------
  |  |  147|  1.11k|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (8561:9): [True: 1.11k, False: 0]
  ------------------
 8562|      0|        (tif->tif_flags & TIFF_CHOPPEDUPARRAYS) != 0)
  ------------------
  |  |  153|      0|    0x4000000U /* set when allocChoppedUpStripArrays() has modified strip      \
  ------------------
  |  Branch (8562:9): [True: 0, False: 0]
  ------------------
 8563|  1.11k|        return 1;
 8564|       |
 8565|      0|    if ((tif->tif_flags & TIFF_LAZYSTRILELOAD_ASKED) &&
  ------------------
  |  |  156|      0|    0x8000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
  |  Branch (8565:9): [True: 0, False: 0]
  ------------------
 8566|      0|        !(tif->tif_flags & TIFF_LAZYSTRILELOAD_DONE))
  ------------------
  |  |  149|      0|    0x2000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
  |  Branch (8566:9): [True: 0, False: 0]
  ------------------
 8567|      0|    {
 8568|       |        /* In case of lazy loading, reload completely the arrays */
 8569|      0|        _TIFFfreeExt(tif, td->td_stripoffset_p);
 8570|      0|        _TIFFfreeExt(tif, td->td_stripbytecount_p);
 8571|      0|        td->td_stripoffset_p = NULL;
 8572|      0|        td->td_stripbytecount_p = NULL;
 8573|      0|        td->td_stripoffsetbyteallocsize = 0;
 8574|      0|        tif->tif_flags |= TIFF_LAZYSTRILELOAD_DONE;
  ------------------
  |  |  149|      0|    0x2000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
 8575|      0|    }
 8576|       |
 8577|       |    /* If stripoffset array is already loaded, exit with success */
 8578|      0|    if (td->td_stripoffset_p != NULL)
  ------------------
  |  Branch (8578:9): [True: 0, False: 0]
  ------------------
 8579|      0|        return 1;
 8580|       |
 8581|       |    /* If tdir_count was canceled, then we already got there, but in error */
 8582|      0|    if (td->td_stripoffset_entry.tdir_count == 0)
  ------------------
  |  Branch (8582:9): [True: 0, False: 0]
  ------------------
 8583|      0|        return 0;
 8584|       |
 8585|      0|    if (!TIFFFetchStripThing(tif, &(td->td_stripoffset_entry), td->td_nstrips,
  ------------------
  |  Branch (8585:9): [True: 0, False: 0]
  ------------------
 8586|      0|                             &td->td_stripoffset_p))
 8587|      0|    {
 8588|      0|        return_value = 0;
 8589|      0|    }
 8590|       |
 8591|      0|    if (loadStripByteCount &&
  ------------------
  |  Branch (8591:9): [True: 0, False: 0]
  ------------------
 8592|      0|        !TIFFFetchStripThing(tif, &(td->td_stripbytecount_entry),
  ------------------
  |  Branch (8592:9): [True: 0, False: 0]
  ------------------
 8593|      0|                             td->td_nstrips, &td->td_stripbytecount_p))
 8594|      0|    {
 8595|      0|        return_value = 0;
 8596|      0|    }
 8597|       |
 8598|      0|    _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
 8599|      0|    _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
 8600|       |
 8601|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 8602|       |    if (tif->tif_dir.td_nstrips > 1 && return_value == 1)
 8603|       |    {
 8604|       |        uint32_t strip;
 8605|       |
 8606|       |        tif->tif_dir.td_stripbytecountsorted = 1;
 8607|       |        for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++)
 8608|       |        {
 8609|       |            if (tif->tif_dir.td_stripoffset_p[strip - 1] >
 8610|       |                tif->tif_dir.td_stripoffset_p[strip])
 8611|       |            {
 8612|       |                tif->tif_dir.td_stripbytecountsorted = 0;
 8613|       |                break;
 8614|       |            }
 8615|       |        }
 8616|       |    }
 8617|       |#endif
 8618|       |
 8619|      0|    return return_value;
 8620|      0|}

TIFFInitDumpMode:
  126|  3.00k|{
  127|  3.00k|    (void)scheme;
  128|  3.00k|    tif->tif_fixuptags = DumpFixupTags;
  129|  3.00k|    tif->tif_decoderow = DumpModeDecode;
  130|  3.00k|    tif->tif_decodestrip = DumpModeDecode;
  131|  3.00k|    tif->tif_decodetile = DumpModeDecode;
  132|  3.00k|    tif->tif_encoderow = DumpModeEncode;
  133|  3.00k|    tif->tif_encodestrip = DumpModeEncode;
  134|  3.00k|    tif->tif_encodetile = DumpModeEncode;
  135|  3.00k|    tif->tif_seek = DumpModeSeek;
  136|  3.00k|    return (1);
  137|  3.00k|}
tif_dumpmode.c:DumpFixupTags:
   33|    192|{
   34|    192|    (void)tif;
   35|    192|    return (1);
   36|    192|}
tif_dumpmode.c:DumpModeDecode:
   74|  2.23k|{
   75|  2.23k|    static const char module[] = "DumpModeDecode";
   76|  2.23k|    (void)s;
   77|  2.23k|    if (tif->tif_rawcc < cc)
  ------------------
  |  Branch (77:9): [True: 69, False: 2.16k]
  ------------------
   78|     69|    {
   79|     69|        TIFFErrorExtR(tif, module,
   80|     69|                      "Not enough data for scanline %" PRIu32
   81|     69|                      ", expected a request for at most %" TIFF_SSIZE_FORMAT
   82|     69|                      " bytes, got a request for %" TIFF_SSIZE_FORMAT " bytes",
   83|     69|                      tif->tif_dir.td_row, tif->tif_rawcc, cc);
   84|     69|        return (0);
   85|     69|    }
   86|       |    /*
   87|       |     * Avoid copy if client has setup raw
   88|       |     * data buffer to avoid extra copy.
   89|       |     */
   90|  2.16k|    if (tif->tif_rawcp != buf)
  ------------------
  |  Branch (90:9): [True: 2.16k, False: 0]
  ------------------
   91|  2.16k|        _TIFFmemcpy(buf, tif->tif_rawcp, cc);
   92|  2.16k|    tif->tif_rawcp += cc;
   93|  2.16k|    tif->tif_rawcc -= cc;
   94|  2.16k|    return (1);
   95|  2.23k|}

TIFFSetErrorHandler:
   33|  1.28k|{
   34|  1.28k|    TIFFErrorHandler prev = _TIFFerrorHandler;
   35|  1.28k|    _TIFFerrorHandler = handler;
   36|  1.28k|    return (prev);
   37|  1.28k|}
TIFFErrorExtR:
  108|   561k|{
  109|   561k|    va_list ap;
  110|   561k|    if (tif && tif->tif_errorhandler)
  ------------------
  |  Branch (110:9): [True: 561k, False: 0]
  |  Branch (110:16): [True: 0, False: 561k]
  ------------------
  111|      0|    {
  112|      0|        va_start(ap, fmt);
  113|      0|        int stop = (*tif->tif_errorhandler)(
  114|      0|            tif, tif->tif_errorhandler_user_data, module, fmt, ap);
  115|      0|        va_end(ap);
  116|      0|        if (stop)
  ------------------
  |  Branch (116:13): [True: 0, False: 0]
  ------------------
  117|      0|            return;
  118|      0|    }
  119|   561k|    if (_TIFFerrorHandler)
  ------------------
  |  Branch (119:9): [True: 561k, False: 0]
  ------------------
  120|   561k|    {
  121|   561k|        va_start(ap, fmt);
  122|   561k|        (*_TIFFerrorHandler)(module, fmt, ap);
  123|   561k|        va_end(ap);
  124|   561k|    }
  125|   561k|    if (_TIFFerrorHandlerExt)
  ------------------
  |  Branch (125:9): [True: 0, False: 561k]
  ------------------
  126|      0|    {
  127|      0|        va_start(ap, fmt);
  128|      0|        (*_TIFFerrorHandlerExt)(tif ? tif->tif_clientdata : NULL, module, fmt,
  ------------------
  |  Branch (128:33): [True: 0, False: 0]
  ------------------
  129|      0|                                ap);
  130|       |        va_end(ap);
  131|      0|    }
  132|   561k|}

_TIFFFax3fillruns:
  464|   155k|{
  465|   155k|    static const unsigned char _fillmasks[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
  466|   155k|                                               0xf8, 0xfc, 0xfe, 0xff};
  467|   155k|    unsigned char *cp;
  468|   155k|    uint32_t x, bx, run;
  469|   155k|    int32_t n, nw;
  470|   155k|    int64_t *lp;
  471|       |
  472|   155k|    if ((erun - runs) & 1)
  ------------------
  |  Branch (472:9): [True: 154k, False: 315]
  ------------------
  473|   154k|        *erun++ = 0;
  474|   155k|    x = 0;
  475|   332k|    for (; runs < erun; runs += 2)
  ------------------
  |  Branch (475:12): [True: 177k, False: 155k]
  ------------------
  476|   177k|    {
  477|   177k|        run = runs[0];
  478|   177k|        if (x + run > lastx || run > lastx)
  ------------------
  |  Branch (478:13): [True: 1.96k, False: 175k]
  |  Branch (478:32): [True: 0, False: 175k]
  ------------------
  479|  1.96k|            run = runs[0] = (uint32_t)(lastx - x);
  480|   177k|        if (run)
  ------------------
  |  Branch (480:13): [True: 175k, False: 2.14k]
  ------------------
  481|   175k|        {
  482|   175k|            cp = buf + (x >> 3);
  483|   175k|            bx = x & 7;
  484|   175k|            if (run > 8 - bx)
  ------------------
  |  Branch (484:17): [True: 87.5k, False: 87.9k]
  ------------------
  485|  87.5k|            {
  486|  87.5k|                if (bx)
  ------------------
  |  Branch (486:21): [True: 10.1k, False: 77.3k]
  ------------------
  487|  10.1k|                { /* align to byte boundary */
  488|  10.1k|                    *cp++ &= (unsigned char)(0xff << (8 - bx));
  489|  10.1k|                    run -= 8 - bx;
  490|  10.1k|                }
  491|  87.5k|                if ((n = (int32_t)(run >> 3)) != 0)
  ------------------
  |  Branch (491:21): [True: 85.7k, False: 1.74k]
  ------------------
  492|  85.7k|                { /* multiple bytes to fill */
  493|  85.7k|                    if (((size_t)n / sizeof(int64_t)) > 1)
  ------------------
  |  Branch (493:25): [True: 3.20k, False: 82.5k]
  ------------------
  494|  3.20k|                    {
  495|       |                        /*
  496|       |                         * Align to int64_tword boundary and fill.
  497|       |                         */
  498|  14.4k|                        for (; n && !isAligned(cp, int64_t); n--)
  ------------------
  |  |  112|  14.4k|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (498:32): [True: 14.4k, False: 0]
  |  Branch (498:37): [True: 11.2k, False: 3.20k]
  ------------------
  499|  11.2k|                            *cp++ = 0x00;
  500|  3.20k|                        lp = (int64_t *)cp;
  501|  3.20k|                        nw = (int32_t)((size_t)n / sizeof(int64_t));
  502|  3.20k|                        n -= (int32_t)((size_t)nw * sizeof(int64_t));
  503|  3.20k|                        do
  504|  89.2k|                        {
  505|  89.2k|                            *lp++ = 0L;
  506|  89.2k|                        } while (--nw);
  ------------------
  |  Branch (506:34): [True: 86.0k, False: 3.20k]
  ------------------
  507|  3.20k|                        cp = (unsigned char *)lp;
  508|  3.20k|                    }
  509|  85.7k|                    ZERO(n, cp);
  ------------------
  |  |  452|   402k|    for (int32_t izero = 0; izero < (n); ++izero)                              \
  |  |  ------------------
  |  |  |  Branch (452:29): [True: 316k, False: 85.7k]
  |  |  ------------------
  |  |  453|   316k|    {                                                                          \
  |  |  454|   316k|        (cp)[izero] = 0;                                                       \
  |  |  455|   316k|    }                                                                          \
  |  |  456|  85.7k|    (cp) += (n);
  ------------------
  510|  85.7k|                    run &= 7;
  511|  85.7k|                }
  512|  87.5k|                if (run)
  ------------------
  |  Branch (512:21): [True: 13.9k, False: 73.5k]
  ------------------
  513|  13.9k|                    cp[0] &= (unsigned char)(0xff >> run);
  514|  87.5k|            }
  515|  87.9k|            else
  516|  87.9k|                cp[0] &= (unsigned char)~(_fillmasks[run] >> bx);
  517|   175k|            x += runs[0];
  518|   175k|        }
  519|   177k|        run = runs[1];
  520|   177k|        if (x + run > lastx || run > lastx)
  ------------------
  |  Branch (520:13): [True: 0, False: 177k]
  |  Branch (520:32): [True: 0, False: 177k]
  ------------------
  521|      0|            run = runs[1] = lastx - x;
  522|   177k|        if (run)
  ------------------
  |  Branch (522:13): [True: 13.9k, False: 163k]
  ------------------
  523|  13.9k|        {
  524|  13.9k|            cp = buf + (x >> 3);
  525|  13.9k|            bx = x & 7;
  526|  13.9k|            if (run > 8 - bx)
  ------------------
  |  Branch (526:17): [True: 4.93k, False: 8.96k]
  ------------------
  527|  4.93k|            {
  528|  4.93k|                if (bx)
  ------------------
  |  Branch (528:21): [True: 4.79k, False: 133]
  ------------------
  529|  4.79k|                { /* align to byte boundary */
  530|  4.79k|                    *cp++ |= (unsigned char)(0xff >> bx);
  531|  4.79k|                    run -= 8 - bx;
  532|  4.79k|                }
  533|  4.93k|                if ((n = (int32_t)(run >> 3)) != 0)
  ------------------
  |  Branch (533:21): [True: 709, False: 4.22k]
  ------------------
  534|    709|                { /* multiple bytes to fill */
  535|    709|                    if (((size_t)n / sizeof(int64_t)) > 1)
  ------------------
  |  Branch (535:25): [True: 101, False: 608]
  ------------------
  536|    101|                    {
  537|       |                        /*
  538|       |                         * Align to int64_t boundary and fill.
  539|       |                         */
  540|    434|                        for (; n && !isAligned(cp, int64_t); n--)
  ------------------
  |  |  112|    434|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (540:32): [True: 434, False: 0]
  |  Branch (540:37): [True: 333, False: 101]
  ------------------
  541|    333|                            *cp++ = 0xff;
  542|    101|                        lp = (int64_t *)cp;
  543|    101|                        nw = (int32_t)((size_t)n / sizeof(int64_t));
  544|    101|                        n -= (int32_t)((size_t)nw * sizeof(int64_t));
  545|    101|                        do
  546|  2.65k|                        {
  547|  2.65k|                            *lp++ = -1L;
  548|  2.65k|                        } while (--nw);
  ------------------
  |  Branch (548:34): [True: 2.55k, False: 101]
  ------------------
  549|    101|                        cp = (unsigned char *)lp;
  550|    101|                    }
  551|    709|                    FILL(n, cp);
  ------------------
  |  |  445|  1.87k|    for (int32_t ifill = 0; ifill < (n); ++ifill)                              \
  |  |  ------------------
  |  |  |  Branch (445:29): [True: 1.16k, False: 709]
  |  |  ------------------
  |  |  446|  1.16k|    {                                                                          \
  |  |  447|  1.16k|        (cp)[ifill] = 0xff;                                                    \
  |  |  448|  1.16k|    }                                                                          \
  |  |  449|    709|    (cp) += (n);
  ------------------
  552|    709|                    run &= 7;
  553|    709|                }
  554|       |                /* Explicit 0xff masking to make icc -check=conversions happy */
  555|  4.93k|                if (run)
  ------------------
  |  Branch (555:21): [True: 4.71k, False: 215]
  ------------------
  556|  4.71k|                    cp[0] = (unsigned char)((cp[0] | (0xff00 >> run)) & 0xff);
  557|  4.93k|            }
  558|  8.96k|            else
  559|  8.96k|                cp[0] |= (unsigned char)(_fillmasks[run] >> bx);
  560|  13.9k|            x += runs[1];
  561|  13.9k|        }
  562|   177k|    }
  563|       |    assert(x == lastx);
  ------------------
  |  Branch (563:5): [True: 0, False: 155k]
  |  Branch (563:5): [True: 155k, False: 0]
  ------------------
  564|   155k|}
TIFFInitCCITTFax3:
 1607|     63|{
 1608|     63|    (void)scheme;
 1609|     63|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1609:9): [True: 63, False: 0]
  ------------------
 1610|     63|    {
 1611|       |        /*
 1612|       |         * Merge codec-specific tag information.
 1613|       |         */
 1614|     63|        if (!_TIFFMergeFields(tif, fax3Fields, TIFFArrayCount(fax3Fields)))
  ------------------
  |  |  339|     63|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1614:13): [True: 0, False: 63]
  ------------------
 1615|      0|        {
 1616|      0|            TIFFErrorExtR(tif, "TIFFInitCCITTFax3",
 1617|      0|                          "Merging CCITT Fax 3 codec-specific tags failed");
 1618|      0|            return 0;
 1619|      0|        }
 1620|       |
 1621|       |        /*
 1622|       |         * The default format is Class/F-style w/o RTC.
 1623|       |         */
 1624|     63|        return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
  ------------------
  |  |  697|     63|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
                      return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
  ------------------
  |  |  703|     63|#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */
  |  |  ------------------
  |  |  |  |  699|     63|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  |  |  ------------------
  ------------------
 1625|     63|    }
 1626|      0|    else
 1627|      0|        return 01;
 1628|     63|}
TIFFInitCCITTFax4:
 1762|     19|{
 1763|     19|    (void)scheme;
 1764|     19|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1764:9): [True: 19, False: 0]
  ------------------
 1765|     19|    { /* reuse G3 support */
 1766|       |        /*
 1767|       |         * Merge codec-specific tag information.
 1768|       |         */
 1769|     19|        if (!_TIFFMergeFields(tif, fax4Fields, TIFFArrayCount(fax4Fields)))
  ------------------
  |  |  339|     19|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1769:13): [True: 0, False: 19]
  ------------------
 1770|      0|        {
 1771|      0|            TIFFErrorExtR(tif, "TIFFInitCCITTFax4",
 1772|      0|                          "Merging CCITT Fax 4 codec-specific tags failed");
 1773|      0|            return 0;
 1774|      0|        }
 1775|       |
 1776|     19|        tif->tif_decoderow = Fax4Decode;
 1777|     19|        tif->tif_decodestrip = Fax4Decode;
 1778|     19|        tif->tif_decodetile = Fax4Decode;
 1779|     19|        tif->tif_encoderow = Fax4Encode;
 1780|     19|        tif->tif_encodestrip = Fax4Encode;
 1781|     19|        tif->tif_encodetile = Fax4Encode;
 1782|     19|        tif->tif_postencode = Fax4PostEncode;
 1783|     19|        tif->tif_getmaxcompressionratio = Fax4GetMaxCompressionRatio;
 1784|       |        /*
 1785|       |         * Suppress RTC at the end of each strip.
 1786|       |         */
 1787|     19|        return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC);
  ------------------
  |  |  697|     19|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
                      return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC);
  ------------------
  |  |  699|     19|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  ------------------
 1788|     19|    }
 1789|      0|    else
 1790|      0|        return (0);
 1791|     19|}
TIFFInitCCITTRLE:
 1871|     27|{
 1872|     27|    (void)scheme;
 1873|     27|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1873:9): [True: 27, False: 0]
  ------------------
 1874|     27|    { /* reuse G3 support */
 1875|     27|        tif->tif_decoderow = Fax3DecodeRLE;
 1876|     27|        tif->tif_decodestrip = Fax3DecodeRLE;
 1877|     27|        tif->tif_decodetile = Fax3DecodeRLE;
 1878|     27|        tif->tif_getmaxcompressionratio = Fax3RLEGetMaxCompressionRatio;
 1879|       |        /*
 1880|       |         * Suppress RTC+EOLs when encoding and byte-align data.
 1881|       |         */
 1882|     27|        return TIFFSetField(tif, TIFFTAG_FAXMODE,
  ------------------
  |  |  697|     27|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
 1883|     27|                            FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  699|     27|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  700|     27|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  701|     27|#define FAXMODE_BYTEALIGN 0x0004     /* byte align row */
  ------------------
 1884|     27|    }
 1885|      0|    else
 1886|      0|        return (0);
 1887|     27|}
TIFFInitCCITTRLEW:
 1890|      4|{
 1891|      4|    (void)scheme;
 1892|      4|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1892:9): [True: 4, False: 0]
  ------------------
 1893|      4|    { /* reuse G3 support */
 1894|      4|        tif->tif_decoderow = Fax3DecodeRLE;
 1895|      4|        tif->tif_decodestrip = Fax3DecodeRLE;
 1896|      4|        tif->tif_decodetile = Fax3DecodeRLE;
 1897|      4|        tif->tif_getmaxcompressionratio = Fax3RLEGetMaxCompressionRatio;
 1898|       |        /*
 1899|       |         * Suppress RTC+EOLs when encoding and word-align data.
 1900|       |         */
 1901|      4|        return TIFFSetField(tif, TIFFTAG_FAXMODE,
  ------------------
  |  |  697|      4|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
 1902|      4|                            FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_WORDALIGN);
  ------------------
  |  |  699|      4|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_WORDALIGN);
  ------------------
  |  |  700|      4|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_WORDALIGN);
  ------------------
  |  |  702|      4|#define FAXMODE_WORDALIGN 0x0008     /* word align row */
  ------------------
 1903|      4|    }
 1904|      0|    else
 1905|      0|        return (0);
 1906|      4|}
tif_fax3.c:InitCCITTFax3:
 1538|    113|{
 1539|    113|    static const char module[] = "InitCCITTFax3";
 1540|    113|    Fax3BaseState *sp;
 1541|       |
 1542|       |    /*
 1543|       |     * Merge codec-specific tag information.
 1544|       |     */
 1545|    113|    if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields)))
  ------------------
  |  |  339|    113|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1545:9): [True: 0, False: 113]
  ------------------
 1546|      0|    {
 1547|      0|        TIFFErrorExtR(tif, "InitCCITTFax3",
 1548|      0|                      "Merging common CCITT Fax codec-specific tags failed");
 1549|      0|        return 0;
 1550|      0|    }
 1551|       |
 1552|       |    /*
 1553|       |     * Allocate state block so tag methods have storage to record values.
 1554|       |     */
 1555|    113|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(Fax3CodecState));
 1556|       |
 1557|    113|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1557:9): [True: 0, False: 113]
  ------------------
 1558|      0|    {
 1559|      0|        TIFFErrorExtR(tif, module, "No space for state block");
 1560|      0|        return (0);
 1561|      0|    }
 1562|    113|    _TIFFmemset(tif->tif_data, 0, sizeof(Fax3CodecState));
 1563|       |
 1564|    113|    sp = Fax3State(tif);
  ------------------
  |  |   72|    113|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1565|    113|    sp->rw_mode = tif->tif_mode;
 1566|       |
 1567|       |    /*
 1568|       |     * Override parent get/set field methods.
 1569|       |     */
 1570|    113|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1571|    113|    tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */
 1572|    113|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1573|    113|    tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */
 1574|    113|    sp->printdir = tif->tif_tagmethods.printdir;
 1575|    113|    tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */
 1576|    113|    sp->groupoptions = 0;
 1577|       |
 1578|    113|    if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */
  ------------------
  |  Branch (1578:9): [True: 113, False: 0]
  ------------------
 1579|    113|        tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */
  ------------------
  |  |  127|    113|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 1580|    113|    DecoderState(tif)->runs = NULL;
  ------------------
  |  |  108|    113|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|    113|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1581|    113|    TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
  ------------------
  |  |  713|    113|#define TIFFTAG_FAXFILLFUNC 65540     /* G3/G4 fill function */
  ------------------
 1582|    113|    EncoderState(tif)->refline = NULL;
  ------------------
  |  |  109|    113|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|    113|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |    /*
 1585|       |     * Install codec methods.
 1586|       |     */
 1587|    113|    tif->tif_fixuptags = Fax3FixupTags;
 1588|    113|    tif->tif_setupdecode = Fax3SetupState;
 1589|    113|    tif->tif_predecode = Fax3PreDecode;
 1590|    113|    tif->tif_decoderow = Fax3Decode1D;
 1591|    113|    tif->tif_decodestrip = Fax3Decode1D;
 1592|    113|    tif->tif_decodetile = Fax3Decode1D;
 1593|    113|    tif->tif_setupencode = Fax3SetupState;
 1594|    113|    tif->tif_preencode = Fax3PreEncode;
 1595|    113|    tif->tif_postencode = Fax3PostEncode;
 1596|    113|    tif->tif_encoderow = Fax3Encode;
 1597|    113|    tif->tif_encodestrip = Fax3Encode;
 1598|    113|    tif->tif_encodetile = Fax3Encode;
 1599|    113|    tif->tif_close = Fax3Close;
 1600|    113|    tif->tif_cleanup = Fax3Cleanup;
 1601|    113|    tif->tif_getmaxcompressionratio = Fax3GetMaxCompressionRatio;
 1602|       |
 1603|    113|    return (1);
 1604|    113|}
tif_fax3.c:Fax3VGetField:
 1424|    818|{
 1425|    818|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|    818|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1426|       |
 1427|    818|    assert(sp != 0);
  ------------------
  |  Branch (1427:5): [True: 0, False: 818]
  |  Branch (1427:5): [True: 818, False: 0]
  ------------------
 1428|       |
 1429|    818|    switch (tag)
 1430|    818|    {
 1431|      0|        case TIFFTAG_FAXMODE:
  ------------------
  |  |  697|      0|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
  |  Branch (1431:9): [True: 0, False: 818]
  ------------------
 1432|      0|            *va_arg(ap, int *) = sp->mode;
 1433|      0|            break;
 1434|      0|        case TIFFTAG_FAXFILLFUNC:
  ------------------
  |  |  713|      0|#define TIFFTAG_FAXFILLFUNC 65540     /* G3/G4 fill function */
  ------------------
  |  Branch (1434:9): [True: 0, False: 818]
  ------------------
 1435|      0|            *va_arg(ap, TIFFFaxFillFunc *) = DecoderState(tif)->fill;
  ------------------
  |  |  108|      0|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|      0|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1436|      0|            break;
 1437|      0|        case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|      0|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1437:9): [True: 0, False: 818]
  ------------------
 1438|      0|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|      0|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1438:9): [True: 0, False: 818]
  ------------------
 1439|      0|            *va_arg(ap, uint32_t *) = sp->groupoptions;
 1440|      0|            break;
 1441|      0|        case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|      0|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1441:9): [True: 0, False: 818]
  ------------------
 1442|      0|            *va_arg(ap, uint32_t *) = sp->badfaxlines;
 1443|      0|            break;
 1444|      0|        case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|      0|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1444:9): [True: 0, False: 818]
  ------------------
 1445|      0|            *va_arg(ap, uint16_t *) = sp->cleanfaxdata;
 1446|      0|            break;
 1447|      0|        case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|      0|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1447:9): [True: 0, False: 818]
  ------------------
 1448|      0|            *va_arg(ap, uint32_t *) = sp->badfaxrun;
 1449|      0|            break;
 1450|    818|        default:
  ------------------
  |  Branch (1450:9): [True: 818, False: 0]
  ------------------
 1451|    818|            return (*sp->vgetparent)(tif, tag, ap);
 1452|    818|    }
 1453|      0|    return (1);
 1454|    818|}
tif_fax3.c:Fax3VSetField:
 1376|  1.07k|{
 1377|  1.07k|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|  1.07k|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1378|  1.07k|    const TIFFField *fip;
 1379|       |
 1380|  1.07k|    assert(sp != 0);
  ------------------
  |  Branch (1380:5): [True: 0, False: 1.07k]
  |  Branch (1380:5): [True: 1.07k, False: 0]
  ------------------
 1381|  1.07k|    assert(sp->vsetparent != 0);
  ------------------
  |  Branch (1381:5): [True: 0, False: 1.07k]
  |  Branch (1381:5): [True: 1.07k, False: 0]
  ------------------
 1382|       |
 1383|  1.07k|    switch (tag)
 1384|  1.07k|    {
 1385|    113|        case TIFFTAG_FAXMODE:
  ------------------
  |  |  697|    113|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
  |  Branch (1385:9): [True: 113, False: 957]
  ------------------
 1386|    113|            sp->mode = (int)va_arg(ap, int);
 1387|    113|            return 1; /* NB: pseudo tag */
 1388|    113|        case TIFFTAG_FAXFILLFUNC:
  ------------------
  |  |  713|    113|#define TIFFTAG_FAXFILLFUNC 65540     /* G3/G4 fill function */
  ------------------
  |  Branch (1388:9): [True: 113, False: 957]
  ------------------
 1389|    113|            DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
  ------------------
  |  |  108|    113|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|    113|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1390|    113|            return 1; /* NB: pseudo tag */
 1391|     16|        case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|     16|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1391:9): [True: 16, False: 1.05k]
  ------------------
 1392|       |            /* XXX: avoid reading options if compression mismatches. */
 1393|     16|            if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
  ------------------
  |  |  184|     16|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1393:17): [True: 16, False: 0]
  ------------------
 1394|     16|                sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
 1395|     16|            break;
 1396|     11|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|     11|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1396:9): [True: 11, False: 1.05k]
  ------------------
 1397|       |            /* XXX: avoid reading options if compression mismatches. */
 1398|     11|            if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
  ------------------
  |  |  186|     11|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1398:17): [True: 11, False: 0]
  ------------------
 1399|     11|                sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
 1400|     11|            break;
 1401|      4|        case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|      4|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1401:9): [True: 4, False: 1.06k]
  ------------------
 1402|      4|            sp->badfaxlines = (uint32_t)va_arg(ap, uint32_t);
 1403|      4|            break;
 1404|      4|        case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|      4|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1404:9): [True: 4, False: 1.06k]
  ------------------
 1405|      4|            sp->cleanfaxdata = (uint16_t)va_arg(ap, uint16_vap);
 1406|      4|            break;
 1407|      8|        case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|      8|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1407:9): [True: 8, False: 1.06k]
  ------------------
 1408|      8|            sp->badfaxrun = (uint32_t)va_arg(ap, uint32_t);
 1409|      8|            break;
 1410|    801|        default:
  ------------------
  |  Branch (1410:9): [True: 801, False: 269]
  ------------------
 1411|    801|            return (*sp->vsetparent)(tif, tag, ap);
 1412|  1.07k|    }
 1413|       |
 1414|     43|    if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
  ------------------
  |  Branch (1414:9): [True: 43, False: 0]
  ------------------
 1415|     43|        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|     43|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     43|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     43|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1416|      0|    else
 1417|      0|        return 0;
 1418|       |
 1419|     43|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|     43|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1420|     43|    return 1;
 1421|     43|}
tif_fax3.c:Fax3FixupTags:
  569|    104|{
  570|    104|    (void)tif;
  571|    104|    return (1);
  572|    104|}
tif_fax3.c:Fax3SetupState:
  582|    830|{
  583|    830|    static const char module[] = "Fax3SetupState";
  584|    830|    TIFFDirectory *td = &tif->tif_dir;
  585|    830|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|    830|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
  586|    830|    int needsRefLine;
  587|    830|    Fax3CodecState *dsp = (Fax3CodecState *)Fax3State(tif);
  ------------------
  |  |   72|    830|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
  588|    830|    tmsize_t rowbytes;
  589|    830|    uint32_t rowpixels;
  590|       |
  591|    830|    if (td->td_bitspersample != 1)
  ------------------
  |  Branch (591:9): [True: 761, False: 69]
  ------------------
  592|    761|    {
  593|    761|        TIFFErrorExtR(tif, module,
  594|    761|                      "Bits/sample must be 1 for Group 3/4 encoding/decoding");
  595|    761|        return (0);
  596|    761|    }
  597|     69|    if (td->td_samplesperpixel != 1 &&
  ------------------
  |  Branch (597:9): [True: 7, False: 62]
  ------------------
  598|      7|        td->td_planarconfig != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|      7|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (598:9): [True: 0, False: 7]
  ------------------
  599|      0|    {
  600|      0|        TIFFErrorExtR(
  601|      0|            tif, module,
  602|      0|            "Samples/pixel shall be 1 for Group 3/4 encoding/decoding, "
  603|      0|            "or PlanarConfiguration must be set to Separate.");
  604|      0|        return 0;
  605|      0|    }
  606|       |    /*
  607|       |     * Calculate the scanline/tile widths.
  608|       |     */
  609|     69|    if (isTiled(tif))
  ------------------
  |  |  278|     69|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     69|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 12, False: 57]
  |  |  ------------------
  ------------------
  610|     12|    {
  611|     12|        rowbytes = TIFFTileRowSize(tif);
  612|     12|        rowpixels = td->td_tilewidth;
  613|     12|    }
  614|     57|    else
  615|     57|    {
  616|     57|        rowbytes = TIFFScanlineSize(tif);
  617|     57|        rowpixels = td->td_imagewidth;
  618|     57|    }
  619|     69|    if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8)
  ------------------
  |  Branch (619:9): [True: 0, False: 69]
  ------------------
  620|      0|    {
  621|      0|        TIFFErrorExtR(tif, module,
  622|      0|                      "Inconsistent number of bytes per row : rowbytes=%" PRId64
  623|      0|                      " rowpixels=%" PRIu32,
  624|      0|                      (int64_t)rowbytes, rowpixels);
  625|      0|        return (0);
  626|      0|    }
  627|     69|    sp->rowbytes = rowbytes;
  628|     69|    sp->rowpixels = rowpixels;
  629|       |    /*
  630|       |     * Allocate any additional space required for decoding/encoding.
  631|       |     */
  632|     69|    needsRefLine = ((sp->groupoptions & GROUP3OPT_2DENCODING) ||
  ------------------
  |  |  281|     69|#define GROUP3OPT_2DENCODING 0x1           /* 2-dimensional coding */
  ------------------
  |  Branch (632:21): [True: 7, False: 62]
  ------------------
  633|     62|                    td->td_compression == COMPRESSION_CCITTFAX4);
  ------------------
  |  |  186|     62|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (633:21): [True: 13, False: 49]
  ------------------
  634|       |
  635|       |    /*
  636|       |      Assure that allocation computations do not overflow.
  637|       |
  638|       |      TIFFroundup and TIFFSafeMultiply return zero on integer overflow
  639|       |    */
  640|     69|    if (dsp->runs != NULL)
  ------------------
  |  Branch (640:9): [True: 0, False: 69]
  ------------------
  641|      0|    {
  642|      0|        _TIFFfreeExt(tif, dsp->runs);
  643|      0|        dsp->runs = (uint32_t *)NULL;
  644|      0|    }
  645|     69|    dsp->nruns = TIFFroundup_32(rowpixels + 1, 32);
  ------------------
  |  |  322|     69|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|     69|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  313|     69|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|     69|         : 0U)
  |  |  ------------------
  ------------------
  646|     69|    if (needsRefLine)
  ------------------
  |  Branch (646:9): [True: 20, False: 49]
  ------------------
  647|     20|    {
  648|     20|        dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2);
  ------------------
  |  |  332|     20|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 20, Folded]
  |  |  |  Branch (332:27): [True: 20, False: 0]
  |  |  ------------------
  |  |  333|     20|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     20|         : (t)0)
  ------------------
  649|     20|    }
  650|     69|    if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0))
  ------------------
  |  |  332|     69|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 69, Folded]
  |  |  |  Branch (332:27): [True: 69, False: 0]
  |  |  ------------------
  |  |  333|     69|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     69|         : (t)0)
  ------------------
  |  Branch (650:9): [True: 0, False: 69]
  |  Branch (650:30): [True: 0, False: 69]
  ------------------
  651|      0|    {
  652|      0|        TIFFErrorExtR(tif, tif->tif_name,
  653|      0|                      "Row pixels integer overflow (rowpixels %" PRIu32 ")",
  654|      0|                      rowpixels);
  655|      0|        return (0);
  656|      0|    }
  657|     69|    dsp->runs = (uint32_t *)_TIFFCheckMalloc(
  658|     69|        tif, TIFFSafeMultiply(uint32_t, dsp->nruns, 2), sizeof(uint32_t),
  ------------------
  |  |  332|     69|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 69, Folded]
  |  |  |  Branch (332:27): [True: 69, False: 0]
  |  |  ------------------
  |  |  333|     69|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     69|         : (t)0)
  ------------------
  659|     69|        "for Group 3/4 run arrays");
  660|     69|    if (dsp->runs == NULL)
  ------------------
  |  Branch (660:9): [True: 0, False: 69]
  ------------------
  661|      0|        return (0);
  662|     69|    memset(dsp->runs, 0,
  663|     69|           TIFFSafeMultiply(uint32_t, dsp->nruns, 2) * sizeof(uint32_t));
  ------------------
  |  |  332|     69|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 69, Folded]
  |  |  |  Branch (332:27): [True: 69, False: 0]
  |  |  ------------------
  |  |  333|     69|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     69|         : (t)0)
  ------------------
  664|     69|    dsp->curruns = dsp->runs;
  665|     69|    if (needsRefLine)
  ------------------
  |  Branch (665:9): [True: 20, False: 49]
  ------------------
  666|     20|        dsp->refruns = dsp->runs + dsp->nruns;
  667|     49|    else
  668|     49|        dsp->refruns = NULL;
  669|     69|    if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp))
  ------------------
  |  |  184|    138|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
                  if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp))
  ------------------
  |  |  111|     38|#define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING)
  |  |  ------------------
  |  |  |  |  281|     38|#define GROUP3OPT_2DENCODING 0x1           /* 2-dimensional coding */
  |  |  ------------------
  |  |  |  Branch (111:26): [True: 7, False: 31]
  |  |  ------------------
  ------------------
  |  Branch (669:9): [True: 38, False: 31]
  ------------------
  670|      7|    { /* NB: default is 1D routine */
  671|      7|        tif->tif_decoderow = Fax3Decode2D;
  672|      7|        tif->tif_decodestrip = Fax3Decode2D;
  673|      7|        tif->tif_decodetile = Fax3Decode2D;
  674|      7|    }
  675|       |
  676|     69|    if (needsRefLine)
  ------------------
  |  Branch (676:9): [True: 20, False: 49]
  ------------------
  677|     20|    { /* 2d encoding */
  678|     20|        Fax3CodecState *esp = EncoderState(tif);
  ------------------
  |  |  109|     20|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     20|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  679|       |        /*
  680|       |         * 2d encoding requires a scanline
  681|       |         * buffer for the ``reference line''; the
  682|       |         * scanline against which delta encoding
  683|       |         * is referenced.  The reference line must
  684|       |         * be initialized to be ``white'' (done elsewhere).
  685|       |         */
  686|     20|        if (esp->refline != NULL)
  ------------------
  |  Branch (686:13): [True: 0, False: 20]
  ------------------
  687|      0|        {
  688|      0|            _TIFFfreeExt(tif, esp->refline);
  689|      0|        }
  690|     20|        esp->refline = (unsigned char *)_TIFFmallocExt(tif, rowbytes);
  691|     20|        if (esp->refline == NULL)
  ------------------
  |  Branch (691:13): [True: 0, False: 20]
  ------------------
  692|      0|        {
  693|      0|            TIFFErrorExtR(tif, module, "No space for Group 3/4 reference line");
  694|      0|            return (0);
  695|      0|        }
  696|     20|    }
  697|     49|    else /* 1d encoding */
  698|     49|        EncoderState(tif)->refline = NULL;
  ------------------
  |  |  109|     49|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     49|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  699|       |
  700|     69|    return (1);
  701|     69|}
tif_fax3.c:Fax3Decode2D:
  385|      9|{
  386|      9|    DECLARE_STATE_2D(tif, sp, "Fax3Decode2D");
  ------------------
  |  |  139|      9|    DECLARE_STATE(tif, sp, mod);                                               \
  |  |  ------------------
  |  |  |  |  123|      9|    static const char module[] = mod;                                          \
  |  |  |  |  124|      9|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  108|      9|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   72|      9|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  125|      9|    int a0;                                   /* reference element */          \
  |  |  |  |  126|      9|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  |  |  127|      9|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  |  |  128|      9|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  |  |  129|      9|    int RunLength;                            /* length of current run */      \
  |  |  |  |  130|      9|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  |  |  131|      9|    unsigned char *ep;                        /* end of input data */          \
  |  |  |  |  132|      9|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  |  |  133|      9|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  |  |  134|      9|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  |  |  135|      9|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  |  |  136|      9|    const TIFFFaxTabEnt *TabEnt
  |  |  ------------------
  |  |  140|      9|    int b1; /* next change on prev line */                                     \
  |  |  141|      9|    uint32_t                                                                   \
  |  |  142|      9|        *pb /* next run in reference line */ /*                                \
  ------------------
  387|      9|    int is1D; /* current line is 1d/2d-encoded */
  388|      9|    (void)s;
  389|      9|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (389:9): [True: 0, False: 9]
  ------------------
  390|      0|    {
  391|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  392|      0|        return (-1);
  393|      0|    }
  394|      9|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (394:9): [True: 0, False: 9]
  ------------------
  395|      0|        return (-1);
  396|     16|RETRY_WITHOUT_EOL_2D:
  397|     16|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|     16|    do                                                                         \
  |  |  148|     16|    {                                                                          \
  |  |  149|     16|        BitAcc = sp->data;                                                     \
  |  |  150|     16|        BitsAvail = sp->bit;                                                   \
  |  |  151|     16|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|     16|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|     16|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|     16|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 16]
  |  |  ------------------
  ------------------
  398|  7.21k|    while (occ > 0)
  ------------------
  |  Branch (398:12): [True: 7.21k, False: 2]
  ------------------
  399|  7.21k|    {
  400|  7.21k|        a0 = 0;
  401|  7.21k|        RunLength = 0;
  402|  7.21k|        pa = thisrun = sp->curruns;
  403|       |#ifdef FAX3_DEBUG
  404|       |        printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d EOLcnt = %d", BitAcc,
  405|       |               BitsAvail, EOLcnt);
  406|       |#endif
  407|  7.21k|        SYNC_EOL(EOF2D, RETRY_WITHOUT_EOL_2D);
  ------------------
  |  |  293|  7.21k|    do                                                                         \
  |  |  294|  7.21k|    {                                                                          \
  |  |  295|  7.21k|        if (!(sp->b.mode & FAXMODE_NOEOL)) /* skip EOL, if not present */      \
  |  |  ------------------
  |  |  |  |  700|  7.21k|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  |  Branch (295:13): [True: 670, False: 6.54k]
  |  |  ------------------
  |  |  296|  7.21k|        {                                                                      \
  |  |  297|    670|            if (EOLcnt == 0)                                                   \
  |  |  ------------------
  |  |  |  Branch (297:17): [True: 349, False: 321]
  |  |  ------------------
  |  |  298|    670|            {                                                                  \
  |  |  299|    349|                for (;;)                                                       \
  |  |  300|  33.5k|                {                                                              \
  |  |  301|  33.5k|                    NeedBits16(11, eoflab);                                    \
  |  |  ------------------
  |  |  |  |  164|  33.5k|    do                                                                         \
  |  |  |  |  165|  33.5k|    {                                                                          \
  |  |  |  |  166|  33.5k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:13): [True: 4.41k, False: 29.1k]
  |  |  |  |  ------------------
  |  |  |  |  167|  33.5k|        {                                                                      \
  |  |  |  |  168|  4.41k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  4.41k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 20, False: 4.39k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  169|  4.41k|            {                                                                  \
  |  |  |  |  170|     20|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (170:21): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  171|     20|                    goto eoflab;                                               \
  |  |  |  |  172|     20|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  173|     20|            }                                                                  \
  |  |  |  |  174|  4.41k|            else                                                               \
  |  |  |  |  175|  4.41k|            {                                                                  \
  |  |  |  |  176|  4.39k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  177|  4.39k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:21): [True: 49, False: 4.34k]
  |  |  |  |  ------------------
  |  |  |  |  178|  4.39k|                {                                                              \
  |  |  |  |  179|     49|                    if (EndOfData())                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|     49|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 4, False: 45]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  180|     49|                    {                                                          \
  |  |  |  |  181|      4|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  182|      4|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  183|      4|                    }                                                          \
  |  |  |  |  184|     49|                    else                                                       \
  |  |  |  |  185|     49|                    {                                                          \
  |  |  |  |  186|     45|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  187|     45|                        BitsAvail += 8;                                        \
  |  |  |  |  188|     45|                    }                                                          \
  |  |  |  |  189|     49|                }                                                              \
  |  |  |  |  190|  4.39k|            }                                                                  \
  |  |  |  |  191|  4.41k|        }                                                                      \
  |  |  |  |  192|  33.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:14): [Folded, False: 33.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  302|  33.5k|                    if (GetBits(11) == 0)                                      \
  |  |  ------------------
  |  |  |  |  194|  33.5k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (302:25): [True: 349, False: 33.2k]
  |  |  ------------------
  |  |  303|  33.5k|                        break; /* EOL found */                                 \
  |  |  304|  33.5k|                    ClrBits(1);                                                \
  |  |  ------------------
  |  |  |  |  196|  33.2k|    do                                                                         \
  |  |  |  |  197|  33.2k|    {                                                                          \
  |  |  |  |  198|  33.2k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  33.2k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  33.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 33.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  305|  33.2k|                }                                                              \
  |  |  306|    349|            }                                                                  \
  |  |  307|    670|            /* Now move after EOL or detect missing EOL. */                    \
  |  |  308|    670|            for (;;)                                                           \
  |  |  309|  2.15k|            {                                                                  \
  |  |  310|  2.15k|                NeedBits8(8, noEOLFound);                                      \
  |  |  ------------------
  |  |  |  |  144|  2.15k|    do                                                                         \
  |  |  |  |  145|  2.15k|    {                                                                          \
  |  |  |  |  146|  2.15k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 1.55k, False: 591]
  |  |  |  |  ------------------
  |  |  |  |  147|  2.15k|        {                                                                      \
  |  |  |  |  148|  1.55k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  1.55k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 14, False: 1.54k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  1.55k|            {                                                                  \
  |  |  |  |  150|     14|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 7, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  151|     14|                    goto eoflab;                                               \
  |  |  |  |  152|     14|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      7|            }                                                                  \
  |  |  |  |  154|  1.55k|            else                                                               \
  |  |  |  |  155|  1.55k|            {                                                                  \
  |  |  |  |  156|  1.54k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  1.54k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  1.54k|            }                                                                  \
  |  |  |  |  159|  1.55k|        }                                                                      \
  |  |  |  |  160|  2.15k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 2.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  311|  2.15k|                if (GetBits(8))                                                \
  |  |  ------------------
  |  |  |  |  194|  2.14k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 663, False: 1.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  312|  2.14k|                    break;                                                     \
  |  |  313|  2.14k|                ClrBits(8);                                                    \
  |  |  ------------------
  |  |  |  |  196|  1.48k|    do                                                                         \
  |  |  |  |  197|  1.48k|    {                                                                          \
  |  |  |  |  198|  1.48k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  1.48k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  1.48k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 1.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  314|  1.48k|            }                                                                  \
  |  |  315|  3.15k|            while (GetBits(1) == 0)                                            \
  |  |  ------------------
  |  |  |  |  194|  3.15k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (315:20): [True: 2.49k, False: 663]
  |  |  ------------------
  |  |  316|  2.49k|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|  3.15k|    do                                                                         \
  |  |  |  |  197|  3.15k|    {                                                                          \
  |  |  |  |  198|  2.49k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  2.49k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  2.49k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 2.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  317|    663|            ClrBits(1); /* EOL bit */                                          \
  |  |  ------------------
  |  |  |  |  196|    663|    do                                                                         \
  |  |  |  |  197|    663|    {                                                                          \
  |  |  |  |  198|    663|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|    663|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|    663|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 663]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  318|    663|            EOLcnt = 0; /* reset EOL counter/flag */                           \
  |  |  319|    663|            break;      /* existing EOL skipped, leave macro */                \
  |  |  320|    670|        noEOLFound:                                                            \
  |  |  321|      7|            sp->b.mode |= FAXMODE_NOEOL;                                       \
  |  |  ------------------
  |  |  |  |  700|      7|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  322|      7|            tryG3WithoutEOL(a0);                                               \
  |  |  ------------------
  |  |  |  |  289|      7|    do                                                                         \
  |  |  |  |  290|      7|    {                                                                          \
  |  |  |  |  291|      7|        Fax3TryG3WithoutEOL(module, tif, (uint32_t)sp->line, (uint32_t)(a0));  \
  |  |  |  |  292|      7|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:14): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  323|      7|            goto retrywithouteol;                                              \
  |  |  324|    670|        }                                                                      \
  |  |  325|  7.21k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (325:14): [Folded, False: 6.54k]
  |  |  ------------------
  ------------------
  408|  7.21k|        NeedBits8(1, EOF2D);
  ------------------
  |  |  144|  7.21k|    do                                                                         \
  |  |  145|  7.21k|    {                                                                          \
  |  |  146|  7.21k|        if (BitsAvail < (n))                                                   \
  |  |  ------------------
  |  |  |  Branch (146:13): [True: 574, False: 6.63k]
  |  |  ------------------
  |  |  147|  7.21k|        {                                                                      \
  |  |  148|    574|            if (EndOfData())                                                   \
  |  |  ------------------
  |  |  |  |  117|    574|#define EndOfData() (cp >= ep)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (117:21): [True: 0, False: 574]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  149|    574|            {                                                                  \
  |  |  150|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  ------------------
  |  |  |  Branch (150:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  151|      0|                    goto eoflab;                                               \
  |  |  152|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  153|      0|            }                                                                  \
  |  |  154|    574|            else                                                               \
  |  |  155|    574|            {                                                                  \
  |  |  156|    574|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  157|    574|                BitsAvail += 8;                                                \
  |  |  158|    574|            }                                                                  \
  |  |  159|    574|        }                                                                      \
  |  |  160|  7.21k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (160:14): [Folded, False: 7.21k]
  |  |  ------------------
  ------------------
  409|  7.21k|        is1D = GetBits(1); /* 1D/2D-encoding tag bit */
  ------------------
  |  |  194|  7.21k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  ------------------
  410|  7.21k|        ClrBits(1);
  ------------------
  |  |  196|  7.21k|    do                                                                         \
  |  |  197|  7.21k|    {                                                                          \
  |  |  198|  7.21k|        BitsAvail -= (n);                                                      \
  |  |  199|  7.21k|        BitAcc >>= (n);                                                        \
  |  |  200|  7.21k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 7.21k]
  |  |  ------------------
  ------------------
  411|       |#ifdef FAX3_DEBUG
  412|       |        printf(" %s\n-------------------- %" PRIu32 "\n", is1D ? "1D" : "2D",
  413|       |               tif->tif_dir.td_row);
  414|       |        fflush(stdout);
  415|       |#endif
  416|  7.21k|        pb = sp->refruns;
  417|  7.21k|        b1 = (int)*pb++;
  418|  7.21k|        if (is1D)
  ------------------
  |  Branch (418:13): [True: 2.94k, False: 4.26k]
  ------------------
  419|  2.94k|            EXPAND1D(EOF2Da);
  ------------------
  |  |  371|  2.94k|    do                                                                         \
  |  |  372|  2.94k|    {                                                                          \
  |  |  373|  2.94k|        for (;;)                                                               \
  |  |  374|  3.48k|        {                                                                      \
  |  |  375|  3.48k|            for (;;)                                                           \
  |  |  376|  5.05k|            {                                                                  \
  |  |  377|  5.05k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  5.05k|    do                                                                         \
  |  |  |  |  255|  5.05k|    {                                                                          \
  |  |  |  |  256|  5.05k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  5.05k|    do                                                                         \
  |  |  |  |  |  |  165|  5.05k|    {                                                                          \
  |  |  |  |  |  |  166|  5.05k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 4.10k, False: 948]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  5.05k|        {                                                                      \
  |  |  |  |  |  |  168|  4.10k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  4.10k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 4.10k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  4.10k|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|  4.10k|            else                                                               \
  |  |  |  |  |  |  175|  4.10k|            {                                                                  \
  |  |  |  |  |  |  176|  4.10k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  4.10k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 244, False: 3.86k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  4.10k|                {                                                              \
  |  |  |  |  |  |  179|    244|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    244|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 244]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|    244|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|    244|                    else                                                       \
  |  |  |  |  |  |  185|    244|                    {                                                          \
  |  |  |  |  |  |  186|    244|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|    244|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|    244|                    }                                                          \
  |  |  |  |  |  |  189|    244|                }                                                              \
  |  |  |  |  |  |  190|  4.10k|            }                                                                  \
  |  |  |  |  |  |  191|  4.10k|        }                                                                      \
  |  |  |  |  |  |  192|  5.05k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 5.05k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  5.05k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  5.05k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  5.05k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  5.05k|    do                                                                         \
  |  |  |  |  |  |  197|  5.05k|    {                                                                          \
  |  |  |  |  |  |  198|  5.05k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  5.05k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  5.05k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 5.05k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  5.05k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 5.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|  5.05k|                switch (TabEnt->State)                                         \
  |  |  379|  5.05k|                {                                                              \
  |  |  380|    137|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    137|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 137, False: 4.91k]
  |  |  ------------------
  |  |  381|    137|                        EOLcnt = 1;                                            \
  |  |  382|    137|                        goto done1d;                                           \
  |  |  383|  3.30k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  3.30k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 3.30k, False: 1.75k]
  |  |  ------------------
  |  |  384|  3.30k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  3.30k|    do                                                                         \
  |  |  |  |  267|  3.30k|    {                                                                          \
  |  |  |  |  268|  3.30k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 3.30k]
  |  |  |  |  ------------------
  |  |  |  |  269|  3.30k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  3.30k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  3.30k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  3.30k|        RunLength = 0;                                                         \
  |  |  |  |  279|  3.30k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 3.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  3.30k|                        goto doneWhite1d;                                      \
  |  |  386|  3.30k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|  1.52k|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 1.52k, False: 3.52k]
  |  |  ------------------
  |  |  387|  1.56k|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|  1.56k|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 45, False: 5.00k]
  |  |  ------------------
  |  |  388|  1.56k|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|  1.56k|                        RunLength =                                            \
  |  |  390|  1.56k|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|  1.56k|                        break;                                                 \
  |  |  392|  1.52k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 45, False: 5.00k]
  |  |  ------------------
  |  |  393|     45|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|     45|    do                                                                         \
  |  |  |  |  221|     45|    {                                                                          \
  |  |  |  |  222|     45|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     45|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     45|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|     45|                        goto done1d;                                           \
  |  |  395|  5.05k|                }                                                              \
  |  |  396|  5.05k|            }                                                                  \
  |  |  397|  3.48k|        doneWhite1d:                                                           \
  |  |  398|  3.30k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 2.65k, False: 643]
  |  |  ------------------
  |  |  399|  3.30k|                goto done1d;                                                   \
  |  |  400|  3.30k|            for (;;)                                                           \
  |  |  401|    664|            {                                                                  \
  |  |  402|    664|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|    664|    do                                                                         \
  |  |  |  |  255|    664|    {                                                                          \
  |  |  |  |  256|    664|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    664|    do                                                                         \
  |  |  |  |  |  |  165|    664|    {                                                                          \
  |  |  |  |  |  |  166|    664|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 412, False: 252]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    664|        {                                                                      \
  |  |  |  |  |  |  168|    412|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    412|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 412]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    412|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|    412|            else                                                               \
  |  |  |  |  |  |  175|    412|            {                                                                  \
  |  |  |  |  |  |  176|    412|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    412|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 6, False: 406]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    412|                {                                                              \
  |  |  |  |  |  |  179|      6|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      6|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 6]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      6|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      6|                    else                                                       \
  |  |  |  |  |  |  185|      6|                    {                                                          \
  |  |  |  |  |  |  186|      6|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      6|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      6|                    }                                                          \
  |  |  |  |  |  |  189|      6|                }                                                              \
  |  |  |  |  |  |  190|    412|            }                                                                  \
  |  |  |  |  |  |  191|    412|        }                                                                      \
  |  |  |  |  |  |  192|    664|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 664]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    664|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    664|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    664|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    664|    do                                                                         \
  |  |  |  |  |  |  197|    664|    {                                                                          \
  |  |  |  |  |  |  198|    664|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    664|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    664|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 664]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    664|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 664]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|    664|                switch (TabEnt->State)                                         \
  |  |  404|    664|                {                                                              \
  |  |  405|     29|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|     29|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 29, False: 635]
  |  |  ------------------
  |  |  406|     29|                        EOLcnt = 1;                                            \
  |  |  407|     29|                        goto done1d;                                           \
  |  |  408|    600|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|    600|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 600, False: 64]
  |  |  ------------------
  |  |  409|    600|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|    600|    do                                                                         \
  |  |  |  |  267|    600|    {                                                                          \
  |  |  |  |  268|    600|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 600]
  |  |  |  |  ------------------
  |  |  |  |  269|    600|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    600|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    600|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    600|        RunLength = 0;                                                         \
  |  |  |  |  279|    600|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 600]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|    600|                        goto doneBlack1d;                                      \
  |  |  411|    600|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 0, False: 664]
  |  |  ------------------
  |  |  412|     21|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|     21|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 21, False: 643]
  |  |  ------------------
  |  |  413|     21|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|     21|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|     21|                        break;                                                 \
  |  |  416|     14|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 14, False: 650]
  |  |  ------------------
  |  |  417|     14|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|     14|    do                                                                         \
  |  |  |  |  221|     14|    {                                                                          \
  |  |  |  |  222|     14|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     14|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     14|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|     14|                        goto done1d;                                           \
  |  |  419|    664|                }                                                              \
  |  |  420|    664|            }                                                                  \
  |  |  421|    643|        doneBlack1d:                                                           \
  |  |  422|    600|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 64, False: 536]
  |  |  ------------------
  |  |  423|    600|                goto done1d;                                                   \
  |  |  424|    600|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 536]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|    536|                pa -= 2;                                                       \
  |  |  426|    536|        }                                                                      \
  |  |  427|  2.94k|    eof1d:                                                                     \
  |  |  428|      0|        prematureEOF(a0);                                                      \
  |  |  ------------------
  |  |  |  |  271|      0|    do                                                                         \
  |  |  |  |  272|      0|    {                                                                          \
  |  |  |  |  273|      0|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|      0|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  429|      0|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|      0|    do                                                                         \
  |  |  |  |  334|      0|    {                                                                          \
  |  |  |  |  335|      0|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  336|      0|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|      0|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|      0|        {                                                                      \
  |  |  |  |  339|      0|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|      0|    do                                                                         \
  |  |  |  |  |  |  254|      0|    {                                                                          \
  |  |  |  |  |  |  255|      0|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|      0|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|      0|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|      0|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|      0|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|      0|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|      0|            {                                                                  \
  |  |  |  |  344|      0|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  345|      0|                    a0 = 0;                                                    \
  |  |  |  |  346|      0|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  347|      0|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|      0|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|      0|            }                                                                  \
  |  |  |  |  350|      0|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|      0|        }                                                                      \
  |  |  |  |  356|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|      0|        goto eoflab;                                                           \
  |  |  431|  2.94k|    done1d:                                                                    \
  |  |  432|  2.94k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  2.94k|    do                                                                         \
  |  |  |  |  334|  2.94k|    {                                                                          \
  |  |  |  |  335|  2.94k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 40, False: 2.90k]
  |  |  |  |  ------------------
  |  |  |  |  336|  2.94k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     40|    do                                                                         \
  |  |  |  |  |  |  267|     40|    {                                                                          \
  |  |  |  |  |  |  268|     40|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 40]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     40|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|     40|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     40|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     40|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     40|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 40]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  2.94k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 2.91k, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  338|  2.94k|        {                                                                      \
  |  |  |  |  339|  2.91k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  2.91k|    do                                                                         \
  |  |  |  |  |  |  254|  2.91k|    {                                                                          \
  |  |  |  |  |  |  255|  2.91k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  2.91k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  2.91k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  2.91k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 2.91k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  5.65k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 2.73k, False: 2.91k]
  |  |  |  |  |  Branch (340:39): [True: 2.73k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  2.91k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  2.91k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 2.91k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  2.91k|            {                                                                  \
  |  |  |  |  344|  2.91k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 2.91k]
  |  |  |  |  ------------------
  |  |  |  |  345|  2.91k|                    a0 = 0;                                                    \
  |  |  |  |  346|  2.91k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 98, False: 2.82k]
  |  |  |  |  ------------------
  |  |  |  |  347|  2.91k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     98|    do                                                                         \
  |  |  |  |  |  |  267|     98|    {                                                                          \
  |  |  |  |  |  |  268|     98|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 98]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     98|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|     98|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     98|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     98|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     98|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 98]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  2.91k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  2.91k|    do                                                                         \
  |  |  |  |  |  |  267|  2.91k|    {                                                                          \
  |  |  |  |  |  |  268|  2.91k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 2.91k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  2.91k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  2.91k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  2.91k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  2.91k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  2.91k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 2.91k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  2.91k|            }                                                                  \
  |  |  |  |  350|  2.91k|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|  2.91k|        }                                                                      \
  |  |  |  |  356|  2.94k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 2.94k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  2.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
  420|  4.26k|        else
  421|  4.26k|            EXPAND2D(EOF2Da);
  ------------------
  |  |  463|  4.26k|    do                                                                         \
  |  |  464|  4.26k|    {                                                                          \
  |  |  465|  7.15k|        while (a0 < (int)lastx)                                                \
  |  |  ------------------
  |  |  |  Branch (465:16): [True: 5.12k, False: 2.02k]
  |  |  ------------------
  |  |  466|  5.12k|        {                                                                      \
  |  |  467|  5.12k|            if (pa >= thisrun + sp->nruns)                                     \
  |  |  ------------------
  |  |  |  Branch (467:17): [True: 0, False: 5.12k]
  |  |  ------------------
  |  |  468|  5.12k|            {                                                                  \
  |  |  469|      0|                TIFFErrorExtR(tif, module,                                     \
  |  |  470|      0|                              "Buffer overflow at line %d of %s %u", sp->line, \
  |  |  471|      0|                              isTiled(tif) ? "tile" : "strip",                 \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  472|      0|                              isTiled(tif) ? tif->tif_dir.td_curtile           \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  473|      0|                                           : tif->tif_dir.td_curstrip);        \
  |  |  474|      0|                return (-1);                                                   \
  |  |  475|      0|            }                                                                  \
  |  |  476|  5.12k|            LOOKUP8(7, TIFFFaxMainTable, eof2d);                               \
  |  |  ------------------
  |  |  |  |  247|  5.12k|    do                                                                         \
  |  |  |  |  248|  5.12k|    {                                                                          \
  |  |  |  |  249|  5.12k|        NeedBits8(wid, eoflab);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|  5.12k|    do                                                                         \
  |  |  |  |  |  |  145|  5.12k|    {                                                                          \
  |  |  |  |  |  |  146|  5.12k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:13): [True: 2.11k, False: 3.01k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  5.12k|        {                                                                      \
  |  |  |  |  |  |  148|  2.11k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  2.11k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 6, False: 2.10k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.11k|            {                                                                  \
  |  |  |  |  |  |  150|      6|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (150:21): [True: 3, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  151|      6|                    goto eoflab;                                               \
  |  |  |  |  |  |  152|      6|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  153|      3|            }                                                                  \
  |  |  |  |  |  |  154|  2.11k|            else                                                               \
  |  |  |  |  |  |  155|  2.11k|            {                                                                  \
  |  |  |  |  |  |  156|  2.10k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  157|  2.10k|                BitsAvail += 8;                                                \
  |  |  |  |  |  |  158|  2.10k|            }                                                                  \
  |  |  |  |  |  |  159|  2.11k|        }                                                                      \
  |  |  |  |  |  |  160|  5.12k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:14): [Folded, False: 5.12k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  250|  5.12k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  5.12k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  251|  5.12k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  5.12k|    do                                                                         \
  |  |  |  |  |  |  197|  5.12k|    {                                                                          \
  |  |  |  |  |  |  198|  5.12k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  5.12k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  5.12k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 5.12k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  252|  5.12k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (252:14): [Folded, False: 5.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  477|  5.12k|            switch (TabEnt->State)                                             \
  |  |  478|  5.12k|            {                                                                  \
  |  |  479|    253|                case S_Pass:                                                   \
  |  |  ------------------
  |  |  |  |   71|    253|#define S_Pass 1
  |  |  ------------------
  |  |  |  Branch (479:17): [True: 253, False: 4.87k]
  |  |  ------------------
  |  |  480|    253|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|    253|    do                                                                         \
  |  |  |  |  441|    253|    {                                                                          \
  |  |  |  |  442|    253|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 35, False: 218]
  |  |  |  |  ------------------
  |  |  |  |  443|    253|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 17, False: 35]
  |  |  |  |  |  Branch (443:32): [True: 17, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|     35|            {                                                                  \
  |  |  |  |  445|     17|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  446|     17|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|     17|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|     17|                pb += 2;                                                       \
  |  |  |  |  456|     17|            }                                                                  \
  |  |  |  |  457|    253|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 253]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  481|    253|                    if (pb + 1 >= sp->refruns + sp->nruns)                     \
  |  |  ------------------
  |  |  |  Branch (481:25): [True: 0, False: 253]
  |  |  ------------------
  |  |  482|    253|                    {                                                          \
  |  |  483|      0|                        TIFFErrorExtR(                                         \
  |  |  484|      0|                            tif, module,                                       \
  |  |  485|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  486|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  487|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  488|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  489|      0|                        return (-1);                                           \
  |  |  490|      0|                    }                                                          \
  |  |  491|    253|                    b1 = b1 + (int)*pb++;                                      \
  |  |  492|    253|                    RunLength =                                                \
  |  |  493|    253|                        (int)((uint32_t)RunLength + (uint32_t)(b1 - a0));      \
  |  |  494|    253|                    a0 = b1;                                                   \
  |  |  495|    253|                    b1 = b1 + (int)*pb++;                                      \
  |  |  496|    253|                    break;                                                     \
  |  |  497|    377|                case S_Horiz:                                                  \
  |  |  ------------------
  |  |  |  |   72|    377|#define S_Horiz 2
  |  |  ------------------
  |  |  |  Branch (497:17): [True: 377, False: 4.74k]
  |  |  ------------------
  |  |  498|    377|                    if ((pa - thisrun) & 1)                                    \
  |  |  ------------------
  |  |  |  Branch (498:25): [True: 42, False: 335]
  |  |  ------------------
  |  |  499|    377|                    {                                                          \
  |  |  500|     42|                        for (;;)                                               \
  |  |  501|     47|                        { /* black first */                                    \
  |  |  502|     47|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|     47|    do                                                                         \
  |  |  |  |  255|     47|    {                                                                          \
  |  |  |  |  256|     47|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|     47|    do                                                                         \
  |  |  |  |  |  |  165|     47|    {                                                                          \
  |  |  |  |  |  |  166|     47|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 46, False: 1]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|     47|        {                                                                      \
  |  |  |  |  |  |  168|     46|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|     46|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 46]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|     46|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|     46|            else                                                               \
  |  |  |  |  |  |  175|     46|            {                                                                  \
  |  |  |  |  |  |  176|     46|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|     46|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 5, False: 41]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|     46|                {                                                              \
  |  |  |  |  |  |  179|      5|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      5|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 5]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      5|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      5|                    else                                                       \
  |  |  |  |  |  |  185|      5|                    {                                                          \
  |  |  |  |  |  |  186|      5|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      5|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      5|                    }                                                          \
  |  |  |  |  |  |  189|      5|                }                                                              \
  |  |  |  |  |  |  190|     46|            }                                                                  \
  |  |  |  |  |  |  191|     46|        }                                                                      \
  |  |  |  |  |  |  192|     47|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 47]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|     47|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|     47|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|     47|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|     47|    do                                                                         \
  |  |  |  |  |  |  197|     47|    {                                                                          \
  |  |  |  |  |  |  198|     47|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|     47|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|     47|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 47]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|     47|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  503|     47|                            switch (TabEnt->State)                             \
  |  |  504|     47|                            {                                                  \
  |  |  505|     41|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|     41|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (505:33): [True: 41, False: 6]
  |  |  ------------------
  |  |  506|     41|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|     41|    do                                                                         \
  |  |  |  |  267|     41|    {                                                                          \
  |  |  |  |  268|     41|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 41]
  |  |  |  |  ------------------
  |  |  |  |  269|     41|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|     41|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|     41|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|     41|        RunLength = 0;                                                         \
  |  |  |  |  279|     41|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 41]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  507|     41|                                    goto doneWhite2da;                         \
  |  |  508|     41|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (508:33): [True: 0, False: 47]
  |  |  ------------------
  |  |  509|      5|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      5|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (509:33): [True: 5, False: 42]
  |  |  ------------------
  |  |  510|      5|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  511|      5|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  512|      5|                                                      TabEnt->Param);          \
  |  |  513|      5|                                    break;                                     \
  |  |  514|      1|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (514:33): [True: 1, False: 46]
  |  |  ------------------
  |  |  515|      1|                                    goto badBlack2d;                           \
  |  |  516|     47|                            }                                                  \
  |  |  517|     47|                        }                                                      \
  |  |  518|     42|                    doneWhite2da:;                                             \
  |  |  519|     41|                        for (;;)                                               \
  |  |  520|     45|                        { /* then white */                                     \
  |  |  521|     45|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|     45|    do                                                                         \
  |  |  |  |  255|     45|    {                                                                          \
  |  |  |  |  256|     45|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|     45|    do                                                                         \
  |  |  |  |  |  |  165|     45|    {                                                                          \
  |  |  |  |  |  |  166|     45|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 17, False: 28]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|     45|        {                                                                      \
  |  |  |  |  |  |  168|     17|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|     17|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 17]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|     17|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|     17|            else                                                               \
  |  |  |  |  |  |  175|     17|            {                                                                  \
  |  |  |  |  |  |  176|     17|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|     17|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 17]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|     17|                {                                                              \
  |  |  |  |  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      0|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      0|                    else                                                       \
  |  |  |  |  |  |  185|      0|                    {                                                          \
  |  |  |  |  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      0|                    }                                                          \
  |  |  |  |  |  |  189|      0|                }                                                              \
  |  |  |  |  |  |  190|     17|            }                                                                  \
  |  |  |  |  |  |  191|     17|        }                                                                      \
  |  |  |  |  |  |  192|     45|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 45]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|     45|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|     45|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|     45|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|     45|    do                                                                         \
  |  |  |  |  |  |  197|     45|    {                                                                          \
  |  |  |  |  |  |  198|     45|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|     45|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|     45|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 45]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|     45|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  522|     45|                            switch (TabEnt->State)                             \
  |  |  523|     45|                            {                                                  \
  |  |  524|     30|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|     30|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (524:33): [True: 30, False: 15]
  |  |  ------------------
  |  |  525|     30|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|     30|    do                                                                         \
  |  |  |  |  267|     30|    {                                                                          \
  |  |  |  |  268|     30|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  269|     30|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|     30|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|     30|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|     30|        RunLength = 0;                                                         \
  |  |  |  |  279|     30|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  526|     30|                                    goto doneBlack2da;                         \
  |  |  527|     30|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|      4|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (527:33): [True: 4, False: 41]
  |  |  ------------------
  |  |  528|      4|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      4|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (528:33): [True: 0, False: 45]
  |  |  ------------------
  |  |  529|      4|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  530|      4|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  531|      4|                                                      TabEnt->Param);          \
  |  |  532|      4|                                    break;                                     \
  |  |  533|     11|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (533:33): [True: 11, False: 34]
  |  |  ------------------
  |  |  534|     11|                                    goto badWhite2d;                           \
  |  |  535|     45|                            }                                                  \
  |  |  536|     45|                        }                                                      \
  |  |  537|     41|                    doneBlack2da:;                                             \
  |  |  538|     30|                    }                                                          \
  |  |  539|    377|                    else                                                       \
  |  |  540|    377|                    {                                                          \
  |  |  541|    335|                        for (;;)                                               \
  |  |  542|    388|                        { /* white first */                                    \
  |  |  543|    388|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|    388|    do                                                                         \
  |  |  |  |  255|    388|    {                                                                          \
  |  |  |  |  256|    388|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    388|    do                                                                         \
  |  |  |  |  |  |  165|    388|    {                                                                          \
  |  |  |  |  |  |  166|    388|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 379, False: 9]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    388|        {                                                                      \
  |  |  |  |  |  |  168|    379|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    379|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 3, False: 376]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    379|            {                                                                  \
  |  |  |  |  |  |  170|      3|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      3|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      3|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      3|            }                                                                  \
  |  |  |  |  |  |  174|    379|            else                                                               \
  |  |  |  |  |  |  175|    379|            {                                                                  \
  |  |  |  |  |  |  176|    376|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    376|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 2, False: 374]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    376|                {                                                              \
  |  |  |  |  |  |  179|      2|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      2|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 2]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      2|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      2|                    else                                                       \
  |  |  |  |  |  |  185|      2|                    {                                                          \
  |  |  |  |  |  |  186|      2|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      2|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      2|                    }                                                          \
  |  |  |  |  |  |  189|      2|                }                                                              \
  |  |  |  |  |  |  190|    376|            }                                                                  \
  |  |  |  |  |  |  191|    379|        }                                                                      \
  |  |  |  |  |  |  192|    388|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 388]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    388|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    388|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    388|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    388|    do                                                                         \
  |  |  |  |  |  |  197|    388|    {                                                                          \
  |  |  |  |  |  |  198|    388|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    388|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    388|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 388]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    388|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 388]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  544|    388|                            switch (TabEnt->State)                             \
  |  |  545|    388|                            {                                                  \
  |  |  546|    271|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|    271|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (546:33): [True: 271, False: 117]
  |  |  ------------------
  |  |  547|    271|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    271|    do                                                                         \
  |  |  |  |  267|    271|    {                                                                          \
  |  |  |  |  268|    271|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 271]
  |  |  |  |  ------------------
  |  |  |  |  269|    271|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    271|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    271|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    271|        RunLength = 0;                                                         \
  |  |  |  |  279|    271|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 271]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  548|    271|                                    goto doneWhite2db;                         \
  |  |  549|    271|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|     26|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (549:33): [True: 26, False: 362]
  |  |  ------------------
  |  |  550|     53|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|     53|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (550:33): [True: 27, False: 361]
  |  |  ------------------
  |  |  551|     53|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  552|     53|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  553|     53|                                                      TabEnt->Param);          \
  |  |  554|     53|                                    break;                                     \
  |  |  555|     64|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (555:33): [True: 64, False: 324]
  |  |  ------------------
  |  |  556|     64|                                    goto badWhite2d;                           \
  |  |  557|    388|                            }                                                  \
  |  |  558|    388|                        }                                                      \
  |  |  559|    335|                    doneWhite2db:;                                             \
  |  |  560|    271|                        for (;;)                                               \
  |  |  561|    280|                        { /* then black */                                     \
  |  |  562|    280|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|    280|    do                                                                         \
  |  |  |  |  255|    280|    {                                                                          \
  |  |  |  |  256|    280|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    280|    do                                                                         \
  |  |  |  |  |  |  165|    280|    {                                                                          \
  |  |  |  |  |  |  166|    280|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 176, False: 104]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    280|        {                                                                      \
  |  |  |  |  |  |  168|    176|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    176|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 176]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    176|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|    176|            else                                                               \
  |  |  |  |  |  |  175|    176|            {                                                                  \
  |  |  |  |  |  |  176|    176|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    176|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 9, False: 167]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    176|                {                                                              \
  |  |  |  |  |  |  179|      9|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      9|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 9]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      9|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      9|                    else                                                       \
  |  |  |  |  |  |  185|      9|                    {                                                          \
  |  |  |  |  |  |  186|      9|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      9|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      9|                    }                                                          \
  |  |  |  |  |  |  189|      9|                }                                                              \
  |  |  |  |  |  |  190|    176|            }                                                                  \
  |  |  |  |  |  |  191|    176|        }                                                                      \
  |  |  |  |  |  |  192|    280|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 280]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    280|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    280|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    280|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    280|    do                                                                         \
  |  |  |  |  |  |  197|    280|    {                                                                          \
  |  |  |  |  |  |  198|    280|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    280|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    280|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 280]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    280|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 280]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  563|    280|                            switch (TabEnt->State)                             \
  |  |  564|    280|                            {                                                  \
  |  |  565|    193|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|    193|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (565:33): [True: 193, False: 87]
  |  |  ------------------
  |  |  566|    193|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    193|    do                                                                         \
  |  |  |  |  267|    193|    {                                                                          \
  |  |  |  |  268|    193|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 193]
  |  |  |  |  ------------------
  |  |  |  |  269|    193|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    193|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    193|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    193|        RunLength = 0;                                                         \
  |  |  |  |  279|    193|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 193]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  567|    193|                                    goto doneBlack2db;                         \
  |  |  568|    193|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (568:33): [True: 0, False: 280]
  |  |  ------------------
  |  |  569|      9|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      9|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (569:33): [True: 9, False: 271]
  |  |  ------------------
  |  |  570|      9|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  571|      9|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  572|      9|                                                      TabEnt->Param);          \
  |  |  573|      9|                                    break;                                     \
  |  |  574|     78|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (574:33): [True: 78, False: 202]
  |  |  ------------------
  |  |  575|     78|                                    goto badBlack2d;                           \
  |  |  576|    280|                            }                                                  \
  |  |  577|    280|                        }                                                      \
  |  |  578|    271|                    doneBlack2db:;                                             \
  |  |  579|    193|                    }                                                          \
  |  |  580|    377|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|    223|    do                                                                         \
  |  |  |  |  441|    223|    {                                                                          \
  |  |  |  |  442|    223|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 223, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|    295|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 225, False: 70]
  |  |  |  |  |  Branch (443:32): [True: 72, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  444|    223|            {                                                                  \
  |  |  |  |  445|     72|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 72]
  |  |  |  |  ------------------
  |  |  |  |  446|     72|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|     72|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|     72|                pb += 2;                                                       \
  |  |  |  |  456|     72|            }                                                                  \
  |  |  |  |  457|    223|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 223]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  581|    223|                    break;                                                     \
  |  |  582|  1.68k|                case S_V0:                                                     \
  |  |  ------------------
  |  |  |  |   73|  1.68k|#define S_V0 3
  |  |  ------------------
  |  |  |  Branch (582:17): [True: 1.68k, False: 3.43k]
  |  |  ------------------
  |  |  583|  1.68k|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|  1.68k|    do                                                                         \
  |  |  |  |  441|  1.68k|    {                                                                          \
  |  |  |  |  442|  1.68k|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 385, False: 1.30k]
  |  |  |  |  ------------------
  |  |  |  |  443|  1.68k|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 138, False: 385]
  |  |  |  |  |  Branch (443:32): [True: 138, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|    385|            {                                                                  \
  |  |  |  |  445|    138|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 138]
  |  |  |  |  ------------------
  |  |  |  |  446|    138|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|    138|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|    138|                pb += 2;                                                       \
  |  |  |  |  456|    138|            }                                                                  \
  |  |  |  |  457|  1.68k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 1.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  584|  1.68k|                    SETVALUE(b1 - a0);                                         \
  |  |  ------------------
  |  |  |  |  266|  1.68k|    do                                                                         \
  |  |  |  |  267|  1.68k|    {                                                                          \
  |  |  |  |  268|  1.68k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.68k]
  |  |  |  |  ------------------
  |  |  |  |  269|  1.68k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  1.68k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  1.68k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  1.68k|        RunLength = 0;                                                         \
  |  |  |  |  279|  1.68k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 1.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  585|  1.68k|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (585:25): [True: 0, False: 1.68k]
  |  |  ------------------
  |  |  586|  1.68k|                    {                                                          \
  |  |  587|      0|                        TIFFErrorExtR(                                         \
  |  |  588|      0|                            tif, module,                                       \
  |  |  589|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  590|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  591|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  592|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  593|      0|                        return (-1);                                           \
  |  |  594|      0|                    }                                                          \
  |  |  595|  1.68k|                    b1 = b1 + (int)*pb++;                                      \
  |  |  596|  1.68k|                    break;                                                     \
  |  |  597|  1.68k|                case S_VR:                                                     \
  |  |  ------------------
  |  |  |  |   74|    351|#define S_VR 4
  |  |  ------------------
  |  |  |  Branch (597:17): [True: 351, False: 4.77k]
  |  |  ------------------
  |  |  598|    351|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|    351|    do                                                                         \
  |  |  |  |  441|    351|    {                                                                          \
  |  |  |  |  442|    351|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 64, False: 287]
  |  |  |  |  ------------------
  |  |  |  |  443|    351|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 23, False: 64]
  |  |  |  |  |  Branch (443:32): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|     64|            {                                                                  \
  |  |  |  |  445|     23|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  446|     23|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|     23|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|     23|                pb += 2;                                                       \
  |  |  |  |  456|     23|            }                                                                  \
  |  |  |  |  457|    351|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 351]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  599|    351|                    SETVALUE((int)((uint32_t)(b1 - a0) + TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|    351|    do                                                                         \
  |  |  |  |  267|    351|    {                                                                          \
  |  |  |  |  268|    351|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 351]
  |  |  |  |  ------------------
  |  |  |  |  269|    351|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    351|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    351|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    351|        RunLength = 0;                                                         \
  |  |  |  |  279|    351|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 351]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  600|    351|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (600:25): [True: 0, False: 351]
  |  |  ------------------
  |  |  601|    351|                    {                                                          \
  |  |  602|      0|                        TIFFErrorExtR(                                         \
  |  |  603|      0|                            tif, module,                                       \
  |  |  604|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  605|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  606|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  607|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  608|      0|                        return (-1);                                           \
  |  |  609|      0|                    }                                                          \
  |  |  610|    351|                    b1 = b1 + (int)*pb++;                                      \
  |  |  611|    351|                    break;                                                     \
  |  |  612|    514|                case S_VL:                                                     \
  |  |  ------------------
  |  |  |  |   75|    514|#define S_VL 5
  |  |  ------------------
  |  |  |  Branch (612:17): [True: 514, False: 4.60k]
  |  |  ------------------
  |  |  613|    514|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|    514|    do                                                                         \
  |  |  |  |  441|    514|    {                                                                          \
  |  |  |  |  442|    514|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 124, False: 390]
  |  |  |  |  ------------------
  |  |  |  |  443|    514|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 85, False: 124]
  |  |  |  |  |  Branch (443:32): [True: 85, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|    124|            {                                                                  \
  |  |  |  |  445|     85|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 85]
  |  |  |  |  ------------------
  |  |  |  |  446|     85|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|     85|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|     85|                pb += 2;                                                       \
  |  |  |  |  456|     85|            }                                                                  \
  |  |  |  |  457|    514|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 514]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  614|    514|                    if (b1 < (int)((uint32_t)a0 + TabEnt->Param))              \
  |  |  ------------------
  |  |  |  Branch (614:25): [True: 137, False: 377]
  |  |  ------------------
  |  |  615|    514|                    {                                                          \
  |  |  616|    137|                        unexpected("VL", a0);                                  \
  |  |  ------------------
  |  |  |  |  220|    137|    do                                                                         \
  |  |  |  |  221|    137|    {                                                                          \
  |  |  |  |  222|    137|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    137|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    137|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 137]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  617|    137|                        goto eol2d;                                            \
  |  |  618|    137|                    }                                                          \
  |  |  619|    514|                    SETVALUE((int)((uint32_t)(b1 - a0) - TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|    377|    do                                                                         \
  |  |  |  |  267|    377|    {                                                                          \
  |  |  |  |  268|    377|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 377]
  |  |  |  |  ------------------
  |  |  |  |  269|    377|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    377|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    377|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    377|        RunLength = 0;                                                         \
  |  |  |  |  279|    377|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 377]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  620|    377|                    b1 = b1 - (int)*--pb;                                      \
  |  |  621|    377|                    break;                                                     \
  |  |  622|    377|                case S_Ext:                                                    \
  |  |  ------------------
  |  |  |  |   76|    137|#define S_Ext 6
  |  |  ------------------
  |  |  |  Branch (622:17): [True: 137, False: 4.98k]
  |  |  ------------------
  |  |  623|    137|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  624|    137|                    extension(a0);                                             \
  |  |  ------------------
  |  |  |  |  238|    137|    Fax3Extension(module, tif, (uint32_t)sp->line, (uint32_t)(a0))
  |  |  ------------------
  |  |  625|    137|                    goto eol2d;                                                \
  |  |  626|  1.80k|                case S_EOL:                                                    \
  |  |  ------------------
  |  |  |  |   82|  1.80k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (626:17): [True: 1.80k, False: 3.31k]
  |  |  ------------------
  |  |  627|  1.80k|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  628|  1.80k|                    NeedBits8(4, eof2d);                                       \
  |  |  ------------------
  |  |  |  |  144|  1.80k|    do                                                                         \
  |  |  |  |  145|  1.80k|    {                                                                          \
  |  |  |  |  146|  1.80k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 1.02k, False: 775]
  |  |  |  |  ------------------
  |  |  |  |  147|  1.80k|        {                                                                      \
  |  |  |  |  148|  1.02k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  1.02k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 4, False: 1.02k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  1.02k|            {                                                                  \
  |  |  |  |  150|      4|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  151|      4|                    goto eoflab;                                               \
  |  |  |  |  152|      4|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  154|  1.02k|            else                                                               \
  |  |  |  |  155|  1.02k|            {                                                                  \
  |  |  |  |  156|  1.02k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  1.02k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  1.02k|            }                                                                  \
  |  |  |  |  159|  1.02k|        }                                                                      \
  |  |  |  |  160|  1.80k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 1.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  629|  1.80k|                    if (GetBits(4))                                            \
  |  |  ------------------
  |  |  |  |  194|  1.80k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 326, False: 1.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  630|  1.80k|                        unexpected("EOL", a0);                                 \
  |  |  ------------------
  |  |  |  |  220|    326|    do                                                                         \
  |  |  |  |  221|    326|    {                                                                          \
  |  |  |  |  222|    326|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    326|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    326|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 326]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  631|  1.80k|                    ClrBits(4);                                                \
  |  |  ------------------
  |  |  |  |  196|  1.80k|    do                                                                         \
  |  |  |  |  197|  1.80k|    {                                                                          \
  |  |  |  |  198|  1.80k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  1.80k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  1.80k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 1.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  632|  1.80k|                    EOLcnt = 1;                                                \
  |  |  633|  1.80k|                    goto eol2d;                                                \
  |  |  634|  1.80k|                default:                                                       \
  |  |  ------------------
  |  |  |  Branch (634:17): [True: 0, False: 5.12k]
  |  |  ------------------
  |  |  635|      0|                badMain2d:                                                     \
  |  |  636|      0|                    unexpected("MainTable", a0);                               \
  |  |  ------------------
  |  |  |  |  220|      0|    do                                                                         \
  |  |  |  |  221|      0|    {                                                                          \
  |  |  |  |  222|      0|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      0|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  637|      0|                    goto eol2d;                                                \
  |  |  638|     79|                badBlack2d:                                                    \
  |  |  639|     79|                    unexpected("BlackTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|     79|    do                                                                         \
  |  |  |  |  221|     79|    {                                                                          \
  |  |  |  |  222|     79|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     79|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     79|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  640|     79|                    goto eol2d;                                                \
  |  |  641|     75|                badWhite2d:                                                    \
  |  |  642|     75|                    unexpected("WhiteTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|     75|    do                                                                         \
  |  |  |  |  221|     75|    {                                                                          \
  |  |  |  |  222|     75|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     75|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     75|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  643|     75|                    goto eol2d;                                                \
  |  |  644|      7|                eof2d:                                                         \
  |  |  645|      7|                    prematureEOF(a0);                                          \
  |  |  ------------------
  |  |  |  |  271|      7|    do                                                                         \
  |  |  |  |  272|      7|    {                                                                          \
  |  |  |  |  273|      7|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|      7|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|      7|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  646|      7|                    CLEANUP_RUNS();                                            \
  |  |  ------------------
  |  |  |  |  333|      7|    do                                                                         \
  |  |  |  |  334|      7|    {                                                                          \
  |  |  |  |  335|      7|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  336|      7|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|      7|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|      7|        {                                                                      \
  |  |  |  |  339|      7|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|      7|    do                                                                         \
  |  |  |  |  |  |  254|      7|    {                                                                          \
  |  |  |  |  |  |  255|      7|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|      7|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|      7|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|      7|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|      7|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 7]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|      7|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|      7|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|      7|            {                                                                  \
  |  |  |  |  344|      7|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  345|      7|                    a0 = 0;                                                    \
  |  |  |  |  346|      7|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 4, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  347|      7|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      4|    do                                                                         \
  |  |  |  |  |  |  267|      4|    {                                                                          \
  |  |  |  |  |  |  268|      4|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      4|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      4|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      4|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      4|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      4|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|      7|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      7|    do                                                                         \
  |  |  |  |  |  |  267|      7|    {                                                                          \
  |  |  |  |  |  |  268|      7|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      7|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      7|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      7|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      7|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      7|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|      7|            }                                                                  \
  |  |  |  |  350|      7|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|      7|        }                                                                      \
  |  |  |  |  356|      7|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  647|      7|                    goto eoflab;                                               \
  |  |  648|  5.12k|            }                                                                  \
  |  |  649|  5.12k|        }                                                                      \
  |  |  650|  4.26k|        if (RunLength)                                                         \
  |  |  ------------------
  |  |  |  Branch (650:13): [True: 219, False: 1.80k]
  |  |  ------------------
  |  |  651|  2.02k|        {                                                                      \
  |  |  652|    219|            if (RunLength + a0 < lastx)                                        \
  |  |  ------------------
  |  |  |  Branch (652:17): [True: 0, False: 219]
  |  |  ------------------
  |  |  653|    219|            {                                                                  \
  |  |  654|      0|                /* expect a final V0 */                                        \
  |  |  655|      0|                NeedBits8(1, eof2d);                                           \
  |  |  ------------------
  |  |  |  |  144|      0|    do                                                                         \
  |  |  |  |  145|      0|    {                                                                          \
  |  |  |  |  146|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  147|      0|        {                                                                      \
  |  |  |  |  148|      0|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|      0|            {                                                                  \
  |  |  |  |  150|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  151|      0|                    goto eoflab;                                               \
  |  |  |  |  152|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  154|      0|            else                                                               \
  |  |  |  |  155|      0|            {                                                                  \
  |  |  |  |  156|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|      0|                BitsAvail += 8;                                                \
  |  |  |  |  158|      0|            }                                                                  \
  |  |  |  |  159|      0|        }                                                                      \
  |  |  |  |  160|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  656|      0|                if (!GetBits(1))                                               \
  |  |  ------------------
  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (656:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  657|      0|                    goto badMain2d;                                            \
  |  |  658|      0|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  659|      0|            }                                                                  \
  |  |  660|    219|            SETVALUE(0);                                                       \
  |  |  ------------------
  |  |  |  |  266|    219|    do                                                                         \
  |  |  |  |  267|    219|    {                                                                          \
  |  |  |  |  268|    219|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 219]
  |  |  |  |  ------------------
  |  |  |  |  269|    219|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|    219|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    219|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    219|        RunLength = 0;                                                         \
  |  |  |  |  279|    219|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 219]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  661|    219|        }                                                                      \
  |  |  662|  4.25k|    eol2d:                                                                     \
  |  |  663|  4.25k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  4.25k|    do                                                                         \
  |  |  |  |  334|  4.25k|    {                                                                          \
  |  |  |  |  335|  4.25k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 7, False: 4.24k]
  |  |  |  |  ------------------
  |  |  |  |  336|  4.25k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      7|    do                                                                         \
  |  |  |  |  |  |  267|      7|    {                                                                          \
  |  |  |  |  |  |  268|      7|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      7|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      7|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      7|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      7|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      7|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  4.25k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 2.63k, False: 1.62k]
  |  |  |  |  ------------------
  |  |  |  |  338|  4.25k|        {                                                                      \
  |  |  |  |  339|  2.63k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  2.63k|    do                                                                         \
  |  |  |  |  |  |  254|  2.63k|    {                                                                          \
  |  |  |  |  |  |  255|  2.63k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  2.63k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  2.63k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  2.63k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 2.63k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  3.23k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 602, False: 2.63k]
  |  |  |  |  |  Branch (340:39): [True: 602, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  2.63k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  2.63k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 2.62k, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  343|  2.63k|            {                                                                  \
  |  |  |  |  344|  2.62k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 2.62k]
  |  |  |  |  ------------------
  |  |  |  |  345|  2.62k|                    a0 = 0;                                                    \
  |  |  |  |  346|  2.62k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 1.90k, False: 723]
  |  |  |  |  ------------------
  |  |  |  |  347|  2.62k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  1.90k|    do                                                                         \
  |  |  |  |  |  |  267|  1.90k|    {                                                                          \
  |  |  |  |  |  |  268|  1.90k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.90k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  1.90k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  1.90k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  1.90k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  1.90k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  1.90k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 1.90k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  2.62k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  2.62k|    do                                                                         \
  |  |  |  |  |  |  267|  2.62k|    {                                                                          \
  |  |  |  |  |  |  268|  2.62k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 2.62k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  2.62k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  2.62k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  2.62k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  2.62k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  2.62k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 2.62k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  2.62k|            }                                                                  \
  |  |  |  |  350|  2.63k|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  351|      5|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|  2.63k|        }                                                                      \
  |  |  |  |  356|  4.25k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 4.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  664|  4.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (664:14): [Folded, False: 4.25k]
  |  |  ------------------
  ------------------
  422|  7.20k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  423|  7.20k|        if (pa < thisrun + sp->nruns)
  ------------------
  |  Branch (423:13): [True: 7.20k, False: 0]
  ------------------
  424|  7.20k|        {
  425|  7.20k|            SETVALUE(0); /* imaginary change for reference */
  ------------------
  |  |  266|  7.20k|    do                                                                         \
  |  |  267|  7.20k|    {                                                                          \
  |  |  268|  7.20k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  ------------------
  |  |  |  Branch (268:13): [True: 0, False: 7.20k]
  |  |  ------------------
  |  |  269|  7.20k|        {                                                                      \
  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  274|      0|            return (-1);                                                       \
  |  |  275|      0|        }                                                                      \
  |  |  276|  7.20k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  277|  7.20k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  278|  7.20k|        RunLength = 0;                                                         \
  |  |  279|  7.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (279:14): [Folded, False: 7.20k]
  |  |  ------------------
  ------------------
  426|  7.20k|        }
  427|  7.20k|        SWAP(uint32_t *, sp->curruns, sp->refruns);
  ------------------
  |  |  375|  7.20k|    {                                                                          \
  |  |  376|  7.20k|        t x;                                                                   \
  |  |  377|  7.20k|        x = (a);                                                               \
  |  |  378|  7.20k|        (a) = (b);                                                             \
  |  |  379|  7.20k|        (b) = x;                                                               \
  |  |  380|  7.20k|    }
  ------------------
  428|  7.20k|        buf += sp->b.rowbytes;
  429|  7.20k|        occ -= sp->b.rowbytes;
  430|  7.20k|        sp->line++;
  431|  7.20k|        continue;
  432|      0|    EOF2D: /* premature EOF */
  433|      0|        CLEANUP_RUNS();
  ------------------
  |  |  333|      0|    do                                                                         \
  |  |  334|      0|    {                                                                          \
  |  |  335|      0|        if (RunLength)                                                         \
  |  |  ------------------
  |  |  |  Branch (335:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  336|      0|            SETVALUE(0);                                                       \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  337|      0|        if (a0 != (int)lastx)                                                  \
  |  |  ------------------
  |  |  |  Branch (337:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  338|      0|        {                                                                      \
  |  |  339|      0|            badlength(a0, lastx);                                              \
  |  |  ------------------
  |  |  |  |  253|      0|    do                                                                         \
  |  |  |  |  254|      0|    {                                                                          \
  |  |  |  |  255|      0|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  256|      0|                      (uint32_t)(lastx));                                      \
  |  |  |  |  257|      0|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  258|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  340|      0|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  ------------------
  |  |  |  Branch (340:20): [True: 0, False: 0]
  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  ------------------
  |  |  341|      0|                a0 -= (int)*--pa;                                              \
  |  |  342|      0|            if (a0 < (int)lastx)                                               \
  |  |  ------------------
  |  |  |  Branch (342:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  343|      0|            {                                                                  \
  |  |  344|      0|                if (a0 < 0)                                                    \
  |  |  ------------------
  |  |  |  Branch (344:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  345|      0|                    a0 = 0;                                                    \
  |  |  346|      0|                if ((pa - thisrun) & 1)                                        \
  |  |  ------------------
  |  |  |  Branch (346:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  347|      0|                    SETVALUE(0);                                               \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  348|      0|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  349|      0|            }                                                                  \
  |  |  350|      0|            else if (a0 > (int)lastx)                                          \
  |  |  ------------------
  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  351|      0|            {                                                                  \
  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  354|      0|            }                                                                  \
  |  |  355|      0|        }                                                                      \
  |  |  356|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (356:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  434|      7|    EOF2Da: /* premature EOF */
  435|      7|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  436|      7|        UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      7|    do                                                                         \
  |  |  160|      7|    {                                                                          \
  |  |  161|      7|        sp->bit = BitsAvail;                                                   \
  |  |  162|      7|        sp->data = BitAcc;                                                     \
  |  |  163|      7|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      7|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      7|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      7|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 7]
  |  |  ------------------
  ------------------
  437|      7|        return (-1);
  438|      0|    }
  439|      2|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      2|    do                                                                         \
  |  |  160|      2|    {                                                                          \
  |  |  161|      2|        sp->bit = BitsAvail;                                                   \
  |  |  162|      2|        sp->data = BitAcc;                                                     \
  |  |  163|      2|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      2|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      2|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  440|      2|    return (1);
  441|     16|}
tif_fax3.c:CheckReachedCounters:
  296|  6.66k|{
  297|  6.66k|    if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|  6.66k|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (297:9): [True: 0, False: 6.66k]
  ------------------
  298|      0|    {
  299|      0|        TIFFErrorExtR(tif, module,
  300|      0|                      "End of file (EOF) has already been reached %d times "
  301|      0|                      "within that %s.",
  302|      0|                      sp->eofReachedCount, isTiled(tif) ? "tile" : "strip");
  ------------------
  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  303|      0|        return (-1);
  304|      0|    }
  305|  6.66k|    if (sp->eolReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|  6.66k|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (305:9): [True: 0, False: 6.66k]
  ------------------
  306|      0|    {
  307|      0|        TIFFErrorExtR(tif, module,
  308|      0|                      "Bad line length (EOL) has already been reached %d times "
  309|      0|                      "within that %s",
  310|      0|                      sp->eolReachedCount, isTiled(tif) ? "tile" : "strip");
  ------------------
  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  311|      0|        return (-1);
  312|      0|    }
  313|  6.66k|    if (sp->unexpectedReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|  6.66k|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (313:9): [True: 0, False: 6.66k]
  ------------------
  314|      0|    {
  315|      0|        TIFFErrorExtR(tif, module,
  316|      0|                      "Bad code word (unexpected) has already been reached %d "
  317|      0|                      "times within that %s",
  318|      0|                      sp->unexpectedReachedCount,
  319|      0|                      isTiled(tif) ? "tile" : "strip");
  ------------------
  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  320|      0|        return (-1);
  321|      0|    }
  322|  6.66k|    return (0);
  323|  6.66k|}
tif_fax3.c:Fax3TryG3WithoutEOL:
  279|     38|{
  280|     38|    TIFFWarningExtR(
  281|     38|        tif, module,
  282|     38|        "Try to decode (read) fax Group 3 data without EOL at line %" PRIu32
  283|     38|        " of %s %" PRIu32 " (x %" PRIu32 "). Please check result",
  284|     38|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|     38|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     38|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 12, False: 26]
  |  |  ------------------
  ------------------
  285|     38|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|     38|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     38|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 12, False: 26]
  |  |  ------------------
  ------------------
  286|     38|        a0);
  287|     38|}
tif_fax3.c:Fax3Unexpected:
  211|  82.8k|{
  212|  82.8k|    TIFFErrorExtR(
  213|  82.8k|        tif, module,
  214|  82.8k|        "Bad code word at line %" PRIu32 " of %s %" PRIu32 " (x %" PRIu32 ")",
  215|  82.8k|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|  82.8k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  82.8k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 13.3k, False: 69.5k]
  |  |  ------------------
  ------------------
  216|  82.8k|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|  82.8k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  82.8k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 13.3k, False: 69.5k]
  |  |  ------------------
  ------------------
  217|  82.8k|        a0);
  218|  82.8k|}
tif_fax3.c:Fax3PrematureEOF:
  262|     17|{
  263|     17|    TIFFWarningExtR(
  264|     17|        tif, module,
  265|     17|        "Premature EOF at line %" PRIu32 " of %s %" PRIu32 " (x %" PRIu32 ")",
  266|     17|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|     17|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     17|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 17]
  |  |  ------------------
  ------------------
  267|     17|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|     17|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     17|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 17]
  |  |  ------------------
  ------------------
  268|     17|        a0);
  269|     17|}
tif_fax3.c:Fax3BadLength:
  242|   153k|{
  243|   153k|    TIFFWarningExtR(
  244|   153k|        tif, module,
  245|   153k|        "%s at line %" PRIu32 " of %s %" PRIu32 " (got %" PRIu32
  246|   153k|        ", expected %" PRIu32 ")",
  247|   153k|        a0 < lastx ? "Premature EOL" : "Line length mismatch", line,
  ------------------
  |  Branch (247:9): [True: 135k, False: 17.5k]
  ------------------
  248|   153k|        isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|   153k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|   153k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 40.1k, False: 112k]
  |  |  ------------------
  ------------------
  249|   153k|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip), a0,
  ------------------
  |  |  278|   153k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|   153k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 40.1k, False: 112k]
  |  |  ------------------
  ------------------
  250|   153k|        lastx);
  251|   153k|}
tif_fax3.c:Fax3Extension:
  228|    137|{
  229|    137|    TIFFErrorExtR(
  230|    137|        tif, module,
  231|    137|        "Uncompressed data (not supported) at line %" PRIu32 " of %s %" PRIu32
  232|    137|        " (x %" PRIu32 ")",
  233|    137|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|    137|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    137|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 137]
  |  |  ------------------
  ------------------
  234|    137|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|    137|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    137|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 137]
  |  |  ------------------
  ------------------
  235|    137|        a0);
  236|    137|}
tif_fax3.c:Fax3PreDecode:
  172|  6.66k|{
  173|  6.66k|    Fax3CodecState *sp = DecoderState(tif);
  ------------------
  |  |  108|  6.66k|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|  6.66k|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  174|       |
  175|  6.66k|    (void)s;
  176|  6.66k|    assert(sp != NULL);
  ------------------
  |  Branch (176:5): [True: 0, False: 6.66k]
  |  Branch (176:5): [True: 6.66k, False: 0]
  ------------------
  177|  6.66k|    sp->bit = 0; /* force initial read */
  178|  6.66k|    sp->data = 0;
  179|  6.66k|    sp->EOLcnt = 0; /* force initial scan for EOL */
  180|  6.66k|    sp->eofReachedCount = 0;
  181|  6.66k|    sp->eolReachedCount = 0;
  182|  6.66k|    sp->unexpectedReachedCount = 0;
  183|       |    /*
  184|       |     * Decoder assumes lsb-to-msb bit order.  Note that we select
  185|       |     * this here rather than in Fax3SetupState so that viewers can
  186|       |     * hold the image open, fiddle with the FillOrder tag value,
  187|       |     * and then re-decode the image.  Otherwise they'd need to close
  188|       |     * and open the image to get the state reset.
  189|       |     */
  190|  6.66k|    sp->bitmap =
  191|  6.66k|        TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB);
  ------------------
  |  |  242|  6.66k|#define FILLORDER_LSB2MSB 2                /* least significant -> most */
  ------------------
  192|  6.66k|    sp->curruns = sp->runs;
  193|  6.66k|    if (sp->refruns)
  ------------------
  |  Branch (193:9): [True: 35, False: 6.62k]
  ------------------
  194|     35|    { /* init reference line to white */
  195|     35|        sp->refruns = sp->runs + sp->nruns;
  196|     35|        sp->refruns[0] = (uint32_t)sp->b.rowpixels;
  197|     35|        sp->refruns[1] = 0;
  198|     35|    }
  199|  6.66k|    sp->line = 0;
  200|  6.66k|    return (1);
  201|  6.66k|}
tif_fax3.c:Fax3Decode1D:
  333|  6.35k|{
  334|  6.35k|    DECLARE_STATE(tif, sp, "Fax3Decode1D");
  ------------------
  |  |  123|  6.35k|    static const char module[] = mod;                                          \
  |  |  124|  6.35k|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  ------------------
  |  |  |  |  108|  6.35k|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|  6.35k|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  125|  6.35k|    int a0;                                   /* reference element */          \
  |  |  126|  6.35k|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  127|  6.35k|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  128|  6.35k|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  129|  6.35k|    int RunLength;                            /* length of current run */      \
  |  |  130|  6.35k|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  131|  6.35k|    unsigned char *ep;                        /* end of input data */          \
  |  |  132|  6.35k|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  133|  6.35k|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  134|  6.35k|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  135|  6.35k|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  136|  6.35k|    const TIFFFaxTabEnt *TabEnt
  ------------------
  335|  6.35k|    (void)s;
  336|  6.35k|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (336:9): [True: 0, False: 6.35k]
  ------------------
  337|      0|    {
  338|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  339|      0|        return (-1);
  340|      0|    }
  341|  6.35k|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (341:9): [True: 0, False: 6.35k]
  ------------------
  342|      0|        return (-1);
  343|  6.39k|RETRY_WITHOUT_EOL_1D:
  344|  6.39k|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|  6.39k|    do                                                                         \
  |  |  148|  6.39k|    {                                                                          \
  |  |  149|  6.39k|        BitAcc = sp->data;                                                     \
  |  |  150|  6.39k|        BitsAvail = sp->bit;                                                   \
  |  |  151|  6.39k|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|  6.39k|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|  6.39k|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|  6.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 6.39k]
  |  |  ------------------
  ------------------
  345|  6.39k|    thisrun = sp->curruns;
  346|  95.2k|    while (occ > 0)
  ------------------
  |  Branch (346:12): [True: 88.9k, False: 6.35k]
  ------------------
  347|  88.9k|    {
  348|  88.9k|        a0 = 0;
  349|  88.9k|        RunLength = 0;
  350|  88.9k|        pa = thisrun;
  351|       |#ifdef FAX3_DEBUG
  352|       |        printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
  353|       |        printf("-------------------- %" PRIu32 "\n", tif->tif_dir.td_row);
  354|       |        fflush(stdout);
  355|       |#endif
  356|  88.9k|        SYNC_EOL(EOF1D, RETRY_WITHOUT_EOL_1D);
  ------------------
  |  |  293|  88.9k|    do                                                                         \
  |  |  294|  88.9k|    {                                                                          \
  |  |  295|  88.9k|        if (!(sp->b.mode & FAXMODE_NOEOL)) /* skip EOL, if not present */      \
  |  |  ------------------
  |  |  |  |  700|  88.9k|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  |  Branch (295:13): [True: 2.03k, False: 86.8k]
  |  |  ------------------
  |  |  296|  88.9k|        {                                                                      \
  |  |  297|  2.03k|            if (EOLcnt == 0)                                                   \
  |  |  ------------------
  |  |  |  Branch (297:17): [True: 603, False: 1.43k]
  |  |  ------------------
  |  |  298|  2.03k|            {                                                                  \
  |  |  299|    603|                for (;;)                                                       \
  |  |  300|  35.5k|                {                                                              \
  |  |  301|  35.5k|                    NeedBits16(11, eoflab);                                    \
  |  |  ------------------
  |  |  |  |  164|  35.5k|    do                                                                         \
  |  |  |  |  165|  35.5k|    {                                                                          \
  |  |  |  |  166|  35.5k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:13): [True: 4.67k, False: 30.8k]
  |  |  |  |  ------------------
  |  |  |  |  167|  35.5k|        {                                                                      \
  |  |  |  |  168|  4.67k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  4.67k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 89, False: 4.58k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  169|  4.67k|            {                                                                  \
  |  |  |  |  170|     89|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (170:21): [True: 0, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  171|     89|                    goto eoflab;                                               \
  |  |  |  |  172|     89|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  173|     89|            }                                                                  \
  |  |  |  |  174|  4.67k|            else                                                               \
  |  |  |  |  175|  4.67k|            {                                                                  \
  |  |  |  |  176|  4.58k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  177|  4.58k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:21): [True: 100, False: 4.48k]
  |  |  |  |  ------------------
  |  |  |  |  178|  4.58k|                {                                                              \
  |  |  |  |  179|    100|                    if (EndOfData())                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|    100|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 4, False: 96]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  180|    100|                    {                                                          \
  |  |  |  |  181|      4|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  182|      4|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  183|      4|                    }                                                          \
  |  |  |  |  184|    100|                    else                                                       \
  |  |  |  |  185|    100|                    {                                                          \
  |  |  |  |  186|     96|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  187|     96|                        BitsAvail += 8;                                        \
  |  |  |  |  188|     96|                    }                                                          \
  |  |  |  |  189|    100|                }                                                              \
  |  |  |  |  190|  4.58k|            }                                                                  \
  |  |  |  |  191|  4.67k|        }                                                                      \
  |  |  |  |  192|  35.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:14): [Folded, False: 35.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  302|  35.5k|                    if (GetBits(11) == 0)                                      \
  |  |  ------------------
  |  |  |  |  194|  35.5k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (302:25): [True: 603, False: 34.9k]
  |  |  ------------------
  |  |  303|  35.5k|                        break; /* EOL found */                                 \
  |  |  304|  35.5k|                    ClrBits(1);                                                \
  |  |  ------------------
  |  |  |  |  196|  34.9k|    do                                                                         \
  |  |  |  |  197|  34.9k|    {                                                                          \
  |  |  |  |  198|  34.9k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  34.9k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  34.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 34.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  305|  34.9k|                }                                                              \
  |  |  306|    603|            }                                                                  \
  |  |  307|  2.03k|            /* Now move after EOL or detect missing EOL. */                    \
  |  |  308|  2.03k|            for (;;)                                                           \
  |  |  309|  6.01k|            {                                                                  \
  |  |  310|  6.01k|                NeedBits8(8, noEOLFound);                                      \
  |  |  ------------------
  |  |  |  |  144|  6.01k|    do                                                                         \
  |  |  |  |  145|  6.01k|    {                                                                          \
  |  |  |  |  146|  6.01k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 4.92k, False: 1.09k]
  |  |  |  |  ------------------
  |  |  |  |  147|  6.01k|        {                                                                      \
  |  |  |  |  148|  4.92k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  4.92k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 56, False: 4.87k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  4.92k|            {                                                                  \
  |  |  |  |  150|     56|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 31, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  151|     56|                    goto eoflab;                                               \
  |  |  |  |  152|     56|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|     25|            }                                                                  \
  |  |  |  |  154|  4.92k|            else                                                               \
  |  |  |  |  155|  4.92k|            {                                                                  \
  |  |  |  |  156|  4.87k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  4.87k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  4.87k|            }                                                                  \
  |  |  |  |  159|  4.92k|        }                                                                      \
  |  |  |  |  160|  6.01k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 5.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  311|  6.01k|                if (GetBits(8))                                                \
  |  |  ------------------
  |  |  |  |  194|  5.98k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 2.00k, False: 3.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  312|  5.98k|                    break;                                                     \
  |  |  313|  5.98k|                ClrBits(8);                                                    \
  |  |  ------------------
  |  |  |  |  196|  3.98k|    do                                                                         \
  |  |  |  |  197|  3.98k|    {                                                                          \
  |  |  |  |  198|  3.98k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  3.98k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  3.98k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 3.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  314|  3.98k|            }                                                                  \
  |  |  315|  8.62k|            while (GetBits(1) == 0)                                            \
  |  |  ------------------
  |  |  |  |  194|  8.62k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (315:20): [True: 6.61k, False: 2.00k]
  |  |  ------------------
  |  |  316|  6.61k|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|  8.62k|    do                                                                         \
  |  |  |  |  197|  8.62k|    {                                                                          \
  |  |  |  |  198|  6.61k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  6.61k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  6.61k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 6.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  317|  2.00k|            ClrBits(1); /* EOL bit */                                          \
  |  |  ------------------
  |  |  |  |  196|  2.00k|    do                                                                         \
  |  |  |  |  197|  2.00k|    {                                                                          \
  |  |  |  |  198|  2.00k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  2.00k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  2.00k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 2.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  318|  2.00k|            EOLcnt = 0; /* reset EOL counter/flag */                           \
  |  |  319|  2.00k|            break;      /* existing EOL skipped, leave macro */                \
  |  |  320|  2.03k|        noEOLFound:                                                            \
  |  |  321|     31|            sp->b.mode |= FAXMODE_NOEOL;                                       \
  |  |  ------------------
  |  |  |  |  700|     31|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  322|     31|            tryG3WithoutEOL(a0);                                               \
  |  |  ------------------
  |  |  |  |  289|     31|    do                                                                         \
  |  |  |  |  290|     31|    {                                                                          \
  |  |  |  |  291|     31|        Fax3TryG3WithoutEOL(module, tif, (uint32_t)sp->line, (uint32_t)(a0));  \
  |  |  |  |  292|     31|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:14): [Folded, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  323|     31|            goto retrywithouteol;                                              \
  |  |  324|  2.03k|        }                                                                      \
  |  |  325|  88.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (325:14): [Folded, False: 86.8k]
  |  |  ------------------
  ------------------
  357|  88.8k|        EXPAND1D(EOF1Da);
  ------------------
  |  |  371|  88.8k|    do                                                                         \
  |  |  372|  88.8k|    {                                                                          \
  |  |  373|  88.8k|        for (;;)                                                               \
  |  |  374|  99.5k|        {                                                                      \
  |  |  375|  99.5k|            for (;;)                                                           \
  |  |  376|   125k|            {                                                                  \
  |  |  377|   125k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|   125k|    do                                                                         \
  |  |  |  |  255|   125k|    {                                                                          \
  |  |  |  |  256|   125k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|   125k|    do                                                                         \
  |  |  |  |  |  |  165|   125k|    {                                                                          \
  |  |  |  |  |  |  166|   125k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 90.0k, False: 35.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|   125k|        {                                                                      \
  |  |  |  |  |  |  168|  90.0k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  90.0k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 40.8k, False: 49.1k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  90.0k|            {                                                                  \
  |  |  |  |  |  |  170|  40.8k|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 40.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  40.8k|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|  40.8k|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|  40.8k|            }                                                                  \
  |  |  |  |  |  |  174|  90.0k|            else                                                               \
  |  |  |  |  |  |  175|  90.0k|            {                                                                  \
  |  |  |  |  |  |  176|  49.1k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  49.1k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 9.79k, False: 39.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  49.1k|                {                                                              \
  |  |  |  |  |  |  179|  9.79k|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  9.79k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 874, False: 8.91k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|  9.79k|                    {                                                          \
  |  |  |  |  |  |  181|    874|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|    874|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|    874|                    }                                                          \
  |  |  |  |  |  |  184|  9.79k|                    else                                                       \
  |  |  |  |  |  |  185|  9.79k|                    {                                                          \
  |  |  |  |  |  |  186|  8.91k|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|  8.91k|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|  8.91k|                    }                                                          \
  |  |  |  |  |  |  189|  9.79k|                }                                                              \
  |  |  |  |  |  |  190|  49.1k|            }                                                                  \
  |  |  |  |  |  |  191|  90.0k|        }                                                                      \
  |  |  |  |  |  |  192|   125k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 125k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|   125k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|   125k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|   125k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|   125k|    do                                                                         \
  |  |  |  |  |  |  197|   125k|    {                                                                          \
  |  |  |  |  |  |  198|   125k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|   125k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|   125k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 125k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|   125k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 125k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|   125k|                switch (TabEnt->State)                                         \
  |  |  379|   125k|                {                                                              \
  |  |  380|  48.8k|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|  48.8k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 48.8k, False: 76.3k]
  |  |  ------------------
  |  |  381|  48.8k|                        EOLcnt = 1;                                            \
  |  |  382|  48.8k|                        goto done1d;                                           \
  |  |  383|  23.4k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  23.4k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 23.4k, False: 101k]
  |  |  ------------------
  |  |  384|  23.4k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  23.4k|    do                                                                         \
  |  |  |  |  267|  23.4k|    {                                                                          \
  |  |  |  |  268|  23.4k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 23.4k]
  |  |  |  |  ------------------
  |  |  |  |  269|  23.4k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  23.4k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  23.4k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  23.4k|        RunLength = 0;                                                         \
  |  |  |  |  279|  23.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 23.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  23.4k|                        goto doneWhite1d;                                      \
  |  |  386|  24.4k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|  24.4k|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 24.4k, False: 100k]
  |  |  ------------------
  |  |  387|  25.6k|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|  25.6k|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 1.21k, False: 124k]
  |  |  ------------------
  |  |  388|  25.6k|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|  25.6k|                        RunLength =                                            \
  |  |  390|  25.6k|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|  25.6k|                        break;                                                 \
  |  |  392|  27.2k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 27.2k, False: 97.9k]
  |  |  ------------------
  |  |  393|  27.2k|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|  27.2k|    do                                                                         \
  |  |  |  |  221|  27.2k|    {                                                                          \
  |  |  |  |  222|  27.2k|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|  27.2k|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|  27.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 27.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|  27.2k|                        goto done1d;                                           \
  |  |  395|   125k|                }                                                              \
  |  |  396|   125k|            }                                                                  \
  |  |  397|  99.5k|        doneWhite1d:                                                           \
  |  |  398|  23.4k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 6.73k, False: 16.7k]
  |  |  ------------------
  |  |  399|  23.4k|                goto done1d;                                                   \
  |  |  400|  23.4k|            for (;;)                                                           \
  |  |  401|  17.3k|            {                                                                  \
  |  |  402|  17.3k|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  17.3k|    do                                                                         \
  |  |  |  |  255|  17.3k|    {                                                                          \
  |  |  |  |  256|  17.3k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  17.3k|    do                                                                         \
  |  |  |  |  |  |  165|  17.3k|    {                                                                          \
  |  |  |  |  |  |  166|  17.3k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 12.6k, False: 4.72k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  17.3k|        {                                                                      \
  |  |  |  |  |  |  168|  12.6k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  12.6k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 1.05k, False: 11.6k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  12.6k|            {                                                                  \
  |  |  |  |  |  |  170|  1.05k|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 1.05k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.05k|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|  1.05k|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|  1.05k|            }                                                                  \
  |  |  |  |  |  |  174|  12.6k|            else                                                               \
  |  |  |  |  |  |  175|  12.6k|            {                                                                  \
  |  |  |  |  |  |  176|  11.6k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  11.6k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 732, False: 10.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  11.6k|                {                                                              \
  |  |  |  |  |  |  179|    732|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    732|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 732]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|    732|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|    732|                    else                                                       \
  |  |  |  |  |  |  185|    732|                    {                                                          \
  |  |  |  |  |  |  186|    732|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|    732|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|    732|                    }                                                          \
  |  |  |  |  |  |  189|    732|                }                                                              \
  |  |  |  |  |  |  190|  11.6k|            }                                                                  \
  |  |  |  |  |  |  191|  12.6k|        }                                                                      \
  |  |  |  |  |  |  192|  17.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 17.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  17.3k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  17.3k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  17.3k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  17.3k|    do                                                                         \
  |  |  |  |  |  |  197|  17.3k|    {                                                                          \
  |  |  |  |  |  |  198|  17.3k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  17.3k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  17.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 17.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  17.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 17.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|  17.3k|                switch (TabEnt->State)                                         \
  |  |  404|  17.3k|                {                                                              \
  |  |  405|  1.98k|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|  1.98k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 1.98k, False: 15.4k]
  |  |  ------------------
  |  |  406|  1.98k|                        EOLcnt = 1;                                            \
  |  |  407|  1.98k|                        goto done1d;                                           \
  |  |  408|  14.5k|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|  14.5k|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 14.5k, False: 2.87k]
  |  |  ------------------
  |  |  409|  14.5k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  14.5k|    do                                                                         \
  |  |  |  |  267|  14.5k|    {                                                                          \
  |  |  |  |  268|  14.5k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 14.5k]
  |  |  |  |  ------------------
  |  |  |  |  269|  14.5k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  14.5k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  14.5k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  14.5k|        RunLength = 0;                                                         \
  |  |  |  |  279|  14.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 14.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|  14.5k|                        goto doneBlack1d;                                      \
  |  |  411|  14.5k|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|     19|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 19, False: 17.3k]
  |  |  ------------------
  |  |  412|    683|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|    683|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 664, False: 16.7k]
  |  |  ------------------
  |  |  413|    683|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|    683|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|    683|                        break;                                                 \
  |  |  416|    211|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 211, False: 17.1k]
  |  |  ------------------
  |  |  417|    211|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|    211|    do                                                                         \
  |  |  |  |  221|    211|    {                                                                          \
  |  |  |  |  222|    211|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    211|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    211|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 211]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|    211|                        goto done1d;                                           \
  |  |  419|  17.3k|                }                                                              \
  |  |  420|  17.3k|            }                                                                  \
  |  |  421|  16.7k|        doneBlack1d:                                                           \
  |  |  422|  14.5k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 3.81k, False: 10.7k]
  |  |  ------------------
  |  |  423|  14.5k|                goto done1d;                                                   \
  |  |  424|  14.5k|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 10.7k]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|  10.7k|                pa -= 2;                                                       \
  |  |  426|  10.7k|        }                                                                      \
  |  |  427|  88.8k|    eof1d:                                                                     \
  |  |  428|      0|        prematureEOF(a0);                                                      \
  |  |  ------------------
  |  |  |  |  271|      0|    do                                                                         \
  |  |  |  |  272|      0|    {                                                                          \
  |  |  |  |  273|      0|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|      0|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  429|      0|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|      0|    do                                                                         \
  |  |  |  |  334|      0|    {                                                                          \
  |  |  |  |  335|      0|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  336|      0|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|      0|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|      0|        {                                                                      \
  |  |  |  |  339|      0|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|      0|    do                                                                         \
  |  |  |  |  |  |  254|      0|    {                                                                          \
  |  |  |  |  |  |  255|      0|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|      0|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|      0|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|      0|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|      0|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|      0|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|      0|            {                                                                  \
  |  |  |  |  344|      0|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  345|      0|                    a0 = 0;                                                    \
  |  |  |  |  346|      0|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  347|      0|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|      0|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|      0|            }                                                                  \
  |  |  |  |  350|      0|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|      0|        }                                                                      \
  |  |  |  |  356|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|      0|        goto eoflab;                                                           \
  |  |  431|  88.8k|    done1d:                                                                    \
  |  |  432|  88.8k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  88.8k|    do                                                                         \
  |  |  |  |  334|  88.8k|    {                                                                          \
  |  |  |  |  335|  88.8k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 1.04k, False: 87.8k]
  |  |  |  |  ------------------
  |  |  |  |  336|  88.8k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  1.04k|    do                                                                         \
  |  |  |  |  |  |  267|  1.04k|    {                                                                          \
  |  |  |  |  |  |  268|  1.04k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.04k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  1.04k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  1.04k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  1.04k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  1.04k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  1.04k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 1.04k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  88.8k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 88.7k, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  338|  88.8k|        {                                                                      \
  |  |  |  |  339|  88.7k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  88.7k|    do                                                                         \
  |  |  |  |  |  |  254|  88.7k|    {                                                                          \
  |  |  |  |  |  |  255|  88.7k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  88.7k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  88.7k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  88.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 88.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|   100k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 11.4k, False: 88.7k]
  |  |  |  |  |  Branch (340:39): [True: 11.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  88.7k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  88.7k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 88.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  88.7k|            {                                                                  \
  |  |  |  |  344|  88.7k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 88.7k]
  |  |  |  |  ------------------
  |  |  |  |  345|  88.7k|                    a0 = 0;                                                    \
  |  |  |  |  346|  88.7k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 5.98k, False: 82.7k]
  |  |  |  |  ------------------
  |  |  |  |  347|  88.7k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  5.98k|    do                                                                         \
  |  |  |  |  |  |  267|  5.98k|    {                                                                          \
  |  |  |  |  |  |  268|  5.98k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 5.98k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  5.98k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  5.98k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  5.98k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  5.98k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  5.98k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 5.98k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  88.7k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  88.7k|    do                                                                         \
  |  |  |  |  |  |  267|  88.7k|    {                                                                          \
  |  |  |  |  |  |  268|  88.7k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 88.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  88.7k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  88.7k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  88.7k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  88.7k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  88.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 88.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  88.7k|            }                                                                  \
  |  |  |  |  350|  88.7k|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|  88.7k|        }                                                                      \
  |  |  |  |  356|  88.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 88.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  88.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 88.8k]
  |  |  ------------------
  ------------------
  358|  88.8k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  359|  88.8k|        buf += sp->b.rowbytes;
  360|  88.8k|        occ -= sp->b.rowbytes;
  361|  88.8k|        sp->line++;
  362|  88.8k|        continue;
  363|      0|    EOF1D: /* premature EOF */
  364|      0|        CLEANUP_RUNS();
  ------------------
  |  |  333|      0|    do                                                                         \
  |  |  334|      0|    {                                                                          \
  |  |  335|      0|        if (RunLength)                                                         \
  |  |  ------------------
  |  |  |  Branch (335:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  336|      0|            SETVALUE(0);                                                       \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  337|      0|        if (a0 != (int)lastx)                                                  \
  |  |  ------------------
  |  |  |  Branch (337:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  338|      0|        {                                                                      \
  |  |  339|      0|            badlength(a0, lastx);                                              \
  |  |  ------------------
  |  |  |  |  253|      0|    do                                                                         \
  |  |  |  |  254|      0|    {                                                                          \
  |  |  |  |  255|      0|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  256|      0|                      (uint32_t)(lastx));                                      \
  |  |  |  |  257|      0|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  258|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (258:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  340|      0|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  ------------------
  |  |  |  Branch (340:20): [True: 0, False: 0]
  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  ------------------
  |  |  341|      0|                a0 -= (int)*--pa;                                              \
  |  |  342|      0|            if (a0 < (int)lastx)                                               \
  |  |  ------------------
  |  |  |  Branch (342:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  343|      0|            {                                                                  \
  |  |  344|      0|                if (a0 < 0)                                                    \
  |  |  ------------------
  |  |  |  Branch (344:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  345|      0|                    a0 = 0;                                                    \
  |  |  346|      0|                if ((pa - thisrun) & 1)                                        \
  |  |  ------------------
  |  |  |  Branch (346:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  347|      0|                    SETVALUE(0);                                               \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  348|      0|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  349|      0|            }                                                                  \
  |  |  350|      0|            else if (a0 > (int)lastx)                                          \
  |  |  ------------------
  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  351|      0|            {                                                                  \
  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  354|      0|            }                                                                  \
  |  |  355|      0|        }                                                                      \
  |  |  356|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (356:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  365|      0|    EOF1Da: /* premature EOF */
  366|      0|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  367|      0|        UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      0|    do                                                                         \
  |  |  160|      0|    {                                                                          \
  |  |  161|      0|        sp->bit = BitsAvail;                                                   \
  |  |  162|      0|        sp->data = BitAcc;                                                     \
  |  |  163|      0|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      0|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      0|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  368|      0|        return (-1);
  369|      0|    }
  370|  6.35k|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|  6.35k|    do                                                                         \
  |  |  160|  6.35k|    {                                                                          \
  |  |  161|  6.35k|        sp->bit = BitsAvail;                                                   \
  |  |  162|  6.35k|        sp->data = BitAcc;                                                     \
  |  |  163|  6.35k|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|  6.35k|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|  6.35k|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|  6.35k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 6.35k]
  |  |  ------------------
  ------------------
  371|  6.35k|    return (1);
  372|  6.39k|}
tif_fax3.c:Fax3Cleanup:
 1329|    113|{
 1330|    113|    Fax3CodecState *sp = DecoderState(tif);
  ------------------
  |  |  108|    113|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|    113|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1331|       |
 1332|    113|    assert(sp != 0);
  ------------------
  |  Branch (1332:5): [True: 0, False: 113]
  |  Branch (1332:5): [True: 113, False: 0]
  ------------------
 1333|       |
 1334|    113|    tif->tif_tagmethods.vgetfield = sp->b.vgetparent;
 1335|    113|    tif->tif_tagmethods.vsetfield = sp->b.vsetparent;
 1336|    113|    tif->tif_tagmethods.printdir = sp->b.printdir;
 1337|       |
 1338|    113|    if (sp->runs)
  ------------------
  |  Branch (1338:9): [True: 69, False: 44]
  ------------------
 1339|     69|        _TIFFfreeExt(tif, sp->runs);
 1340|    113|    if (sp->refline)
  ------------------
  |  Branch (1340:9): [True: 20, False: 93]
  ------------------
 1341|     20|        _TIFFfreeExt(tif, sp->refline);
 1342|       |
 1343|    113|    _TIFFfreeExt(tif, tif->tif_data);
 1344|    113|    tif->tif_data = NULL;
 1345|       |
 1346|    113|    _TIFFSetDefaultCompressionState(tif);
 1347|    113|}
tif_fax3.c:Fax4Decode:
 1646|     26|{
 1647|     26|    DECLARE_STATE_2D(tif, sp, "Fax4Decode");
  ------------------
  |  |  139|     26|    DECLARE_STATE(tif, sp, mod);                                               \
  |  |  ------------------
  |  |  |  |  123|     26|    static const char module[] = mod;                                          \
  |  |  |  |  124|     26|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  108|     26|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   72|     26|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  125|     26|    int a0;                                   /* reference element */          \
  |  |  |  |  126|     26|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  |  |  127|     26|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  |  |  128|     26|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  |  |  129|     26|    int RunLength;                            /* length of current run */      \
  |  |  |  |  130|     26|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  |  |  131|     26|    unsigned char *ep;                        /* end of input data */          \
  |  |  |  |  132|     26|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  |  |  133|     26|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  |  |  134|     26|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  |  |  135|     26|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  |  |  136|     26|    const TIFFFaxTabEnt *TabEnt
  |  |  ------------------
  |  |  140|     26|    int b1; /* next change on prev line */                                     \
  |  |  141|     26|    uint32_t                                                                   \
  |  |  142|     26|        *pb /* next run in reference line */ /*                                \
  ------------------
 1648|     26|    (void)s;
 1649|     26|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (1649:9): [True: 0, False: 26]
  ------------------
 1650|      0|    {
 1651|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
 1652|      0|        return (-1);
 1653|      0|    }
 1654|     26|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (1654:9): [True: 0, False: 26]
  ------------------
 1655|      0|        return (-1);
 1656|     26|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|     26|    do                                                                         \
  |  |  148|     26|    {                                                                          \
  |  |  149|     26|        BitAcc = sp->data;                                                     \
  |  |  150|     26|        BitsAvail = sp->bit;                                                   \
  |  |  151|     26|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|     26|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|     26|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|     26|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1657|     26|    int start = sp->line;
 1658|     26|    while (occ > 0)
  ------------------
  |  Branch (1658:12): [True: 26, False: 0]
  ------------------
 1659|     26|    {
 1660|     26|        a0 = 0;
 1661|     26|        RunLength = 0;
 1662|     26|        pa = thisrun = sp->curruns;
 1663|     26|        pb = sp->refruns;
 1664|     26|        b1 = (int)*pb++;
 1665|       |#ifdef FAX3_DEBUG
 1666|       |        printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
 1667|       |        printf("-------------------- %d\n", tif->tif_dir.td_row);
 1668|       |        fflush(stdout);
 1669|       |#endif
 1670|     26|        EXPAND2D(EOFG4);
  ------------------
  |  |  463|     26|    do                                                                         \
  |  |  464|     26|    {                                                                          \
  |  |  465|     26|        while (a0 < (int)lastx)                                                \
  |  |  ------------------
  |  |  |  Branch (465:16): [True: 26, False: 0]
  |  |  ------------------
  |  |  466|     26|        {                                                                      \
  |  |  467|     26|            if (pa >= thisrun + sp->nruns)                                     \
  |  |  ------------------
  |  |  |  Branch (467:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  468|     26|            {                                                                  \
  |  |  469|      0|                TIFFErrorExtR(tif, module,                                     \
  |  |  470|      0|                              "Buffer overflow at line %d of %s %u", sp->line, \
  |  |  471|      0|                              isTiled(tif) ? "tile" : "strip",                 \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  472|      0|                              isTiled(tif) ? tif->tif_dir.td_curtile           \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  473|      0|                                           : tif->tif_dir.td_curstrip);        \
  |  |  474|      0|                return (-1);                                                   \
  |  |  475|      0|            }                                                                  \
  |  |  476|     26|            LOOKUP8(7, TIFFFaxMainTable, eof2d);                               \
  |  |  ------------------
  |  |  |  |  247|     26|    do                                                                         \
  |  |  |  |  248|     26|    {                                                                          \
  |  |  |  |  249|     26|        NeedBits8(wid, eoflab);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|     26|    do                                                                         \
  |  |  |  |  |  |  145|     26|    {                                                                          \
  |  |  |  |  |  |  146|     26|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:13): [True: 26, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  147|     26|        {                                                                      \
  |  |  |  |  |  |  148|     26|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|     26|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  149|     26|            {                                                                  \
  |  |  |  |  |  |  150|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (150:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  151|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  152|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  |  |  154|     26|            else                                                               \
  |  |  |  |  |  |  155|     26|            {                                                                  \
  |  |  |  |  |  |  156|     26|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  157|     26|                BitsAvail += 8;                                                \
  |  |  |  |  |  |  158|     26|            }                                                                  \
  |  |  |  |  |  |  159|     26|        }                                                                      \
  |  |  |  |  |  |  160|     26|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:14): [Folded, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  250|     26|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|     26|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  251|     26|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|     26|    do                                                                         \
  |  |  |  |  |  |  197|     26|    {                                                                          \
  |  |  |  |  |  |  198|     26|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|     26|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|     26|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  252|     26|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (252:14): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  477|     26|            switch (TabEnt->State)                                             \
  |  |  478|     26|            {                                                                  \
  |  |  479|      0|                case S_Pass:                                                   \
  |  |  ------------------
  |  |  |  |   71|      0|#define S_Pass 1
  |  |  ------------------
  |  |  |  Branch (479:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  480|      0|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|      0|    do                                                                         \
  |  |  |  |  441|      0|    {                                                                          \
  |  |  |  |  442|      0|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|      0|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (443:32): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|      0|            {                                                                  \
  |  |  |  |  445|      0|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  446|      0|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|      0|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|      0|                pb += 2;                                                       \
  |  |  |  |  456|      0|            }                                                                  \
  |  |  |  |  457|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  481|      0|                    if (pb + 1 >= sp->refruns + sp->nruns)                     \
  |  |  ------------------
  |  |  |  Branch (481:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  482|      0|                    {                                                          \
  |  |  483|      0|                        TIFFErrorExtR(                                         \
  |  |  484|      0|                            tif, module,                                       \
  |  |  485|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  486|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  487|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  488|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  489|      0|                        return (-1);                                           \
  |  |  490|      0|                    }                                                          \
  |  |  491|      0|                    b1 = b1 + (int)*pb++;                                      \
  |  |  492|      0|                    RunLength =                                                \
  |  |  493|      0|                        (int)((uint32_t)RunLength + (uint32_t)(b1 - a0));      \
  |  |  494|      0|                    a0 = b1;                                                   \
  |  |  495|      0|                    b1 = b1 + (int)*pb++;                                      \
  |  |  496|      0|                    break;                                                     \
  |  |  497|      0|                case S_Horiz:                                                  \
  |  |  ------------------
  |  |  |  |   72|      0|#define S_Horiz 2
  |  |  ------------------
  |  |  |  Branch (497:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  498|      0|                    if ((pa - thisrun) & 1)                                    \
  |  |  ------------------
  |  |  |  Branch (498:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  499|      0|                    {                                                          \
  |  |  500|      0|                        for (;;)                                               \
  |  |  501|      0|                        { /* black first */                                    \
  |  |  502|      0|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|      0|    do                                                                         \
  |  |  |  |  255|      0|    {                                                                          \
  |  |  |  |  256|      0|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|    do                                                                         \
  |  |  |  |  |  |  165|      0|    {                                                                          \
  |  |  |  |  |  |  166|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|        {                                                                      \
  |  |  |  |  |  |  168|      0|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|      0|            else                                                               \
  |  |  |  |  |  |  175|      0|            {                                                                  \
  |  |  |  |  |  |  176|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|      0|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      0|                {                                                              \
  |  |  |  |  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      0|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      0|                    else                                                       \
  |  |  |  |  |  |  185|      0|                    {                                                          \
  |  |  |  |  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      0|                    }                                                          \
  |  |  |  |  |  |  189|      0|                }                                                              \
  |  |  |  |  |  |  190|      0|            }                                                                  \
  |  |  |  |  |  |  191|      0|        }                                                                      \
  |  |  |  |  |  |  192|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|      0|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|      0|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  503|      0|                            switch (TabEnt->State)                             \
  |  |  504|      0|                            {                                                  \
  |  |  505|      0|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|      0|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (505:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  506|      0|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  507|      0|                                    goto doneWhite2da;                         \
  |  |  508|      0|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (508:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  509|      0|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      0|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (509:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  510|      0|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  511|      0|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  512|      0|                                                      TabEnt->Param);          \
  |  |  513|      0|                                    break;                                     \
  |  |  514|      0|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (514:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  515|      0|                                    goto badBlack2d;                           \
  |  |  516|      0|                            }                                                  \
  |  |  517|      0|                        }                                                      \
  |  |  518|      0|                    doneWhite2da:;                                             \
  |  |  519|      0|                        for (;;)                                               \
  |  |  520|      0|                        { /* then white */                                     \
  |  |  521|      0|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|      0|    do                                                                         \
  |  |  |  |  255|      0|    {                                                                          \
  |  |  |  |  256|      0|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|    do                                                                         \
  |  |  |  |  |  |  165|      0|    {                                                                          \
  |  |  |  |  |  |  166|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|        {                                                                      \
  |  |  |  |  |  |  168|      0|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|      0|            else                                                               \
  |  |  |  |  |  |  175|      0|            {                                                                  \
  |  |  |  |  |  |  176|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|      0|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      0|                {                                                              \
  |  |  |  |  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      0|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      0|                    else                                                       \
  |  |  |  |  |  |  185|      0|                    {                                                          \
  |  |  |  |  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      0|                    }                                                          \
  |  |  |  |  |  |  189|      0|                }                                                              \
  |  |  |  |  |  |  190|      0|            }                                                                  \
  |  |  |  |  |  |  191|      0|        }                                                                      \
  |  |  |  |  |  |  192|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|      0|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|      0|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  522|      0|                            switch (TabEnt->State)                             \
  |  |  523|      0|                            {                                                  \
  |  |  524|      0|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|      0|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (524:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  525|      0|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  526|      0|                                    goto doneBlack2da;                         \
  |  |  527|      0|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|      0|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (527:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  528|      0|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      0|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (528:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  529|      0|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  530|      0|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  531|      0|                                                      TabEnt->Param);          \
  |  |  532|      0|                                    break;                                     \
  |  |  533|      0|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (533:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  534|      0|                                    goto badWhite2d;                           \
  |  |  535|      0|                            }                                                  \
  |  |  536|      0|                        }                                                      \
  |  |  537|      0|                    doneBlack2da:;                                             \
  |  |  538|      0|                    }                                                          \
  |  |  539|      0|                    else                                                       \
  |  |  540|      0|                    {                                                          \
  |  |  541|      0|                        for (;;)                                               \
  |  |  542|      0|                        { /* white first */                                    \
  |  |  543|      0|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|      0|    do                                                                         \
  |  |  |  |  255|      0|    {                                                                          \
  |  |  |  |  256|      0|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|    do                                                                         \
  |  |  |  |  |  |  165|      0|    {                                                                          \
  |  |  |  |  |  |  166|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|        {                                                                      \
  |  |  |  |  |  |  168|      0|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|      0|            else                                                               \
  |  |  |  |  |  |  175|      0|            {                                                                  \
  |  |  |  |  |  |  176|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|      0|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      0|                {                                                              \
  |  |  |  |  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      0|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      0|                    else                                                       \
  |  |  |  |  |  |  185|      0|                    {                                                          \
  |  |  |  |  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      0|                    }                                                          \
  |  |  |  |  |  |  189|      0|                }                                                              \
  |  |  |  |  |  |  190|      0|            }                                                                  \
  |  |  |  |  |  |  191|      0|        }                                                                      \
  |  |  |  |  |  |  192|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|      0|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|      0|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  544|      0|                            switch (TabEnt->State)                             \
  |  |  545|      0|                            {                                                  \
  |  |  546|      0|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|      0|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (546:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  547|      0|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  548|      0|                                    goto doneWhite2db;                         \
  |  |  549|      0|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|      0|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (549:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      0|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (550:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  551|      0|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  552|      0|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  553|      0|                                                      TabEnt->Param);          \
  |  |  554|      0|                                    break;                                     \
  |  |  555|      0|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (555:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  556|      0|                                    goto badWhite2d;                           \
  |  |  557|      0|                            }                                                  \
  |  |  558|      0|                        }                                                      \
  |  |  559|      0|                    doneWhite2db:;                                             \
  |  |  560|      0|                        for (;;)                                               \
  |  |  561|      0|                        { /* then black */                                     \
  |  |  562|      0|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|      0|    do                                                                         \
  |  |  |  |  255|      0|    {                                                                          \
  |  |  |  |  256|      0|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|    do                                                                         \
  |  |  |  |  |  |  165|      0|    {                                                                          \
  |  |  |  |  |  |  166|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|        {                                                                      \
  |  |  |  |  |  |  168|      0|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|            {                                                                  \
  |  |  |  |  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      0|            }                                                                  \
  |  |  |  |  |  |  174|      0|            else                                                               \
  |  |  |  |  |  |  175|      0|            {                                                                  \
  |  |  |  |  |  |  176|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|      0|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      0|                {                                                              \
  |  |  |  |  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      0|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      0|                    else                                                       \
  |  |  |  |  |  |  185|      0|                    {                                                          \
  |  |  |  |  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      0|                    }                                                          \
  |  |  |  |  |  |  189|      0|                }                                                              \
  |  |  |  |  |  |  190|      0|            }                                                                  \
  |  |  |  |  |  |  191|      0|        }                                                                      \
  |  |  |  |  |  |  192|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|      0|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|      0|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  563|      0|                            switch (TabEnt->State)                             \
  |  |  564|      0|                            {                                                  \
  |  |  565|      0|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|      0|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (565:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  566|      0|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  567|      0|                                    goto doneBlack2db;                         \
  |  |  568|      0|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (568:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  569|      0|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      0|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (569:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  570|      0|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  571|      0|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  572|      0|                                                      TabEnt->Param);          \
  |  |  573|      0|                                    break;                                     \
  |  |  574|      0|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (574:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  575|      0|                                    goto badBlack2d;                           \
  |  |  576|      0|                            }                                                  \
  |  |  577|      0|                        }                                                      \
  |  |  578|      0|                    doneBlack2db:;                                             \
  |  |  579|      0|                    }                                                          \
  |  |  580|      0|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|      0|    do                                                                         \
  |  |  |  |  441|      0|    {                                                                          \
  |  |  |  |  442|      0|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|      0|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (443:32): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|      0|            {                                                                  \
  |  |  |  |  445|      0|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  446|      0|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|      0|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|      0|                pb += 2;                                                       \
  |  |  |  |  456|      0|            }                                                                  \
  |  |  |  |  457|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  581|      0|                    break;                                                     \
  |  |  582|      0|                case S_V0:                                                     \
  |  |  ------------------
  |  |  |  |   73|      0|#define S_V0 3
  |  |  ------------------
  |  |  |  Branch (582:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  583|      0|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|      0|    do                                                                         \
  |  |  |  |  441|      0|    {                                                                          \
  |  |  |  |  442|      0|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|      0|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (443:32): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|      0|            {                                                                  \
  |  |  |  |  445|      0|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  446|      0|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|      0|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|      0|                pb += 2;                                                       \
  |  |  |  |  456|      0|            }                                                                  \
  |  |  |  |  457|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  584|      0|                    SETVALUE(b1 - a0);                                         \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  585|      0|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (585:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  586|      0|                    {                                                          \
  |  |  587|      0|                        TIFFErrorExtR(                                         \
  |  |  588|      0|                            tif, module,                                       \
  |  |  589|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  590|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  591|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  592|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  593|      0|                        return (-1);                                           \
  |  |  594|      0|                    }                                                          \
  |  |  595|      0|                    b1 = b1 + (int)*pb++;                                      \
  |  |  596|      0|                    break;                                                     \
  |  |  597|      0|                case S_VR:                                                     \
  |  |  ------------------
  |  |  |  |   74|      0|#define S_VR 4
  |  |  ------------------
  |  |  |  Branch (597:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  598|      0|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|      0|    do                                                                         \
  |  |  |  |  441|      0|    {                                                                          \
  |  |  |  |  442|      0|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|      0|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (443:32): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|      0|            {                                                                  \
  |  |  |  |  445|      0|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  446|      0|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|      0|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|      0|                pb += 2;                                                       \
  |  |  |  |  456|      0|            }                                                                  \
  |  |  |  |  457|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  599|      0|                    SETVALUE((int)((uint32_t)(b1 - a0) + TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  600|      0|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (600:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  601|      0|                    {                                                          \
  |  |  602|      0|                        TIFFErrorExtR(                                         \
  |  |  603|      0|                            tif, module,                                       \
  |  |  604|      0|                            "Buffer overflow at line %d of %s %u", sp->line,   \
  |  |  605|      0|                            isTiled(tif) ? "tile" : "strip",                   \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  606|      0|                            isTiled(tif) ? tif->tif_dir.td_curtile             \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  607|      0|                                         : tif->tif_dir.td_curstrip);          \
  |  |  608|      0|                        return (-1);                                           \
  |  |  609|      0|                    }                                                          \
  |  |  610|      0|                    b1 = b1 + (int)*pb++;                                      \
  |  |  611|      0|                    break;                                                     \
  |  |  612|      0|                case S_VL:                                                     \
  |  |  ------------------
  |  |  |  |   75|      0|#define S_VL 5
  |  |  ------------------
  |  |  |  Branch (612:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  613|      0|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|      0|    do                                                                         \
  |  |  |  |  441|      0|    {                                                                          \
  |  |  |  |  442|      0|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|      0|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (443:32): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|      0|            {                                                                  \
  |  |  |  |  445|      0|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  446|      0|                {                                                              \
  |  |  |  |  447|      0|                    TIFFErrorExtR(tif, module,                                 \
  |  |  |  |  448|      0|                                  "Buffer overflow at line %d of %s %u",       \
  |  |  |  |  449|      0|                                  sp->line, isTiled(tif) ? "tile" : "strip",   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  450|      0|                                  isTiled(tif) ? tif->tif_dir.td_curtile       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  451|      0|                                               : tif->tif_dir.td_curstrip);    \
  |  |  |  |  452|      0|                    return (-1);                                               \
  |  |  |  |  453|      0|                }                                                              \
  |  |  |  |  454|      0|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|      0|                pb += 2;                                                       \
  |  |  |  |  456|      0|            }                                                                  \
  |  |  |  |  457|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  614|      0|                    if (b1 < (int)((uint32_t)a0 + TabEnt->Param))              \
  |  |  ------------------
  |  |  |  Branch (614:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  615|      0|                    {                                                          \
  |  |  616|      0|                        unexpected("VL", a0);                                  \
  |  |  ------------------
  |  |  |  |  220|      0|    do                                                                         \
  |  |  |  |  221|      0|    {                                                                          \
  |  |  |  |  222|      0|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      0|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  617|      0|                        goto eol2d;                                            \
  |  |  618|      0|                    }                                                          \
  |  |  619|      0|                    SETVALUE((int)((uint32_t)(b1 - a0) - TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  620|      0|                    b1 = b1 - (int)*--pb;                                      \
  |  |  621|      0|                    break;                                                     \
  |  |  622|      0|                case S_Ext:                                                    \
  |  |  ------------------
  |  |  |  |   76|      0|#define S_Ext 6
  |  |  ------------------
  |  |  |  Branch (622:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  623|      0|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  624|      0|                    extension(a0);                                             \
  |  |  ------------------
  |  |  |  |  238|      0|    Fax3Extension(module, tif, (uint32_t)sp->line, (uint32_t)(a0))
  |  |  ------------------
  |  |  625|      0|                    goto eol2d;                                                \
  |  |  626|     26|                case S_EOL:                                                    \
  |  |  ------------------
  |  |  |  |   82|     26|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (626:17): [True: 26, False: 0]
  |  |  ------------------
  |  |  627|     26|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  628|     26|                    NeedBits8(4, eof2d);                                       \
  |  |  ------------------
  |  |  |  |  144|     26|    do                                                                         \
  |  |  |  |  145|     26|    {                                                                          \
  |  |  |  |  146|     26|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  147|     26|        {                                                                      \
  |  |  |  |  148|     26|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|     26|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|     26|            {                                                                  \
  |  |  |  |  150|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  151|      0|                    goto eoflab;                                               \
  |  |  |  |  152|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  154|     26|            else                                                               \
  |  |  |  |  155|     26|            {                                                                  \
  |  |  |  |  156|     26|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|     26|                BitsAvail += 8;                                                \
  |  |  |  |  158|     26|            }                                                                  \
  |  |  |  |  159|     26|        }                                                                      \
  |  |  |  |  160|     26|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  629|     26|                    if (GetBits(4))                                            \
  |  |  ------------------
  |  |  |  |  194|     26|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 18, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  630|     26|                        unexpected("EOL", a0);                                 \
  |  |  ------------------
  |  |  |  |  220|     18|    do                                                                         \
  |  |  |  |  221|     18|    {                                                                          \
  |  |  |  |  222|     18|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     18|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     18|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  631|     26|                    ClrBits(4);                                                \
  |  |  ------------------
  |  |  |  |  196|     26|    do                                                                         \
  |  |  |  |  197|     26|    {                                                                          \
  |  |  |  |  198|     26|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|     26|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|     26|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  632|     26|                    EOLcnt = 1;                                                \
  |  |  633|     26|                    goto eol2d;                                                \
  |  |  634|     26|                default:                                                       \
  |  |  ------------------
  |  |  |  Branch (634:17): [True: 0, False: 26]
  |  |  ------------------
  |  |  635|      0|                badMain2d:                                                     \
  |  |  636|      0|                    unexpected("MainTable", a0);                               \
  |  |  ------------------
  |  |  |  |  220|      0|    do                                                                         \
  |  |  |  |  221|      0|    {                                                                          \
  |  |  |  |  222|      0|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      0|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  637|      0|                    goto eol2d;                                                \
  |  |  638|      0|                badBlack2d:                                                    \
  |  |  639|      0|                    unexpected("BlackTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|      0|    do                                                                         \
  |  |  |  |  221|      0|    {                                                                          \
  |  |  |  |  222|      0|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      0|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  640|      0|                    goto eol2d;                                                \
  |  |  641|      0|                badWhite2d:                                                    \
  |  |  642|      0|                    unexpected("WhiteTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|      0|    do                                                                         \
  |  |  |  |  221|      0|    {                                                                          \
  |  |  |  |  222|      0|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      0|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  643|      0|                    goto eol2d;                                                \
  |  |  644|      0|                eof2d:                                                         \
  |  |  645|      0|                    prematureEOF(a0);                                          \
  |  |  ------------------
  |  |  |  |  271|      0|    do                                                                         \
  |  |  |  |  272|      0|    {                                                                          \
  |  |  |  |  273|      0|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|      0|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  646|      0|                    CLEANUP_RUNS();                                            \
  |  |  ------------------
  |  |  |  |  333|      0|    do                                                                         \
  |  |  |  |  334|      0|    {                                                                          \
  |  |  |  |  335|      0|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  336|      0|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|      0|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|      0|        {                                                                      \
  |  |  |  |  339|      0|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|      0|    do                                                                         \
  |  |  |  |  |  |  254|      0|    {                                                                          \
  |  |  |  |  |  |  255|      0|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|      0|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|      0|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|      0|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 0]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|      0|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|      0|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|      0|            {                                                                  \
  |  |  |  |  344|      0|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  345|      0|                    a0 = 0;                                                    \
  |  |  |  |  346|      0|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  347|      0|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|      0|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|      0|            }                                                                  \
  |  |  |  |  350|      0|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|      0|        }                                                                      \
  |  |  |  |  356|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  647|      0|                    goto eoflab;                                               \
  |  |  648|     26|            }                                                                  \
  |  |  649|     26|        }                                                                      \
  |  |  650|     26|        if (RunLength)                                                         \
  |  |  ------------------
  |  |  |  Branch (650:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  651|      0|        {                                                                      \
  |  |  652|      0|            if (RunLength + a0 < lastx)                                        \
  |  |  ------------------
  |  |  |  Branch (652:17): [True: 0, False: 0]
  |  |  ------------------
  |  |  653|      0|            {                                                                  \
  |  |  654|      0|                /* expect a final V0 */                                        \
  |  |  655|      0|                NeedBits8(1, eof2d);                                           \
  |  |  ------------------
  |  |  |  |  144|      0|    do                                                                         \
  |  |  |  |  145|      0|    {                                                                          \
  |  |  |  |  146|      0|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  147|      0|        {                                                                      \
  |  |  |  |  148|      0|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|      0|            {                                                                  \
  |  |  |  |  150|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  151|      0|                    goto eoflab;                                               \
  |  |  |  |  152|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  154|      0|            else                                                               \
  |  |  |  |  155|      0|            {                                                                  \
  |  |  |  |  156|      0|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|      0|                BitsAvail += 8;                                                \
  |  |  |  |  158|      0|            }                                                                  \
  |  |  |  |  159|      0|        }                                                                      \
  |  |  |  |  160|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  656|      0|                if (!GetBits(1))                                               \
  |  |  ------------------
  |  |  |  |  194|      0|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (656:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  657|      0|                    goto badMain2d;                                            \
  |  |  658|      0|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|      0|    do                                                                         \
  |  |  |  |  197|      0|    {                                                                          \
  |  |  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  659|      0|            }                                                                  \
  |  |  660|      0|            SETVALUE(0);                                                       \
  |  |  ------------------
  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  661|      0|        }                                                                      \
  |  |  662|     26|    eol2d:                                                                     \
  |  |  663|     26|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|     26|    do                                                                         \
  |  |  |  |  334|     26|    {                                                                          \
  |  |  |  |  335|     26|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  336|     26|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|     26|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|     26|        {                                                                      \
  |  |  |  |  339|     26|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|     26|    do                                                                         \
  |  |  |  |  |  |  254|     26|    {                                                                          \
  |  |  |  |  |  |  255|     26|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|     26|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|     26|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|     26|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|     26|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 26]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|     26|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|     26|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|     26|            {                                                                  \
  |  |  |  |  344|     26|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  345|     26|                    a0 = 0;                                                    \
  |  |  |  |  346|     26|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  347|     26|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     26|    do                                                                         \
  |  |  |  |  |  |  267|     26|    {                                                                          \
  |  |  |  |  |  |  268|     26|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     26|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|     26|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     26|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     26|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     26|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|     26|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     26|    do                                                                         \
  |  |  |  |  |  |  267|     26|    {                                                                          \
  |  |  |  |  |  |  268|     26|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     26|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|     26|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     26|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     26|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     26|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|     26|            }                                                                  \
  |  |  |  |  350|     26|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|     26|        }                                                                      \
  |  |  |  |  356|     26|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  664|     26|    } while (0)
  |  |  ------------------
  |  |  |  Branch (664:14): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1671|     26|        if (EOLcnt)
  ------------------
  |  Branch (1671:13): [True: 26, False: 0]
  ------------------
 1672|     26|            goto EOFG4;
 1673|      0|        if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
  ------------------
  |  Branch (1673:13): [True: 0, False: 0]
  ------------------
 1674|      0|        {
 1675|      0|            TIFFErrorExtR(tif, module,
 1676|      0|                          "Buffer overrun detected : %" TIFF_SSIZE_FORMAT
 1677|      0|                          " bytes available, %d bits needed",
 1678|      0|                          occ, lastx);
 1679|      0|            return -1;
 1680|      0|        }
 1681|      0|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1682|      0|        SETVALUE(0); /* imaginary change for reference */
  ------------------
  |  |  266|      0|    do                                                                         \
  |  |  267|      0|    {                                                                          \
  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  ------------------
  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  269|      0|        {                                                                      \
  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  ------------------
  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  274|      0|            return (-1);                                                       \
  |  |  275|      0|        }                                                                      \
  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  279|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1683|      0|        SWAP(uint32_t *, sp->curruns, sp->refruns);
  ------------------
  |  | 1636|      0|    {                                                                          \
  |  | 1637|      0|        t x;                                                                   \
  |  | 1638|      0|        x = (a);                                                               \
  |  | 1639|      0|        (a) = (b);                                                             \
  |  | 1640|      0|        (b) = x;                                                               \
  |  | 1641|      0|    }
  ------------------
 1684|      0|        buf += sp->b.rowbytes;
 1685|      0|        occ -= sp->b.rowbytes;
 1686|      0|        sp->line++;
 1687|      0|        continue;
 1688|     26|    EOFG4:
 1689|     26|        NeedBits16(13, BADG4);
  ------------------
  |  |  164|     26|    do                                                                         \
  |  |  165|     26|    {                                                                          \
  |  |  166|     26|        if (BitsAvail < (n))                                                   \
  |  |  ------------------
  |  |  |  Branch (166:13): [True: 26, False: 0]
  |  |  ------------------
  |  |  167|     26|        {                                                                      \
  |  |  168|     26|            if (EndOfData())                                                   \
  |  |  ------------------
  |  |  |  |  117|     26|#define EndOfData() (cp >= ep)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (117:21): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  169|     26|            {                                                                  \
  |  |  170|      0|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  ------------------
  |  |  |  Branch (170:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  171|      0|                    goto eoflab;                                               \
  |  |  172|      0|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  173|      0|            }                                                                  \
  |  |  174|     26|            else                                                               \
  |  |  175|     26|            {                                                                  \
  |  |  176|     26|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  177|     26|                if ((BitsAvail += 8) < (n))                                    \
  |  |  ------------------
  |  |  |  Branch (177:21): [True: 0, False: 26]
  |  |  ------------------
  |  |  178|     26|                {                                                              \
  |  |  179|      0|                    if (EndOfData())                                           \
  |  |  ------------------
  |  |  |  |  117|      0|#define EndOfData() (cp >= ep)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (117:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  180|      0|                    {                                                          \
  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  183|      0|                    }                                                          \
  |  |  184|      0|                    else                                                       \
  |  |  185|      0|                    {                                                          \
  |  |  186|      0|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  187|      0|                        BitsAvail += 8;                                        \
  |  |  188|      0|                    }                                                          \
  |  |  189|      0|                }                                                              \
  |  |  190|     26|            }                                                                  \
  |  |  191|     26|        }                                                                      \
  |  |  192|     26|    } while (0)
  |  |  ------------------
  |  |  |  Branch (192:14): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1690|     26|    BADG4:
 1691|       |#ifdef FAX3_DEBUG
 1692|       |        if (GetBits(13) != 0x1001)
 1693|       |            fputs("Bad EOFB\n", stderr);
 1694|       |#endif
 1695|     26|        ClrBits(13);
  ------------------
  |  |  196|     26|    do                                                                         \
  |  |  197|     26|    {                                                                          \
  |  |  198|     26|        BitsAvail -= (n);                                                      \
  |  |  199|     26|        BitAcc >>= (n);                                                        \
  |  |  200|     26|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1696|     26|        if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
  ------------------
  |  Branch (1696:13): [True: 0, False: 26]
  ------------------
 1697|      0|        {
 1698|      0|            TIFFErrorExtR(tif, module,
 1699|      0|                          "Buffer overrun detected : %" TIFF_SSIZE_FORMAT
 1700|      0|                          " bytes available, %d bits needed",
 1701|      0|                          occ, lastx);
 1702|      0|            return -1;
 1703|      0|        }
 1704|     26|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1705|     26|        UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|     26|    do                                                                         \
  |  |  160|     26|    {                                                                          \
  |  |  161|     26|        sp->bit = BitsAvail;                                                   \
  |  |  162|     26|        sp->data = BitAcc;                                                     \
  |  |  163|     26|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|     26|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|     26|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|     26|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1706|     26|        return (sp->line != start
  ------------------
  |  Branch (1706:17): [True: 0, False: 26]
  ------------------
 1707|     26|                    ? 1
 1708|     26|                    : -1); /* don't error on badly-terminated strips */
 1709|     26|    }
 1710|      0|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      0|    do                                                                         \
  |  |  160|      0|    {                                                                          \
  |  |  161|      0|        sp->bit = BitsAvail;                                                   \
  |  |  162|      0|        sp->data = BitAcc;                                                     \
  |  |  163|      0|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      0|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      0|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1711|      0|    return (1);
 1712|     26|}
tif_fax3.c:Fax3DecodeRLE:
 1802|    268|{
 1803|    268|    DECLARE_STATE(tif, sp, "Fax3DecodeRLE");
  ------------------
  |  |  123|    268|    static const char module[] = mod;                                          \
  |  |  124|    268|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  ------------------
  |  |  |  |  108|    268|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|    268|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  125|    268|    int a0;                                   /* reference element */          \
  |  |  126|    268|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  127|    268|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  128|    268|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  129|    268|    int RunLength;                            /* length of current run */      \
  |  |  130|    268|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  131|    268|    unsigned char *ep;                        /* end of input data */          \
  |  |  132|    268|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  133|    268|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  134|    268|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  135|    268|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  136|    268|    const TIFFFaxTabEnt *TabEnt
  ------------------
 1804|    268|    int mode = sp->b.mode;
 1805|    268|    (void)s;
 1806|    268|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (1806:9): [True: 0, False: 268]
  ------------------
 1807|      0|    {
 1808|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
 1809|      0|        return (-1);
 1810|      0|    }
 1811|    268|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (1811:9): [True: 0, False: 268]
  ------------------
 1812|      0|        return (-1);
 1813|    268|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|    268|    do                                                                         \
  |  |  148|    268|    {                                                                          \
  |  |  149|    268|        BitAcc = sp->data;                                                     \
  |  |  150|    268|        BitsAvail = sp->bit;                                                   \
  |  |  151|    268|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|    268|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|    268|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|    268|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 268]
  |  |  ------------------
  ------------------
 1814|    268|    thisrun = sp->curruns;
 1815|  59.2k|    while (occ > 0)
  ------------------
  |  Branch (1815:12): [True: 58.9k, False: 258]
  ------------------
 1816|  58.9k|    {
 1817|  58.9k|        a0 = 0;
 1818|  58.9k|        RunLength = 0;
 1819|  58.9k|        pa = thisrun;
 1820|       |#ifdef FAX3_DEBUG
 1821|       |        printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
 1822|       |        printf("-------------------- %" PRIu32 "\n", tif->tif_dir.td_row);
 1823|       |        fflush(stdout);
 1824|       |#endif
 1825|  58.9k|        EXPAND1D(EOFRLE);
  ------------------
  |  |  371|  58.9k|    do                                                                         \
  |  |  372|  58.9k|    {                                                                          \
  |  |  373|  58.9k|        for (;;)                                                               \
  |  |  374|  60.9k|        {                                                                      \
  |  |  375|  60.9k|            for (;;)                                                           \
  |  |  376|  61.6k|            {                                                                  \
  |  |  377|  61.6k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  61.6k|    do                                                                         \
  |  |  |  |  255|  61.6k|    {                                                                          \
  |  |  |  |  256|  61.6k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  61.6k|    do                                                                         \
  |  |  |  |  |  |  165|  61.6k|    {                                                                          \
  |  |  |  |  |  |  166|  61.6k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 5.59k, False: 56.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  61.6k|        {                                                                      \
  |  |  |  |  |  |  168|  5.59k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  5.59k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 19, False: 5.57k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  5.59k|            {                                                                  \
  |  |  |  |  |  |  170|     19|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 10, False: 9]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     19|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|     19|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      9|            }                                                                  \
  |  |  |  |  |  |  174|  5.59k|            else                                                               \
  |  |  |  |  |  |  175|  5.59k|            {                                                                  \
  |  |  |  |  |  |  176|  5.57k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  5.57k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 2.25k, False: 3.31k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  5.57k|                {                                                              \
  |  |  |  |  |  |  179|  2.25k|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  2.25k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 3, False: 2.25k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|  2.25k|                    {                                                          \
  |  |  |  |  |  |  181|      3|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      3|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      3|                    }                                                          \
  |  |  |  |  |  |  184|  2.25k|                    else                                                       \
  |  |  |  |  |  |  185|  2.25k|                    {                                                          \
  |  |  |  |  |  |  186|  2.25k|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|  2.25k|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|  2.25k|                    }                                                          \
  |  |  |  |  |  |  189|  2.25k|                }                                                              \
  |  |  |  |  |  |  190|  5.57k|            }                                                                  \
  |  |  |  |  |  |  191|  5.59k|        }                                                                      \
  |  |  |  |  |  |  192|  61.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 61.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  61.6k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  61.6k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  61.6k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  61.6k|    do                                                                         \
  |  |  |  |  |  |  197|  61.6k|    {                                                                          \
  |  |  |  |  |  |  198|  61.6k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  61.6k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  61.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 61.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  61.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 61.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|  61.6k|                switch (TabEnt->State)                                         \
  |  |  379|  61.6k|                {                                                              \
  |  |  380|  1.08k|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|  1.08k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 1.08k, False: 60.5k]
  |  |  ------------------
  |  |  381|  1.08k|                        EOLcnt = 1;                                            \
  |  |  382|  1.08k|                        goto done1d;                                           \
  |  |  383|  5.13k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  5.13k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 5.13k, False: 56.5k]
  |  |  ------------------
  |  |  384|  5.13k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  5.13k|    do                                                                         \
  |  |  |  |  267|  5.13k|    {                                                                          \
  |  |  |  |  268|  5.13k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 5.13k]
  |  |  |  |  ------------------
  |  |  |  |  269|  5.13k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  5.13k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  5.13k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  5.13k|        RunLength = 0;                                                         \
  |  |  |  |  279|  5.13k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 5.13k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  5.13k|                        goto doneWhite1d;                                      \
  |  |  386|  5.13k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|    435|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 435, False: 61.2k]
  |  |  ------------------
  |  |  387|    733|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|    733|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 298, False: 61.3k]
  |  |  ------------------
  |  |  388|    733|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|    733|                        RunLength =                                            \
  |  |  390|    733|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|    733|                        break;                                                 \
  |  |  392|  54.7k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 54.7k, False: 6.95k]
  |  |  ------------------
  |  |  393|  54.7k|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|  54.7k|    do                                                                         \
  |  |  |  |  221|  54.7k|    {                                                                          \
  |  |  |  |  222|  54.7k|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|  54.7k|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|  54.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 54.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|  54.7k|                        goto done1d;                                           \
  |  |  395|  61.6k|                }                                                              \
  |  |  396|  61.6k|            }                                                                  \
  |  |  397|  60.9k|        doneWhite1d:                                                           \
  |  |  398|  5.13k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 2.12k, False: 3.01k]
  |  |  ------------------
  |  |  399|  5.13k|                goto done1d;                                                   \
  |  |  400|  5.13k|            for (;;)                                                           \
  |  |  401|  3.03k|            {                                                                  \
  |  |  402|  3.03k|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  3.03k|    do                                                                         \
  |  |  |  |  255|  3.03k|    {                                                                          \
  |  |  |  |  256|  3.03k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  3.03k|    do                                                                         \
  |  |  |  |  |  |  165|  3.03k|    {                                                                          \
  |  |  |  |  |  |  166|  3.03k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 2.38k, False: 652]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  3.03k|        {                                                                      \
  |  |  |  |  |  |  168|  2.38k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  2.38k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 7, False: 2.38k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  2.38k|            {                                                                  \
  |  |  |  |  |  |  170|      7|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      7|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      7|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      7|            }                                                                  \
  |  |  |  |  |  |  174|  2.38k|            else                                                               \
  |  |  |  |  |  |  175|  2.38k|            {                                                                  \
  |  |  |  |  |  |  176|  2.38k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  2.38k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 12, False: 2.36k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  2.38k|                {                                                              \
  |  |  |  |  |  |  179|     12|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|     12|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 12]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|     12|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|     12|                    else                                                       \
  |  |  |  |  |  |  185|     12|                    {                                                          \
  |  |  |  |  |  |  186|     12|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|     12|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|     12|                    }                                                          \
  |  |  |  |  |  |  189|     12|                }                                                              \
  |  |  |  |  |  |  190|  2.38k|            }                                                                  \
  |  |  |  |  |  |  191|  2.38k|        }                                                                      \
  |  |  |  |  |  |  192|  3.03k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 3.03k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  3.03k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  3.03k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  3.03k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  3.03k|    do                                                                         \
  |  |  |  |  |  |  197|  3.03k|    {                                                                          \
  |  |  |  |  |  |  198|  3.03k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  3.03k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  3.03k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 3.03k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  3.03k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 3.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|  3.03k|                switch (TabEnt->State)                                         \
  |  |  404|  3.03k|                {                                                              \
  |  |  405|    216|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    216|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 216, False: 2.82k]
  |  |  ------------------
  |  |  406|    216|                        EOLcnt = 1;                                            \
  |  |  407|    216|                        goto done1d;                                           \
  |  |  408|  2.78k|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|  2.78k|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 2.78k, False: 252]
  |  |  ------------------
  |  |  409|  2.78k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  2.78k|    do                                                                         \
  |  |  |  |  267|  2.78k|    {                                                                          \
  |  |  |  |  268|  2.78k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 2.78k]
  |  |  |  |  ------------------
  |  |  |  |  269|  2.78k|        {                                                                      \
  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  276|  2.78k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  2.78k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  2.78k|        RunLength = 0;                                                         \
  |  |  |  |  279|  2.78k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 2.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|  2.78k|                        goto doneBlack1d;                                      \
  |  |  411|  2.78k|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|     12|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 12, False: 3.02k]
  |  |  ------------------
  |  |  412|     24|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|     24|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 12, False: 3.02k]
  |  |  ------------------
  |  |  413|     24|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|     24|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|     24|                        break;                                                 \
  |  |  416|     12|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 12, False: 3.02k]
  |  |  ------------------
  |  |  417|     12|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|     12|    do                                                                         \
  |  |  |  |  221|     12|    {                                                                          \
  |  |  |  |  222|     12|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     12|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     12|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|     12|                        goto done1d;                                           \
  |  |  419|  3.03k|                }                                                              \
  |  |  420|  3.03k|            }                                                                  \
  |  |  421|  3.01k|        doneBlack1d:                                                           \
  |  |  422|  2.78k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 802, False: 1.98k]
  |  |  ------------------
  |  |  423|  2.78k|                goto done1d;                                                   \
  |  |  424|  2.78k|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 1.98k]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|  1.98k|                pa -= 2;                                                       \
  |  |  426|  1.98k|        }                                                                      \
  |  |  427|  58.9k|    eof1d:                                                                     \
  |  |  428|     10|        prematureEOF(a0);                                                      \
  |  |  ------------------
  |  |  |  |  271|     10|    do                                                                         \
  |  |  |  |  272|     10|    {                                                                          \
  |  |  |  |  273|     10|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|     10|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|     10|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  429|     10|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|     10|    do                                                                         \
  |  |  |  |  334|     10|    {                                                                          \
  |  |  |  |  335|     10|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  336|     10|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|     10|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|     10|        {                                                                      \
  |  |  |  |  339|     10|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|     10|    do                                                                         \
  |  |  |  |  |  |  254|     10|    {                                                                          \
  |  |  |  |  |  |  255|     10|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|     10|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|     10|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|     10|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 10]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|     10|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 10]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|     10|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|     10|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|     10|            {                                                                  \
  |  |  |  |  344|     10|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  345|     10|                    a0 = 0;                                                    \
  |  |  |  |  346|     10|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  347|     10|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|     10|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     10|    do                                                                         \
  |  |  |  |  |  |  267|     10|    {                                                                          \
  |  |  |  |  |  |  268|     10|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 10]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     10|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|     10|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     10|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     10|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     10|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 10]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|     10|            }                                                                  \
  |  |  |  |  350|     10|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|     10|        }                                                                      \
  |  |  |  |  356|     10|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|     10|        goto eoflab;                                                           \
  |  |  431|  58.9k|    done1d:                                                                    \
  |  |  432|  58.9k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  58.9k|    do                                                                         \
  |  |  |  |  334|  58.9k|    {                                                                          \
  |  |  |  |  335|  58.9k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 128, False: 58.8k]
  |  |  |  |  ------------------
  |  |  |  |  336|  58.9k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|    128|    do                                                                         \
  |  |  |  |  |  |  267|    128|    {                                                                          \
  |  |  |  |  |  |  268|    128|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 128]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|    128|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|    128|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|    128|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|    128|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|    128|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 128]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  58.9k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 58.7k, False: 177]
  |  |  |  |  ------------------
  |  |  |  |  338|  58.9k|        {                                                                      \
  |  |  |  |  339|  58.7k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  58.7k|    do                                                                         \
  |  |  |  |  |  |  254|  58.7k|    {                                                                          \
  |  |  |  |  |  |  255|  58.7k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  58.7k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  58.7k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  58.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 58.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  61.6k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 2.87k, False: 58.7k]
  |  |  |  |  |  Branch (340:39): [True: 2.87k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  58.7k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  58.7k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 58.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  58.7k|            {                                                                  \
  |  |  |  |  344|  58.7k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 58.7k]
  |  |  |  |  ------------------
  |  |  |  |  345|  58.7k|                    a0 = 0;                                                    \
  |  |  |  |  346|  58.7k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 948, False: 57.8k]
  |  |  |  |  ------------------
  |  |  |  |  347|  58.7k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|    948|    do                                                                         \
  |  |  |  |  |  |  267|    948|    {                                                                          \
  |  |  |  |  |  |  268|    948|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 948]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|    948|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|    948|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|    948|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|    948|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|    948|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 948]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  58.7k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  58.7k|    do                                                                         \
  |  |  |  |  |  |  267|  58.7k|    {                                                                          \
  |  |  |  |  |  |  268|  58.7k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 58.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  58.7k|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|  58.7k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  58.7k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  58.7k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  58.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 58.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  58.7k|            }                                                                  \
  |  |  |  |  350|  58.7k|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|            {                                                                  \
  |  |  |  |  352|      0|                SETVALUE(lastx);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  353|      0|                SETVALUE(0);                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      0|    do                                                                         \
  |  |  |  |  |  |  267|      0|    {                                                                          \
  |  |  |  |  |  |  268|      0|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      0|        {                                                                      \
  |  |  |  |  |  |  270|      0|            TIFFErrorExtR(tif, module, "Buffer overflow at line %d of %s %u",  \
  |  |  |  |  |  |  271|      0|                          sp->line, isTiled(tif) ? "tile" : "strip",           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  272|      0|                          isTiled(tif) ? tif->tif_dir.td_curtile               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  273|      0|                                       : tif->tif_dir.td_curstrip);            \
  |  |  |  |  |  |  274|      0|            return (-1);                                                       \
  |  |  |  |  |  |  275|      0|        }                                                                      \
  |  |  |  |  |  |  276|      0|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      0|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      0|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  354|      0|            }                                                                  \
  |  |  |  |  355|  58.7k|        }                                                                      \
  |  |  |  |  356|  58.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 58.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  58.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 58.9k]
  |  |  ------------------
  ------------------
 1826|  58.9k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1827|       |        /*
 1828|       |         * Cleanup at the end of the row.
 1829|       |         */
 1830|  58.9k|        if (mode & FAXMODE_BYTEALIGN)
  ------------------
  |  |  701|  58.9k|#define FAXMODE_BYTEALIGN 0x0004     /* byte align row */
  ------------------
  |  Branch (1830:13): [True: 58.8k, False: 62]
  ------------------
 1831|  58.8k|        {
 1832|  58.8k|            int n = BitsAvail - (BitsAvail & ~7);
 1833|  58.8k|            ClrBits(n);
  ------------------
  |  |  196|  58.8k|    do                                                                         \
  |  |  197|  58.8k|    {                                                                          \
  |  |  198|  58.8k|        BitsAvail -= (n);                                                      \
  |  |  199|  58.8k|        BitAcc >>= (n);                                                        \
  |  |  200|  58.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 58.8k]
  |  |  ------------------
  ------------------
 1834|  58.8k|        }
 1835|     62|        else if (mode & FAXMODE_WORDALIGN)
  ------------------
  |  |  702|     62|#define FAXMODE_WORDALIGN 0x0008     /* word align row */
  ------------------
  |  Branch (1835:18): [True: 62, False: 0]
  ------------------
 1836|     62|        {
 1837|     62|            int n = BitsAvail - (BitsAvail & ~15);
 1838|     62|            ClrBits(n);
  ------------------
  |  |  196|     62|    do                                                                         \
  |  |  197|     62|    {                                                                          \
  |  |  198|     62|        BitsAvail -= (n);                                                      \
  |  |  199|     62|        BitAcc >>= (n);                                                        \
  |  |  200|     62|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 62]
  |  |  ------------------
  ------------------
 1839|     62|            if (BitsAvail == 0 && !isAligned(cp, uint16_t))
  ------------------
  |  |  112|     60|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (1839:17): [True: 60, False: 2]
  |  Branch (1839:35): [True: 38, False: 22]
  ------------------
 1840|     38|                cp++;
 1841|     62|        }
 1842|  58.9k|        buf += sp->b.rowbytes;
 1843|  58.9k|        occ -= sp->b.rowbytes;
 1844|  58.9k|        sp->line++;
 1845|  58.9k|        continue;
 1846|     10|    EOFRLE: /* premature EOF */
 1847|     10|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1848|     10|        UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|     10|    do                                                                         \
  |  |  160|     10|    {                                                                          \
  |  |  161|     10|        sp->bit = BitsAvail;                                                   \
  |  |  162|     10|        sp->data = BitAcc;                                                     \
  |  |  163|     10|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|     10|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|     10|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|     10|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 10]
  |  |  ------------------
  ------------------
 1849|     10|        return (-1);
 1850|  58.9k|    }
 1851|    258|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|    258|    do                                                                         \
  |  |  160|    258|    {                                                                          \
  |  |  161|    258|        sp->bit = BitsAvail;                                                   \
  |  |  162|    258|        sp->data = BitAcc;                                                     \
  |  |  163|    258|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|    258|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|    258|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|    258|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 258]
  |  |  ------------------
  ------------------
 1852|    258|    return (1);
 1853|    268|}

TIFFRGBAImageOK:
   85|  2.55k|{
   86|  2.55k|    TIFFDirectory *td = &tif->tif_dir;
   87|  2.55k|    uint16_t photometric;
   88|  2.55k|    int colorchannels;
   89|       |
   90|  2.55k|    if (!tif->tif_decodestatus)
  ------------------
  |  Branch (90:9): [True: 2, False: 2.55k]
  ------------------
   91|      2|    {
   92|      2|        snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      2|#define EMSG_BUF_SIZE 1024
  ------------------
   93|      2|                 "Sorry, requested compression method is not configured");
   94|      2|        return (0);
   95|      2|    }
   96|  2.55k|    switch (td->td_bitspersample)
   97|  2.55k|    {
   98|    352|        case 1:
  ------------------
  |  Branch (98:9): [True: 352, False: 2.20k]
  ------------------
   99|    440|        case 2:
  ------------------
  |  Branch (99:9): [True: 88, False: 2.46k]
  ------------------
  100|    479|        case 4:
  ------------------
  |  Branch (100:9): [True: 39, False: 2.51k]
  ------------------
  101|  1.86k|        case 8:
  ------------------
  |  Branch (101:9): [True: 1.38k, False: 1.17k]
  ------------------
  102|  2.39k|        case 16:
  ------------------
  |  Branch (102:9): [True: 530, False: 2.02k]
  ------------------
  103|  2.39k|            break;
  104|    166|        default:
  ------------------
  |  Branch (104:9): [True: 166, False: 2.39k]
  ------------------
  105|    166|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|    166|#define EMSG_BUF_SIZE 1024
  ------------------
  106|    166|                     "Sorry, can not handle images with %" PRIu16
  107|    166|                     "-bit samples",
  108|    166|                     td->td_bitspersample);
  109|    166|            return (0);
  110|  2.55k|    }
  111|  2.39k|    if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
  ------------------
  |  |  336|  2.39k|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (111:9): [True: 8, False: 2.38k]
  ------------------
  112|      8|    {
  113|      8|        snprintf(
  114|      8|            emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      8|#define EMSG_BUF_SIZE 1024
  ------------------
  115|      8|            "Sorry, can not handle images with IEEE floating-point samples");
  116|      8|        return (0);
  117|      8|    }
  118|  2.38k|    colorchannels = td->td_samplesperpixel - td->td_extrasamples;
  119|  2.38k|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric))
  ------------------
  |  |  220|  2.38k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (119:9): [True: 403, False: 1.97k]
  ------------------
  120|    403|    {
  121|    403|        switch (colorchannels)
  122|    403|        {
  123|    403|            case 1:
  ------------------
  |  Branch (123:13): [True: 403, False: 0]
  ------------------
  124|    403|                photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|    403|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  125|    403|                break;
  126|      0|            case 3:
  ------------------
  |  Branch (126:13): [True: 0, False: 403]
  ------------------
  127|      0|                photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  128|      0|                break;
  129|      0|            default:
  ------------------
  |  Branch (129:13): [True: 0, False: 403]
  ------------------
  130|      0|                snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag",
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  131|      0|                         photoTag);
  132|      0|                return (0);
  133|    403|        }
  134|    403|    }
  135|  2.38k|    switch (photometric)
  136|  2.38k|    {
  137|     44|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|     44|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (137:9): [True: 44, False: 2.33k]
  ------------------
  138|    696|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    696|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (138:9): [True: 652, False: 1.73k]
  ------------------
  139|    725|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|    725|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (139:9): [True: 29, False: 2.35k]
  ------------------
  140|    725|            if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|  1.45k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (140:17): [True: 558, False: 167]
  ------------------
  141|    558|                td->td_samplesperpixel != 1 && td->td_bitspersample < 8)
  ------------------
  |  Branch (141:17): [True: 216, False: 342]
  |  Branch (141:48): [True: 58, False: 158]
  ------------------
  142|     58|            {
  143|     58|                snprintf(
  144|     58|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     58|#define EMSG_BUF_SIZE 1024
  ------------------
  145|     58|                    "Sorry, can not handle contiguous data with %s=%" PRIu16
  146|     58|                    ", "
  147|     58|                    "and %s=%" PRIu16 " and Bits/Sample=%" PRIu16 "",
  148|     58|                    photoTag, photometric, "Samples/pixel",
  149|     58|                    td->td_samplesperpixel, td->td_bitspersample);
  150|     58|                return (0);
  151|     58|            }
  152|       |            /*
  153|       |             * We should likely validate that any extra samples are either
  154|       |             * to be ignored, or are alpha, and if alpha we should try to use
  155|       |             * them.  But for now we won't bother with this.
  156|       |             */
  157|    667|            break;
  158|  1.24k|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|  1.24k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (158:9): [True: 1.24k, False: 1.14k]
  ------------------
  159|       |            /*
  160|       |             * TODO: if at all meaningful and useful, make more complete
  161|       |             * support check here, or better still, refactor to let supporting
  162|       |             * code decide whether there is support and what meaningful
  163|       |             * error to return
  164|       |             */
  165|  1.24k|            break;
  166|     59|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|     59|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (166:9): [True: 59, False: 2.32k]
  ------------------
  167|     59|            if (colorchannels < 3)
  ------------------
  |  Branch (167:17): [True: 7, False: 52]
  ------------------
  168|      7|            {
  169|      7|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      7|#define EMSG_BUF_SIZE 1024
  ------------------
  170|      7|                         "Sorry, can not handle RGB image with %s=%d",
  171|      7|                         "Color channels", colorchannels);
  172|      7|                return (0);
  173|      7|            }
  174|     52|            break;
  175|    100|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|    100|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (175:9): [True: 100, False: 2.28k]
  ------------------
  176|    100|        {
  177|    100|            uint16_t inkset;
  178|    100|            TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
  ------------------
  |  |  322|    100|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  179|    100|            if (inkset != INKSET_CMYK)
  ------------------
  |  |  323|    100|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  |  Branch (179:17): [True: 14, False: 86]
  ------------------
  180|     14|            {
  181|     14|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     14|#define EMSG_BUF_SIZE 1024
  ------------------
  182|     14|                         "Sorry, can not handle separated image with %s=%d",
  183|     14|                         "InkSet", inkset);
  184|     14|                return 0;
  185|     14|            }
  186|     86|            if (td->td_samplesperpixel < 4)
  ------------------
  |  Branch (186:17): [True: 14, False: 72]
  ------------------
  187|     14|            {
  188|     14|                snprintf(
  189|     14|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     14|#define EMSG_BUF_SIZE 1024
  ------------------
  190|     14|                    "Sorry, can not handle separated image with %s=%" PRIu16,
  191|     14|                    "Samples/pixel", td->td_samplesperpixel);
  192|     14|                return 0;
  193|     14|            }
  194|     72|            break;
  195|     86|        }
  196|     72|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|     20|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (196:9): [True: 20, False: 2.36k]
  ------------------
  197|     20|            if (td->td_compression != COMPRESSION_SGILOG)
  ------------------
  |  |  210|     20|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (197:17): [True: 4, False: 16]
  ------------------
  198|      4|            {
  199|      4|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      4|#define EMSG_BUF_SIZE 1024
  ------------------
  200|      4|                         "Sorry, LogL data must have %s=%d", "Compression",
  201|      4|                         COMPRESSION_SGILOG);
  ------------------
  |  |  210|      4|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  202|      4|                return (0);
  203|      4|            }
  204|     16|            break;
  205|     54|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|     54|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (205:9): [True: 54, False: 2.32k]
  ------------------
  206|     54|            if (td->td_compression != COMPRESSION_SGILOG &&
  ------------------
  |  |  210|    108|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (206:17): [True: 49, False: 5]
  ------------------
  207|     49|                td->td_compression != COMPRESSION_SGILOG24)
  ------------------
  |  |  211|     49|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (207:17): [True: 8, False: 41]
  ------------------
  208|      8|            {
  209|      8|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      8|#define EMSG_BUF_SIZE 1024
  ------------------
  210|      8|                         "Sorry, LogLuv data must have %s=%d or %d",
  211|      8|                         "Compression", COMPRESSION_SGILOG,
  ------------------
  |  |  210|      8|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  212|      8|                         COMPRESSION_SGILOG24);
  ------------------
  |  |  211|      8|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  213|      8|                return (0);
  214|      8|            }
  215|     46|            if (td->td_planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|     46|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (215:17): [True: 7, False: 39]
  ------------------
  216|      7|            {
  217|      7|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      7|#define EMSG_BUF_SIZE 1024
  ------------------
  218|      7|                         "Sorry, can not handle LogLuv images with %s=%" PRIu16,
  219|      7|                         "Planarconfiguration", td->td_planarconfig);
  220|      7|                return (0);
  221|      7|            }
  222|     39|            if (td->td_samplesperpixel != 3 || colorchannels != 3)
  ------------------
  |  Branch (222:17): [True: 7, False: 32]
  |  Branch (222:48): [True: 11, False: 21]
  ------------------
  223|     18|            {
  224|     18|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     18|#define EMSG_BUF_SIZE 1024
  ------------------
  225|     18|                         "Sorry, can not handle image with %s=%" PRIu16
  226|     18|                         ", %s=%d",
  227|     18|                         "Samples/pixel", td->td_samplesperpixel,
  228|     18|                         "colorchannels", colorchannels);
  229|     18|                return 0;
  230|     18|            }
  231|     21|            break;
  232|     76|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|     76|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (232:9): [True: 76, False: 2.30k]
  ------------------
  233|     76|            if (td->td_samplesperpixel != 3 || colorchannels != 3 ||
  ------------------
  |  Branch (233:17): [True: 16, False: 60]
  |  Branch (233:48): [True: 11, False: 49]
  ------------------
  234|     49|                (td->td_bitspersample != 8 && td->td_bitspersample != 16))
  ------------------
  |  Branch (234:18): [True: 11, False: 38]
  |  Branch (234:47): [True: 4, False: 7]
  ------------------
  235|     31|            {
  236|     31|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     31|#define EMSG_BUF_SIZE 1024
  ------------------
  237|     31|                         "Sorry, can not handle image with %s=%" PRIu16
  238|     31|                         ", %s=%d and %s=%" PRIu16,
  239|     31|                         "Samples/pixel", td->td_samplesperpixel,
  240|     31|                         "colorchannels", colorchannels, "Bits/sample",
  241|     31|                         td->td_bitspersample);
  242|     31|                return 0;
  243|     31|            }
  244|     45|            break;
  245|    107|        default:
  ------------------
  |  Branch (245:9): [True: 107, False: 2.27k]
  ------------------
  246|    107|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|    107|#define EMSG_BUF_SIZE 1024
  ------------------
  247|    107|                     "Sorry, can not handle image with %s=%" PRIu16, photoTag,
  248|    107|                     photometric);
  249|    107|            return (0);
  250|  2.38k|    }
  251|  2.11k|    return (1);
  252|  2.38k|}
TIFFRGBAImageEnd:
  255|  2.11k|{
  256|  2.11k|    if (img->Map)
  ------------------
  |  Branch (256:9): [True: 10, False: 2.10k]
  ------------------
  257|     10|    {
  258|     10|        _TIFFfreeExt(img->tif, img->Map);
  259|     10|        img->Map = NULL;
  260|     10|    }
  261|  2.11k|    if (img->BWmap)
  ------------------
  |  Branch (261:9): [True: 545, False: 1.56k]
  ------------------
  262|    545|    {
  263|    545|        _TIFFfreeExt(img->tif, img->BWmap);
  264|    545|        img->BWmap = NULL;
  265|    545|    }
  266|  2.11k|    if (img->PALmap)
  ------------------
  |  Branch (266:9): [True: 25, False: 2.08k]
  ------------------
  267|     25|    {
  268|     25|        _TIFFfreeExt(img->tif, img->PALmap);
  269|     25|        img->PALmap = NULL;
  270|     25|    }
  271|  2.11k|    if (img->ycbcr)
  ------------------
  |  Branch (271:9): [True: 814, False: 1.30k]
  ------------------
  272|    814|    {
  273|    814|        _TIFFfreeExt(img->tif, img->ycbcr);
  274|    814|        img->ycbcr = NULL;
  275|    814|    }
  276|  2.11k|    if (img->cielab)
  ------------------
  |  Branch (276:9): [True: 22, False: 2.09k]
  ------------------
  277|     22|    {
  278|     22|        _TIFFfreeExt(img->tif, img->cielab);
  279|     22|        img->cielab = NULL;
  280|     22|    }
  281|  2.11k|    if (img->UaToAa)
  ------------------
  |  Branch (281:9): [True: 57, False: 2.05k]
  ------------------
  282|     57|    {
  283|     57|        _TIFFfreeExt(img->tif, img->UaToAa);
  284|     57|        img->UaToAa = NULL;
  285|     57|    }
  286|  2.11k|    if (img->Bitdepth16To8)
  ------------------
  |  Branch (286:9): [True: 394, False: 1.72k]
  ------------------
  287|    394|    {
  288|    394|        _TIFFfreeExt(img->tif, img->Bitdepth16To8);
  289|    394|        img->Bitdepth16To8 = NULL;
  290|    394|    }
  291|       |
  292|  2.11k|    if (img->redcmap)
  ------------------
  |  Branch (292:9): [True: 25, False: 2.08k]
  ------------------
  293|     25|    {
  294|     25|        _TIFFfreeExt(img->tif, img->redcmap);
  295|     25|        _TIFFfreeExt(img->tif, img->greencmap);
  296|     25|        _TIFFfreeExt(img->tif, img->bluecmap);
  297|       |        img->redcmap = img->greencmap = img->bluecmap = NULL;
  298|     25|    }
  299|  2.11k|}
TIFFRGBAImageBegin:
  313|  2.55k|{
  314|  2.55k|    uint16_t *sampleinfo;
  315|  2.55k|    uint16_t extrasamples;
  316|  2.55k|    uint16_t planarconfig;
  317|  2.55k|    uint16_t compress;
  318|  2.55k|    int colorchannels;
  319|  2.55k|    uint16_t *red_orig, *green_orig, *blue_orig;
  320|  2.55k|    uint32_t n_color;
  321|       |
  322|  2.55k|    if (!TIFFRGBAImageOK(tif, emsg))
  ------------------
  |  Branch (322:9): [True: 444, False: 2.11k]
  ------------------
  323|    444|        return 0;
  324|       |
  325|       |    /* Initialize to normal values */
  326|  2.11k|    img->row_offset = 0;
  327|  2.11k|    img->col_offset = 0;
  328|  2.11k|    img->redcmap = NULL;
  329|  2.11k|    img->greencmap = NULL;
  330|  2.11k|    img->bluecmap = NULL;
  331|  2.11k|    img->Map = NULL;
  332|  2.11k|    img->BWmap = NULL;
  333|  2.11k|    img->PALmap = NULL;
  334|  2.11k|    img->ycbcr = NULL;
  335|  2.11k|    img->cielab = NULL;
  336|  2.11k|    img->UaToAa = NULL;
  337|  2.11k|    img->Bitdepth16To8 = NULL;
  338|  2.11k|    img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
  ------------------
  |  |  252|  2.11k|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  339|       |
  340|  2.11k|    img->tif = tif;
  341|  2.11k|    img->stoponerr = stop;
  342|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
  ------------------
  |  |  180|  2.11k|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  343|  2.11k|    switch (img->bitspersample)
  344|  2.11k|    {
  345|    265|        case 1:
  ------------------
  |  Branch (345:9): [True: 265, False: 1.84k]
  ------------------
  346|    320|        case 2:
  ------------------
  |  Branch (346:9): [True: 55, False: 2.05k]
  ------------------
  347|    339|        case 4:
  ------------------
  |  Branch (347:9): [True: 19, False: 2.09k]
  ------------------
  348|  1.60k|        case 8:
  ------------------
  |  Branch (348:9): [True: 1.26k, False: 848]
  ------------------
  349|  2.11k|        case 16:
  ------------------
  |  Branch (349:9): [True: 509, False: 1.60k]
  ------------------
  350|  2.11k|            break;
  351|      0|        default:
  ------------------
  |  Branch (351:9): [True: 0, False: 2.11k]
  ------------------
  352|      0|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  353|      0|                     "Sorry, can not handle images with %" PRIu16
  354|      0|                     "-bit samples",
  355|      0|                     img->bitspersample);
  356|      0|            goto fail_return;
  357|  2.11k|    }
  358|  2.11k|    img->alpha = 0;
  359|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
  ------------------
  |  |  257|  2.11k|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  360|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples,
  ------------------
  |  |  329|  2.11k|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  361|  2.11k|                          &sampleinfo);
  362|  2.11k|    if (extrasamples >= 1)
  ------------------
  |  Branch (362:9): [True: 746, False: 1.36k]
  ------------------
  363|    746|    {
  364|    746|        switch (sampleinfo[0])
  365|    746|        {
  366|    191|            case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without
  ------------------
  |  |  330|    191|#define EXTRASAMPLE_UNSPECIFIED 0          /* !unspecified data */
  ------------------
  |  Branch (366:13): [True: 191, False: 555]
  ------------------
  367|       |                                           */
  368|    191|                if (img->samplesperpixel >
  ------------------
  |  Branch (368:21): [True: 124, False: 67]
  ------------------
  369|    191|                    3) /* correct info about alpha channel */
  370|    124|                    img->alpha = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|    124|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  371|    191|                break;
  372|     46|            case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
  ------------------
  |  |  331|     46|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (372:13): [True: 46, False: 700]
  ------------------
  373|    555|            case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
  ------------------
  |  |  332|    555|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (373:13): [True: 509, False: 237]
  ------------------
  374|    555|                img->alpha = sampleinfo[0];
  375|    555|                break;
  376|      0|            default:
  ------------------
  |  Branch (376:13): [True: 0, False: 746]
  ------------------
  377|      0|                break;
  378|    746|        }
  379|    746|    }
  380|       |
  381|  2.11k|#ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA
  382|  2.11k|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
  ------------------
  |  |  220|  2.11k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (382:9): [True: 353, False: 1.76k]
  ------------------
  383|    353|        img->photometric = PHOTOMETRIC_MINISWHITE;
  ------------------
  |  |  221|    353|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  384|       |
  385|  2.11k|    if (extrasamples == 0 && img->samplesperpixel == 4 &&
  ------------------
  |  Branch (385:9): [True: 1.36k, False: 746]
  |  Branch (385:30): [True: 56, False: 1.31k]
  ------------------
  386|     56|        img->photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|     56|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (386:9): [True: 0, False: 56]
  ------------------
  387|      0|    {
  388|      0|        img->alpha = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|      0|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  389|      0|        extrasamples = 1;
  390|      0|    }
  391|  2.11k|#endif
  392|       |
  393|  2.11k|    colorchannels = img->samplesperpixel - extrasamples;
  394|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress);
  ------------------
  |  |  181|  2.11k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  395|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
  ------------------
  |  |  264|  2.11k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  396|  2.11k|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
  ------------------
  |  |  220|  2.11k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (396:9): [True: 353, False: 1.76k]
  ------------------
  397|    353|    {
  398|    353|        switch (colorchannels)
  399|    353|        {
  400|    353|            case 1:
  ------------------
  |  Branch (400:13): [True: 353, False: 0]
  ------------------
  401|    353|                if (isCCITTCompression(tif))
  ------------------
  |  Branch (401:21): [True: 79, False: 274]
  ------------------
  402|     79|                    img->photometric = PHOTOMETRIC_MINISWHITE;
  ------------------
  |  |  221|     79|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  403|    274|                else
  404|    274|                    img->photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|    274|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  405|    353|                break;
  406|      0|            case 3:
  ------------------
  |  Branch (406:13): [True: 0, False: 353]
  ------------------
  407|      0|                img->photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  408|      0|                break;
  409|      0|            default:
  ------------------
  |  Branch (409:13): [True: 0, False: 353]
  ------------------
  410|      0|                snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag",
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  411|      0|                         photoTag);
  412|      0|                goto fail_return;
  413|    353|        }
  414|    353|    }
  415|  2.11k|    switch (img->photometric)
  416|  2.11k|    {
  417|     25|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     25|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (417:9): [True: 25, False: 2.08k]
  ------------------
  418|     25|            if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &red_orig, &green_orig,
  ------------------
  |  |  309|     25|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (418:17): [True: 0, False: 25]
  ------------------
  419|     25|                              &blue_orig))
  420|      0|            {
  421|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  422|      0|                         "Missing required \"Colormap\" tag");
  423|      0|                goto fail_return;
  424|      0|            }
  425|       |
  426|       |            /* copy the colormaps so we can modify them */
  427|     25|            n_color = (uint32_t)(1U << img->bitspersample);
  428|     25|            img->redcmap = (uint16_t *)_TIFFmallocExt(
  429|     25|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  430|     25|            img->greencmap = (uint16_t *)_TIFFmallocExt(
  431|     25|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  432|     25|            img->bluecmap = (uint16_t *)_TIFFmallocExt(
  433|     25|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  434|     25|            if (!img->redcmap || !img->greencmap || !img->bluecmap)
  ------------------
  |  Branch (434:17): [True: 0, False: 25]
  |  Branch (434:34): [True: 0, False: 25]
  |  Branch (434:53): [True: 0, False: 25]
  ------------------
  435|      0|            {
  436|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  437|      0|                         "Out of memory for colormap copy");
  438|      0|                goto fail_return;
  439|      0|            }
  440|       |
  441|     25|            _TIFFmemcpy(img->redcmap, red_orig, n_color * 2);
  442|     25|            _TIFFmemcpy(img->greencmap, green_orig, n_color * 2);
  443|     25|            _TIFFmemcpy(img->bluecmap, blue_orig, n_color * 2);
  444|       |
  445|       |            /* fall through... */
  446|    148|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    148|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (446:9): [True: 123, False: 1.99k]
  ------------------
  447|    667|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    667|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (447:9): [True: 519, False: 1.59k]
  ------------------
  448|    667|            if (planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|  1.33k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (448:17): [True: 500, False: 167]
  ------------------
  449|    500|                img->samplesperpixel != 1 && img->bitspersample < 8)
  ------------------
  |  Branch (449:17): [True: 158, False: 342]
  |  Branch (449:46): [True: 0, False: 158]
  ------------------
  450|      0|            {
  451|      0|                snprintf(
  452|      0|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  453|      0|                    "Sorry, can not handle contiguous data with %s=%" PRIu16
  454|      0|                    ", "
  455|      0|                    "and %s=%" PRIu16 " and Bits/Sample=%" PRIu16,
  456|      0|                    photoTag, img->photometric, "Samples/pixel",
  457|      0|                    img->samplesperpixel, img->bitspersample);
  458|      0|                goto fail_return;
  459|      0|            }
  460|    667|            break;
  461|  1.24k|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|  1.24k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (461:9): [True: 1.24k, False: 873]
  ------------------
  462|       |            /* It would probably be nice to have a reality check here. */
  463|  1.24k|            if (planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|  1.24k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (463:17): [True: 934, False: 307]
  ------------------
  464|       |                /* can rely on libjpeg to convert to RGB */
  465|       |                /* XXX should restore current state on exit */
  466|    934|                switch (compress)
  467|    934|                {
  468|    380|                    case COMPRESSION_JPEG:
  ------------------
  |  |  190|    380|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
  |  Branch (468:21): [True: 380, False: 554]
  ------------------
  469|       |                        /*
  470|       |                         * TODO: when complete tests verify complete
  471|       |                         * desubsampling and YCbCr handling, remove use of
  472|       |                         * TIFFTAG_JPEGCOLORMODE in favor of tif_getimage.c
  473|       |                         * native handling
  474|       |                         */
  475|    380|                        TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE,
  ------------------
  |  |  706|    380|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  476|    380|                                     JPEGCOLORMODE_RGB);
  ------------------
  |  |  708|    380|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  477|    380|                        img->photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|    380|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  478|    380|                        break;
  479|    554|                    default:
  ------------------
  |  Branch (479:21): [True: 554, False: 380]
  ------------------
  480|    554|                        /* do nothing */;
  481|    554|                        break;
  482|    934|                }
  483|       |            /*
  484|       |             * TODO: if at all meaningful and useful, make more complete
  485|       |             * support check here, or better still, refactor to let supporting
  486|       |             * code decide whether there is support and what meaningful
  487|       |             * error to return
  488|       |             */
  489|  1.24k|            break;
  490|  1.24k|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|     52|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (490:9): [True: 52, False: 2.06k]
  ------------------
  491|     52|            if (colorchannels < 3)
  ------------------
  |  Branch (491:17): [True: 0, False: 52]
  ------------------
  492|      0|            {
  493|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  494|      0|                         "Sorry, can not handle RGB image with %s=%d",
  495|      0|                         "Color channels", colorchannels);
  496|      0|                goto fail_return;
  497|      0|            }
  498|     52|            break;
  499|     72|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|     72|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (499:9): [True: 72, False: 2.04k]
  ------------------
  500|     72|        {
  501|     72|            uint16_t inkset;
  502|     72|            TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
  ------------------
  |  |  322|     72|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  503|     72|            if (inkset != INKSET_CMYK)
  ------------------
  |  |  323|     72|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  |  Branch (503:17): [True: 0, False: 72]
  ------------------
  504|      0|            {
  505|      0|                snprintf(
  506|      0|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  507|      0|                    "Sorry, can not handle separated image with %s=%" PRIu16,
  508|      0|                    "InkSet", inkset);
  509|      0|                goto fail_return;
  510|      0|            }
  511|     72|            if (img->samplesperpixel < 4)
  ------------------
  |  Branch (511:17): [True: 0, False: 72]
  ------------------
  512|      0|            {
  513|      0|                snprintf(
  514|      0|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  515|      0|                    "Sorry, can not handle separated image with %s=%" PRIu16,
  516|      0|                    "Samples/pixel", img->samplesperpixel);
  517|      0|                goto fail_return;
  518|      0|            }
  519|     72|        }
  520|     72|        break;
  521|     72|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|     16|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (521:9): [True: 16, False: 2.09k]
  ------------------
  522|     16|            if (compress != COMPRESSION_SGILOG)
  ------------------
  |  |  210|     16|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (522:17): [True: 0, False: 16]
  ------------------
  523|      0|            {
  524|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  525|      0|                         "Sorry, LogL data must have %s=%d", "Compression",
  526|      0|                         COMPRESSION_SGILOG);
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  527|      0|                goto fail_return;
  528|      0|            }
  529|     16|            TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  743|     16|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
                          TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  747|     16|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  530|     16|            img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */
  ------------------
  |  |  222|     16|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  531|     16|            img->bitspersample = 8;
  532|     16|            break;
  533|     21|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|     21|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (533:9): [True: 21, False: 2.09k]
  ------------------
  534|     21|            if (compress != COMPRESSION_SGILOG &&
  ------------------
  |  |  210|     42|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (534:17): [True: 16, False: 5]
  ------------------
  535|     16|                compress != COMPRESSION_SGILOG24)
  ------------------
  |  |  211|     16|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (535:17): [True: 0, False: 16]
  ------------------
  536|      0|            {
  537|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  538|      0|                         "Sorry, LogLuv data must have %s=%d or %d",
  539|      0|                         "Compression", COMPRESSION_SGILOG,
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  540|      0|                         COMPRESSION_SGILOG24);
  ------------------
  |  |  211|      0|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  541|      0|                goto fail_return;
  542|      0|            }
  543|     21|            if (planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|     21|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (543:17): [True: 0, False: 21]
  ------------------
  544|      0|            {
  545|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  546|      0|                         "Sorry, can not handle LogLuv images with %s=%" PRIu16,
  547|      0|                         "Planarconfiguration", planarconfig);
  548|      0|                return (0);
  549|      0|            }
  550|     21|            TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  743|     21|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
                          TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  747|     21|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  551|     21|            img->photometric = PHOTOMETRIC_RGB; /* little white lie */
  ------------------
  |  |  223|     21|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  552|     21|            img->bitspersample = 8;
  553|     21|            break;
  554|     45|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|     45|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (554:9): [True: 45, False: 2.06k]
  ------------------
  555|     45|            break;
  556|      0|        default:
  ------------------
  |  Branch (556:9): [True: 0, False: 2.11k]
  ------------------
  557|      0|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  558|      0|                     "Sorry, can not handle image with %s=%" PRIu16, photoTag,
  559|      0|                     img->photometric);
  560|      0|            goto fail_return;
  561|  2.11k|    }
  562|  2.11k|    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
  ------------------
  |  |  178|  2.11k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  563|  2.11k|    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
  ------------------
  |  |  179|  2.11k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  564|  2.11k|    TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
  ------------------
  |  |  248|  2.11k|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  565|  2.11k|    img->isContig =
  566|  2.11k|        !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1);
  ------------------
  |  |  266|  4.22k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (566:11): [True: 550, False: 1.56k]
  |  Branch (566:52): [True: 487, False: 63]
  ------------------
  567|  2.11k|    if (img->isContig)
  ------------------
  |  Branch (567:9): [True: 1.62k, False: 487]
  ------------------
  568|  1.62k|    {
  569|  1.62k|        if (!PickContigCase(img))
  ------------------
  |  Branch (569:13): [True: 266, False: 1.36k]
  ------------------
  570|    266|        {
  571|    266|            snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
  ------------------
  |  |   53|    266|#define EMSG_BUF_SIZE 1024
  ------------------
  572|    266|            goto fail_return;
  573|    266|        }
  574|  1.62k|    }
  575|    487|    else
  576|    487|    {
  577|    487|        if (!PickSeparateCase(img))
  ------------------
  |  Branch (577:13): [True: 231, False: 256]
  ------------------
  578|    231|        {
  579|    231|            snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
  ------------------
  |  |   53|    231|#define EMSG_BUF_SIZE 1024
  ------------------
  580|    231|            goto fail_return;
  581|    231|        }
  582|    487|    }
  583|  1.61k|    return 1;
  584|       |
  585|    497|fail_return:
  586|    497|    TIFFRGBAImageEnd(img);
  587|    497|    return 0;
  588|  2.11k|}
TIFFRGBAImageGet:
  592|  1.61k|{
  593|  1.61k|    if (img->get == NULL)
  ------------------
  |  Branch (593:9): [True: 0, False: 1.61k]
  ------------------
  594|      0|    {
  595|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
  596|      0|                      "No \"get\" routine setup");
  597|      0|        return (0);
  598|      0|    }
  599|  1.61k|    if (img->put.any == NULL)
  ------------------
  |  Branch (599:9): [True: 0, False: 1.61k]
  ------------------
  600|      0|    {
  601|      0|        TIFFErrorExtR(
  602|      0|            img->tif, TIFFFileName(img->tif),
  603|      0|            "No \"put\" routine setupl; probably can not handle image format");
  604|      0|        return (0);
  605|      0|    }
  606|       |    /* Verify raster height against image height.
  607|       |     * Width is checked in img->get() function individually. */
  608|  1.61k|    if (0 <= img->row_offset && (uint32_t)img->row_offset < img->height)
  ------------------
  |  Branch (608:9): [True: 1.61k, False: 0]
  |  Branch (608:33): [True: 1.61k, False: 0]
  ------------------
  609|  1.61k|    {
  610|  1.61k|        uint32_t hx = img->height - (uint32_t)img->row_offset;
  611|  1.61k|        if (h > hx)
  ------------------
  |  Branch (611:13): [True: 0, False: 1.61k]
  ------------------
  612|      0|        {
  613|       |            /* Adapt parameters to read only available lines and put image
  614|       |             * at the bottom of the raster. */
  615|      0|            raster += (size_t)(h - hx) * w;
  616|      0|            h = hx;
  617|      0|        }
  618|  1.61k|    }
  619|      0|    else
  620|      0|    {
  621|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
  622|      0|                      "Error in TIFFRGBAImageGet: row offset %d exceeds "
  623|      0|                      "image height %u",
  624|      0|                      img->row_offset, img->height);
  625|      0|        return 0;
  626|      0|    }
  627|  1.61k|    return (*img->get)(img, raster, w, h);
  628|  1.61k|}
TIFFReadRGBAImageOriented:
  636|  2.55k|{
  637|  2.55k|    char emsg[EMSG_BUF_SIZE] = "";
  638|  2.55k|    TIFFRGBAImage img;
  639|  2.55k|    int ok;
  640|       |
  641|  2.55k|    if (TIFFRGBAImageBegin(&img, tif, stop, emsg))
  ------------------
  |  Branch (641:9): [True: 1.61k, False: 941]
  ------------------
  642|  1.61k|    {
  643|  1.61k|        img.req_orientation = (uint16_t)orientation;
  644|  1.61k|        ok = TIFFRGBAImageGet(&img, raster, rwidth, rheight);
  645|  1.61k|        TIFFRGBAImageEnd(&img);
  646|  1.61k|    }
  647|    941|    else
  648|    941|    {
  649|    941|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg);
  650|    941|        ok = 0;
  651|    941|    }
  652|  2.55k|    return (ok);
  653|  2.55k|}
tif_getimage.c:isCCITTCompression:
  302|    353|{
  303|    353|    uint16_t compress;
  304|    353|    TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
  ------------------
  |  |  181|    353|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  305|    353|    return (compress == COMPRESSION_CCITTFAX3 ||
  ------------------
  |  |  184|    706|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (305:13): [True: 39, False: 314]
  ------------------
  306|    314|            compress == COMPRESSION_CCITTFAX4 ||
  ------------------
  |  |  186|    667|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (306:13): [True: 15, False: 299]
  ------------------
  307|    299|            compress == COMPRESSION_CCITTRLE ||
  ------------------
  |  |  183|    652|#define COMPRESSION_CCITTRLE 2        /* CCITT modified Huffman RLE */
  ------------------
  |  Branch (307:13): [True: 21, False: 278]
  ------------------
  308|    278|            compress == COMPRESSION_CCITTRLEW);
  ------------------
  |  |  194|    278|#define COMPRESSION_CCITTRLEW 32771   /* #1 w/ word alignment */
  ------------------
  |  Branch (308:13): [True: 4, False: 274]
  ------------------
  309|    353|}
tif_getimage.c:PickContigCase:
 3123|  1.62k|{
 3124|  1.62k|    img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig;
  ------------------
  |  Branch (3124:16): [True: 207, False: 1.42k]
  ------------------
 3125|  1.62k|    img->put.contig = NULL;
 3126|  1.62k|    switch (img->photometric)
 3127|  1.62k|    {
 3128|    442|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|    442|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3128:9): [True: 442, False: 1.18k]
  ------------------
 3129|    442|            switch (img->bitspersample)
 3130|    442|            {
 3131|     64|                case 8:
  ------------------
  |  Branch (3131:17): [True: 64, False: 378]
  ------------------
 3132|     64|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
  ------------------
  |  |  331|    128|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3132:25): [True: 16, False: 48]
  ------------------
 3133|     16|                        img->samplesperpixel >= 4)
  ------------------
  |  Branch (3133:25): [True: 12, False: 4]
  ------------------
 3134|     12|                        img->put.contig = putRGBAAcontig8bittile;
 3135|     52|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
  ------------------
  |  |  332|    104|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3135:30): [True: 11, False: 41]
  ------------------
 3136|     11|                             img->samplesperpixel >= 4)
  ------------------
  |  Branch (3136:30): [True: 4, False: 7]
  ------------------
 3137|      4|                    {
 3138|      4|                        if (BuildMapUaToAa(img))
  ------------------
  |  Branch (3138:29): [True: 4, False: 0]
  ------------------
 3139|      4|                            img->put.contig = putRGBUAcontig8bittile;
 3140|      4|                    }
 3141|     48|                    else if (img->samplesperpixel >= 3)
  ------------------
  |  Branch (3141:30): [True: 48, False: 0]
  ------------------
 3142|     48|                        img->put.contig = putRGBcontig8bittile;
 3143|     64|                    break;
 3144|    366|                case 16:
  ------------------
  |  Branch (3144:17): [True: 366, False: 76]
  ------------------
 3145|    366|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
  ------------------
  |  |  331|    732|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3145:25): [True: 8, False: 358]
  ------------------
 3146|      8|                        img->samplesperpixel >= 4)
  ------------------
  |  Branch (3146:25): [True: 8, False: 0]
  ------------------
 3147|      8|                    {
 3148|      8|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3148:29): [True: 8, False: 0]
  ------------------
 3149|      8|                            img->put.contig = putRGBAAcontig16bittile;
 3150|      8|                    }
 3151|    358|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
  ------------------
  |  |  332|    716|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3151:30): [True: 304, False: 54]
  ------------------
 3152|    304|                             img->samplesperpixel >= 4)
  ------------------
  |  Branch (3152:30): [True: 4, False: 300]
  ------------------
 3153|      4|                    {
 3154|      4|                        if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
  ------------------
  |  Branch (3154:29): [True: 4, False: 0]
  |  Branch (3154:59): [True: 4, False: 0]
  ------------------
 3155|      4|                            img->put.contig = putRGBUAcontig16bittile;
 3156|      4|                    }
 3157|    354|                    else if (img->samplesperpixel >= 3)
  ------------------
  |  Branch (3157:30): [True: 354, False: 0]
  ------------------
 3158|    354|                    {
 3159|    354|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3159:29): [True: 354, False: 0]
  ------------------
 3160|    354|                            img->put.contig = putRGBcontig16bittile;
 3161|    354|                    }
 3162|    366|                    break;
 3163|     12|                default:
  ------------------
  |  Branch (3163:17): [True: 12, False: 430]
  ------------------
 3164|     12|                    break;
 3165|    442|            }
 3166|    442|            break;
 3167|    442|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|     32|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3167:9): [True: 32, False: 1.59k]
  ------------------
 3168|     32|            if (img->samplesperpixel >= 4 && buildMap(img))
  ------------------
  |  Branch (3168:17): [True: 32, False: 0]
  |  Branch (3168:46): [True: 32, False: 0]
  ------------------
 3169|     32|            {
 3170|     32|                if (img->bitspersample == 8)
  ------------------
  |  Branch (3170:21): [True: 22, False: 10]
  ------------------
 3171|     22|                {
 3172|     22|                    if (!img->Map)
  ------------------
  |  Branch (3172:25): [True: 22, False: 0]
  ------------------
 3173|     22|                        img->put.contig = putRGBcontig8bitCMYKtile;
 3174|      0|                    else
 3175|      0|                        img->put.contig = putRGBcontig8bitCMYKMaptile;
 3176|     22|                }
 3177|     32|            }
 3178|     32|            break;
 3179|     25|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     25|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (3179:9): [True: 25, False: 1.60k]
  ------------------
 3180|     25|            if (buildMap(img))
  ------------------
  |  Branch (3180:17): [True: 25, False: 0]
  ------------------
 3181|     25|            {
 3182|     25|                switch (img->bitspersample)
 3183|     25|                {
 3184|      0|                    case 8:
  ------------------
  |  Branch (3184:21): [True: 0, False: 25]
  ------------------
 3185|      0|                        img->put.contig = put8bitcmaptile;
 3186|      0|                        break;
 3187|      0|                    case 4:
  ------------------
  |  Branch (3187:21): [True: 0, False: 25]
  ------------------
 3188|      0|                        img->put.contig = put4bitcmaptile;
 3189|      0|                        break;
 3190|     25|                    case 2:
  ------------------
  |  Branch (3190:21): [True: 25, False: 0]
  ------------------
 3191|     25|                        img->put.contig = put2bitcmaptile;
 3192|     25|                        break;
 3193|      0|                    case 1:
  ------------------
  |  Branch (3193:21): [True: 0, False: 25]
  ------------------
 3194|      0|                        img->put.contig = put1bitcmaptile;
 3195|      0|                        break;
 3196|      0|                    default:
  ------------------
  |  Branch (3196:21): [True: 0, False: 25]
  ------------------
 3197|      0|                        break;
 3198|     25|                }
 3199|     25|            }
 3200|     25|            break;
 3201|    108|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    108|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3201:9): [True: 108, False: 1.51k]
  ------------------
 3202|    545|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    545|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3202:9): [True: 437, False: 1.19k]
  ------------------
 3203|    545|            if (buildMap(img))
  ------------------
  |  Branch (3203:17): [True: 545, False: 0]
  ------------------
 3204|    545|            {
 3205|    545|                switch (img->bitspersample)
 3206|    545|                {
 3207|     83|                    case 16:
  ------------------
  |  Branch (3207:21): [True: 83, False: 462]
  ------------------
 3208|     83|                        img->put.contig = put16bitbwtile;
 3209|     83|                        break;
 3210|    225|                    case 8:
  ------------------
  |  Branch (3210:21): [True: 225, False: 320]
  ------------------
 3211|    225|                        if (img->alpha && img->samplesperpixel == 2)
  ------------------
  |  Branch (3211:29): [True: 122, False: 103]
  |  Branch (3211:43): [True: 16, False: 106]
  ------------------
 3212|     16|                            img->put.contig = putagreytile;
 3213|    209|                        else
 3214|    209|                            img->put.contig = putgreytile;
 3215|    225|                        break;
 3216|     15|                    case 4:
  ------------------
  |  Branch (3216:21): [True: 15, False: 530]
  ------------------
 3217|     15|                        img->put.contig = put4bitbwtile;
 3218|     15|                        break;
 3219|     18|                    case 2:
  ------------------
  |  Branch (3219:21): [True: 18, False: 527]
  ------------------
 3220|     18|                        img->put.contig = put2bitbwtile;
 3221|     18|                        break;
 3222|    204|                    case 1:
  ------------------
  |  Branch (3222:21): [True: 204, False: 341]
  ------------------
 3223|    204|                        img->put.contig = put1bitbwtile;
 3224|    204|                        break;
 3225|      0|                    default:
  ------------------
  |  Branch (3225:21): [True: 0, False: 545]
  ------------------
 3226|      0|                        break;
 3227|    545|                }
 3228|    545|            }
 3229|    545|            break;
 3230|    561|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    561|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3230:9): [True: 561, False: 1.06k]
  ------------------
 3231|    561|            if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
  ------------------
  |  Branch (3231:17): [True: 542, False: 19]
  |  Branch (3231:46): [True: 536, False: 6]
  ------------------
 3232|    536|            {
 3233|    536|                if (initYCbCrConversion(img) != 0)
  ------------------
  |  Branch (3233:21): [True: 449, False: 87]
  ------------------
 3234|    449|                {
 3235|       |                    /*
 3236|       |                     * The 6.0 spec says that subsampling must be
 3237|       |                     * one of 1, 2, or 4, and that vertical subsampling
 3238|       |                     * must always be <= horizontal subsampling; so
 3239|       |                     * there are only a few possibilities and we just
 3240|       |                     * enumerate the cases.
 3241|       |                     * Joris: added support for the [1,2] case, nonetheless, to
 3242|       |                     * accommodate some OJPEG files
 3243|       |                     */
 3244|    449|                    uint16_t SubsamplingHor;
 3245|    449|                    uint16_t SubsamplingVer;
 3246|    449|                    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|    449|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 3247|    449|                                          &SubsamplingHor, &SubsamplingVer);
 3248|       |                    /* Validate that the image dimensions are compatible with
 3249|       |                    the subsampling block. All putcontig8bitYCbCrXYtile routines
 3250|       |                    assume width >= X and height >= Y. */
 3251|    449|                    if (img->width < SubsamplingHor ||
  ------------------
  |  Branch (3251:25): [True: 125, False: 324]
  ------------------
 3252|    324|                        img->height < SubsamplingVer)
  ------------------
  |  Branch (3252:25): [True: 4, False: 320]
  ------------------
 3253|    129|                    {
 3254|    129|                        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
 3255|    129|                                      "YCbCr subsampling (%u,%u) incompatible "
 3256|    129|                                      "with image size %ux%u",
 3257|    129|                                      SubsamplingHor, SubsamplingVer,
 3258|    129|                                      img->width, img->height);
 3259|    129|                        return (0);
 3260|    129|                    }
 3261|    320|                    switch ((SubsamplingHor << 4) | SubsamplingVer)
 3262|    320|                    {
 3263|      3|                        case 0x44:
  ------------------
  |  Branch (3263:25): [True: 3, False: 317]
  ------------------
 3264|      3|                            img->put.contig = putcontig8bitYCbCr44tile;
 3265|      3|                            break;
 3266|      5|                        case 0x42:
  ------------------
  |  Branch (3266:25): [True: 5, False: 315]
  ------------------
 3267|      5|                            img->put.contig = putcontig8bitYCbCr42tile;
 3268|      5|                            break;
 3269|      3|                        case 0x41:
  ------------------
  |  Branch (3269:25): [True: 3, False: 317]
  ------------------
 3270|      3|                            img->put.contig = putcontig8bitYCbCr41tile;
 3271|      3|                            break;
 3272|    265|                        case 0x22:
  ------------------
  |  Branch (3272:25): [True: 265, False: 55]
  ------------------
 3273|    265|                            img->put.contig = putcontig8bitYCbCr22tile;
 3274|    265|                            break;
 3275|      0|                        case 0x21:
  ------------------
  |  Branch (3275:25): [True: 0, False: 320]
  ------------------
 3276|      0|                            img->put.contig = putcontig8bitYCbCr21tile;
 3277|      0|                            break;
 3278|      7|                        case 0x12:
  ------------------
  |  Branch (3278:25): [True: 7, False: 313]
  ------------------
 3279|      7|                            img->put.contig = putcontig8bitYCbCr12tile;
 3280|      7|                            break;
 3281|     34|                        case 0x11:
  ------------------
  |  Branch (3281:25): [True: 34, False: 286]
  ------------------
 3282|     34|                            img->put.contig = putcontig8bitYCbCr11tile;
 3283|     34|                            break;
 3284|      3|                        default:
  ------------------
  |  Branch (3284:25): [True: 3, False: 317]
  ------------------
 3285|      3|                            break;
 3286|    320|                    }
 3287|    320|                }
 3288|    536|            }
 3289|    432|            break;
 3290|    432|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|     22|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (3290:9): [True: 22, False: 1.60k]
  ------------------
 3291|     22|            if (img->samplesperpixel == 3 && buildMap(img))
  ------------------
  |  Branch (3291:17): [True: 22, False: 0]
  |  Branch (3291:46): [True: 22, False: 0]
  ------------------
 3292|     22|            {
 3293|     22|                if (img->bitspersample == 8 || img->bitspersample == 16)
  ------------------
  |  Branch (3293:21): [True: 18, False: 4]
  |  Branch (3293:48): [True: 4, False: 0]
  ------------------
 3294|     22|                    img->put.contig = initCIELabConversion(img);
 3295|     22|                break;
 3296|     22|            }
 3297|      0|            break;
 3298|      0|        default:
  ------------------
  |  Branch (3298:9): [True: 0, False: 1.62k]
  ------------------
 3299|      0|            break;
 3300|  1.62k|    }
 3301|  1.49k|    return ((img->get != NULL) && (img->put.contig != NULL));
  ------------------
  |  Branch (3301:13): [True: 1.49k, False: 0]
  |  Branch (3301:35): [True: 1.36k, False: 137]
  ------------------
 3302|  1.62k|}
tif_getimage.c:gtTileContig:
  735|    189|{
  736|    189|    TIFF *tif = img->tif;
  737|    189|    tileContigRoutine put = img->put.contig;
  738|    189|    uint32_t col, row, y, rowstoread;
  739|    189|    tmsize_t pos;
  740|    189|    uint32_t tw, th;
  741|    189|    unsigned char *buf = NULL;
  742|    189|    int32_t fromskew, toskew;
  743|    189|    uint32_t nrow;
  744|    189|    int ret = 1, flip;
  745|    189|    uint32_t this_tw, tocol;
  746|    189|    int32_t this_toskew, leftmost_toskew;
  747|    189|    int32_t leftmost_fromskew;
  748|    189|    uint32_t leftmost_tw;
  749|    189|    tmsize_t bufsize;
  750|       |
  751|       |    /* If the raster is smaller than the image,
  752|       |     * or if there is a col_offset, adapt the samples to be copied per row. */
  753|    189|    uint32_t wmin;
  754|       |
  755|    189|    if (0 <= img->col_offset && (uint32_t)img->col_offset < img->width)
  ------------------
  |  Branch (755:9): [True: 189, False: 0]
  |  Branch (755:33): [True: 189, False: 0]
  ------------------
  756|    189|    {
  757|    189|        wmin = TIFFmin(w, img->width - (uint32_t)img->col_offset);
  ------------------
  |  |  337|    189|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 189]
  |  |  ------------------
  ------------------
  758|    189|    }
  759|      0|    else
  760|      0|    {
  761|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
  762|      0|                      "Error in gtTileContig: column offset %d exceeds "
  763|      0|                      "image width %u",
  764|      0|                      img->col_offset, img->width);
  765|      0|        return 0;
  766|      0|    }
  767|    189|    bufsize = TIFFTileSize(tif);
  768|    189|    if (bufsize == 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 189]
  ------------------
  769|      0|    {
  770|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s", "No space for tile buffer");
  771|      0|        return (0);
  772|      0|    }
  773|       |
  774|    189|    TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
  ------------------
  |  |  311|    189|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  775|    189|    TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
  ------------------
  |  |  312|    189|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  776|       |
  777|    189|    flip = setorientation(img);
  778|    189|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|    189|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (778:9): [True: 25, False: 164]
  ------------------
  779|     25|    {
  780|     25|        if (((int64_t)tw + w) > INT_MAX)
  ------------------
  |  Branch (780:13): [True: 3, False: 22]
  ------------------
  781|      3|        {
  782|      3|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  783|      3|                          "unsupported tile size (too wide)");
  784|      3|            return (0);
  785|      3|        }
  786|     22|        y = h - 1;
  787|     22|        toskew = -(int32_t)(tw + w);
  788|     22|    }
  789|    164|    else
  790|    164|    {
  791|    164|        if (tw > ((int64_t)INT_MAX + w) || w > ((int64_t)INT_MAX + tw))
  ------------------
  |  Branch (791:13): [True: 8, False: 156]
  |  Branch (791:44): [True: 0, False: 156]
  ------------------
  792|      8|        {
  793|      8|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  794|      8|                          "unsupported tile size (too wide)");
  795|      8|            return (0);
  796|      8|        }
  797|    156|        y = 0;
  798|    156|        toskew = -(int32_t)(tw - w);
  799|    156|    }
  800|       |
  801|    178|    if (tw == 0 || th == 0)
  ------------------
  |  Branch (801:9): [True: 0, False: 178]
  |  Branch (801:20): [True: 0, False: 178]
  ------------------
  802|      0|    {
  803|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
  804|      0|        return (0);
  805|      0|    }
  806|       |
  807|       |    /*
  808|       |     *	Leftmost tile is clipped on left side if col_offset > 0.
  809|       |     */
  810|    178|    leftmost_fromskew = (int32_t)((uint32_t)img->col_offset % tw);
  811|    178|    leftmost_tw = (uint32_t)((int32_t)tw - leftmost_fromskew);
  812|    178|    int64_t skew_i64 = (int64_t)toskew + (int64_t)(int32_t)leftmost_fromskew;
  813|    178|    if (skew_i64 > INT_MAX || skew_i64 < INT_MIN)
  ------------------
  |  Branch (813:9): [True: 0, False: 178]
  |  Branch (813:31): [True: 0, False: 178]
  ------------------
  814|      0|    {
  815|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s %" PRId64, "Invalid skew",
  816|      0|                      skew_i64);
  817|      0|        return (0);
  818|      0|    }
  819|    178|    leftmost_toskew = (int32_t)skew_i64;
  820|  5.22k|    for (row = 0; ret != 0 && row < h; row += nrow)
  ------------------
  |  Branch (820:19): [True: 5.08k, False: 148]
  |  Branch (820:31): [True: 5.05k, False: 30]
  ------------------
  821|  5.05k|    {
  822|  5.05k|        rowstoread = th - ((uint32_t)row + (uint32_t)img->row_offset) % th;
  823|  5.05k|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (823:17): [True: 128, False: 4.92k]
  ------------------
  824|  5.05k|        fromskew = leftmost_fromskew;
  825|  5.05k|        this_tw = leftmost_tw;
  826|  5.05k|        this_toskew = leftmost_toskew;
  827|  5.05k|        tocol = 0;
  828|  5.05k|        col = (uint32_t)img->col_offset;
  829|       |        /* wmin: only write imagewidth if raster is bigger. */
  830|  10.5k|        while (tocol < wmin)
  ------------------
  |  Branch (830:16): [True: 5.67k, False: 4.90k]
  ------------------
  831|  5.67k|        {
  832|  5.67k|            if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize, col,
  ------------------
  |  Branch (832:17): [True: 2.35k, False: 3.31k]
  ------------------
  833|  5.67k|                                            (uint32_t)row +
  834|  5.67k|                                                (uint32_t)img->row_offset,
  835|  5.67k|                                            0, 0) == (tmsize_t)(-1) &&
  836|  2.35k|                (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (836:18): [True: 148, False: 2.20k]
  |  Branch (836:33): [True: 0, False: 2.20k]
  ------------------
  837|    148|            {
  838|    148|                ret = 0;
  839|    148|                break;
  840|    148|            }
  841|  5.52k|            pos = (((uint32_t)row + (uint32_t)img->row_offset) % th) *
  842|  5.52k|                      TIFFTileRowSize(tif) +
  843|  5.52k|                  ((tmsize_t)fromskew * img->samplesperpixel);
  844|  5.52k|            if (tocol + this_tw > wmin)
  ------------------
  |  Branch (844:17): [True: 26, False: 5.49k]
  ------------------
  845|     26|            {
  846|       |                /*
  847|       |                 * Rightmost tile is clipped on right side.
  848|       |                 */
  849|     26|                fromskew = (int32_t)(tw - (wmin - tocol));
  850|     26|                this_tw = (uint32_t)((int32_t)tw - fromskew);
  851|     26|                this_toskew = (int32_t)(toskew + (int32_t)(uint32_t)fromskew);
  852|     26|            }
  853|  5.52k|            tmsize_t roffset = (tmsize_t)y * w + tocol;
  854|  5.52k|            (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
  855|  5.52k|                   this_toskew, buf + pos);
  856|  5.52k|            tocol += this_tw;
  857|  5.52k|            col += this_tw;
  858|       |            /*
  859|       |             * After the leftmost tile, tiles are no longer clipped on left
  860|       |             * side.
  861|       |             */
  862|  5.52k|            fromskew = 0;
  863|  5.52k|            this_tw = tw;
  864|  5.52k|            this_toskew = toskew;
  865|  5.52k|        }
  866|       |
  867|  5.05k|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|  5.05k|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (867:25): [True: 22, False: 5.02k]
  ------------------
  868|  5.05k|                                                 : (int32_t)nrow);
  869|  5.05k|    }
  870|    178|    _TIFFfreeExt(img->tif, buf);
  871|       |
  872|    178|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|    178|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (872:9): [True: 19, False: 159]
  ------------------
  873|     19|    {
  874|     19|        uint32_t line;
  875|       |
  876|  4.52k|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (876:24): [True: 4.51k, False: 19]
  ------------------
  877|  4.51k|        {
  878|  4.51k|            uint32_t *left = raster + (size_t)line * w;
  879|       |            /* Use wmin to only flip horizontally data in place and not complete
  880|       |             * raster-row. */
  881|  4.51k|            uint32_t *right = left + wmin - 1;
  882|       |
  883|  4.97k|            while (left < right)
  ------------------
  |  Branch (883:20): [True: 468, False: 4.51k]
  ------------------
  884|    468|            {
  885|    468|                uint32_t temp = *left;
  886|    468|                *left = *right;
  887|    468|                *right = temp;
  888|    468|                left++;
  889|    468|                right--;
  890|    468|            }
  891|  4.51k|        }
  892|     19|    }
  893|       |
  894|    178|    return (ret);
  895|    178|}
tif_getimage.c:setorientation:
  667|  1.61k|{
  668|  1.61k|    switch (img->orientation)
  669|  1.61k|    {
  670|  1.39k|        case ORIENTATION_TOPLEFT:
  ------------------
  |  |  249|  1.39k|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (670:9): [True: 1.39k, False: 220]
  ------------------
  671|  1.43k|        case ORIENTATION_LEFTTOP:
  ------------------
  |  |  253|  1.43k|#define ORIENTATION_LEFTTOP 5              /* row 0 lhs, col 0 top */
  ------------------
  |  Branch (671:9): [True: 33, False: 1.58k]
  ------------------
  672|  1.43k|            if (img->req_orientation == ORIENTATION_TOPRIGHT ||
  ------------------
  |  |  250|  2.86k|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (672:17): [True: 0, False: 1.43k]
  ------------------
  673|  1.43k|                img->req_orientation == ORIENTATION_RIGHTTOP)
  ------------------
  |  |  254|  1.43k|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (673:17): [True: 0, False: 1.43k]
  ------------------
  674|      0|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
  675|  1.43k|            else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
  ------------------
  |  |  251|  2.86k|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (675:22): [True: 0, False: 1.43k]
  ------------------
  676|  1.43k|                     img->req_orientation == ORIENTATION_RIGHTBOT)
  ------------------
  |  |  255|  1.43k|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (676:22): [True: 0, False: 1.43k]
  ------------------
  677|      0|                return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
                              return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  678|  1.43k|            else if (img->req_orientation == ORIENTATION_BOTLEFT ||
  ------------------
  |  |  252|  2.86k|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (678:22): [True: 0, False: 1.43k]
  ------------------
  679|  1.43k|                     img->req_orientation == ORIENTATION_LEFTBOT)
  ------------------
  |  |  256|  1.43k|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (679:22): [True: 0, False: 1.43k]
  ------------------
  680|      0|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  681|  1.43k|            else
  682|  1.43k|                return 0;
  683|     22|        case ORIENTATION_TOPRIGHT:
  ------------------
  |  |  250|     22|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (683:9): [True: 22, False: 1.59k]
  ------------------
  684|     45|        case ORIENTATION_RIGHTTOP:
  ------------------
  |  |  254|     45|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (684:9): [True: 23, False: 1.59k]
  ------------------
  685|     45|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|     90|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (685:17): [True: 45, False: 0]
  ------------------
  686|      0|                img->req_orientation == ORIENTATION_LEFTTOP)
  ------------------
  |  |  253|      0|#define ORIENTATION_LEFTTOP 5              /* row 0 lhs, col 0 top */
  ------------------
  |  Branch (686:17): [True: 0, False: 0]
  ------------------
  687|     45|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|     45|#define FLIP_HORIZONTALLY 0x02
  ------------------
  688|      0|            else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
  ------------------
  |  |  251|      0|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (688:22): [True: 0, False: 0]
  ------------------
  689|      0|                     img->req_orientation == ORIENTATION_RIGHTBOT)
  ------------------
  |  |  255|      0|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (689:22): [True: 0, False: 0]
  ------------------
  690|      0|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  691|      0|            else if (img->req_orientation == ORIENTATION_BOTLEFT ||
  ------------------
  |  |  252|      0|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (691:22): [True: 0, False: 0]
  ------------------
  692|      0|                     img->req_orientation == ORIENTATION_LEFTBOT)
  ------------------
  |  |  256|      0|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (692:22): [True: 0, False: 0]
  ------------------
  693|      0|                return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
                              return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  694|      0|            else
  695|      0|                return 0;
  696|     73|        case ORIENTATION_BOTRIGHT:
  ------------------
  |  |  251|     73|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (696:9): [True: 73, False: 1.54k]
  ------------------
  697|     91|        case ORIENTATION_RIGHTBOT:
  ------------------
  |  |  255|     91|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (697:9): [True: 18, False: 1.59k]
  ------------------
  698|     91|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|    182|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (698:17): [True: 91, False: 0]
  ------------------
  699|      0|                img->req_orientation == ORIENTATION_LEFTTOP)
  ------------------
  |  |  253|      0|#define ORIENTATION_LEFTTOP 5              /* row 0 lhs, col 0 top */
  ------------------
  |  Branch (699:17): [True: 0, False: 0]
  ------------------
  700|     91|                return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   51|     91|#define FLIP_HORIZONTALLY 0x02
  ------------------
                              return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   50|     91|#define FLIP_VERTICALLY 0x01
  ------------------
  701|      0|            else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
  ------------------
  |  |  250|      0|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (701:22): [True: 0, False: 0]
  ------------------
  702|      0|                     img->req_orientation == ORIENTATION_RIGHTTOP)
  ------------------
  |  |  254|      0|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (702:22): [True: 0, False: 0]
  ------------------
  703|      0|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  704|      0|            else if (img->req_orientation == ORIENTATION_BOTLEFT ||
  ------------------
  |  |  252|      0|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (704:22): [True: 0, False: 0]
  ------------------
  705|      0|                     img->req_orientation == ORIENTATION_LEFTBOT)
  ------------------
  |  |  256|      0|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (705:22): [True: 0, False: 0]
  ------------------
  706|      0|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
  707|      0|            else
  708|      0|                return 0;
  709|     14|        case ORIENTATION_BOTLEFT:
  ------------------
  |  |  252|     14|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (709:9): [True: 14, False: 1.60k]
  ------------------
  710|     51|        case ORIENTATION_LEFTBOT:
  ------------------
  |  |  256|     51|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (710:9): [True: 37, False: 1.58k]
  ------------------
  711|     51|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|    102|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (711:17): [True: 51, False: 0]
  ------------------
  712|      0|                img->req_orientation == ORIENTATION_LEFTTOP)
  ------------------
  |  |  253|      0|#define ORIENTATION_LEFTTOP 5              /* row 0 lhs, col 0 top */
  ------------------
  |  Branch (712:17): [True: 0, False: 0]
  ------------------
  713|     51|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|     51|#define FLIP_VERTICALLY 0x01
  ------------------
  714|      0|            else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
  ------------------
  |  |  250|      0|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (714:22): [True: 0, False: 0]
  ------------------
  715|      0|                     img->req_orientation == ORIENTATION_RIGHTTOP)
  ------------------
  |  |  254|      0|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (715:22): [True: 0, False: 0]
  ------------------
  716|      0|                return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
                              return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  717|      0|            else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
  ------------------
  |  |  251|      0|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (717:22): [True: 0, False: 0]
  ------------------
  718|      0|                     img->req_orientation == ORIENTATION_RIGHTBOT)
  ------------------
  |  |  255|      0|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (718:22): [True: 0, False: 0]
  ------------------
  719|      0|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
  720|      0|            else
  721|      0|                return 0;
  722|      0|        default: /* NOTREACHED */
  ------------------
  |  Branch (722:9): [True: 0, False: 1.61k]
  ------------------
  723|      0|            return 0;
  724|  1.61k|    }
  725|  1.61k|}
tif_getimage.c:gtStripContig:
 1150|  1.17k|{
 1151|  1.17k|    TIFF *tif = img->tif;
 1152|  1.17k|    tileContigRoutine put = img->put.contig;
 1153|  1.17k|    uint32_t row, y, nrow, nrowsub, rowstoread;
 1154|  1.17k|    tmsize_t pos;
 1155|  1.17k|    unsigned char *buf = NULL;
 1156|  1.17k|    uint32_t rowsperstrip;
 1157|  1.17k|    uint16_t subsamplinghor, subsamplingver;
 1158|  1.17k|    uint32_t imagewidth = img->width;
 1159|  1.17k|    tmsize_t scanline;
 1160|       |    /* fromskew, toskew are the increments within the input image or the raster
 1161|       |     * from the end of a line to the start of the next line to read or write. */
 1162|  1.17k|    int32_t fromskew, toskew;
 1163|  1.17k|    int ret = 1, flip;
 1164|  1.17k|    tmsize_t maxstripsize;
 1165|       |
 1166|       |    /* If the raster is smaller than the image,
 1167|       |     * or if there is a col_offset, adapt the samples to be copied per row. */
 1168|  1.17k|    uint32_t wmin;
 1169|  1.17k|    if (0 <= img->col_offset && (uint32_t)img->col_offset < imagewidth)
  ------------------
  |  Branch (1169:9): [True: 1.17k, False: 0]
  |  Branch (1169:33): [True: 1.17k, False: 0]
  ------------------
 1170|  1.17k|    {
 1171|  1.17k|        wmin = TIFFmin(w, imagewidth - (uint32_t)img->col_offset);
  ------------------
  |  |  337|  1.17k|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 1.17k]
  |  |  ------------------
  ------------------
 1172|  1.17k|    }
 1173|      0|    else
 1174|      0|    {
 1175|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
 1176|      0|                      "Error in gtStripContig: column offset %d exceeds "
 1177|      0|                      "image width %u",
 1178|      0|                      img->col_offset, imagewidth);
 1179|      0|        return 0;
 1180|      0|    }
 1181|       |
 1182|  1.17k|    TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor,
  ------------------
  |  |  388|  1.17k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 1183|  1.17k|                          &subsamplingver);
 1184|  1.17k|    if (subsamplingver == 0)
  ------------------
  |  Branch (1184:9): [True: 0, False: 1.17k]
  ------------------
 1185|      0|    {
 1186|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
 1187|      0|                      "Invalid vertical YCbCr subsampling");
 1188|      0|        return (0);
 1189|      0|    }
 1190|       |
 1191|  1.17k|    maxstripsize = TIFFStripSize(tif);
 1192|       |
 1193|  1.17k|    flip = setorientation(img);
 1194|  1.17k|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|  1.17k|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1194:9): [True: 43, False: 1.12k]
  ------------------
 1195|     43|    {
 1196|     43|        if (w > INT_MAX / 2)
  ------------------
  |  Branch (1196:13): [True: 0, False: 43]
  ------------------
 1197|      0|        {
 1198|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
 1199|      0|            return (0);
 1200|      0|        }
 1201|     43|        y = h - 1;
 1202|       |        /* Skew back to the raster row before the currently written row
 1203|       |         * -> one raster width plus copied image pixels. */
 1204|     43|        toskew = -(int32_t)(w + wmin);
 1205|     43|    }
 1206|  1.12k|    else
 1207|  1.12k|    {
 1208|  1.12k|        y = 0;
 1209|       |        /* Skew forward to the end of the raster width of the row currently
 1210|       |         * copied. */
 1211|  1.12k|        toskew = (int32_t)(w - wmin);
 1212|  1.12k|    }
 1213|       |
 1214|  1.17k|    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
  ------------------
  |  |  258|  1.17k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 1215|  1.17k|    if (rowsperstrip == 0)
  ------------------
  |  Branch (1215:9): [True: 0, False: 1.17k]
  ------------------
 1216|      0|    {
 1217|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
 1218|      0|        return (0);
 1219|      0|    }
 1220|       |
 1221|  1.17k|    scanline = TIFFScanlineSize(tif);
 1222|  1.17k|    fromskew = (int32_t)(w < imagewidth ? imagewidth - w : 0);
  ------------------
  |  Branch (1222:26): [True: 0, False: 1.17k]
  ------------------
 1223|  2.08k|    for (row = 0; row < h; row += nrow)
  ------------------
  |  Branch (1223:19): [True: 1.80k, False: 278]
  ------------------
 1224|  1.80k|    {
 1225|  1.80k|        uint32_t temp;
 1226|  1.80k|        rowstoread = rowsperstrip -
 1227|  1.80k|                     (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip;
 1228|  1.80k|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1228:17): [True: 751, False: 1.05k]
  ------------------
 1229|  1.80k|        nrowsub = nrow;
 1230|  1.80k|        if ((nrowsub % subsamplingver) != 0)
  ------------------
  |  Branch (1230:13): [True: 622, False: 1.18k]
  ------------------
 1231|    622|            nrowsub += subsamplingver - nrowsub % subsamplingver;
 1232|  1.80k|        temp =
 1233|  1.80k|            (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip + nrowsub;
 1234|  1.80k|        if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
  ------------------
  |  |   68|  1.80k|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (1234:13): [True: 1.80k, False: 0]
  |  Branch (1234:29): [True: 0, False: 1.80k]
  ------------------
 1235|      0|        {
 1236|      0|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1237|      0|                          "Integer overflow in gtStripContig");
 1238|      0|            return 0;
 1239|      0|        }
 1240|  1.80k|        if (_TIFFReadEncodedStripAndAllocBuffer(
  ------------------
  |  Branch (1240:13): [True: 1.60k, False: 202]
  ------------------
 1241|  1.80k|                tif,
 1242|  1.80k|                TIFFComputeStrip(tif,
 1243|  1.80k|                                 (uint32_t)((int32_t)row + img->row_offset), 0),
 1244|  1.80k|                (void **)(&buf), maxstripsize,
 1245|  1.80k|                (tmsize_t)((size_t)temp * (size_t)scanline)) ==
 1246|  1.80k|                (tmsize_t)(-1) &&
 1247|  1.60k|            (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1247:14): [True: 894, False: 710]
  |  Branch (1247:29): [True: 0, False: 710]
  ------------------
 1248|    894|        {
 1249|    894|            ret = 0;
 1250|    894|            break;
 1251|    894|        }
 1252|       |
 1253|    912|        pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) %
 1254|    912|                         rowsperstrip) *
 1255|    912|                  scanline +
 1256|    912|              ((tmsize_t)img->col_offset * img->samplesperpixel);
 1257|    912|        tmsize_t roffset = (tmsize_t)y * w;
 1258|    912|        (*put)(img, raster + roffset, 0, y, wmin, nrow, fromskew, toskew,
 1259|    912|               buf + pos);
 1260|    912|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|    912|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1260:25): [True: 13, False: 899]
  ------------------
 1261|    912|                                                 : (int32_t)nrow);
 1262|    912|    }
 1263|       |
 1264|  1.17k|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|  1.17k|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1264:9): [True: 44, False: 1.12k]
  ------------------
 1265|     44|    {
 1266|       |        /* Flips the complete raster matrix horizontally. If raster width is
 1267|       |         * larger than image width, data are moved horizontally to the right
 1268|       |         * side.
 1269|       |         * Use wmin to only flip data in place. */
 1270|     44|        uint32_t line;
 1271|       |
 1272|   267k|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1272:24): [True: 267k, False: 44]
  ------------------
 1273|   267k|        {
 1274|   267k|            uint32_t *left = raster + (size_t)line * w;
 1275|       |            /* Use wmin to only flip horizontally data in place and not complete
 1276|       |             * raster-row. */
 1277|   267k|            uint32_t *right = left + wmin - 1;
 1278|       |
 1279|  4.48M|            while (left < right)
  ------------------
  |  Branch (1279:20): [True: 4.21M, False: 267k]
  ------------------
 1280|  4.21M|            {
 1281|  4.21M|                uint32_t temp = *left;
 1282|  4.21M|                *left = *right;
 1283|  4.21M|                *right = temp;
 1284|  4.21M|                left++;
 1285|  4.21M|                right--;
 1286|  4.21M|            }
 1287|   267k|        }
 1288|     44|    }
 1289|       |
 1290|  1.17k|    _TIFFfreeExt(img->tif, buf);
 1291|  1.17k|    return (ret);
 1292|  1.17k|}
tif_getimage.c:putRGBAAcontig8bittile:
 1862|     20|{
 1863|     20|    int samplesperpixel = img->samplesperpixel;
 1864|       |
 1865|     20|    (void)x;
 1866|     20|    (void)y;
 1867|     20|    const tmsize_t fromskewLocal =
 1868|     20|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1869|     40|    for (; h > 0; --h)
  ------------------
  |  Branch (1869:12): [True: 20, False: 20]
  ------------------
 1870|     20|    {
 1871|     20|        UNROLL8(w, NOP, *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]);
  ------------------
  |  | 1554|     20|    {                                                                          \
  |  | 1555|     20|        uint32_t _x;                                                           \
  |  | 1556|    100|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 80, False: 20]
  |  |  ------------------
  |  | 1557|     80|        {                                                                      \
  |  | 1558|     80|            op1;                                                               \
  |  | 1559|     80|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|     80|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|     80|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     80|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     80|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|     80|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     80|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     80|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|     80|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|     80|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     80|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     80|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|     80|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     80|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     80|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|     80|        }                                                                      \
  |  | 1561|     20|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 0, False: 20]
  |  |  ------------------
  |  | 1562|     20|        {                                                                      \
  |  | 1563|      0|            op1;                                                               \
  |  | 1564|      0|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|      0|    switch (x)                                                                 \
  |  |  |  | 1519|      0|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|      0|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1531|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|      0|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1533|      0|            op;                                                                \
  |  |  |  | 1534|      0|            break;                                                             \
  |  |  |  | 1535|      0|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|      0|    }
  |  |  ------------------
  |  | 1565|      0|        }                                                                      \
  |  | 1566|     20|    }
  ------------------
 1872|     20|                pp += samplesperpixel);
 1873|     20|        cp += toskew;
 1874|     20|        pp += fromskewLocal;
 1875|     20|    }
 1876|     20|}
tif_getimage.c:BuildMapUaToAa:
 3390|     57|{
 3391|     57|    static const char module[] = "BuildMapUaToAa";
 3392|     57|    uint8_t *m;
 3393|     57|    uint16_t na, nv;
 3394|     57|    assert(img->UaToAa == NULL);
  ------------------
  |  Branch (3394:5): [True: 0, False: 57]
  |  Branch (3394:5): [True: 57, False: 0]
  ------------------
 3395|     57|    img->UaToAa = (uint8_t *)_TIFFmallocExt(img->tif, 65536);
 3396|     57|    if (img->UaToAa == NULL)
  ------------------
  |  Branch (3396:9): [True: 0, False: 57]
  ------------------
 3397|      0|    {
 3398|      0|        TIFFErrorExtR(img->tif, module, "Out of memory");
 3399|      0|        return (0);
 3400|      0|    }
 3401|     57|    m = img->UaToAa;
 3402|  14.6k|    for (na = 0; na < 256; na++)
  ------------------
  |  Branch (3402:18): [True: 14.5k, False: 57]
  ------------------
 3403|  14.5k|    {
 3404|  3.75M|        for (nv = 0; nv < 256; nv++)
  ------------------
  |  Branch (3404:22): [True: 3.73M, False: 14.5k]
  ------------------
 3405|  3.73M|            *m++ = (uint8_t)((nv * na + 127) / 255);
 3406|  14.5k|    }
 3407|     57|    return (1);
 3408|     57|}
tif_getimage.c:putRGBUAcontig8bittile:
 1883|     12|{
 1884|     12|    int samplesperpixel = img->samplesperpixel;
 1885|     12|    (void)y;
 1886|     12|    const tmsize_t fromskewLocal =
 1887|     12|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1888|  2.18k|    for (; h > 0; --h)
  ------------------
  |  Branch (1888:12): [True: 2.17k, False: 12]
  ------------------
 1889|  2.17k|    {
 1890|  2.17k|        uint32_t r, g, b, a;
 1891|  2.17k|        uint8_t *m;
 1892|  71.8k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1892:21): [True: 69.6k, False: 2.17k]
  ------------------
 1893|  69.6k|        {
 1894|  69.6k|            a = pp[3];
 1895|  69.6k|            m = img->UaToAa + ((size_t)a << 8);
 1896|  69.6k|            r = m[pp[0]];
 1897|  69.6k|            g = m[pp[1]];
 1898|  69.6k|            b = m[pp[2]];
 1899|  69.6k|            *cp++ = PACK4(r, g, b, a);
  ------------------
  |  | 1614|  69.6k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|  69.6k|     ((uint32_t)(a) << 24))
  ------------------
 1900|  69.6k|            pp += samplesperpixel;
 1901|  69.6k|        }
 1902|  2.17k|        cp += toskew;
 1903|  2.17k|        pp += fromskewLocal;
 1904|  2.17k|    }
 1905|     12|}
tif_getimage.c:putRGBcontig8bittile:
 1841|    248|{
 1842|    248|    int samplesperpixel = img->samplesperpixel;
 1843|       |
 1844|    248|    (void)x;
 1845|    248|    (void)y;
 1846|    248|    const tmsize_t fromskewLocal =
 1847|    248|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1848|   176k|    for (; h > 0; --h)
  ------------------
  |  Branch (1848:12): [True: 176k, False: 248]
  ------------------
 1849|   176k|    {
 1850|   176k|        UNROLL8(w, NOP, *cp++ = PACK(pp[0], pp[1], pp[2]);
  ------------------
  |  | 1554|   176k|    {                                                                          \
  |  | 1555|   176k|        uint32_t _x;                                                           \
  |  | 1556|   872k|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 696k, False: 176k]
  |  |  ------------------
  |  | 1557|   696k|        {                                                                      \
  |  | 1558|   696k|            op1;                                                               \
  |  | 1559|   696k|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|   696k|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|   696k|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   696k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   696k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|   696k|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   696k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   696k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|   696k|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|   696k|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   696k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   696k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|   696k|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   696k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   696k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|   696k|        }                                                                      \
  |  | 1561|   176k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 2.06k, False: 174k]
  |  |  ------------------
  |  | 1562|   176k|        {                                                                      \
  |  | 1563|  2.06k|            op1;                                                               \
  |  | 1564|  2.06k|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|  2.06k|    switch (x)                                                                 \
  |  |  |  | 1519|  2.06k|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|     20|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 20, False: 2.04k]
  |  |  |  |  ------------------
  |  |  |  | 1531|     20|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|  2.06k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 2.04k, False: 20]
  |  |  |  |  ------------------
  |  |  |  | 1533|  2.06k|            op;                                                                \
  |  |  |  | 1534|  2.06k|            break;                                                             \
  |  |  |  | 1535|     20|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|  2.06k|    }
  |  |  ------------------
  |  | 1565|  2.06k|        }                                                                      \
  |  | 1566|   176k|    }
  ------------------
 1851|   176k|                pp += samplesperpixel);
 1852|   176k|        cp += toskew;
 1853|   176k|        pp += fromskewLocal;
 1854|   176k|    }
 1855|    248|}
tif_getimage.c:BuildMapBitdepth16To8:
 3411|    394|{
 3412|    394|    static const char module[] = "BuildMapBitdepth16To8";
 3413|    394|    uint8_t *m;
 3414|    394|    uint32_t n;
 3415|    394|    assert(img->Bitdepth16To8 == NULL);
  ------------------
  |  Branch (3415:5): [True: 0, False: 394]
  |  Branch (3415:5): [True: 394, False: 0]
  ------------------
 3416|    394|    img->Bitdepth16To8 = (uint8_t *)_TIFFmallocExt(img->tif, 65536);
 3417|    394|    if (img->Bitdepth16To8 == NULL)
  ------------------
  |  Branch (3417:9): [True: 0, False: 394]
  ------------------
 3418|      0|    {
 3419|      0|        TIFFErrorExtR(img->tif, module, "Out of memory");
 3420|      0|        return (0);
 3421|      0|    }
 3422|    394|    m = img->Bitdepth16To8;
 3423|  25.8M|    for (n = 0; n < 65536; n++)
  ------------------
  |  Branch (3423:17): [True: 25.8M, False: 394]
  ------------------
 3424|  25.8M|        *m++ = (uint8_t)((n + 128) / 257);
 3425|    394|    return (1);
 3426|    394|}
tif_getimage.c:putRGBAAcontig16bittile:
 1935|     60|{
 1936|     60|    int samplesperpixel = img->samplesperpixel;
 1937|     60|    uint16_t *wp = (uint16_t *)pp;
 1938|     60|    (void)y;
 1939|     60|    const tmsize_t fromskewLocal =
 1940|     60|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1941|    120|    for (; h > 0; --h)
  ------------------
  |  Branch (1941:12): [True: 60, False: 60]
  ------------------
 1942|     60|    {
 1943|  1.34k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1943:21): [True: 1.28k, False: 60]
  ------------------
 1944|  1.28k|        {
 1945|  1.28k|            *cp++ = PACK4(img->Bitdepth16To8[wp[0]], img->Bitdepth16To8[wp[1]],
  ------------------
  |  | 1614|  1.28k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|  1.28k|     ((uint32_t)(a) << 24))
  ------------------
 1946|  1.28k|                          img->Bitdepth16To8[wp[2]], img->Bitdepth16To8[wp[3]]);
 1947|  1.28k|            wp += samplesperpixel;
 1948|  1.28k|        }
 1949|     60|        cp += toskew;
 1950|     60|        wp += fromskewLocal;
 1951|     60|    }
 1952|     60|}
tif_getimage.c:buildMap:
 3082|    624|{
 3083|    624|    switch (img->photometric)
 3084|    624|    {
 3085|      0|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3085:9): [True: 0, False: 624]
  ------------------
 3086|      0|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|      0|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3086:9): [True: 0, False: 624]
  ------------------
 3087|     32|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|     32|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3087:9): [True: 32, False: 592]
  ------------------
 3088|     32|            if (img->bitspersample == 8)
  ------------------
  |  Branch (3088:17): [True: 22, False: 10]
  ------------------
 3089|     22|                break;
 3090|       |            /* fall through... */
 3091|    447|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    447|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3091:9): [True: 437, False: 187]
  ------------------
 3092|    555|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    555|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3092:9): [True: 108, False: 516]
  ------------------
 3093|    555|            if (!setupMap(img))
  ------------------
  |  Branch (3093:17): [True: 0, False: 555]
  ------------------
 3094|      0|                return (0);
 3095|    555|            break;
 3096|    555|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     25|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (3096:9): [True: 25, False: 599]
  ------------------
 3097|       |            /*
 3098|       |             * Convert 16-bit colormap to 8-bit (unless it looks
 3099|       |             * like an old-style 8-bit colormap).
 3100|       |             */
 3101|     25|            if (checkcmap(img) == 16)
  ------------------
  |  Branch (3101:17): [True: 18, False: 7]
  ------------------
 3102|     18|                cvtcmap(img);
 3103|      7|            else
 3104|      7|                TIFFWarningExtR(img->tif, TIFFFileName(img->tif),
 3105|      7|                                "Assuming 8-bit colormap");
 3106|       |            /*
 3107|       |             * Use mapping table and colormap to construct
 3108|       |             * unpacking tables for samples < 8 bits.
 3109|       |             */
 3110|     25|            if (img->bitspersample <= 8 && !makecmap(img))
  ------------------
  |  Branch (3110:17): [True: 25, False: 0]
  |  Branch (3110:44): [True: 0, False: 25]
  ------------------
 3111|      0|                return (0);
 3112|     25|            break;
 3113|     25|        default:
  ------------------
  |  Branch (3113:9): [True: 22, False: 602]
  ------------------
 3114|     22|            break;
 3115|    624|    }
 3116|    624|    return (1);
 3117|    624|}
tif_getimage.c:setupMap:
 2935|    555|{
 2936|    555|    int32_t x, range;
 2937|       |
 2938|    555|    range = (int32_t)((1U << img->bitspersample) - 1U);
 2939|       |
 2940|       |    /* treat 16 bit the same as eight bit */
 2941|    555|    if (img->bitspersample == 16)
  ------------------
  |  Branch (2941:9): [True: 83, False: 472]
  ------------------
 2942|     83|        range = 255;
 2943|       |
 2944|    555|    img->Map = (TIFFRGBValue *)_TIFFmallocExt(
 2945|    555|        img->tif, (tmsize_t)((size_t)(range + 1) * sizeof(TIFFRGBValue)));
 2946|    555|    if (img->Map == NULL)
  ------------------
  |  Branch (2946:9): [True: 0, False: 555]
  ------------------
 2947|      0|    {
 2948|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
 2949|      0|                      "No space for photometric conversion table");
 2950|      0|        return (0);
 2951|      0|    }
 2952|    555|    if (img->photometric == PHOTOMETRIC_MINISWHITE)
  ------------------
  |  |  221|    555|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (2952:9): [True: 108, False: 447]
  ------------------
 2953|    108|    {
 2954|  7.81k|        for (x = 0; x <= range; x++)
  ------------------
  |  Branch (2954:21): [True: 7.70k, False: 108]
  ------------------
 2955|  7.70k|            img->Map[x] = (TIFFRGBValue)(((range - x) * 255) / range);
 2956|    108|    }
 2957|    447|    else
 2958|    447|    {
 2959|  72.3k|        for (x = 0; x <= range; x++)
  ------------------
  |  Branch (2959:21): [True: 71.8k, False: 447]
  ------------------
 2960|  71.8k|            img->Map[x] = (TIFFRGBValue)((x * 255) / range);
 2961|    447|    }
 2962|    555|    if (img->bitspersample <= 16 &&
  ------------------
  |  Branch (2962:9): [True: 555, False: 0]
  ------------------
 2963|    555|        (img->photometric == PHOTOMETRIC_MINISBLACK ||
  ------------------
  |  |  222|  1.11k|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (2963:10): [True: 437, False: 118]
  ------------------
 2964|    118|         img->photometric == PHOTOMETRIC_MINISWHITE))
  ------------------
  |  |  221|    118|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (2964:10): [True: 108, False: 10]
  ------------------
 2965|    545|    {
 2966|       |        /*
 2967|       |         * Use photometric mapping table to construct
 2968|       |         * unpacking tables for samples <= 8 bits.
 2969|       |         */
 2970|    545|        if (!makebwmap(img))
  ------------------
  |  Branch (2970:13): [True: 0, False: 545]
  ------------------
 2971|      0|            return (0);
 2972|       |        /* no longer need Map, free it */
 2973|    545|        _TIFFfreeExt(img->tif, img->Map);
 2974|    545|        img->Map = NULL;
 2975|    545|    }
 2976|    555|    return (1);
 2977|    555|}
tif_getimage.c:makebwmap:
 2867|    545|{
 2868|    545|    TIFFRGBValue *Map = img->Map;
 2869|    545|    int bitspersample = img->bitspersample;
 2870|    545|    int nsamples = 8 / bitspersample;
 2871|    545|    int i;
 2872|    545|    uint32_t *p;
 2873|       |
 2874|    545|    if (nsamples == 0)
  ------------------
  |  Branch (2874:9): [True: 83, False: 462]
  ------------------
 2875|     83|        nsamples = 1;
 2876|       |
 2877|    545|    img->BWmap = (uint32_t **)_TIFFmallocExt(
 2878|    545|        img->tif,
 2879|    545|        (tmsize_t)((size_t)256 * sizeof(uint32_t *) +
 2880|    545|                   ((size_t)256 * (size_t)nsamples * sizeof(uint32_t))));
 2881|    545|    if (img->BWmap == NULL)
  ------------------
  |  Branch (2881:9): [True: 0, False: 545]
  ------------------
 2882|      0|    {
 2883|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
 2884|      0|                      "No space for B&W mapping table");
 2885|      0|        return (0);
 2886|      0|    }
 2887|    545|    p = (uint32_t *)(img->BWmap + 256);
 2888|   140k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (2888:17): [True: 139k, False: 545]
  ------------------
 2889|   139k|    {
 2890|   139k|        TIFFRGBValue c;
 2891|   139k|        img->BWmap[i] = p;
 2892|   139k|        switch (bitspersample)
 2893|   139k|        {
 2894|      0|#define GREY(x)                                                                \
 2895|      0|    c = Map[x];                                                                \
 2896|      0|    *p++ = PACK(c, c, c);
 2897|  52.2k|            case 1:
  ------------------
  |  Branch (2897:13): [True: 52.2k, False: 87.2k]
  ------------------
 2898|  52.2k|                GREY(i >> 7);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2899|  52.2k|                GREY((i >> 6) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2900|  52.2k|                GREY((i >> 5) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2901|  52.2k|                GREY((i >> 4) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2902|  52.2k|                GREY((i >> 3) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2903|  52.2k|                GREY((i >> 2) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2904|  52.2k|                GREY((i >> 1) & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2905|  52.2k|                GREY(i & 1);
  ------------------
  |  | 2895|  52.2k|    c = Map[x];                                                                \
  |  | 2896|  52.2k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  52.2k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  52.2k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2906|  52.2k|                break;
 2907|  4.60k|            case 2:
  ------------------
  |  Branch (2907:13): [True: 4.60k, False: 134k]
  ------------------
 2908|  4.60k|                GREY(i >> 6);
  ------------------
  |  | 2895|  4.60k|    c = Map[x];                                                                \
  |  | 2896|  4.60k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.60k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.60k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2909|  4.60k|                GREY((i >> 4) & 3);
  ------------------
  |  | 2895|  4.60k|    c = Map[x];                                                                \
  |  | 2896|  4.60k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.60k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.60k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2910|  4.60k|                GREY((i >> 2) & 3);
  ------------------
  |  | 2895|  4.60k|    c = Map[x];                                                                \
  |  | 2896|  4.60k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.60k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.60k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2911|  4.60k|                GREY(i & 3);
  ------------------
  |  | 2895|  4.60k|    c = Map[x];                                                                \
  |  | 2896|  4.60k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.60k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.60k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2912|  4.60k|                break;
 2913|  3.84k|            case 4:
  ------------------
  |  Branch (2913:13): [True: 3.84k, False: 135k]
  ------------------
 2914|  3.84k|                GREY(i >> 4);
  ------------------
  |  | 2895|  3.84k|    c = Map[x];                                                                \
  |  | 2896|  3.84k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  3.84k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  3.84k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2915|  3.84k|                GREY(i & 0xf);
  ------------------
  |  | 2895|  3.84k|    c = Map[x];                                                                \
  |  | 2896|  3.84k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  3.84k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  3.84k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|  3.84k|                break;
 2917|  57.6k|            case 8:
  ------------------
  |  Branch (2917:13): [True: 57.6k, False: 81.9k]
  ------------------
 2918|  78.8k|            case 16:
  ------------------
  |  Branch (2918:13): [True: 21.2k, False: 118k]
  ------------------
 2919|  78.8k|                GREY(i);
  ------------------
  |  | 2895|  78.8k|    c = Map[x];                                                                \
  |  | 2896|  78.8k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  78.8k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  78.8k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|  78.8k|                break;
 2921|      0|            default:
  ------------------
  |  Branch (2921:13): [True: 0, False: 139k]
  ------------------
 2922|      0|                break;
 2923|   139k|        }
 2924|   139k|#undef GREY
 2925|   139k|    }
 2926|    545|    return (1);
 2927|    545|}
tif_getimage.c:checkcmap:
 2980|     25|{
 2981|     25|    uint16_t *r = img->redcmap;
 2982|     25|    uint16_t *g = img->greencmap;
 2983|     25|    uint16_t *b = img->bluecmap;
 2984|     25|    long n = 1L << img->bitspersample;
 2985|       |
 2986|     88|    while (n-- > 0)
  ------------------
  |  Branch (2986:12): [True: 81, False: 7]
  ------------------
 2987|     81|        if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
  ------------------
  |  Branch (2987:13): [True: 7, False: 74]
  |  Branch (2987:28): [True: 7, False: 67]
  |  Branch (2987:43): [True: 4, False: 63]
  ------------------
 2988|     18|            return (16);
 2989|      7|    return (8);
 2990|     25|}
tif_getimage.c:cvtcmap:
 2993|     18|{
 2994|     18|    uint16_t *r = img->redcmap;
 2995|     18|    uint16_t *g = img->greencmap;
 2996|     18|    uint16_t *b = img->bluecmap;
 2997|     18|    long i;
 2998|       |
 2999|     90|    for (i = (1L << img->bitspersample) - 1; i >= 0; i--)
  ------------------
  |  Branch (2999:46): [True: 72, False: 18]
  ------------------
 3000|     72|    {
 3001|     72|#define CVT(x) ((uint16_t)((x) >> 8))
 3002|     72|        r[i] = CVT(r[i]);
  ------------------
  |  | 3001|     72|#define CVT(x) ((uint16_t)((x) >> 8))
  ------------------
 3003|     72|        g[i] = CVT(g[i]);
  ------------------
  |  | 3001|     72|#define CVT(x) ((uint16_t)((x) >> 8))
  ------------------
 3004|     72|        b[i] = CVT(b[i]);
  ------------------
  |  | 3001|     72|#define CVT(x) ((uint16_t)((x) >> 8))
  ------------------
 3005|     72|#undef CVT
 3006|     72|    }
 3007|     18|}
tif_getimage.c:makecmap:
 3017|     25|{
 3018|     25|    int bitspersample = img->bitspersample;
 3019|     25|    int nsamples = 8 / bitspersample;
 3020|     25|    uint16_t *r = img->redcmap;
 3021|     25|    uint16_t *g = img->greencmap;
 3022|     25|    uint16_t *b = img->bluecmap;
 3023|     25|    uint32_t *p;
 3024|     25|    int i;
 3025|       |
 3026|     25|    img->PALmap = (uint32_t **)_TIFFmallocExt(
 3027|     25|        img->tif,
 3028|     25|        (tmsize_t)((size_t)256 * sizeof(uint32_t *) +
 3029|     25|                   ((size_t)256 * (size_t)nsamples * sizeof(uint32_t))));
 3030|     25|    if (img->PALmap == NULL)
  ------------------
  |  Branch (3030:9): [True: 0, False: 25]
  ------------------
 3031|      0|    {
 3032|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
 3033|      0|                      "No space for Palette mapping table");
 3034|      0|        return (0);
 3035|      0|    }
 3036|     25|    p = (uint32_t *)(img->PALmap + 256);
 3037|  6.42k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (3037:17): [True: 6.40k, False: 25]
  ------------------
 3038|  6.40k|    {
 3039|  6.40k|        TIFFRGBValue c;
 3040|  6.40k|        img->PALmap[i] = p;
 3041|  6.40k|#define CMAP(x)                                                                \
 3042|  6.40k|    c = (TIFFRGBValue)x;                                                       \
 3043|  6.40k|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
 3044|  6.40k|        switch (bitspersample)
 3045|  6.40k|        {
 3046|      0|            case 1:
  ------------------
  |  Branch (3046:13): [True: 0, False: 6.40k]
  ------------------
 3047|      0|                CMAP(i >> 7);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3048|      0|                CMAP((i >> 6) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3049|      0|                CMAP((i >> 5) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3050|      0|                CMAP((i >> 4) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3051|      0|                CMAP((i >> 3) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3052|      0|                CMAP((i >> 2) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3053|      0|                CMAP((i >> 1) & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3054|      0|                CMAP(i & 1);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3055|      0|                break;
 3056|  6.40k|            case 2:
  ------------------
  |  Branch (3056:13): [True: 6.40k, False: 0]
  ------------------
 3057|  6.40k|                CMAP(i >> 6);
  ------------------
  |  | 3042|  6.40k|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|  6.40k|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|  6.40k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  6.40k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3058|  6.40k|                CMAP((i >> 4) & 3);
  ------------------
  |  | 3042|  6.40k|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|  6.40k|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|  6.40k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  6.40k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3059|  6.40k|                CMAP((i >> 2) & 3);
  ------------------
  |  | 3042|  6.40k|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|  6.40k|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|  6.40k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  6.40k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3060|  6.40k|                CMAP(i & 3);
  ------------------
  |  | 3042|  6.40k|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|  6.40k|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|  6.40k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  6.40k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3061|  6.40k|                break;
 3062|      0|            case 4:
  ------------------
  |  Branch (3062:13): [True: 0, False: 6.40k]
  ------------------
 3063|      0|                CMAP(i >> 4);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3064|      0|                CMAP(i & 0xf);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3065|      0|                break;
 3066|      0|            case 8:
  ------------------
  |  Branch (3066:13): [True: 0, False: 6.40k]
  ------------------
 3067|      0|                CMAP(i);
  ------------------
  |  | 3042|      0|    c = (TIFFRGBValue)x;                                                       \
  |  | 3043|      0|    *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3068|      0|                break;
 3069|      0|            default:
  ------------------
  |  Branch (3069:13): [True: 0, False: 6.40k]
  ------------------
 3070|      0|                break;
 3071|  6.40k|        }
 3072|  6.40k|#undef CMAP
 3073|  6.40k|    }
 3074|     25|    return (1);
 3075|     25|}
tif_getimage.c:putRGBcontig8bitCMYKtile:
 1990|      7|{
 1991|      7|    int samplesperpixel = img->samplesperpixel;
 1992|      7|    uint16_t r, g, b, k;
 1993|       |
 1994|      7|    (void)x;
 1995|      7|    (void)y;
 1996|      7|    const tmsize_t fromskewLocal =
 1997|      7|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1998|   131k|    for (; h > 0; --h)
  ------------------
  |  Branch (1998:12): [True: 131k, False: 7]
  ------------------
 1999|   131k|    {
 2000|   131k|        UNROLL8(w, NOP, k = (uint16_t)(255 - pp[3]);
  ------------------
  |  | 1554|   131k|    {                                                                          \
  |  | 1555|   131k|        uint32_t _x;                                                           \
  |  | 1556|   659k|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 527k, False: 131k]
  |  |  ------------------
  |  | 1557|   527k|        {                                                                      \
  |  | 1558|   527k|            op1;                                                               \
  |  | 1559|   527k|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|   527k|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|   527k|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   527k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   527k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|   527k|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   527k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   527k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|   527k|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|   527k|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   527k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   527k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|   527k|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|   527k|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|   527k|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|   527k|        }                                                                      \
  |  | 1561|   131k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 0, False: 131k]
  |  |  ------------------
  |  | 1562|   131k|        {                                                                      \
  |  | 1563|      0|            op1;                                                               \
  |  | 1564|      0|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|      0|    switch (x)                                                                 \
  |  |  |  | 1519|      0|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|      0|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1531|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|      0|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1533|      0|            op;                                                                \
  |  |  |  | 1534|      0|            break;                                                             \
  |  |  |  | 1535|      0|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|      0|    }
  |  |  ------------------
  |  | 1565|      0|        }                                                                      \
  |  | 1566|   131k|    }
  ------------------
 2001|   131k|                r = (uint16_t)((k * (uint16_t)(255 - pp[0])) / 255);
 2002|   131k|                g = (uint16_t)((k * (uint16_t)(255 - pp[1])) / 255);
 2003|   131k|                b = (uint16_t)((k * (uint16_t)(255 - pp[2])) / 255);
 2004|   131k|                *cp++ = PACK(r, g, b); pp += samplesperpixel);
 2005|   131k|        cp += toskew;
 2006|   131k|        pp += fromskewLocal;
 2007|   131k|    }
 2008|      7|}
tif_getimage.c:put16bitbwtile:
 1755|     43|{
 1756|     43|    int samplesperpixel = img->samplesperpixel;
 1757|     43|    uint32_t **BWmap = img->BWmap;
 1758|       |    /* Convert pixel skew to byte skew (16-bit samples) */
 1759|     43|    const tmsize_t fromskewLocal =
 1760|     43|        (tmsize_t)fromskew * (tmsize_t)(2 * samplesperpixel);
 1761|       |
 1762|     43|    (void)y;
 1763|  1.40k|    for (; h > 0; --h)
  ------------------
  |  Branch (1763:12): [True: 1.36k, False: 43]
  ------------------
 1764|  1.36k|    {
 1765|  1.36k|        uint16_t *wp = (uint16_t *)pp;
 1766|       |
 1767|  48.1k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1767:21): [True: 46.8k, False: 1.36k]
  ------------------
 1768|  46.8k|        {
 1769|       |            /* use high order byte of 16bit value */
 1770|       |
 1771|  46.8k|            *cp++ = BWmap[*wp >> 8][0];
 1772|  46.8k|            pp += 2 * samplesperpixel;
 1773|  46.8k|            wp += samplesperpixel;
 1774|  46.8k|        }
 1775|  1.36k|        cp += toskew;
 1776|  1.36k|        pp += fromskewLocal;
 1777|  1.36k|    }
 1778|     43|}
tif_getimage.c:putagreytile:
 1731|      1|{
 1732|      1|    int samplesperpixel = img->samplesperpixel;
 1733|      1|    uint32_t **BWmap = img->BWmap;
 1734|       |    /* Convert pixel skew to byte skew (8-bit samples) */
 1735|      1|    const tmsize_t fromskewLocal =
 1736|      1|        (tmsize_t)fromskew * +(tmsize_t)samplesperpixel;
 1737|       |
 1738|      1|    (void)y;
 1739|      8|    for (; h > 0; --h)
  ------------------
  |  Branch (1739:12): [True: 7, False: 1]
  ------------------
 1740|      7|    {
 1741|     21|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1741:21): [True: 14, False: 7]
  ------------------
 1742|     14|        {
 1743|     14|            *cp++ = BWmap[*pp][0] & ((uint32_t)*(pp + 1) << 24 | ~A1);
  ------------------
  |  | 1610|     14|#define A1 (((uint32_t)0xffL) << 24)
  ------------------
 1744|     14|            pp += samplesperpixel;
 1745|     14|        }
 1746|      7|        cp += toskew;
 1747|      7|        pp += fromskewLocal;
 1748|      7|    }
 1749|      1|}
tif_getimage.c:putgreytile:
 1707|    397|{
 1708|    397|    int samplesperpixel = img->samplesperpixel;
 1709|    397|    uint32_t **BWmap = img->BWmap;
 1710|       |    /* Convert pixel skew to byte skew (8-bit samples) */
 1711|    397|    const tmsize_t fromskewLocal =
 1712|    397|        (tmsize_t)fromskew * +(tmsize_t)samplesperpixel;
 1713|       |
 1714|    397|    (void)y;
 1715|   229k|    for (; h > 0; --h)
  ------------------
  |  Branch (1715:12): [True: 229k, False: 397]
  ------------------
 1716|   229k|    {
 1717|  4.51M|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1717:21): [True: 4.28M, False: 229k]
  ------------------
 1718|  4.28M|        {
 1719|  4.28M|            *cp++ = BWmap[*pp][0];
 1720|  4.28M|            pp += samplesperpixel;
 1721|  4.28M|        }
 1722|   229k|        cp += toskew;
 1723|   229k|        pp += fromskewLocal;
 1724|   229k|    }
 1725|    397|}
tif_getimage.c:put4bitbwtile:
 1822|      6|{
 1823|      6|    uint32_t **BWmap = img->BWmap;
 1824|       |
 1825|      6|    (void)x;
 1826|      6|    (void)y;
 1827|      6|    fromskew /= 2;
 1828|  12.4k|    for (; h > 0; --h)
  ------------------
  |  Branch (1828:12): [True: 12.4k, False: 6]
  ------------------
 1829|  12.4k|    {
 1830|  12.4k|        uint32_t *bw;
 1831|  12.4k|        UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1582|  12.4k|    {                                                                          \
  |  | 1583|  12.4k|        uint32_t _x;                                                           \
  |  | 1584|  68.2M|        for (_x = w; _x >= 2; _x -= 2)                                         \
  |  |  ------------------
  |  |  |  Branch (1584:22): [True: 68.1M, False: 12.4k]
  |  |  ------------------
  |  | 1585|  68.1M|        {                                                                      \
  |  | 1586|  68.1M|            op1;                                                               \
  |  | 1587|  68.1M|            REPEAT2(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1515|  68.1M|    op;                                                                        \
  |  |  |  | 1516|  68.1M|    op
  |  |  ------------------
  |  | 1588|  68.1M|        }                                                                      \
  |  | 1589|  12.4k|        if (_x)                                                                \
  |  |  ------------------
  |  |  |  Branch (1589:13): [True: 4.16k, False: 8.31k]
  |  |  ------------------
  |  | 1590|  12.4k|        {                                                                      \
  |  | 1591|  4.16k|            op1;                                                               \
  |  | 1592|  4.16k|            op2;                                                               \
  |  | 1593|  4.16k|        }                                                                      \
  |  | 1594|  12.4k|    }
  ------------------
 1832|  12.4k|        cp += toskew;
 1833|  12.4k|        pp += fromskew;
 1834|  12.4k|    }
 1835|      6|}
tif_getimage.c:put2bitbwtile:
 1803|     16|{
 1804|     16|    uint32_t **BWmap = img->BWmap;
 1805|       |
 1806|     16|    (void)x;
 1807|     16|    (void)y;
 1808|     16|    fromskew /= 4;
 1809|   325k|    for (; h > 0; --h)
  ------------------
  |  Branch (1809:12): [True: 325k, False: 16]
  ------------------
 1810|   325k|    {
 1811|   325k|        uint32_t *bw;
 1812|   325k|        UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1568|   325k|    {                                                                          \
  |  | 1569|   325k|        uint32_t _x;                                                           \
  |  | 1570|   325k|        for (_x = w; _x >= 4; _x -= 4)                                         \
  |  |  ------------------
  |  |  |  Branch (1570:22): [True: 0, False: 325k]
  |  |  ------------------
  |  | 1571|   325k|        {                                                                      \
  |  | 1572|      0|            op1;                                                               \
  |  | 1573|      0|            REPEAT4(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1512|      0|    REPEAT2(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1515|      0|    op;                                                                        \
  |  |  |  |  |  | 1516|      0|    op
  |  |  |  |  ------------------
  |  |  |  | 1513|      0|    REPEAT2(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1515|      0|    op;                                                                        \
  |  |  |  |  |  | 1516|      0|    op
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1574|      0|        }                                                                      \
  |  | 1575|   325k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1575:13): [True: 325k, False: 0]
  |  |  ------------------
  |  | 1576|   325k|        {                                                                      \
  |  | 1577|   325k|            op1;                                                               \
  |  | 1578|   325k|            CASE4(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1539|   325k|    switch (x)                                                                 \
  |  |  |  | 1540|   325k|    {                                                                          \
  |  |  |  | 1541|   316k|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1541:9): [True: 316k, False: 8.32k]
  |  |  |  |  ------------------
  |  |  |  | 1542|   316k|            op; /*-fallthrough*/                                               \
  |  |  |  | 1543|   316k|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1543:9): [True: 0, False: 325k]
  |  |  |  |  ------------------
  |  |  |  | 1544|   316k|            op; /*-fallthrough*/                                               \
  |  |  |  | 1545|   325k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1545:9): [True: 8.32k, False: 316k]
  |  |  |  |  ------------------
  |  |  |  | 1546|   325k|            op;                                                                \
  |  |  |  | 1547|   325k|            break;                                                             \
  |  |  |  | 1548|   316k|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1548:9): [True: 0, False: 325k]
  |  |  |  |  ------------------
  |  |  |  | 1549|      0|            break;                                                             \
  |  |  |  | 1550|   325k|    }
  |  |  ------------------
  |  | 1579|   325k|        }                                                                      \
  |  | 1580|   325k|    }
  ------------------
 1813|   325k|        cp += toskew;
 1814|   325k|        pp += fromskew;
 1815|   325k|    }
 1816|     16|}
tif_getimage.c:put1bitbwtile:
 1784|  5.42k|{
 1785|  5.42k|    uint32_t **BWmap = img->BWmap;
 1786|       |
 1787|  5.42k|    (void)x;
 1788|  5.42k|    (void)y;
 1789|  5.42k|    fromskew /= 8;
 1790|   230k|    for (; h > 0; --h)
  ------------------
  |  Branch (1790:12): [True: 225k, False: 5.42k]
  ------------------
 1791|   225k|    {
 1792|   225k|        uint32_t *bw;
 1793|   225k|        UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1554|   225k|    {                                                                          \
  |  | 1555|   225k|        uint32_t _x;                                                           \
  |  | 1556|  1.51M|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 1.28M, False: 225k]
  |  |  ------------------
  |  | 1557|  1.28M|        {                                                                      \
  |  | 1558|  1.28M|            op1;                                                               \
  |  | 1559|  1.28M|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|  1.28M|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|  1.28M|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.28M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.28M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|  1.28M|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.28M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.28M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|  1.28M|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|  1.28M|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.28M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.28M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|  1.28M|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.28M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.28M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|  1.28M|        }                                                                      \
  |  | 1561|   225k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 97.7k, False: 127k]
  |  |  ------------------
  |  | 1562|   225k|        {                                                                      \
  |  | 1563|  97.7k|            op1;                                                               \
  |  | 1564|  97.7k|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|  97.7k|    switch (x)                                                                 \
  |  |  |  | 1519|  97.7k|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|    538|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 538, False: 97.2k]
  |  |  |  |  ------------------
  |  |  |  | 1531|    538|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|  97.7k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 97.2k, False: 538]
  |  |  |  |  ------------------
  |  |  |  | 1533|  97.7k|            op;                                                                \
  |  |  |  | 1534|  97.7k|            break;                                                             \
  |  |  |  | 1535|    538|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|  97.7k|    }
  |  |  ------------------
  |  | 1565|  97.7k|        }                                                                      \
  |  | 1566|   225k|    }
  ------------------
 1794|   225k|        cp += toskew;
 1795|   225k|        pp += fromskew;
 1796|   225k|    }
 1797|  5.42k|}
tif_getimage.c:initYCbCrConversion:
 2764|    814|{
 2765|    814|    static const char module[] = "initYCbCrConversion";
 2766|       |
 2767|    814|    float *luma, *refBlackWhite;
 2768|       |
 2769|    814|    if (img->ycbcr == NULL)
  ------------------
  |  Branch (2769:9): [True: 814, False: 0]
  ------------------
 2770|    814|    {
 2771|    814|        img->ycbcr = (TIFFYCbCrToRGB *)_TIFFmallocExt(
 2772|    814|            img->tif, TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long)) +
  ------------------
  |  |  322|    814|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|    814|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 814, Folded]
  |  |  |  |  ------------------
  |  |  |  |  313|    814|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|    814|         : 0U)
  |  |  ------------------
  ------------------
 2773|    814|                          4 * 256 * sizeof(TIFFRGBValue) +
 2774|    814|                          2 * 256 * sizeof(int) + 3 * 256 * sizeof(int32_t));
 2775|    814|        if (img->ycbcr == NULL)
  ------------------
  |  Branch (2775:13): [True: 0, False: 814]
  ------------------
 2776|      0|        {
 2777|      0|            TIFFErrorExtR(img->tif, module,
 2778|      0|                          "No space for YCbCr->RGB conversion state");
 2779|      0|            return (0);
 2780|      0|        }
 2781|    814|    }
 2782|       |
 2783|    814|    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);
  ------------------
  |  |  387|    814|#define TIFFTAG_YCBCRCOEFFICIENTS 529      /* !RGB -> YCbCr transform */
  ------------------
 2784|    814|    TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE,
  ------------------
  |  |  392|    814|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
 2785|    814|                          &refBlackWhite);
 2786|       |
 2787|       |    /* Do some validation to avoid later issues. Detect NaN for now */
 2788|       |    /* and also if lumaGreen is zero since we divide by it later */
 2789|    814|    if (isnan(luma[0]) || isnan(luma[1]) || TIFF_FLOAT_EQ(luma[1], 0.0f) ||
  ------------------
  |  |  342|  1.62k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (342:29): [True: 8, False: 806]
  |  |  ------------------
  ------------------
  |  Branch (2789:9): [True: 0, False: 814]
  |  Branch (2789:27): [True: 0, False: 814]
  ------------------
 2790|    814|        isnan(luma[2]))
  ------------------
  |  Branch (2790:9): [True: 0, False: 806]
  ------------------
 2791|      8|    {
 2792|      8|        TIFFErrorExtR(img->tif, module,
 2793|      8|                      "Invalid values for YCbCrCoefficients tag");
 2794|      8|        return (0);
 2795|      8|    }
 2796|       |
 2797|    806|    if (!isInRefBlackWhiteRange(refBlackWhite[0]) ||
  ------------------
  |  Branch (2797:9): [True: 17, False: 789]
  ------------------
 2798|    789|        !isInRefBlackWhiteRange(refBlackWhite[1]) ||
  ------------------
  |  Branch (2798:9): [True: 13, False: 776]
  ------------------
 2799|    776|        !isInRefBlackWhiteRange(refBlackWhite[2]) ||
  ------------------
  |  Branch (2799:9): [True: 14, False: 762]
  ------------------
 2800|    762|        !isInRefBlackWhiteRange(refBlackWhite[3]) ||
  ------------------
  |  Branch (2800:9): [True: 8, False: 754]
  ------------------
 2801|    754|        !isInRefBlackWhiteRange(refBlackWhite[4]) ||
  ------------------
  |  Branch (2801:9): [True: 34, False: 720]
  ------------------
 2802|    720|        !isInRefBlackWhiteRange(refBlackWhite[5]))
  ------------------
  |  Branch (2802:9): [True: 11, False: 709]
  ------------------
 2803|     97|    {
 2804|     97|        TIFFErrorExtR(img->tif, module,
 2805|     97|                      "Invalid values for ReferenceBlackWhite tag");
 2806|     97|        return (0);
 2807|     97|    }
 2808|       |
 2809|    709|    if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0)
  ------------------
  |  Branch (2809:9): [True: 0, False: 709]
  ------------------
 2810|      0|        return (0);
 2811|    709|    return (1);
 2812|    709|}
tif_getimage.c:isInRefBlackWhiteRange:
 2759|  4.60k|{
 2760|  4.60k|    return f > (float)(-0x7FFFFFFF + 128) && f < (float)0x7FFFFFFF;
  ------------------
  |  Branch (2760:12): [True: 4.57k, False: 31]
  |  Branch (2760:46): [True: 4.51k, False: 66]
  ------------------
 2761|  4.60k|}
tif_getimage.c:putcontig8bitYCbCr42tile:
 2405|      2|{
 2406|      2|    uint32_t *cp1 = cp + w + toskew;
 2407|      2|    const tmsize_t incr = 2 * (tmsize_t)toskew + (tmsize_t)w;
 2408|       |
 2409|      2|    (void)y;
 2410|      2|    const tmsize_t fromskewLocal =
 2411|      2|        (tmsize_t)(fromskew / 4) * (tmsize_t)(4 * 2 + 2);
 2412|      2|    if ((w & 3) == 0 && (h & 1) == 0)
  ------------------
  |  Branch (2412:9): [True: 0, False: 2]
  |  Branch (2412:25): [True: 0, False: 0]
  ------------------
 2413|      0|    {
 2414|      0|        for (; h >= 2; h -= 2)
  ------------------
  |  Branch (2414:16): [True: 0, False: 0]
  ------------------
 2415|      0|        {
 2416|      0|            x = w >> 2;
 2417|      0|            do
 2418|      0|            {
 2419|      0|                int32_t Cb = pp[8];
 2420|      0|                int32_t Cr = pp[9];
 2421|       |
 2422|      0|                YCbCrtoRGB(cp[0], pp[0]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2423|      0|                YCbCrtoRGB(cp[1], pp[1]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2424|      0|                YCbCrtoRGB(cp[2], pp[2]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2425|      0|                YCbCrtoRGB(cp[3], pp[3]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2426|      0|                YCbCrtoRGB(cp1[0], pp[4]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2427|      0|                YCbCrtoRGB(cp1[1], pp[5]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2428|      0|                YCbCrtoRGB(cp1[2], pp[6]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2429|      0|                YCbCrtoRGB(cp1[3], pp[7]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2430|       |
 2431|      0|                cp += 4;
 2432|      0|                cp1 += 4;
 2433|      0|                pp += 10;
 2434|      0|            } while (--x);
  ------------------
  |  Branch (2434:22): [True: 0, False: 0]
  ------------------
 2435|      0|            cp += incr;
 2436|      0|            cp1 += incr;
 2437|      0|            pp += fromskewLocal;
 2438|      0|        }
 2439|      0|    }
 2440|      2|    else
 2441|      2|    {
 2442|     20|        while (h > 0)
  ------------------
  |  Branch (2442:16): [True: 20, False: 0]
  ------------------
 2443|     20|        {
 2444|     80|            for (x = w; x > 0;)
  ------------------
  |  Branch (2444:25): [True: 60, False: 20]
  ------------------
 2445|     60|            {
 2446|     60|                int32_t Cb = pp[8];
 2447|     60|                int32_t Cr = pp[9];
 2448|     60|                switch (x)
 2449|     60|                {
 2450|     40|                    default:
  ------------------
  |  Branch (2450:21): [True: 40, False: 20]
  ------------------
 2451|     40|                        switch (h)
 2452|     40|                        {
 2453|     40|                            default:
  ------------------
  |  Branch (2453:29): [True: 40, False: 0]
  ------------------
 2454|     40|                                YCbCrtoRGB(cp1[3], pp[7]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     40|    {                                                                          \
  |  | 2253|     40|        uint32_t r, g, b;                                                      \
  |  | 2254|     40|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     40|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     40|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     40|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     40|    }
  ------------------
 2455|     40|                            case 1:
  ------------------
  |  Branch (2455:29): [True: 0, False: 40]
  ------------------
 2456|     40|                                YCbCrtoRGB(cp[3], pp[3]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     40|    {                                                                          \
  |  | 2253|     40|        uint32_t r, g, b;                                                      \
  |  | 2254|     40|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     40|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     40|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     40|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     40|    }
  ------------------
 2457|     40|                        } /* FALLTHROUGH */
 2458|     40|                    case 3:
  ------------------
  |  Branch (2458:21): [True: 0, False: 60]
  ------------------
 2459|     40|                        switch (h)
 2460|     40|                        {
 2461|     40|                            default:
  ------------------
  |  Branch (2461:29): [True: 40, False: 0]
  ------------------
 2462|     40|                                YCbCrtoRGB(cp1[2], pp[6]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     40|    {                                                                          \
  |  | 2253|     40|        uint32_t r, g, b;                                                      \
  |  | 2254|     40|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     40|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     40|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     40|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     40|    }
  ------------------
 2463|     40|                            case 1:
  ------------------
  |  Branch (2463:29): [True: 0, False: 40]
  ------------------
 2464|     40|                                YCbCrtoRGB(cp[2], pp[2]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     40|    {                                                                          \
  |  | 2253|     40|        uint32_t r, g, b;                                                      \
  |  | 2254|     40|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     40|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     40|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     40|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     40|    }
  ------------------
 2465|     40|                        } /* FALLTHROUGH */
 2466|     60|                    case 2:
  ------------------
  |  Branch (2466:21): [True: 20, False: 40]
  ------------------
 2467|     60|                        switch (h)
 2468|     60|                        {
 2469|     60|                            default:
  ------------------
  |  Branch (2469:29): [True: 60, False: 0]
  ------------------
 2470|     60|                                YCbCrtoRGB(cp1[1], pp[5]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     60|    {                                                                          \
  |  | 2253|     60|        uint32_t r, g, b;                                                      \
  |  | 2254|     60|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     60|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     60|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     60|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     60|    }
  ------------------
 2471|     60|                            case 1:
  ------------------
  |  Branch (2471:29): [True: 0, False: 60]
  ------------------
 2472|     60|                                YCbCrtoRGB(cp[1], pp[1]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     60|    {                                                                          \
  |  | 2253|     60|        uint32_t r, g, b;                                                      \
  |  | 2254|     60|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     60|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     60|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     60|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     60|    }
  ------------------
 2473|     60|                        } /* FALLTHROUGH */
 2474|     60|                    case 1:
  ------------------
  |  Branch (2474:21): [True: 0, False: 60]
  ------------------
 2475|     60|                        switch (h)
 2476|     60|                        {
 2477|     60|                            default:
  ------------------
  |  Branch (2477:29): [True: 60, False: 0]
  ------------------
 2478|     60|                                YCbCrtoRGB(cp1[0], pp[4]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     60|    {                                                                          \
  |  | 2253|     60|        uint32_t r, g, b;                                                      \
  |  | 2254|     60|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     60|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     60|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     60|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     60|    }
  ------------------
 2479|     60|                            case 1:
  ------------------
  |  Branch (2479:29): [True: 0, False: 60]
  ------------------
 2480|     60|                                YCbCrtoRGB(cp[0], pp[0]); /* FALLTHROUGH */
  ------------------
  |  | 2252|     60|    {                                                                          \
  |  | 2253|     60|        uint32_t r, g, b;                                                      \
  |  | 2254|     60|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|     60|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|     60|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|     60|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|     60|    }
  ------------------
 2481|     60|                        } /* FALLTHROUGH */
 2482|     60|                }
 2483|     60|                if (x < 4)
  ------------------
  |  Branch (2483:21): [True: 20, False: 40]
  ------------------
 2484|     20|                {
 2485|     20|                    cp += x;
 2486|     20|                    cp1 += x;
 2487|     20|                    x = 0;
 2488|     20|                }
 2489|     40|                else
 2490|     40|                {
 2491|     40|                    cp += 4;
 2492|     40|                    cp1 += 4;
 2493|     40|                    x -= 4;
 2494|     40|                }
 2495|     60|                pp += 10;
 2496|     60|            }
 2497|     20|            if (h <= 2)
  ------------------
  |  Branch (2497:17): [True: 2, False: 18]
  ------------------
 2498|      2|                break;
 2499|     18|            h -= 2;
 2500|     18|            cp += incr;
 2501|     18|            cp1 += incr;
 2502|     18|            pp += fromskewLocal;
 2503|     18|        }
 2504|      2|    }
 2505|      2|}
tif_getimage.c:putcontig8bitYCbCr22tile:
 2565|    182|{
 2566|    182|    uint32_t *cp2;
 2567|    182|    const tmsize_t incr = 2 * (tmsize_t)toskew + (tmsize_t)w;
 2568|    182|    (void)y;
 2569|    182|    const tmsize_t fromskewLocal =
 2570|    182|        (tmsize_t)(fromskew / 2) * (tmsize_t)(2 * 2 + 2);
 2571|    182|    cp2 = cp + w + toskew;
 2572|  8.67k|    while (h >= 2)
  ------------------
  |  Branch (2572:12): [True: 8.49k, False: 182]
  ------------------
 2573|  8.49k|    {
 2574|  8.49k|        x = w;
 2575|   109k|        while (x >= 2)
  ------------------
  |  Branch (2575:16): [True: 100k, False: 8.49k]
  ------------------
 2576|   100k|        {
 2577|   100k|            uint32_t Cb = pp[4];
 2578|   100k|            uint32_t Cr = pp[5];
 2579|   100k|            YCbCrtoRGB(cp[0], pp[0]);
  ------------------
  |  | 2252|   100k|    {                                                                          \
  |  | 2253|   100k|        uint32_t r, g, b;                                                      \
  |  | 2254|   100k|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|   100k|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|   100k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|   100k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|   100k|    }
  ------------------
 2580|   100k|            YCbCrtoRGB(cp[1], pp[1]);
  ------------------
  |  | 2252|   100k|    {                                                                          \
  |  | 2253|   100k|        uint32_t r, g, b;                                                      \
  |  | 2254|   100k|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|   100k|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|   100k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|   100k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|   100k|    }
  ------------------
 2581|   100k|            YCbCrtoRGB(cp2[0], pp[2]);
  ------------------
  |  | 2252|   100k|    {                                                                          \
  |  | 2253|   100k|        uint32_t r, g, b;                                                      \
  |  | 2254|   100k|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|   100k|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|   100k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|   100k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|   100k|    }
  ------------------
 2582|   100k|            YCbCrtoRGB(cp2[1], pp[3]);
  ------------------
  |  | 2252|   100k|    {                                                                          \
  |  | 2253|   100k|        uint32_t r, g, b;                                                      \
  |  | 2254|   100k|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|   100k|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|   100k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|   100k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|   100k|    }
  ------------------
 2583|   100k|            cp += 2;
 2584|   100k|            cp2 += 2;
 2585|   100k|            pp += 6;
 2586|   100k|            x -= 2;
 2587|   100k|        }
 2588|  8.49k|        if (x == 1)
  ------------------
  |  Branch (2588:13): [True: 174, False: 8.32k]
  ------------------
 2589|    174|        {
 2590|    174|            uint32_t Cb = pp[4];
 2591|    174|            uint32_t Cr = pp[5];
 2592|    174|            YCbCrtoRGB(cp[0], pp[0]);
  ------------------
  |  | 2252|    174|    {                                                                          \
  |  | 2253|    174|        uint32_t r, g, b;                                                      \
  |  | 2254|    174|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|    174|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|    174|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|    174|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|    174|    }
  ------------------
 2593|    174|            YCbCrtoRGB(cp2[0], pp[2]);
  ------------------
  |  | 2252|    174|    {                                                                          \
  |  | 2253|    174|        uint32_t r, g, b;                                                      \
  |  | 2254|    174|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|    174|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|    174|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|    174|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|    174|    }
  ------------------
 2594|    174|            cp++;
 2595|    174|            cp2++;
 2596|    174|            pp += 6;
 2597|    174|        }
 2598|  8.49k|        cp += incr;
 2599|  8.49k|        cp2 += incr;
 2600|  8.49k|        pp += fromskewLocal;
 2601|  8.49k|        h -= 2;
 2602|  8.49k|    }
 2603|    182|    if (h == 1)
  ------------------
  |  Branch (2603:9): [True: 0, False: 182]
  ------------------
 2604|      0|    {
 2605|      0|        x = w;
 2606|      0|        while (x >= 2)
  ------------------
  |  Branch (2606:16): [True: 0, False: 0]
  ------------------
 2607|      0|        {
 2608|      0|            uint32_t Cb = pp[4];
 2609|      0|            uint32_t Cr = pp[5];
 2610|      0|            YCbCrtoRGB(cp[0], pp[0]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2611|      0|            YCbCrtoRGB(cp[1], pp[1]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2612|      0|            cp += 2;
 2613|      0|            cp2 += 2;
 2614|      0|            pp += 6;
 2615|      0|            x -= 2;
 2616|      0|        }
 2617|      0|        if (x == 1)
  ------------------
  |  Branch (2617:13): [True: 0, False: 0]
  ------------------
 2618|      0|        {
 2619|      0|            uint32_t Cb = pp[4];
 2620|      0|            uint32_t Cr = pp[5];
 2621|      0|            YCbCrtoRGB(cp[0], pp[0]);
  ------------------
  |  | 2252|      0|    {                                                                          \
  |  | 2253|      0|        uint32_t r, g, b;                                                      \
  |  | 2254|      0|        TIFFYCbCrtoRGB(img->ycbcr, (Y), (int32_t)Cb, (int32_t)Cr, &r, &g, &b); \
  |  | 2255|      0|        dst = PACK(r, g, b);                                                   \
  |  |  ------------------
  |  |  |  | 1612|      0|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|      0|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 2256|      0|    }
  ------------------
 2622|      0|        }
 2623|      0|    }
 2624|    182|}
tif_getimage.c:initCIELabConversion:
 2815|     22|{
 2816|     22|    static const char module[] = "initCIELabConversion";
 2817|       |
 2818|     22|    float *whitePoint;
 2819|     22|    float refWhite[3];
 2820|       |
 2821|     22|    TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint);
  ------------------
  |  |  307|     22|#define TIFFTAG_WHITEPOINT 318             /* image white point */
  ------------------
 2822|     22|    if (TIFF_FLOAT_EQ(whitePoint[1], 0.0f))
  ------------------
  |  |  342|     22|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (342:29): [True: 0, False: 22]
  |  |  ------------------
  ------------------
 2823|      0|    {
 2824|      0|        TIFFErrorExtR(img->tif, module, "Invalid value for WhitePoint tag.");
 2825|      0|        return NULL;
 2826|      0|    }
 2827|       |
 2828|     22|    if (!img->cielab)
  ------------------
  |  Branch (2828:9): [True: 22, False: 0]
  ------------------
 2829|     22|    {
 2830|     22|        img->cielab = (TIFFCIELabToRGB *)_TIFFmallocExt(
 2831|     22|            img->tif, sizeof(TIFFCIELabToRGB));
 2832|     22|        if (!img->cielab)
  ------------------
  |  Branch (2832:13): [True: 0, False: 22]
  ------------------
 2833|      0|        {
 2834|      0|            TIFFErrorExtR(img->tif, module,
 2835|      0|                          "No space for CIE L*a*b*->RGB conversion state.");
 2836|      0|            return NULL;
 2837|      0|        }
 2838|     22|    }
 2839|       |
 2840|     22|    refWhite[1] = 100.0f;
 2841|     22|    refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1];
 2842|     22|    refWhite[2] =
 2843|     22|        (1.0f - whitePoint[0] - whitePoint[1]) / whitePoint[1] * refWhite[1];
 2844|     22|    if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0)
  ------------------
  |  Branch (2844:9): [True: 0, False: 22]
  ------------------
 2845|      0|    {
 2846|      0|        TIFFErrorExtR(img->tif, module,
 2847|      0|                      "Failed to initialize CIE L*a*b*->RGB conversion state.");
 2848|      0|        _TIFFfreeExt(img->tif, img->cielab);
 2849|      0|        return NULL;
 2850|      0|    }
 2851|       |
 2852|     22|    if (img->bitspersample == 8)
  ------------------
  |  Branch (2852:9): [True: 18, False: 4]
  ------------------
 2853|     18|        return putcontig8bitCIELab8;
 2854|      4|    else if (img->bitspersample == 16)
  ------------------
  |  Branch (2854:14): [True: 4, False: 0]
  ------------------
 2855|      4|        return putcontig8bitCIELab16;
 2856|      0|    return NULL;
 2857|     22|}
tif_getimage.c:putcontig8bitCIELab8:
 2202|     14|{
 2203|     14|    float X, Y, Z;
 2204|     14|    uint32_t r, g, b;
 2205|     14|    (void)y;
 2206|     14|    const tmsize_t fromskewLocal = (tmsize_t)fromskew * (tmsize_t)3;
 2207|     84|    for (; h > 0; --h)
  ------------------
  |  Branch (2207:12): [True: 70, False: 14]
  ------------------
 2208|     70|    {
 2209|  2.31k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2209:21): [True: 2.24k, False: 70]
  ------------------
 2210|  2.24k|        {
 2211|  2.24k|            TIFFCIELabToXYZ(img->cielab, (unsigned char)pp[0],
 2212|  2.24k|                            (signed char)pp[1], (signed char)pp[2], &X, &Y, &Z);
 2213|  2.24k|            TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b);
 2214|  2.24k|            *cp++ = PACK(r, g, b);
  ------------------
  |  | 1612|  2.24k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  ------------------
  |  |  |  | 1610|  2.24k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  ------------------
  ------------------
 2215|  2.24k|            pp += 3;
 2216|  2.24k|        }
 2217|     70|        cp += toskew;
 2218|     70|        pp += fromskewLocal;
 2219|     70|    }
 2220|     14|}
tif_getimage.c:putcontig8bitCIELab16:
 2226|      4|{
 2227|      4|    float X, Y, Z;
 2228|      4|    uint32_t r, g, b;
 2229|      4|    uint16_t *wp = (uint16_t *)pp;
 2230|      4|    (void)y;
 2231|      4|    const tmsize_t fromskewLocal = (tmsize_t)fromskew * (tmsize_t)3;
 2232|    132|    for (; h > 0; --h)
  ------------------
  |  Branch (2232:12): [True: 128, False: 4]
  ------------------
 2233|    128|    {
 2234|  4.22k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2234:21): [True: 4.09k, False: 128]
  ------------------
 2235|  4.09k|        {
 2236|  4.09k|            TIFFCIELab16ToXYZ(img->cielab, (uint16_t)wp[0], (int16_t)wp[1],
 2237|  4.09k|                              (int16_t)wp[2], &X, &Y, &Z);
 2238|  4.09k|            TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b);
 2239|  4.09k|            *cp++ = PACK(r, g, b);
  ------------------
  |  | 1612|  4.09k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  ------------------
  |  |  |  | 1610|  4.09k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  ------------------
  ------------------
 2240|  4.09k|            wp += 3;
 2241|  4.09k|        }
 2242|    128|        cp += toskew;
 2243|    128|        wp += fromskewLocal;
 2244|    128|    }
 2245|      4|}
tif_getimage.c:PickSeparateCase:
 3311|    487|{
 3312|    487|    img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
  ------------------
  |  Branch (3312:16): [True: 270, False: 217]
  ------------------
 3313|    487|    img->put.separate = NULL;
 3314|    487|    switch (img->photometric)
 3315|    487|    {
 3316|     15|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|     15|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3316:9): [True: 15, False: 472]
  ------------------
 3317|    113|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    113|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3317:9): [True: 98, False: 389]
  ------------------
 3318|       |            /* greyscale images processed pretty much as RGB by gtTileSeparate
 3319|       |             */
 3320|    124|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|    124|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3320:9): [True: 11, False: 476]
  ------------------
 3321|    124|            switch (img->bitspersample)
 3322|    124|            {
 3323|     86|                case 8:
  ------------------
  |  Branch (3323:17): [True: 86, False: 38]
  ------------------
 3324|     86|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
  ------------------
  |  |  331|     86|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3324:25): [True: 31, False: 55]
  ------------------
 3325|     31|                        img->put.separate = putRGBAAseparate8bittile;
 3326|     55|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|     55|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3326:30): [True: 29, False: 26]
  ------------------
 3327|     29|                    {
 3328|     29|                        if (BuildMapUaToAa(img))
  ------------------
  |  Branch (3328:29): [True: 29, False: 0]
  ------------------
 3329|     29|                            img->put.separate = putRGBUAseparate8bittile;
 3330|     29|                    }
 3331|     26|                    else
 3332|     26|                        img->put.separate = putRGBseparate8bittile;
 3333|     86|                    break;
 3334|     28|                case 16:
  ------------------
  |  Branch (3334:17): [True: 28, False: 96]
  ------------------
 3335|     28|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
  ------------------
  |  |  331|     28|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3335:25): [True: 4, False: 24]
  ------------------
 3336|      4|                    {
 3337|      4|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3337:29): [True: 4, False: 0]
  ------------------
 3338|      4|                            img->put.separate = putRGBAAseparate16bittile;
 3339|      4|                    }
 3340|     24|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|     24|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3340:30): [True: 20, False: 4]
  ------------------
 3341|     20|                    {
 3342|     20|                        if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
  ------------------
  |  Branch (3342:29): [True: 20, False: 0]
  |  Branch (3342:59): [True: 20, False: 0]
  ------------------
 3343|     20|                            img->put.separate = putRGBUAseparate16bittile;
 3344|     20|                    }
 3345|      4|                    else
 3346|      4|                    {
 3347|      4|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3347:29): [True: 4, False: 0]
  ------------------
 3348|      4|                            img->put.separate = putRGBseparate16bittile;
 3349|      4|                    }
 3350|     28|                    break;
 3351|     10|                default:
  ------------------
  |  Branch (3351:17): [True: 10, False: 114]
  ------------------
 3352|     10|                    break;
 3353|    124|            }
 3354|    124|            break;
 3355|    124|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|     40|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3355:9): [True: 40, False: 447]
  ------------------
 3356|     40|            if (img->bitspersample == 8 && img->samplesperpixel == 4)
  ------------------
  |  Branch (3356:17): [True: 33, False: 7]
  |  Branch (3356:44): [True: 30, False: 3]
  ------------------
 3357|     30|            {
 3358|       |                /* Not alpha, but seems like the only way to get 4th band */
 3359|     30|                img->alpha = 1;
 3360|     30|                img->put.separate = putCMYKseparate8bittile;
 3361|     30|            }
 3362|     40|            break;
 3363|    300|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    300|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3363:9): [True: 300, False: 187]
  ------------------
 3364|    300|            if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
  ------------------
  |  Branch (3364:17): [True: 286, False: 14]
  |  Branch (3364:46): [True: 278, False: 8]
  ------------------
 3365|    278|            {
 3366|    278|                if (initYCbCrConversion(img) != 0)
  ------------------
  |  Branch (3366:21): [True: 260, False: 18]
  ------------------
 3367|    260|                {
 3368|    260|                    uint16_t hs, vs;
 3369|    260|                    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|    260|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 3370|    260|                                          &hs, &vs);
 3371|    260|                    switch ((hs << 4) | vs)
 3372|    260|                    {
 3373|    112|                        case 0x11:
  ------------------
  |  Branch (3373:25): [True: 112, False: 148]
  ------------------
 3374|    112|                            img->put.separate = putseparate8bitYCbCr11tile;
 3375|    112|                            break;
 3376|       |                            /* TODO: add other cases here */
 3377|    148|                        default:
  ------------------
  |  Branch (3377:25): [True: 148, False: 112]
  ------------------
 3378|    148|                            break;
 3379|    260|                    }
 3380|    260|                }
 3381|    278|            }
 3382|    300|            break;
 3383|    300|        default:
  ------------------
  |  Branch (3383:9): [True: 23, False: 464]
  ------------------
 3384|     23|            break;
 3385|    487|    }
 3386|    487|    return ((img->get != NULL) && (img->put.separate != NULL));
  ------------------
  |  Branch (3386:13): [True: 487, False: 0]
  |  Branch (3386:35): [True: 256, False: 231]
  ------------------
 3387|    487|}
tif_getimage.c:gtTileSeparate:
  905|    170|{
  906|    170|    TIFF *tif = img->tif;
  907|    170|    tileSeparateRoutine put = img->put.separate;
  908|    170|    uint32_t col, row, y, rowstoread;
  909|    170|    tmsize_t pos;
  910|    170|    uint32_t tw, th;
  911|    170|    unsigned char *buf = NULL;
  912|    170|    unsigned char *p0 = NULL;
  913|    170|    unsigned char *p1 = NULL;
  914|    170|    unsigned char *p2 = NULL;
  915|    170|    unsigned char *pa = NULL;
  916|    170|    tmsize_t tilesize;
  917|    170|    tmsize_t bufsize;
  918|    170|    int32_t fromskew, toskew;
  919|    170|    int alpha = img->alpha;
  920|    170|    uint32_t nrow;
  921|    170|    int ret = 1, flip;
  922|    170|    uint16_t colorchannels;
  923|    170|    uint32_t this_tw, tocol;
  924|    170|    int32_t this_toskew, leftmost_toskew;
  925|    170|    int32_t leftmost_fromskew;
  926|    170|    uint32_t leftmost_tw;
  927|       |
  928|       |    /* If the raster is smaller than the image,
  929|       |     * or if there is a col_offset, adapt the samples to be copied per row. */
  930|    170|    uint32_t wmin;
  931|    170|    if (0 <= img->col_offset && (uint32_t)img->col_offset < img->width)
  ------------------
  |  Branch (931:9): [True: 170, False: 0]
  |  Branch (931:33): [True: 170, False: 0]
  ------------------
  932|    170|    {
  933|    170|        wmin = TIFFmin(w, img->width - (uint32_t)img->col_offset);
  ------------------
  |  |  337|    170|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 170]
  |  |  ------------------
  ------------------
  934|    170|    }
  935|      0|    else
  936|      0|    {
  937|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
  938|      0|                      "Error in gtTileSeparate: column offset %d exceeds "
  939|      0|                      "image width %u",
  940|      0|                      img->col_offset, img->width);
  941|      0|        return 0;
  942|      0|    }
  943|       |
  944|    170|    tilesize = TIFFTileSize(tif);
  945|    170|    bufsize =
  946|    170|        _TIFFMultiplySSize(tif, alpha ? 4 : 3, tilesize, "gtTileSeparate");
  ------------------
  |  Branch (946:33): [True: 59, False: 111]
  ------------------
  947|    170|    if (bufsize == 0)
  ------------------
  |  Branch (947:9): [True: 0, False: 170]
  ------------------
  948|      0|    {
  949|      0|        return (0);
  950|      0|    }
  951|       |
  952|    170|    TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
  ------------------
  |  |  311|    170|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  953|    170|    TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
  ------------------
  |  |  312|    170|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  954|       |
  955|    170|    flip = setorientation(img);
  956|    170|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|    170|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (956:9): [True: 36, False: 134]
  ------------------
  957|     36|    {
  958|     36|        if (((int64_t)tw + w) > INT_MAX)
  ------------------
  |  Branch (958:13): [True: 10, False: 26]
  ------------------
  959|     10|        {
  960|     10|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  961|     10|                          "unsupported tile size (too wide)");
  962|     10|            return (0);
  963|     10|        }
  964|     26|        y = h - 1;
  965|     26|        toskew = -(int32_t)(tw + w);
  966|     26|    }
  967|    134|    else
  968|    134|    {
  969|    134|        if (tw > ((int64_t)INT_MAX + w) || w > ((int64_t)INT_MAX + tw))
  ------------------
  |  Branch (969:13): [True: 10, False: 124]
  |  Branch (969:44): [True: 0, False: 124]
  ------------------
  970|     10|        {
  971|     10|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  972|     10|                          "unsupported tile size (too wide)");
  973|     10|            return (0);
  974|     10|        }
  975|    124|        y = 0;
  976|    124|        toskew = -(int32_t)(tw - w);
  977|    124|    }
  978|       |
  979|    150|    switch (img->photometric)
  980|    150|    {
  981|      6|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      6|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (981:9): [True: 6, False: 144]
  ------------------
  982|     52|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|     52|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (982:9): [True: 46, False: 104]
  ------------------
  983|     52|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     52|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (983:9): [True: 0, False: 150]
  ------------------
  984|     52|            colorchannels = 1;
  985|     52|            break;
  986|       |
  987|     98|        default:
  ------------------
  |  Branch (987:9): [True: 98, False: 52]
  ------------------
  988|     98|            colorchannels = 3;
  989|     98|            break;
  990|    150|    }
  991|       |
  992|    150|    if (tw == 0 || th == 0)
  ------------------
  |  Branch (992:9): [True: 0, False: 150]
  |  Branch (992:20): [True: 0, False: 150]
  ------------------
  993|      0|    {
  994|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
  995|      0|        return (0);
  996|      0|    }
  997|       |
  998|       |    /*
  999|       |     *	Leftmost tile is clipped on left side if col_offset > 0.
 1000|       |     */
 1001|    150|    leftmost_fromskew = (int32_t)((uint32_t)img->col_offset % tw);
 1002|    150|    leftmost_tw = (uint32_t)((int32_t)tw - leftmost_fromskew);
 1003|    150|    int64_t skew_i64 = (int64_t)toskew + (int64_t)(int32_t)leftmost_fromskew;
 1004|    150|    if (skew_i64 > INT_MAX || skew_i64 < INT_MIN)
  ------------------
  |  Branch (1004:9): [True: 0, False: 150]
  |  Branch (1004:31): [True: 0, False: 150]
  ------------------
 1005|      0|    {
 1006|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s %" PRId64, "Invalid skew",
 1007|      0|                      skew_i64);
 1008|      0|        return (0);
 1009|      0|    }
 1010|    150|    leftmost_toskew = (int32_t)skew_i64;
 1011|  1.55k|    for (row = 0; ret != 0 && row < h; row += nrow)
  ------------------
  |  Branch (1011:19): [True: 1.51k, False: 44]
  |  Branch (1011:31): [True: 1.40k, False: 106]
  ------------------
 1012|  1.40k|    {
 1013|  1.40k|        rowstoread = th - ((uint32_t)row + (uint32_t)img->row_offset) % th;
 1014|  1.40k|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1014:17): [True: 125, False: 1.28k]
  ------------------
 1015|  1.40k|        fromskew = leftmost_fromskew;
 1016|  1.40k|        this_tw = leftmost_tw;
 1017|  1.40k|        this_toskew = leftmost_toskew;
 1018|  1.40k|        tocol = 0;
 1019|  1.40k|        col = (uint32_t)img->col_offset;
 1020|       |        /* wmin: only write imagewidth if raster is bigger. */
 1021|  20.2k|        while (tocol < wmin)
  ------------------
  |  Branch (1021:16): [True: 18.8k, False: 1.36k]
  ------------------
 1022|  18.8k|        {
 1023|  18.8k|            if (buf == NULL)
  ------------------
  |  Branch (1023:17): [True: 150, False: 18.7k]
  ------------------
 1024|    150|            {
 1025|    150|                if (_TIFFReadTileAndAllocBuffer(
  ------------------
  |  Branch (1025:21): [True: 60, False: 90]
  ------------------
 1026|    150|                        tif, (void **)&buf, bufsize, col,
 1027|    150|                        (uint32_t)((int32_t)row + img->row_offset), 0,
 1028|    150|                        0) == (tmsize_t)(-1) &&
 1029|     60|                    (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1029:22): [True: 44, False: 16]
  |  Branch (1029:37): [True: 0, False: 16]
  ------------------
 1030|     44|                {
 1031|     44|                    ret = 0;
 1032|     44|                    break;
 1033|     44|                }
 1034|    106|                p0 = buf;
 1035|    106|                if (colorchannels == 1)
  ------------------
  |  Branch (1035:21): [True: 29, False: 77]
  ------------------
 1036|     29|                {
 1037|     29|                    p2 = p1 = p0;
 1038|     29|                    pa = (alpha ? (p0 + 3 * tilesize) : NULL);
  ------------------
  |  Branch (1038:27): [True: 17, False: 12]
  ------------------
 1039|     29|                }
 1040|     77|                else
 1041|     77|                {
 1042|     77|                    p1 = p0 + tilesize;
 1043|     77|                    p2 = p1 + tilesize;
 1044|     77|                    pa = (alpha ? (p2 + tilesize) : NULL);
  ------------------
  |  Branch (1044:27): [True: 9, False: 68]
  ------------------
 1045|     77|                }
 1046|    106|            }
 1047|  18.7k|            else if (TIFFReadTile(tif, p0, col,
  ------------------
  |  Branch (1047:22): [True: 15.0k, False: 3.68k]
  ------------------
 1048|  18.7k|                                  (uint32_t)((int32_t)row + img->row_offset), 0,
 1049|  18.7k|                                  0) == (tmsize_t)(-1) &&
 1050|  15.0k|                     img->stoponerr)
  ------------------
  |  Branch (1050:22): [True: 0, False: 15.0k]
  ------------------
 1051|      0|            {
 1052|      0|                ret = 0;
 1053|      0|                break;
 1054|      0|            }
 1055|  18.8k|            if (colorchannels > 1 &&
  ------------------
  |  Branch (1055:17): [True: 10.9k, False: 7.92k]
  ------------------
 1056|  10.9k|                TIFFReadTile(tif, p1, col,
  ------------------
  |  Branch (1056:17): [True: 7.46k, False: 3.45k]
  ------------------
 1057|  10.9k|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1058|  10.9k|                             (uint16_t)1) == (tmsize_t)(-1) &&
 1059|  7.46k|                img->stoponerr)
  ------------------
  |  Branch (1059:17): [True: 0, False: 7.46k]
  ------------------
 1060|      0|            {
 1061|      0|                ret = 0;
 1062|      0|                break;
 1063|      0|            }
 1064|  18.8k|            if (colorchannels > 1 &&
  ------------------
  |  Branch (1064:17): [True: 10.9k, False: 7.92k]
  ------------------
 1065|  10.9k|                TIFFReadTile(tif, p2, col,
  ------------------
  |  Branch (1065:17): [True: 10.3k, False: 598]
  ------------------
 1066|  10.9k|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1067|  10.9k|                             (uint16_t)2) == (tmsize_t)(-1) &&
 1068|  10.3k|                img->stoponerr)
  ------------------
  |  Branch (1068:17): [True: 0, False: 10.3k]
  ------------------
 1069|      0|            {
 1070|      0|                ret = 0;
 1071|      0|                break;
 1072|      0|            }
 1073|  18.8k|            if (alpha &&
  ------------------
  |  Branch (1073:17): [True: 14.9k, False: 3.91k]
  ------------------
 1074|  14.9k|                TIFFReadTile(tif, pa, col,
  ------------------
  |  Branch (1074:17): [True: 14.6k, False: 280]
  ------------------
 1075|  14.9k|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1076|  14.9k|                             (uint16_t)colorchannels) == (tmsize_t)(-1) &&
 1077|  14.6k|                img->stoponerr)
  ------------------
  |  Branch (1077:17): [True: 0, False: 14.6k]
  ------------------
 1078|      0|            {
 1079|      0|                ret = 0;
 1080|      0|                break;
 1081|      0|            }
 1082|       |
 1083|       |            /* For SEPARATE the pos-offset is per sample and should not be
 1084|       |             * multiplied by img->samplesperpixel. */
 1085|  18.8k|            pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) % th) *
 1086|  18.8k|                      TIFFTileRowSize(tif) +
 1087|  18.8k|                  (tmsize_t)fromskew;
 1088|  18.8k|            if (tocol + this_tw > wmin)
  ------------------
  |  Branch (1088:17): [True: 16, False: 18.8k]
  ------------------
 1089|     16|            {
 1090|       |                /*
 1091|       |                 * Rightmost tile is clipped on right side.
 1092|       |                 */
 1093|     16|                fromskew = (int32_t)(tw - (wmin - tocol));
 1094|     16|                this_tw = (uint32_t)((int32_t)tw - fromskew);
 1095|     16|                this_toskew = (int32_t)(toskew + (int32_t)(uint32_t)fromskew);
 1096|     16|            }
 1097|  18.8k|            tmsize_t roffset = (tmsize_t)y * w + tocol;
 1098|  18.8k|            (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
 1099|  18.8k|                   this_toskew, p0 + pos, p1 + pos, p2 + pos,
 1100|  18.8k|                   (alpha ? (pa + pos) : NULL));
  ------------------
  |  Branch (1100:21): [True: 14.9k, False: 3.91k]
  ------------------
 1101|  18.8k|            tocol += this_tw;
 1102|  18.8k|            col += this_tw;
 1103|       |            /*
 1104|       |             * After the leftmost tile, tiles are no longer clipped on left
 1105|       |             * side.
 1106|       |             */
 1107|  18.8k|            fromskew = 0;
 1108|  18.8k|            this_tw = tw;
 1109|  18.8k|            this_toskew = toskew;
 1110|  18.8k|        }
 1111|       |
 1112|  1.40k|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|  1.40k|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1112:25): [True: 1.27k, False: 135]
  ------------------
 1113|  1.40k|                                                 : (int32_t)nrow);
 1114|  1.40k|    }
 1115|       |
 1116|    150|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|    150|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1116:9): [True: 21, False: 129]
  ------------------
 1117|     21|    {
 1118|     21|        uint32_t line;
 1119|       |
 1120|   229k|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1120:24): [True: 229k, False: 21]
  ------------------
 1121|   229k|        {
 1122|   229k|            uint32_t *left = raster + (size_t)line * w;
 1123|       |            /* Use wmin to only flip horizontally data in place and not complete
 1124|       |             * raster-row. */
 1125|   229k|            uint32_t *right = left + wmin - 1;
 1126|       |
 1127|  4.34M|            while (left < right)
  ------------------
  |  Branch (1127:20): [True: 4.11M, False: 229k]
  ------------------
 1128|  4.11M|            {
 1129|  4.11M|                uint32_t temp = *left;
 1130|  4.11M|                *left = *right;
 1131|  4.11M|                *right = temp;
 1132|  4.11M|                left++;
 1133|  4.11M|                right--;
 1134|  4.11M|            }
 1135|   229k|        }
 1136|     21|    }
 1137|       |
 1138|    150|    _TIFFfreeExt(img->tif, buf);
 1139|    150|    return (ret);
 1140|    150|}
tif_getimage.c:gtStripSeparate:
 1302|     86|{
 1303|     86|    TIFF *tif = img->tif;
 1304|     86|    tileSeparateRoutine put = img->put.separate;
 1305|     86|    unsigned char *buf = NULL;
 1306|     86|    unsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL;
 1307|     86|    uint32_t row, y, nrow, rowstoread;
 1308|     86|    tmsize_t pos;
 1309|     86|    tmsize_t scanline;
 1310|     86|    uint32_t rowsperstrip, offset_row;
 1311|     86|    uint32_t imagewidth = img->width;
 1312|     86|    tmsize_t stripsize;
 1313|     86|    tmsize_t bufsize;
 1314|     86|    int32_t fromskew, toskew;
 1315|     86|    int alpha = img->alpha;
 1316|     86|    int ret = 1, flip;
 1317|     86|    uint16_t colorchannels;
 1318|       |
 1319|       |    /* If the raster is smaller than the image,
 1320|       |     * or if there is a col_offset, adapt the samples to be copied per row. */
 1321|     86|    uint32_t wmin;
 1322|     86|    if (0 <= img->col_offset && (uint32_t)img->col_offset < imagewidth)
  ------------------
  |  Branch (1322:9): [True: 86, False: 0]
  |  Branch (1322:33): [True: 86, False: 0]
  ------------------
 1323|     86|    {
 1324|     86|        wmin = TIFFmin(w, imagewidth - (uint32_t)img->col_offset);
  ------------------
  |  |  337|     86|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 86]
  |  |  ------------------
  ------------------
 1325|     86|    }
 1326|      0|    else
 1327|      0|    {
 1328|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
 1329|      0|                      "Error in gtStripSeparate: column offset %d exceeds "
 1330|      0|                      "image width %u",
 1331|      0|                      img->col_offset, imagewidth);
 1332|      0|        return 0;
 1333|      0|    }
 1334|       |
 1335|     86|    stripsize = TIFFStripSize(tif);
 1336|     86|    bufsize =
 1337|     86|        _TIFFMultiplySSize(tif, alpha ? 4 : 3, stripsize, "gtStripSeparate");
  ------------------
  |  Branch (1337:33): [True: 60, False: 26]
  ------------------
 1338|     86|    if (bufsize == 0)
  ------------------
  |  Branch (1338:9): [True: 0, False: 86]
  ------------------
 1339|      0|    {
 1340|      0|        return (0);
 1341|      0|    }
 1342|       |
 1343|     86|    flip = setorientation(img);
 1344|     86|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|     86|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1344:9): [True: 38, False: 48]
  ------------------
 1345|     38|    {
 1346|     38|        if (w > INT_MAX / 2)
  ------------------
  |  Branch (1346:13): [True: 0, False: 38]
  ------------------
 1347|      0|        {
 1348|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
 1349|      0|            return (0);
 1350|      0|        }
 1351|     38|        y = h - 1;
 1352|       |        /* Skew back to the raster row before the currently written row
 1353|       |         * -> one raster width plus one image width. */
 1354|     38|        toskew = -(int32_t)(w + wmin);
 1355|     38|    }
 1356|     48|    else
 1357|     48|    {
 1358|     48|        y = 0;
 1359|       |        /* Skew forward to the end of the raster width of the row currently
 1360|       |         * written. */
 1361|     48|        toskew = (int32_t)(w - wmin);
 1362|     48|    }
 1363|       |
 1364|     86|    switch (img->photometric)
 1365|     86|    {
 1366|      5|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      5|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (1366:9): [True: 5, False: 81]
  ------------------
 1367|     37|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|     37|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (1367:9): [True: 32, False: 54]
  ------------------
 1368|     37|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     37|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (1368:9): [True: 0, False: 86]
  ------------------
 1369|     37|            colorchannels = 1;
 1370|     37|            break;
 1371|       |
 1372|     49|        default:
  ------------------
  |  Branch (1372:9): [True: 49, False: 37]
  ------------------
 1373|     49|            colorchannels = 3;
 1374|     49|            break;
 1375|     86|    }
 1376|       |
 1377|     86|    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
  ------------------
  |  |  258|     86|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 1378|     86|    if (rowsperstrip == 0)
  ------------------
  |  Branch (1378:9): [True: 0, False: 86]
  ------------------
 1379|      0|    {
 1380|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
 1381|      0|        return (0);
 1382|      0|    }
 1383|       |
 1384|     86|    scanline = TIFFScanlineSize(tif);
 1385|     86|    fromskew = (int32_t)(w < imagewidth ? imagewidth - w : 0);
  ------------------
  |  Branch (1385:26): [True: 0, False: 86]
  ------------------
 1386|    145|    for (row = 0; row < h; row += nrow)
  ------------------
  |  Branch (1386:19): [True: 116, False: 29]
  ------------------
 1387|    116|    {
 1388|    116|        uint32_t temp;
 1389|    116|        rowstoread =
 1390|    116|            rowsperstrip -
 1391|    116|            ((uint32_t)((int32_t)row + img->row_offset) % rowsperstrip);
 1392|    116|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1392:17): [True: 69, False: 47]
  ------------------
 1393|    116|        offset_row = (uint32_t)((int32_t)row + img->row_offset);
 1394|    116|        temp = (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip + nrow;
 1395|    116|        if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
  ------------------
  |  |   68|    116|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (1395:13): [True: 116, False: 0]
  |  Branch (1395:29): [True: 0, False: 116]
  ------------------
 1396|      0|        {
 1397|      0|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1398|      0|                          "Integer overflow in gtStripSeparate");
 1399|      0|            return 0;
 1400|      0|        }
 1401|    116|        if (buf == NULL)
  ------------------
  |  Branch (1401:13): [True: 86, False: 30]
  ------------------
 1402|     86|        {
 1403|     86|            if (_TIFFReadEncodedStripAndAllocBuffer(
  ------------------
  |  Branch (1403:17): [True: 70, False: 16]
  ------------------
 1404|     86|                    tif, TIFFComputeStrip(tif, offset_row, 0), (void **)&buf,
 1405|     86|                    bufsize, temp * scanline) == (tmsize_t)(-1) &&
 1406|     70|                (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1406:18): [True: 57, False: 13]
  |  Branch (1406:33): [True: 0, False: 13]
  ------------------
 1407|     57|            {
 1408|     57|                ret = 0;
 1409|     57|                break;
 1410|     57|            }
 1411|     29|            p0 = buf;
 1412|     29|            if (colorchannels == 1)
  ------------------
  |  Branch (1412:17): [True: 11, False: 18]
  ------------------
 1413|     11|            {
 1414|     11|                p2 = p1 = p0;
 1415|     11|                pa = (alpha ? (p0 + 3 * stripsize) : NULL);
  ------------------
  |  Branch (1415:23): [True: 7, False: 4]
  ------------------
 1416|     11|            }
 1417|     18|            else
 1418|     18|            {
 1419|     18|                p1 = p0 + stripsize;
 1420|     18|                p2 = p1 + stripsize;
 1421|     18|                pa = (alpha ? (p2 + stripsize) : NULL);
  ------------------
  |  Branch (1421:23): [True: 11, False: 7]
  ------------------
 1422|     18|            }
 1423|     29|        }
 1424|     30|        else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),
  ------------------
  |  Branch (1424:18): [True: 19, False: 11]
  ------------------
 1425|     30|                                      p0, temp * scanline) == (tmsize_t)(-1) &&
 1426|     19|                 img->stoponerr)
  ------------------
  |  Branch (1426:18): [True: 0, False: 19]
  ------------------
 1427|      0|        {
 1428|      0|            ret = 0;
 1429|      0|            break;
 1430|      0|        }
 1431|     59|        if (colorchannels > 1 &&
  ------------------
  |  Branch (1431:13): [True: 48, False: 11]
  ------------------
 1432|     48|            TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), p1,
  ------------------
  |  Branch (1432:13): [True: 24, False: 24]
  ------------------
 1433|     48|                                 temp * scanline) == (tmsize_t)(-1) &&
 1434|     24|            img->stoponerr)
  ------------------
  |  Branch (1434:13): [True: 0, False: 24]
  ------------------
 1435|      0|        {
 1436|      0|            ret = 0;
 1437|      0|            break;
 1438|      0|        }
 1439|     59|        if (colorchannels > 1 &&
  ------------------
  |  Branch (1439:13): [True: 48, False: 11]
  ------------------
 1440|     48|            TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), p2,
  ------------------
  |  Branch (1440:13): [True: 24, False: 24]
  ------------------
 1441|     48|                                 temp * scanline) == (tmsize_t)(-1) &&
 1442|     24|            img->stoponerr)
  ------------------
  |  Branch (1442:13): [True: 0, False: 24]
  ------------------
 1443|      0|        {
 1444|      0|            ret = 0;
 1445|      0|            break;
 1446|      0|        }
 1447|     59|        if (alpha)
  ------------------
  |  Branch (1447:13): [True: 48, False: 11]
  ------------------
 1448|     48|        {
 1449|     48|            if (TIFFReadEncodedStrip(
  ------------------
  |  Branch (1449:17): [True: 9, False: 39]
  ------------------
 1450|     48|                    tif, TIFFComputeStrip(tif, offset_row, colorchannels), pa,
 1451|     48|                    temp * scanline) == (tmsize_t)(-1) &&
 1452|      9|                img->stoponerr)
  ------------------
  |  Branch (1452:17): [True: 0, False: 9]
  ------------------
 1453|      0|            {
 1454|      0|                ret = 0;
 1455|      0|                break;
 1456|      0|            }
 1457|     48|        }
 1458|       |
 1459|       |        /* For SEPARATE the pos-offset is per sample and should not be
 1460|       |         * multiplied by img->samplesperpixel. */
 1461|     59|        pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) %
 1462|     59|                         rowsperstrip) *
 1463|     59|                  scanline +
 1464|     59|              (tmsize_t)img->col_offset;
 1465|     59|        tmsize_t roffset = (tmsize_t)y * w;
 1466|     59|        (*put)(img, raster + roffset, 0, y, wmin, nrow, fromskew, toskew,
 1467|     59|               p0 + pos, p1 + pos, p2 + pos, (alpha ? (pa + pos) : NULL));
  ------------------
  |  Branch (1467:47): [True: 48, False: 11]
  ------------------
 1468|     59|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|     59|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1468:25): [True: 13, False: 46]
  ------------------
 1469|     59|                                                 : (int32_t)nrow);
 1470|     59|    }
 1471|       |
 1472|     86|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|     86|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1472:9): [True: 39, False: 47]
  ------------------
 1473|     39|    {
 1474|     39|        uint32_t line;
 1475|       |
 1476|   471k|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1476:24): [True: 471k, False: 39]
  ------------------
 1477|   471k|        {
 1478|   471k|            uint32_t *left = raster + (size_t)line * w;
 1479|       |            /* Use wmin to only flip horizontally data in place and not complete
 1480|       |             * raster-row. */
 1481|   471k|            uint32_t *right = left + wmin - 1;
 1482|       |
 1483|  8.34M|            while (left < right)
  ------------------
  |  Branch (1483:20): [True: 7.86M, False: 471k]
  ------------------
 1484|  7.86M|            {
 1485|  7.86M|                uint32_t temp = *left;
 1486|  7.86M|                *left = *right;
 1487|  7.86M|                *right = temp;
 1488|  7.86M|                left++;
 1489|  7.86M|                right--;
 1490|  7.86M|            }
 1491|   471k|        }
 1492|     39|    }
 1493|       |
 1494|     86|    _TIFFfreeExt(img->tif, buf);
 1495|     86|    return (ret);
 1496|     86|}
tif_getimage.c:putRGBAAseparate8bittile:
 2067|      3|{
 2068|      3|    (void)img;
 2069|      3|    (void)x;
 2070|      3|    (void)y;
 2071|     99|    for (; h > 0; --h)
  ------------------
  |  Branch (2071:12): [True: 96, False: 3]
  ------------------
 2072|     96|    {
 2073|     96|        UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++));
  ------------------
  |  | 1554|     96|    {                                                                          \
  |  | 1555|     96|        uint32_t _x;                                                           \
  |  | 1556|    480|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 384, False: 96]
  |  |  ------------------
  |  | 1557|    384|        {                                                                      \
  |  | 1558|    384|            op1;                                                               \
  |  | 1559|    384|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|    384|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|    384|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    384|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    384|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|    384|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    384|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    384|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|    384|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|    384|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    384|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    384|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|    384|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    384|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    384|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|    384|        }                                                                      \
  |  | 1561|     96|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 0, False: 96]
  |  |  ------------------
  |  | 1562|     96|        {                                                                      \
  |  | 1563|      0|            op1;                                                               \
  |  | 1564|      0|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|      0|    switch (x)                                                                 \
  |  |  |  | 1519|      0|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|      0|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1531|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|      0|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1533|      0|            op;                                                                \
  |  |  |  | 1534|      0|            break;                                                             \
  |  |  |  | 1535|      0|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|      0|    }
  |  |  ------------------
  |  | 1565|      0|        }                                                                      \
  |  | 1566|     96|    }
  ------------------
 2074|     96|        SKEW4(r, g, b, a, fromskew);
  ------------------
  |  | 1603|     96|    {                                                                          \
  |  | 1604|     96|        r += skew;                                                             \
  |  | 1605|     96|        g += skew;                                                             \
  |  | 1606|     96|        b += skew;                                                             \
  |  | 1607|     96|        a += skew;                                                             \
  |  | 1608|     96|    }
  ------------------
 2075|     96|        cp += toskew;
 2076|     96|    }
 2077|      3|}
tif_getimage.c:putRGBUAseparate8bittile:
 2106|  7.44k|{
 2107|  7.44k|    (void)img;
 2108|  7.44k|    (void)y;
 2109|   122k|    for (; h > 0; --h)
  ------------------
  |  Branch (2109:12): [True: 115k, False: 7.44k]
  ------------------
 2110|   115k|    {
 2111|   115k|        uint32_t rv, gv, bv, av;
 2112|   115k|        uint8_t *m;
 2113|   318k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2113:21): [True: 203k, False: 115k]
  ------------------
 2114|   203k|        {
 2115|   203k|            av = *a++;
 2116|   203k|            m = img->UaToAa + ((size_t)av << 8);
 2117|   203k|            rv = m[*r++];
 2118|   203k|            gv = m[*g++];
 2119|   203k|            bv = m[*b++];
 2120|   203k|            *cp++ = PACK4(rv, gv, bv, av);
  ------------------
  |  | 1614|   203k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|   203k|     ((uint32_t)(a) << 24))
  ------------------
 2121|   203k|        }
 2122|   115k|        SKEW4(r, g, b, a, fromskew);
  ------------------
  |  | 1603|   115k|    {                                                                          \
  |  | 1604|   115k|        r += skew;                                                             \
  |  | 1605|   115k|        g += skew;                                                             \
  |  | 1606|   115k|        b += skew;                                                             \
  |  | 1607|   115k|        a += skew;                                                             \
  |  | 1608|   115k|    }
  ------------------
 2123|   115k|        cp += toskew;
 2124|   115k|    }
 2125|  7.44k|}
tif_getimage.c:putRGBseparate8bittile:
 2050|    490|{
 2051|    490|    (void)img;
 2052|    490|    (void)x;
 2053|    490|    (void)y;
 2054|    490|    (void)a;
 2055|  12.4k|    for (; h > 0; --h)
  ------------------
  |  Branch (2055:12): [True: 11.9k, False: 490]
  ------------------
 2056|  11.9k|    {
 2057|  11.9k|        UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++));
  ------------------
  |  | 1554|  11.9k|    {                                                                          \
  |  | 1555|  11.9k|        uint32_t _x;                                                           \
  |  | 1556|  12.5k|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 652, False: 11.9k]
  |  |  ------------------
  |  | 1557|  11.9k|        {                                                                      \
  |  | 1558|    652|            op1;                                                               \
  |  | 1559|    652|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|    652|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|    652|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    652|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    652|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|    652|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    652|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    652|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|    652|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|    652|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    652|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    652|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|    652|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|    652|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|    652|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|    652|        }                                                                      \
  |  | 1561|  11.9k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 11.7k, False: 163]
  |  |  ------------------
  |  | 1562|  11.9k|        {                                                                      \
  |  | 1563|  11.7k|            op1;                                                               \
  |  | 1564|  11.7k|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|  11.7k|    switch (x)                                                                 \
  |  |  |  | 1519|  11.7k|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|      0|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1531|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|  11.7k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 11.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1533|  11.7k|            op;                                                                \
  |  |  |  | 1534|  11.7k|            break;                                                             \
  |  |  |  | 1535|      0|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|  11.7k|    }
  |  |  ------------------
  |  | 1565|  11.7k|        }                                                                      \
  |  | 1566|  11.9k|    }
  ------------------
 2058|  11.9k|        SKEW(r, g, b, fromskew);
  ------------------
  |  | 1597|  11.9k|    {                                                                          \
  |  | 1598|  11.9k|        r += skew;                                                             \
  |  | 1599|  11.9k|        g += skew;                                                             \
  |  | 1600|  11.9k|        b += skew;                                                             \
  |  | 1601|  11.9k|    }
  ------------------
 2059|  11.9k|        cp += toskew;
 2060|  11.9k|    }
 2061|    490|}
tif_getimage.c:putRGBUAseparate16bittile:
 2173|      6|{
 2174|      6|    uint16_t *wr = (uint16_t *)r;
 2175|      6|    uint16_t *wg = (uint16_t *)g;
 2176|      6|    uint16_t *wb = (uint16_t *)b;
 2177|      6|    uint16_t *wa = (uint16_t *)a;
 2178|      6|    (void)img;
 2179|      6|    (void)y;
 2180|    102|    for (; h > 0; --h)
  ------------------
  |  Branch (2180:12): [True: 96, False: 6]
  ------------------
 2181|     96|    {
 2182|     96|        uint32_t r2, g2, b2, a2;
 2183|     96|        uint8_t *m;
 2184|    192|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2184:21): [True: 96, False: 96]
  ------------------
 2185|     96|        {
 2186|     96|            a2 = img->Bitdepth16To8[*wa++];
 2187|     96|            m = img->UaToAa + ((size_t)a2 << 8);
 2188|     96|            r2 = m[img->Bitdepth16To8[*wr++]];
 2189|     96|            g2 = m[img->Bitdepth16To8[*wg++]];
 2190|     96|            b2 = m[img->Bitdepth16To8[*wb++]];
 2191|     96|            *cp++ = PACK4(r2, g2, b2, a2);
  ------------------
  |  | 1614|     96|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|     96|     ((uint32_t)(a) << 24))
  ------------------
 2192|     96|        }
 2193|     96|        SKEW4(wr, wg, wb, wa, fromskew);
  ------------------
  |  | 1603|     96|    {                                                                          \
  |  | 1604|     96|        r += skew;                                                             \
  |  | 1605|     96|        g += skew;                                                             \
  |  | 1606|     96|        b += skew;                                                             \
  |  | 1607|     96|        a += skew;                                                             \
  |  | 1608|     96|    }
  ------------------
 2194|     96|        cp += toskew;
 2195|     96|    }
 2196|      6|}
tif_getimage.c:putCMYKseparate8bittile:
 2083|  7.41k|{
 2084|  7.41k|    (void)img;
 2085|  7.41k|    (void)y;
 2086|  7.36M|    for (; h > 0; --h)
  ------------------
  |  Branch (2086:12): [True: 7.35M, False: 7.41k]
  ------------------
 2087|  7.35M|    {
 2088|  7.35M|        unsigned int rv, gv, bv, kv;
 2089|  15.0M|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2089:21): [True: 7.70M, False: 7.35M]
  ------------------
 2090|  7.70M|        {
 2091|  7.70M|            kv = 255U - *a++;
 2092|  7.70M|            rv = (kv * (255U - *r++)) / 255U;
 2093|  7.70M|            gv = (kv * (255U - *g++)) / 255U;
 2094|  7.70M|            bv = (kv * (255U - *b++)) / 255U;
 2095|  7.70M|            *cp++ = PACK4(rv, gv, bv, 255);
  ------------------
  |  | 1614|  7.70M|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|  7.70M|     ((uint32_t)(a) << 24))
  ------------------
 2096|  7.70M|        }
 2097|  7.35M|        SKEW4(r, g, b, a, fromskew);
  ------------------
  |  | 1603|  7.35M|    {                                                                          \
  |  | 1604|  7.35M|        r += skew;                                                             \
  |  | 1605|  7.35M|        g += skew;                                                             \
  |  | 1606|  7.35M|        b += skew;                                                             \
  |  | 1607|  7.35M|        a += skew;                                                             \
  |  | 1608|  7.35M|    }
  ------------------
 2098|  7.35M|        cp += toskew;
 2099|  7.35M|    }
 2100|  7.41k|}
tif_getimage.c:putseparate8bitYCbCr11tile:
 2738|  3.54k|{
 2739|  3.54k|    (void)y;
 2740|  3.54k|    (void)a;
 2741|       |    /* TODO: naming of input vars is still off, change obfuscating declaration
 2742|       |     * inside define, or resolve obfuscation */
 2743|   133k|    for (; h > 0; --h)
  ------------------
  |  Branch (2743:12): [True: 129k, False: 3.54k]
  ------------------
 2744|   129k|    {
 2745|   129k|        x = w;
 2746|   129k|        do
 2747|   405k|        {
 2748|   405k|            uint32_t dr, dg, db;
 2749|   405k|            TIFFYCbCrtoRGB(img->ycbcr, *r++, *g++, *b++, &dr, &dg, &db);
 2750|   405k|            *cp++ = PACK(dr, dg, db);
  ------------------
  |  | 1612|   405k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  ------------------
  |  |  |  | 1610|   405k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  ------------------
  ------------------
 2751|   405k|        } while (--x);
  ------------------
  |  Branch (2751:18): [True: 275k, False: 129k]
  ------------------
 2752|   129k|        SKEW(r, g, b, fromskew);
  ------------------
  |  | 1597|   129k|    {                                                                          \
  |  | 1598|   129k|        r += skew;                                                             \
  |  | 1599|   129k|        g += skew;                                                             \
  |  | 1600|   129k|        b += skew;                                                             \
  |  | 1601|   129k|    }
  ------------------
 2753|   129k|        cp += toskew;
 2754|   129k|    }
 2755|  3.54k|}

TIFFHashSetNew:
  141|  2.55k|{
  142|  2.55k|    TIFFHashSet *set = (TIFFHashSet *)malloc(sizeof(TIFFHashSet));
  143|  2.55k|    if (set == NULL)
  ------------------
  |  Branch (143:9): [True: 0, False: 2.55k]
  ------------------
  144|      0|        return NULL;
  145|  2.55k|    set->fnHashFunc = fnHashFunc ? fnHashFunc : TIFFHashSetHashPointer;
  ------------------
  |  Branch (145:23): [True: 2.55k, False: 0]
  ------------------
  146|  2.55k|    set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer;
  ------------------
  |  Branch (146:24): [True: 2.55k, False: 0]
  ------------------
  147|  2.55k|    set->fnFreeEltFunc = fnFreeEltFunc;
  148|  2.55k|    set->nSize = 0;
  149|  2.55k|    set->tabList = (TIFFList **)(calloc(53, sizeof(TIFFList *)));
  150|  2.55k|    if (set->tabList == NULL)
  ------------------
  |  Branch (150:9): [True: 0, False: 2.55k]
  ------------------
  151|      0|    {
  152|      0|        free(set);
  153|      0|        return NULL;
  154|      0|    }
  155|  2.55k|    set->nIndiceAllocatedSize = 0;
  156|  2.55k|    set->nAllocatedSize = 53;
  157|  2.55k|    set->psRecyclingList = NULL;
  158|  2.55k|    set->nRecyclingListSize = 0;
  159|  2.55k|    set->bRehash = false;
  160|       |#ifdef HASH_DEBUG
  161|       |    set->nCollisions = 0;
  162|       |#endif
  163|  2.55k|    return set;
  164|  2.55k|}
TIFFHashSetSize:
  181|  3.82k|{
  182|  3.82k|    assert(set != NULL);
  ------------------
  |  Branch (182:5): [True: 0, False: 3.82k]
  |  Branch (182:5): [True: 3.82k, False: 0]
  ------------------
  183|  3.82k|    return set->nSize;
  184|  3.82k|}
TIFFHashSetDestroy:
  286|  2.55k|{
  287|  2.55k|    if (set)
  ------------------
  |  Branch (287:9): [True: 2.55k, False: 0]
  ------------------
  288|  2.55k|    {
  289|       |        TIFFHashSetClearInternal(set, true);
  290|  2.55k|        free(set->tabList);
  291|  2.55k|        TIFFListDestroy(set->psRecyclingList);
  292|  2.55k|        free(set);
  293|  2.55k|    }
  294|  2.55k|}
TIFFHashSetInsert:
  442|  7.65k|{
  443|  7.65k|    assert(set != NULL);
  ------------------
  |  Branch (443:5): [True: 0, False: 7.65k]
  |  Branch (443:5): [True: 7.65k, False: 0]
  ------------------
  444|  7.65k|    void **pElt = TIFFHashSetFindPtr(set, elt);
  445|  7.65k|    if (pElt)
  ------------------
  |  Branch (445:9): [True: 0, False: 7.65k]
  ------------------
  446|      0|    {
  447|      0|        if (set->fnFreeEltFunc)
  ------------------
  |  Branch (447:13): [True: 0, False: 0]
  ------------------
  448|      0|            set->fnFreeEltFunc(*pElt);
  449|       |
  450|      0|        *pElt = elt;
  451|      0|        return true;
  452|      0|    }
  453|       |
  454|  7.65k|    if (set->nSize >= 2 * set->nAllocatedSize / 3 ||
  ------------------
  |  Branch (454:9): [True: 0, False: 7.65k]
  ------------------
  455|  7.65k|        (set->bRehash && set->nIndiceAllocatedSize > 0 &&
  ------------------
  |  Branch (455:10): [True: 0, False: 7.65k]
  |  Branch (455:26): [True: 0, False: 0]
  ------------------
  456|      0|         set->nSize <= set->nAllocatedSize / 2))
  ------------------
  |  Branch (456:10): [True: 0, False: 0]
  ------------------
  457|      0|    {
  458|      0|        set->nIndiceAllocatedSize++;
  459|      0|        if (!TIFFHashSetRehash(set))
  ------------------
  |  Branch (459:13): [True: 0, False: 0]
  ------------------
  460|      0|        {
  461|      0|            set->nIndiceAllocatedSize--;
  462|      0|            if (set->fnFreeEltFunc)
  ------------------
  |  Branch (462:17): [True: 0, False: 0]
  ------------------
  463|      0|                set->fnFreeEltFunc(elt);
  464|      0|            return false;
  465|      0|        }
  466|      0|    }
  467|       |
  468|  7.65k|    const unsigned long nHashVal =
  469|  7.65k|        set->fnHashFunc(elt) % (unsigned long)set->nAllocatedSize;
  470|       |#ifdef HASH_DEBUG
  471|       |    if (set->tabList[nHashVal])
  472|       |        set->nCollisions++;
  473|       |#endif
  474|       |
  475|  7.65k|    TIFFList *new_elt = TIFFHashSetGetNewListElt(set);
  476|  7.65k|    if (new_elt == NULL)
  ------------------
  |  Branch (476:9): [True: 0, False: 7.65k]
  ------------------
  477|      0|    {
  478|      0|        if (set->fnFreeEltFunc)
  ------------------
  |  Branch (478:13): [True: 0, False: 0]
  ------------------
  479|      0|            set->fnFreeEltFunc(elt);
  480|      0|        return false;
  481|      0|    }
  482|  7.65k|    new_elt->pData = elt;
  483|  7.65k|    new_elt->psNext = set->tabList[nHashVal];
  484|  7.65k|    set->tabList[nHashVal] = new_elt;
  485|  7.65k|    set->nSize++;
  486|       |
  487|       |    return true;
  488|  7.65k|}
TIFFHashSetLookup:
  505|  7.65k|{
  506|  7.65k|    assert(set != NULL);
  ------------------
  |  Branch (506:5): [True: 0, False: 7.65k]
  |  Branch (506:5): [True: 7.65k, False: 0]
  ------------------
  507|  7.65k|    void **pElt = TIFFHashSetFindPtr(set, elt);
  508|  7.65k|    if (pElt)
  ------------------
  |  Branch (508:9): [True: 2, False: 7.65k]
  ------------------
  509|      2|        return *pElt;
  510|       |
  511|  7.65k|    return NULL;
  512|  7.65k|}
tif_hash_set.c:TIFFHashSetClearInternal:
  227|  2.55k|{
  228|  2.55k|    assert(set != NULL);
  ------------------
  |  Branch (228:5): [True: 0, False: 2.55k]
  |  Branch (228:5): [True: 2.55k, False: 0]
  ------------------
  229|   137k|    for (int i = 0; i < set->nAllocatedSize; i++)
  ------------------
  |  Branch (229:21): [True: 135k, False: 2.55k]
  ------------------
  230|   135k|    {
  231|   135k|        TIFFList *cur = set->tabList[i];
  232|   143k|        while (cur)
  ------------------
  |  Branch (232:16): [True: 7.65k, False: 135k]
  ------------------
  233|  7.65k|        {
  234|  7.65k|            if (set->fnFreeEltFunc)
  ------------------
  |  Branch (234:17): [True: 3.82k, False: 3.82k]
  ------------------
  235|  3.82k|                set->fnFreeEltFunc(cur->pData);
  236|  7.65k|            TIFFList *psNext = cur->psNext;
  237|  7.65k|            if (bFinalize)
  ------------------
  |  Branch (237:17): [True: 7.65k, False: 0]
  ------------------
  238|  7.65k|                free(cur);
  239|      0|            else
  240|      0|                TIFFHashSetReturnListElt(set, cur);
  241|  7.65k|            cur = psNext;
  242|  7.65k|        }
  243|   135k|        set->tabList[i] = NULL;
  244|   135k|    }
  245|       |    set->bRehash = false;
  246|  2.55k|}
tif_hash_set.c:TIFFListDestroy:
  261|  2.55k|{
  262|  2.55k|    TIFFList *psCurrent = psList;
  263|       |
  264|  2.55k|    while (psCurrent)
  ------------------
  |  Branch (264:12): [True: 0, False: 2.55k]
  ------------------
  265|      0|    {
  266|      0|        TIFFList *const psNext = psCurrent->psNext;
  267|      0|        free(psCurrent);
  268|      0|        psCurrent = psNext;
  269|      0|    }
  270|  2.55k|}
tif_hash_set.c:TIFFHashSetFindPtr:
  410|  15.3k|{
  411|  15.3k|    const unsigned long nHashVal =
  412|  15.3k|        set->fnHashFunc(elt) % (unsigned long)set->nAllocatedSize;
  413|  15.3k|    TIFFList *cur = set->tabList[nHashVal];
  414|  15.3k|    while (cur)
  ------------------
  |  Branch (414:12): [True: 92, False: 15.3k]
  ------------------
  415|     92|    {
  416|     92|        if (set->fnEqualFunc(cur->pData, elt))
  ------------------
  |  Branch (416:13): [True: 2, False: 90]
  ------------------
  417|      2|            return &cur->pData;
  418|     90|        cur = cur->psNext;
  419|     90|    }
  420|  15.3k|    return NULL;
  421|  15.3k|}
tif_hash_set.c:TIFFHashSetGetNewListElt:
  191|  7.65k|{
  192|  7.65k|    if (set->psRecyclingList)
  ------------------
  |  Branch (192:9): [True: 0, False: 7.65k]
  ------------------
  193|      0|    {
  194|      0|        TIFFList *psRet = set->psRecyclingList;
  195|      0|        psRet->pData = NULL;
  196|      0|        set->nRecyclingListSize--;
  197|      0|        set->psRecyclingList = psRet->psNext;
  198|      0|        return psRet;
  199|      0|    }
  200|       |
  201|  7.65k|    return (TIFFList *)malloc(sizeof(TIFFList));
  202|  7.65k|}

TIFFInitJBIG:
  241|      3|{
  242|      3|    (void)scheme;
  243|      3|    assert(scheme == COMPRESSION_JBIG);
  ------------------
  |  Branch (243:5): [True: 0, False: 3]
  |  Branch (243:5): [True: 3, False: 0]
  ------------------
  244|       |
  245|       |    /*
  246|       |     * These flags are set so the JBIG Codec can control when to reverse
  247|       |     * bits and when not to and to allow the jbig decoder and bit reverser
  248|       |     * to write to memory when necessary.
  249|       |     */
  250|      3|    tif->tif_flags |= TIFF_NOBITREV;
  ------------------
  |  |  127|      3|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  251|      3|    tif->tif_flags &= ~TIFF_MAPPED;
  ------------------
  |  |  130|      3|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  252|       |    /* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and
  253|       |     * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial
  254|       |     * value to be consistent with the state of a non-memory mapped file.
  255|       |     */
  256|      3|    if (tif->tif_flags & TIFF_BUFFERMMAP)
  ------------------
  |  |  145|      3|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  |  Branch (256:9): [True: 0, False: 3]
  ------------------
  257|      0|    {
  258|      0|        tif->tif_rawdata = NULL;
  259|      0|        tif->tif_rawdatasize = 0;
  260|      0|        tif->tif_flags &= ~TIFF_BUFFERMMAP;
  ------------------
  |  |  145|      0|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  261|      0|        tif->tif_flags |= TIFF_MYBUFFER;
  ------------------
  |  |  128|      0|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  262|      0|    }
  263|       |
  264|       |    /* Setup the function pointers for encode, decode, and cleanup. */
  265|      3|    tif->tif_setupdecode = JBIGSetupDecode;
  266|      3|    tif->tif_decodestrip = JBIGDecode;
  267|       |
  268|      3|    tif->tif_setupencode = JBIGSetupEncode;
  269|      3|    tif->tif_encodestrip = JBIGEncode;
  270|       |
  271|      3|    return 1;
  272|      3|}
tif_jbig.c:JBIGSetupDecode:
   46|      3|{
   47|      3|    if (TIFFNumberOfStrips(tif) != 1)
  ------------------
  |  Branch (47:9): [True: 0, False: 3]
  ------------------
   48|      0|    {
   49|      0|        TIFFErrorExtR(tif, "JBIG",
   50|      0|                      "Multistrip images not supported in decoder");
   51|      0|        return 0;
   52|      0|    }
   53|       |
   54|      3|    return 1;
   55|      3|}
tif_jbig.c:JBIGDecode:
   58|      3|{
   59|      3|    struct jbg_dec_state decoder;
   60|      3|    int decodeStatus = 0;
   61|      3|    unsigned char *pImage = NULL;
   62|      3|    unsigned long decodedSize;
   63|      3|    (void)s;
   64|       |
   65|      3|    if (isFillOrder(tif, tif->tif_dir.td_fillorder))
  ------------------
  |  |  280|      3|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  |  |  ------------------
  |  |  |  Branch (280:29): [True: 3, False: 0]
  |  |  ------------------
  ------------------
   66|      3|    {
   67|      3|        TIFFReverseBits(tif->tif_rawcp, tif->tif_rawcc);
   68|      3|    }
   69|       |
   70|      3|    jbg_dec_init(&decoder);
   71|       |
   72|      3|#if defined(HAVE_JBG_NEWLEN)
   73|      3|    jbg_newlen(tif->tif_rawcp, (size_t)tif->tif_rawcc);
   74|       |    /*
   75|       |     * I do not check the return status of jbg_newlen because even if this
   76|       |     * function fails it does not necessarily mean that decoding the image
   77|       |     * will fail.  It is generally only needed for received fax images
   78|       |     * that do not contain the actual length of the image in the BIE
   79|       |     * header.  I do not log when an error occurs because that will cause
   80|       |     * problems when converting JBIG encoded TIFF's to
   81|       |     * PostScript.  As long as the actual image length is contained in the
   82|       |     * BIE header jbg_dec_in should succeed.
   83|       |     */
   84|      3|#endif /* HAVE_JBG_NEWLEN */
   85|       |
   86|      3|    decodeStatus = jbg_dec_in(&decoder, (unsigned char *)tif->tif_rawcp,
   87|      3|                              (size_t)tif->tif_rawcc, NULL);
   88|      3|    if (JBG_EOK != decodeStatus)
  ------------------
  |  Branch (88:9): [True: 3, False: 0]
  ------------------
   89|      3|    {
   90|       |        /*
   91|       |         * XXX: JBG_EN constant was defined in pre-2.0 releases of the
   92|       |         * JBIG-KIT. Since the 2.0 the error reporting functions were
   93|       |         * changed. We will handle both cases here.
   94|       |         */
   95|      3|        TIFFErrorExtR(tif, "JBIG", "Error (%d) decoding: %s", decodeStatus,
   96|       |#if defined(JBG_EN)
   97|       |                      jbg_strerror(decodeStatus, JBG_EN)
   98|       |#else
   99|      3|                      jbg_strerror(decodeStatus)
  100|      3|#endif
  101|      3|        );
  102|      3|        memset(buffer, 0, (size_t)size);
  103|      3|        jbg_dec_free(&decoder);
  104|      3|        return 0;
  105|      3|    }
  106|       |
  107|      0|    decodedSize = jbg_dec_getsize(&decoder);
  108|      0|    if ((tmsize_t)decodedSize < size)
  ------------------
  |  Branch (108:9): [True: 0, False: 0]
  ------------------
  109|      0|    {
  110|      0|        memset(buffer + decodedSize, 0, (size_t)(size - (tmsize_t)decodedSize));
  111|      0|        TIFFWarningExtR(tif, "JBIG",
  112|      0|                        "Only decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT
  113|      0|                        " requested",
  114|      0|                        decodedSize, size);
  115|      0|    }
  116|      0|    else if ((tmsize_t)decodedSize > size)
  ------------------
  |  Branch (116:14): [True: 0, False: 0]
  ------------------
  117|      0|    {
  118|      0|        TIFFErrorExtR(tif, "JBIG",
  119|      0|                      "Decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT
  120|      0|                      " were requested",
  121|      0|                      decodedSize, size);
  122|      0|        jbg_dec_free(&decoder);
  123|      0|        return 0;
  124|      0|    }
  125|      0|    pImage = jbg_dec_getimage(&decoder, 0);
  126|      0|    _TIFFmemcpy(buffer, pImage, (tmsize_t)decodedSize);
  127|      0|    jbg_dec_free(&decoder);
  128|       |
  129|      0|    tif->tif_rawcp += tif->tif_rawcc;
  130|      0|    tif->tif_rawcc = 0;
  131|       |
  132|      0|    return 1;
  133|      0|}

TIFFInitJPEG:
 3013|    556|{
 3014|    556|    JPEGState *sp;
 3015|       |
 3016|    556|    (void)scheme;
 3017|    556|    assert(scheme == COMPRESSION_JPEG);
  ------------------
  |  Branch (3017:5): [True: 0, False: 556]
  |  Branch (3017:5): [True: 556, False: 0]
  ------------------
 3018|       |
 3019|       |    /*
 3020|       |     * Merge codec-specific tag information.
 3021|       |     */
 3022|    556|    if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields)))
  ------------------
  |  |  339|    556|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (3022:9): [True: 0, False: 556]
  ------------------
 3023|      0|    {
 3024|      0|        TIFFErrorExtR(tif, "TIFFInitJPEG",
 3025|      0|                      "Merging JPEG codec-specific tags failed");
 3026|      0|        return 0;
 3027|      0|    }
 3028|       |
 3029|       |    /*
 3030|       |     * Allocate state block so tag methods have storage to record values.
 3031|       |     */
 3032|    556|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(JPEGState));
 3033|       |
 3034|    556|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (3034:9): [True: 0, False: 556]
  ------------------
 3035|      0|    {
 3036|      0|        TIFFErrorExtR(tif, "TIFFInitJPEG", "No space for JPEG state block");
 3037|      0|        return 0;
 3038|      0|    }
 3039|    556|    _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
 3040|       |
 3041|    556|    sp = JState(tif);
  ------------------
  |  |  208|    556|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 3042|       |    /*
 3043|       |     * Override parent get/set field methods.
 3044|       |     */
 3045|    556|    sp->otherSettings.vgetparent = tif->tif_tagmethods.vgetfield;
 3046|    556|    sp->otherSettings.vsetparent = tif->tif_tagmethods.vsetfield;
 3047|    556|    sp->otherSettings.printdir = tif->tif_tagmethods.printdir;
 3048|       |
 3049|    556|    sp->otherSettings.defsparent = tif->tif_defstripsize;
 3050|    556|    sp->otherSettings.deftparent = tif->tif_deftilesize;
 3051|       |
 3052|    556|    TIFFInitJPEGCommon(tif);
 3053|       |
 3054|       |    /*
 3055|       |    ** Create a JPEGTables field if no directory has yet been created.
 3056|       |    ** We do this just to ensure that sufficient space is reserved for
 3057|       |    ** the JPEGTables field.  It will be properly created the right
 3058|       |    ** size later.
 3059|       |    */
 3060|    556|    if (tif->tif_diroff == 0)
  ------------------
  |  Branch (3060:9): [True: 0, False: 556]
  ------------------
 3061|      0|    {
 3062|      0|#define SIZE_OF_JPEGTABLES 2000
 3063|       |        /*
 3064|       |        The following line assumes incorrectly that all JPEG-in-TIFF files will
 3065|       |        have a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags
 3066|       |        to be written when the JPEG data is placed with TIFFWriteRawStrip.  The
 3067|       |        field bit should be set, anyway, later when actual JPEGTABLES header is
 3068|       |        generated, so removing it here hopefully is harmless.
 3069|       |        TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
 3070|       |        */
 3071|      0|        sp->otherSettings.jpegtables_length = SIZE_OF_JPEGTABLES;
  ------------------
  |  | 3062|      0|#define SIZE_OF_JPEGTABLES 2000
  ------------------
 3072|      0|        sp->otherSettings.jpegtables =
 3073|      0|            (void *)_TIFFmallocExt(tif, sp->otherSettings.jpegtables_length);
 3074|      0|        if (sp->otherSettings.jpegtables)
  ------------------
  |  Branch (3074:13): [True: 0, False: 0]
  ------------------
 3075|      0|        {
 3076|      0|            _TIFFmemset(sp->otherSettings.jpegtables, 0, SIZE_OF_JPEGTABLES);
  ------------------
  |  | 3062|      0|#define SIZE_OF_JPEGTABLES 2000
  ------------------
 3077|      0|        }
 3078|      0|        else
 3079|      0|        {
 3080|      0|            TIFFErrorExtR(tif, "TIFFInitJPEG",
 3081|      0|                          "Failed to allocate memory for JPEG tables");
 3082|      0|            return 0;
 3083|      0|        }
 3084|      0|#undef SIZE_OF_JPEGTABLES
 3085|      0|    }
 3086|    556|    return 1;
 3087|    556|}
tif_jpeg.c:TIFFjpeg_create_decompress:
  318|    373|{
  319|       |    /* initialize JPEG error handling */
  320|    373|    sp->cinfo.d.err = jpeg_std_error(&sp->err);
  321|    373|    sp->err.error_exit = TIFFjpeg_error_exit;
  322|    373|    sp->err.output_message = TIFFjpeg_output_message;
  323|       |
  324|       |    /* set client_data to avoid UMR warning from tools like Purify */
  325|    373|    sp->cinfo.d.client_data = NULL;
  326|       |
  327|       |    return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
  ------------------
  |  |  302|    373|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|    373|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    373|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (327:12): [True: 0, False: 373]
  ------------------
  328|    373|}
tif_jpeg.c:TIFFjpeg_error_exit:
  244|  37.6k|{
  245|  37.6k|    JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
  246|  37.6k|    char buffer[JMSG_LENGTH_MAX];
  247|       |
  248|  37.6k|    (*cinfo->err->format_message)(cinfo, buffer);
  249|  37.6k|    TIFFErrorExtR(sp->tif, "JPEGLib", "%s",
  250|  37.6k|                  buffer);       /* display the error message */
  251|  37.6k|    jpeg_abort(cinfo);           /* clean up libjpeg state */
  252|  37.6k|    LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
  ------------------
  |  |  143|  37.6k|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
  253|  37.6k|}
tif_jpeg.c:TIFFjpeg_output_message:
  261|  13.3k|{
  262|  13.3k|    char buffer[JMSG_LENGTH_MAX];
  263|       |
  264|  13.3k|    (*cinfo->err->format_message)(cinfo, buffer);
  265|  13.3k|    TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer);
  266|  13.3k|}
tif_jpeg.c:TIFFjpeg_data_src:
  744|    373|{
  745|    373|    sp->cinfo.d.src = &sp->src;
  746|    373|    sp->src.init_source = std_init_source;
  747|    373|    sp->src.fill_input_buffer = std_fill_input_buffer;
  748|    373|    sp->src.skip_input_data = std_skip_input_data;
  749|    373|    sp->src.resync_to_restart = jpeg_resync_to_restart;
  750|    373|    sp->src.term_source = std_term_source;
  751|    373|    sp->src.bytes_in_buffer = 0; /* for safety */
  752|       |    sp->src.next_input_byte = NULL;
  753|    373|}
tif_jpeg.c:std_init_source:
  674|  37.6k|{
  675|  37.6k|    JPEGState *sp = (JPEGState *)cinfo;
  676|  37.6k|    TIFF *tif = sp->tif;
  677|       |
  678|  37.6k|    sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata;
  679|  37.6k|    sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
  680|  37.6k|}
tif_jpeg.c:std_fill_input_buffer:
  683|  38.0k|{
  684|  38.0k|    JPEGState *sp = (JPEGState *)cinfo;
  685|  38.0k|    static const JOCTET dummy_EOI[2] = {0xFF, JPEG_EOI};
  686|       |
  687|       |#ifdef IPPJ_HUFF
  688|       |    /*
  689|       |     * The Intel IPP performance library does not necessarily read the whole
  690|       |     * input buffer in one pass, so it is possible to get here with data
  691|       |     * yet to read.
  692|       |     *
  693|       |     * We just return without doing anything, until the entire buffer has
  694|       |     * been read.
  695|       |     * http://trac.osgeo.org/gdal/wiki/JpegIPP
  696|       |     */
  697|       |    if (sp->src.bytes_in_buffer > 0)
  698|       |    {
  699|       |        return (TRUE);
  700|       |    }
  701|       |#endif
  702|       |
  703|       |    /*
  704|       |     * Normally the whole strip/tile is read and so we don't need to do
  705|       |     * a fill.  In the case of CHUNKY_STRIP_READ_SUPPORT we might not have
  706|       |     * all the data, but the rawdata is refreshed between scanlines and
  707|       |     * we push this into the io machinery in JPEGDecode().
  708|       |     * http://trac.osgeo.org/gdal/ticket/3894
  709|       |     */
  710|       |
  711|  38.0k|    WARNMS(cinfo, JWRN_JPEG_EOF);
  712|       |    /* insert a fake EOI marker */
  713|  38.0k|    sp->src.next_input_byte = dummy_EOI;
  714|  38.0k|    sp->src.bytes_in_buffer = 2;
  715|  38.0k|    return (TRUE);
  ------------------
  |  |   71|  38.0k|#define TRUE 1
  ------------------
  716|  38.0k|}
tif_jpeg.c:std_skip_input_data:
  719|  13.9k|{
  720|  13.9k|    JPEGState *sp = (JPEGState *)cinfo;
  721|       |
  722|  13.9k|    if (num_bytes > 0)
  ------------------
  |  Branch (722:9): [True: 13.9k, False: 0]
  ------------------
  723|  13.9k|    {
  724|  13.9k|        if ((size_t)num_bytes > sp->src.bytes_in_buffer)
  ------------------
  |  Branch (724:13): [True: 1.51k, False: 12.4k]
  ------------------
  725|  1.51k|        {
  726|       |            /* oops, buffer overrun */
  727|  1.51k|            (void)std_fill_input_buffer(cinfo);
  728|  1.51k|        }
  729|  12.4k|        else
  730|  12.4k|        {
  731|  12.4k|            sp->src.next_input_byte += (size_t)num_bytes;
  732|  12.4k|            sp->src.bytes_in_buffer -= (size_t)num_bytes;
  733|  12.4k|        }
  734|  13.9k|    }
  735|  13.9k|}
tif_jpeg.c:TIFFjpeg_read_header:
  396|  37.6k|{
  397|       |    return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image));
  ------------------
  |  |  301|  37.6k|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|  37.6k|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (397:12): [True: 37.6k, False: 37]
  ------------------
  398|  37.6k|}
tif_jpeg.c:TIFFjpeg_destroy:
  525|    373|{
  526|       |    return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm));
  ------------------
  |  |  302|    373|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|    373|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    373|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (526:12): [True: 0, False: 373]
  ------------------
  527|    373|}
tif_jpeg.c:TIFFjpeg_has_multiple_scans:
  401|      3|{
  402|       |    return CALLJPEG(sp, 0, jpeg_has_multiple_scans(&sp->cinfo.d));
  ------------------
  |  |  301|      3|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|      3|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (402:12): [True: 0, False: 3]
  ------------------
  403|      3|}
tif_jpeg.c:TIFFInitJPEGCommon:
 2969|    556|{
 2970|    556|    JPEGState *sp;
 2971|       |
 2972|    556|    sp = JState(tif);
  ------------------
  |  |  208|    556|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2973|    556|    sp->tif = tif; /* back link */
 2974|       |
 2975|       |    /* Default values for codec-specific fields */
 2976|    556|    sp->otherSettings.jpegtables = NULL;
 2977|    556|    sp->otherSettings.jpegtables_length = 0;
 2978|    556|    sp->otherSettings.jpegquality = 75; /* Default IJG quality */
 2979|    556|    sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW;
  ------------------
  |  |  707|    556|#define JPEGCOLORMODE_RAW 0x0000     /* no conversion (default) */
  ------------------
 2980|    556|    sp->otherSettings.jpegtablesmode =
 2981|    556|        JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  710|    556|#define JPEGTABLESMODE_QUANT 0x0001  /* include quantization tbls */
  ------------------
                      JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  711|    556|#define JPEGTABLESMODE_HUFF 0x0002   /* include Huffman tbls */
  ------------------
 2982|    556|    sp->otherSettings.ycbcrsampling_fetched = 0;
 2983|       |
 2984|    556|    tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
 2985|    556|    tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
 2986|    556|    tif->tif_tagmethods.printdir = JPEGPrintDir;   /* hook for codec tags */
 2987|       |
 2988|       |    /*
 2989|       |     * Install codec methods.
 2990|       |     */
 2991|    556|    tif->tif_fixuptags = JPEGFixupTags;
 2992|    556|    tif->tif_setupdecode = JPEGSetupDecode;
 2993|    556|    tif->tif_predecode = JPEGPreDecode;
 2994|    556|    tif->tif_decoderow = JPEGDecode;
 2995|    556|    tif->tif_decodestrip = JPEGDecode;
 2996|    556|    tif->tif_decodetile = JPEGDecode;
 2997|    556|    tif->tif_setupencode = JPEGSetupEncode;
 2998|    556|    tif->tif_preencode = JPEGPreEncode;
 2999|    556|    tif->tif_postencode = JPEGPostEncode;
 3000|    556|    tif->tif_encoderow = JPEGEncode;
 3001|    556|    tif->tif_encodestrip = JPEGEncode;
 3002|    556|    tif->tif_encodetile = JPEGEncode;
 3003|    556|    tif->tif_getmaxcompressionratio = JPEGGetMaxCompressionRatio;
 3004|    556|    tif->tif_cleanup = JPEGCleanup;
 3005|       |
 3006|    556|    tif->tif_defstripsize = JPEGDefaultStripSize;
 3007|    556|    tif->tif_deftilesize = JPEGDefaultTileSize;
 3008|    556|    tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
  ------------------
  |  |  127|    556|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 3009|    556|    sp->cinfo_initialized = FALSE;
  ------------------
  |  |   72|    556|#define FALSE 0
  ------------------
 3010|    556|}
tif_jpeg.c:JPEGVGetField:
 2796|  5.99k|{
 2797|  5.99k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  5.99k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2798|       |
 2799|  5.99k|    assert(sp != NULL);
  ------------------
  |  Branch (2799:5): [True: 0, False: 5.99k]
  |  Branch (2799:5): [True: 5.99k, False: 0]
  ------------------
 2800|       |
 2801|  5.99k|    switch (tag)
 2802|  5.99k|    {
 2803|      0|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|      0|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2803:9): [True: 0, False: 5.99k]
  ------------------
 2804|      0|            *va_arg(ap, uint32_t *) = sp->otherSettings.jpegtables_length;
 2805|      0|            *va_arg(ap, const void **) = sp->otherSettings.jpegtables;
 2806|      0|            break;
 2807|      0|        case TIFFTAG_JPEGQUALITY:
  ------------------
  |  |  704|      0|#define TIFFTAG_JPEGQUALITY 65537    /* Compression quality level */
  ------------------
  |  Branch (2807:9): [True: 0, False: 5.99k]
  ------------------
 2808|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegquality;
 2809|      0|            break;
 2810|      0|        case TIFFTAG_JPEGCOLORMODE:
  ------------------
  |  |  706|      0|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  |  Branch (2810:9): [True: 0, False: 5.99k]
  ------------------
 2811|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegcolormode;
 2812|      0|            break;
 2813|      0|        case TIFFTAG_JPEGTABLESMODE:
  ------------------
  |  |  709|      0|#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
  ------------------
  |  Branch (2813:9): [True: 0, False: 5.99k]
  ------------------
 2814|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode;
 2815|      0|            break;
 2816|  5.99k|        default:
  ------------------
  |  Branch (2816:9): [True: 5.99k, False: 0]
  ------------------
 2817|  5.99k|            return (*sp->otherSettings.vgetparent)(tif, tag, ap);
 2818|  5.99k|    }
 2819|      0|    return (1);
 2820|  5.99k|}
tif_jpeg.c:JPEGVSetField:
 2736|  5.49k|{
 2737|  5.49k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  5.49k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2738|  5.49k|    const TIFFField *fip;
 2739|  5.49k|    uint32_t v32;
 2740|       |
 2741|  5.49k|    assert(sp != NULL);
  ------------------
  |  Branch (2741:5): [True: 0, False: 5.49k]
  |  Branch (2741:5): [True: 5.49k, False: 0]
  ------------------
 2742|       |
 2743|  5.49k|    switch (tag)
 2744|  5.49k|    {
 2745|     10|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|     10|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2745:9): [True: 10, False: 5.48k]
  ------------------
 2746|     10|            v32 = (uint32_t)va_arg(ap, uint32_t);
 2747|     10|            if (v32 == 0)
  ------------------
  |  Branch (2747:17): [True: 0, False: 10]
  ------------------
 2748|      0|            {
 2749|       |                /* XXX */
 2750|      0|                return (0);
 2751|      0|            }
 2752|     10|            _TIFFsetByteArrayExt(tif, &sp->otherSettings.jpegtables,
 2753|     10|                                 va_arg(ap, void *), v32);
 2754|     10|            sp->otherSettings.jpegtables_length = v32;
 2755|     10|            TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
  ------------------
  |  |  249|     10|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     10|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     10|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 2756|     10|            break;
 2757|      0|        case TIFFTAG_JPEGQUALITY:
  ------------------
  |  |  704|      0|#define TIFFTAG_JPEGQUALITY 65537    /* Compression quality level */
  ------------------
  |  Branch (2757:9): [True: 0, False: 5.49k]
  ------------------
 2758|      0|            sp->otherSettings.jpegquality = (int)va_arg(ap, int);
 2759|      0|            return (1); /* pseudo tag */
 2760|    380|        case TIFFTAG_JPEGCOLORMODE:
  ------------------
  |  |  706|    380|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  |  Branch (2760:9): [True: 380, False: 5.11k]
  ------------------
 2761|    380|            sp->otherSettings.jpegcolormode = (int)va_arg(ap, int);
 2762|    380|            JPEGResetUpsampled(tif);
 2763|    380|            return (1); /* pseudo tag */
 2764|    468|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|    468|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (2764:9): [True: 468, False: 5.02k]
  ------------------
 2765|    468|        {
 2766|    468|            int ret_value = (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2767|    468|            JPEGResetUpsampled(tif);
 2768|    468|            return ret_value;
 2769|     10|        }
 2770|      0|        case TIFFTAG_JPEGTABLESMODE:
  ------------------
  |  |  709|      0|#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
  ------------------
  |  Branch (2770:9): [True: 0, False: 5.49k]
  ------------------
 2771|      0|            sp->otherSettings.jpegtablesmode = (int)va_arg(ap, int);
 2772|      0|            return (1); /* pseudo tag */
 2773|      3|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|      3|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (2773:9): [True: 3, False: 5.48k]
  ------------------
 2774|       |            /* mark the fact that we have a real ycbcrsubsampling! */
 2775|      3|            sp->otherSettings.ycbcrsampling_fetched = 1;
 2776|       |            /* should we be recomputing upsampling info here? */
 2777|      3|            return (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2778|  4.63k|        default:
  ------------------
  |  Branch (2778:9): [True: 4.63k, False: 861]
  ------------------
 2779|  4.63k|            return (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2780|  5.49k|    }
 2781|       |
 2782|     10|    if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
  ------------------
  |  Branch (2782:9): [True: 10, False: 0]
  ------------------
 2783|     10|    {
 2784|     10|        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|     10|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     10|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     10|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 2785|     10|    }
 2786|      0|    else
 2787|      0|    {
 2788|      0|        return (0);
 2789|      0|    }
 2790|       |
 2791|     10|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|     10|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 2792|     10|    return (1);
 2793|     10|}
tif_jpeg.c:JPEGResetUpsampled:
 2697|    848|{
 2698|    848|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    848|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2699|    848|    TIFFDirectory *td = &tif->tif_dir;
 2700|       |
 2701|       |    /*
 2702|       |     * Mark whether returned data is up-sampled or not so TIFFStripSize
 2703|       |     * and TIFFTileSize return values that reflect the true amount of
 2704|       |     * data.
 2705|       |     */
 2706|    848|    tif->tif_flags &= ~TIFF_UPSAMPLED;
  ------------------
  |  |  133|    848|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  ------------------
 2707|    848|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|    848|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (2707:9): [True: 839, False: 9]
  ------------------
 2708|    839|    {
 2709|    839|        if (td->td_photometric == PHOTOMETRIC_YCBCR &&
  ------------------
  |  |  227|  1.67k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (2709:13): [True: 827, False: 12]
  ------------------
 2710|    827|            sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
  ------------------
  |  |  708|    827|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  |  Branch (2710:13): [True: 380, False: 447]
  ------------------
 2711|    380|        {
 2712|    380|            tif->tif_flags |= TIFF_UPSAMPLED;
  ------------------
  |  |  133|    380|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  ------------------
 2713|    380|        }
 2714|    459|        else
 2715|    459|        {
 2716|       |#ifdef notdef
 2717|       |            if (td->td_ycbcrsubsampling[0] != 1 ||
 2718|       |                td->td_ycbcrsubsampling[1] != 1)
 2719|       |                ; /* XXX what about up-sampling? */
 2720|       |#endif
 2721|    459|        }
 2722|    839|    }
 2723|       |
 2724|       |    /*
 2725|       |     * Must recalculate cached tile size in case sampling state changed.
 2726|       |     * Should we really be doing this now if image size isn't set?
 2727|       |     */
 2728|    848|    if (tif->tif_dir.td_tilesize > 0)
  ------------------
  |  Branch (2728:9): [True: 45, False: 803]
  ------------------
 2729|     45|        tif->tif_dir.td_tilesize =
 2730|     45|            isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1);
  ------------------
  |  |  278|     45|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     45|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 45, False: 0]
  |  |  ------------------
  ------------------
 2731|    848|    if (tif->tif_dir.td_scanlinesize > 0)
  ------------------
  |  Branch (2731:9): [True: 380, False: 468]
  ------------------
 2732|    380|        tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 2733|    848|}
tif_jpeg.c:JPEGFixupTags:
  849|    528|{
  850|    528|#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
  851|    528|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    528|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
  852|    528|    if ((tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|    528|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (852:9): [True: 428, False: 100]
  ------------------
  853|    428|        (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|    428|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (853:9): [True: 424, False: 4]
  ------------------
  854|    424|        (tif->tif_dir.td_samplesperpixel == 3) &&
  ------------------
  |  Branch (854:9): [True: 424, False: 0]
  ------------------
  855|    424|        !sp->otherSettings.ycbcrsampling_fetched)
  ------------------
  |  Branch (855:9): [True: 424, False: 0]
  ------------------
  856|    424|        JPEGFixupTagsSubsampling(tif);
  857|    528|#endif
  858|       |
  859|    528|    return (1);
  860|    528|}
tif_jpeg.c:JPEGFixupTagsSubsampling:
  865|    424|{
  866|       |    /*
  867|       |     * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in
  868|       |     * the TIFF tags, but still use non-default (2,2) values within the jpeg
  869|       |     * data stream itself.  In order for TIFF applications to work properly
  870|       |     * - for instance to get the strip buffer size right - it is imperative
  871|       |     * that the subsampling be available before we start reading the image
  872|       |     * data normally.  This function will attempt to analyze the first strip in
  873|       |     * order to get the sampling values from the jpeg data stream.
  874|       |     *
  875|       |     * Note that JPEGPreDeocode() will produce a fairly loud warning when the
  876|       |     * discovered sampling does not match the default sampling (2,2) or whatever
  877|       |     * was actually in the tiff tags.
  878|       |     *
  879|       |     * See the bug in bugzilla for details:
  880|       |     *
  881|       |     * http://bugzilla.remotesensing.org/show_bug.cgi?id=168
  882|       |     *
  883|       |     * Frank Warmerdam, July 2002
  884|       |     * Joris Van Damme, May 2007
  885|       |     */
  886|    424|    static const char module[] = "JPEGFixupTagsSubsampling";
  887|    424|    struct JPEGFixupTagsSubsamplingData m;
  888|    424|    uint64_t fileoffset = TIFFGetStrileOffset(tif, 0);
  889|       |
  890|    424|    if (fileoffset == 0)
  ------------------
  |  Branch (890:9): [True: 17, False: 407]
  ------------------
  891|     17|    {
  892|       |        /* Do not even try to check if the first strip/tile does not
  893|       |           yet exist, as occurs when GDAL has created a new NULL file
  894|       |           for instance. */
  895|     17|        return;
  896|     17|    }
  897|       |
  898|    407|    m.tif = tif;
  899|    407|    m.buffersize = 2048;
  900|    407|    m.buffer = _TIFFmallocExt(tif, m.buffersize);
  901|    407|    if (m.buffer == NULL)
  ------------------
  |  Branch (901:9): [True: 0, False: 407]
  ------------------
  902|      0|    {
  903|      0|        TIFFWarningExtR(tif, module,
  904|      0|                        "Unable to allocate memory for auto-correcting of "
  905|      0|                        "subsampling values; auto-correcting skipped");
  906|      0|        return;
  907|      0|    }
  908|    407|    m.buffercurrentbyte = NULL;
  909|    407|    m.bufferbytesleft = 0;
  910|    407|    m.fileoffset = fileoffset;
  911|    407|    m.filepositioned = 0;
  912|    407|    m.filebytesleft = TIFFGetStrileByteCount(tif, 0);
  913|    407|    if (!JPEGFixupTagsSubsamplingSec(&m))
  ------------------
  |  Branch (913:9): [True: 332, False: 75]
  ------------------
  914|    332|        TIFFWarningExtR(
  915|    332|            tif, module,
  916|    332|            "Unable to auto-correct subsampling values, likely corrupt JPEG "
  917|    332|            "compressed data in first strip/tile; auto-correcting skipped");
  918|    407|    _TIFFfreeExt(tif, m.buffer);
  919|    407|}
tif_jpeg.c:JPEGFixupTagsSubsamplingSec:
  923|    407|{
  924|    407|    static const char module[] = "JPEGFixupTagsSubsamplingSec";
  925|    407|    uint8_t m;
  926|  24.5k|    while (1)
  ------------------
  |  Branch (926:12): [True: 24.5k, Folded]
  ------------------
  927|  24.5k|    {
  928|  4.65M|        while (1)
  ------------------
  |  Branch (928:16): [True: 4.65M, Folded]
  ------------------
  929|  4.65M|        {
  930|  4.65M|            if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
  ------------------
  |  Branch (930:17): [True: 99, False: 4.65M]
  ------------------
  931|     99|                return (0);
  932|  4.65M|            if (m == 255)
  ------------------
  |  Branch (932:17): [True: 24.4k, False: 4.63M]
  ------------------
  933|  24.4k|                break;
  934|  4.65M|        }
  935|  29.6k|        while (1)
  ------------------
  |  Branch (935:16): [True: 29.6k, Folded]
  ------------------
  936|  29.6k|        {
  937|  29.6k|            if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
  ------------------
  |  Branch (937:17): [True: 11, False: 29.6k]
  ------------------
  938|     11|                return (0);
  939|  29.6k|            if (m != 255)
  ------------------
  |  Branch (939:17): [True: 24.4k, False: 5.15k]
  ------------------
  940|  24.4k|                break;
  941|  29.6k|        }
  942|  24.4k|        switch (m)
  943|  24.4k|        {
  944|    528|            case JPEG_MARKER_SOI:
  ------------------
  |  |  816|    528|#define JPEG_MARKER_SOI 0xD8
  ------------------
  |  Branch (944:13): [True: 528, False: 23.9k]
  ------------------
  945|       |                /* this type of marker has no data and should be skipped */
  946|    528|                break;
  947|    401|            case JPEG_MARKER_COM:
  ------------------
  |  |  821|    401|#define JPEG_MARKER_COM 0xFE
  ------------------
  |  Branch (947:13): [True: 401, False: 24.0k]
  ------------------
  948|  5.47k|            case JPEG_MARKER_APP0:
  ------------------
  |  |  820|  5.47k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (948:13): [True: 5.06k, False: 19.4k]
  ------------------
  949|  17.8k|            case JPEG_MARKER_APP0 + 1:
  ------------------
  |  |  820|  17.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (949:13): [True: 12.3k, False: 12.1k]
  ------------------
  950|  17.9k|            case JPEG_MARKER_APP0 + 2:
  ------------------
  |  |  820|  17.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (950:13): [True: 105, False: 24.3k]
  ------------------
  951|  18.1k|            case JPEG_MARKER_APP0 + 3:
  ------------------
  |  |  820|  18.1k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (951:13): [True: 211, False: 24.2k]
  ------------------
  952|  18.6k|            case JPEG_MARKER_APP0 + 4:
  ------------------
  |  |  820|  18.6k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (952:13): [True: 471, False: 24.0k]
  ------------------
  953|  18.9k|            case JPEG_MARKER_APP0 + 5:
  ------------------
  |  |  820|  18.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (953:13): [True: 307, False: 24.1k]
  ------------------
  954|  18.9k|            case JPEG_MARKER_APP0 + 6:
  ------------------
  |  |  820|  18.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (954:13): [True: 87, False: 24.3k]
  ------------------
  955|  19.0k|            case JPEG_MARKER_APP0 + 7:
  ------------------
  |  |  820|  19.0k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (955:13): [True: 82, False: 24.4k]
  ------------------
  956|  19.7k|            case JPEG_MARKER_APP0 + 8:
  ------------------
  |  |  820|  19.7k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (956:13): [True: 686, False: 23.7k]
  ------------------
  957|  19.8k|            case JPEG_MARKER_APP0 + 9:
  ------------------
  |  |  820|  19.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (957:13): [True: 99, False: 24.3k]
  ------------------
  958|  19.9k|            case JPEG_MARKER_APP0 + 10:
  ------------------
  |  |  820|  19.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (958:13): [True: 131, False: 24.3k]
  ------------------
  959|  20.0k|            case JPEG_MARKER_APP0 + 11:
  ------------------
  |  |  820|  20.0k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (959:13): [True: 93, False: 24.3k]
  ------------------
  960|  20.3k|            case JPEG_MARKER_APP0 + 12:
  ------------------
  |  |  820|  20.3k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (960:13): [True: 250, False: 24.2k]
  ------------------
  961|  20.3k|            case JPEG_MARKER_APP0 + 13:
  ------------------
  |  |  820|  20.3k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (961:13): [True: 42, False: 24.4k]
  ------------------
  962|  21.1k|            case JPEG_MARKER_APP0 + 14:
  ------------------
  |  |  820|  21.1k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (962:13): [True: 757, False: 23.7k]
  ------------------
  963|  21.4k|            case JPEG_MARKER_APP0 + 15:
  ------------------
  |  |  820|  21.4k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (963:13): [True: 291, False: 24.1k]
  ------------------
  964|  21.6k|            case JPEG_MARKER_DQT:
  ------------------
  |  |  818|  21.6k|#define JPEG_MARKER_DQT 0xDB
  ------------------
  |  Branch (964:13): [True: 256, False: 24.2k]
  ------------------
  965|  21.8k|            case JPEG_MARKER_SOS:
  ------------------
  |  |  817|  21.8k|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (965:13): [True: 146, False: 24.3k]
  ------------------
  966|  22.1k|            case JPEG_MARKER_DHT:
  ------------------
  |  |  815|  22.1k|#define JPEG_MARKER_DHT 0xC4
  ------------------
  |  Branch (966:13): [True: 344, False: 24.1k]
  ------------------
  967|  23.6k|            case JPEG_MARKER_DRI:
  ------------------
  |  |  819|  23.6k|#define JPEG_MARKER_DRI 0xDD
  ------------------
  |  Branch (967:13): [True: 1.51k, False: 22.9k]
  ------------------
  968|       |                /* this type of marker has data, but it has no use to us and
  969|       |                 * should be skipped */
  970|  23.6k|                {
  971|  23.6k|                    uint16_t n;
  972|  23.6k|                    if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
  ------------------
  |  Branch (972:25): [True: 19, False: 23.6k]
  ------------------
  973|     19|                        return (0);
  974|  23.6k|                    if (n < 2)
  ------------------
  |  Branch (974:25): [True: 9, False: 23.6k]
  ------------------
  975|      9|                        return (0);
  976|  23.6k|                    n = (uint16_t)(n - 2);
  977|  23.6k|                    if (n > 0)
  ------------------
  |  Branch (977:25): [True: 19.6k, False: 4.05k]
  ------------------
  978|  19.6k|                        JPEGFixupTagsSubsamplingSkip(data, n);
  979|  23.6k|                }
  980|      0|                break;
  981|     89|            case JPEG_MARKER_SOF0:  /* Baseline sequential Huffman */
  ------------------
  |  |  810|     89|#define JPEG_MARKER_SOF0 0xC0
  ------------------
  |  Branch (981:13): [True: 89, False: 24.3k]
  ------------------
  982|     89|            case JPEG_MARKER_SOF1:  /* Extended sequential Huffman */
  ------------------
  |  |  811|     89|#define JPEG_MARKER_SOF1 0xC1
  ------------------
  |  Branch (982:13): [True: 0, False: 24.4k]
  ------------------
  983|     90|            case JPEG_MARKER_SOF2:  /* Progressive Huffman: normally not allowed
  ------------------
  |  |  812|     90|#define JPEG_MARKER_SOF2 0xC2
  ------------------
  |  Branch (983:13): [True: 1, False: 24.4k]
  ------------------
  984|       |                                       by  TechNote, but that doesn't hurt
  985|       |                                       supporting it */
  986|     93|            case JPEG_MARKER_SOF9:  /* Extended sequential arithmetic */
  ------------------
  |  |  813|     93|#define JPEG_MARKER_SOF9 0xC9
  ------------------
  |  Branch (986:13): [True: 3, False: 24.4k]
  ------------------
  987|     98|            case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not
  ------------------
  |  |  814|     98|#define JPEG_MARKER_SOF10 0xCA
  ------------------
  |  Branch (987:13): [True: 5, False: 24.4k]
  ------------------
  988|       |                                       allowed by TechNote, but that doesn't
  989|       |                                       hurt supporting it */
  990|       |                /* this marker contains the subsampling factors we're scanning
  991|       |                 * for */
  992|     98|                {
  993|     98|                    uint16_t n;
  994|     98|                    uint16_t o;
  995|     98|                    uint8_t p;
  996|     98|                    uint8_t ph, pv;
  997|     98|                    if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
  ------------------
  |  Branch (997:25): [True: 1, False: 97]
  ------------------
  998|      1|                        return (0);
  999|     97|                    if (n != 8 + data->tif->tif_dir.td_samplesperpixel * 3)
  ------------------
  |  Branch (999:25): [True: 7, False: 90]
  ------------------
 1000|      7|                        return (0);
 1001|     90|                    JPEGFixupTagsSubsamplingSkip(data, 7);
 1002|     90|                    if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
  ------------------
  |  Branch (1002:25): [True: 8, False: 82]
  ------------------
 1003|      8|                        return (0);
 1004|     82|                    ph = (p >> 4);
 1005|     82|                    pv = (p & 15);
 1006|     82|                    JPEGFixupTagsSubsamplingSkip(data, 1);
 1007|    172|                    for (o = 1; o < data->tif->tif_dir.td_samplesperpixel; o++)
  ------------------
  |  Branch (1007:33): [True: 129, False: 43]
  ------------------
 1008|    129|                    {
 1009|    129|                        JPEGFixupTagsSubsamplingSkip(data, 1);
 1010|    129|                        if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
  ------------------
  |  Branch (1010:29): [True: 7, False: 122]
  ------------------
 1011|      7|                            return (0);
 1012|    122|                        if (p != 0x11)
  ------------------
  |  Branch (1012:29): [True: 32, False: 90]
  ------------------
 1013|     32|                        {
 1014|     32|                            TIFFWarningExtR(data->tif, module,
 1015|     32|                                            "Subsampling values inside JPEG "
 1016|     32|                                            "compressed data "
 1017|     32|                                            "have no TIFF equivalent, "
 1018|     32|                                            "auto-correction of TIFF "
 1019|     32|                                            "subsampling values failed");
 1020|     32|                            return (1);
 1021|     32|                        }
 1022|     90|                        JPEGFixupTagsSubsamplingSkip(data, 1);
 1023|     90|                    }
 1024|     43|                    if (((ph != 1) && (ph != 2) && (ph != 4)) ||
  ------------------
  |  Branch (1024:26): [True: 4, False: 39]
  |  Branch (1024:39): [True: 4, False: 0]
  |  Branch (1024:52): [True: 4, False: 0]
  ------------------
 1025|     39|                        ((pv != 1) && (pv != 2) && (pv != 4)))
  ------------------
  |  Branch (1025:26): [True: 2, False: 37]
  |  Branch (1025:39): [True: 2, False: 0]
  |  Branch (1025:52): [True: 2, False: 0]
  ------------------
 1026|      6|                    {
 1027|      6|                        TIFFWarningExtR(data->tif, module,
 1028|      6|                                        "Subsampling values inside JPEG "
 1029|      6|                                        "compressed data have no TIFF "
 1030|      6|                                        "equivalent, auto-correction of TIFF "
 1031|      6|                                        "subsampling values failed");
 1032|      6|                        return (1);
 1033|      6|                    }
 1034|     37|                    if ((ph != data->tif->tif_dir.td_ycbcrsubsampling[0]) ||
  ------------------
  |  Branch (1034:25): [True: 37, False: 0]
  ------------------
 1035|      0|                        (pv != data->tif->tif_dir.td_ycbcrsubsampling[1]))
  ------------------
  |  Branch (1035:25): [True: 0, False: 0]
  ------------------
 1036|     37|                    {
 1037|     37|                        TIFFWarningExtR(
 1038|     37|                            data->tif, module,
 1039|     37|                            "Auto-corrected former TIFF subsampling values "
 1040|     37|                            "[%" PRIu16 ",%" PRIu16
 1041|     37|                            "] to match subsampling values inside JPEG "
 1042|     37|                            "compressed data [%" PRIu8 ",%" PRIu8 "]",
 1043|     37|                            data->tif->tif_dir.td_ycbcrsubsampling[0],
 1044|     37|                            data->tif->tif_dir.td_ycbcrsubsampling[1], ph, pv);
 1045|     37|                        data->tif->tif_dir.td_ycbcrsubsampling[0] = ph;
 1046|     37|                        data->tif->tif_dir.td_ycbcrsubsampling[1] = pv;
 1047|     37|                    }
 1048|     37|                }
 1049|      0|                return (1);
 1050|    171|            default:
  ------------------
  |  Branch (1050:13): [True: 171, False: 24.3k]
  ------------------
 1051|    171|                return (0);
 1052|  24.4k|        }
 1053|  24.4k|    }
 1054|    407|}
tif_jpeg.c:JPEGFixupTagsSubsamplingReadByte:
 1059|  4.73M|{
 1060|  4.73M|    if (data->bufferbytesleft == 0)
  ------------------
  |  Branch (1060:9): [True: 3.21k, False: 4.73M]
  ------------------
 1061|  3.21k|    {
 1062|  3.21k|        uint32_t m;
 1063|  3.21k|        if (data->filebytesleft == 0)
  ------------------
  |  Branch (1063:13): [True: 78, False: 3.13k]
  ------------------
 1064|     78|            return (0);
 1065|  3.13k|        if (!data->filepositioned)
  ------------------
  |  Branch (1065:13): [True: 779, False: 2.35k]
  ------------------
 1066|    779|        {
 1067|    779|            if (TIFFSeekFile(data->tif, data->fileoffset, SEEK_SET) ==
  ------------------
  |  |  287|    779|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
  |  Branch (1067:17): [True: 7, False: 772]
  ------------------
 1068|    779|                (toff_t)-1)
 1069|      7|            {
 1070|      7|                return 0;
 1071|      7|            }
 1072|    772|            data->filepositioned = 1;
 1073|    772|        }
 1074|  3.12k|        m = data->buffersize;
 1075|  3.12k|        if ((uint64_t)m > data->filebytesleft)
  ------------------
  |  Branch (1075:13): [True: 132, False: 2.99k]
  ------------------
 1076|    132|            m = (uint32_t)data->filebytesleft;
 1077|  3.12k|        assert(m < 0x80000000UL);
  ------------------
  |  Branch (1077:9): [True: 0, False: 3.12k]
  |  Branch (1077:9): [True: 3.12k, False: 0]
  ------------------
 1078|  3.12k|        if (TIFFReadFile(data->tif, data->buffer, (tmsize_t)m) != (tmsize_t)m)
  ------------------
  |  |  283|  3.12k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  |  Branch (1078:13): [True: 60, False: 3.06k]
  ------------------
 1079|     60|            return (0);
 1080|  3.06k|        data->buffercurrentbyte = (uint8_t *)data->buffer;
 1081|  3.06k|        data->bufferbytesleft = m;
 1082|  3.06k|        data->fileoffset += m;
 1083|  3.06k|        data->filebytesleft -= m;
 1084|  3.06k|    }
 1085|  4.73M|    *result = *data->buffercurrentbyte;
 1086|  4.73M|    data->buffercurrentbyte++;
 1087|  4.73M|    data->bufferbytesleft--;
 1088|  4.73M|    return (1);
 1089|  4.73M|}
tif_jpeg.c:JPEGFixupTagsSubsamplingReadWord:
 1094|  23.7k|{
 1095|  23.7k|    uint8_t ma;
 1096|  23.7k|    uint8_t mb;
 1097|  23.7k|    if (!JPEGFixupTagsSubsamplingReadByte(data, &ma))
  ------------------
  |  Branch (1097:9): [True: 9, False: 23.7k]
  ------------------
 1098|      9|        return (0);
 1099|  23.7k|    if (!JPEGFixupTagsSubsamplingReadByte(data, &mb))
  ------------------
  |  Branch (1099:9): [True: 11, False: 23.7k]
  ------------------
 1100|     11|        return (0);
 1101|  23.7k|    *result = (uint16_t)((ma << 8) | mb);
 1102|  23.7k|    return (1);
 1103|  23.7k|}
tif_jpeg.c:JPEGFixupTagsSubsamplingSkip:
 1108|  19.9k|{
 1109|  19.9k|    if ((uint32_t)skiplength <= data->bufferbytesleft)
  ------------------
  |  Branch (1109:9): [True: 19.5k, False: 421]
  ------------------
 1110|  19.5k|    {
 1111|  19.5k|        data->buffercurrentbyte += skiplength;
 1112|  19.5k|        data->bufferbytesleft -= skiplength;
 1113|  19.5k|    }
 1114|    421|    else
 1115|    421|    {
 1116|    421|        uint16_t m;
 1117|    421|        m = (uint16_t)(skiplength - data->bufferbytesleft);
 1118|    421|        if (m <= data->filebytesleft)
  ------------------
  |  Branch (1118:13): [True: 391, False: 30]
  ------------------
 1119|    391|        {
 1120|    391|            data->bufferbytesleft = 0;
 1121|    391|            data->fileoffset += m;
 1122|    391|            data->filebytesleft -= m;
 1123|    391|            data->filepositioned = 0;
 1124|    391|        }
 1125|     30|        else
 1126|     30|        {
 1127|     30|            data->bufferbytesleft = 0;
 1128|     30|            data->filebytesleft = 0;
 1129|     30|        }
 1130|    421|    }
 1131|  19.9k|}
tif_jpeg.c:JPEGSetupDecode:
 1136|    382|{
 1137|    382|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    382|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1138|    382|    TIFFDirectory *td = &tif->tif_dir;
 1139|       |
 1140|    382|#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
 1141|    382|    if (tif->tif_dir.td_bitspersample == 12)
  ------------------
  |  Branch (1141:9): [True: 9, False: 373]
  ------------------
 1142|      9|    {
 1143|       |        /* We pass a pointer to a copy of otherSettings, since */
 1144|       |        /* TIFFReInitJPEG_12() will clear sp */
 1145|      9|        JPEGOtherSettings savedOtherSettings = sp->otherSettings;
 1146|      9|        return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 0);
  ------------------
  |  |  190|      9|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
 1147|      9|    }
 1148|    373|#endif
 1149|       |
 1150|    373|    JPEGInitializeLibJPEG(tif, TRUE);
  ------------------
  |  |   71|    373|#define TRUE 1
  ------------------
 1151|       |
 1152|    373|    assert(sp != NULL);
  ------------------
  |  Branch (1152:5): [True: 0, False: 373]
  |  Branch (1152:5): [True: 373, False: 0]
  ------------------
 1153|    373|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1153:5): [True: 0, False: 373]
  |  Branch (1153:5): [True: 373, False: 0]
  ------------------
 1154|       |
 1155|       |    /* Read JPEGTables if it is present */
 1156|    373|    if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
  ------------------
  |  |  248|    373|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    373|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    373|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 0, False: 373]
  |  |  ------------------
  ------------------
 1157|      0|    {
 1158|      0|        TIFFjpeg_tables_src(sp);
 1159|      0|        if (TIFFjpeg_read_header(sp, FALSE) != JPEG_HEADER_TABLES_ONLY)
  ------------------
  |  |   72|      0|#define FALSE 0
  ------------------
  |  Branch (1159:13): [True: 0, False: 0]
  ------------------
 1160|      0|        {
 1161|      0|            TIFFErrorExtR(tif, "JPEGSetupDecode", "Bogus JPEGTables field");
 1162|      0|            return (0);
 1163|      0|        }
 1164|      0|    }
 1165|       |
 1166|       |    /* Grab parameters that are same for all strips/tiles */
 1167|    373|    sp->photometric = td->td_photometric;
 1168|    373|    switch (sp->photometric)
 1169|    373|    {
 1170|    292|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    292|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1170:9): [True: 292, False: 81]
  ------------------
 1171|    292|            sp->h_sampling = td->td_ycbcrsubsampling[0];
 1172|    292|            sp->v_sampling = td->td_ycbcrsubsampling[1];
 1173|    292|            break;
 1174|     81|        default:
  ------------------
  |  Branch (1174:9): [True: 81, False: 292]
  ------------------
 1175|       |            /* TIFF 6.0 forbids subsampling of all other color spaces */
 1176|     81|            sp->h_sampling = 1;
 1177|     81|            sp->v_sampling = 1;
 1178|     81|            break;
 1179|    373|    }
 1180|       |
 1181|       |    /* Set up for reading normal data */
 1182|    373|    TIFFjpeg_data_src(sp);
 1183|    373|    tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
 1184|    373|    return (1);
 1185|    373|}
tif_jpeg.c:JPEGInitializeLibJPEG:
 2883|    373|{
 2884|    373|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    373|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2885|       |
 2886|    373|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2886:9): [True: 0, False: 373]
  ------------------
 2887|      0|    {
 2888|      0|        if (!decompress && sp->cinfo.comm.is_decompressor)
  ------------------
  |  Branch (2888:13): [True: 0, False: 0]
  |  Branch (2888:28): [True: 0, False: 0]
  ------------------
 2889|      0|            TIFFjpeg_destroy(sp);
 2890|      0|        else if (decompress && !sp->cinfo.comm.is_decompressor)
  ------------------
  |  Branch (2890:18): [True: 0, False: 0]
  |  Branch (2890:32): [True: 0, False: 0]
  ------------------
 2891|      0|            TIFFjpeg_destroy(sp);
 2892|      0|        else
 2893|      0|            return 1;
 2894|       |
 2895|      0|        sp->cinfo_initialized = 0;
 2896|      0|    }
 2897|       |
 2898|       |    /*
 2899|       |     * Initialize libjpeg.
 2900|       |     */
 2901|    373|    if (decompress)
  ------------------
  |  Branch (2901:9): [True: 373, False: 0]
  ------------------
 2902|    373|    {
 2903|    373|        if (!TIFFjpeg_create_decompress(sp))
  ------------------
  |  Branch (2903:13): [True: 0, False: 373]
  ------------------
 2904|      0|            return (0);
 2905|    373|    }
 2906|      0|    else
 2907|      0|    {
 2908|      0|        if (!TIFFjpeg_create_compress(sp))
  ------------------
  |  Branch (2908:13): [True: 0, False: 0]
  ------------------
 2909|      0|            return (0);
 2910|      0|#ifndef TIFF_JPEG_MAX_MEMORY_TO_USE
 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
 2912|      0|#endif
 2913|       |        /* libjpeg turbo 1.5.2 honours max_memory_to_use, but has no backing */
 2914|       |        /* store implementation, so better not set max_memory_to_use ourselves.
 2915|       |         */
 2916|       |        /* See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 */
 2917|      0|        if (sp->cinfo.c.mem->max_memory_to_use > 0)
  ------------------
  |  Branch (2917:13): [True: 0, False: 0]
  ------------------
 2918|      0|        {
 2919|       |            /* This is to address bug related in ticket GDAL #1795. */
 2920|      0|            if (getenv("JPEGMEM") == NULL)
  ------------------
  |  Branch (2920:17): [True: 0, False: 0]
  ------------------
 2921|      0|            {
 2922|       |                /* Increase the max memory usable. This helps when creating
 2923|       |                 * files */
 2924|       |                /* with "big" tile, without using libjpeg temporary files. */
 2925|       |                /* For example a 512x512 tile with 3 bands */
 2926|       |                /* requires 1.5 MB which is above libjpeg 1MB default */
 2927|      0|                if (sp->cinfo.c.mem->max_memory_to_use <
  ------------------
  |  Branch (2927:21): [True: 0, False: 0]
  ------------------
 2928|      0|                    TIFF_JPEG_MAX_MEMORY_TO_USE)
  ------------------
  |  | 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
  ------------------
 2929|      0|                    sp->cinfo.c.mem->max_memory_to_use =
 2930|      0|                        TIFF_JPEG_MAX_MEMORY_TO_USE;
  ------------------
  |  | 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
  ------------------
 2931|      0|            }
 2932|      0|        }
 2933|      0|    }
 2934|       |
 2935|    373|    sp->cinfo_initialized = TRUE;
  ------------------
  |  |   71|    373|#define TRUE 1
  ------------------
 2936|       |
 2937|    373|    return 1;
 2938|    373|}
tif_jpeg.c:JPEGPreDecode:
 1268|  37.6k|{
 1269|  37.6k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  37.6k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1270|  37.6k|    TIFFDirectory *td = &tif->tif_dir;
 1271|  37.6k|    static const char module[] = "JPEGPreDecode";
 1272|  37.6k|    int downsampled_output;
 1273|  37.6k|    int ci;
 1274|       |
 1275|  37.6k|    assert(sp != NULL);
  ------------------
  |  Branch (1275:5): [True: 0, False: 37.6k]
  |  Branch (1275:5): [True: 37.6k, False: 0]
  ------------------
 1276|       |
 1277|  37.6k|    if (sp->cinfo.comm.is_decompressor == 0)
  ------------------
  |  Branch (1277:9): [True: 0, False: 37.6k]
  ------------------
 1278|      0|    {
 1279|      0|        tif->tif_setupdecode(tif);
 1280|      0|    }
 1281|       |
 1282|  37.6k|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1282:5): [True: 0, False: 37.6k]
  |  Branch (1282:5): [True: 37.6k, False: 0]
  ------------------
 1283|       |    /*
 1284|       |     * Reset decoder state from any previous strip/tile,
 1285|       |     * in case application didn't read the whole strip.
 1286|       |     */
 1287|  37.6k|    if (!TIFFjpeg_abort(sp))
  ------------------
  |  Branch (1287:9): [True: 0, False: 37.6k]
  ------------------
 1288|      0|        return (0);
 1289|       |    /*
 1290|       |     * Read the header for this strip/tile.
 1291|       |     */
 1292|       |
 1293|  37.6k|    if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
  ------------------
  |  |   71|  37.6k|#define TRUE 1
  ------------------
  |  Branch (1293:9): [True: 37.6k, False: 37]
  ------------------
 1294|  37.6k|        return (0);
 1295|       |
 1296|     37|    tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
 1297|     37|    tif->tif_rawcc = (tmsize_t)sp->src.bytes_in_buffer;
 1298|       |
 1299|     37|    if (!JPEGComputeStrileWidthHeightBytesPerLine(tif, s))
  ------------------
  |  Branch (1299:9): [True: 0, False: 37]
  ------------------
 1300|      0|        return 0;
 1301|       |
 1302|     37|    if (sp->cinfo.d.image_width < sp->strile_width ||
  ------------------
  |  Branch (1302:9): [True: 30, False: 7]
  ------------------
 1303|      7|        sp->cinfo.d.image_height < sp->strile_height)
  ------------------
  |  Branch (1303:9): [True: 3, False: 4]
  ------------------
 1304|     33|    {
 1305|     33|        TIFFWarningExtR(tif, module,
 1306|     33|                        "Improper JPEG strip/tile size, "
 1307|     33|                        "expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1308|     33|                        sp->strile_width, sp->strile_height,
 1309|     33|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1310|     33|    }
 1311|     37|    if (sp->cinfo.d.image_width == sp->strile_width &&
  ------------------
  |  Branch (1311:9): [True: 4, False: 33]
  ------------------
 1312|      4|        sp->cinfo.d.image_height > sp->strile_height &&
  ------------------
  |  Branch (1312:9): [True: 1, False: 3]
  ------------------
 1313|      1|        tif->tif_dir.td_row + sp->strile_height == td->td_imagelength &&
  ------------------
  |  Branch (1313:9): [True: 1, False: 0]
  ------------------
 1314|      1|        !isTiled(tif))
  ------------------
  |  |  278|      1|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      1|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (1314:9): [True: 1, False: 0]
  ------------------
 1315|      1|    {
 1316|       |        /* Some files have a last strip, that should be truncated, */
 1317|       |        /* but their JPEG codestream has still the maximum strip */
 1318|       |        /* height. Warn about this as this is non compliant, but */
 1319|       |        /* we can safely recover from that. */
 1320|      1|        TIFFWarningExtR(tif, module,
 1321|      1|                        "JPEG strip size exceeds expected dimensions,"
 1322|      1|                        " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1323|      1|                        sp->strile_width, sp->strile_height,
 1324|      1|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1325|      1|    }
 1326|     36|    else if (sp->cinfo.d.image_width > sp->strile_width ||
  ------------------
  |  Branch (1326:14): [True: 3, False: 33]
  ------------------
 1327|     33|             sp->cinfo.d.image_height > sp->strile_height)
  ------------------
  |  Branch (1327:14): [True: 29, False: 4]
  ------------------
 1328|     32|    {
 1329|       |        /*
 1330|       |         * This case could be dangerous, if the strip or tile size has
 1331|       |         * been reported as less than the amount of data jpeg will
 1332|       |         * return, some potential security issues arise. Catch this
 1333|       |         * case and error out.
 1334|       |         */
 1335|     32|        TIFFErrorExtR(tif, module,
 1336|     32|                      "JPEG strip/tile size exceeds expected dimensions,"
 1337|     32|                      " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1338|     32|                      sp->strile_width, sp->strile_height,
 1339|     32|                      sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1340|     32|        return (0);
 1341|     32|    }
 1342|      5|    if (sp->cinfo.d.num_components !=
  ------------------
  |  Branch (1342:9): [True: 2, False: 3]
  ------------------
 1343|      5|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|      5|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1343:10): [True: 5, False: 0]
  ------------------
 1344|      5|                                                    : 1))
 1345|      2|    {
 1346|      2|        TIFFErrorExtR(tif, module, "Improper JPEG component count");
 1347|      2|        return (0);
 1348|      2|    }
 1349|       |#ifdef JPEG_LIB_MK1
 1350|       |    if (12 != td->td_bitspersample && 8 != td->td_bitspersample)
 1351|       |    {
 1352|       |        TIFFErrorExtR(tif, module, "Improper JPEG data precision");
 1353|       |        return (0);
 1354|       |    }
 1355|       |    sp->cinfo.d.data_precision = td->td_bitspersample;
 1356|       |    sp->cinfo.d.bits_in_jsample = td->td_bitspersample;
 1357|       |#else
 1358|      3|    if (td->td_bitspersample != BITS_IN_JSAMPLE ||
  ------------------
  |  |  108|      6|#define BITS_IN_JSAMPLE 8
  ------------------
  |  Branch (1358:9): [True: 0, False: 3]
  ------------------
 1359|      3|        sp->cinfo.d.data_precision != td->td_bitspersample)
  ------------------
  |  Branch (1359:9): [True: 0, False: 3]
  ------------------
 1360|      0|    {
 1361|      0|        TIFFErrorExtR(tif, module, "Improper JPEG data precision");
 1362|      0|        return (0);
 1363|      0|    }
 1364|      3|#endif
 1365|       |
 1366|      3|    if (sp->cinfo.d.progressive_mode &&
  ------------------
  |  Branch (1366:9): [True: 0, False: 3]
  ------------------
 1367|      0|        !sp->otherSettings.has_warned_about_progressive_mode)
  ------------------
  |  Branch (1367:9): [True: 0, False: 0]
  ------------------
 1368|      0|    {
 1369|      0|        TIFFWarningExtR(tif, module,
 1370|      0|                        "The JPEG strip/tile is encoded with progressive mode, "
 1371|      0|                        "which is normally not legal for JPEG-in-TIFF.\n"
 1372|      0|                        "libtiff should be able to decode it, but it might "
 1373|      0|                        "cause compatibility issues with other readers");
 1374|      0|        sp->otherSettings.has_warned_about_progressive_mode = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1375|      0|    }
 1376|       |
 1377|       |    /* In some cases, libjpeg needs to allocate a lot of memory */
 1378|       |    /* http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
 1379|       |     */
 1380|      3|    if (TIFFjpeg_has_multiple_scans(sp))
  ------------------
  |  Branch (1380:9): [True: 3, False: 0]
  ------------------
 1381|      3|    {
 1382|       |        /* In this case libjpeg will need to allocate memory or backing */
 1383|       |        /* store for all coefficients */
 1384|       |        /* See call to jinit_d_coef_controller() from master_selection() */
 1385|       |        /* in libjpeg */
 1386|       |
 1387|       |        /* 1 MB for regular libjpeg usage */
 1388|      3|        toff_t nRequiredMemory = 1024 * 1024;
 1389|       |
 1390|     12|        for (ci = 0; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1390:22): [True: 9, False: 3]
  ------------------
 1391|      9|        {
 1392|      9|            const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]);
 1393|      9|            if (compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0)
  ------------------
  |  Branch (1393:17): [True: 9, False: 0]
  |  Branch (1393:47): [True: 9, False: 0]
  ------------------
 1394|      9|            {
 1395|      9|                nRequiredMemory +=
 1396|      9|                    (toff_t)((JDIMENSION)(((int)compptr->width_in_blocks +
 1397|      9|                                           compptr->h_samp_factor - 1) /
 1398|      9|                                          compptr->h_samp_factor)) *
 1399|      9|                    (JDIMENSION)(((int)compptr->height_in_blocks +
 1400|      9|                                  compptr->v_samp_factor - 1) /
 1401|      9|                                 compptr->v_samp_factor) *
 1402|      9|                    sizeof(JBLOCK);
 1403|      9|            }
 1404|      9|        }
 1405|       |
 1406|      3|        if (sp->cinfo.d.mem->max_memory_to_use > 0 &&
  ------------------
  |  Branch (1406:13): [True: 0, False: 3]
  ------------------
 1407|      0|            nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) &&
  ------------------
  |  Branch (1407:13): [True: 0, False: 0]
  ------------------
 1408|      0|            getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL)
  ------------------
  |  Branch (1408:13): [True: 0, False: 0]
  ------------------
 1409|      0|        {
 1410|      0|            TIFFErrorExtR(
 1411|      0|                tif, module,
 1412|      0|                "Reading this image would require libjpeg to allocate "
 1413|      0|                "at least %" PRIu64 " bytes. "
 1414|      0|                "This is disabled since above the %ld threshold. "
 1415|      0|                "You may override this restriction by defining the "
 1416|      0|                "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
 1417|      0|                "or setting the JPEGMEM environment variable to a value "
 1418|      0|                "greater "
 1419|      0|                "or equal to '%" PRIu64 "M'",
 1420|      0|                nRequiredMemory, sp->cinfo.d.mem->max_memory_to_use,
 1421|      0|                (nRequiredMemory + 1000000u - 1u) / 1000000u);
 1422|      0|            return 0;
 1423|      0|        }
 1424|      3|    }
 1425|       |
 1426|      3|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|      3|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1426:9): [True: 3, False: 0]
  ------------------
 1427|      3|    {
 1428|       |        /* Component 0 should have expected sampling factors */
 1429|      3|        if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
  ------------------
  |  Branch (1429:13): [True: 0, False: 3]
  ------------------
 1430|      3|            sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling)
  ------------------
  |  Branch (1430:13): [True: 0, False: 3]
  ------------------
 1431|      0|        {
 1432|      0|            TIFFErrorExtR(tif, module,
 1433|      0|                          "Improper JPEG sampling factors %d,%d\n"
 1434|      0|                          "Apparently should be %" PRIu16 ",%" PRIu16 ".",
 1435|      0|                          sp->cinfo.d.comp_info[0].h_samp_factor,
 1436|      0|                          sp->cinfo.d.comp_info[0].v_samp_factor,
 1437|      0|                          sp->h_sampling, sp->v_sampling);
 1438|      0|            return (0);
 1439|      0|        }
 1440|       |        /* Rest should have sampling factors 1,1 */
 1441|      9|        for (ci = 1; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1441:22): [True: 6, False: 3]
  ------------------
 1442|      6|        {
 1443|      6|            if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 ||
  ------------------
  |  Branch (1443:17): [True: 0, False: 6]
  ------------------
 1444|      6|                sp->cinfo.d.comp_info[ci].v_samp_factor != 1)
  ------------------
  |  Branch (1444:17): [True: 0, False: 6]
  ------------------
 1445|      0|            {
 1446|      0|                TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
 1447|      0|                return (0);
 1448|      0|            }
 1449|      6|        }
 1450|      3|    }
 1451|      0|    else
 1452|      0|    {
 1453|       |        /* PC 2's single component should have sampling factors 1,1 */
 1454|      0|        if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 ||
  ------------------
  |  Branch (1454:13): [True: 0, False: 0]
  ------------------
 1455|      0|            sp->cinfo.d.comp_info[0].v_samp_factor != 1)
  ------------------
  |  Branch (1455:13): [True: 0, False: 0]
  ------------------
 1456|      0|        {
 1457|      0|            TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
 1458|      0|            return (0);
 1459|      0|        }
 1460|      0|    }
 1461|      3|    downsampled_output = FALSE;
  ------------------
  |  |   72|      3|#define FALSE 0
  ------------------
 1462|      3|    if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|      6|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1462:9): [True: 3, False: 0]
  ------------------
 1463|      3|        sp->photometric == PHOTOMETRIC_YCBCR &&
  ------------------
  |  |  227|      6|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1463:9): [True: 1, False: 2]
  ------------------
 1464|      1|        sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
  ------------------
  |  |  708|      1|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  |  Branch (1464:9): [True: 1, False: 0]
  ------------------
 1465|      1|    {
 1466|       |        /* Convert YCbCr to RGB */
 1467|      1|        sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
 1468|      1|        sp->cinfo.d.out_color_space = JCS_RGB;
 1469|      1|    }
 1470|      2|    else
 1471|      2|    {
 1472|       |        /* Suppress colorspace handling */
 1473|      2|        sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
 1474|      2|        sp->cinfo.d.out_color_space = JCS_UNKNOWN;
 1475|      2|        if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|      4|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1475:13): [True: 2, False: 0]
  ------------------
 1476|      2|            (sp->h_sampling != 1 || sp->v_sampling != 1))
  ------------------
  |  Branch (1476:14): [True: 0, False: 2]
  |  Branch (1476:37): [True: 0, False: 2]
  ------------------
 1477|      0|            downsampled_output = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1478|       |        /* XXX what about up-sampling? */
 1479|      2|    }
 1480|      3|    if (downsampled_output)
  ------------------
  |  Branch (1480:9): [True: 0, False: 3]
  ------------------
 1481|      0|    {
 1482|       |        /* Need to use raw-data interface to libjpeg */
 1483|      0|        sp->cinfo.d.raw_data_out = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1484|       |#if JPEG_LIB_VERSION >= 70
 1485|       |        sp->cinfo.d.do_fancy_upsampling = FALSE;
 1486|       |#endif /* JPEG_LIB_VERSION >= 70 */
 1487|      0|        tif->tif_decoderow = DecodeRowError;
 1488|      0|        tif->tif_decodestrip = JPEGDecodeRaw;
 1489|      0|        tif->tif_decodetile = JPEGDecodeRaw;
 1490|      0|    }
 1491|      3|    else
 1492|      3|    {
 1493|       |        /* Use normal interface to libjpeg */
 1494|      3|        sp->cinfo.d.raw_data_out = FALSE;
  ------------------
  |  |   72|      3|#define FALSE 0
  ------------------
 1495|      3|        tif->tif_decoderow = JPEGDecode;
 1496|      3|        tif->tif_decodestrip = JPEGDecode;
 1497|      3|        tif->tif_decodetile = JPEGDecode;
 1498|      3|    }
 1499|       |    /* Start JPEG decompressor */
 1500|      3|    if (!TIFFjpeg_start_decompress(sp))
  ------------------
  |  Branch (1500:9): [True: 3, False: 0]
  ------------------
 1501|      3|        return (0);
 1502|       |    /* Allocate downsampled-data buffers if needed */
 1503|      0|    if (downsampled_output)
  ------------------
  |  Branch (1503:9): [True: 0, False: 0]
  ------------------
 1504|      0|    {
 1505|      0|        if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info,
  ------------------
  |  Branch (1505:13): [True: 0, False: 0]
  ------------------
 1506|      0|                                       sp->cinfo.d.num_components))
 1507|      0|            return (0);
 1508|      0|        sp->scancount = DCTSIZE; /* mark buffer empty */
 1509|      0|    }
 1510|      0|    return (1);
 1511|      0|}
tif_jpeg.c:TIFFjpeg_abort:
  520|  37.6k|{
  521|       |    return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm));
  ------------------
  |  |  302|  37.6k|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|  37.6k|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|  37.6k|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (521:12): [True: 0, False: 37.6k]
  ------------------
  522|  37.6k|}
tif_jpeg.c:JPEGComputeStrileWidthHeightBytesPerLine:
 1224|     37|{
 1225|     37|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|     37|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1226|     37|    TIFFDirectory *td = &tif->tif_dir;
 1227|       |
 1228|       |    /*
 1229|       |     * Check image parameters and set decompression parameters.
 1230|       |     */
 1231|     37|    if (isTiled(tif))
  ------------------
  |  |  278|     37|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     37|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 4, False: 33]
  |  |  ------------------
  ------------------
 1232|      4|    {
 1233|      4|        sp->strile_width = td->td_tilewidth;
 1234|      4|        sp->strile_height = td->td_tilelength;
 1235|      4|        sp->bytesperline = TIFFTileRowSize(tif);
 1236|      4|    }
 1237|     33|    else
 1238|     33|    {
 1239|     33|        sp->strile_width = td->td_imagewidth;
 1240|     33|        sp->strile_height = td->td_imagelength - tif->tif_dir.td_row;
 1241|     33|        if (sp->strile_height > td->td_rowsperstrip)
  ------------------
  |  Branch (1241:13): [True: 0, False: 33]
  ------------------
 1242|      0|            sp->strile_height = td->td_rowsperstrip;
 1243|     33|        sp->bytesperline = TIFFScanlineSize(tif);
 1244|     33|    }
 1245|     37|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0)
  ------------------
  |  |  266|     74|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (1245:9): [True: 0, False: 37]
  |  Branch (1245:57): [True: 0, False: 0]
  ------------------
 1246|      0|    {
 1247|       |        /*
 1248|       |         * For PC 2, scale down the expected strip/tile size
 1249|       |         * to match a downsampled component
 1250|       |         */
 1251|      0|        if (sp->h_sampling == 0 || sp->v_sampling == 0)
  ------------------
  |  Branch (1251:13): [True: 0, False: 0]
  |  Branch (1251:36): [True: 0, False: 0]
  ------------------
 1252|      0|        {
 1253|      0|            TIFFErrorExtR(tif, "JPEGComputeStrileWidthHeightBytesPerLine",
 1254|      0|                          "JPEG horizontal or vertical sampling is zero");
 1255|      0|            return (0);
 1256|      0|        }
 1257|      0|        sp->strile_width = TIFFhowmany_32(sp->strile_width, sp->h_sampling);
  ------------------
  |  |  312|      0|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  313|      0|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|      0|         : 0U)
  ------------------
 1258|      0|        sp->strile_height = TIFFhowmany_32(sp->strile_height, sp->v_sampling);
  ------------------
  |  |  312|      0|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  313|      0|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|      0|         : 0U)
  ------------------
 1259|      0|    }
 1260|       |
 1261|     37|    return 1;
 1262|     37|}
tif_jpeg.c:TIFFjpeg_start_decompress:
  406|      3|{
  407|      3|    const char *sz_max_allowed_scan_number;
  408|       |    /* progress monitor */
  409|      3|    sp->cinfo.d.progress = &sp->progress;
  410|      3|    sp->progress.progress_monitor = TIFFjpeg_progress_monitor;
  411|      3|    sp->otherSettings.max_allowed_scan_number = 100;
  412|      3|    sz_max_allowed_scan_number = getenv("LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER");
  413|      3|    if (sz_max_allowed_scan_number)
  ------------------
  |  Branch (413:9): [True: 0, False: 3]
  ------------------
  414|      0|        sp->otherSettings.max_allowed_scan_number =
  415|      0|            atoi(sz_max_allowed_scan_number);
  416|       |
  417|       |    return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d));
  ------------------
  |  |  302|      3|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|      3|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|      3|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (417:12): [True: 3, False: 0]
  ------------------
  418|      3|}
tif_jpeg.c:JPEGGetMaxCompressionRatio:
 2941|      5|{
 2942|       |    /* See README_for_libtiff_developpers.md for raw data used to estimate
 2943|       |     * the maximum compression rate. */
 2944|       |
 2945|      5|    const JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      5|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2946|      5|    if ((tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|      5|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (2946:9): [True: 4, False: 1]
  ------------------
 2947|      4|        (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|      4|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (2947:9): [True: 4, False: 0]
  ------------------
 2948|      4|        (tif->tif_dir.td_samplesperpixel == 3))
  ------------------
  |  Branch (2948:9): [True: 4, False: 0]
  ------------------
 2949|      4|    {
 2950|      4|        if (sp->h_sampling == 2 && sp->v_sampling == 2)
  ------------------
  |  Branch (2950:13): [True: 1, False: 3]
  |  Branch (2950:36): [True: 1, False: 0]
  ------------------
 2951|      1|        {
 2952|      1|            if (tif->tif_dir.td_bitspersample == 12)
  ------------------
  |  Branch (2952:17): [True: 0, False: 1]
  ------------------
 2953|      0|                return 768;
 2954|      1|            else
 2955|      1|                return 512;
 2956|      1|        }
 2957|       |
 2958|      3|        return 0; /* unknown */
 2959|      4|    }
 2960|       |
 2961|      1|    if (tif->tif_dir.td_bitspersample == 12)
  ------------------
  |  Branch (2961:9): [True: 0, False: 1]
  ------------------
 2962|      0|        return 384;
 2963|      1|    else
 2964|      1|        return 256;
 2965|      1|}
tif_jpeg.c:JPEGCleanup:
 2678|    547|{
 2679|    547|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    547|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2680|       |
 2681|    547|    assert(sp != 0);
  ------------------
  |  Branch (2681:5): [True: 0, False: 547]
  |  Branch (2681:5): [True: 547, False: 0]
  ------------------
 2682|       |
 2683|    547|    tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent;
 2684|    547|    tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent;
 2685|    547|    tif->tif_tagmethods.printdir = sp->otherSettings.printdir;
 2686|    547|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2686:9): [True: 373, False: 174]
  ------------------
 2687|    373|        TIFFjpeg_destroy(sp);         /* release libjpeg resources */
 2688|    547|    if (sp->otherSettings.jpegtables) /* tag value */
  ------------------
  |  Branch (2688:9): [True: 8, False: 539]
  ------------------
 2689|      8|        _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
 2690|    547|    _TIFFfreeExt(tif, tif->tif_data); /* release local state */
 2691|    547|    tif->tif_data = NULL;
 2692|       |
 2693|    547|    _TIFFSetDefaultCompressionState(tif);
 2694|    547|}
tif_jpeg_12.c:TIFFjpeg_create_decompress:
  318|      9|{
  319|       |    /* initialize JPEG error handling */
  320|      9|    sp->cinfo.d.err = jpeg_std_error(&sp->err);
  321|      9|    sp->err.error_exit = TIFFjpeg_error_exit;
  322|      9|    sp->err.output_message = TIFFjpeg_output_message;
  323|       |
  324|       |    /* set client_data to avoid UMR warning from tools like Purify */
  325|      9|    sp->cinfo.d.client_data = NULL;
  326|       |
  327|       |    return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
  ------------------
  |  |  302|      9|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|      9|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|      9|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (327:12): [True: 0, False: 9]
  ------------------
  328|      9|}
tif_jpeg_12.c:TIFFjpeg_error_exit:
  244|      9|{
  245|      9|    JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
  246|      9|    char buffer[JMSG_LENGTH_MAX];
  247|       |
  248|      9|    (*cinfo->err->format_message)(cinfo, buffer);
  249|      9|    TIFFErrorExtR(sp->tif, "JPEGLib", "%s",
  250|      9|                  buffer);       /* display the error message */
  251|      9|    jpeg_abort(cinfo);           /* clean up libjpeg state */
  252|      9|    LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
  ------------------
  |  |  143|      9|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
  253|      9|}
tif_jpeg_12.c:TIFFjpeg_output_message:
  261|      5|{
  262|      5|    char buffer[JMSG_LENGTH_MAX];
  263|       |
  264|      5|    (*cinfo->err->format_message)(cinfo, buffer);
  265|      5|    TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer);
  266|      5|}
tif_jpeg_12.c:TIFFjpeg_data_src:
  744|      9|{
  745|      9|    sp->cinfo.d.src = &sp->src;
  746|      9|    sp->src.init_source = std_init_source;
  747|      9|    sp->src.fill_input_buffer = std_fill_input_buffer;
  748|      9|    sp->src.skip_input_data = std_skip_input_data;
  749|      9|    sp->src.resync_to_restart = jpeg_resync_to_restart;
  750|      9|    sp->src.term_source = std_term_source;
  751|      9|    sp->src.bytes_in_buffer = 0; /* for safety */
  752|       |    sp->src.next_input_byte = NULL;
  753|      9|}
tif_jpeg_12.c:std_init_source:
  674|      7|{
  675|      7|    JPEGState *sp = (JPEGState *)cinfo;
  676|      7|    TIFF *tif = sp->tif;
  677|       |
  678|      7|    sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata;
  679|      7|    sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
  680|      7|}
tif_jpeg_12.c:std_fill_input_buffer:
  683|      4|{
  684|      4|    JPEGState *sp = (JPEGState *)cinfo;
  685|      4|    static const JOCTET dummy_EOI[2] = {0xFF, JPEG_EOI};
  686|       |
  687|       |#ifdef IPPJ_HUFF
  688|       |    /*
  689|       |     * The Intel IPP performance library does not necessarily read the whole
  690|       |     * input buffer in one pass, so it is possible to get here with data
  691|       |     * yet to read.
  692|       |     *
  693|       |     * We just return without doing anything, until the entire buffer has
  694|       |     * been read.
  695|       |     * http://trac.osgeo.org/gdal/wiki/JpegIPP
  696|       |     */
  697|       |    if (sp->src.bytes_in_buffer > 0)
  698|       |    {
  699|       |        return (TRUE);
  700|       |    }
  701|       |#endif
  702|       |
  703|       |    /*
  704|       |     * Normally the whole strip/tile is read and so we don't need to do
  705|       |     * a fill.  In the case of CHUNKY_STRIP_READ_SUPPORT we might not have
  706|       |     * all the data, but the rawdata is refreshed between scanlines and
  707|       |     * we push this into the io machinery in JPEGDecode().
  708|       |     * http://trac.osgeo.org/gdal/ticket/3894
  709|       |     */
  710|       |
  711|      4|    WARNMS(cinfo, JWRN_JPEG_EOF);
  712|       |    /* insert a fake EOI marker */
  713|      4|    sp->src.next_input_byte = dummy_EOI;
  714|      4|    sp->src.bytes_in_buffer = 2;
  715|      4|    return (TRUE);
  ------------------
  |  |   71|      4|#define TRUE 1
  ------------------
  716|      4|}
tif_jpeg_12.c:std_skip_input_data:
  719|    212|{
  720|    212|    JPEGState *sp = (JPEGState *)cinfo;
  721|       |
  722|    212|    if (num_bytes > 0)
  ------------------
  |  Branch (722:9): [True: 212, False: 0]
  ------------------
  723|    212|    {
  724|    212|        if ((size_t)num_bytes > sp->src.bytes_in_buffer)
  ------------------
  |  Branch (724:13): [True: 0, False: 212]
  ------------------
  725|      0|        {
  726|       |            /* oops, buffer overrun */
  727|      0|            (void)std_fill_input_buffer(cinfo);
  728|      0|        }
  729|    212|        else
  730|    212|        {
  731|    212|            sp->src.next_input_byte += (size_t)num_bytes;
  732|    212|            sp->src.bytes_in_buffer -= (size_t)num_bytes;
  733|    212|        }
  734|    212|    }
  735|    212|}
tif_jpeg_12.c:TIFFjpeg_read_header:
  396|      9|{
  397|       |    return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image));
  ------------------
  |  |  301|      9|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|      9|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (397:12): [True: 9, False: 0]
  ------------------
  398|      9|}
tif_jpeg_12.c:TIFFjpeg_destroy:
  525|      9|{
  526|       |    return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm));
  ------------------
  |  |  302|      9|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|      9|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|      9|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (526:12): [True: 0, False: 9]
  ------------------
  527|      9|}
tif_jpeg_12.c:TIFFInitJPEGCommon:
 2969|      9|{
 2970|      9|    JPEGState *sp;
 2971|       |
 2972|      9|    sp = JState(tif);
  ------------------
  |  |  208|      9|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2973|      9|    sp->tif = tif; /* back link */
 2974|       |
 2975|       |    /* Default values for codec-specific fields */
 2976|      9|    sp->otherSettings.jpegtables = NULL;
 2977|      9|    sp->otherSettings.jpegtables_length = 0;
 2978|      9|    sp->otherSettings.jpegquality = 75; /* Default IJG quality */
 2979|      9|    sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW;
  ------------------
  |  |  707|      9|#define JPEGCOLORMODE_RAW 0x0000     /* no conversion (default) */
  ------------------
 2980|      9|    sp->otherSettings.jpegtablesmode =
 2981|      9|        JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  710|      9|#define JPEGTABLESMODE_QUANT 0x0001  /* include quantization tbls */
  ------------------
                      JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  711|      9|#define JPEGTABLESMODE_HUFF 0x0002   /* include Huffman tbls */
  ------------------
 2982|      9|    sp->otherSettings.ycbcrsampling_fetched = 0;
 2983|       |
 2984|      9|    tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
 2985|      9|    tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
 2986|      9|    tif->tif_tagmethods.printdir = JPEGPrintDir;   /* hook for codec tags */
 2987|       |
 2988|       |    /*
 2989|       |     * Install codec methods.
 2990|       |     */
 2991|      9|    tif->tif_fixuptags = JPEGFixupTags;
 2992|      9|    tif->tif_setupdecode = JPEGSetupDecode;
 2993|      9|    tif->tif_predecode = JPEGPreDecode;
 2994|      9|    tif->tif_decoderow = JPEGDecode;
 2995|      9|    tif->tif_decodestrip = JPEGDecode;
 2996|      9|    tif->tif_decodetile = JPEGDecode;
 2997|      9|    tif->tif_setupencode = JPEGSetupEncode;
 2998|      9|    tif->tif_preencode = JPEGPreEncode;
 2999|      9|    tif->tif_postencode = JPEGPostEncode;
 3000|      9|    tif->tif_encoderow = JPEGEncode;
 3001|      9|    tif->tif_encodestrip = JPEGEncode;
 3002|      9|    tif->tif_encodetile = JPEGEncode;
 3003|      9|    tif->tif_getmaxcompressionratio = JPEGGetMaxCompressionRatio;
 3004|      9|    tif->tif_cleanup = JPEGCleanup;
 3005|       |
 3006|      9|    tif->tif_defstripsize = JPEGDefaultStripSize;
 3007|      9|    tif->tif_deftilesize = JPEGDefaultTileSize;
 3008|      9|    tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
  ------------------
  |  |  127|      9|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 3009|      9|    sp->cinfo_initialized = FALSE;
  ------------------
  |  |   72|      9|#define FALSE 0
  ------------------
 3010|      9|}
tif_jpeg_12.c:JPEGVGetField:
 2796|     18|{
 2797|     18|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|     18|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2798|       |
 2799|     18|    assert(sp != NULL);
  ------------------
  |  Branch (2799:5): [True: 0, False: 18]
  |  Branch (2799:5): [True: 18, False: 0]
  ------------------
 2800|       |
 2801|     18|    switch (tag)
 2802|     18|    {
 2803|      0|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|      0|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2803:9): [True: 0, False: 18]
  ------------------
 2804|      0|            *va_arg(ap, uint32_t *) = sp->otherSettings.jpegtables_length;
 2805|      0|            *va_arg(ap, const void **) = sp->otherSettings.jpegtables;
 2806|      0|            break;
 2807|      0|        case TIFFTAG_JPEGQUALITY:
  ------------------
  |  |  704|      0|#define TIFFTAG_JPEGQUALITY 65537    /* Compression quality level */
  ------------------
  |  Branch (2807:9): [True: 0, False: 18]
  ------------------
 2808|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegquality;
 2809|      0|            break;
 2810|      0|        case TIFFTAG_JPEGCOLORMODE:
  ------------------
  |  |  706|      0|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  |  Branch (2810:9): [True: 0, False: 18]
  ------------------
 2811|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegcolormode;
 2812|      0|            break;
 2813|      0|        case TIFFTAG_JPEGTABLESMODE:
  ------------------
  |  |  709|      0|#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
  ------------------
  |  Branch (2813:9): [True: 0, False: 18]
  ------------------
 2814|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode;
 2815|      0|            break;
 2816|     18|        default:
  ------------------
  |  Branch (2816:9): [True: 18, False: 0]
  ------------------
 2817|     18|            return (*sp->otherSettings.vgetparent)(tif, tag, ap);
 2818|     18|    }
 2819|      0|    return (1);
 2820|     18|}
tif_jpeg_12.c:JPEGPreDecode:
 1268|      7|{
 1269|      7|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1270|      7|    TIFFDirectory *td = &tif->tif_dir;
 1271|      7|    static const char module[] = "JPEGPreDecode";
 1272|      7|    int downsampled_output;
 1273|      7|    int ci;
 1274|       |
 1275|      7|    assert(sp != NULL);
  ------------------
  |  Branch (1275:5): [True: 0, False: 7]
  |  Branch (1275:5): [True: 7, False: 0]
  ------------------
 1276|       |
 1277|      7|    if (sp->cinfo.comm.is_decompressor == 0)
  ------------------
  |  Branch (1277:9): [True: 0, False: 7]
  ------------------
 1278|      0|    {
 1279|      0|        tif->tif_setupdecode(tif);
 1280|      0|    }
 1281|       |
 1282|      7|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1282:5): [True: 0, False: 7]
  |  Branch (1282:5): [True: 7, False: 0]
  ------------------
 1283|       |    /*
 1284|       |     * Reset decoder state from any previous strip/tile,
 1285|       |     * in case application didn't read the whole strip.
 1286|       |     */
 1287|      7|    if (!TIFFjpeg_abort(sp))
  ------------------
  |  Branch (1287:9): [True: 0, False: 7]
  ------------------
 1288|      0|        return (0);
 1289|       |    /*
 1290|       |     * Read the header for this strip/tile.
 1291|       |     */
 1292|       |
 1293|      7|    if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
  ------------------
  |  |   71|      7|#define TRUE 1
  ------------------
  |  Branch (1293:9): [True: 7, False: 0]
  ------------------
 1294|      7|        return (0);
 1295|       |
 1296|      0|    tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
 1297|      0|    tif->tif_rawcc = (tmsize_t)sp->src.bytes_in_buffer;
 1298|       |
 1299|      0|    if (!JPEGComputeStrileWidthHeightBytesPerLine(tif, s))
  ------------------
  |  Branch (1299:9): [True: 0, False: 0]
  ------------------
 1300|      0|        return 0;
 1301|       |
 1302|      0|    if (sp->cinfo.d.image_width < sp->strile_width ||
  ------------------
  |  Branch (1302:9): [True: 0, False: 0]
  ------------------
 1303|      0|        sp->cinfo.d.image_height < sp->strile_height)
  ------------------
  |  Branch (1303:9): [True: 0, False: 0]
  ------------------
 1304|      0|    {
 1305|      0|        TIFFWarningExtR(tif, module,
 1306|      0|                        "Improper JPEG strip/tile size, "
 1307|      0|                        "expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1308|      0|                        sp->strile_width, sp->strile_height,
 1309|      0|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1310|      0|    }
 1311|      0|    if (sp->cinfo.d.image_width == sp->strile_width &&
  ------------------
  |  Branch (1311:9): [True: 0, False: 0]
  ------------------
 1312|      0|        sp->cinfo.d.image_height > sp->strile_height &&
  ------------------
  |  Branch (1312:9): [True: 0, False: 0]
  ------------------
 1313|      0|        tif->tif_dir.td_row + sp->strile_height == td->td_imagelength &&
  ------------------
  |  Branch (1313:9): [True: 0, False: 0]
  ------------------
 1314|      0|        !isTiled(tif))
  ------------------
  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (1314:9): [True: 0, False: 0]
  ------------------
 1315|      0|    {
 1316|       |        /* Some files have a last strip, that should be truncated, */
 1317|       |        /* but their JPEG codestream has still the maximum strip */
 1318|       |        /* height. Warn about this as this is non compliant, but */
 1319|       |        /* we can safely recover from that. */
 1320|      0|        TIFFWarningExtR(tif, module,
 1321|      0|                        "JPEG strip size exceeds expected dimensions,"
 1322|      0|                        " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1323|      0|                        sp->strile_width, sp->strile_height,
 1324|      0|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1325|      0|    }
 1326|      0|    else if (sp->cinfo.d.image_width > sp->strile_width ||
  ------------------
  |  Branch (1326:14): [True: 0, False: 0]
  ------------------
 1327|      0|             sp->cinfo.d.image_height > sp->strile_height)
  ------------------
  |  Branch (1327:14): [True: 0, False: 0]
  ------------------
 1328|      0|    {
 1329|       |        /*
 1330|       |         * This case could be dangerous, if the strip or tile size has
 1331|       |         * been reported as less than the amount of data jpeg will
 1332|       |         * return, some potential security issues arise. Catch this
 1333|       |         * case and error out.
 1334|       |         */
 1335|      0|        TIFFErrorExtR(tif, module,
 1336|      0|                      "JPEG strip/tile size exceeds expected dimensions,"
 1337|      0|                      " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1338|      0|                      sp->strile_width, sp->strile_height,
 1339|      0|                      sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1340|      0|        return (0);
 1341|      0|    }
 1342|      0|    if (sp->cinfo.d.num_components !=
  ------------------
  |  Branch (1342:9): [True: 0, False: 0]
  ------------------
 1343|      0|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|      0|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1343:10): [True: 0, False: 0]
  ------------------
 1344|      0|                                                    : 1))
 1345|      0|    {
 1346|      0|        TIFFErrorExtR(tif, module, "Improper JPEG component count");
 1347|      0|        return (0);
 1348|      0|    }
 1349|       |#ifdef JPEG_LIB_MK1
 1350|       |    if (12 != td->td_bitspersample && 8 != td->td_bitspersample)
 1351|       |    {
 1352|       |        TIFFErrorExtR(tif, module, "Improper JPEG data precision");
 1353|       |        return (0);
 1354|       |    }
 1355|       |    sp->cinfo.d.data_precision = td->td_bitspersample;
 1356|       |    sp->cinfo.d.bits_in_jsample = td->td_bitspersample;
 1357|       |#else
 1358|      0|    if (td->td_bitspersample != BITS_IN_JSAMPLE ||
  ------------------
  |  |  102|      0|#define BITS_IN_JSAMPLE 12
  ------------------
  |  Branch (1358:9): [True: 0, False: 0]
  ------------------
 1359|      0|        sp->cinfo.d.data_precision != td->td_bitspersample)
  ------------------
  |  Branch (1359:9): [True: 0, False: 0]
  ------------------
 1360|      0|    {
 1361|      0|        TIFFErrorExtR(tif, module, "Improper JPEG data precision");
 1362|      0|        return (0);
 1363|      0|    }
 1364|      0|#endif
 1365|       |
 1366|      0|    if (sp->cinfo.d.progressive_mode &&
  ------------------
  |  Branch (1366:9): [True: 0, False: 0]
  ------------------
 1367|      0|        !sp->otherSettings.has_warned_about_progressive_mode)
  ------------------
  |  Branch (1367:9): [True: 0, False: 0]
  ------------------
 1368|      0|    {
 1369|      0|        TIFFWarningExtR(tif, module,
 1370|      0|                        "The JPEG strip/tile is encoded with progressive mode, "
 1371|      0|                        "which is normally not legal for JPEG-in-TIFF.\n"
 1372|      0|                        "libtiff should be able to decode it, but it might "
 1373|      0|                        "cause compatibility issues with other readers");
 1374|      0|        sp->otherSettings.has_warned_about_progressive_mode = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1375|      0|    }
 1376|       |
 1377|       |    /* In some cases, libjpeg needs to allocate a lot of memory */
 1378|       |    /* http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
 1379|       |     */
 1380|      0|    if (TIFFjpeg_has_multiple_scans(sp))
  ------------------
  |  Branch (1380:9): [True: 0, False: 0]
  ------------------
 1381|      0|    {
 1382|       |        /* In this case libjpeg will need to allocate memory or backing */
 1383|       |        /* store for all coefficients */
 1384|       |        /* See call to jinit_d_coef_controller() from master_selection() */
 1385|       |        /* in libjpeg */
 1386|       |
 1387|       |        /* 1 MB for regular libjpeg usage */
 1388|      0|        toff_t nRequiredMemory = 1024 * 1024;
 1389|       |
 1390|      0|        for (ci = 0; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1390:22): [True: 0, False: 0]
  ------------------
 1391|      0|        {
 1392|      0|            const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]);
 1393|      0|            if (compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0)
  ------------------
  |  Branch (1393:17): [True: 0, False: 0]
  |  Branch (1393:47): [True: 0, False: 0]
  ------------------
 1394|      0|            {
 1395|      0|                nRequiredMemory +=
 1396|      0|                    (toff_t)((JDIMENSION)(((int)compptr->width_in_blocks +
 1397|      0|                                           compptr->h_samp_factor - 1) /
 1398|      0|                                          compptr->h_samp_factor)) *
 1399|      0|                    (JDIMENSION)(((int)compptr->height_in_blocks +
 1400|      0|                                  compptr->v_samp_factor - 1) /
 1401|      0|                                 compptr->v_samp_factor) *
 1402|      0|                    sizeof(JBLOCK);
 1403|      0|            }
 1404|      0|        }
 1405|       |
 1406|      0|        if (sp->cinfo.d.mem->max_memory_to_use > 0 &&
  ------------------
  |  Branch (1406:13): [True: 0, False: 0]
  ------------------
 1407|      0|            nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) &&
  ------------------
  |  Branch (1407:13): [True: 0, False: 0]
  ------------------
 1408|      0|            getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL)
  ------------------
  |  Branch (1408:13): [True: 0, False: 0]
  ------------------
 1409|      0|        {
 1410|      0|            TIFFErrorExtR(
 1411|      0|                tif, module,
 1412|      0|                "Reading this image would require libjpeg to allocate "
 1413|      0|                "at least %" PRIu64 " bytes. "
 1414|      0|                "This is disabled since above the %ld threshold. "
 1415|      0|                "You may override this restriction by defining the "
 1416|      0|                "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
 1417|      0|                "or setting the JPEGMEM environment variable to a value "
 1418|      0|                "greater "
 1419|      0|                "or equal to '%" PRIu64 "M'",
 1420|      0|                nRequiredMemory, sp->cinfo.d.mem->max_memory_to_use,
 1421|      0|                (nRequiredMemory + 1000000u - 1u) / 1000000u);
 1422|      0|            return 0;
 1423|      0|        }
 1424|      0|    }
 1425|       |
 1426|      0|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|      0|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1426:9): [True: 0, False: 0]
  ------------------
 1427|      0|    {
 1428|       |        /* Component 0 should have expected sampling factors */
 1429|      0|        if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
  ------------------
  |  Branch (1429:13): [True: 0, False: 0]
  ------------------
 1430|      0|            sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling)
  ------------------
  |  Branch (1430:13): [True: 0, False: 0]
  ------------------
 1431|      0|        {
 1432|      0|            TIFFErrorExtR(tif, module,
 1433|      0|                          "Improper JPEG sampling factors %d,%d\n"
 1434|      0|                          "Apparently should be %" PRIu16 ",%" PRIu16 ".",
 1435|      0|                          sp->cinfo.d.comp_info[0].h_samp_factor,
 1436|      0|                          sp->cinfo.d.comp_info[0].v_samp_factor,
 1437|      0|                          sp->h_sampling, sp->v_sampling);
 1438|      0|            return (0);
 1439|      0|        }
 1440|       |        /* Rest should have sampling factors 1,1 */
 1441|      0|        for (ci = 1; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1441:22): [True: 0, False: 0]
  ------------------
 1442|      0|        {
 1443|      0|            if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 ||
  ------------------
  |  Branch (1443:17): [True: 0, False: 0]
  ------------------
 1444|      0|                sp->cinfo.d.comp_info[ci].v_samp_factor != 1)
  ------------------
  |  Branch (1444:17): [True: 0, False: 0]
  ------------------
 1445|      0|            {
 1446|      0|                TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
 1447|      0|                return (0);
 1448|      0|            }
 1449|      0|        }
 1450|      0|    }
 1451|      0|    else
 1452|      0|    {
 1453|       |        /* PC 2's single component should have sampling factors 1,1 */
 1454|      0|        if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 ||
  ------------------
  |  Branch (1454:13): [True: 0, False: 0]
  ------------------
 1455|      0|            sp->cinfo.d.comp_info[0].v_samp_factor != 1)
  ------------------
  |  Branch (1455:13): [True: 0, False: 0]
  ------------------
 1456|      0|        {
 1457|      0|            TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
 1458|      0|            return (0);
 1459|      0|        }
 1460|      0|    }
 1461|      0|    downsampled_output = FALSE;
  ------------------
  |  |   72|      0|#define FALSE 0
  ------------------
 1462|      0|    if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|      0|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1462:9): [True: 0, False: 0]
  ------------------
 1463|      0|        sp->photometric == PHOTOMETRIC_YCBCR &&
  ------------------
  |  |  227|      0|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1463:9): [True: 0, False: 0]
  ------------------
 1464|      0|        sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
  ------------------
  |  |  708|      0|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  |  Branch (1464:9): [True: 0, False: 0]
  ------------------
 1465|      0|    {
 1466|       |        /* Convert YCbCr to RGB */
 1467|      0|        sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
 1468|      0|        sp->cinfo.d.out_color_space = JCS_RGB;
 1469|      0|    }
 1470|      0|    else
 1471|      0|    {
 1472|       |        /* Suppress colorspace handling */
 1473|      0|        sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
 1474|      0|        sp->cinfo.d.out_color_space = JCS_UNKNOWN;
 1475|      0|        if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|      0|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1475:13): [True: 0, False: 0]
  ------------------
 1476|      0|            (sp->h_sampling != 1 || sp->v_sampling != 1))
  ------------------
  |  Branch (1476:14): [True: 0, False: 0]
  |  Branch (1476:37): [True: 0, False: 0]
  ------------------
 1477|      0|            downsampled_output = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1478|       |        /* XXX what about up-sampling? */
 1479|      0|    }
 1480|      0|    if (downsampled_output)
  ------------------
  |  Branch (1480:9): [True: 0, False: 0]
  ------------------
 1481|      0|    {
 1482|       |        /* Need to use raw-data interface to libjpeg */
 1483|      0|        sp->cinfo.d.raw_data_out = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1484|       |#if JPEG_LIB_VERSION >= 70
 1485|       |        sp->cinfo.d.do_fancy_upsampling = FALSE;
 1486|       |#endif /* JPEG_LIB_VERSION >= 70 */
 1487|      0|        tif->tif_decoderow = DecodeRowError;
 1488|      0|        tif->tif_decodestrip = JPEGDecodeRaw;
 1489|      0|        tif->tif_decodetile = JPEGDecodeRaw;
 1490|      0|    }
 1491|      0|    else
 1492|      0|    {
 1493|       |        /* Use normal interface to libjpeg */
 1494|      0|        sp->cinfo.d.raw_data_out = FALSE;
  ------------------
  |  |   72|      0|#define FALSE 0
  ------------------
 1495|      0|        tif->tif_decoderow = JPEGDecode;
 1496|      0|        tif->tif_decodestrip = JPEGDecode;
 1497|      0|        tif->tif_decodetile = JPEGDecode;
 1498|      0|    }
 1499|       |    /* Start JPEG decompressor */
 1500|      0|    if (!TIFFjpeg_start_decompress(sp))
  ------------------
  |  Branch (1500:9): [True: 0, False: 0]
  ------------------
 1501|      0|        return (0);
 1502|       |    /* Allocate downsampled-data buffers if needed */
 1503|      0|    if (downsampled_output)
  ------------------
  |  Branch (1503:9): [True: 0, False: 0]
  ------------------
 1504|      0|    {
 1505|      0|        if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info,
  ------------------
  |  Branch (1505:13): [True: 0, False: 0]
  ------------------
 1506|      0|                                       sp->cinfo.d.num_components))
 1507|      0|            return (0);
 1508|      0|        sp->scancount = DCTSIZE; /* mark buffer empty */
 1509|      0|    }
 1510|      0|    return (1);
 1511|      0|}
tif_jpeg_12.c:TIFFjpeg_abort:
  520|      7|{
  521|       |    return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm));
  ------------------
  |  |  302|      7|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|      7|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|      7|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (521:12): [True: 0, False: 7]
  ------------------
  522|      7|}
tif_jpeg_12.c:JPEGCleanup:
 2678|      9|{
 2679|      9|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      9|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2680|       |
 2681|      9|    assert(sp != 0);
  ------------------
  |  Branch (2681:5): [True: 0, False: 9]
  |  Branch (2681:5): [True: 9, False: 0]
  ------------------
 2682|       |
 2683|      9|    tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent;
 2684|      9|    tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent;
 2685|      9|    tif->tif_tagmethods.printdir = sp->otherSettings.printdir;
 2686|      9|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2686:9): [True: 9, False: 0]
  ------------------
 2687|      9|        TIFFjpeg_destroy(sp);         /* release libjpeg resources */
 2688|      9|    if (sp->otherSettings.jpegtables) /* tag value */
  ------------------
  |  Branch (2688:9): [True: 2, False: 7]
  ------------------
 2689|      2|        _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
 2690|      9|    _TIFFfreeExt(tif, tif->tif_data); /* release local state */
 2691|      9|    tif->tif_data = NULL;
 2692|       |
 2693|      9|    _TIFFSetDefaultCompressionState(tif);
 2694|      9|}
tif_jpeg_12.c:JPEGInitializeLibJPEG:
 2883|      9|{
 2884|      9|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      9|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2885|       |
 2886|      9|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2886:9): [True: 0, False: 9]
  ------------------
 2887|      0|    {
 2888|      0|        if (!decompress && sp->cinfo.comm.is_decompressor)
  ------------------
  |  Branch (2888:13): [True: 0, False: 0]
  |  Branch (2888:28): [True: 0, False: 0]
  ------------------
 2889|      0|            TIFFjpeg_destroy(sp);
 2890|      0|        else if (decompress && !sp->cinfo.comm.is_decompressor)
  ------------------
  |  Branch (2890:18): [True: 0, False: 0]
  |  Branch (2890:32): [True: 0, False: 0]
  ------------------
 2891|      0|            TIFFjpeg_destroy(sp);
 2892|      0|        else
 2893|      0|            return 1;
 2894|       |
 2895|      0|        sp->cinfo_initialized = 0;
 2896|      0|    }
 2897|       |
 2898|       |    /*
 2899|       |     * Initialize libjpeg.
 2900|       |     */
 2901|      9|    if (decompress)
  ------------------
  |  Branch (2901:9): [True: 9, False: 0]
  ------------------
 2902|      9|    {
 2903|      9|        if (!TIFFjpeg_create_decompress(sp))
  ------------------
  |  Branch (2903:13): [True: 0, False: 9]
  ------------------
 2904|      0|            return (0);
 2905|      9|    }
 2906|      0|    else
 2907|      0|    {
 2908|      0|        if (!TIFFjpeg_create_compress(sp))
  ------------------
  |  Branch (2908:13): [True: 0, False: 0]
  ------------------
 2909|      0|            return (0);
 2910|      0|#ifndef TIFF_JPEG_MAX_MEMORY_TO_USE
 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
 2912|      0|#endif
 2913|       |        /* libjpeg turbo 1.5.2 honours max_memory_to_use, but has no backing */
 2914|       |        /* store implementation, so better not set max_memory_to_use ourselves.
 2915|       |         */
 2916|       |        /* See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 */
 2917|      0|        if (sp->cinfo.c.mem->max_memory_to_use > 0)
  ------------------
  |  Branch (2917:13): [True: 0, False: 0]
  ------------------
 2918|      0|        {
 2919|       |            /* This is to address bug related in ticket GDAL #1795. */
 2920|      0|            if (getenv("JPEGMEM") == NULL)
  ------------------
  |  Branch (2920:17): [True: 0, False: 0]
  ------------------
 2921|      0|            {
 2922|       |                /* Increase the max memory usable. This helps when creating
 2923|       |                 * files */
 2924|       |                /* with "big" tile, without using libjpeg temporary files. */
 2925|       |                /* For example a 512x512 tile with 3 bands */
 2926|       |                /* requires 1.5 MB which is above libjpeg 1MB default */
 2927|      0|                if (sp->cinfo.c.mem->max_memory_to_use <
  ------------------
  |  Branch (2927:21): [True: 0, False: 0]
  ------------------
 2928|      0|                    TIFF_JPEG_MAX_MEMORY_TO_USE)
  ------------------
  |  | 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
  ------------------
 2929|      0|                    sp->cinfo.c.mem->max_memory_to_use =
 2930|      0|                        TIFF_JPEG_MAX_MEMORY_TO_USE;
  ------------------
  |  | 2911|      0|#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
  ------------------
 2931|      0|            }
 2932|      0|        }
 2933|      0|    }
 2934|       |
 2935|      9|    sp->cinfo_initialized = TRUE;
  ------------------
  |  |   71|      9|#define TRUE 1
  ------------------
 2936|       |
 2937|      9|    return 1;
 2938|      9|}
tif_jpeg_12.c:JPEGSetupDecode:
 1136|      9|{
 1137|      9|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      9|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1138|      9|    TIFFDirectory *td = &tif->tif_dir;
 1139|       |
 1140|       |#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
 1141|       |    if (tif->tif_dir.td_bitspersample == 12)
 1142|       |    {
 1143|       |        /* We pass a pointer to a copy of otherSettings, since */
 1144|       |        /* TIFFReInitJPEG_12() will clear sp */
 1145|       |        JPEGOtherSettings savedOtherSettings = sp->otherSettings;
 1146|       |        return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 0);
 1147|       |    }
 1148|       |#endif
 1149|       |
 1150|      9|    JPEGInitializeLibJPEG(tif, TRUE);
  ------------------
  |  |   71|      9|#define TRUE 1
  ------------------
 1151|       |
 1152|      9|    assert(sp != NULL);
  ------------------
  |  Branch (1152:5): [True: 0, False: 9]
  |  Branch (1152:5): [True: 9, False: 0]
  ------------------
 1153|      9|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1153:5): [True: 0, False: 9]
  |  Branch (1153:5): [True: 9, False: 0]
  ------------------
 1154|       |
 1155|       |    /* Read JPEGTables if it is present */
 1156|      9|    if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
  ------------------
  |  |  248|      9|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      9|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      9|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 2, False: 7]
  |  |  ------------------
  ------------------
 1157|      2|    {
 1158|      2|        TIFFjpeg_tables_src(sp);
 1159|      2|        if (TIFFjpeg_read_header(sp, FALSE) != JPEG_HEADER_TABLES_ONLY)
  ------------------
  |  |   72|      2|#define FALSE 0
  ------------------
  |  Branch (1159:13): [True: 2, False: 0]
  ------------------
 1160|      2|        {
 1161|      2|            TIFFErrorExtR(tif, "JPEGSetupDecode", "Bogus JPEGTables field");
 1162|      2|            return (0);
 1163|      2|        }
 1164|      2|    }
 1165|       |
 1166|       |    /* Grab parameters that are same for all strips/tiles */
 1167|      7|    sp->photometric = td->td_photometric;
 1168|      7|    switch (sp->photometric)
 1169|      7|    {
 1170|      3|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|      3|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1170:9): [True: 3, False: 4]
  ------------------
 1171|      3|            sp->h_sampling = td->td_ycbcrsubsampling[0];
 1172|      3|            sp->v_sampling = td->td_ycbcrsubsampling[1];
 1173|      3|            break;
 1174|      4|        default:
  ------------------
  |  Branch (1174:9): [True: 4, False: 3]
  ------------------
 1175|       |            /* TIFF 6.0 forbids subsampling of all other color spaces */
 1176|      4|            sp->h_sampling = 1;
 1177|      4|            sp->v_sampling = 1;
 1178|      4|            break;
 1179|      7|    }
 1180|       |
 1181|       |    /* Set up for reading normal data */
 1182|      7|    TIFFjpeg_data_src(sp);
 1183|      7|    tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
 1184|      7|    return (1);
 1185|      7|}
tif_jpeg_12.c:TIFFjpeg_tables_src:
  769|      2|{
  770|      2|    TIFFjpeg_data_src(sp);
  771|      2|    sp->src.init_source = tables_init_source;
  772|      2|}
tif_jpeg_12.c:tables_init_source:
  761|      2|{
  762|      2|    JPEGState *sp = (JPEGState *)cinfo;
  763|       |
  764|      2|    sp->src.next_input_byte = (const JOCTET *)sp->otherSettings.jpegtables;
  765|      2|    sp->src.bytes_in_buffer = (size_t)sp->otherSettings.jpegtables_length;
  766|      2|}

TIFFReInitJPEG_12:
   32|      9|{
   33|      9|    JPEGState *sp;
   34|      9|    uint8_t *new_tif_data;
   35|       |
   36|      9|    (void)scheme;
   37|      9|    assert(scheme == COMPRESSION_JPEG);
  ------------------
  |  Branch (37:5): [True: 0, False: 9]
  |  Branch (37:5): [True: 9, False: 0]
  ------------------
   38|       |
   39|      9|    new_tif_data =
   40|      9|        (uint8_t *)_TIFFreallocExt(tif, tif->tif_data, sizeof(JPEGState));
   41|       |
   42|      9|    if (new_tif_data == NULL)
  ------------------
  |  Branch (42:9): [True: 0, False: 9]
  ------------------
   43|      0|    {
   44|      0|        TIFFErrorExtR(tif, "TIFFReInitJPEG_12",
   45|      0|                      "No space for JPEG state block");
   46|      0|        return 0;
   47|      0|    }
   48|       |
   49|      9|    tif->tif_data = new_tif_data;
   50|      9|    _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
   51|       |
   52|      9|    TIFFInitJPEGCommon(tif);
   53|       |
   54|      9|    sp = JState(tif);
  ------------------
  |  |  208|      9|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
   55|      9|    sp->otherSettings = *otherSettings;
   56|       |
   57|      9|    if (is_encode)
  ------------------
  |  Branch (57:9): [True: 0, False: 9]
  ------------------
   58|      0|        return JPEGSetupEncode(tif);
   59|      9|    else
   60|      9|        return JPEGSetupDecode(tif);
   61|      9|}

LogL16toY:
  790|  9.50k|{
  791|  9.50k|    int Le = p16 & 0x7fff;
  792|  9.50k|    double Y;
  793|       |
  794|  9.50k|    if (!Le)
  ------------------
  |  Branch (794:9): [True: 334, False: 9.17k]
  ------------------
  795|    334|        return (0.);
  796|  9.17k|    Y = exp(M_LN2 / 256. * (Le + .5) - M_LN2 * 64.);
  797|  9.17k|    return (!(p16 & 0x8000) ? Y : -Y);
  ------------------
  |  Branch (797:13): [True: 2.04k, False: 7.12k]
  ------------------
  798|  9.50k|}
XYZtoRGB24:
  945|  7.61k|{
  946|  7.61k|    double r, g, b;
  947|       |    /* assume CCIR-709 primaries */
  948|  7.61k|    r = 2.690 * (double)xyz[0] + -1.276 * (double)xyz[1] +
  949|  7.61k|        -0.414 * (double)xyz[2];
  950|  7.61k|    g = -1.022 * (double)xyz[0] + 1.978 * (double)xyz[1] +
  951|  7.61k|        0.044 * (double)xyz[2];
  952|  7.61k|    b = 0.061 * (double)xyz[0] + -0.224 * (double)xyz[1] +
  953|  7.61k|        1.163 * (double)xyz[2];
  954|       |    /* assume 2.0 gamma for speed */
  955|       |    /* could use integer sqrt approx., but this is probably faster */
  956|  7.61k|    rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r)));
  ------------------
  |  Branch (956:24): [True: 6.24k, False: 1.36k]
  |  Branch (956:40): [True: 464, False: 903]
  ------------------
  957|  7.61k|    rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g)));
  ------------------
  |  Branch (957:24): [True: 6.74k, False: 867]
  |  Branch (957:40): [True: 271, False: 596]
  ------------------
  958|  7.61k|    rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b)));
  ------------------
  |  Branch (958:24): [True: 5.85k, False: 1.76k]
  |  Branch (958:40): [True: 596, False: 1.16k]
  ------------------
  959|  7.61k|}
LogL10toY:
  965|  1.45k|{
  966|  1.45k|    if (p10 == 0)
  ------------------
  |  Branch (966:9): [True: 355, False: 1.10k]
  ------------------
  967|    355|        return (0.);
  968|  1.10k|    return (exp(M_LN2 / 64. * (p10 + .5) - M_LN2 * 12.));
  969|  1.45k|}
uv_decode:
 1080|  1.10k|{
 1081|  1.10k|    unsigned int upper, lower;
 1082|  1.10k|    int ui;
 1083|  1.10k|    unsigned int vi;
 1084|       |
 1085|  1.10k|    if (c < 0 || c >= UV_NDIVS)
  ------------------
  |  |    3|  1.10k|#define UV_NDIVS 16289
  ------------------
  |  Branch (1085:9): [True: 0, False: 1.10k]
  |  Branch (1085:18): [True: 74, False: 1.02k]
  ------------------
 1086|     74|        return (-1);
 1087|  1.02k|    lower = 0; /* binary search */
 1088|  1.02k|    upper = UV_NVS;
  ------------------
  |  |    5|  1.02k|#define UV_NVS 163
  ------------------
 1089|  8.56k|    while (upper - lower > 1)
  ------------------
  |  Branch (1089:12): [True: 7.55k, False: 1.01k]
  ------------------
 1090|  7.55k|    {
 1091|  7.55k|        vi = (lower + upper) >> 1;
 1092|  7.55k|        ui = c - uv_row[vi].ncum;
 1093|  7.55k|        if (ui > 0)
  ------------------
  |  Branch (1093:13): [True: 3.07k, False: 4.47k]
  ------------------
 1094|  3.07k|            lower = vi;
 1095|  4.47k|        else if (ui < 0)
  ------------------
  |  Branch (1095:18): [True: 4.45k, False: 18]
  ------------------
 1096|  4.45k|            upper = vi;
 1097|     18|        else
 1098|     18|        {
 1099|     18|            lower = vi;
 1100|     18|            break;
 1101|     18|        }
 1102|  7.55k|    }
 1103|  1.02k|    vi = lower;
 1104|  1.02k|    ui = c - uv_row[vi].ncum;
 1105|  1.02k|    *up = (double)uv_row[vi].ustart + ((double)ui + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    2|  1.02k|#define UV_SQSIZ (float)0.003500
  ------------------
 1106|  1.02k|    *vp = (double)UV_VSTART + ((double)vi + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    4|  1.02k|#define UV_VSTART (float)0.016940
  ------------------
                  *vp = (double)UV_VSTART + ((double)vi + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    2|  1.02k|#define UV_SQSIZ (float)0.003500
  ------------------
 1107|  1.02k|    return (0);
 1108|  1.10k|}
LogLuv24toXYZ:
 1114|  1.45k|{
 1115|  1.45k|    int Ce;
 1116|  1.45k|    double L, u, v, s, x, y;
 1117|       |    /* decode luminance */
 1118|  1.45k|    L = LogL10toY(p >> 14 & 0x3ff);
 1119|  1.45k|    if (L <= 0.)
  ------------------
  |  Branch (1119:9): [True: 355, False: 1.10k]
  ------------------
 1120|    355|    {
 1121|    355|        XYZ[0] = XYZ[1] = XYZ[2] = 0.;
 1122|    355|        return;
 1123|    355|    }
 1124|       |    /* decode color */
 1125|  1.10k|    Ce = p & 0x3fff;
 1126|  1.10k|    if (uv_decode(&u, &v, Ce) < 0)
  ------------------
  |  Branch (1126:9): [True: 74, False: 1.02k]
  ------------------
 1127|     74|    {
 1128|     74|        u = U_NEU;
  ------------------
  |  |  613|     74|#define U_NEU 0.210526316
  ------------------
 1129|     74|        v = V_NEU;
  ------------------
  |  |  614|     74|#define V_NEU 0.473684211
  ------------------
 1130|     74|    }
 1131|  1.10k|    s = 1. / (6. * u - 16. * v + 12.);
 1132|  1.10k|    x = 9. * u * s;
 1133|  1.10k|    y = 4. * v * s;
 1134|       |    /* convert to XYZ */
 1135|  1.10k|    XYZ[0] = (float)(x / y * L);
 1136|  1.10k|    XYZ[1] = (float)L;
 1137|  1.10k|    XYZ[2] = (float)((1. - x - y) / y * L);
 1138|  1.10k|}
LogLuv32toXYZ:
 1274|  8.41k|{
 1275|  8.41k|    double L, u, v, s, x, y;
 1276|       |    /* decode luminance */
 1277|  8.41k|    L = LogL16toY((int)p >> 16);
 1278|  8.41k|    if (L <= 0.)
  ------------------
  |  Branch (1278:9): [True: 6.71k, False: 1.70k]
  ------------------
 1279|  6.71k|    {
 1280|  6.71k|        XYZ[0] = XYZ[1] = XYZ[2] = 0.;
 1281|  6.71k|        return;
 1282|  6.71k|    }
 1283|       |    /* decode color */
 1284|  1.70k|    u = 1. / UVSCALE * ((p >> 8 & 0xff) + .5);
  ------------------
  |  |  615|  1.70k|#define UVSCALE 410.
  ------------------
 1285|  1.70k|    v = 1. / UVSCALE * ((p & 0xff) + .5);
  ------------------
  |  |  615|  1.70k|#define UVSCALE 410.
  ------------------
 1286|  1.70k|    s = 1. / (6. * u - 16. * v + 12.);
 1287|  1.70k|    x = 9. * u * s;
 1288|  1.70k|    y = 4. * v * s;
 1289|       |    /* convert to XYZ */
 1290|  1.70k|    XYZ[0] = (float)(x / y * L);
 1291|  1.70k|    XYZ[1] = (float)L;
 1292|  1.70k|    XYZ[2] = (float)((1. - x - y) / y * L);
 1293|  1.70k|}
TIFFInitSGILog:
 1917|     85|{
 1918|     85|    static const char module[] = "TIFFInitSGILog";
 1919|     85|    LogLuvState *sp;
 1920|       |
 1921|     85|    assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
  ------------------
  |  Branch (1921:5): [True: 85, False: 0]
  |  Branch (1921:5): [True: 0, False: 0]
  |  Branch (1921:5): [True: 57, False: 28]
  |  Branch (1921:5): [True: 28, False: 0]
  ------------------
 1922|       |
 1923|       |    /*
 1924|       |     * Merge codec-specific tag information.
 1925|       |     */
 1926|     85|    if (!_TIFFMergeFields(tif, LogLuvFields, TIFFArrayCount(LogLuvFields)))
  ------------------
  |  |  339|     85|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1926:9): [True: 0, False: 85]
  ------------------
 1927|      0|    {
 1928|      0|        TIFFErrorExtR(tif, module, "Merging SGILog codec-specific tags failed");
 1929|      0|        return 0;
 1930|      0|    }
 1931|       |
 1932|       |    /*
 1933|       |     * Allocate state block so tag methods have storage to record values.
 1934|       |     */
 1935|     85|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LogLuvState));
 1936|     85|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1936:9): [True: 0, False: 85]
  ------------------
 1937|      0|        goto bad;
 1938|     85|    sp = (LogLuvState *)tif->tif_data;
 1939|     85|    _TIFFmemset((void *)sp, 0, sizeof(*sp));
 1940|     85|    sp->user_datafmt = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|     85|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1941|     85|    sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
  ------------------
  |  |  211|     85|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
                  sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
  ------------------
  |  |  750|     57|#define SGILOGENCODE_RANDITHER 1       /* randomly dither encd values */
  ------------------
  |  Branch (1941:23): [True: 57, False: 28]
  ------------------
 1942|     85|                                                       : SGILOGENCODE_NODITHER;
  ------------------
  |  |  749|    113|#define SGILOGENCODE_NODITHER 0        /* do not dither encoded values*/
  ------------------
 1943|     85|    sp->tfunc = _logLuvNop;
 1944|       |
 1945|       |    /*
 1946|       |     * Install codec methods.
 1947|       |     * NB: tif_decoderow & tif_encoderow are filled
 1948|       |     *     in at setup time.
 1949|       |     */
 1950|     85|    tif->tif_fixuptags = LogLuvFixupTags;
 1951|     85|    tif->tif_setupdecode = LogLuvSetupDecode;
 1952|     85|    tif->tif_decodestrip = LogLuvDecodeStrip;
 1953|     85|    tif->tif_decodetile = LogLuvDecodeTile;
 1954|     85|    tif->tif_setupencode = LogLuvSetupEncode;
 1955|     85|    tif->tif_encodestrip = LogLuvEncodeStrip;
 1956|     85|    tif->tif_encodetile = LogLuvEncodeTile;
 1957|     85|    tif->tif_close = LogLuvClose;
 1958|     85|    tif->tif_cleanup = LogLuvCleanup;
 1959|       |
 1960|       |    /*
 1961|       |     * Override parent get/set field methods.
 1962|       |     */
 1963|     85|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1964|     85|    tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */
 1965|     85|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1966|     85|    tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */
 1967|       |
 1968|     85|    return (1);
 1969|      0|bad:
 1970|      0|    TIFFErrorExtR(tif, module, "%s: No space for LogLuv state block",
 1971|      0|                  tif->tif_name);
 1972|      0|    return (0);
 1973|     85|}
tif_luv.c:_logLuvNop:
 1437|     15|{
 1438|     15|    (void)sp;
 1439|     15|    (void)op;
 1440|     15|    (void)n;
 1441|     15|}
tif_luv.c:LogLuvFixupTags:
 1630|     84|{
 1631|     84|    (void)tif;
 1632|     84|    return (1);
 1633|     84|}
tif_luv.c:LogLuvSetupDecode:
 1636|     89|{
 1637|     89|    static const char module[] = "LogLuvSetupDecode";
 1638|     89|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     89|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1639|     89|    TIFFDirectory *td = &tif->tif_dir;
 1640|       |
 1641|     89|    tif->tif_postdecode = _TIFFNoPostDecode;
 1642|     89|    switch (td->td_photometric)
 1643|     89|    {
 1644|     58|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|     58|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (1644:9): [True: 58, False: 31]
  ------------------
 1645|     58|            if (!LogLuvInitState(tif))
  ------------------
  |  Branch (1645:17): [True: 22, False: 36]
  ------------------
 1646|     22|                break;
 1647|     36|            if (td->td_compression == COMPRESSION_SGILOG24)
  ------------------
  |  |  211|     36|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (1647:17): [True: 28, False: 8]
  ------------------
 1648|     28|            {
 1649|     28|                tif->tif_decoderow = LogLuvDecode24;
 1650|     28|                switch (sp->user_datafmt)
 1651|     28|                {
 1652|      3|                    case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      3|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1652:21): [True: 3, False: 25]
  ------------------
 1653|      3|                        sp->tfunc = Luv24toXYZ;
 1654|      3|                        break;
 1655|      0|                    case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1655:21): [True: 0, False: 28]
  ------------------
 1656|      0|                        sp->tfunc = Luv24toLuv48;
 1657|      0|                        break;
 1658|     22|                    case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|     22|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1658:21): [True: 22, False: 6]
  ------------------
 1659|     22|                        sp->tfunc = Luv24toRGB;
 1660|     22|                        break;
 1661|      3|                    default:
  ------------------
  |  Branch (1661:21): [True: 3, False: 25]
  ------------------
 1662|      3|                        break;
 1663|     28|                }
 1664|     28|            }
 1665|      8|            else
 1666|      8|            {
 1667|      8|                tif->tif_decoderow = LogLuvDecode32;
 1668|      8|                switch (sp->user_datafmt)
 1669|      8|                {
 1670|      3|                    case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      3|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1670:21): [True: 3, False: 5]
  ------------------
 1671|      3|                        sp->tfunc = Luv32toXYZ;
 1672|      3|                        break;
 1673|      0|                    case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1673:21): [True: 0, False: 8]
  ------------------
 1674|      0|                        sp->tfunc = Luv32toLuv48;
 1675|      0|                        break;
 1676|      4|                    case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      4|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1676:21): [True: 4, False: 4]
  ------------------
 1677|      4|                        sp->tfunc = Luv32toRGB;
 1678|      4|                        break;
 1679|      1|                    default:
  ------------------
  |  Branch (1679:21): [True: 1, False: 7]
  ------------------
 1680|      1|                        break;
 1681|      8|                }
 1682|      8|            }
 1683|     36|            return (1);
 1684|     31|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|     31|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (1684:9): [True: 31, False: 58]
  ------------------
 1685|     31|            if (!LogL16InitState(tif))
  ------------------
  |  Branch (1685:17): [True: 11, False: 20]
  ------------------
 1686|     11|                break;
 1687|     20|            tif->tif_decoderow = LogL16Decode;
 1688|     20|            switch (sp->user_datafmt)
 1689|     20|            {
 1690|      9|                case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      9|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1690:17): [True: 9, False: 11]
  ------------------
 1691|      9|                    sp->tfunc = L16toY;
 1692|      9|                    break;
 1693|      6|                case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      6|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1693:17): [True: 6, False: 14]
  ------------------
 1694|      6|                    sp->tfunc = L16toGry;
 1695|      6|                    break;
 1696|      5|                default:
  ------------------
  |  Branch (1696:17): [True: 5, False: 15]
  ------------------
 1697|      5|                    break;
 1698|     20|            }
 1699|     20|            return (1);
 1700|      0|        default:
  ------------------
  |  Branch (1700:9): [True: 0, False: 89]
  ------------------
 1701|      0|            TIFFErrorExtR(tif, module,
 1702|      0|                          "Inappropriate photometric interpretation %" PRIu16
 1703|      0|                          " for SGILog compression; %s",
 1704|      0|                          td->td_photometric, "must be either LogLUV or LogL");
 1705|      0|            break;
 1706|     89|    }
 1707|     33|    return (0);
 1708|     89|}
tif_luv.c:LogLuvInitState:
 1576|     58|{
 1577|     58|    static const char module[] = "LogLuvInitState";
 1578|     58|    TIFFDirectory *td = &tif->tif_dir;
 1579|     58|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     58|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1580|       |
 1581|     58|    assert(sp != NULL);
  ------------------
  |  Branch (1581:5): [True: 0, False: 58]
  |  Branch (1581:5): [True: 58, False: 0]
  ------------------
 1582|     58|    assert(td->td_photometric == PHOTOMETRIC_LOGLUV);
  ------------------
  |  Branch (1582:5): [True: 0, False: 58]
  |  Branch (1582:5): [True: 58, False: 0]
  ------------------
 1583|       |
 1584|       |    /* for some reason, we can't do this in TIFFInitLogLuv */
 1585|     58|    if (td->td_planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|     58|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1585:9): [True: 6, False: 52]
  ------------------
 1586|      6|    {
 1587|      6|        TIFFErrorExtR(tif, module,
 1588|      6|                      "SGILog compression cannot handle non-contiguous data");
 1589|      6|        return (0);
 1590|      6|    }
 1591|     52|    if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
  ------------------
  |  |  178|     52|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (1591:9): [True: 37, False: 15]
  ------------------
 1592|     37|        sp->user_datafmt = LogLuvGuessDataFmt(td);
 1593|     52|    switch (sp->user_datafmt)
 1594|     52|    {
 1595|      6|        case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      6|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1595:9): [True: 6, False: 46]
  ------------------
 1596|      6|            sp->pixel_size = 3 * sizeof(float);
 1597|      6|            break;
 1598|      0|        case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1598:9): [True: 0, False: 52]
  ------------------
 1599|      0|            sp->pixel_size = 3 * sizeof(int16_t);
 1600|      0|            break;
 1601|      4|        case SGILOGDATAFMT_RAW:
  ------------------
  |  |  746|      4|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1601:9): [True: 4, False: 48]
  ------------------
 1602|      4|            sp->pixel_size = sizeof(uint32_t);
 1603|      4|            break;
 1604|     26|        case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|     26|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1604:9): [True: 26, False: 26]
  ------------------
 1605|     26|            sp->pixel_size = 3 * sizeof(uint8_t);
 1606|     26|            break;
 1607|     16|        default:
  ------------------
  |  Branch (1607:9): [True: 16, False: 36]
  ------------------
 1608|     16|            TIFFErrorExtR(
 1609|     16|                tif, module,
 1610|     16|                "No support for converting user data format to LogLuv");
 1611|     16|            return (0);
 1612|     52|    }
 1613|     36|    if (isTiled(tif))
  ------------------
  |  |  278|     36|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     36|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 5, False: 31]
  |  |  ------------------
  ------------------
 1614|      5|        sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
 1615|     31|    else if (td->td_rowsperstrip < td->td_imagelength)
  ------------------
  |  Branch (1615:14): [True: 12, False: 19]
  ------------------
 1616|     12|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
 1617|     19|    else
 1618|     19|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
 1619|     36|    if (multiply_ms(sp->tbuflen, sizeof(uint32_t)) == 0 ||
  ------------------
  |  Branch (1619:9): [True: 0, False: 36]
  ------------------
 1620|     36|        (sp->tbuf = (uint8_t *)_TIFFmallocExt(
  ------------------
  |  Branch (1620:9): [True: 0, False: 36]
  ------------------
 1621|     36|             tif, (tmsize_t)((size_t)sp->tbuflen * sizeof(uint32_t)))) == NULL)
 1622|      0|    {
 1623|      0|        TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
 1624|      0|        return (0);
 1625|      0|    }
 1626|     36|    return (1);
 1627|     36|}
tif_luv.c:LogLuvGuessDataFmt:
 1523|     37|{
 1524|     37|    int guess;
 1525|       |
 1526|       |    /*
 1527|       |     * If the user didn't tell us their datafmt,
 1528|       |     * take our best guess from the bitspersample.
 1529|       |     */
 1530|     37|#define PACK(a, b) (((a) << 3) | (b))
 1531|     37|    switch (PACK(td->td_bitspersample, td->td_sampleformat))
  ------------------
  |  | 1530|     37|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
 1532|     37|    {
 1533|      6|        case PACK(32, SAMPLEFORMAT_IEEEFP):
  ------------------
  |  | 1530|      6|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1533:9): [True: 6, False: 31]
  ------------------
 1534|      6|            guess = SGILOGDATAFMT_FLOAT;
  ------------------
  |  |  744|      6|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
 1535|      6|            break;
 1536|      1|        case PACK(32, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1530|      1|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1536:9): [True: 1, False: 36]
  ------------------
 1537|      4|        case PACK(32, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|      4|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1537:9): [True: 3, False: 34]
  ------------------
 1538|      4|        case PACK(32, SAMPLEFORMAT_INT):
  ------------------
  |  | 1530|      4|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1538:9): [True: 0, False: 37]
  ------------------
 1539|      4|            guess = SGILOGDATAFMT_RAW;
  ------------------
  |  |  746|      4|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
 1540|      4|            break;
 1541|      0|        case PACK(16, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1541:9): [True: 0, False: 37]
  ------------------
 1542|      0|        case PACK(16, SAMPLEFORMAT_INT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1542:9): [True: 0, False: 37]
  ------------------
 1543|      0|        case PACK(16, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1543:9): [True: 0, False: 37]
  ------------------
 1544|      0|            guess = SGILOGDATAFMT_16BIT;
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
 1545|      0|            break;
 1546|      0|        case PACK(8, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1546:9): [True: 0, False: 37]
  ------------------
 1547|     11|        case PACK(8, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|     11|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1547:9): [True: 11, False: 26]
  ------------------
 1548|     11|            guess = SGILOGDATAFMT_8BIT;
  ------------------
  |  |  747|     11|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
 1549|     11|            break;
 1550|     16|        default:
  ------------------
  |  Branch (1550:9): [True: 16, False: 21]
  ------------------
 1551|     16|            guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|     16|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1552|     16|            break;
 1553|     37|#undef PACK
 1554|     37|    }
 1555|       |    /*
 1556|       |     * Double-check samples per pixel.
 1557|       |     */
 1558|     37|    switch (td->td_samplesperpixel)
 1559|     37|    {
 1560|     11|        case 1:
  ------------------
  |  Branch (1560:9): [True: 11, False: 26]
  ------------------
 1561|     11|            if (guess != SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|     11|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1561:17): [True: 7, False: 4]
  ------------------
 1562|      7|                guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      7|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1563|     11|            break;
 1564|     26|        case 3:
  ------------------
  |  Branch (1564:9): [True: 26, False: 11]
  ------------------
 1565|     26|            if (guess == SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|     26|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1565:17): [True: 0, False: 26]
  ------------------
 1566|      0|                guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      0|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1567|     26|            break;
 1568|      0|        default:
  ------------------
  |  Branch (1568:9): [True: 0, False: 37]
  ------------------
 1569|      0|            guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      0|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1570|      0|            break;
 1571|     37|    }
 1572|     37|    return (guess);
 1573|     37|}
tif_luv.c:multiply_ms:
 1466|    112|{
 1467|    112|    return _TIFFMultiplySSize(NULL, m1, m2, NULL);
 1468|    112|}
tif_luv.c:LogLuvDecode24:
  265|     91|{
  266|     91|    static const char module[] = "LogLuvDecode24";
  267|     91|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     91|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
  268|     91|    tmsize_t cc;
  269|     91|    tmsize_t i;
  270|     91|    tmsize_t npixels;
  271|     91|    unsigned char *bp;
  272|     91|    uint32_t *tp;
  273|       |
  274|     91|    (void)s;
  275|     91|    assert(s == 0);
  ------------------
  |  Branch (275:5): [True: 0, False: 91]
  |  Branch (275:5): [True: 91, False: 0]
  ------------------
  276|     91|    assert(sp != NULL);
  ------------------
  |  Branch (276:5): [True: 0, False: 91]
  |  Branch (276:5): [True: 91, False: 0]
  ------------------
  277|       |
  278|     91|    npixels = occ / sp->pixel_size;
  279|       |
  280|     91|    if (sp->tbuflen < npixels)
  ------------------
  |  Branch (280:9): [True: 0, False: 91]
  ------------------
  281|      0|    {
  282|      0|        TIFFErrorExtR(tif, module, "Translation buffer too short");
  283|      0|        return (0);
  284|      0|    }
  285|     91|    tp = (uint32_t *)sp->tbuf;
  286|       |    /* copy to array of uint32_t */
  287|     91|    bp = (unsigned char *)tif->tif_rawcp;
  288|     91|    cc = tif->tif_rawcc;
  289|  1.83k|    for (i = 0; i < npixels && cc >= 3; i++)
  ------------------
  |  Branch (289:17): [True: 1.76k, False: 67]
  |  Branch (289:32): [True: 1.74k, False: 24]
  ------------------
  290|  1.74k|    {
  291|  1.74k|        tp[i] = (uint32_t)bp[0] << 16 | (uint32_t)bp[1] << 8 | bp[2];
  292|  1.74k|        bp += 3;
  293|  1.74k|        cc -= 3;
  294|  1.74k|    }
  295|     91|    tif->tif_rawcp = (uint8_t *)bp;
  296|     91|    tif->tif_rawcc = cc;
  297|     91|    if (i != npixels)
  ------------------
  |  Branch (297:9): [True: 24, False: 67]
  ------------------
  298|     24|    {
  299|     24|        TIFFErrorExtR(tif, module,
  300|     24|                      "Not enough data at row %" PRIu32
  301|     24|                      " (short %" TIFF_SSIZE_FORMAT " pixels)",
  302|     24|                      tif->tif_dir.td_row, npixels - i);
  303|     24|        return (0);
  304|     24|    }
  305|     67|    if (sp->user_datafmt == SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|     67|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (305:9): [True: 15, False: 52]
  ------------------
  306|     15|        LuvRawToRaw(sp, op, npixels);
  307|     52|    else
  308|     52|        (*sp->tfunc)(sp, op, npixels);
  309|     67|    return (1);
  310|     91|}
tif_luv.c:LuvRawToRaw:
  883|     63|{
  884|     63|    uint32_t *luv = (uint32_t *)sp->tbuf;
  885|       |
  886|  12.2k|    while (n-- > 0)
  ------------------
  |  Branch (886:12): [True: 12.2k, False: 63]
  ------------------
  887|  12.2k|    {
  888|  12.2k|        LogLuvStore32NativeUnaligned(op, *luv++);
  889|  12.2k|        op += sizeof(uint32_t);
  890|  12.2k|    }
  891|     63|}
tif_luv.c:LogLuvStore32NativeUnaligned:
  856|  12.2k|{
  857|  12.2k|    memcpy(cp, &v, sizeof(v));
  858|  12.2k|}
tif_luv.c:Luv24toXYZ:
 1169|      9|{
 1170|      9|    uint32_t *luv = (uint32_t *)sp->tbuf;
 1171|       |
 1172|    349|    while (n-- > 0)
  ------------------
  |  Branch (1172:12): [True: 340, False: 9]
  ------------------
 1173|    340|    {
 1174|    340|        float xyz[3];
 1175|    340|        LogLuv24toXYZ(*luv, xyz);
 1176|    340|        LogLuvStoreFloatNativeUnaligned(op, xyz[0]);
 1177|    340|        LogLuvStoreFloatNativeUnaligned(op + sizeof(float), xyz[1]);
 1178|    340|        LogLuvStoreFloatNativeUnaligned(op + 2 * sizeof(float), xyz[2]);
 1179|    340|        op += 3 * sizeof(float);
 1180|    340|        luv++;
 1181|    340|    }
 1182|      9|}
tif_luv.c:LogLuvStoreFloatNativeUnaligned:
  832|  7.64k|{
  833|  7.64k|    memcpy(cp, &v, sizeof(v));
  834|  7.64k|}
tif_luv.c:LogLuvStore16NativeUnaligned:
  844|    320|{
  845|    320|    memcpy(cp, &v, sizeof(v));
  846|    320|}
tif_luv.c:Luv24toRGB:
 1212|     43|{
 1213|     43|    uint32_t *luv = (uint32_t *)sp->tbuf;
 1214|     43|    uint8_t *rgb = (uint8_t *)op;
 1215|       |
 1216|  1.16k|    while (n-- > 0)
  ------------------
  |  Branch (1216:12): [True: 1.11k, False: 43]
  ------------------
 1217|  1.11k|    {
 1218|  1.11k|        float xyz[3];
 1219|       |
 1220|  1.11k|        LogLuv24toXYZ(*luv++, xyz);
 1221|  1.11k|        XYZtoRGB24(xyz, rgb);
 1222|  1.11k|        rgb += 3;
 1223|  1.11k|    }
 1224|     43|}
tif_luv.c:LogLuvDecode32:
  316|  1.70k|{
  317|  1.70k|    static const char module[] = "LogLuvDecode32";
  318|  1.70k|    LogLuvState *sp;
  319|  1.70k|    int shft;
  320|  1.70k|    tmsize_t i;
  321|  1.70k|    tmsize_t npixels;
  322|  1.70k|    unsigned char *bp;
  323|  1.70k|    uint32_t *tp;
  324|  1.70k|    uint32_t b;
  325|  1.70k|    tmsize_t cc;
  326|  1.70k|    int rc;
  327|       |
  328|  1.70k|    (void)s;
  329|  1.70k|    assert(s == 0);
  ------------------
  |  Branch (329:5): [True: 0, False: 1.70k]
  |  Branch (329:5): [True: 1.70k, False: 0]
  ------------------
  330|  1.70k|    sp = DecoderState(tif);
  ------------------
  |  |  175|  1.70k|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
  331|  1.70k|    assert(sp != NULL);
  ------------------
  |  Branch (331:5): [True: 0, False: 1.70k]
  |  Branch (331:5): [True: 1.70k, False: 0]
  ------------------
  332|       |
  333|  1.70k|    npixels = occ / sp->pixel_size;
  334|       |
  335|  1.70k|    if (sp->tbuflen < npixels)
  ------------------
  |  Branch (335:9): [True: 0, False: 1.70k]
  ------------------
  336|      0|    {
  337|      0|        TIFFErrorExtR(tif, module, "Translation buffer too short");
  338|      0|        return (0);
  339|      0|    }
  340|  1.70k|    tp = (uint32_t *)sp->tbuf;
  341|  1.70k|    _TIFFmemset((void *)tp, 0, (tmsize_t)((size_t)npixels * sizeof(tp[0])));
  342|       |
  343|  1.70k|    bp = (unsigned char *)tif->tif_rawcp;
  344|  1.70k|    cc = tif->tif_rawcc;
  345|       |    /* get each byte string */
  346|  3.61k|    for (shft = 24; shft >= 0; shft -= 8)
  ------------------
  |  Branch (346:21): [True: 3.30k, False: 311]
  ------------------
  347|  3.30k|    {
  348|  14.7k|        for (i = 0; i < npixels && cc > 0;)
  ------------------
  |  Branch (348:21): [True: 12.8k, False: 1.91k]
  |  Branch (348:36): [True: 11.6k, False: 1.22k]
  ------------------
  349|  11.6k|        {
  350|  11.6k|            if (*bp >= 128)
  ------------------
  |  Branch (350:17): [True: 3.25k, False: 8.36k]
  ------------------
  351|  3.25k|            { /* run */
  352|  3.25k|                if (cc < 2)
  ------------------
  |  Branch (352:21): [True: 172, False: 3.08k]
  ------------------
  353|    172|                    break;
  354|  3.08k|                rc = *bp++ + (2 - 128);
  355|  3.08k|                b = (uint32_t)*bp++ << shft;
  356|  3.08k|                cc -= 2;
  357|   217k|                while (rc-- && i < npixels)
  ------------------
  |  Branch (357:24): [True: 216k, False: 1.45k]
  |  Branch (357:32): [True: 214k, False: 1.62k]
  ------------------
  358|   214k|                    tp[i++] |= b;
  359|  3.08k|            }
  360|  8.36k|            else
  361|  8.36k|            {               /* non-run */
  362|  8.36k|                rc = *bp++; /* nul is noop */
  363|   107k|                while (--cc && rc-- && i < npixels)
  ------------------
  |  Branch (363:24): [True: 106k, False: 1.06k]
  |  Branch (363:32): [True: 99.8k, False: 7.03k]
  |  Branch (363:40): [True: 99.6k, False: 266]
  ------------------
  364|  99.6k|                    tp[i++] |= (uint32_t)*bp++ << shft;
  365|  8.36k|            }
  366|  11.6k|        }
  367|  3.30k|        if (i != npixels)
  ------------------
  |  Branch (367:13): [True: 1.39k, False: 1.91k]
  ------------------
  368|  1.39k|        {
  369|  1.39k|            TIFFErrorExtR(tif, module,
  370|  1.39k|                          "Not enough data at row %" PRIu32
  371|  1.39k|                          " (short %" TIFF_SSIZE_FORMAT " pixels)",
  372|  1.39k|                          tif->tif_dir.td_row, npixels - i);
  373|  1.39k|            tif->tif_rawcp = (uint8_t *)bp;
  374|  1.39k|            tif->tif_rawcc = cc;
  375|  1.39k|            return (0);
  376|  1.39k|        }
  377|  3.30k|    }
  378|    311|    if (sp->user_datafmt == SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|    311|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (378:9): [True: 48, False: 263]
  ------------------
  379|     48|        LuvRawToRaw(sp, op, npixels);
  380|    263|    else
  381|    263|        (*sp->tfunc)(sp, op, npixels);
  382|    311|    tif->tif_rawcp = (uint8_t *)bp;
  383|    311|    tif->tif_rawcc = cc;
  384|    311|    return (1);
  385|  1.70k|}
tif_luv.c:Luv32toXYZ:
 1333|     60|{
 1334|     60|    uint32_t *luv = (uint32_t *)sp->tbuf;
 1335|       |
 1336|  1.98k|    while (n-- > 0)
  ------------------
  |  Branch (1336:12): [True: 1.92k, False: 60]
  ------------------
 1337|  1.92k|    {
 1338|  1.92k|        float xyz[3];
 1339|  1.92k|        LogLuv32toXYZ(*luv++, xyz);
 1340|  1.92k|        LogLuvStoreFloatNativeUnaligned(op, xyz[0]);
 1341|  1.92k|        LogLuvStoreFloatNativeUnaligned(op + sizeof(float), xyz[1]);
 1342|  1.92k|        LogLuvStoreFloatNativeUnaligned(op + 2 * sizeof(float), xyz[2]);
 1343|  1.92k|        op += 3 * sizeof(float);
 1344|  1.92k|    }
 1345|     60|}
tif_luv.c:Luv32toRGB:
 1371|    203|{
 1372|    203|    uint32_t *luv = (uint32_t *)sp->tbuf;
 1373|    203|    uint8_t *rgb = (uint8_t *)op;
 1374|       |
 1375|  6.69k|    while (n-- > 0)
  ------------------
  |  Branch (1375:12): [True: 6.49k, False: 203]
  ------------------
 1376|  6.49k|    {
 1377|  6.49k|        float xyz[3];
 1378|       |
 1379|  6.49k|        LogLuv32toXYZ(*luv++, xyz);
 1380|  6.49k|        XYZtoRGB24(xyz, rgb);
 1381|  6.49k|        rgb += 3;
 1382|  6.49k|    }
 1383|    203|}
tif_luv.c:LogL16InitState:
 1471|     31|{
 1472|     31|    static const char module[] = "LogL16InitState";
 1473|     31|    TIFFDirectory *td = &tif->tif_dir;
 1474|     31|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     31|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1475|       |
 1476|     31|    assert(sp != NULL);
  ------------------
  |  Branch (1476:5): [True: 0, False: 31]
  |  Branch (1476:5): [True: 31, False: 0]
  ------------------
 1477|     31|    assert(td->td_photometric == PHOTOMETRIC_LOGL);
  ------------------
  |  Branch (1477:5): [True: 0, False: 31]
  |  Branch (1477:5): [True: 31, False: 0]
  ------------------
 1478|       |
 1479|     31|    if (td->td_samplesperpixel != 1)
  ------------------
  |  Branch (1479:9): [True: 8, False: 23]
  ------------------
 1480|      8|    {
 1481|      8|        TIFFErrorExtR(tif, module,
 1482|      8|                      "Sorry, can not handle LogL image with %s=%" PRIu16,
 1483|      8|                      "Samples/pixel", td->td_samplesperpixel);
 1484|      8|        return 0;
 1485|      8|    }
 1486|       |
 1487|       |    /* for some reason, we can't do this in TIFFInitLogL16 */
 1488|     23|    if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
  ------------------
  |  |  178|     23|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (1488:9): [True: 20, False: 3]
  ------------------
 1489|     20|        sp->user_datafmt = LogL16GuessDataFmt(td);
 1490|     23|    switch (sp->user_datafmt)
 1491|     23|    {
 1492|      9|        case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      9|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1492:9): [True: 9, False: 14]
  ------------------
 1493|      9|            sp->pixel_size = sizeof(float);
 1494|      9|            break;
 1495|      5|        case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      5|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1495:9): [True: 5, False: 18]
  ------------------
 1496|      5|            sp->pixel_size = sizeof(int16_t);
 1497|      5|            break;
 1498|      6|        case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      6|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1498:9): [True: 6, False: 17]
  ------------------
 1499|      6|            sp->pixel_size = sizeof(uint8_t);
 1500|      6|            break;
 1501|      3|        default:
  ------------------
  |  Branch (1501:9): [True: 3, False: 20]
  ------------------
 1502|      3|            TIFFErrorExtR(tif, module,
 1503|      3|                          "No support for converting user data format to LogL");
 1504|      3|            return (0);
 1505|     23|    }
 1506|     20|    if (isTiled(tif))
  ------------------
  |  |  278|     20|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     20|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 2, False: 18]
  |  |  ------------------
  ------------------
 1507|      2|        sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
 1508|     18|    else if (td->td_rowsperstrip < td->td_imagelength)
  ------------------
  |  Branch (1508:14): [True: 9, False: 9]
  ------------------
 1509|      9|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
 1510|      9|    else
 1511|      9|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
 1512|     20|    if (multiply_ms(sp->tbuflen, sizeof(int16_t)) == 0 ||
  ------------------
  |  Branch (1512:9): [True: 0, False: 20]
  ------------------
 1513|     20|        (sp->tbuf = (uint8_t *)_TIFFmallocExt(
  ------------------
  |  Branch (1513:9): [True: 0, False: 20]
  ------------------
 1514|     20|             tif, (tmsize_t)((size_t)sp->tbuflen * sizeof(int16_t)))) == NULL)
 1515|      0|    {
 1516|      0|        TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
 1517|      0|        return (0);
 1518|      0|    }
 1519|     20|    return (1);
 1520|     20|}
tif_luv.c:LogL16GuessDataFmt:
 1444|     20|{
 1445|     20|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
 1446|     20|    switch (
 1447|     20|        PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat))
  ------------------
  |  | 1445|     20|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
 1448|     20|    {
 1449|      9|        case PACK(1, 32, SAMPLEFORMAT_IEEEFP):
  ------------------
  |  | 1445|      9|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1449:9): [True: 9, False: 11]
  ------------------
 1450|      9|            return (SGILOGDATAFMT_FLOAT);
  ------------------
  |  |  744|      9|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
 1451|      0|        case PACK(1, 16, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1445|      0|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1451:9): [True: 0, False: 20]
  ------------------
 1452|      2|        case PACK(1, 16, SAMPLEFORMAT_INT):
  ------------------
  |  | 1445|      2|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1452:9): [True: 2, False: 18]
  ------------------
 1453|      5|        case PACK(1, 16, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1445|      5|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1453:9): [True: 3, False: 17]
  ------------------
 1454|      5|            return (SGILOGDATAFMT_16BIT);
  ------------------
  |  |  745|      5|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
 1455|      0|        case PACK(1, 8, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1445|      0|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1455:9): [True: 0, False: 20]
  ------------------
 1456|      3|        case PACK(1, 8, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1445|      3|#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
  ------------------
  |  Branch (1456:9): [True: 3, False: 17]
  ------------------
 1457|      3|            return (SGILOGDATAFMT_8BIT);
  ------------------
  |  |  747|      3|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
 1458|      3|        default:
  ------------------
  |  Branch (1458:9): [True: 3, False: 17]
  ------------------
 1459|      3|            break;
 1460|     20|    }
 1461|      3|#undef PACK
 1462|      3|    return (SGILOGDATAFMT_UNKNOWN);
  ------------------
  |  |  178|      3|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1463|     20|}
tif_luv.c:LogL16Decode:
  191|     74|{
  192|     74|    static const char module[] = "LogL16Decode";
  193|     74|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     74|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
  194|     74|    int shft;
  195|     74|    tmsize_t i;
  196|     74|    tmsize_t npixels;
  197|     74|    unsigned char *bp;
  198|     74|    int16_t *tp;
  199|     74|    int16_t b;
  200|     74|    tmsize_t cc;
  201|     74|    int rc;
  202|       |
  203|     74|    (void)s;
  204|     74|    assert(s == 0);
  ------------------
  |  Branch (204:5): [True: 0, False: 74]
  |  Branch (204:5): [True: 74, False: 0]
  ------------------
  205|     74|    assert(sp != NULL);
  ------------------
  |  Branch (205:5): [True: 0, False: 74]
  |  Branch (205:5): [True: 74, False: 0]
  ------------------
  206|       |
  207|     74|    npixels = occ / sp->pixel_size;
  208|       |
  209|     74|    if (sp->tbuflen < npixels)
  ------------------
  |  Branch (209:9): [True: 0, False: 74]
  ------------------
  210|      0|    {
  211|      0|        TIFFErrorExtR(tif, module, "Translation buffer too short");
  212|      0|        return (0);
  213|      0|    }
  214|     74|    tp = (int16_t *)sp->tbuf;
  215|     74|    _TIFFmemset((void *)tp, 0, (tmsize_t)((size_t)npixels * sizeof(tp[0])));
  216|       |
  217|     74|    bp = (unsigned char *)tif->tif_rawcp;
  218|     74|    cc = tif->tif_rawcc;
  219|       |    /* get each byte string */
  220|    206|    for (shft = 8; shft >= 0; shft -= 8)
  ------------------
  |  Branch (220:20): [True: 145, False: 61]
  ------------------
  221|    145|    {
  222|    521|        for (i = 0; i < npixels && cc > 0;)
  ------------------
  |  Branch (222:21): [True: 389, False: 132]
  |  Branch (222:36): [True: 376, False: 13]
  ------------------
  223|    376|        {
  224|    376|            if (*bp >= 128)
  ------------------
  |  Branch (224:17): [True: 66, False: 310]
  ------------------
  225|     66|            { /* run */
  226|     66|                if (cc < 2)
  ------------------
  |  Branch (226:21): [True: 0, False: 66]
  ------------------
  227|      0|                    break;
  228|     66|                rc = *bp++ + (2 - 128);
  229|     66|                b = (int16_t)(*bp++ << shft);
  230|     66|                cc -= 2;
  231|  1.70k|                while (rc-- && i < npixels)
  ------------------
  |  Branch (231:24): [True: 1.70k, False: 0]
  |  Branch (231:32): [True: 1.64k, False: 66]
  ------------------
  232|  1.64k|                    tp[i++] |= b;
  233|     66|            }
  234|    310|            else
  235|    310|            {               /* non-run */
  236|    310|                rc = *bp++; /* nul is noop */
  237|  2.27k|                while (--cc && rc-- && i < npixels)
  ------------------
  |  Branch (237:24): [True: 2.26k, False: 10]
  |  Branch (237:32): [True: 2.02k, False: 239]
  |  Branch (237:40): [True: 1.96k, False: 61]
  ------------------
  238|  1.96k|                    tp[i++] |= (int16_t)(*bp++ << shft);
  239|    310|            }
  240|    376|        }
  241|    145|        if (i != npixels)
  ------------------
  |  Branch (241:13): [True: 13, False: 132]
  ------------------
  242|     13|        {
  243|     13|            TIFFErrorExtR(tif, module,
  244|     13|                          "Not enough data at row %" PRIu32
  245|     13|                          " (short %" TIFF_SSIZE_FORMAT " pixels)",
  246|     13|                          tif->tif_dir.td_row, npixels - i);
  247|     13|            tif->tif_rawcp = (uint8_t *)bp;
  248|     13|            tif->tif_rawcc = cc;
  249|     13|            return (0);
  250|     13|        }
  251|    145|    }
  252|     61|    if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
  ------------------
  |  |  745|     61|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (252:9): [True: 10, False: 51]
  ------------------
  253|     10|        L16toL16(sp, op, npixels);
  254|     51|    else
  255|     51|        (*sp->tfunc)(sp, op, npixels);
  256|     61|    tif->tif_rawcp = (uint8_t *)bp;
  257|     61|    tif->tif_rawcc = cc;
  258|     61|    return (1);
  259|     74|}
tif_luv.c:L16toL16:
  861|     10|{
  862|     10|    int16_t *l16 = (int16_t *)sp->tbuf;
  863|       |
  864|    330|    while (n-- > 0)
  ------------------
  |  Branch (864:12): [True: 320, False: 10]
  ------------------
  865|    320|    {
  866|    320|        LogLuvStore16NativeUnaligned(op, *l16++);
  867|    320|        op += sizeof(int16_t);
  868|    320|    }
  869|     10|}
tif_luv.c:L16toY:
  905|     27|{
  906|     27|    int16_t *l16 = (int16_t *)sp->tbuf;
  907|       |
  908|    891|    while (n-- > 0)
  ------------------
  |  Branch (908:12): [True: 864, False: 27]
  ------------------
  909|    864|    {
  910|    864|        LogLuvStoreFloatNativeUnaligned(op, (float)LogL16toY(*l16++));
  911|    864|        op += sizeof(float);
  912|    864|    }
  913|     27|}
tif_luv.c:L16toGry:
  916|      9|{
  917|      9|    int16_t *l16 = (int16_t *)sp->tbuf;
  918|      9|    uint8_t *gp = (uint8_t *)op;
  919|       |
  920|    235|    while (n-- > 0)
  ------------------
  |  Branch (920:12): [True: 226, False: 9]
  ------------------
  921|    226|    {
  922|    226|        double Y = LogL16toY(*l16++);
  923|    226|        *gp++ = (uint8_t)((Y <= 0.)   ? 0
  ------------------
  |  Branch (923:27): [True: 226, False: 0]
  ------------------
  924|    226|                          : (Y >= 1.) ? 255
  ------------------
  |  Branch (924:29): [True: 0, False: 0]
  ------------------
  925|      0|                                      : (int)(256. * sqrt(Y)));
  926|    226|    }
  927|      9|}
tif_luv.c:LogLuvDecodeStrip:
  393|  1.44k|{
  394|  1.44k|    tmsize_t rowlen = TIFFScanlineSize(tif);
  395|       |
  396|  1.44k|    if (rowlen == 0)
  ------------------
  |  Branch (396:9): [True: 0, False: 1.44k]
  ------------------
  397|      0|        return 0;
  398|       |
  399|  1.44k|    assert(cc % rowlen == 0);
  ------------------
  |  Branch (399:5): [True: 0, False: 1.44k]
  |  Branch (399:5): [True: 1.44k, False: 0]
  ------------------
  400|  1.85k|    while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
  ------------------
  |  Branch (400:12): [True: 1.83k, False: 25]
  |  Branch (400:18): [True: 412, False: 1.42k]
  ------------------
  401|    412|    {
  402|    412|        bp += rowlen;
  403|    412|        cc -= rowlen;
  404|    412|    }
  405|  1.44k|    return (cc == 0);
  406|  1.44k|}
tif_luv.c:LogLuvDecodeTile:
  414|      7|{
  415|      7|    tmsize_t rowlen = TIFFTileRowSize(tif);
  416|       |
  417|      7|    if (rowlen == 0)
  ------------------
  |  Branch (417:9): [True: 0, False: 7]
  ------------------
  418|      0|        return 0;
  419|       |
  420|      7|    assert(cc % rowlen == 0);
  ------------------
  |  Branch (420:5): [True: 0, False: 7]
  |  Branch (420:5): [True: 7, False: 0]
  ------------------
  421|     34|    while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
  ------------------
  |  Branch (421:12): [True: 34, False: 0]
  |  Branch (421:18): [True: 27, False: 7]
  ------------------
  422|     27|    {
  423|     27|        bp += rowlen;
  424|     27|        cc -= rowlen;
  425|     27|    }
  426|      7|    return (cc == 0);
  427|      7|}
tif_luv.c:LogLuvCleanup:
 1813|     85|{
 1814|     85|    LogLuvState *sp = (LogLuvState *)tif->tif_data;
 1815|       |
 1816|     85|    assert(sp != 0);
  ------------------
  |  Branch (1816:5): [True: 0, False: 85]
  |  Branch (1816:5): [True: 85, False: 0]
  ------------------
 1817|       |
 1818|     85|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1819|     85|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1820|       |
 1821|     85|    if (sp->tbuf)
  ------------------
  |  Branch (1821:9): [True: 56, False: 29]
  ------------------
 1822|     56|        _TIFFfreeExt(tif, sp->tbuf);
 1823|     85|    _TIFFfreeExt(tif, sp);
 1824|     85|    tif->tif_data = NULL;
 1825|       |
 1826|     85|    _TIFFSetDefaultCompressionState(tif);
 1827|     85|}
tif_luv.c:LogLuvVGetField:
 1897|    644|{
 1898|    644|    LogLuvState *sp = (LogLuvState *)tif->tif_data;
 1899|       |
 1900|    644|    switch (tag)
 1901|    644|    {
 1902|      0|        case TIFFTAG_SGILOGDATAFMT:
  ------------------
  |  |  743|      0|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
  |  Branch (1902:9): [True: 0, False: 644]
  ------------------
 1903|      0|            *va_arg(ap, int *) = sp->user_datafmt;
 1904|      0|            return (1);
 1905|    644|        default:
  ------------------
  |  Branch (1905:9): [True: 644, False: 0]
  ------------------
 1906|    644|            return (*sp->vgetparent)(tif, tag, ap);
 1907|    644|    }
 1908|    644|}
tif_luv.c:LogLuvVSetField:
 1830|  1.21k|{
 1831|  1.21k|    static const char module[] = "LogLuvVSetField";
 1832|  1.21k|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|  1.21k|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1833|  1.21k|    int bps, fmt;
 1834|       |
 1835|  1.21k|    switch (tag)
 1836|  1.21k|    {
 1837|     37|        case TIFFTAG_SGILOGDATAFMT:
  ------------------
  |  |  743|     37|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
  |  Branch (1837:9): [True: 37, False: 1.17k]
  ------------------
 1838|     37|            sp->user_datafmt = (int)va_arg(ap, int);
 1839|       |            /*
 1840|       |             * Tweak the TIFF header so that the rest of libtiff knows what
 1841|       |             * size of data will be passed between app and library, and
 1842|       |             * assume that the app knows what it is doing and is not
 1843|       |             * confused by these header manipulations...
 1844|       |             */
 1845|     37|            switch (sp->user_datafmt)
 1846|     37|            {
 1847|      0|                case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1847:17): [True: 0, False: 37]
  ------------------
 1848|      0|                    bps = 32;
 1849|      0|                    fmt = SAMPLEFORMAT_IEEEFP;
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
 1850|      0|                    break;
 1851|      0|                case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1851:17): [True: 0, False: 37]
  ------------------
 1852|      0|                    bps = 16;
 1853|      0|                    fmt = SAMPLEFORMAT_INT;
  ------------------
  |  |  335|      0|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
 1854|      0|                    break;
 1855|      0|                case SGILOGDATAFMT_RAW:
  ------------------
  |  |  746|      0|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1855:17): [True: 0, False: 37]
  ------------------
 1856|      0|                    bps = 32;
 1857|      0|                    fmt = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1858|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
  ------------------
  |  |  257|      0|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
 1859|      0|                    break;
 1860|     37|                case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|     37|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1860:17): [True: 37, False: 0]
  ------------------
 1861|     37|                    bps = 8;
 1862|     37|                    fmt = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|     37|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1863|     37|                    break;
 1864|      0|                default:
  ------------------
  |  Branch (1864:17): [True: 0, False: 37]
  ------------------
 1865|      0|                    TIFFErrorExtR(
 1866|      0|                        tif, tif->tif_name,
 1867|      0|                        "Unknown data format %d for LogLuv compression",
 1868|      0|                        sp->user_datafmt);
 1869|      0|                    return (0);
 1870|     37|            }
 1871|     37|            TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
  ------------------
  |  |  180|     37|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1872|     37|            TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt);
  ------------------
  |  |  333|     37|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
 1873|       |            /*
 1874|       |             * Must recalculate sizes should bits/sample change.
 1875|       |             */
 1876|     37|            tif->tif_dir.td_tilesize =
 1877|     37|                isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)-1;
  ------------------
  |  |  278|     37|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     37|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 9, False: 28]
  |  |  ------------------
  ------------------
 1878|     37|            tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 1879|     37|            return (1);
 1880|      0|        case TIFFTAG_SGILOGENCODE:
  ------------------
  |  |  748|      0|#define TIFFTAG_SGILOGENCODE 65561     /* SGILog data encoding control*/
  ------------------
  |  Branch (1880:9): [True: 0, False: 1.21k]
  ------------------
 1881|      0|            sp->encode_meth = (int)va_arg(ap, int);
 1882|      0|            if (sp->encode_meth != SGILOGENCODE_NODITHER &&
  ------------------
  |  |  749|      0|#define SGILOGENCODE_NODITHER 0        /* do not dither encoded values*/
  ------------------
  |  Branch (1882:17): [True: 0, False: 0]
  ------------------
 1883|      0|                sp->encode_meth != SGILOGENCODE_RANDITHER)
  ------------------
  |  |  750|      0|#define SGILOGENCODE_RANDITHER 1       /* randomly dither encd values */
  ------------------
  |  Branch (1883:17): [True: 0, False: 0]
  ------------------
 1884|      0|            {
 1885|      0|                TIFFErrorExtR(tif, module,
 1886|      0|                              "Unknown encoding %d for LogLuv compression",
 1887|      0|                              sp->encode_meth);
 1888|      0|                return (0);
 1889|      0|            }
 1890|      0|            return (1);
 1891|  1.17k|        default:
  ------------------
  |  Branch (1891:9): [True: 1.17k, False: 37]
  ------------------
 1892|  1.17k|            return (*sp->vsetparent)(tif, tag, ap);
 1893|  1.21k|    }
 1894|  1.21k|}

TIFFInitLZW:
 1411|    108|{
 1412|    108|    static const char module[] = "TIFFInitLZW";
 1413|    108|    (void)scheme;
 1414|    108|    assert(scheme == COMPRESSION_LZW);
  ------------------
  |  Branch (1414:5): [True: 0, False: 108]
  |  Branch (1414:5): [True: 108, False: 0]
  ------------------
 1415|       |    /*
 1416|       |     * Allocate state block so tag methods have storage to record values.
 1417|       |     */
 1418|    108|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState));
 1419|    108|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1419:9): [True: 0, False: 108]
  ------------------
 1420|      0|        goto bad;
 1421|    108|    LZWDecoderState(tif)->dec_codetab = NULL;
  ------------------
  |  |  164|    108|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1422|    108|    LZWDecoderState(tif)->dec_decode = NULL;
  ------------------
  |  |  164|    108|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1423|    108|    LZWEncoderState(tif)->enc_hashtab = NULL;
  ------------------
  |  |  165|    108|#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1424|    108|    LZWState(tif)->rw_mode = tif->tif_mode;
  ------------------
  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  ------------------
 1425|       |
 1426|       |    /*
 1427|       |     * Install codec methods.
 1428|       |     */
 1429|    108|    tif->tif_fixuptags = LZWFixupTags;
 1430|    108|    tif->tif_setupdecode = LZWSetupDecode;
 1431|    108|    tif->tif_predecode = LZWPreDecode;
 1432|    108|    tif->tif_decoderow = LZWDecode;
 1433|    108|    tif->tif_decodestrip = LZWDecode;
 1434|    108|    tif->tif_decodetile = LZWDecode;
 1435|    108|#ifndef LZW_READ_ONLY
 1436|    108|    tif->tif_setupencode = LZWSetupEncode;
 1437|    108|    tif->tif_preencode = LZWPreEncode;
 1438|    108|    tif->tif_postencode = LZWPostEncode;
 1439|    108|    tif->tif_encoderow = LZWEncode;
 1440|    108|    tif->tif_encodestrip = LZWEncode;
 1441|    108|    tif->tif_encodetile = LZWEncode;
 1442|    108|#endif
 1443|    108|    tif->tif_getmaxcompressionratio = LZWGetMaxCompressionRatio;
 1444|    108|    tif->tif_cleanup = LZWCleanup;
 1445|       |    /*
 1446|       |     * Setup predictor setup.
 1447|       |     */
 1448|    108|    (void)TIFFPredictorInit(tif);
 1449|    108|    return (1);
 1450|      0|bad:
 1451|      0|    TIFFErrorExtR(tif, module, "No space for LZW state block");
 1452|      0|    return (0);
 1453|    108|}
tif_lzw.c:LZWFixupTags:
  177|     91|{
  178|     91|    (void)tif;
  179|     91|    return (1);
  180|     91|}
tif_lzw.c:LZWSetupDecode:
  183|    247|{
  184|    247|    static const char module[] = "LZWSetupDecode";
  185|    247|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    247|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    247|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  186|    247|    int code;
  187|       |
  188|    247|    if (sp == NULL)
  ------------------
  |  Branch (188:9): [True: 0, False: 247]
  ------------------
  189|      0|    {
  190|       |        /*
  191|       |         * Allocate state block so tag methods have storage to record
  192|       |         * values.
  193|       |         */
  194|      0|        tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState));
  195|      0|        if (tif->tif_data == NULL)
  ------------------
  |  Branch (195:13): [True: 0, False: 0]
  ------------------
  196|      0|        {
  197|      0|            TIFFErrorExtR(tif, module, "No space for LZW state block");
  198|      0|            return (0);
  199|      0|        }
  200|       |
  201|      0|        sp = LZWDecoderState(tif);
  ------------------
  |  |  164|      0|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|      0|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  202|      0|        sp->dec_codetab = NULL;
  203|      0|        sp->dec_decode = NULL;
  204|       |
  205|       |        /*
  206|       |         * Setup predictor setup.
  207|       |         */
  208|      0|        (void)TIFFPredictorInit(tif);
  209|      0|    }
  210|       |
  211|    247|    if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (211:9): [True: 91, False: 156]
  ------------------
  212|     91|    {
  213|     91|        sp->dec_codetab = (code_t *)_TIFFmallocExt(tif, CSIZE * sizeof(code_t));
  ------------------
  |  |   79|     91|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|     91|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  214|     91|        if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (214:13): [True: 0, False: 91]
  ------------------
  215|      0|        {
  216|      0|            TIFFErrorExtR(tif, module, "No space for LZW code table");
  217|      0|            return (0);
  218|      0|        }
  219|       |        /*
  220|       |         * Pre-load the table.
  221|       |         */
  222|     91|        code = 255;
  223|     91|        do
  224|  23.2k|        {
  225|  23.2k|            sp->dec_codetab[code].firstchar = (unsigned char)code;
  226|  23.2k|            sp->dec_codetab[code].value = (unsigned char)code;
  227|  23.2k|            sp->dec_codetab[code].repeated = true;
  228|  23.2k|            sp->dec_codetab[code].length = 1;
  229|  23.2k|            sp->dec_codetab[code].next = NULL;
  230|  23.2k|        } while (code--);
  ------------------
  |  Branch (230:18): [True: 23.2k, False: 91]
  ------------------
  231|       |        /*
  232|       |         * Zero-out the unused entries  */
  233|       |        /* Silence false positive */
  234|       |        /* coverity[overrun-buffer-arg] */
  235|     91|        memset(&sp->dec_codetab[CODE_CLEAR], 0,
  ------------------
  |  |   71|     91|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  236|     91|               (CODE_FIRST - CODE_CLEAR) * sizeof(code_t));
  ------------------
  |  |   73|     91|#define CODE_FIRST 258 /* first free code entry */
  ------------------
                             (CODE_FIRST - CODE_CLEAR) * sizeof(code_t));
  ------------------
  |  |   71|     91|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  237|     91|    }
  238|    247|    return (1);
  239|    247|}
tif_lzw.c:LZWPreDecode:
  245|    314|{
  246|    314|    static const char module[] = "LZWPreDecode";
  247|    314|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    314|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    314|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  248|       |
  249|    314|    (void)s;
  250|    314|    assert(sp != NULL);
  ------------------
  |  Branch (250:5): [True: 0, False: 314]
  |  Branch (250:5): [True: 314, False: 0]
  ------------------
  251|    314|    if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (251:9): [True: 0, False: 314]
  ------------------
  252|      0|    {
  253|      0|        tif->tif_setupdecode(tif);
  254|      0|        if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (254:13): [True: 0, False: 0]
  ------------------
  255|      0|            return (0);
  256|      0|    }
  257|       |
  258|       |    /*
  259|       |     * Check for old bit-reversed codes.
  260|       |     */
  261|    314|    if (tif->tif_rawcc >= 2 && tif->tif_rawdata[0] == 0 &&
  ------------------
  |  Branch (261:9): [True: 276, False: 38]
  |  Branch (261:32): [True: 105, False: 171]
  ------------------
  262|    105|        (tif->tif_rawdata[1] & 0x1))
  ------------------
  |  Branch (262:9): [True: 78, False: 27]
  ------------------
  263|     78|    {
  264|     78|#ifdef LZW_COMPAT
  265|     78|        if (!sp->dec_decode)
  ------------------
  |  Branch (265:13): [True: 44, False: 34]
  ------------------
  266|     44|        {
  267|     44|            TIFFWarningExtR(tif, module, "Old-style LZW codes, convert file");
  268|       |            /*
  269|       |             * Override default decoding methods with
  270|       |             * ones that deal with the old coding.
  271|       |             * Otherwise the predictor versions set
  272|       |             * above will call the compatibility routines
  273|       |             * through the dec_decode method.
  274|       |             */
  275|     44|            tif->tif_decoderow = LZWDecodeCompat;
  276|     44|            tif->tif_decodestrip = LZWDecodeCompat;
  277|     44|            tif->tif_decodetile = LZWDecodeCompat;
  278|       |            /*
  279|       |             * If doing horizontal differencing, must
  280|       |             * re-setup the predictor logic since we
  281|       |             * switched the basic decoder methods...
  282|       |             */
  283|     44|            (*tif->tif_setupdecode)(tif);
  284|     44|            sp->dec_decode = LZWDecodeCompat;
  285|     44|        }
  286|     78|        sp->lzw_maxcode = MAXCODE(BITS_MIN);
  ------------------
  |  |  103|     78|#define lzw_maxcode base.maxcode
  ------------------
                      sp->lzw_maxcode = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|     78|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  287|       |#else  /* !LZW_COMPAT */
  288|       |        if (!sp->dec_decode)
  289|       |        {
  290|       |            TIFFErrorExtR(tif, module, "Old-style LZW codes not supported");
  291|       |            sp->dec_decode = LZWDecode;
  292|       |        }
  293|       |        return (0);
  294|       |#endif /* !LZW_COMPAT */
  295|     78|    }
  296|    236|    else
  297|    236|    {
  298|    236|        sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1;
  ------------------
  |  |  103|    236|#define lzw_maxcode base.maxcode
  ------------------
                      sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1;
  ------------------
  |  |   63|    236|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  299|    236|        sp->dec_decode = LZWDecode;
  300|    236|    }
  301|    314|    sp->lzw_nbits = BITS_MIN;
  ------------------
  |  |  102|    314|#define lzw_nbits base.nbits
  ------------------
                  sp->lzw_nbits = BITS_MIN;
  ------------------
  |  |   68|    314|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  302|    314|    sp->lzw_nextbits = 0;
  ------------------
  |  |  106|    314|#define lzw_nextbits base.nextbits
  ------------------
  303|    314|    sp->lzw_nextdata = 0;
  ------------------
  |  |  105|    314|#define lzw_nextdata base.nextdata
  ------------------
  304|       |
  305|    314|    sp->dec_restart = 0;
  306|    314|    sp->dec_nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|    314|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  307|    314|    sp->dec_bitsleft = 0;
  308|    314|    sp->old_tif_rawcc = 0;
  309|    314|    sp->dec_free_entp = sp->dec_codetab - 1; // + CODE_FIRST;
  310|       |    /*
  311|       |     * Zero entries that are not yet filled in.  We do
  312|       |     * this to guard against bogus input data that causes
  313|       |     * us to index into undefined entries.  If you can
  314|       |     * come up with a way to safely bounds-check input codes
  315|       |     * while decoding then you can remove this operation.
  316|       |     */
  317|    314|    sp->dec_oldcodep = &sp->dec_codetab[0];
  318|    314|    sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask - 1];
  319|    314|    sp->read_error = 0;
  320|    314|    return (1);
  321|    314|}
tif_lzw.c:LZWDecodeCompat:
  800|    132|{
  801|    132|    static const char module[] = "LZWDecodeCompat";
  802|    132|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    132|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    132|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  803|    132|    uint8_t *op = (uint8_t *)op0;
  804|    132|    tmsize_t occ = occ0;
  805|    132|    uint8_t *tp;
  806|    132|    uint8_t *bp;
  807|    132|    int code, nbits;
  808|    132|    int len;
  809|    132|    long nextbits, nbitsmask;
  810|    132|    WordType nextdata;
  811|    132|    code_t *codep, *free_entp, *maxcodep, *oldcodep;
  812|       |
  813|    132|    (void)s;
  814|    132|    assert(sp != NULL);
  ------------------
  |  Branch (814:5): [True: 0, False: 132]
  |  Branch (814:5): [True: 132, False: 0]
  ------------------
  815|       |
  816|       |    /*
  817|       |     * Restart interrupted output operation.
  818|       |     */
  819|    132|    if (sp->dec_restart)
  ------------------
  |  Branch (819:9): [True: 0, False: 132]
  ------------------
  820|      0|    {
  821|      0|        tmsize_t residue;
  822|       |
  823|      0|        codep = sp->dec_codep;
  824|      0|        residue = codep->length - sp->dec_restart;
  825|      0|        if (residue > occ)
  ------------------
  |  Branch (825:13): [True: 0, False: 0]
  ------------------
  826|      0|        {
  827|       |            /*
  828|       |             * Residue from previous decode is sufficient
  829|       |             * to satisfy decode request.  Skip to the
  830|       |             * start of the decoded string, place decoded
  831|       |             * values in the output buffer, and return.
  832|       |             */
  833|      0|            sp->dec_restart += occ;
  834|      0|            do
  835|      0|            {
  836|      0|                codep = codep->next;
  837|      0|            } while (--residue > occ);
  ------------------
  |  Branch (837:22): [True: 0, False: 0]
  ------------------
  838|      0|            tp = op + occ;
  839|      0|            do
  840|      0|            {
  841|      0|                *--tp = codep->value;
  842|      0|                codep = codep->next;
  843|      0|            } while (--occ);
  ------------------
  |  Branch (843:22): [True: 0, False: 0]
  ------------------
  844|      0|            return (1);
  845|      0|        }
  846|       |        /*
  847|       |         * Residue satisfies only part of the decode request.
  848|       |         */
  849|      0|        op += residue;
  850|      0|        occ -= residue;
  851|      0|        tp = op;
  852|      0|        do
  853|      0|        {
  854|      0|            *--tp = codep->value;
  855|      0|            codep = codep->next;
  856|      0|        } while (--residue);
  ------------------
  |  Branch (856:18): [True: 0, False: 0]
  ------------------
  857|      0|        sp->dec_restart = 0;
  858|      0|    }
  859|       |
  860|    132|    bp = (uint8_t *)tif->tif_rawcp;
  861|       |
  862|    132|    sp->dec_bitsleft +=
  863|    132|        (((uint64_t)tif->tif_rawcc - (uint64_t)sp->old_tif_rawcc) << 3);
  864|    132|    uint64_t dec_bitsleft = sp->dec_bitsleft;
  865|       |
  866|    132|    nbits = sp->lzw_nbits;
  ------------------
  |  |  102|    132|#define lzw_nbits base.nbits
  ------------------
  867|    132|    nextdata = sp->lzw_nextdata;
  ------------------
  |  |  105|    132|#define lzw_nextdata base.nextdata
  ------------------
  868|    132|    nextbits = sp->lzw_nextbits;
  ------------------
  |  |  106|    132|#define lzw_nextbits base.nextbits
  ------------------
  869|    132|    nbitsmask = sp->dec_nbitsmask;
  870|    132|    oldcodep = sp->dec_oldcodep;
  871|    132|    free_entp = sp->dec_free_entp;
  872|    132|    maxcodep = sp->dec_maxcodep;
  873|       |
  874|  47.2k|    while (occ > 0)
  ------------------
  |  Branch (874:12): [True: 47.2k, False: 11]
  ------------------
  875|  47.2k|    {
  876|  47.2k|        NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  ------------------
  |  |  766|  47.2k|    {                                                                          \
  |  |  767|  47.2k|        if (dec_bitsleft < (uint64_t)nbits)                                    \
  |  |  ------------------
  |  |  |  Branch (767:13): [True: 19, False: 47.2k]
  |  |  ------------------
  |  |  768|  47.2k|        {                                                                      \
  |  |  769|     19|            TIFFWarningExtR(_tif, module,                                      \
  |  |  770|     19|                            "LZWDecode: Strip %" PRIu32                        \
  |  |  771|     19|                            " not terminated with EOI code",                   \
  |  |  772|     19|                            _tif->tif_dir.td_curstrip);                        \
  |  |  773|     19|            _code = CODE_EOI;                                                  \
  |  |  ------------------
  |  |  |  |   72|     19|#define CODE_EOI 257   /* end-of-information code */
  |  |  ------------------
  |  |  774|     19|        }                                                                      \
  |  |  775|  47.2k|        else                                                                   \
  |  |  776|  47.2k|        {                                                                      \
  |  |  777|  47.2k|            _get(_sp, _bp, _code);                                             \
  |  |  ------------------
  |  |  |  |  876|  47.2k|        NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  |  |  |  |  ------------------
  |  |  |  |  |  |  786|  47.2k|    {                                                                          \
  |  |  |  |  |  |  787|  47.2k|        nextdata |= (unsigned long)*(bp)++ << nextbits;                        \
  |  |  |  |  |  |  788|  47.2k|        nextbits += 8;                                                         \
  |  |  |  |  |  |  789|  47.2k|        if (nextbits < nbits)                                                  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (789:13): [True: 16.0k, False: 31.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  790|  47.2k|        {                                                                      \
  |  |  |  |  |  |  791|  16.0k|            nextdata |= (unsigned long)*(bp)++ << nextbits;                    \
  |  |  |  |  |  |  792|  16.0k|            nextbits += 8;                                                     \
  |  |  |  |  |  |  793|  16.0k|        }                                                                      \
  |  |  |  |  |  |  794|  47.2k|        code = (hcode_t)(nextdata & (unsigned long)nbitsmask);                 \
  |  |  |  |  |  |  795|  47.2k|        nextdata >>= nbits;                                                    \
  |  |  |  |  |  |  796|  47.2k|        nextbits -= nbits;                                                     \
  |  |  |  |  |  |  797|  47.2k|    }
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  778|  47.2k|            dec_bitsleft -= (uint64_t)nbits;                                   \
  |  |  779|  47.2k|        }                                                                      \
  |  |  780|  47.2k|    }
  ------------------
  877|  47.2k|        if (code == CODE_EOI)
  ------------------
  |  |   72|  47.2k|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (877:13): [True: 35, False: 47.1k]
  ------------------
  878|     35|            break;
  879|  47.1k|        if (code == CODE_CLEAR)
  ------------------
  |  |   71|  47.1k|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (879:13): [True: 92, False: 47.0k]
  ------------------
  880|     92|        {
  881|     92|            do
  882|     92|            {
  883|     92|                free_entp = sp->dec_codetab + CODE_FIRST;
  ------------------
  |  |   73|     92|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  884|     92|                _TIFFmemset(free_entp, 0,
  885|     92|                            (CSIZE - CODE_FIRST) * sizeof(code_t));
  ------------------
  |  |   79|     92|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|     92|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
                                          (CSIZE - CODE_FIRST) * sizeof(code_t));
  ------------------
  |  |   73|     92|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  886|     92|                nbits = BITS_MIN;
  ------------------
  |  |   68|     92|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  887|     92|                nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|     92|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  888|     92|                maxcodep = sp->dec_codetab + nbitsmask;
  889|     92|                NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  ------------------
  |  |  766|     92|    {                                                                          \
  |  |  767|     92|        if (dec_bitsleft < (uint64_t)nbits)                                    \
  |  |  ------------------
  |  |  |  Branch (767:13): [True: 8, False: 84]
  |  |  ------------------
  |  |  768|     92|        {                                                                      \
  |  |  769|      8|            TIFFWarningExtR(_tif, module,                                      \
  |  |  770|      8|                            "LZWDecode: Strip %" PRIu32                        \
  |  |  771|      8|                            " not terminated with EOI code",                   \
  |  |  772|      8|                            _tif->tif_dir.td_curstrip);                        \
  |  |  773|      8|            _code = CODE_EOI;                                                  \
  |  |  ------------------
  |  |  |  |   72|      8|#define CODE_EOI 257   /* end-of-information code */
  |  |  ------------------
  |  |  774|      8|        }                                                                      \
  |  |  775|     92|        else                                                                   \
  |  |  776|     92|        {                                                                      \
  |  |  777|     84|            _get(_sp, _bp, _code);                                             \
  |  |  ------------------
  |  |  |  |  889|     84|                NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  |  |  |  |  ------------------
  |  |  |  |  |  |  786|     84|    {                                                                          \
  |  |  |  |  |  |  787|     84|        nextdata |= (unsigned long)*(bp)++ << nextbits;                        \
  |  |  |  |  |  |  788|     84|        nextbits += 8;                                                         \
  |  |  |  |  |  |  789|     84|        if (nextbits < nbits)                                                  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (789:13): [True: 2, False: 82]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  790|     84|        {                                                                      \
  |  |  |  |  |  |  791|      2|            nextdata |= (unsigned long)*(bp)++ << nextbits;                    \
  |  |  |  |  |  |  792|      2|            nextbits += 8;                                                     \
  |  |  |  |  |  |  793|      2|        }                                                                      \
  |  |  |  |  |  |  794|     84|        code = (hcode_t)(nextdata & (unsigned long)nbitsmask);                 \
  |  |  |  |  |  |  795|     84|        nextdata >>= nbits;                                                    \
  |  |  |  |  |  |  796|     84|        nextbits -= nbits;                                                     \
  |  |  |  |  |  |  797|     84|    }
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  778|     84|            dec_bitsleft -= (uint64_t)nbits;                                   \
  |  |  779|     84|        }                                                                      \
  |  |  780|     92|    }
  ------------------
  890|     92|            } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
  ------------------
  |  |   71|     92|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (890:22): [True: 0, False: 92]
  ------------------
  891|     92|            if (code == CODE_EOI)
  ------------------
  |  |   72|     92|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (891:17): [True: 8, False: 84]
  ------------------
  892|      8|                break;
  893|     84|            if (code > CODE_CLEAR)
  ------------------
  |  |   71|     84|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (893:17): [True: 0, False: 84]
  ------------------
  894|      0|            {
  895|      0|                TIFFErrorExtR(
  896|      0|                    tif, tif->tif_name,
  897|      0|                    "LZWDecode: Corrupted LZW table at scanline %" PRIu32,
  898|      0|                    tif->tif_dir.td_row);
  899|      0|                return (0);
  900|      0|            }
  901|     84|            *op++ = (uint8_t)code;
  902|     84|            occ--;
  903|     84|            oldcodep = sp->dec_codetab + code;
  904|     84|            continue;
  905|     84|        }
  906|  47.0k|        codep = sp->dec_codetab + code;
  907|       |
  908|       |        /*
  909|       |         * Add the new entry to the code table.
  910|       |         */
  911|  47.0k|        if (free_entp < &sp->dec_codetab[0] ||
  ------------------
  |  Branch (911:13): [True: 40, False: 47.0k]
  ------------------
  912|  47.0k|            free_entp >= &sp->dec_codetab[CSIZE])
  ------------------
  |  |   79|  47.0k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  47.0k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (912:13): [True: 3, False: 47.0k]
  ------------------
  913|     43|        {
  914|     43|            TIFFErrorExtR(tif, module,
  915|     43|                          "Corrupted LZW table at scanline %" PRIu32,
  916|     43|                          tif->tif_dir.td_row);
  917|     43|            return (0);
  918|     43|        }
  919|       |
  920|  47.0k|        free_entp->next = oldcodep;
  921|  47.0k|        if (free_entp->next < &sp->dec_codetab[0] ||
  ------------------
  |  Branch (921:13): [True: 0, False: 47.0k]
  ------------------
  922|  47.0k|            free_entp->next >= &sp->dec_codetab[CSIZE])
  ------------------
  |  |   79|  47.0k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  47.0k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (922:13): [True: 0, False: 47.0k]
  ------------------
  923|      0|        {
  924|      0|            TIFFErrorExtR(tif, module,
  925|      0|                          "Corrupted LZW table at scanline %" PRIu32,
  926|      0|                          tif->tif_dir.td_row);
  927|      0|            return (0);
  928|      0|        }
  929|  47.0k|        free_entp->firstchar = free_entp->next->firstchar;
  930|  47.0k|        free_entp->length = (uint16_t)(free_entp->next->length + 1);
  931|  47.0k|        free_entp->value =
  932|  47.0k|            (codep < free_entp) ? codep->firstchar : free_entp->firstchar;
  ------------------
  |  Branch (932:13): [True: 47.0k, False: 35]
  ------------------
  933|  47.0k|        if (++free_entp > maxcodep)
  ------------------
  |  Branch (933:13): [True: 3.72k, False: 43.3k]
  ------------------
  934|  3.72k|        {
  935|  3.72k|            if (++nbits > BITS_MAX) /* should not happen */
  ------------------
  |  |   69|  3.72k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (935:17): [True: 3.66k, False: 57]
  ------------------
  936|  3.66k|                nbits = BITS_MAX;
  ------------------
  |  |   69|  3.66k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  937|  3.72k|            nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|  3.72k|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  938|  3.72k|            maxcodep = sp->dec_codetab + nbitsmask;
  939|  3.72k|        }
  940|  47.0k|        oldcodep = codep;
  941|  47.0k|        if (code >= 256)
  ------------------
  |  Branch (941:13): [True: 591, False: 46.4k]
  ------------------
  942|    591|        {
  943|       |            /*
  944|       |             * Code maps to a string, copy string
  945|       |             * value to output (written in reverse).
  946|       |             */
  947|    591|            if (codep->length == 0)
  ------------------
  |  Branch (947:17): [True: 35, False: 556]
  ------------------
  948|     35|            {
  949|     35|                TIFFErrorExtR(
  950|     35|                    tif, module,
  951|     35|                    "Wrong length of decoded "
  952|     35|                    "string: data probably corrupted at scanline %" PRIu32,
  953|     35|                    tif->tif_dir.td_row);
  954|     35|                return (0);
  955|     35|            }
  956|    556|            if (codep->length > occ)
  ------------------
  |  Branch (956:17): [True: 0, False: 556]
  ------------------
  957|      0|            {
  958|       |                /*
  959|       |                 * String is too long for decode buffer,
  960|       |                 * locate portion that will fit, copy to
  961|       |                 * the decode buffer, and setup restart
  962|       |                 * logic for the next decoding call.
  963|       |                 */
  964|      0|                sp->dec_codep = codep;
  965|      0|                do
  966|      0|                {
  967|      0|                    codep = codep->next;
  968|      0|                } while (codep->length > occ);
  ------------------
  |  Branch (968:26): [True: 0, False: 0]
  ------------------
  969|      0|                sp->dec_restart = occ;
  970|      0|                tp = op + occ;
  971|      0|                do
  972|      0|                {
  973|      0|                    *--tp = codep->value;
  974|      0|                    codep = codep->next;
  975|      0|                } while (--occ);
  ------------------
  |  Branch (975:26): [True: 0, False: 0]
  ------------------
  976|      0|                break;
  977|      0|            }
  978|    556|            len = codep->length;
  979|    556|            tp = op + len;
  980|    556|            do
  981|  1.11k|            {
  982|  1.11k|                *--tp = codep->value;
  983|  1.11k|                codep = codep->next;
  984|  1.11k|            } while (codep && tp > op);
  ------------------
  |  Branch (984:22): [True: 556, False: 556]
  |  Branch (984:31): [True: 556, False: 0]
  ------------------
  985|    556|            assert(occ >= len);
  ------------------
  |  Branch (985:13): [True: 0, False: 556]
  |  Branch (985:13): [True: 556, False: 0]
  ------------------
  986|    556|            op += len;
  987|    556|            occ -= len;
  988|    556|        }
  989|  46.4k|        else
  990|  46.4k|        {
  991|  46.4k|            *op++ = (uint8_t)code;
  992|  46.4k|            occ--;
  993|  46.4k|        }
  994|  47.0k|    }
  995|       |
  996|     54|    tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
  997|     54|    tif->tif_rawcp = (uint8_t *)bp;
  998|       |
  999|     54|    sp->old_tif_rawcc = tif->tif_rawcc;
 1000|     54|    sp->dec_bitsleft = dec_bitsleft;
 1001|       |
 1002|     54|    sp->lzw_nbits = (unsigned short)nbits;
  ------------------
  |  |  102|     54|#define lzw_nbits base.nbits
  ------------------
 1003|     54|    sp->lzw_nextdata = nextdata;
  ------------------
  |  |  105|     54|#define lzw_nextdata base.nextdata
  ------------------
 1004|     54|    sp->lzw_nextbits = nextbits;
  ------------------
  |  |  106|     54|#define lzw_nextbits base.nextbits
  ------------------
 1005|     54|    sp->dec_nbitsmask = nbitsmask;
 1006|     54|    sp->dec_oldcodep = oldcodep;
 1007|     54|    sp->dec_free_entp = free_entp;
 1008|     54|    sp->dec_maxcodep = maxcodep;
 1009|       |
 1010|     54|    if (occ > 0)
  ------------------
  |  Branch (1010:9): [True: 43, False: 11]
  ------------------
 1011|     43|    {
 1012|     43|        TIFFErrorExtR(tif, module,
 1013|     43|                      "Not enough data at scanline %" PRIu32 " (short %" PRIu64
 1014|     43|                      " bytes)",
 1015|     43|                      tif->tif_dir.td_row, (uint64_t)occ);
 1016|     43|        return (0);
 1017|     43|    }
 1018|     11|    return (1);
 1019|     54|}
tif_lzw.c:LZWDecode:
  403|    177|{
  404|    177|    static const char module[] = "LZWDecode";
  405|    177|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    177|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    177|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  406|    177|    uint8_t *op = (uint8_t *)op0;
  407|    177|    tmsize_t occ = occ0;
  408|    177|    uint8_t *bp;
  409|    177|    long nbits, nextbits, nbitsmask;
  410|    177|    WordType nextdata;
  411|    177|    code_t *free_entp, *maxcodep, *oldcodep;
  412|       |
  413|    177|    (void)s;
  414|    177|    assert(sp != NULL);
  ------------------
  |  Branch (414:5): [True: 0, False: 177]
  |  Branch (414:5): [True: 177, False: 0]
  ------------------
  415|    177|    assert(sp->dec_codetab != NULL);
  ------------------
  |  Branch (415:5): [True: 0, False: 177]
  |  Branch (415:5): [True: 177, False: 0]
  ------------------
  416|       |
  417|    177|    if (sp->read_error)
  ------------------
  |  Branch (417:9): [True: 0, False: 177]
  ------------------
  418|      0|    {
  419|      0|        memset(op, 0, (size_t)occ);
  420|      0|        TIFFErrorExtR(tif, module,
  421|      0|                      "LZWDecode: Scanline %" PRIu32 " cannot be read due to "
  422|      0|                      "previous error",
  423|      0|                      tif->tif_dir.td_row);
  424|      0|        return 0;
  425|      0|    }
  426|       |
  427|       |    /*
  428|       |     * Restart interrupted output operation.
  429|       |     */
  430|    177|    if (sp->dec_restart)
  ------------------
  |  Branch (430:9): [True: 0, False: 177]
  ------------------
  431|      0|    {
  432|      0|        tmsize_t residue;
  433|       |
  434|      0|        code_t *codep = sp->dec_codep;
  435|      0|        residue = codep->length - sp->dec_restart;
  436|      0|        if (residue > occ)
  ------------------
  |  Branch (436:13): [True: 0, False: 0]
  ------------------
  437|      0|        {
  438|       |            /*
  439|       |             * Residue from previous decode is sufficient
  440|       |             * to satisfy decode request.  Skip to the
  441|       |             * start of the decoded string, place decoded
  442|       |             * values in the output buffer, and return.
  443|       |             */
  444|      0|            sp->dec_restart += occ;
  445|      0|            do
  446|      0|            {
  447|      0|                codep = codep->next;
  448|      0|            } while (--residue > occ && codep);
  ------------------
  |  Branch (448:22): [True: 0, False: 0]
  |  Branch (448:41): [True: 0, False: 0]
  ------------------
  449|      0|            if (codep)
  ------------------
  |  Branch (449:17): [True: 0, False: 0]
  ------------------
  450|      0|            {
  451|      0|                uint8_t *tp = op + occ;
  452|      0|                do
  453|      0|                {
  454|      0|                    *--tp = codep->value;
  455|      0|                    codep = codep->next;
  456|      0|                } while (--occ && codep);
  ------------------
  |  Branch (456:26): [True: 0, False: 0]
  |  Branch (456:35): [True: 0, False: 0]
  ------------------
  457|      0|            }
  458|      0|            return (1);
  459|      0|        }
  460|       |        /*
  461|       |         * Residue satisfies only part of the decode request.
  462|       |         */
  463|      0|        op += residue;
  464|      0|        occ -= residue;
  465|      0|        uint8_t *tp = op;
  466|      0|        do
  467|      0|        {
  468|      0|            *--tp = codep->value;
  469|      0|            codep = codep->next;
  470|      0|        } while (--residue && codep);
  ------------------
  |  Branch (470:18): [True: 0, False: 0]
  |  Branch (470:31): [True: 0, False: 0]
  ------------------
  471|      0|        sp->dec_restart = 0;
  472|      0|    }
  473|       |
  474|    177|    bp = (uint8_t *)tif->tif_rawcp;
  475|    177|    sp->dec_bitsleft +=
  476|    177|        (((uint64_t)tif->tif_rawcc - (uint64_t)sp->old_tif_rawcc) << 3);
  477|    177|    uint64_t dec_bitsleft = sp->dec_bitsleft;
  478|    177|    nbits = sp->lzw_nbits;
  ------------------
  |  |  102|    177|#define lzw_nbits base.nbits
  ------------------
  479|    177|    nextdata = sp->lzw_nextdata;
  ------------------
  |  |  105|    177|#define lzw_nextdata base.nextdata
  ------------------
  480|    177|    nextbits = sp->lzw_nextbits;
  ------------------
  |  |  106|    177|#define lzw_nextbits base.nextbits
  ------------------
  481|    177|    nbitsmask = sp->dec_nbitsmask;
  482|    177|    oldcodep = sp->dec_oldcodep;
  483|    177|    free_entp = sp->dec_free_entp;
  484|    177|    maxcodep = sp->dec_maxcodep;
  485|    177|    code_t *const dec_codetab = sp->dec_codetab;
  486|    177|    code_t *codep;
  487|       |
  488|    177|    if (occ == 0)
  ------------------
  |  Branch (488:9): [True: 0, False: 177]
  ------------------
  489|      0|    {
  490|      0|        goto after_loop;
  491|      0|    }
  492|       |
  493|  89.7k|begin:
  494|  89.7k|{
  495|  89.7k|    WordType code;
  496|  89.7k|    GetNextCodeLZW();
  ------------------
  |  |  362|  89.7k|    do                                                                         \
  |  |  363|  89.7k|    {                                                                          \
  |  |  364|  89.7k|        nextbits -= nbits;                                                     \
  |  |  365|  89.7k|        if (nextbits < 0)                                                      \
  |  |  ------------------
  |  |  |  Branch (365:13): [True: 15.8k, False: 73.8k]
  |  |  ------------------
  |  |  366|  89.7k|        {                                                                      \
  |  |  367|  15.8k|            if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE)                           \
  |  |  ------------------
  |  |  |  |   45|  15.8k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  15.8k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (367:17): [True: 15.7k, False: 70]
  |  |  ------------------
  |  |  368|  15.8k|            {                                                                  \
  |  |  369|  15.7k|                unsigned codetmp = (unsigned)(nextdata << (-nextbits));        \
  |  |  370|  15.7k|                GetNextData(nextdata, bp);                                     \
  |  |  ------------------
  |  |  |  |  335|  15.7k|    memcpy(&nextdata, bp, sizeof(nextdata));                                   \
  |  |  |  |  336|  15.7k|    nextdata = __builtin_bswap64(nextdata)
  |  |  ------------------
  |  |  371|  15.7k|                bp += SIZEOF_WORDTYPE;                                         \
  |  |  ------------------
  |  |  |  |   45|  15.7k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  15.7k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  15.7k|                nextbits += 8 * SIZEOF_WORDTYPE;                               \
  |  |  ------------------
  |  |  |  |   45|  15.7k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  15.7k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  373|  15.7k|                dec_bitsleft -= 8 * SIZEOF_WORDTYPE;                           \
  |  |  ------------------
  |  |  |  |   45|  15.7k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  15.7k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  374|  15.7k|                code = (WordType)((codetmp | (nextdata >> nextbits)) &         \
  |  |  375|  15.7k|                                  (WordType)nbitsmask);                        \
  |  |  376|  15.7k|                break;                                                         \
  |  |  377|  15.7k|            }                                                                  \
  |  |  378|  15.8k|            else                                                               \
  |  |  379|  15.8k|            {                                                                  \
  |  |  380|     70|                if (dec_bitsleft < 8)                                          \
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 7, False: 63]
  |  |  ------------------
  |  |  381|     70|                {                                                              \
  |  |  382|      7|                    goto no_eoi;                                               \
  |  |  383|      7|                }                                                              \
  |  |  384|     70|                nextdata = (nextdata << 8) | *(bp)++;                          \
  |  |  385|     63|                nextbits += 8;                                                 \
  |  |  386|     63|                dec_bitsleft -= 8;                                             \
  |  |  387|     63|                if (nextbits < 0)                                              \
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 50, False: 13]
  |  |  ------------------
  |  |  388|     63|                {                                                              \
  |  |  389|     50|                    if (dec_bitsleft < 8)                                      \
  |  |  ------------------
  |  |  |  Branch (389:25): [True: 24, False: 26]
  |  |  ------------------
  |  |  390|     50|                    {                                                          \
  |  |  391|     24|                        goto no_eoi;                                           \
  |  |  392|     24|                    }                                                          \
  |  |  393|     50|                    nextdata = (nextdata << 8) | *(bp)++;                      \
  |  |  394|     26|                    nextbits += 8;                                             \
  |  |  395|     26|                    dec_bitsleft -= 8;                                         \
  |  |  396|     26|                }                                                              \
  |  |  397|     63|            }                                                                  \
  |  |  398|  15.8k|        }                                                                      \
  |  |  399|  89.7k|        code = (WordType)((nextdata >> nextbits) & (WordType)nbitsmask);       \
  |  |  400|  73.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (400:14): [Folded, False: 73.9k]
  |  |  ------------------
  ------------------
  497|  89.6k|    codep = dec_codetab + (unsigned long)code;
  498|  89.6k|    if (code >= CODE_FIRST)
  ------------------
  |  |   73|  89.6k|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  |  Branch (498:9): [True: 1.51k, False: 88.1k]
  ------------------
  499|  1.51k|        goto code_above_or_equal_to_258;
  500|  88.1k|    if (code < 256)
  ------------------
  |  Branch (500:9): [True: 88.1k, False: 58]
  ------------------
  501|  88.1k|        goto code_below_256;
  502|     58|    if (code == CODE_EOI)
  ------------------
  |  |   72|     58|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (502:9): [True: 1, False: 57]
  ------------------
  503|      1|        goto after_loop;
  504|     57|    goto code_clear;
  505|       |
  506|  88.1k|code_below_256:
  507|  88.1k|{
  508|  88.1k|    if (codep > free_entp)
  ------------------
  |  Branch (508:9): [True: 100, False: 88.0k]
  ------------------
  509|    100|        goto error_code;
  510|  88.0k|    free_entp->next = oldcodep;
  511|  88.0k|    free_entp->firstchar = oldcodep->firstchar;
  512|  88.0k|    free_entp->length = (uint16_t)(oldcodep->length + 1);
  513|  88.0k|    free_entp->value = (uint8_t)code;
  514|  88.0k|    free_entp->repeated =
  515|  88.0k|        (bool)(oldcodep->repeated & (oldcodep->value == code));
  516|  88.0k|    if (++free_entp > maxcodep)
  ------------------
  |  Branch (516:9): [True: 8.14k, False: 79.8k]
  ------------------
  517|  8.14k|    {
  518|  8.14k|        if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
  ------------------
  |  |   69|  8.14k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (518:13): [True: 8.06k, False: 74]
  ------------------
  519|  8.06k|            nbits = BITS_MAX;
  ------------------
  |  |   69|  8.06k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  520|  8.14k|        nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|  8.14k|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  521|  8.14k|        maxcodep = dec_codetab + nbitsmask - 1;
  522|  8.14k|        if (free_entp >= &dec_codetab[CSIZE])
  ------------------
  |  |   79|  8.14k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  8.14k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (522:13): [True: 3, False: 8.14k]
  ------------------
  523|      3|        {
  524|       |            /* At that point, the next valid states are either EOI or a */
  525|       |            /* CODE_CLEAR. If a regular code is read, at the next */
  526|       |            /* attempt at registering a new entry, we will error out */
  527|       |            /* due to setting free_entp before any valid code */
  528|      3|            free_entp = dec_codetab - 1;
  529|      3|        }
  530|  8.14k|    }
  531|  88.0k|    oldcodep = codep;
  532|  88.0k|    *op++ = (uint8_t)code;
  533|  88.0k|    occ--;
  534|  88.0k|    if (occ == 0)
  ------------------
  |  Branch (534:9): [True: 0, False: 88.0k]
  ------------------
  535|      0|        goto after_loop;
  536|  88.0k|    goto begin;
  537|  88.0k|}
  538|       |
  539|  88.0k|code_above_or_equal_to_258:
  540|  1.51k|{
  541|       |    /*
  542|       |     * Add the new entry to the code table.
  543|       |     */
  544|       |
  545|  1.51k|    if (codep >= free_entp)
  ------------------
  |  Branch (545:9): [True: 84, False: 1.43k]
  ------------------
  546|     84|    {
  547|     84|        if (codep != free_entp)
  ------------------
  |  Branch (547:13): [True: 38, False: 46]
  ------------------
  548|     38|            goto error_code;
  549|     46|        free_entp->value = oldcodep->firstchar;
  550|     46|    }
  551|  1.43k|    else
  552|  1.43k|    {
  553|  1.43k|        free_entp->value = codep->firstchar;
  554|  1.43k|    }
  555|  1.47k|    free_entp->repeated =
  556|  1.47k|        (bool)(oldcodep->repeated & (oldcodep->value == free_entp->value));
  557|  1.47k|    free_entp->next = oldcodep;
  558|       |
  559|  1.47k|    free_entp->firstchar = oldcodep->firstchar;
  560|  1.47k|    free_entp->length = (uint16_t)(oldcodep->length + 1);
  561|  1.47k|    if (++free_entp > maxcodep)
  ------------------
  |  Branch (561:9): [True: 475, False: 1.00k]
  ------------------
  562|    475|    {
  563|    475|        if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
  ------------------
  |  |   69|    475|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (563:13): [True: 475, False: 0]
  ------------------
  564|    475|            nbits = BITS_MAX;
  ------------------
  |  |   69|    475|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  565|    475|        nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|    475|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  566|    475|        maxcodep = dec_codetab + nbitsmask - 1;
  567|    475|        if (free_entp >= &dec_codetab[CSIZE])
  ------------------
  |  |   79|    475|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|    475|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (567:13): [True: 3, False: 472]
  ------------------
  568|      3|        {
  569|       |            /* At that point, the next valid states are either EOI or a */
  570|       |            /* CODE_CLEAR. If a regular code is read, at the next */
  571|       |            /* attempt at registering a new entry, we will error out */
  572|       |            /* due to setting free_entp before any valid code */
  573|      3|            free_entp = dec_codetab - 1;
  574|      3|        }
  575|    475|    }
  576|  1.47k|    oldcodep = codep;
  577|       |
  578|       |    /*
  579|       |     * Code maps to a string, copy string
  580|       |     * value to output (written in reverse).
  581|       |     */
  582|       |    /* tiny bit faster on x86_64 to store in unsigned short than int */
  583|  1.47k|    unsigned short len = codep->length;
  584|       |
  585|  1.47k|    if (len < 3) /* equivalent to len == 2 given all other conditions */
  ------------------
  |  Branch (585:9): [True: 1.14k, False: 338]
  ------------------
  586|  1.14k|    {
  587|  1.14k|        if (occ <= 2)
  ------------------
  |  Branch (587:13): [True: 0, False: 1.14k]
  ------------------
  588|      0|        {
  589|      0|            if (occ == 2)
  ------------------
  |  Branch (589:17): [True: 0, False: 0]
  ------------------
  590|      0|            {
  591|      0|                memcpy(op, &(codep->firstchar), 2);
  592|      0|                op += 2;
  593|      0|                occ -= 2;
  594|      0|                goto after_loop;
  595|      0|            }
  596|      0|            goto too_short_buffer;
  597|      0|        }
  598|       |
  599|  1.14k|        memcpy(op, &(codep->firstchar), 2);
  600|  1.14k|        op += 2;
  601|  1.14k|        occ -= 2;
  602|  1.14k|        goto begin; /* we can save the comparison occ > 0 */
  603|  1.14k|    }
  604|       |
  605|    338|    if (len == 3)
  ------------------
  |  Branch (605:9): [True: 152, False: 186]
  ------------------
  606|    152|    {
  607|    152|        if (occ <= 3)
  ------------------
  |  Branch (607:13): [True: 0, False: 152]
  ------------------
  608|      0|        {
  609|      0|            if (occ == 3)
  ------------------
  |  Branch (609:17): [True: 0, False: 0]
  ------------------
  610|      0|            {
  611|      0|                op[0] = codep->firstchar;
  612|      0|                op[1] = codep->next->value;
  613|      0|                op[2] = codep->value;
  614|      0|                op += 3;
  615|      0|                occ -= 3;
  616|      0|                goto after_loop;
  617|      0|            }
  618|      0|            goto too_short_buffer;
  619|      0|        }
  620|       |
  621|    152|        op[0] = codep->firstchar;
  622|    152|        op[1] = codep->next->value;
  623|    152|        op[2] = codep->value;
  624|    152|        op += 3;
  625|    152|        occ -= 3;
  626|    152|        goto begin; /* we can save the comparison occ > 0 */
  627|    152|    }
  628|       |
  629|    186|    if (len > occ)
  ------------------
  |  Branch (629:9): [True: 0, False: 186]
  ------------------
  630|      0|    {
  631|      0|        goto too_short_buffer;
  632|      0|    }
  633|       |
  634|    186|    if (codep->repeated)
  ------------------
  |  Branch (634:9): [True: 125, False: 61]
  ------------------
  635|    125|    {
  636|    125|        memset(op, codep->value, len);
  637|    125|        op += len;
  638|    125|        occ -= len;
  639|    125|        if (occ == 0)
  ------------------
  |  Branch (639:13): [True: 0, False: 125]
  ------------------
  640|      0|            goto after_loop;
  641|    125|        goto begin;
  642|    125|    }
  643|       |
  644|     61|    uint8_t *tp = op + len;
  645|       |
  646|     61|    assert(len >= 4);
  ------------------
  |  Branch (646:5): [True: 0, False: 61]
  |  Branch (646:5): [True: 61, False: 0]
  ------------------
  647|       |
  648|     61|    *--tp = codep->value;
  649|     61|    codep = codep->next;
  650|     61|    *--tp = codep->value;
  651|     61|    codep = codep->next;
  652|     61|    *--tp = codep->value;
  653|     61|    codep = codep->next;
  654|     61|    *--tp = codep->value;
  655|     61|    if (tp > op)
  ------------------
  |  Branch (655:9): [True: 43, False: 18]
  ------------------
  656|     43|    {
  657|     43|        do
  658|    107|        {
  659|    107|            codep = codep->next;
  660|    107|            *--tp = codep->value;
  661|    107|        } while (tp > op);
  ------------------
  |  Branch (661:18): [True: 64, False: 43]
  ------------------
  662|     43|    }
  663|       |
  664|     61|    assert(occ >= len);
  ------------------
  |  Branch (664:5): [True: 0, False: 61]
  |  Branch (664:5): [True: 61, False: 0]
  ------------------
  665|     61|    op += len;
  666|     61|    occ -= len;
  667|     61|    if (occ == 0)
  ------------------
  |  Branch (667:9): [True: 0, False: 61]
  ------------------
  668|      0|        goto after_loop;
  669|     61|    goto begin;
  670|     61|}
  671|       |
  672|     61|code_clear:
  673|     57|{
  674|     57|    free_entp = dec_codetab + CODE_FIRST;
  ------------------
  |  |   73|     57|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  675|     57|    nbits = BITS_MIN;
  ------------------
  |  |   68|     57|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  676|     57|    nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|     57|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  677|     57|    maxcodep = dec_codetab + (unsigned long)nbitsmask - 1;
  678|     57|    do
  679|     61|    {
  680|     61|        GetNextCodeLZW();
  ------------------
  |  |  362|     61|    do                                                                         \
  |  |  363|     61|    {                                                                          \
  |  |  364|     61|        nextbits -= nbits;                                                     \
  |  |  365|     61|        if (nextbits < 0)                                                      \
  |  |  ------------------
  |  |  |  Branch (365:13): [True: 5, False: 56]
  |  |  ------------------
  |  |  366|     61|        {                                                                      \
  |  |  367|      5|            if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE)                           \
  |  |  ------------------
  |  |  |  |   45|      5|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|      5|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (367:17): [True: 5, False: 0]
  |  |  ------------------
  |  |  368|      5|            {                                                                  \
  |  |  369|      5|                unsigned codetmp = (unsigned)(nextdata << (-nextbits));        \
  |  |  370|      5|                GetNextData(nextdata, bp);                                     \
  |  |  ------------------
  |  |  |  |  335|      5|    memcpy(&nextdata, bp, sizeof(nextdata));                                   \
  |  |  |  |  336|      5|    nextdata = __builtin_bswap64(nextdata)
  |  |  ------------------
  |  |  371|      5|                bp += SIZEOF_WORDTYPE;                                         \
  |  |  ------------------
  |  |  |  |   45|      5|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|      5|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      5|                nextbits += 8 * SIZEOF_WORDTYPE;                               \
  |  |  ------------------
  |  |  |  |   45|      5|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|      5|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  373|      5|                dec_bitsleft -= 8 * SIZEOF_WORDTYPE;                           \
  |  |  ------------------
  |  |  |  |   45|      5|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|      5|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  374|      5|                code = (WordType)((codetmp | (nextdata >> nextbits)) &         \
  |  |  375|      5|                                  (WordType)nbitsmask);                        \
  |  |  376|      5|                break;                                                         \
  |  |  377|      5|            }                                                                  \
  |  |  378|      5|            else                                                               \
  |  |  379|      5|            {                                                                  \
  |  |  380|      0|                if (dec_bitsleft < 8)                                          \
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  381|      0|                {                                                              \
  |  |  382|      0|                    goto no_eoi;                                               \
  |  |  383|      0|                }                                                              \
  |  |  384|      0|                nextdata = (nextdata << 8) | *(bp)++;                          \
  |  |  385|      0|                nextbits += 8;                                                 \
  |  |  386|      0|                dec_bitsleft -= 8;                                             \
  |  |  387|      0|                if (nextbits < 0)                                              \
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|                {                                                              \
  |  |  389|      0|                    if (dec_bitsleft < 8)                                      \
  |  |  ------------------
  |  |  |  Branch (389:25): [True: 0, False: 0]
  |  |  ------------------
  |  |  390|      0|                    {                                                          \
  |  |  391|      0|                        goto no_eoi;                                           \
  |  |  392|      0|                    }                                                          \
  |  |  393|      0|                    nextdata = (nextdata << 8) | *(bp)++;                      \
  |  |  394|      0|                    nextbits += 8;                                             \
  |  |  395|      0|                    dec_bitsleft -= 8;                                         \
  |  |  396|      0|                }                                                              \
  |  |  397|      0|            }                                                                  \
  |  |  398|      5|        }                                                                      \
  |  |  399|     61|        code = (WordType)((nextdata >> nextbits) & (WordType)nbitsmask);       \
  |  |  400|     56|    } while (0)
  |  |  ------------------
  |  |  |  Branch (400:14): [Folded, False: 56]
  |  |  ------------------
  ------------------
  681|     61|    } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
  ------------------
  |  |   71|     61|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (681:14): [True: 4, False: 57]
  ------------------
  682|     57|    if (code == CODE_EOI)
  ------------------
  |  |   72|     57|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (682:9): [True: 0, False: 57]
  ------------------
  683|      0|        goto after_loop;
  684|     57|    if (code > CODE_EOI)
  ------------------
  |  |   72|     57|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (684:9): [True: 7, False: 50]
  ------------------
  685|      7|    {
  686|      7|        goto error_code;
  687|      7|    }
  688|     50|    *op++ = (uint8_t)code;
  689|     50|    occ--;
  690|     50|    oldcodep = dec_codetab + code;
  691|     50|    if (occ == 0)
  ------------------
  |  Branch (691:9): [True: 0, False: 50]
  ------------------
  692|      0|        goto after_loop;
  693|     50|    goto begin;
  694|     50|}
  695|     50|}
  696|       |
  697|     50|too_short_buffer:
  698|      0|{
  699|       |    /*
  700|       |     * String is too long for decode buffer,
  701|       |     * locate portion that will fit, copy to
  702|       |     * the decode buffer, and setup restart
  703|       |     * logic for the next decoding call.
  704|       |     */
  705|      0|    sp->dec_codep = codep;
  706|      0|    do
  707|      0|    {
  708|      0|        codep = codep->next;
  709|      0|    } while (codep->length > occ);
  ------------------
  |  Branch (709:14): [True: 0, False: 0]
  ------------------
  710|       |
  711|      0|    sp->dec_restart = occ;
  712|      0|    uint8_t *tp = op + occ;
  713|      0|    do
  714|      0|    {
  715|      0|        *--tp = codep->value;
  716|      0|        codep = codep->next;
  717|      0|    } while (--occ);
  ------------------
  |  Branch (717:14): [True: 0, False: 0]
  ------------------
  718|      0|}
  719|       |
  720|      1|after_loop:
  721|      1|    tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
  722|      1|    tif->tif_rawcp = (uint8_t *)bp;
  723|      1|    sp->old_tif_rawcc = tif->tif_rawcc;
  724|      1|    sp->dec_bitsleft = dec_bitsleft;
  725|      1|    sp->lzw_nbits = (unsigned short)nbits;
  ------------------
  |  |  102|      1|#define lzw_nbits base.nbits
  ------------------
  726|      1|    sp->lzw_nextdata = nextdata;
  ------------------
  |  |  105|      1|#define lzw_nextdata base.nextdata
  ------------------
  727|      1|    sp->lzw_nextbits = nextbits;
  ------------------
  |  |  106|      1|#define lzw_nextbits base.nextbits
  ------------------
  728|      1|    sp->dec_nbitsmask = nbitsmask;
  729|      1|    sp->dec_oldcodep = oldcodep;
  730|      1|    sp->dec_free_entp = free_entp;
  731|      1|    sp->dec_maxcodep = maxcodep;
  732|       |
  733|      1|    if (occ > 0)
  ------------------
  |  Branch (733:9): [True: 1, False: 0]
  ------------------
  734|      1|    {
  735|      1|        memset(op, 0, (size_t)occ);
  736|      1|        sp->read_error = 1;
  737|      1|        TIFFErrorExtR(tif, module,
  738|      1|                      "Not enough data at scanline %" PRIu32 " (short %" PRIu64
  739|      1|                      " bytes)",
  740|      1|                      tif->tif_dir.td_row, (uint64_t)occ);
  741|      1|        return (0);
  742|      1|    }
  743|      0|    return (1);
  744|       |
  745|     31|no_eoi:
  746|     31|    memset(op, 0, (size_t)occ);
  747|     31|    sp->read_error = 1;
  748|     31|    TIFFErrorExtR(tif, module,
  749|     31|                  "LZWDecode: Strip %" PRIu32 " not terminated with EOI code",
  750|     31|                  tif->tif_dir.td_curstrip);
  751|     31|    return 0;
  752|    145|error_code:
  753|    145|    memset(op, 0, (size_t)occ);
  754|    145|    sp->read_error = 1;
  755|    145|    TIFFErrorExtR(tif, tif->tif_name, "Using code not yet in table");
  756|    145|    return 0;
  757|      1|}
tif_lzw.c:LZWGetMaxCompressionRatio:
 1396|     17|{
 1397|     17|    (void)tif;
 1398|       |
 1399|       |    /* See README_for_libtiff_developpers.md for raw data used to estimate
 1400|       |     * the maximum compression rate. */
 1401|       |
 1402|       |    /* 1024x1024: 562 */
 1403|       |    /* 4096x4096: 1243 */
 1404|       |    /* 16383x16383: 1353 */
 1405|       |    /* 65536x65536: 1362 */
 1406|       |
 1407|     17|    return 1400;
 1408|     17|}
tif_lzw.c:LZWCleanup:
 1378|    108|{
 1379|    108|    (void)TIFFPredictorCleanup(tif);
 1380|       |
 1381|    108|    assert(tif->tif_data != NULL);
  ------------------
  |  Branch (1381:5): [True: 0, False: 108]
  |  Branch (1381:5): [True: 108, False: 0]
  ------------------
 1382|       |
 1383|    108|    if (LZWDecoderState(tif)->dec_codetab)
  ------------------
  |  |  164|    108|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  |  Branch (1383:9): [True: 91, False: 17]
  ------------------
 1384|     91|        _TIFFfreeExt(tif, LZWDecoderState(tif)->dec_codetab);
  ------------------
  |  |  164|     91|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     91|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1385|       |
 1386|    108|    if (LZWEncoderState(tif)->enc_hashtab)
  ------------------
  |  |  165|    108|#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    108|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  |  Branch (1386:9): [True: 0, False: 108]
  ------------------
 1387|      0|        _TIFFfreeExt(tif, LZWEncoderState(tif)->enc_hashtab);
  ------------------
  |  |  165|      0|#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|      0|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1388|       |
 1389|    108|    _TIFFfreeExt(tif, tif->tif_data);
 1390|    108|    tif->tif_data = NULL;
 1391|       |
 1392|    108|    _TIFFSetDefaultCompressionState(tif);
 1393|    108|}

TIFFInitNeXT:
  187|     16|{
  188|     16|    (void)scheme;
  189|     16|    tif->tif_predecode = NeXTPreDecode;
  190|     16|    tif->tif_decoderow = NeXTDecode;
  191|     16|    tif->tif_decodestrip = NeXTDecode;
  192|     16|    tif->tif_decodetile = NeXTDecode;
  193|     16|    return (1);
  194|     16|}
tif_next.c:NeXTPreDecode:
  172|     12|{
  173|     12|    static const char module[] = "NeXTPreDecode";
  174|     12|    TIFFDirectory *td = &tif->tif_dir;
  175|     12|    (void)s;
  176|       |
  177|     12|    if (td->td_bitspersample != 2)
  ------------------
  |  Branch (177:9): [True: 0, False: 12]
  ------------------
  178|      0|    {
  179|      0|        TIFFErrorExtR(tif, module, "Unsupported BitsPerSample = %" PRIu16,
  180|      0|                      td->td_bitspersample);
  181|      0|        return (0);
  182|      0|    }
  183|     12|    return (1);
  184|     12|}
tif_next.c:NeXTDecode:
   59|     12|{
   60|     12|    static const char module[] = "NeXTDecode";
   61|     12|    unsigned char *bp, *op;
   62|     12|    tmsize_t cc;
   63|     12|    uint8_t *row;
   64|     12|    tmsize_t scanline, n;
   65|       |
   66|     12|    (void)s;
   67|       |    /*
   68|       |     * Each scanline is assumed to start off as all
   69|       |     * white (we assume a PhotometricInterpretation
   70|       |     * of ``min-is-black'').
   71|       |     */
   72|   316k|    for (op = (unsigned char *)buf, cc = occ; cc-- > 0;)
  ------------------
  |  Branch (72:47): [True: 316k, False: 12]
  ------------------
   73|   316k|        *op++ = 0xff;
   74|       |
   75|     12|    bp = (unsigned char *)tif->tif_rawcp;
   76|     12|    cc = tif->tif_rawcc;
   77|     12|    scanline = tif->tif_dir.td_scanlinesize;
   78|     12|    if (occ % scanline)
  ------------------
  |  Branch (78:9): [True: 0, False: 12]
  ------------------
   79|      0|    {
   80|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
   81|      0|        return (0);
   82|      0|    }
   83|   100k|    for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline)
  ------------------
  |  Branch (83:21): [True: 100k, False: 0]
  |  Branch (83:31): [True: 100k, False: 3]
  ------------------
   84|   100k|    {
   85|   100k|        n = *bp++;
   86|   100k|        cc--;
   87|   100k|        switch (n)
   88|   100k|        {
   89|  50.9k|            case LITERALROW:
  ------------------
  |  |   55|  50.9k|#define LITERALROW 0x00
  ------------------
  |  Branch (89:13): [True: 50.9k, False: 49.3k]
  ------------------
   90|       |                /*
   91|       |                 * The entire scanline is given as literal values.
   92|       |                 */
   93|  50.9k|                if (cc < scanline)
  ------------------
  |  Branch (93:21): [True: 0, False: 50.9k]
  ------------------
   94|      0|                    goto bad;
   95|  50.9k|                _TIFFmemcpy(row, bp, scanline);
   96|  50.9k|                bp += scanline;
   97|  50.9k|                cc -= scanline;
   98|  50.9k|                break;
   99|     36|            case LITERALSPAN:
  ------------------
  |  |   56|     36|#define LITERALSPAN 0x40
  ------------------
  |  Branch (99:13): [True: 36, False: 100k]
  ------------------
  100|     36|            {
  101|     36|                tmsize_t off;
  102|       |                /*
  103|       |                 * The scanline has a literal span that begins at some
  104|       |                 * offset.
  105|       |                 */
  106|     36|                if (cc < 4)
  ------------------
  |  Branch (106:21): [True: 0, False: 36]
  ------------------
  107|      0|                    goto bad;
  108|     36|                off = (bp[0] * 256) + bp[1];
  109|     36|                n = (bp[2] * 256) + bp[3];
  110|     36|                if (cc < 4 + n || off + n > scanline)
  ------------------
  |  Branch (110:21): [True: 0, False: 36]
  |  Branch (110:35): [True: 8, False: 28]
  ------------------
  111|      8|                    goto bad;
  112|     28|                _TIFFmemcpy(row + off, bp + 4, n);
  113|     28|                bp += 4 + n;
  114|     28|                cc -= 4 + n;
  115|     28|                break;
  116|     36|            }
  117|  49.3k|            default:
  ------------------
  |  Branch (117:13): [True: 49.3k, False: 50.9k]
  ------------------
  118|  49.3k|            {
  119|  49.3k|                uint32_t npixels = 0, grey;
  120|  49.3k|                tmsize_t op_offset = 0;
  121|  49.3k|                uint32_t imagewidth = tif->tif_dir.td_imagewidth;
  122|  49.3k|                if (isTiled(tif))
  ------------------
  |  |  278|  49.3k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  49.3k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 49.3k]
  |  |  ------------------
  ------------------
  123|      0|                    imagewidth = tif->tif_dir.td_tilewidth;
  124|       |
  125|       |                /*
  126|       |                 * The scanline is composed of a sequence of constant
  127|       |                 * color ``runs''.  We shift into ``run mode'' and
  128|       |                 * interpret bytes as codes of the form
  129|       |                 * <color><npixels> until we've filled the scanline.
  130|       |                 */
  131|  49.3k|                op = row;
  132|  49.3k|                for (;;)
  133|  57.5k|                {
  134|  57.5k|                    grey = (uint32_t)((n >> 6) & 0x3);
  135|  57.5k|                    n &= 0x3f;
  136|       |                    /*
  137|       |                     * Ensure the run does not exceed the scanline
  138|       |                     * bounds, potentially resulting in a security
  139|       |                     * issue.
  140|       |                     */
  141|   205k|                    while (n-- > 0 && npixels < imagewidth &&
  ------------------
  |  Branch (141:28): [True: 196k, False: 8.83k]
  |  Branch (141:39): [True: 148k, False: 48.6k]
  ------------------
  142|   148k|                           op_offset < scanline)
  ------------------
  |  Branch (142:28): [True: 148k, False: 0]
  ------------------
  143|   148k|                        SETPIXEL(op, grey);
  ------------------
  |  |   34|   148k|    {                                                                          \
  |  |   35|   148k|        switch (npixels++ & 3)                                                 \
  |  |   36|   148k|        {                                                                      \
  |  |   37|  49.3k|            case 0:                                                            \
  |  |  ------------------
  |  |  |  Branch (37:13): [True: 49.3k, False: 98.7k]
  |  |  ------------------
  |  |   38|  49.3k|                op[0] = (unsigned char)((v) << 6);                             \
  |  |   39|  49.3k|                break;                                                         \
  |  |   40|  49.3k|            case 1:                                                            \
  |  |  ------------------
  |  |  |  Branch (40:13): [True: 49.3k, False: 98.7k]
  |  |  ------------------
  |  |   41|  49.3k|                op[0] |= (unsigned char)((v) << 4);                            \
  |  |   42|  49.3k|                break;                                                         \
  |  |   43|  49.3k|            case 2:                                                            \
  |  |  ------------------
  |  |  |  Branch (43:13): [True: 49.3k, False: 98.7k]
  |  |  ------------------
  |  |   44|  49.3k|                op[0] |= (unsigned char)((v) << 2);                            \
  |  |   45|  49.3k|                break;                                                         \
  |  |   46|      0|            case 3:                                                            \
  |  |  ------------------
  |  |  |  Branch (46:13): [True: 0, False: 148k]
  |  |  ------------------
  |  |   47|      0|                *op++ |= (unsigned char)(v);                                   \
  |  |   48|      0|                op_offset++;                                                   \
  |  |   49|      0|                break;                                                         \
  |  |   50|      0|            default:                                                           \
  |  |  ------------------
  |  |  |  Branch (50:13): [True: 0, False: 148k]
  |  |  ------------------
  |  |   51|      0|                break;                                                         \
  |  |   52|   148k|        }                                                                      \
  |  |   53|   148k|    }
  ------------------
  144|  57.5k|                    if (npixels >= imagewidth)
  ------------------
  |  Branch (144:25): [True: 49.3k, False: 8.15k]
  ------------------
  145|  49.3k|                        break;
  146|  8.15k|                    if (op_offset >= scanline)
  ------------------
  |  Branch (146:25): [True: 0, False: 8.15k]
  ------------------
  147|      0|                    {
  148|      0|                        TIFFErrorExtR(tif, module,
  149|      0|                                      "Invalid data for scanline %" PRIu32,
  150|      0|                                      tif->tif_dir.td_row);
  151|      0|                        return (0);
  152|      0|                    }
  153|  8.15k|                    if (cc == 0)
  ------------------
  |  Branch (153:25): [True: 1, False: 8.15k]
  ------------------
  154|      1|                        goto bad;
  155|  8.15k|                    n = *bp++;
  156|  8.15k|                    cc--;
  157|  8.15k|                }
  158|  49.3k|                break;
  159|  49.3k|            }
  160|   100k|        }
  161|   100k|    }
  162|      3|    tif->tif_rawcp = (uint8_t *)bp;
  163|      3|    tif->tif_rawcc = cc;
  164|      3|    return (1);
  165|      9|bad:
  166|       |    TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
  167|      9|                  tif->tif_dir.td_row);
  168|      9|    return (0);
  169|     12|}

TIFFInitOJPEG:
  454|  1.42k|{
  455|  1.42k|    static const char module[] = "TIFFInitOJPEG";
  456|  1.42k|    OJPEGState *sp;
  457|       |
  458|  1.42k|    (void)scheme;
  459|  1.42k|    assert(scheme == COMPRESSION_OJPEG);
  ------------------
  |  Branch (459:5): [True: 0, False: 1.42k]
  |  Branch (459:5): [True: 1.42k, False: 0]
  ------------------
  460|       |
  461|       |    /*
  462|       |     * Merge codec-specific tag information.
  463|       |     */
  464|  1.42k|    if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields)))
  ------------------
  |  |  339|  1.42k|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (464:9): [True: 0, False: 1.42k]
  ------------------
  465|      0|    {
  466|      0|        TIFFErrorExtR(tif, module,
  467|      0|                      "Merging Old JPEG codec-specific tags failed");
  468|      0|        return 0;
  469|      0|    }
  470|       |
  471|       |    /* state block */
  472|  1.42k|    sp = (OJPEGState *)_TIFFmallocExt(tif, sizeof(OJPEGState));
  473|  1.42k|    if (sp == NULL)
  ------------------
  |  Branch (473:9): [True: 0, False: 1.42k]
  ------------------
  474|      0|    {
  475|      0|        TIFFErrorExtR(tif, module, "No space for OJPEG state block");
  476|      0|        return (0);
  477|      0|    }
  478|  1.42k|    _TIFFmemset(sp, 0, sizeof(OJPEGState));
  479|  1.42k|    sp->tif = tif;
  480|  1.42k|    sp->jpeg_proc = 1;
  481|  1.42k|    sp->subsampling_hor = 2;
  482|  1.42k|    sp->subsampling_ver = 2;
  483|  1.42k|    TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, 2, 2);
  ------------------
  |  |  388|  1.42k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  484|       |    /* tif codec methods */
  485|  1.42k|    tif->tif_fixuptags = OJPEGFixupTags;
  486|  1.42k|    tif->tif_setupdecode = OJPEGSetupDecode;
  487|  1.42k|    tif->tif_predecode = OJPEGPreDecode;
  488|  1.42k|    tif->tif_postdecode = OJPEGPostDecode;
  489|  1.42k|    tif->tif_decoderow = OJPEGDecode;
  490|  1.42k|    tif->tif_decodestrip = OJPEGDecode;
  491|  1.42k|    tif->tif_decodetile = OJPEGDecode;
  492|  1.42k|    tif->tif_setupencode = OJPEGSetupEncode;
  493|  1.42k|    tif->tif_preencode = OJPEGPreEncode;
  494|  1.42k|    tif->tif_postencode = OJPEGPostEncode;
  495|  1.42k|    tif->tif_encoderow = OJPEGEncode;
  496|  1.42k|    tif->tif_encodestrip = OJPEGEncode;
  497|  1.42k|    tif->tif_encodetile = OJPEGEncode;
  498|  1.42k|    tif->tif_cleanup = OJPEGCleanup;
  499|  1.42k|    tif->tif_data = (uint8_t *)sp;
  500|       |    /* tif tag methods */
  501|  1.42k|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
  502|  1.42k|    tif->tif_tagmethods.vgetfield = OJPEGVGetField;
  503|  1.42k|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
  504|  1.42k|    tif->tif_tagmethods.vsetfield = OJPEGVSetField;
  505|  1.42k|    sp->printdir = tif->tif_tagmethods.printdir;
  506|  1.42k|    tif->tif_tagmethods.printdir = OJPEGPrintDir;
  507|       |    /* Some OJPEG files don't have strip or tile offsets or bytecounts tags.
  508|       |       Some others do, but have totally meaningless or corrupt values
  509|       |       in these tags. In these cases, the JpegInterchangeFormat stream is
  510|       |       reliable. In any case, this decoder reads the compressed data itself,
  511|       |       from the most reliable locations, and we need to notify encapsulating
  512|       |       LibTiff not to read raw strips or tiles for us. */
  513|  1.42k|    tif->tif_flags |= TIFF_NOREADRAW;
  ------------------
  |  |  138|  1.42k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  514|  1.42k|    return (1);
  515|  1.42k|}
tif_ojpeg.c:OJPEGVGetField:
  518|  27.0k|{
  519|  27.0k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  520|  27.0k|    switch (tag)
  521|  27.0k|    {
  522|      0|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|      0|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (522:9): [True: 0, False: 27.0k]
  ------------------
  523|      0|            *va_arg(ap, uint64_t *) = (uint64_t)sp->jpeg_interchange_format;
  524|      0|            break;
  525|      0|        case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|      0|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (525:9): [True: 0, False: 27.0k]
  ------------------
  526|      0|            *va_arg(ap, uint64_t *) =
  527|      0|                (uint64_t)sp->jpeg_interchange_format_length;
  528|      0|            break;
  529|  9.89k|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|  9.89k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (529:9): [True: 9.89k, False: 17.1k]
  ------------------
  530|  9.89k|            if (sp->subsamplingcorrect_done == 0)
  ------------------
  |  Branch (530:17): [True: 617, False: 9.27k]
  ------------------
  531|    617|                OJPEGSubsamplingCorrect(tif);
  532|  9.89k|            *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_hor;
  533|  9.89k|            *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_ver;
  534|  9.89k|            break;
  535|      0|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|      0|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (535:9): [True: 0, False: 27.0k]
  ------------------
  536|      0|            *va_arg(ap, uint32_t *) = (uint32_t)sp->qtable_offset_count;
  537|      0|            *va_arg(ap, const void **) = (const void *)sp->qtable_offset;
  538|      0|            break;
  539|      0|        case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|      0|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (539:9): [True: 0, False: 27.0k]
  ------------------
  540|      0|            *va_arg(ap, uint32_t *) = (uint32_t)sp->dctable_offset_count;
  541|      0|            *va_arg(ap, const void **) = (const void *)sp->dctable_offset;
  542|      0|            break;
  543|      0|        case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|      0|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (543:9): [True: 0, False: 27.0k]
  ------------------
  544|      0|            *va_arg(ap, uint32_t *) = (uint32_t)sp->actable_offset_count;
  545|      0|            *va_arg(ap, const void **) = (const void *)sp->actable_offset;
  546|      0|            break;
  547|      0|        case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|      0|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (547:9): [True: 0, False: 27.0k]
  ------------------
  548|      0|            *va_arg(ap, uint16_t *) = (uint16_t)sp->jpeg_proc;
  549|      0|            break;
  550|      0|        case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|      0|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (550:9): [True: 0, False: 27.0k]
  ------------------
  551|      0|            *va_arg(ap, uint16_t *) = sp->restart_interval;
  552|      0|            break;
  553|  17.1k|        default:
  ------------------
  |  Branch (553:9): [True: 17.1k, False: 9.89k]
  ------------------
  554|  17.1k|            return (*sp->vgetparent)(tif, tag, ap);
  555|  27.0k|    }
  556|  9.89k|    return (1);
  557|  27.0k|}
tif_ojpeg.c:OJPEGSubsamplingCorrect:
 1082|  1.34k|{
 1083|  1.34k|    static const char module[] = "OJPEGSubsamplingCorrect";
 1084|  1.34k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1085|  1.34k|    uint8_t mh;
 1086|  1.34k|    uint8_t mv;
 1087|       |
 1088|  1.34k|    assert(sp->subsamplingcorrect_done == 0);
  ------------------
  |  Branch (1088:5): [True: 0, False: 1.34k]
  |  Branch (1088:5): [True: 1.34k, False: 0]
  ------------------
 1089|  1.34k|    if ((tif->tif_dir.td_samplesperpixel != 3) ||
  ------------------
  |  Branch (1089:9): [True: 385, False: 961]
  ------------------
 1090|    961|        ((tif->tif_dir.td_photometric != PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|    961|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1090:10): [True: 96, False: 865]
  ------------------
 1091|     96|         (tif->tif_dir.td_photometric != PHOTOMETRIC_ITULAB)))
  ------------------
  |  |  230|     96|#define PHOTOMETRIC_ITULAB 10              /* ITU L*a*b* */
  ------------------
  |  Branch (1091:10): [True: 86, False: 10]
  ------------------
 1092|    471|    {
 1093|    471|        if (sp->subsampling_tag != 0)
  ------------------
  |  Branch (1093:13): [True: 0, False: 471]
  ------------------
 1094|      0|            TIFFWarningExtR(tif, module,
 1095|      0|                            "Subsampling tag not appropriate for this "
 1096|      0|                            "Photometric and/or SamplesPerPixel");
 1097|    471|        sp->subsampling_hor = 1;
 1098|    471|        sp->subsampling_ver = 1;
 1099|    471|        sp->subsampling_force_desubsampling_inside_decompression = 0;
 1100|    471|    }
 1101|    875|    else
 1102|    875|    {
 1103|    875|        sp->subsamplingcorrect_done = 1;
 1104|    875|        mh = sp->subsampling_hor;
 1105|    875|        mv = sp->subsampling_ver;
 1106|    875|        sp->subsamplingcorrect = 1;
 1107|    875|        OJPEGReadHeaderInfoSec(tif);
 1108|    875|        if (sp->subsampling_force_desubsampling_inside_decompression != 0)
  ------------------
  |  Branch (1108:13): [True: 66, False: 809]
  ------------------
 1109|     66|        {
 1110|     66|            sp->subsampling_hor = 1;
 1111|     66|            sp->subsampling_ver = 1;
 1112|     66|        }
 1113|    875|        sp->subsamplingcorrect = 0;
 1114|    875|        if (((sp->subsampling_hor != mh) || (sp->subsampling_ver != mv)) &&
  ------------------
  |  Branch (1114:14): [True: 71, False: 804]
  |  Branch (1114:45): [True: 3, False: 801]
  ------------------
 1115|     74|            (sp->subsampling_force_desubsampling_inside_decompression == 0))
  ------------------
  |  Branch (1115:13): [True: 8, False: 66]
  ------------------
 1116|      8|        {
 1117|      8|            if (sp->subsampling_tag == 0)
  ------------------
  |  Branch (1117:17): [True: 8, False: 0]
  ------------------
 1118|      8|                TIFFWarningExtR(
 1119|      8|                    tif, module,
 1120|      8|                    "Subsampling tag is not set, yet subsampling inside JPEG "
 1121|      8|                    "data [%" PRIu8 ",%" PRIu8
 1122|      8|                    "] does not match default values [2,2]; assuming "
 1123|      8|                    "subsampling inside JPEG data is correct",
 1124|      8|                    sp->subsampling_hor, sp->subsampling_ver);
 1125|      0|            else
 1126|      0|                TIFFWarningExtR(
 1127|      0|                    tif, module,
 1128|      0|                    "Subsampling inside JPEG data [%" PRIu8 ",%" PRIu8
 1129|      0|                    "] does not match subsampling tag values [%" PRIu8
 1130|      0|                    ",%" PRIu8
 1131|      0|                    "]; assuming subsampling inside JPEG data is correct",
 1132|      0|                    sp->subsampling_hor, sp->subsampling_ver, mh, mv);
 1133|      8|        }
 1134|    875|        if (sp->subsampling_force_desubsampling_inside_decompression != 0)
  ------------------
  |  Branch (1134:13): [True: 66, False: 809]
  ------------------
 1135|     66|        {
 1136|     66|            if (sp->subsampling_tag == 0)
  ------------------
  |  Branch (1136:17): [True: 63, False: 3]
  ------------------
 1137|     63|                TIFFWarningExtR(
 1138|     63|                    tif, module,
 1139|     63|                    "Subsampling tag is not set, yet subsampling inside JPEG "
 1140|     63|                    "data does not match default values [2,2] (nor any other "
 1141|     63|                    "values allowed in TIFF); assuming subsampling inside JPEG "
 1142|     63|                    "data is correct and desubsampling inside JPEG "
 1143|     63|                    "decompression");
 1144|      3|            else
 1145|      3|                TIFFWarningExtR(
 1146|      3|                    tif, module,
 1147|      3|                    "Subsampling inside JPEG data does not match subsampling "
 1148|      3|                    "tag values [%" PRIu8 ",%" PRIu8
 1149|      3|                    "] (nor any other values allowed in TIFF); assuming "
 1150|      3|                    "subsampling inside JPEG data is correct and desubsampling "
 1151|      3|                    "inside JPEG decompression",
 1152|      3|                    mh, mv);
 1153|     66|        }
 1154|    875|        if (sp->subsampling_force_desubsampling_inside_decompression == 0)
  ------------------
  |  Branch (1154:13): [True: 809, False: 66]
  ------------------
 1155|    809|        {
 1156|    809|            if (sp->subsampling_hor < sp->subsampling_ver)
  ------------------
  |  Branch (1156:17): [True: 16, False: 793]
  ------------------
 1157|     16|                TIFFWarningExtR(tif, module,
 1158|     16|                                "Subsampling values [%" PRIu8 ",%" PRIu8
 1159|     16|                                "] are not allowed in TIFF",
 1160|     16|                                sp->subsampling_hor, sp->subsampling_ver);
 1161|    809|        }
 1162|    875|    }
 1163|  1.34k|    sp->subsamplingcorrect_done = 1;
 1164|  1.34k|}
tif_ojpeg.c:OJPEGReadHeaderInfoSec:
 1536|  42.9k|{
 1537|  42.9k|    static const char module[] = "OJPEGReadHeaderInfoSec";
 1538|  42.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1539|  42.9k|    uint8_t m;
 1540|  42.9k|    uint16_t n;
 1541|  42.9k|    uint8_t o;
 1542|  42.9k|    if (sp->file_size == 0)
  ------------------
  |  Branch (1542:9): [True: 1.12k, False: 41.8k]
  ------------------
 1543|  1.12k|        sp->file_size = TIFFGetFileSize(tif);
  ------------------
  |  |  289|  1.12k|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 1544|  42.9k|    if (sp->jpeg_interchange_format != 0)
  ------------------
  |  Branch (1544:9): [True: 227, False: 42.7k]
  ------------------
 1545|    227|    {
 1546|    227|        if (sp->jpeg_interchange_format >= sp->file_size)
  ------------------
  |  Branch (1546:13): [True: 1, False: 226]
  ------------------
 1547|      1|        {
 1548|      1|            sp->jpeg_interchange_format = 0;
 1549|      1|            sp->jpeg_interchange_format_length = 0;
 1550|      1|        }
 1551|    226|        else
 1552|    226|        {
 1553|    226|            if ((sp->jpeg_interchange_format_length == 0) ||
  ------------------
  |  Branch (1553:17): [True: 50, False: 176]
  ------------------
 1554|    176|                (sp->jpeg_interchange_format >
  ------------------
  |  Branch (1554:17): [True: 5, False: 171]
  ------------------
 1555|    176|                 UINT64_MAX - sp->jpeg_interchange_format_length) ||
 1556|    171|                (sp->jpeg_interchange_format +
  ------------------
  |  Branch (1556:17): [True: 4, False: 167]
  ------------------
 1557|    171|                     sp->jpeg_interchange_format_length >
 1558|    171|                 sp->file_size))
 1559|     59|                sp->jpeg_interchange_format_length =
 1560|     59|                    sp->file_size - sp->jpeg_interchange_format;
 1561|    226|        }
 1562|    227|    }
 1563|  42.9k|    sp->in_buffer_source = osibsNotSetYet;
 1564|  42.9k|    sp->in_buffer_next_strile = 0;
 1565|  42.9k|    sp->in_buffer_strile_count = tif->tif_dir.td_nstrips;
 1566|  42.9k|    sp->in_buffer_file_togo = 0;
 1567|  42.9k|    sp->in_buffer_togo = 0;
 1568|  42.9k|    do
 1569|  43.8k|    {
 1570|  43.8k|        if (OJPEGReadBytePeek(sp, &m) == 0)
  ------------------
  |  Branch (1570:13): [True: 3.35k, False: 40.4k]
  ------------------
 1571|  3.35k|            return (0);
 1572|  40.4k|        if (m != 255)
  ------------------
  |  Branch (1572:13): [True: 35.1k, False: 5.34k]
  ------------------
 1573|  35.1k|            break;
 1574|  5.34k|        OJPEGReadByteAdvance(sp);
 1575|  5.34k|        do
 1576|  7.07k|        {
 1577|  7.07k|            if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1577:17): [True: 0, False: 7.07k]
  ------------------
 1578|      0|                return (0);
 1579|  7.07k|        } while (m == 255);
  ------------------
  |  Branch (1579:18): [True: 1.73k, False: 5.34k]
  ------------------
 1580|  5.34k|        switch (m)
 1581|  5.34k|        {
 1582|      3|            case JPEG_MARKER_SOI:
  ------------------
  |  |  163|      3|#define JPEG_MARKER_SOI 0xD8
  ------------------
  |  Branch (1582:13): [True: 3, False: 5.33k]
  ------------------
 1583|       |                /* this type of marker has no data, and should be skipped */
 1584|      3|                break;
 1585|      0|            case JPEG_MARKER_COM:
  ------------------
  |  |  169|      0|#define JPEG_MARKER_COM 0xFE
  ------------------
  |  Branch (1585:13): [True: 0, False: 5.34k]
  ------------------
 1586|      0|            case JPEG_MARKER_APP0:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1586:13): [True: 0, False: 5.34k]
  ------------------
 1587|     72|            case JPEG_MARKER_APP0 + 1:
  ------------------
  |  |  168|     72|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1587:13): [True: 72, False: 5.26k]
  ------------------
 1588|     72|            case JPEG_MARKER_APP0 + 2:
  ------------------
  |  |  168|     72|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1588:13): [True: 0, False: 5.34k]
  ------------------
 1589|     75|            case JPEG_MARKER_APP0 + 3:
  ------------------
  |  |  168|     75|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1589:13): [True: 3, False: 5.33k]
  ------------------
 1590|     75|            case JPEG_MARKER_APP0 + 4:
  ------------------
  |  |  168|     75|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1590:13): [True: 0, False: 5.34k]
  ------------------
 1591|     79|            case JPEG_MARKER_APP0 + 5:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1591:13): [True: 4, False: 5.33k]
  ------------------
 1592|     79|            case JPEG_MARKER_APP0 + 6:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1592:13): [True: 0, False: 5.34k]
  ------------------
 1593|     79|            case JPEG_MARKER_APP0 + 7:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1593:13): [True: 0, False: 5.34k]
  ------------------
 1594|     79|            case JPEG_MARKER_APP0 + 8:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1594:13): [True: 0, False: 5.34k]
  ------------------
 1595|     79|            case JPEG_MARKER_APP0 + 9:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1595:13): [True: 0, False: 5.34k]
  ------------------
 1596|     79|            case JPEG_MARKER_APP0 + 10:
  ------------------
  |  |  168|     79|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1596:13): [True: 0, False: 5.34k]
  ------------------
 1597|    784|            case JPEG_MARKER_APP0 + 11:
  ------------------
  |  |  168|    784|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1597:13): [True: 705, False: 4.63k]
  ------------------
 1598|    792|            case JPEG_MARKER_APP0 + 12:
  ------------------
  |  |  168|    792|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1598:13): [True: 8, False: 5.33k]
  ------------------
 1599|    792|            case JPEG_MARKER_APP0 + 13:
  ------------------
  |  |  168|    792|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1599:13): [True: 0, False: 5.34k]
  ------------------
 1600|    792|            case JPEG_MARKER_APP0 + 14:
  ------------------
  |  |  168|    792|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1600:13): [True: 0, False: 5.34k]
  ------------------
 1601|    792|            case JPEG_MARKER_APP0 + 15:
  ------------------
  |  |  168|    792|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1601:13): [True: 0, False: 5.34k]
  ------------------
 1602|       |                /* this type of marker has data, but it has no use to us (and no
 1603|       |                 * place here) and should be skipped */
 1604|    792|                if (OJPEGReadWord(sp, &n) == 0)
  ------------------
  |  Branch (1604:21): [True: 0, False: 792]
  ------------------
 1605|      0|                    return (0);
 1606|    792|                if (n < 2)
  ------------------
  |  Branch (1606:21): [True: 8, False: 784]
  ------------------
 1607|      8|                {
 1608|      8|                    if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1608:25): [True: 4, False: 4]
  ------------------
 1609|      4|                        TIFFErrorExtR(tif, module, "Corrupt JPEG data");
 1610|      8|                    return (0);
 1611|      8|                }
 1612|    784|                if (n > 2)
  ------------------
  |  Branch (1612:21): [True: 784, False: 0]
  ------------------
 1613|    784|                    OJPEGReadSkip(sp, (uint16_t)(n - 2));
 1614|    784|                break;
 1615|      0|            case JPEG_MARKER_DRI:
  ------------------
  |  |  167|      0|#define JPEG_MARKER_DRI 0xDD
  ------------------
  |  Branch (1615:13): [True: 0, False: 5.34k]
  ------------------
 1616|      0|                if (OJPEGReadHeaderInfoSecStreamDri(tif) == 0)
  ------------------
  |  Branch (1616:21): [True: 0, False: 0]
  ------------------
 1617|      0|                    return (0);
 1618|      0|                break;
 1619|  3.34k|            case JPEG_MARKER_DQT:
  ------------------
  |  |  166|  3.34k|#define JPEG_MARKER_DQT 0xDB
  ------------------
  |  Branch (1619:13): [True: 3.34k, False: 1.99k]
  ------------------
 1620|  3.34k|                if (OJPEGReadHeaderInfoSecStreamDqt(tif) == 0)
  ------------------
  |  Branch (1620:21): [True: 3.32k, False: 24]
  ------------------
 1621|  3.32k|                    return (0);
 1622|     24|                break;
 1623|    111|            case JPEG_MARKER_DHT:
  ------------------
  |  |  161|    111|#define JPEG_MARKER_DHT 0xC4
  ------------------
  |  Branch (1623:13): [True: 111, False: 5.23k]
  ------------------
 1624|    111|                if (OJPEGReadHeaderInfoSecStreamDht(tif) == 0)
  ------------------
  |  Branch (1624:21): [True: 40, False: 71]
  ------------------
 1625|     40|                    return (0);
 1626|     71|                break;
 1627|    633|            case JPEG_MARKER_SOF0:
  ------------------
  |  |  158|    633|#define JPEG_MARKER_SOF0 0xC0
  ------------------
  |  Branch (1627:13): [True: 633, False: 4.70k]
  ------------------
 1628|    648|            case JPEG_MARKER_SOF1:
  ------------------
  |  |  159|    648|#define JPEG_MARKER_SOF1 0xC1
  ------------------
  |  Branch (1628:13): [True: 15, False: 5.32k]
  ------------------
 1629|    774|            case JPEG_MARKER_SOF3:
  ------------------
  |  |  160|    774|#define JPEG_MARKER_SOF3 0xC3
  ------------------
  |  Branch (1629:13): [True: 126, False: 5.21k]
  ------------------
 1630|    774|                if (OJPEGReadHeaderInfoSecStreamSof(tif, m) == 0)
  ------------------
  |  Branch (1630:21): [True: 699, False: 75]
  ------------------
 1631|    699|                    return (0);
 1632|     75|                if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1632:21): [True: 53, False: 22]
  ------------------
 1633|     53|                    return (1);
 1634|     22|                break;
 1635|    136|            case JPEG_MARKER_SOS:
  ------------------
  |  |  165|    136|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1635:13): [True: 136, False: 5.20k]
  ------------------
 1636|    136|                if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1636:21): [True: 4, False: 132]
  ------------------
 1637|      4|                    return (1);
 1638|    136|                assert(sp->plane_sample_offset == 0);
  ------------------
  |  Branch (1638:17): [True: 0, False: 132]
  |  Branch (1638:17): [True: 132, False: 0]
  ------------------
 1639|    132|                if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
  ------------------
  |  Branch (1639:21): [True: 132, False: 0]
  ------------------
 1640|    132|                    return (0);
 1641|      0|                break;
 1642|    180|            default:
  ------------------
  |  Branch (1642:13): [True: 180, False: 5.16k]
  ------------------
 1643|    180|                TIFFErrorExtR(tif, module,
 1644|    180|                              "Unknown marker type %" PRIu8 " in JPEG data", m);
 1645|    180|                return (0);
 1646|  5.34k|        }
 1647|  5.34k|    } while (m != JPEG_MARKER_SOS);
  ------------------
  |  |  165|    904|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1647:14): [True: 904, False: 0]
  ------------------
 1648|  35.1k|    if (sp->subsamplingcorrect)
  ------------------
  |  Branch (1648:9): [True: 344, False: 34.8k]
  ------------------
 1649|    344|        return (1);
 1650|  34.8k|    if (sp->sof_log == 0)
  ------------------
  |  Branch (1650:9): [True: 34.5k, False: 263]
  ------------------
 1651|  34.5k|    {
 1652|  34.5k|        if (OJPEGReadHeaderInfoSecTablesQTable(tif) == 0)
  ------------------
  |  Branch (1652:13): [True: 34.2k, False: 328]
  ------------------
 1653|  34.2k|            return (0);
 1654|    328|        sp->sof_marker_id = JPEG_MARKER_SOF0;
  ------------------
  |  |  158|    328|#define JPEG_MARKER_SOF0 0xC0
  ------------------
 1655|  1.25k|        for (o = 0; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1655:21): [True: 926, False: 328]
  ------------------
 1656|    926|            sp->sof_c[o] = (uint8_t)o;
 1657|    328|        sp->sof_hv[0] =
 1658|    328|            (uint8_t)((sp->subsampling_hor << 4) | sp->subsampling_ver);
 1659|    926|        for (o = 1; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1659:21): [True: 598, False: 328]
  ------------------
 1660|    598|            sp->sof_hv[o] = 17;
 1661|    328|        sp->sof_x = sp->strile_width;
 1662|    328|        sp->sof_y = sp->strile_length_total;
 1663|    328|        sp->sof_log = 1;
 1664|    328|        if (OJPEGReadHeaderInfoSecTablesDcTable(tif) == 0)
  ------------------
  |  Branch (1664:13): [True: 218, False: 110]
  ------------------
 1665|    218|            return (0);
 1666|    110|        if (OJPEGReadHeaderInfoSecTablesAcTable(tif) == 0)
  ------------------
  |  Branch (1666:13): [True: 42, False: 68]
  ------------------
 1667|     42|            return (0);
 1668|    184|        for (o = 1; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1668:21): [True: 116, False: 68]
  ------------------
 1669|    116|            sp->sos_cs[o] = o;
 1670|     68|    }
 1671|    331|    return (1);
 1672|  34.8k|}
tif_ojpeg.c:OJPEGReadBytePeek:
 2364|  43.8k|{
 2365|  43.8k|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2365:9): [True: 43.6k, False: 179]
  ------------------
 2366|  43.6k|    {
 2367|  43.6k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2367:13): [True: 3.35k, False: 40.3k]
  ------------------
 2368|  3.35k|            return (0);
 2369|  43.6k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2369:9): [True: 0, False: 40.3k]
  |  Branch (2369:9): [True: 40.3k, False: 0]
  ------------------
 2370|  40.3k|    }
 2371|  40.4k|    *byte = *(sp->in_buffer_cur);
 2372|  40.4k|    return (1);
 2373|  43.8k|}
tif_ojpeg.c:OJPEGReadBufferFill:
 2256|   128k|{
 2257|   128k|    uint16_t m;
 2258|   128k|    tmsize_t n;
 2259|       |    /* TODO: double-check: when subsamplingcorrect is set, no call to
 2260|       |     * TIFFErrorExt or TIFFWarningExt should be made in any other case, seek or
 2261|       |     * read errors should be passed through */
 2262|   128k|    do
 2263|  42.0M|    {
 2264|  42.0M|        if (sp->in_buffer_file_togo != 0)
  ------------------
  |  Branch (2264:13): [True: 115k, False: 41.9M]
  ------------------
 2265|   115k|        {
 2266|   115k|            if (sp->in_buffer_file_pos_log == 0)
  ------------------
  |  Branch (2266:17): [True: 97.3k, False: 17.6k]
  ------------------
 2267|  97.3k|            {
 2268|  97.3k|                TIFFSeekFile(sp->tif, sp->in_buffer_file_pos, SEEK_SET);
  ------------------
  |  |  287|  97.3k|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2269|  97.3k|                sp->in_buffer_file_pos_log = 1;
 2270|  97.3k|            }
 2271|   115k|            m = OJPEG_BUFFER;
  ------------------
  |  |  155|   115k|#define OJPEG_BUFFER 2048
  ------------------
 2272|   115k|            if ((uint64_t)m > sp->in_buffer_file_togo)
  ------------------
  |  Branch (2272:17): [True: 50.4k, False: 64.5k]
  ------------------
 2273|  50.4k|                m = (uint16_t)sp->in_buffer_file_togo;
 2274|   115k|            n = TIFFReadFile(sp->tif, sp->in_buffer, (tmsize_t)m);
  ------------------
  |  |  283|   115k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2275|   115k|            if (n <= 0)
  ------------------
  |  Branch (2275:17): [True: 0, False: 115k]
  ------------------
 2276|      0|                return (0);
 2277|   115k|            assert(n > 0);
  ------------------
  |  Branch (2277:13): [True: 0, False: 115k]
  |  Branch (2277:13): [True: 115k, False: 0]
  ------------------
 2278|   115k|            assert(n <= OJPEG_BUFFER);
  ------------------
  |  Branch (2278:13): [True: 0, False: 115k]
  |  Branch (2278:13): [True: 115k, False: 0]
  ------------------
 2279|   115k|            assert(n < 65536);
  ------------------
  |  Branch (2279:13): [True: 0, False: 115k]
  |  Branch (2279:13): [True: 115k, False: 0]
  ------------------
 2280|   115k|            assert((uint64_t)n <= sp->in_buffer_file_togo);
  ------------------
  |  Branch (2280:13): [True: 0, False: 115k]
  |  Branch (2280:13): [True: 115k, False: 0]
  ------------------
 2281|   115k|            m = (uint16_t)n;
 2282|   115k|            sp->in_buffer_togo = m;
 2283|   115k|            sp->in_buffer_cur = sp->in_buffer;
 2284|   115k|            sp->in_buffer_file_togo -= m;
 2285|   115k|            sp->in_buffer_file_pos += m;
 2286|   115k|            break;
 2287|   115k|        }
 2288|  41.9M|        sp->in_buffer_file_pos_log = 0;
 2289|  41.9M|        switch (sp->in_buffer_source)
 2290|  41.9M|        {
 2291|  42.9k|            case osibsNotSetYet:
  ------------------
  |  Branch (2291:13): [True: 42.9k, False: 41.8M]
  ------------------
 2292|  42.9k|                if (sp->jpeg_interchange_format != 0)
  ------------------
  |  Branch (2292:21): [True: 226, False: 42.7k]
  ------------------
 2293|    226|                {
 2294|    226|                    sp->in_buffer_file_pos = sp->jpeg_interchange_format;
 2295|    226|                    sp->in_buffer_file_togo =
 2296|    226|                        sp->jpeg_interchange_format_length;
 2297|    226|                }
 2298|  42.9k|                sp->in_buffer_source = osibsJpegInterchangeFormat;
 2299|  42.9k|                break;
 2300|  42.7k|            case osibsJpegInterchangeFormat:
  ------------------
  |  Branch (2300:13): [True: 42.7k, False: 41.8M]
  ------------------
 2301|  42.7k|                sp->in_buffer_source = osibsStrile;
 2302|  42.7k|                break;
 2303|  41.8M|            case osibsStrile:
  ------------------
  |  Branch (2303:13): [True: 41.8M, False: 96.7k]
  ------------------
 2304|  41.8M|                if (sp->in_buffer_next_strile == sp->in_buffer_strile_count)
  ------------------
  |  Branch (2304:21): [True: 10.4k, False: 41.7M]
  ------------------
 2305|  10.4k|                    sp->in_buffer_source = osibsEof;
 2306|  41.7M|                else
 2307|  41.7M|                {
 2308|  41.7M|                    int err = 0;
 2309|  41.7M|                    sp->in_buffer_file_pos = TIFFGetStrileOffsetWithErr(
 2310|  41.7M|                        sp->tif, sp->in_buffer_next_strile, &err);
 2311|  41.7M|                    if (err)
  ------------------
  |  Branch (2311:25): [True: 2.24k, False: 41.7M]
  ------------------
 2312|  2.24k|                        return 0;
 2313|  41.7M|                    if (sp->in_buffer_file_pos != 0)
  ------------------
  |  Branch (2313:25): [True: 1.25M, False: 40.5M]
  ------------------
 2314|  1.25M|                    {
 2315|  1.25M|                        uint64_t bytecount = TIFFGetStrileByteCountWithErr(
 2316|  1.25M|                            sp->tif, sp->in_buffer_next_strile, &err);
 2317|  1.25M|                        if (err)
  ------------------
  |  Branch (2317:29): [True: 556, False: 1.25M]
  ------------------
 2318|    556|                            return 0;
 2319|  1.25M|                        if (sp->in_buffer_file_pos >= sp->file_size)
  ------------------
  |  Branch (2319:29): [True: 1.19M, False: 59.3k]
  ------------------
 2320|  1.19M|                            sp->in_buffer_file_pos = 0;
 2321|  59.3k|                        else if (bytecount == 0)
  ------------------
  |  Branch (2321:34): [True: 735, False: 58.6k]
  ------------------
 2322|    735|                            sp->in_buffer_file_togo =
 2323|    735|                                sp->file_size - sp->in_buffer_file_pos;
 2324|  58.6k|                        else
 2325|  58.6k|                        {
 2326|  58.6k|                            sp->in_buffer_file_togo = bytecount;
 2327|  58.6k|                            if (sp->in_buffer_file_togo == 0)
  ------------------
  |  Branch (2327:33): [True: 0, False: 58.6k]
  ------------------
 2328|      0|                                sp->in_buffer_file_pos = 0;
 2329|  58.6k|                            else if (sp->in_buffer_file_pos >
  ------------------
  |  Branch (2329:38): [True: 3, False: 58.6k]
  ------------------
 2330|  58.6k|                                         UINT64_MAX - sp->in_buffer_file_togo ||
 2331|  58.6k|                                     sp->in_buffer_file_pos +
  ------------------
  |  Branch (2331:38): [True: 38.3k, False: 20.3k]
  ------------------
 2332|  58.6k|                                             sp->in_buffer_file_togo >
 2333|  58.6k|                                         sp->file_size)
 2334|  38.3k|                                sp->in_buffer_file_togo =
 2335|  38.3k|                                    sp->file_size - sp->in_buffer_file_pos;
 2336|  58.6k|                        }
 2337|  1.25M|                    }
 2338|  41.7M|                    sp->in_buffer_next_strile++;
 2339|  41.7M|                }
 2340|  41.8M|                break;
 2341|  41.8M|            case osibsEof:
  ------------------
  |  Branch (2341:13): [True: 11.1k, False: 41.8M]
  ------------------
 2342|  11.1k|            default:
  ------------------
  |  Branch (2342:13): [True: 0, False: 41.9M]
  ------------------
 2343|  11.1k|                return (0);
 2344|  41.9M|        }
 2345|  41.9M|    } while (1);
  ------------------
  |  Branch (2345:14): [True: 41.8M, Folded]
  ------------------
 2346|   115k|    return (1);
 2347|   128k|}
tif_ojpeg.c:OJPEGReadByteAdvance:
 2376|  5.34k|{
 2377|  5.34k|    assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2377:5): [True: 0, False: 5.34k]
  |  Branch (2377:5): [True: 5.34k, False: 0]
  ------------------
 2378|  5.34k|    sp->in_buffer_cur++;
 2379|  5.34k|    sp->in_buffer_togo--;
 2380|  5.34k|}
tif_ojpeg.c:OJPEGReadByte:
 2350|  40.2M|{
 2351|  40.2M|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2351:9): [True: 49.5k, False: 40.2M]
  ------------------
 2352|  49.5k|    {
 2353|  49.5k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2353:13): [True: 9.53k, False: 39.9k]
  ------------------
 2354|  9.53k|            return (0);
 2355|  49.5k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2355:9): [True: 0, False: 39.9k]
  |  Branch (2355:9): [True: 39.9k, False: 0]
  ------------------
 2356|  39.9k|    }
 2357|  40.2M|    *byte = *(sp->in_buffer_cur);
 2358|  40.2M|    sp->in_buffer_cur++;
 2359|  40.2M|    sp->in_buffer_togo--;
 2360|  40.2M|    return (1);
 2361|  40.2M|}
tif_ojpeg.c:OJPEGReadWord:
 2383|  11.6k|{
 2384|  11.6k|    uint8_t m;
 2385|  11.6k|    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (2385:9): [True: 0, False: 11.6k]
  ------------------
 2386|      0|        return (0);
 2387|  11.6k|    *word = (uint16_t)(m << 8);
 2388|  11.6k|    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (2388:9): [True: 11, False: 11.6k]
  ------------------
 2389|     11|        return (0);
 2390|  11.6k|    *word |= m;
 2391|  11.6k|    return (1);
 2392|  11.6k|}
tif_ojpeg.c:OJPEGReadSkip:
 2423|  1.12k|{
 2424|  1.12k|    uint16_t m;
 2425|  1.12k|    uint16_t n;
 2426|  1.12k|    m = len;
 2427|  1.12k|    n = m;
 2428|  1.12k|    if (n > sp->in_buffer_togo)
  ------------------
  |  Branch (2428:9): [True: 760, False: 367]
  ------------------
 2429|    760|        n = sp->in_buffer_togo;
 2430|  1.12k|    sp->in_buffer_cur += n;
 2431|  1.12k|    sp->in_buffer_togo = (uint16_t)(sp->in_buffer_togo - n);
 2432|  1.12k|    m = (uint16_t)(m - n);
 2433|  1.12k|    if (m > 0)
  ------------------
  |  Branch (2433:9): [True: 760, False: 367]
  ------------------
 2434|    760|    {
 2435|    760|        assert(sp->in_buffer_togo == 0);
  ------------------
  |  Branch (2435:9): [True: 0, False: 760]
  |  Branch (2435:9): [True: 760, False: 0]
  ------------------
 2436|    760|        n = m;
 2437|    760|        if ((uint64_t)n > sp->in_buffer_file_togo)
  ------------------
  |  Branch (2437:13): [True: 715, False: 45]
  ------------------
 2438|    715|            n = (uint16_t)sp->in_buffer_file_togo;
 2439|    760|        sp->in_buffer_file_pos += n;
 2440|    760|        sp->in_buffer_file_togo -= n;
 2441|    760|        sp->in_buffer_file_pos_log = 0;
 2442|       |        /* we don't skip past jpeginterchangeformat/strile block...
 2443|       |         * if that is asked from us, we're dealing with totally bazurk
 2444|       |         * data anyway, and we've not seen this happening on any
 2445|       |         * testfile, so we might as well likely cause some other
 2446|       |         * meaningless error to be passed at some later time
 2447|       |         */
 2448|    760|    }
 2449|  1.12k|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamDqt:
 1695|  3.34k|{
 1696|       |    /* this is a table marker, and it is to be saved as a whole for exact
 1697|       |     * pushing on the jpeg stream later on */
 1698|  3.34k|    static const char module[] = "OJPEGReadHeaderInfoSecStreamDqt";
 1699|  3.34k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1700|  3.34k|    uint16_t m;
 1701|  3.34k|    uint32_t na;
 1702|  3.34k|    uint8_t *nb;
 1703|  3.34k|    uint8_t o;
 1704|  3.34k|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (1704:9): [True: 0, False: 3.34k]
  ------------------
 1705|      0|        return (0);
 1706|  3.34k|    if (m <= 2)
  ------------------
  |  Branch (1706:9): [True: 0, False: 3.34k]
  ------------------
 1707|      0|    {
 1708|      0|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1708:13): [True: 0, False: 0]
  ------------------
 1709|      0|            TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
 1710|      0|        return (0);
 1711|      0|    }
 1712|  3.34k|    if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1712:9): [True: 24, False: 3.32k]
  ------------------
 1713|     24|        OJPEGReadSkip(sp, (uint16_t)(m - 2));
 1714|  3.32k|    else
 1715|  3.32k|    {
 1716|  3.32k|        m = (uint16_t)(m - 2);
 1717|  3.32k|        do
 1718|  6.30k|        {
 1719|  6.30k|            if (m < 65)
  ------------------
  |  Branch (1719:17): [True: 8, False: 6.29k]
  ------------------
 1720|      8|            {
 1721|      8|                TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
 1722|      8|                return (0);
 1723|      8|            }
 1724|  6.29k|            na = sizeof(uint32_t) + 69;
 1725|  6.29k|            nb = (uint8_t *)_TIFFmallocExt(tif, na);
 1726|  6.29k|            if (nb == 0)
  ------------------
  |  Branch (1726:17): [True: 0, False: 6.29k]
  ------------------
 1727|      0|            {
 1728|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1729|      0|                return (0);
 1730|      0|            }
 1731|  6.29k|            *(uint32_t *)nb = na;
 1732|  6.29k|            nb[sizeof(uint32_t)] = 255;
 1733|  6.29k|            nb[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
  ------------------
  |  |  166|  6.29k|#define JPEG_MARKER_DQT 0xDB
  ------------------
 1734|  6.29k|            nb[sizeof(uint32_t) + 2] = 0;
 1735|  6.29k|            nb[sizeof(uint32_t) + 3] = 67;
 1736|  6.29k|            if (OJPEGReadBlock(sp, 65, &nb[sizeof(uint32_t) + 4]) == 0)
  ------------------
  |  Branch (1736:17): [True: 0, False: 6.29k]
  ------------------
 1737|      0|            {
 1738|      0|                _TIFFfreeExt(tif, nb);
 1739|      0|                return (0);
 1740|      0|            }
 1741|  6.29k|            o = nb[sizeof(uint32_t) + 4] & 15;
 1742|  6.29k|            if (3 < o)
  ------------------
  |  Branch (1742:17): [True: 3.31k, False: 2.98k]
  ------------------
 1743|  3.31k|            {
 1744|  3.31k|                TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
 1745|  3.31k|                _TIFFfreeExt(tif, nb);
 1746|  3.31k|                return (0);
 1747|  3.31k|            }
 1748|  2.98k|            if (sp->qtable[o] != 0)
  ------------------
  |  Branch (1748:17): [True: 2.94k, False: 37]
  ------------------
 1749|  2.94k|                _TIFFfreeExt(tif, sp->qtable[o]);
 1750|  2.98k|            sp->qtable[o] = nb;
 1751|  2.98k|            m = (uint16_t)(m - 65);
 1752|  2.98k|        } while (m > 0);
  ------------------
  |  Branch (1752:18): [True: 2.98k, False: 0]
  ------------------
 1753|  3.32k|    }
 1754|     24|    return (1);
 1755|  3.34k|}
tif_ojpeg.c:OJPEGReadBlock:
 2395|  6.35k|{
 2396|  6.35k|    uint16_t mlen;
 2397|  6.35k|    uint8_t *mmem;
 2398|  6.35k|    uint16_t n;
 2399|  6.35k|    assert(len > 0);
  ------------------
  |  Branch (2399:5): [True: 0, False: 6.35k]
  |  Branch (2399:5): [True: 6.35k, False: 0]
  ------------------
 2400|  6.35k|    mlen = len;
 2401|  6.35k|    mmem = (uint8_t *)mem;
 2402|  6.35k|    do
 2403|  6.43k|    {
 2404|  6.43k|        if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2404:13): [True: 83, False: 6.35k]
  ------------------
 2405|     83|        {
 2406|     83|            if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2406:17): [True: 3, False: 80]
  ------------------
 2407|      3|                return (0);
 2408|     83|            assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2408:13): [True: 0, False: 80]
  |  Branch (2408:13): [True: 80, False: 0]
  ------------------
 2409|     80|        }
 2410|  6.43k|        n = mlen;
 2411|  6.43k|        if (n > sp->in_buffer_togo)
  ------------------
  |  Branch (2411:13): [True: 83, False: 6.35k]
  ------------------
 2412|     83|            n = sp->in_buffer_togo;
 2413|  6.43k|        _TIFFmemcpy(mmem, sp->in_buffer_cur, n);
 2414|  6.43k|        sp->in_buffer_cur += n;
 2415|  6.43k|        sp->in_buffer_togo = (uint16_t)(sp->in_buffer_togo - n);
 2416|  6.43k|        mlen = (uint16_t)(mlen - n);
 2417|  6.43k|        mmem += n;
 2418|  6.43k|    } while (mlen > 0);
  ------------------
  |  Branch (2418:14): [True: 83, False: 6.35k]
  ------------------
 2419|  6.35k|    return (1);
 2420|  6.35k|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamDht:
 1758|    111|{
 1759|       |    /* this is a table marker, and it is to be saved as a whole for exact
 1760|       |     * pushing on the jpeg stream later on */
 1761|       |    /* TODO: the following assumes there is only one table in this marker... but
 1762|       |     * i'm not quite sure that assumption is guaranteed correct */
 1763|    111|    static const char module[] = "OJPEGReadHeaderInfoSecStreamDht";
 1764|    111|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1765|    111|    uint16_t m;
 1766|    111|    uint32_t na;
 1767|    111|    uint8_t *nb;
 1768|    111|    uint8_t o;
 1769|    111|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (1769:9): [True: 0, False: 111]
  ------------------
 1770|      0|        return (0);
 1771|    111|    if (m <= 2)
  ------------------
  |  Branch (1771:9): [True: 16, False: 95]
  ------------------
 1772|     16|    {
 1773|     16|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1773:13): [True: 13, False: 3]
  ------------------
 1774|     13|            TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
 1775|     16|        return (0);
 1776|     16|    }
 1777|     95|    if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1777:9): [True: 36, False: 59]
  ------------------
 1778|     36|    {
 1779|     36|        OJPEGReadSkip(sp, (uint16_t)(m - 2));
 1780|     36|    }
 1781|     59|    else
 1782|     59|    {
 1783|     59|        na = (uint32_t)(sizeof(uint32_t) + 2 + m);
 1784|     59|        nb = (uint8_t *)_TIFFmallocExt(tif, na);
 1785|     59|        if (nb == 0)
  ------------------
  |  Branch (1785:13): [True: 0, False: 59]
  ------------------
 1786|      0|        {
 1787|      0|            TIFFErrorExtR(tif, module, "Out of memory");
 1788|      0|            return (0);
 1789|      0|        }
 1790|     59|        *(uint32_t *)nb = na;
 1791|     59|        nb[sizeof(uint32_t)] = 255;
 1792|     59|        nb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
  ------------------
  |  |  161|     59|#define JPEG_MARKER_DHT 0xC4
  ------------------
 1793|     59|        nb[sizeof(uint32_t) + 2] = (uint8_t)(m >> 8);
 1794|     59|        nb[sizeof(uint32_t) + 3] = (uint8_t)(m & 255);
 1795|     59|        if (OJPEGReadBlock(sp, (uint16_t)(m - 2), &nb[sizeof(uint32_t) + 4]) ==
  ------------------
  |  Branch (1795:13): [True: 3, False: 56]
  ------------------
 1796|     59|            0)
 1797|      3|        {
 1798|      3|            _TIFFfreeExt(tif, nb);
 1799|      3|            return (0);
 1800|      3|        }
 1801|     56|        o = nb[sizeof(uint32_t) + 4];
 1802|     56|        if ((o & 240) == 0)
  ------------------
  |  Branch (1802:13): [True: 37, False: 19]
  ------------------
 1803|     37|        {
 1804|     37|            if (3 < o)
  ------------------
  |  Branch (1804:17): [True: 21, False: 16]
  ------------------
 1805|     21|            {
 1806|     21|                TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
 1807|     21|                _TIFFfreeExt(tif, nb);
 1808|     21|                return (0);
 1809|     21|            }
 1810|     16|            if (sp->dctable[o] != 0)
  ------------------
  |  Branch (1810:17): [True: 4, False: 12]
  ------------------
 1811|      4|                _TIFFfreeExt(tif, sp->dctable[o]);
 1812|     16|            sp->dctable[o] = nb;
 1813|     16|        }
 1814|     19|        else
 1815|     19|        {
 1816|     19|            if ((o & 240) != 16)
  ------------------
  |  Branch (1816:17): [True: 0, False: 19]
  ------------------
 1817|      0|            {
 1818|      0|                TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
 1819|      0|                _TIFFfreeExt(tif, nb);
 1820|      0|                return (0);
 1821|      0|            }
 1822|     19|            o &= 15;
 1823|     19|            if (3 < o)
  ------------------
  |  Branch (1823:17): [True: 0, False: 19]
  ------------------
 1824|      0|            {
 1825|      0|                TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
 1826|      0|                _TIFFfreeExt(tif, nb);
 1827|      0|                return (0);
 1828|      0|            }
 1829|     19|            if (sp->actable[o] != 0)
  ------------------
  |  Branch (1829:17): [True: 5, False: 14]
  ------------------
 1830|      5|                _TIFFfreeExt(tif, sp->actable[o]);
 1831|     19|            sp->actable[o] = nb;
 1832|     19|        }
 1833|     56|    }
 1834|     71|    return (1);
 1835|     95|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamSof:
 1838|    774|{
 1839|       |    /* this marker needs to be checked, and part of its data needs to be saved
 1840|       |     * for regeneration later on */
 1841|    774|    static const char module[] = "OJPEGReadHeaderInfoSecStreamSof";
 1842|    774|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1843|    774|    uint16_t m;
 1844|    774|    uint16_t n;
 1845|    774|    uint8_t o;
 1846|    774|    uint16_t p;
 1847|    774|    uint16_t q;
 1848|    774|    if (sp->sof_log != 0)
  ------------------
  |  Branch (1848:9): [True: 0, False: 774]
  ------------------
 1849|      0|    {
 1850|      0|        TIFFErrorExtR(tif, module, "Corrupt JPEG data");
 1851|      0|        return (0);
 1852|      0|    }
 1853|    774|    if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1853:9): [True: 674, False: 100]
  ------------------
 1854|    674|        sp->sof_marker_id = marker_id;
 1855|       |    /* Lf: data length */
 1856|    774|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (1856:9): [True: 0, False: 774]
  ------------------
 1857|      0|        return (0);
 1858|    774|    if (m < 11)
  ------------------
  |  Branch (1858:9): [True: 13, False: 761]
  ------------------
 1859|     13|    {
 1860|     13|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1860:13): [True: 8, False: 5]
  ------------------
 1861|      8|            TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
 1862|     13|        return (0);
 1863|     13|    }
 1864|    761|    m = (uint16_t)(m - 8);
 1865|    761|    if (m % 3 != 0)
  ------------------
  |  Branch (1865:9): [True: 6, False: 755]
  ------------------
 1866|      6|    {
 1867|      6|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1867:13): [True: 3, False: 3]
  ------------------
 1868|      3|            TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
 1869|      6|        return (0);
 1870|      6|    }
 1871|    755|    n = m / 3;
 1872|    755|    if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1872:9): [True: 663, False: 92]
  ------------------
 1873|    663|    {
 1874|    663|        if (n != sp->samples_per_pixel)
  ------------------
  |  Branch (1874:13): [True: 192, False: 471]
  ------------------
 1875|    192|        {
 1876|    192|            TIFFErrorExtR(
 1877|    192|                tif, module,
 1878|    192|                "JPEG compressed data indicates unexpected number of samples");
 1879|    192|            return (0);
 1880|    192|        }
 1881|    663|    }
 1882|       |    /* P: Sample precision */
 1883|    563|    if (OJPEGReadByte(sp, &o) == 0)
  ------------------
  |  Branch (1883:9): [True: 0, False: 563]
  ------------------
 1884|      0|        return (0);
 1885|    563|    if (o != 8)
  ------------------
  |  Branch (1885:9): [True: 4, False: 559]
  ------------------
 1886|      4|    {
 1887|      4|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1887:13): [True: 0, False: 4]
  ------------------
 1888|      0|            TIFFErrorExtR(tif, module,
 1889|      0|                          "JPEG compressed data indicates unexpected number of "
 1890|      0|                          "bits per sample");
 1891|      4|        return (0);
 1892|      4|    }
 1893|       |    /* Y: Number of lines, X: Number of samples per line */
 1894|    559|    if (sp->subsamplingcorrect)
  ------------------
  |  Branch (1894:9): [True: 88, False: 471]
  ------------------
 1895|     88|        OJPEGReadSkip(sp, 4);
 1896|    471|    else
 1897|    471|    {
 1898|       |        /* Y: Number of lines */
 1899|    471|        if (OJPEGReadWord(sp, &p) == 0)
  ------------------
  |  Branch (1899:13): [True: 11, False: 460]
  ------------------
 1900|     11|            return (0);
 1901|    460|        if (((uint32_t)p < sp->image_length) &&
  ------------------
  |  Branch (1901:13): [True: 215, False: 245]
  ------------------
 1902|    215|            ((uint32_t)p < sp->strile_length_total))
  ------------------
  |  Branch (1902:13): [True: 215, False: 0]
  ------------------
 1903|    215|        {
 1904|    215|            TIFFErrorExtR(tif, module,
 1905|    215|                          "JPEG compressed data indicates unexpected height");
 1906|    215|            return (0);
 1907|    215|        }
 1908|    245|        sp->sof_y = p;
 1909|       |        /* X: Number of samples per line */
 1910|    245|        if (OJPEGReadWord(sp, &p) == 0)
  ------------------
  |  Branch (1910:13): [True: 0, False: 245]
  ------------------
 1911|      0|            return (0);
 1912|    245|        if (((uint32_t)p < sp->image_width) && ((uint32_t)p < sp->strile_width))
  ------------------
  |  Branch (1912:13): [True: 240, False: 5]
  |  Branch (1912:48): [True: 90, False: 150]
  ------------------
 1913|     90|        {
 1914|     90|            TIFFErrorExtR(tif, module,
 1915|     90|                          "JPEG compressed data indicates unexpected width");
 1916|     90|            return (0);
 1917|     90|        }
 1918|    155|        if ((uint32_t)p > sp->strile_width)
  ------------------
  |  Branch (1918:13): [True: 0, False: 155]
  ------------------
 1919|      0|        {
 1920|      0|            TIFFErrorExtR(tif, module,
 1921|      0|                          "JPEG compressed data image width exceeds expected "
 1922|      0|                          "image width");
 1923|      0|            return (0);
 1924|      0|        }
 1925|    155|        sp->sof_x = p;
 1926|    155|    }
 1927|       |    /* Nf: Number of image components in frame */
 1928|    243|    if (OJPEGReadByte(sp, &o) == 0)
  ------------------
  |  Branch (1928:9): [True: 12, False: 231]
  ------------------
 1929|     12|        return (0);
 1930|    231|    if (o != n)
  ------------------
  |  Branch (1930:9): [True: 7, False: 224]
  ------------------
 1931|      7|    {
 1932|      7|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1932:13): [True: 0, False: 7]
  ------------------
 1933|      0|            TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
 1934|      7|        return (0);
 1935|      7|    }
 1936|       |    /* per component stuff */
 1937|       |    /* TODO: double-check that flow implies that n cannot be as big as to make
 1938|       |     * us overflow sof_c, sof_hv and sof_tq arrays */
 1939|    598|    for (q = 0; q < n; q++)
  ------------------
  |  Branch (1939:17): [True: 523, False: 75]
  ------------------
 1940|    523|    {
 1941|       |        /* C: Component identifier */
 1942|    523|        if (OJPEGReadByte(sp, &o) == 0)
  ------------------
  |  Branch (1942:13): [True: 0, False: 523]
  ------------------
 1943|      0|            return (0);
 1944|    523|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1944:13): [True: 322, False: 201]
  ------------------
 1945|    322|            sp->sof_c[q] = o;
 1946|       |        /* H: Horizontal sampling factor, and V: Vertical sampling factor */
 1947|    523|        if (OJPEGReadByte(sp, &o) == 0)
  ------------------
  |  Branch (1947:13): [True: 143, False: 380]
  ------------------
 1948|    143|            return (0);
 1949|    380|        if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1949:13): [True: 186, False: 194]
  ------------------
 1950|    186|        {
 1951|    186|            if (q == 0)
  ------------------
  |  Branch (1951:17): [True: 74, False: 112]
  ------------------
 1952|     74|            {
 1953|     74|                sp->subsampling_hor = (o >> 4);
 1954|     74|                sp->subsampling_ver = (o & 15);
 1955|     74|                if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) &&
  ------------------
  |  Branch (1955:22): [True: 65, False: 9]
  |  Branch (1955:52): [True: 58, False: 7]
  ------------------
 1956|     58|                     (sp->subsampling_hor != 4)) ||
  ------------------
  |  Branch (1956:22): [True: 34, False: 24]
  ------------------
 1957|     40|                    ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) &&
  ------------------
  |  Branch (1957:22): [True: 32, False: 8]
  |  Branch (1957:52): [True: 28, False: 4]
  ------------------
 1958|     28|                     (sp->subsampling_ver != 4)))
  ------------------
  |  Branch (1958:22): [True: 22, False: 6]
  ------------------
 1959|     56|                    sp->subsampling_force_desubsampling_inside_decompression =
 1960|     56|                        1;
 1961|     74|            }
 1962|    112|            else
 1963|    112|            {
 1964|    112|                if (o != 17)
  ------------------
  |  Branch (1964:21): [True: 102, False: 10]
  ------------------
 1965|    102|                    sp->subsampling_force_desubsampling_inside_decompression =
 1966|    102|                        1;
 1967|    112|            }
 1968|    186|        }
 1969|    194|        else
 1970|    194|        {
 1971|    194|            sp->sof_hv[q] = o;
 1972|    194|            if (sp->subsampling_force_desubsampling_inside_decompression == 0)
  ------------------
  |  Branch (1972:17): [True: 3, False: 191]
  ------------------
 1973|      3|            {
 1974|      3|                if (q == 0)
  ------------------
  |  Branch (1974:21): [True: 1, False: 2]
  ------------------
 1975|      1|                {
 1976|      1|                    if (o != ((sp->subsampling_hor << 4) | sp->subsampling_ver))
  ------------------
  |  Branch (1976:25): [True: 0, False: 1]
  ------------------
 1977|      0|                    {
 1978|      0|                        TIFFErrorExtR(tif, module,
 1979|      0|                                      "JPEG compressed data indicates "
 1980|      0|                                      "unexpected subsampling values");
 1981|      0|                        return (0);
 1982|      0|                    }
 1983|      1|                }
 1984|      2|                else
 1985|      2|                {
 1986|      2|                    if (o != 17)
  ------------------
  |  Branch (1986:25): [True: 0, False: 2]
  ------------------
 1987|      0|                    {
 1988|      0|                        TIFFErrorExtR(tif, module,
 1989|      0|                                      "JPEG compressed data indicates "
 1990|      0|                                      "unexpected subsampling values");
 1991|      0|                        return (0);
 1992|      0|                    }
 1993|      2|                }
 1994|      3|            }
 1995|    194|        }
 1996|       |        /* Tq: Quantization table destination selector */
 1997|    380|        if (OJPEGReadByte(sp, &o) == 0)
  ------------------
  |  Branch (1997:13): [True: 6, False: 374]
  ------------------
 1998|      6|            return (0);
 1999|    374|        if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1999:13): [True: 194, False: 180]
  ------------------
 2000|    194|            sp->sof_tq[q] = o;
 2001|    374|    }
 2002|     75|    if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (2002:9): [True: 22, False: 53]
  ------------------
 2003|     22|        sp->sof_log = 1;
 2004|     75|    return (1);
 2005|    224|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamSos:
 2008|  6.08k|{
 2009|       |    /* this marker needs to be checked, and part of its data needs to be saved
 2010|       |     * for regeneration later on */
 2011|  6.08k|    static const char module[] = "OJPEGReadHeaderInfoSecStreamSos";
 2012|  6.08k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2013|  6.08k|    uint16_t m;
 2014|  6.08k|    uint8_t n;
 2015|  6.08k|    uint8_t o;
 2016|  6.08k|    assert(sp->subsamplingcorrect == 0);
  ------------------
  |  Branch (2016:5): [True: 0, False: 6.08k]
  |  Branch (2016:5): [True: 6.08k, False: 0]
  ------------------
 2017|  6.08k|    if (sp->sof_log == 0)
  ------------------
  |  Branch (2017:9): [True: 132, False: 5.94k]
  ------------------
 2018|    132|    {
 2019|    132|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2020|    132|        return (0);
 2021|    132|    }
 2022|       |    /* Ls */
 2023|  5.94k|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (2023:9): [True: 0, False: 5.94k]
  ------------------
 2024|      0|        return (0);
 2025|  5.94k|    if (m != 6 + sp->samples_per_pixel_per_plane * 2)
  ------------------
  |  Branch (2025:9): [True: 5.74k, False: 200]
  ------------------
 2026|  5.74k|    {
 2027|  5.74k|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2028|  5.74k|        return (0);
 2029|  5.74k|    }
 2030|       |    /* Ns */
 2031|    200|    if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2031:9): [True: 0, False: 200]
  ------------------
 2032|      0|        return (0);
 2033|    200|    if (n != sp->samples_per_pixel_per_plane)
  ------------------
  |  Branch (2033:9): [True: 2, False: 198]
  ------------------
 2034|      2|    {
 2035|      2|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2036|      2|        return (0);
 2037|      2|    }
 2038|       |    /* Cs, Td, and Ta */
 2039|    393|    for (o = 0; o < sp->samples_per_pixel_per_plane; o++)
  ------------------
  |  Branch (2039:17): [True: 198, False: 195]
  ------------------
 2040|    198|    {
 2041|       |        /* Cs */
 2042|    198|        if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2042:13): [True: 3, False: 195]
  ------------------
 2043|      3|            return (0);
 2044|    195|        sp->sos_cs[sp->plane_sample_offset + o] = n;
 2045|       |        /* Td and Ta */
 2046|    195|        if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2046:13): [True: 0, False: 195]
  ------------------
 2047|      0|            return (0);
 2048|    195|        sp->sos_tda[sp->plane_sample_offset + o] = n;
 2049|    195|    }
 2050|       |    /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as
 2051|       |     * per LibJpeg source */
 2052|    195|    OJPEGReadSkip(sp, 3);
 2053|    195|    return (1);
 2054|    198|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesQTable:
 2057|  34.5k|{
 2058|  34.5k|    static const char module[] = "OJPEGReadHeaderInfoSecTablesQTable";
 2059|  34.5k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2060|  34.5k|    uint8_t m;
 2061|  34.5k|    uint8_t n;
 2062|  34.5k|    uint32_t oa;
 2063|  34.5k|    uint8_t *ob;
 2064|  34.5k|    uint32_t p;
 2065|  34.5k|    if (sp->qtable_offset[0] == 0)
  ------------------
  |  Branch (2065:9): [True: 34.2k, False: 328]
  ------------------
 2066|  34.2k|    {
 2067|  34.2k|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2068|  34.2k|        return (0);
 2069|  34.2k|    }
 2070|    328|    sp->in_buffer_file_pos_log = 0;
 2071|  1.25k|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2071:17): [True: 926, False: 328]
  ------------------
 2072|    926|    {
 2073|    926|        if ((sp->qtable_offset[m] != 0) &&
  ------------------
  |  Branch (2073:13): [True: 368, False: 558]
  ------------------
 2074|    368|            ((m == 0) || (sp->qtable_offset[m] != sp->qtable_offset[m - 1])))
  ------------------
  |  Branch (2074:14): [True: 328, False: 40]
  |  Branch (2074:26): [True: 40, False: 0]
  ------------------
 2075|    368|        {
 2076|    373|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2076:25): [True: 5, False: 368]
  ------------------
 2077|      5|            {
 2078|      5|                if (sp->qtable_offset[m] == sp->qtable_offset[n])
  ------------------
  |  Branch (2078:21): [True: 0, False: 5]
  ------------------
 2079|      0|                {
 2080|      0|                    TIFFErrorExtR(tif, module, "Corrupt JpegQTables tag value");
 2081|      0|                    return (0);
 2082|      0|                }
 2083|      5|            }
 2084|    368|            oa = sizeof(uint32_t) + 69;
 2085|    368|            ob = (uint8_t *)_TIFFmallocExt(tif, oa);
 2086|    368|            if (ob == 0)
  ------------------
  |  Branch (2086:17): [True: 0, False: 368]
  ------------------
 2087|      0|            {
 2088|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2089|      0|                return (0);
 2090|      0|            }
 2091|    368|            *(uint32_t *)ob = oa;
 2092|    368|            ob[sizeof(uint32_t)] = 255;
 2093|    368|            ob[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
  ------------------
  |  |  166|    368|#define JPEG_MARKER_DQT 0xDB
  ------------------
 2094|    368|            ob[sizeof(uint32_t) + 2] = 0;
 2095|    368|            ob[sizeof(uint32_t) + 3] = 67;
 2096|    368|            ob[sizeof(uint32_t) + 4] = m;
 2097|    368|            TIFFSeekFile(tif, sp->qtable_offset[m], SEEK_SET);
  ------------------
  |  |  287|    368|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2098|    368|            p = (uint32_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64);
  ------------------
  |  |  283|    368|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2099|    368|            if (p != 64)
  ------------------
  |  Branch (2099:17): [True: 0, False: 368]
  ------------------
 2100|      0|            {
 2101|      0|                _TIFFfreeExt(tif, ob);
 2102|      0|                return (0);
 2103|      0|            }
 2104|    368|            if (sp->qtable[m] != 0)
  ------------------
  |  Branch (2104:17): [True: 0, False: 368]
  ------------------
 2105|      0|                _TIFFfreeExt(tif, sp->qtable[m]);
 2106|    368|            sp->qtable[m] = ob;
 2107|    368|            sp->sof_tq[m] = m;
 2108|    368|        }
 2109|    558|        else
 2110|    558|            sp->sof_tq[m] = sp->sof_tq[m - 1];
 2111|    926|    }
 2112|    328|    return (1);
 2113|    328|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesDcTable:
 2116|    328|{
 2117|    328|    static const char module[] = "OJPEGReadHeaderInfoSecTablesDcTable";
 2118|    328|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2119|    328|    uint8_t m;
 2120|    328|    uint8_t n;
 2121|    328|    uint8_t o[16];
 2122|    328|    uint32_t p;
 2123|    328|    uint32_t q;
 2124|    328|    uint32_t ra;
 2125|    328|    uint8_t *rb;
 2126|    328|    if (sp->dctable_offset[0] == 0)
  ------------------
  |  Branch (2126:9): [True: 212, False: 116]
  ------------------
 2127|    212|    {
 2128|    212|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2129|    212|        return (0);
 2130|    212|    }
 2131|    116|    sp->in_buffer_file_pos_log = 0;
 2132|    410|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2132:17): [True: 300, False: 110]
  ------------------
 2133|    300|    {
 2134|    300|        if ((sp->dctable_offset[m] != 0) &&
  ------------------
  |  Branch (2134:13): [True: 235, False: 65]
  ------------------
 2135|    235|            ((m == 0) || (sp->dctable_offset[m] != sp->dctable_offset[m - 1])))
  ------------------
  |  Branch (2135:14): [True: 116, False: 119]
  |  Branch (2135:26): [True: 93, False: 26]
  ------------------
 2136|    209|        {
 2137|    264|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2137:25): [True: 59, False: 205]
  ------------------
 2138|     59|            {
 2139|     59|                if (sp->dctable_offset[m] == sp->dctable_offset[n])
  ------------------
  |  Branch (2139:21): [True: 4, False: 55]
  ------------------
 2140|      4|                {
 2141|      4|                    TIFFErrorExtR(tif, module,
 2142|      4|                                  "Corrupt JpegDcTables tag value");
 2143|      4|                    return (0);
 2144|      4|                }
 2145|     59|            }
 2146|    205|            TIFFSeekFile(tif, sp->dctable_offset[m], SEEK_SET);
  ------------------
  |  |  287|    205|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2147|    205|            p = (uint32_t)TIFFReadFile(tif, o, 16);
  ------------------
  |  |  283|    205|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2148|    205|            if (p != 16)
  ------------------
  |  Branch (2148:17): [True: 2, False: 203]
  ------------------
 2149|      2|                return (0);
 2150|    203|            q = 0;
 2151|  3.45k|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2151:25): [True: 3.24k, False: 203]
  ------------------
 2152|  3.24k|                q += o[n];
 2153|    203|            ra = (uint32_t)(sizeof(uint32_t) + 21 + q);
 2154|    203|            rb = (uint8_t *)_TIFFmallocExt(tif, ra);
 2155|    203|            if (rb == 0)
  ------------------
  |  Branch (2155:17): [True: 0, False: 203]
  ------------------
 2156|      0|            {
 2157|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2158|      0|                return (0);
 2159|      0|            }
 2160|    203|            *(uint32_t *)rb = ra;
 2161|    203|            rb[sizeof(uint32_t)] = 255;
 2162|    203|            rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
  ------------------
  |  |  161|    203|#define JPEG_MARKER_DHT 0xC4
  ------------------
 2163|    203|            rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
 2164|    203|            rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
 2165|    203|            rb[sizeof(uint32_t) + 4] = m;
 2166|  3.45k|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2166:25): [True: 3.24k, False: 203]
  ------------------
 2167|  3.24k|                rb[sizeof(uint32_t) + 5 + n] = o[n];
 2168|    203|            p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
  ------------------
  |  |  283|    203|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2169|    203|            if (p != q)
  ------------------
  |  Branch (2169:17): [True: 0, False: 203]
  ------------------
 2170|      0|            {
 2171|      0|                _TIFFfreeExt(tif, rb);
 2172|      0|                return (0);
 2173|      0|            }
 2174|    203|            if (sp->dctable[m] != 0)
  ------------------
  |  Branch (2174:17): [True: 6, False: 197]
  ------------------
 2175|      6|                _TIFFfreeExt(tif, sp->dctable[m]);
 2176|    203|            sp->dctable[m] = rb;
 2177|    203|            sp->sos_tda[m] = (uint8_t)(m << 4);
 2178|    203|        }
 2179|     91|        else
 2180|     91|            sp->sos_tda[m] = sp->sos_tda[m - 1];
 2181|    300|    }
 2182|    110|    return (1);
 2183|    116|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesAcTable:
 2186|    110|{
 2187|    110|    static const char module[] = "OJPEGReadHeaderInfoSecTablesAcTable";
 2188|    110|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2189|    110|    uint8_t m;
 2190|    110|    uint8_t n;
 2191|    110|    uint8_t o[16];
 2192|    110|    uint32_t p;
 2193|    110|    uint32_t q;
 2194|    110|    uint32_t ra;
 2195|    110|    uint8_t *rb;
 2196|    110|    if (sp->actable_offset[0] == 0)
  ------------------
  |  Branch (2196:9): [True: 42, False: 68]
  ------------------
 2197|     42|    {
 2198|     42|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2199|     42|        return (0);
 2200|     42|    }
 2201|     68|    sp->in_buffer_file_pos_log = 0;
 2202|    252|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2202:17): [True: 184, False: 68]
  ------------------
 2203|    184|    {
 2204|    184|        if ((sp->actable_offset[m] != 0) &&
  ------------------
  |  Branch (2204:13): [True: 134, False: 50]
  ------------------
 2205|    134|            ((m == 0) || (sp->actable_offset[m] != sp->actable_offset[m - 1])))
  ------------------
  |  Branch (2205:14): [True: 68, False: 66]
  |  Branch (2205:26): [True: 57, False: 9]
  ------------------
 2206|    125|        {
 2207|    154|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2207:25): [True: 29, False: 125]
  ------------------
 2208|     29|            {
 2209|     29|                if (sp->actable_offset[m] == sp->actable_offset[n])
  ------------------
  |  Branch (2209:21): [True: 0, False: 29]
  ------------------
 2210|      0|                {
 2211|      0|                    TIFFErrorExtR(tif, module,
 2212|      0|                                  "Corrupt JpegAcTables tag value");
 2213|      0|                    return (0);
 2214|      0|                }
 2215|     29|            }
 2216|    125|            TIFFSeekFile(tif, sp->actable_offset[m], SEEK_SET);
  ------------------
  |  |  287|    125|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2217|    125|            p = (uint32_t)TIFFReadFile(tif, o, 16);
  ------------------
  |  |  283|    125|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2218|    125|            if (p != 16)
  ------------------
  |  Branch (2218:17): [True: 0, False: 125]
  ------------------
 2219|      0|                return (0);
 2220|    125|            q = 0;
 2221|  2.12k|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2221:25): [True: 2.00k, False: 125]
  ------------------
 2222|  2.00k|                q += o[n];
 2223|    125|            ra = (uint32_t)(sizeof(uint32_t) + 21 + q);
 2224|    125|            rb = (uint8_t *)_TIFFmallocExt(tif, ra);
 2225|    125|            if (rb == 0)
  ------------------
  |  Branch (2225:17): [True: 0, False: 125]
  ------------------
 2226|      0|            {
 2227|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2228|      0|                return (0);
 2229|      0|            }
 2230|    125|            *(uint32_t *)rb = ra;
 2231|    125|            rb[sizeof(uint32_t)] = 255;
 2232|    125|            rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
  ------------------
  |  |  161|    125|#define JPEG_MARKER_DHT 0xC4
  ------------------
 2233|    125|            rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
 2234|    125|            rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
 2235|    125|            rb[sizeof(uint32_t) + 4] = (16 | m);
 2236|  2.12k|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2236:25): [True: 2.00k, False: 125]
  ------------------
 2237|  2.00k|                rb[sizeof(uint32_t) + 5 + n] = o[n];
 2238|    125|            p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
  ------------------
  |  |  283|    125|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2239|    125|            if (p != q)
  ------------------
  |  Branch (2239:17): [True: 0, False: 125]
  ------------------
 2240|      0|            {
 2241|      0|                _TIFFfreeExt(tif, rb);
 2242|      0|                return (0);
 2243|      0|            }
 2244|    125|            if (sp->actable[m] != 0)
  ------------------
  |  Branch (2244:17): [True: 5, False: 120]
  ------------------
 2245|      5|                _TIFFfreeExt(tif, sp->actable[m]);
 2246|    125|            sp->actable[m] = rb;
 2247|    125|            sp->sos_tda[m] = (sp->sos_tda[m] | m);
 2248|    125|        }
 2249|     59|        else
 2250|     59|            sp->sos_tda[m] = (sp->sos_tda[m] | (sp->sos_tda[m - 1] & 15));
 2251|    184|    }
 2252|     68|    return (1);
 2253|     68|}
tif_ojpeg.c:OJPEGVSetField:
  560|  20.6k|{
  561|  20.6k|    static const char module[] = "OJPEGVSetField";
  562|  20.6k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  563|  20.6k|    uint32_t ma;
  564|  20.6k|    uint64_t *mb;
  565|  20.6k|    uint32_t n;
  566|  20.6k|    const TIFFField *fip;
  567|       |
  568|  20.6k|    switch (tag)
  569|  20.6k|    {
  570|     65|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|     65|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (570:9): [True: 65, False: 20.5k]
  ------------------
  571|     65|            sp->jpeg_interchange_format = (uint64_t)va_arg(ap, uint64_t);
  572|     65|            break;
  573|     37|        case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|     37|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (573:9): [True: 37, False: 20.5k]
  ------------------
  574|     37|            sp->jpeg_interchange_format_length = (uint64_t)va_arg(ap, uint64_t);
  575|     37|            break;
  576|    118|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|    118|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (576:9): [True: 118, False: 20.4k]
  ------------------
  577|    118|            sp->subsampling_tag = 1;
  578|    118|            sp->subsampling_hor = (uint8_t)va_arg(ap, uint16_vap);
  579|    118|            sp->subsampling_ver = (uint8_t)va_arg(ap, uint16_vap);
  580|    118|            tif->tif_dir.td_ycbcrsubsampling[0] = sp->subsampling_hor;
  581|    118|            tif->tif_dir.td_ycbcrsubsampling[1] = sp->subsampling_ver;
  582|    118|            break;
  583|    634|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|    634|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (583:9): [True: 634, False: 19.9k]
  ------------------
  584|    634|            ma = (uint32_t)va_arg(ap, uint32_t);
  585|    634|            if (ma != 0)
  ------------------
  |  Branch (585:17): [True: 634, False: 0]
  ------------------
  586|    634|            {
  587|    634|                if (ma > 3)
  ------------------
  |  Branch (587:21): [True: 0, False: 634]
  ------------------
  588|      0|                {
  589|      0|                    TIFFErrorExtR(tif, module,
  590|      0|                                  "JpegQTables tag has incorrect count");
  591|      0|                    return (0);
  592|      0|                }
  593|    634|                sp->qtable_offset_count = (uint8_t)ma;
  594|    634|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  595|  1.41k|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (595:29): [True: 780, False: 634]
  ------------------
  596|    780|                    sp->qtable_offset[n] = mb[n];
  597|    634|            }
  598|    634|            break;
  599|    634|        case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|    573|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (599:9): [True: 573, False: 20.0k]
  ------------------
  600|    573|            ma = (uint32_t)va_arg(ap, uint32_t);
  601|    573|            if (ma != 0)
  ------------------
  |  Branch (601:17): [True: 569, False: 4]
  ------------------
  602|    569|            {
  603|    569|                if (ma > 3)
  ------------------
  |  Branch (603:21): [True: 271, False: 298]
  ------------------
  604|    271|                {
  605|    271|                    TIFFErrorExtR(tif, module,
  606|    271|                                  "JpegDcTables tag has incorrect count");
  607|    271|                    return (0);
  608|    271|                }
  609|    298|                sp->dctable_offset_count = (uint8_t)ma;
  610|    298|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  611|  1.18k|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (611:29): [True: 886, False: 298]
  ------------------
  612|    886|                    sp->dctable_offset[n] = mb[n];
  613|    298|            }
  614|    302|            break;
  615|    357|        case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|    357|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (615:9): [True: 357, False: 20.2k]
  ------------------
  616|    357|            ma = (uint32_t)va_arg(ap, uint32_t);
  617|    357|            if (ma != 0)
  ------------------
  |  Branch (617:17): [True: 353, False: 4]
  ------------------
  618|    353|            {
  619|    353|                if (ma > 3)
  ------------------
  |  Branch (619:21): [True: 20, False: 333]
  ------------------
  620|     20|                {
  621|     20|                    TIFFErrorExtR(tif, module,
  622|     20|                                  "JpegAcTables tag has incorrect count");
  623|     20|                    return (0);
  624|     20|                }
  625|    333|                sp->actable_offset_count = (uint8_t)ma;
  626|    333|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  627|  1.31k|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (627:29): [True: 979, False: 333]
  ------------------
  628|    979|                    sp->actable_offset[n] = mb[n];
  629|    333|            }
  630|    337|            break;
  631|    337|        case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|     70|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (631:9): [True: 70, False: 20.5k]
  ------------------
  632|     70|            sp->jpeg_proc = (uint8_t)va_arg(ap, uint16_vap);
  633|     70|            break;
  634|     20|        case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|     20|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (634:9): [True: 20, False: 20.5k]
  ------------------
  635|     20|            sp->restart_interval = (uint16_t)va_arg(ap, uint16_vap);
  636|     20|            break;
  637|  18.7k|        default:
  ------------------
  |  Branch (637:9): [True: 18.7k, False: 1.87k]
  ------------------
  638|  18.7k|            return (*sp->vsetparent)(tif, tag, ap);
  639|  20.6k|    }
  640|  1.58k|    fip = TIFFFieldWithTag(tif, tag);
  641|  1.58k|    if (fip == NULL) /* shouldn't happen */
  ------------------
  |  Branch (641:9): [True: 0, False: 1.58k]
  ------------------
  642|      0|        return (0);
  643|  1.58k|    TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|  1.58k|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.58k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.58k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  644|  1.58k|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|  1.58k|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
  645|  1.58k|    return (1);
  646|  1.58k|}
tif_ojpeg.c:OJPEGFixupTags:
  691|  1.38k|{
  692|  1.38k|    (void)tif;
  693|  1.38k|    return (1);
  694|  1.38k|}
tif_ojpeg.c:OJPEGSetupDecode:
  697|  1.23k|{
  698|  1.23k|    static const char module[] = "OJPEGSetupDecode";
  699|  1.23k|    TIFFWarningExtR(tif, module,
  700|  1.23k|                    "Deprecated and troublesome old-style JPEG compression "
  701|  1.23k|                    "mode, please convert to new-style JPEG compression and "
  702|  1.23k|                    "notify vendor of writing software");
  703|  1.23k|    return (1);
  704|  1.23k|}
tif_ojpeg.c:OJPEGPreDecode:
  707|   208k|{
  708|   208k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  709|   208k|    uint32_t m;
  710|   208k|    if (sp->subsamplingcorrect_done == 0)
  ------------------
  |  Branch (710:9): [True: 729, False: 207k]
  ------------------
  711|    729|        OJPEGSubsamplingCorrect(tif);
  712|   208k|    if (sp->readheader_done == 0)
  ------------------
  |  Branch (712:9): [True: 89.3k, False: 118k]
  ------------------
  713|  89.3k|    {
  714|  89.3k|        if (OJPEGReadHeaderInfo(tif) == 0)
  ------------------
  |  Branch (714:13): [True: 89.0k, False: 331]
  ------------------
  715|  89.0k|            return (0);
  716|  89.3k|    }
  717|   119k|    if (sp->sos_end[s].log == 0)
  ------------------
  |  Branch (717:9): [True: 15.3k, False: 103k]
  ------------------
  718|  15.3k|    {
  719|  15.3k|        if (OJPEGReadSecondarySos(tif, s) == 0)
  ------------------
  |  Branch (719:13): [True: 15.1k, False: 195]
  ------------------
  720|  15.1k|            return (0);
  721|  15.3k|    }
  722|   103k|    if (isTiled(tif))
  ------------------
  |  |  278|   103k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|   103k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 102k, False: 1.18k]
  |  |  ------------------
  ------------------
  723|   102k|        m = tif->tif_dir.td_curtile;
  724|  1.18k|    else
  725|  1.18k|        m = tif->tif_dir.td_curstrip;
  726|   103k|    if ((sp->writeheader_done != 0) &&
  ------------------
  |  Branch (726:9): [True: 51.3k, False: 52.5k]
  ------------------
  727|  51.3k|        ((sp->write_cursample != s) || (sp->write_curstrile > m)))
  ------------------
  |  Branch (727:10): [True: 22.3k, False: 29.0k]
  |  Branch (727:40): [True: 27, False: 29.0k]
  ------------------
  728|  22.3k|    {
  729|  22.3k|        if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (729:13): [True: 22.3k, False: 0]
  ------------------
  730|  22.3k|            OJPEGLibjpegSessionAbort(tif);
  731|  22.3k|        sp->writeheader_done = 0;
  732|  22.3k|    }
  733|   103k|    if (sp->writeheader_done == 0)
  ------------------
  |  Branch (733:9): [True: 74.9k, False: 29.0k]
  ------------------
  734|  74.9k|    {
  735|  74.9k|        sp->plane_sample_offset = (uint8_t)s;
  736|  74.9k|        sp->write_cursample = s;
  737|  74.9k|        sp->write_curstrile = s * tif->tif_dir.td_stripsperimage;
  738|  74.9k|        if ((sp->in_buffer_file_pos_log == 0) ||
  ------------------
  |  Branch (738:13): [True: 812, False: 74.0k]
  ------------------
  739|  74.0k|            (sp->in_buffer_file_pos - sp->in_buffer_togo !=
  ------------------
  |  Branch (739:13): [True: 21.9k, False: 52.0k]
  ------------------
  740|  74.0k|             sp->sos_end[s].in_buffer_file_pos))
  741|  22.8k|        {
  742|  22.8k|            sp->in_buffer_source = sp->sos_end[s].in_buffer_source;
  743|  22.8k|            sp->in_buffer_next_strile = sp->sos_end[s].in_buffer_next_strile;
  744|  22.8k|            sp->in_buffer_file_pos = sp->sos_end[s].in_buffer_file_pos;
  745|  22.8k|            sp->in_buffer_file_pos_log = 0;
  746|  22.8k|            sp->in_buffer_file_togo = sp->sos_end[s].in_buffer_file_togo;
  747|  22.8k|            sp->in_buffer_togo = 0;
  748|  22.8k|            sp->in_buffer_cur = 0;
  749|  22.8k|        }
  750|  74.9k|        if (OJPEGWriteHeaderInfo(tif) == 0)
  ------------------
  |  Branch (750:13): [True: 52.1k, False: 22.7k]
  ------------------
  751|  52.1k|            return (0);
  752|  74.9k|    }
  753|       |
  754|  51.8k|    sp->subsampling_convert_state = 0;
  755|       |
  756|   367k|    while (sp->write_curstrile < m)
  ------------------
  |  Branch (756:12): [True: 350k, False: 16.8k]
  ------------------
  757|   350k|    {
  758|   350k|        if (sp->libjpeg_jpeg_query_style == 0)
  ------------------
  |  Branch (758:13): [True: 0, False: 350k]
  ------------------
  759|      0|        {
  760|      0|            if (OJPEGPreDecodeSkipRaw(tif) == 0)
  ------------------
  |  Branch (760:17): [True: 0, False: 0]
  ------------------
  761|      0|                return (0);
  762|      0|        }
  763|   350k|        else
  764|   350k|        {
  765|   350k|            if (OJPEGPreDecodeSkipScanlines(tif) == 0)
  ------------------
  |  Branch (765:17): [True: 34.9k, False: 315k]
  ------------------
  766|  34.9k|                return (0);
  767|   350k|        }
  768|   315k|        sp->write_curstrile++;
  769|   315k|    }
  770|  16.8k|    sp->decoder_ok = 1;
  771|  16.8k|    return (1);
  772|  51.8k|}
tif_ojpeg.c:OJPEGReadHeaderInfo:
 1167|  89.3k|{
 1168|  89.3k|    static const char module[] = "OJPEGReadHeaderInfo";
 1169|  89.3k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1170|  89.3k|    assert(sp->readheader_done == 0);
  ------------------
  |  Branch (1170:5): [True: 0, False: 89.3k]
  |  Branch (1170:5): [True: 89.3k, False: 0]
  ------------------
 1171|  89.3k|    sp->image_width = tif->tif_dir.td_imagewidth;
 1172|  89.3k|    sp->image_length = tif->tif_dir.td_imagelength;
 1173|  89.3k|    if (isTiled(tif))
  ------------------
  |  |  278|  89.3k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  89.3k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 73.9k, False: 15.4k]
  |  |  ------------------
  ------------------
 1174|  73.9k|    {
 1175|  73.9k|        sp->strile_width = tif->tif_dir.td_tilewidth;
 1176|  73.9k|        sp->strile_length = tif->tif_dir.td_tilelength;
 1177|  73.9k|        sp->strile_length_total =
 1178|  73.9k|            ((sp->image_length + sp->strile_length - 1) / sp->strile_length) *
 1179|  73.9k|            sp->strile_length;
 1180|  73.9k|    }
 1181|  15.4k|    else
 1182|  15.4k|    {
 1183|  15.4k|        sp->strile_width = sp->image_width;
 1184|  15.4k|        sp->strile_length = tif->tif_dir.td_rowsperstrip;
 1185|  15.4k|        if (sp->strile_length == (uint32_t)-1)
  ------------------
  |  Branch (1185:13): [True: 144, False: 15.2k]
  ------------------
 1186|    144|            sp->strile_length = sp->image_length;
 1187|  15.4k|        sp->strile_length_total = sp->image_length;
 1188|  15.4k|    }
 1189|  89.3k|    if (tif->tif_dir.td_samplesperpixel == 1)
  ------------------
  |  Branch (1189:9): [True: 4.76k, False: 84.5k]
  ------------------
 1190|  4.76k|    {
 1191|  4.76k|        sp->samples_per_pixel = 1;
 1192|  4.76k|        sp->plane_sample_offset = 0;
 1193|  4.76k|        sp->samples_per_pixel_per_plane = sp->samples_per_pixel;
 1194|  4.76k|        sp->subsampling_hor = 1;
 1195|  4.76k|        sp->subsampling_ver = 1;
 1196|  4.76k|    }
 1197|  84.5k|    else
 1198|  84.5k|    {
 1199|  84.5k|        if (tif->tif_dir.td_samplesperpixel != 3)
  ------------------
  |  Branch (1199:13): [True: 40.1k, False: 44.4k]
  ------------------
 1200|  40.1k|        {
 1201|  40.1k|            TIFFErrorExtR(tif, module,
 1202|  40.1k|                          "SamplesPerPixel %" PRIu8
 1203|  40.1k|                          " not supported for this compression scheme",
 1204|  40.1k|                          sp->samples_per_pixel);
 1205|  40.1k|            return (0);
 1206|  40.1k|        }
 1207|  44.4k|        sp->samples_per_pixel = 3;
 1208|  44.4k|        sp->plane_sample_offset = 0;
 1209|  44.4k|        if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|  44.4k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1209:13): [True: 42.9k, False: 1.44k]
  ------------------
 1210|  42.9k|            sp->samples_per_pixel_per_plane = 3;
 1211|  1.44k|        else
 1212|  1.44k|            sp->samples_per_pixel_per_plane = 1;
 1213|  44.4k|    }
 1214|  49.1k|    if (sp->strile_length < sp->image_length)
  ------------------
  |  Branch (1214:9): [True: 14.2k, False: 34.9k]
  ------------------
 1215|  14.2k|    {
 1216|  14.2k|        if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) &&
  ------------------
  |  Branch (1216:14): [True: 5.57k, False: 8.64k]
  |  Branch (1216:44): [True: 0, False: 5.57k]
  ------------------
 1217|      0|             (sp->subsampling_hor != 4)) ||
  ------------------
  |  Branch (1217:14): [True: 0, False: 0]
  ------------------
 1218|  14.2k|            ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) &&
  ------------------
  |  Branch (1218:14): [True: 5.59k, False: 8.62k]
  |  Branch (1218:44): [True: 192, False: 5.40k]
  ------------------
 1219|    192|             (sp->subsampling_ver != 4)))
  ------------------
  |  Branch (1219:14): [True: 0, False: 192]
  ------------------
 1220|      0|        {
 1221|      0|            TIFFErrorExtR(tif, module, "Invalid subsampling values");
 1222|      0|            return (0);
 1223|      0|        }
 1224|  14.2k|        if (sp->strile_length % ((uint32_t)sp->subsampling_ver * 8) != 0)
  ------------------
  |  Branch (1224:13): [True: 7.11k, False: 7.10k]
  ------------------
 1225|  7.11k|        {
 1226|  7.11k|            TIFFErrorExtR(tif, module,
 1227|  7.11k|                          "Incompatible vertical subsampling and image "
 1228|  7.11k|                          "strip/tile length");
 1229|  7.11k|            return (0);
 1230|  7.11k|        }
 1231|  7.10k|        {
 1232|       |            /* Values were validated above as 1, 2, or 4. */
 1233|  7.10k|            uint32_t mcu_width = (uint32_t)sp->subsampling_hor * 8;
 1234|  7.10k|            uint32_t mcu_height = (uint32_t)sp->subsampling_ver * 8;
 1235|  7.10k|            uint32_t mcu_cols =
 1236|  7.10k|                TIFFhowmany_32_maxuint_compat(sp->strile_width, mcu_width);
  ------------------
  |  |  318|  7.10k|    (((uint32_t)(x) / (uint32_t)(y)) +                                         \
  |  |  319|  7.10k|     ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
  |  |  ------------------
  |  |  |  Branch (319:7): [True: 6.40k, False: 707]
  |  |  ------------------
  ------------------
 1237|  7.10k|            uint32_t mcu_rows = sp->strile_length / mcu_height;
 1238|  7.10k|            if (mcu_cols == 0 || mcu_rows == 0)
  ------------------
  |  Branch (1238:17): [True: 0, False: 7.10k]
  |  Branch (1238:34): [True: 0, False: 7.10k]
  ------------------
 1239|      0|            {
 1240|      0|                sp->restart_interval = 0;
 1241|      0|            }
 1242|  7.10k|            else
 1243|  7.10k|            {
 1244|  7.10k|                uint32_t restart_interval =
 1245|  7.10k|                    _TIFFMultiply32(tif, mcu_cols, mcu_rows, module);
 1246|  7.10k|                if (restart_interval == 0 || restart_interval > UINT16_MAX)
  ------------------
  |  Branch (1246:21): [True: 0, False: 7.10k]
  |  Branch (1246:46): [True: 0, False: 7.10k]
  ------------------
 1247|      0|                {
 1248|      0|                    TIFFErrorExtR(tif, module,
 1249|      0|                                  "Integer overflow in restart interval");
 1250|      0|                    return (0);
 1251|      0|                }
 1252|  7.10k|                sp->restart_interval = (uint16_t)restart_interval;
 1253|  7.10k|            }
 1254|  7.10k|        }
 1255|  7.10k|    }
 1256|  42.0k|    if (OJPEGReadHeaderInfoSec(tif) == 0)
  ------------------
  |  Branch (1256:9): [True: 41.7k, False: 331]
  ------------------
 1257|  41.7k|        return (0);
 1258|    331|    sp->sos_end[0].log = 1;
 1259|    331|    sp->sos_end[0].in_buffer_source = sp->in_buffer_source;
 1260|    331|    sp->sos_end[0].in_buffer_next_strile = sp->in_buffer_next_strile;
 1261|    331|    sp->sos_end[0].in_buffer_file_pos =
 1262|    331|        sp->in_buffer_file_pos - sp->in_buffer_togo;
 1263|    331|    sp->sos_end[0].in_buffer_file_togo =
 1264|    331|        sp->in_buffer_file_togo + sp->in_buffer_togo;
 1265|    331|    sp->readheader_done = 1;
 1266|    331|    return (1);
 1267|  42.0k|}
tif_ojpeg.c:OJPEGReadSecondarySos:
 1270|  15.3k|{
 1271|  15.3k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1272|  15.3k|    uint8_t m;
 1273|  15.3k|    assert(s > 0);
  ------------------
  |  Branch (1273:5): [True: 0, False: 15.3k]
  |  Branch (1273:5): [True: 15.3k, False: 0]
  ------------------
 1274|  15.3k|    assert(s < 3);
  ------------------
  |  Branch (1274:5): [True: 0, False: 15.3k]
  |  Branch (1274:5): [True: 15.3k, False: 0]
  ------------------
 1275|  15.3k|    assert(sp->sos_end[0].log != 0);
  ------------------
  |  Branch (1275:5): [True: 0, False: 15.3k]
  |  Branch (1275:5): [True: 15.3k, False: 0]
  ------------------
 1276|  15.3k|    assert(sp->sos_end[s].log == 0);
  ------------------
  |  Branch (1276:5): [True: 0, False: 15.3k]
  |  Branch (1276:5): [True: 15.3k, False: 0]
  ------------------
 1277|  15.3k|    sp->plane_sample_offset = (uint8_t)(s - 1);
 1278|  16.3k|    while (sp->sos_end[sp->plane_sample_offset].log == 0)
  ------------------
  |  Branch (1278:12): [True: 1.06k, False: 15.3k]
  ------------------
 1279|  1.06k|        sp->plane_sample_offset--;
 1280|  15.3k|    sp->in_buffer_source =
 1281|  15.3k|        sp->sos_end[sp->plane_sample_offset].in_buffer_source;
 1282|  15.3k|    sp->in_buffer_next_strile =
 1283|  15.3k|        sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile;
 1284|  15.3k|    sp->in_buffer_file_pos =
 1285|  15.3k|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos;
 1286|  15.3k|    sp->in_buffer_file_pos_log = 0;
 1287|  15.3k|    sp->in_buffer_file_togo =
 1288|  15.3k|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo;
 1289|  15.3k|    sp->in_buffer_togo = 0;
 1290|  15.3k|    sp->in_buffer_cur = 0;
 1291|  15.5k|    while (sp->plane_sample_offset < s)
  ------------------
  |  Branch (1291:12): [True: 15.3k, False: 195]
  ------------------
 1292|  15.3k|    {
 1293|  15.3k|        do
 1294|  39.1M|        {
 1295|  39.1M|            if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1295:17): [True: 9.21k, False: 39.1M]
  ------------------
 1296|  9.21k|                return (0);
 1297|  39.1M|            if (m == 255)
  ------------------
  |  Branch (1297:17): [True: 376k, False: 38.7M]
  ------------------
 1298|   376k|            {
 1299|   376k|                do
 1300|  1.08M|                {
 1301|  1.08M|                    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1301:25): [True: 152, False: 1.08M]
  ------------------
 1302|    152|                        return (0);
 1303|  1.08M|                    if (m != 255)
  ------------------
  |  Branch (1303:25): [True: 376k, False: 708k]
  ------------------
 1304|   376k|                        break;
 1305|  1.08M|                } while (1);
  ------------------
  |  Branch (1305:26): [True: 708k, Folded]
  ------------------
 1306|   376k|                if (m == JPEG_MARKER_SOS)
  ------------------
  |  |  165|   376k|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1306:21): [True: 5.94k, False: 370k]
  ------------------
 1307|  5.94k|                    break;
 1308|   376k|            }
 1309|  39.1M|        } while (1);
  ------------------
  |  Branch (1309:18): [True: 39.1M, Folded]
  ------------------
 1310|  5.94k|        sp->plane_sample_offset++;
 1311|  5.94k|        if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
  ------------------
  |  Branch (1311:13): [True: 5.75k, False: 195]
  ------------------
 1312|  5.75k|            return (0);
 1313|    195|        sp->sos_end[sp->plane_sample_offset].log = 1;
 1314|    195|        sp->sos_end[sp->plane_sample_offset].in_buffer_source =
 1315|    195|            sp->in_buffer_source;
 1316|    195|        sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile =
 1317|    195|            sp->in_buffer_next_strile;
 1318|    195|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos =
 1319|    195|            sp->in_buffer_file_pos - sp->in_buffer_togo;
 1320|    195|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo =
 1321|    195|            sp->in_buffer_file_togo + sp->in_buffer_togo;
 1322|    195|    }
 1323|    195|    return (1);
 1324|  15.3k|}
tif_ojpeg.c:OJPEGLibjpegSessionAbort:
 1527|  22.9k|{
 1528|  22.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1529|  22.9k|    assert(sp->libjpeg_session_active != 0);
  ------------------
  |  Branch (1529:5): [True: 0, False: 22.9k]
  |  Branch (1529:5): [True: 22.9k, False: 0]
  ------------------
 1530|  22.9k|    jpeg_destroy(
 1531|  22.9k|        (tiff_ojpeg_common_struct *)(&(sp->libjpeg_jpeg_decompress_struct)));
 1532|  22.9k|    sp->libjpeg_session_active = 0;
 1533|  22.9k|}
tif_ojpeg.c:OJPEGWriteHeaderInfo:
 1327|  74.9k|{
 1328|  74.9k|    static const char module[] = "OJPEGWriteHeaderInfo";
 1329|  74.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1330|  74.9k|    uint8_t **m;
 1331|  74.9k|    uint32_t n;
 1332|       |    /* if a previous attempt failed, don't try again */
 1333|  74.9k|    if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (1333:9): [True: 51.9k, False: 22.9k]
  ------------------
 1334|  51.9k|        return 0;
 1335|  22.9k|    sp->out_state = ososSoi;
 1336|  22.9k|    sp->restart_index = 0;
 1337|  22.9k|    jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
 1338|  22.9k|    sp->libjpeg_jpeg_error_mgr.output_message =
 1339|  22.9k|        OJPEGLibjpegJpegErrorMgrOutputMessage;
 1340|  22.9k|    sp->libjpeg_jpeg_error_mgr.error_exit = OJPEGLibjpegJpegErrorMgrErrorExit;
 1341|  22.9k|    sp->libjpeg_jpeg_decompress_struct.err = &(sp->libjpeg_jpeg_error_mgr);
 1342|  22.9k|    sp->libjpeg_jpeg_decompress_struct.client_data = (void *)tif;
 1343|  22.9k|    if (jpeg_create_decompress_encap(
  ------------------
  |  Branch (1343:9): [True: 0, False: 22.9k]
  ------------------
 1344|  22.9k|            sp, &(sp->libjpeg_jpeg_decompress_struct)) == 0)
 1345|      0|        return (0);
 1346|  22.9k|    sp->libjpeg_session_active = 1;
 1347|  22.9k|    sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = 0;
 1348|  22.9k|    sp->libjpeg_jpeg_source_mgr.init_source =
 1349|  22.9k|        OJPEGLibjpegJpegSourceMgrInitSource;
 1350|  22.9k|    sp->libjpeg_jpeg_source_mgr.fill_input_buffer =
 1351|  22.9k|        OJPEGLibjpegJpegSourceMgrFillInputBuffer;
 1352|  22.9k|    sp->libjpeg_jpeg_source_mgr.skip_input_data =
 1353|  22.9k|        OJPEGLibjpegJpegSourceMgrSkipInputData;
 1354|  22.9k|    sp->libjpeg_jpeg_source_mgr.resync_to_restart =
 1355|  22.9k|        OJPEGLibjpegJpegSourceMgrResyncToRestart;
 1356|  22.9k|    sp->libjpeg_jpeg_source_mgr.term_source =
 1357|  22.9k|        OJPEGLibjpegJpegSourceMgrTermSource;
 1358|  22.9k|    sp->libjpeg_jpeg_decompress_struct.src = &(sp->libjpeg_jpeg_source_mgr);
 1359|  22.9k|    if (jpeg_read_header_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), 1) ==
  ------------------
  |  Branch (1359:9): [True: 122, False: 22.8k]
  ------------------
 1360|  22.9k|        0)
 1361|    122|        return (0);
 1362|  22.8k|    if ((sp->subsampling_force_desubsampling_inside_decompression == 0) &&
  ------------------
  |  Branch (1362:9): [True: 22.8k, False: 10]
  ------------------
 1363|  22.8k|        (sp->samples_per_pixel_per_plane > 1))
  ------------------
  |  Branch (1363:9): [True: 40, False: 22.7k]
  ------------------
 1364|     40|    {
 1365|     40|        sp->libjpeg_jpeg_decompress_struct.raw_data_out = 1;
 1366|       |#if JPEG_LIB_VERSION >= 70
 1367|       |        sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling = FALSE;
 1368|       |#endif
 1369|     40|        sp->libjpeg_jpeg_query_style = 0;
 1370|     40|        if (sp->subsampling_convert_log == 0)
  ------------------
  |  Branch (1370:13): [True: 26, False: 14]
  ------------------
 1371|     26|        {
 1372|     26|            assert(sp->subsampling_convert_ycbcrbuf == 0);
  ------------------
  |  Branch (1372:13): [True: 0, False: 26]
  |  Branch (1372:13): [True: 26, False: 0]
  ------------------
 1373|     26|            assert(sp->subsampling_convert_ycbcrimage == 0);
  ------------------
  |  Branch (1373:13): [True: 0, False: 26]
  |  Branch (1373:13): [True: 26, False: 0]
  ------------------
 1374|       |            /* Check for division by zero. */
 1375|     26|            if (sp->subsampling_hor == 0 || sp->subsampling_ver == 0)
  ------------------
  |  Branch (1375:17): [True: 0, False: 26]
  |  Branch (1375:45): [True: 0, False: 26]
  ------------------
 1376|      0|                return (0);
 1377|       |            /* Check for potential overflow in subsampling_convert_ylinelen
 1378|       |             * computation.
 1379|       |             */
 1380|     26|            if (sp->strile_width >
  ------------------
  |  Branch (1380:17): [True: 0, False: 26]
  ------------------
 1381|     26|                UINT32_MAX - ((uint32_t)sp->subsampling_hor * 8 - 1))
 1382|      0|                return (0);
 1383|     26|            sp->subsampling_convert_ylinelen =
 1384|     26|                ((sp->strile_width + (uint32_t)sp->subsampling_hor * 8 - 1) /
 1385|     26|                 ((uint32_t)sp->subsampling_hor * 8) *
 1386|     26|                 ((uint32_t)sp->subsampling_hor * 8));
 1387|     26|            sp->subsampling_convert_ylines = (uint32_t)sp->subsampling_ver * 8;
 1388|     26|            sp->subsampling_convert_clinelen =
 1389|     26|                sp->subsampling_convert_ylinelen / sp->subsampling_hor;
 1390|     26|            sp->subsampling_convert_clines = 8;
 1391|       |            /* Check for potential overflow in buffer length computations.
 1392|       |             * Use 64-bit intermediates to detect uint32_t overflow in
 1393|       |             * ylinelen * ylines, clinelen * clines, and their sum.
 1394|       |             */
 1395|     26|            {
 1396|     26|                uint64_t ybuflen64 =
 1397|     26|                    (uint64_t)sp->subsampling_convert_ylinelen *
 1398|     26|                    sp->subsampling_convert_ylines;
 1399|     26|                uint64_t cbuflen64 =
 1400|     26|                    (uint64_t)sp->subsampling_convert_clinelen *
 1401|     26|                    sp->subsampling_convert_clines;
 1402|     26|                uint64_t ycbcrbuflen64 = ybuflen64 + 2 * cbuflen64;
 1403|     26|                if (ybuflen64 > UINT32_MAX || cbuflen64 > UINT32_MAX ||
  ------------------
  |  Branch (1403:21): [True: 0, False: 26]
  |  Branch (1403:47): [True: 0, False: 26]
  ------------------
 1404|     26|                    ycbcrbuflen64 > UINT32_MAX)
  ------------------
  |  Branch (1404:21): [True: 0, False: 26]
  ------------------
 1405|      0|                {
 1406|      0|                    TIFFErrorExtR(tif, module,
 1407|      0|                                  "Integer overflow in OJPEG buffer size");
 1408|      0|                    return (0);
 1409|      0|                }
 1410|     26|                sp->subsampling_convert_ybuflen = (uint32_t)ybuflen64;
 1411|     26|                sp->subsampling_convert_cbuflen = (uint32_t)cbuflen64;
 1412|     26|                sp->subsampling_convert_ycbcrbuflen = (uint32_t)ycbcrbuflen64;
 1413|     26|            }
 1414|       |            /* The calloc is not normally necessary, except in some edge/broken
 1415|       |             * cases */
 1416|       |            /* for example for a tiled image of height 1 with a tile height of 1
 1417|       |             * and subsampling_hor=subsampling_ver=2 */
 1418|       |            /* In that case, libjpeg will only fill the 8 first lines of the 16
 1419|       |             * lines */
 1420|       |            /* See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844
 1421|       |             */
 1422|       |            /* Even if this case is allowed (?), its handling is broken because
 1423|       |             * OJPEGPreDecode() should also likely */
 1424|       |            /* reset subsampling_convert_state to 0 when changing tile. */
 1425|      0|            sp->subsampling_convert_ycbcrbuf = (uint8_t *)_TIFFcallocExt(
 1426|     26|                tif, 1, sp->subsampling_convert_ycbcrbuflen);
 1427|     26|            if (sp->subsampling_convert_ycbcrbuf == 0)
  ------------------
  |  Branch (1427:17): [True: 0, False: 26]
  ------------------
 1428|      0|            {
 1429|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1430|      0|                return (0);
 1431|      0|            }
 1432|     26|            sp->subsampling_convert_ybuf = sp->subsampling_convert_ycbcrbuf;
 1433|     26|            sp->subsampling_convert_cbbuf =
 1434|     26|                sp->subsampling_convert_ybuf + sp->subsampling_convert_ybuflen;
 1435|     26|            sp->subsampling_convert_crbuf =
 1436|     26|                sp->subsampling_convert_cbbuf + sp->subsampling_convert_cbuflen;
 1437|     26|            sp->subsampling_convert_ycbcrimagelen =
 1438|     26|                3 + sp->subsampling_convert_ylines +
 1439|     26|                2 * sp->subsampling_convert_clines;
 1440|     26|            sp->subsampling_convert_ycbcrimage = (uint8_t **)_TIFFmallocExt(
 1441|     26|                tif, (tmsize_t)((size_t)sp->subsampling_convert_ycbcrimagelen *
 1442|     26|                                sizeof(uint8_t *)));
 1443|     26|            if (sp->subsampling_convert_ycbcrimage == 0)
  ------------------
  |  Branch (1443:17): [True: 0, False: 26]
  ------------------
 1444|      0|            {
 1445|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1446|      0|                return (0);
 1447|      0|            }
 1448|     26|            m = sp->subsampling_convert_ycbcrimage;
 1449|     26|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3);
 1450|     26|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
 1451|     26|                               sp->subsampling_convert_ylines);
 1452|     26|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
 1453|     26|                               sp->subsampling_convert_ylines +
 1454|     26|                               sp->subsampling_convert_clines);
 1455|    490|            for (n = 0; n < sp->subsampling_convert_ylines; n++)
  ------------------
  |  Branch (1455:25): [True: 464, False: 26]
  ------------------
 1456|    464|                *m++ = sp->subsampling_convert_ybuf +
 1457|    464|                       n * sp->subsampling_convert_ylinelen;
 1458|    234|            for (n = 0; n < sp->subsampling_convert_clines; n++)
  ------------------
  |  Branch (1458:25): [True: 208, False: 26]
  ------------------
 1459|    208|                *m++ = sp->subsampling_convert_cbbuf +
 1460|    208|                       n * sp->subsampling_convert_clinelen;
 1461|    234|            for (n = 0; n < sp->subsampling_convert_clines; n++)
  ------------------
  |  Branch (1461:25): [True: 208, False: 26]
  ------------------
 1462|    208|                *m++ = sp->subsampling_convert_crbuf +
 1463|    208|                       n * sp->subsampling_convert_clinelen;
 1464|     26|            sp->subsampling_convert_clinelenout =
 1465|     26|                sp->strile_width / sp->subsampling_hor +
 1466|     26|                ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0);
  ------------------
  |  Branch (1466:18): [True: 14, False: 12]
  ------------------
 1467|     26|            sp->subsampling_convert_state = 0;
 1468|     26|            sp->error_in_raw_data_decoding = 0;
 1469|       |
 1470|     26|            const uint64_t bpl =
 1471|     26|                (uint64_t)sp->subsampling_convert_clinelenout *
 1472|     26|                ((uint64_t)sp->subsampling_ver * sp->subsampling_hor + 2);
 1473|     26|            if (bpl > UINT32_MAX)
  ------------------
  |  Branch (1473:17): [True: 0, False: 26]
  ------------------
 1474|      0|                return (0);
 1475|     26|            sp->bytes_per_line = (uint32_t)bpl;
 1476|       |
 1477|     26|            sp->lines_per_strile =
 1478|     26|                sp->strile_length / sp->subsampling_ver +
 1479|     26|                ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0);
  ------------------
  |  Branch (1479:18): [True: 14, False: 12]
  ------------------
 1480|     26|            sp->subsampling_convert_log = 1;
 1481|     26|        }
 1482|     40|    }
 1483|  22.8k|    else
 1484|  22.8k|    {
 1485|  22.8k|        sp->libjpeg_jpeg_decompress_struct.jpeg_color_space = JCS_UNKNOWN;
 1486|  22.8k|        sp->libjpeg_jpeg_decompress_struct.out_color_space = JCS_UNKNOWN;
 1487|  22.8k|        sp->libjpeg_jpeg_query_style = 1;
 1488|  22.8k|        sp->bytes_per_line =
 1489|  22.8k|            _TIFFMultiply32(tif, sp->samples_per_pixel_per_plane,
 1490|  22.8k|                            sp->strile_width, "OJPEGWriteHeaderInfo");
 1491|  22.8k|        if (sp->bytes_per_line == 0)
  ------------------
  |  Branch (1491:13): [True: 0, False: 22.8k]
  ------------------
 1492|      0|            return (0);
 1493|  22.8k|        sp->lines_per_strile = sp->strile_length;
 1494|  22.8k|    }
 1495|  22.8k|    if (jpeg_start_decompress_encap(sp,
  ------------------
  |  Branch (1495:9): [True: 40, False: 22.8k]
  ------------------
 1496|  22.8k|                                    &(sp->libjpeg_jpeg_decompress_struct)) == 0)
 1497|     40|        return (0);
 1498|  22.8k|    if (sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width)
  ------------------
  |  Branch (1498:9): [True: 0, False: 22.8k]
  ------------------
 1499|      0|    {
 1500|      0|        TIFFErrorExtR(tif, module,
 1501|      0|                      "jpeg_start_decompress() returned image_width = %u, "
 1502|      0|                      "expected %" PRIu32,
 1503|      0|                      sp->libjpeg_jpeg_decompress_struct.image_width,
 1504|      0|                      sp->strile_width);
 1505|      0|        return 0;
 1506|      0|    }
 1507|  22.8k|    if (sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor !=
  ------------------
  |  Branch (1507:9): [True: 10, False: 22.7k]
  ------------------
 1508|  22.8k|            sp->subsampling_hor ||
 1509|  22.7k|        sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor !=
  ------------------
  |  Branch (1509:9): [True: 6, False: 22.7k]
  ------------------
 1510|  22.7k|            sp->subsampling_ver)
 1511|     16|    {
 1512|     16|        TIFFErrorExtR(tif, module,
 1513|     16|                      "jpeg_start_decompress() returned max_h_samp_factor = %d "
 1514|     16|                      "and max_v_samp_factor = %d, expected %" PRIu8
 1515|     16|                      " and %" PRIu8,
 1516|     16|                      sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
 1517|     16|                      sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
 1518|     16|                      sp->subsampling_hor, sp->subsampling_ver);
 1519|     16|        return 0;
 1520|     16|    }
 1521|       |
 1522|  22.7k|    sp->writeheader_done = 1;
 1523|  22.7k|    return (1);
 1524|  22.8k|}
tif_ojpeg.c:OJPEGLibjpegJpegErrorMgrOutputMessage:
 2803|  22.7k|{
 2804|  22.7k|    char buffer[JMSG_LENGTH_MAX];
 2805|  22.7k|    (*cinfo->err->format_message)(cinfo, buffer);
 2806|  22.7k|    TIFFWarningExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
 2807|  22.7k|}
tif_ojpeg.c:OJPEGLibjpegJpegErrorMgrErrorExit:
 2810|    162|{
 2811|    162|    char buffer[JMSG_LENGTH_MAX];
 2812|    162|    (*cinfo->err->format_message)(cinfo, buffer);
 2813|    162|    TIFFErrorExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
 2814|    162|    jpeg_encap_unwind((TIFF *)(cinfo->client_data));
 2815|    162|}
tif_ojpeg.c:jpeg_encap_unwind:
 2795|  35.1k|{
 2796|  35.1k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2797|  35.1k|    LONGJMP(sp->exit_jmpbuf, 1);
  ------------------
  |  |  153|  35.1k|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
 2798|  35.1k|}
tif_ojpeg.c:jpeg_create_decompress_encap:
 2723|  22.9k|{
 2724|  22.9k|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|  22.9k|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2724:9): [True: 0, False: 22.9k]
  ------------------
 2725|      0|        return 0;
 2726|  22.9k|    else
 2727|  22.9k|    {
 2728|       |        jpeg_create_decompress(cinfo);
 2729|  22.9k|        return 1;
 2730|  22.9k|    }
 2731|  22.9k|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrInitSource:
 2819|  22.9k|{
 2820|  22.9k|    (void)cinfo;
 2821|  22.9k|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrFillInputBuffer:
 2825|   153k|{
 2826|   153k|    TIFF *tif = (TIFF *)cinfo->client_data;
 2827|   153k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2828|   153k|    void *mem = 0;
 2829|   153k|    uint32_t len = 0U;
 2830|   153k|    if (OJPEGWriteStream(tif, &mem, &len) == 0)
  ------------------
  |  Branch (2830:9): [True: 1.02k, False: 152k]
  ------------------
 2831|  1.02k|    {
 2832|  1.02k|        TIFFErrorExtR(tif, "LibJpeg", "Premature end of JPEG data");
 2833|  1.02k|        jpeg_encap_unwind(tif);
 2834|  1.02k|    }
 2835|   153k|    sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = len;
 2836|   153k|    sp->libjpeg_jpeg_source_mgr.next_input_byte = (const JOCTET *)mem;
 2837|   153k|    return (1);
 2838|   153k|}
tif_ojpeg.c:OJPEGWriteStream:
 2452|   153k|{
 2453|   153k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2454|   153k|    *len = 0;
 2455|   153k|    do
 2456|   413k|    {
 2457|   413k|        assert(sp->out_state <= ososEoi);
  ------------------
  |  Branch (2457:9): [True: 0, False: 413k]
  |  Branch (2457:9): [True: 413k, False: 0]
  ------------------
 2458|   413k|        switch (sp->out_state)
 2459|   413k|        {
 2460|  22.9k|            case ososSoi:
  ------------------
  |  Branch (2460:13): [True: 22.9k, False: 390k]
  ------------------
 2461|  22.9k|                OJPEGWriteStreamSoi(tif, mem, len);
 2462|  22.9k|                break;
 2463|  22.9k|            case ososQTable0:
  ------------------
  |  Branch (2463:13): [True: 22.9k, False: 390k]
  ------------------
 2464|  22.9k|                OJPEGWriteStreamQTable(tif, 0, mem, len);
 2465|  22.9k|                break;
 2466|  22.9k|            case ososQTable1:
  ------------------
  |  Branch (2466:13): [True: 22.9k, False: 390k]
  ------------------
 2467|  22.9k|                OJPEGWriteStreamQTable(tif, 1, mem, len);
 2468|  22.9k|                break;
 2469|  22.9k|            case ososQTable2:
  ------------------
  |  Branch (2469:13): [True: 22.9k, False: 390k]
  ------------------
 2470|  22.9k|                OJPEGWriteStreamQTable(tif, 2, mem, len);
 2471|  22.9k|                break;
 2472|  22.9k|            case ososQTable3:
  ------------------
  |  Branch (2472:13): [True: 22.9k, False: 390k]
  ------------------
 2473|  22.9k|                OJPEGWriteStreamQTable(tif, 3, mem, len);
 2474|  22.9k|                break;
 2475|  22.9k|            case ososDcTable0:
  ------------------
  |  Branch (2475:13): [True: 22.9k, False: 390k]
  ------------------
 2476|  22.9k|                OJPEGWriteStreamDcTable(tif, 0, mem, len);
 2477|  22.9k|                break;
 2478|  22.9k|            case ososDcTable1:
  ------------------
  |  Branch (2478:13): [True: 22.9k, False: 390k]
  ------------------
 2479|  22.9k|                OJPEGWriteStreamDcTable(tif, 1, mem, len);
 2480|  22.9k|                break;
 2481|  22.9k|            case ososDcTable2:
  ------------------
  |  Branch (2481:13): [True: 22.9k, False: 390k]
  ------------------
 2482|  22.9k|                OJPEGWriteStreamDcTable(tif, 2, mem, len);
 2483|  22.9k|                break;
 2484|  22.9k|            case ososDcTable3:
  ------------------
  |  Branch (2484:13): [True: 22.9k, False: 390k]
  ------------------
 2485|  22.9k|                OJPEGWriteStreamDcTable(tif, 3, mem, len);
 2486|  22.9k|                break;
 2487|  22.9k|            case ososAcTable0:
  ------------------
  |  Branch (2487:13): [True: 22.9k, False: 390k]
  ------------------
 2488|  22.9k|                OJPEGWriteStreamAcTable(tif, 0, mem, len);
 2489|  22.9k|                break;
 2490|  22.9k|            case ososAcTable1:
  ------------------
  |  Branch (2490:13): [True: 22.9k, False: 390k]
  ------------------
 2491|  22.9k|                OJPEGWriteStreamAcTable(tif, 1, mem, len);
 2492|  22.9k|                break;
 2493|  22.9k|            case ososAcTable2:
  ------------------
  |  Branch (2493:13): [True: 22.9k, False: 390k]
  ------------------
 2494|  22.9k|                OJPEGWriteStreamAcTable(tif, 2, mem, len);
 2495|  22.9k|                break;
 2496|  22.9k|            case ososAcTable3:
  ------------------
  |  Branch (2496:13): [True: 22.9k, False: 390k]
  ------------------
 2497|  22.9k|                OJPEGWriteStreamAcTable(tif, 3, mem, len);
 2498|  22.9k|                break;
 2499|  22.9k|            case ososDri:
  ------------------
  |  Branch (2499:13): [True: 22.9k, False: 390k]
  ------------------
 2500|  22.9k|                OJPEGWriteStreamDri(tif, mem, len);
 2501|  22.9k|                break;
 2502|  22.9k|            case ososSof:
  ------------------
  |  Branch (2502:13): [True: 22.9k, False: 390k]
  ------------------
 2503|  22.9k|                OJPEGWriteStreamSof(tif, mem, len);
 2504|  22.9k|                break;
 2505|  22.9k|            case ososSos:
  ------------------
  |  Branch (2505:13): [True: 22.9k, False: 390k]
  ------------------
 2506|  22.9k|                OJPEGWriteStreamSos(tif, mem, len);
 2507|  22.9k|                break;
 2508|  36.0k|            case ososCompressed:
  ------------------
  |  Branch (2508:13): [True: 36.0k, False: 377k]
  ------------------
 2509|  36.0k|                if (OJPEGWriteStreamCompressed(tif, mem, len) == 0)
  ------------------
  |  Branch (2509:21): [True: 1.02k, False: 35.0k]
  ------------------
 2510|  1.02k|                    return (0);
 2511|  35.0k|                break;
 2512|  35.0k|            case ososRst:
  ------------------
  |  Branch (2512:13): [True: 10.7k, False: 403k]
  ------------------
 2513|  10.7k|                OJPEGWriteStreamRst(tif, mem, len);
 2514|  10.7k|                break;
 2515|     18|            case ososEoi:
  ------------------
  |  Branch (2515:13): [True: 18, False: 413k]
  ------------------
 2516|     18|                OJPEGWriteStreamEoi(tif, mem, len);
 2517|     18|                break;
 2518|      0|            default:
  ------------------
  |  Branch (2518:13): [True: 0, False: 413k]
  ------------------
 2519|      0|                break;
 2520|   413k|        }
 2521|   413k|    } while (*len == 0);
  ------------------
  |  Branch (2521:14): [True: 260k, False: 152k]
  ------------------
 2522|   152k|    return (1);
 2523|   153k|}
tif_ojpeg.c:OJPEGWriteStreamSoi:
 2526|  22.9k|{
 2527|  22.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2528|  22.9k|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2528:5): [True: 0, Folded]
  |  Branch (2528:5): [True: 22.9k, Folded]
  ------------------
 2529|  22.9k|    sp->out_buffer[0] = 255;
 2530|  22.9k|    sp->out_buffer[1] = JPEG_MARKER_SOI;
  ------------------
  |  |  163|  22.9k|#define JPEG_MARKER_SOI 0xD8
  ------------------
 2531|  22.9k|    *len = 2;
 2532|  22.9k|    *mem = (void *)sp->out_buffer;
 2533|  22.9k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2534|  22.9k|}
tif_ojpeg.c:OJPEGWriteStreamQTable:
 2538|  91.8k|{
 2539|  91.8k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2540|  91.8k|    if (sp->qtable[table_index] != 0)
  ------------------
  |  Branch (2540:9): [True: 23.0k, False: 68.8k]
  ------------------
 2541|  23.0k|    {
 2542|  23.0k|        *mem = (void *)(sp->qtable[table_index] + sizeof(uint32_t));
 2543|  23.0k|        *len = (uint32_t)(*((uint32_t *)sp->qtable[table_index]) -
 2544|  23.0k|                          sizeof(uint32_t));
 2545|  23.0k|    }
 2546|  91.8k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2547|  91.8k|}
tif_ojpeg.c:OJPEGWriteStreamDcTable:
 2551|  91.8k|{
 2552|  91.8k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2553|  91.8k|    if (sp->dctable[table_index] != 0)
  ------------------
  |  Branch (2553:9): [True: 205, False: 91.6k]
  ------------------
 2554|    205|    {
 2555|    205|        *mem = (void *)(sp->dctable[table_index] + sizeof(uint32_t));
 2556|    205|        *len = (uint32_t)(*((uint32_t *)sp->dctable[table_index]) -
 2557|    205|                          sizeof(uint32_t));
 2558|    205|    }
 2559|  91.8k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2560|  91.8k|}
tif_ojpeg.c:OJPEGWriteStreamAcTable:
 2564|  91.6k|{
 2565|  91.6k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2566|  91.6k|    if (sp->actable[table_index] != 0)
  ------------------
  |  Branch (2566:9): [True: 121, False: 91.5k]
  ------------------
 2567|    121|    {
 2568|    121|        *mem = (void *)(sp->actable[table_index] + sizeof(uint32_t));
 2569|    121|        *len = (uint32_t)(*((uint32_t *)sp->actable[table_index]) -
 2570|    121|                          sizeof(uint32_t));
 2571|    121|    }
 2572|  91.6k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2573|  91.6k|}
tif_ojpeg.c:OJPEGWriteStreamDri:
 2576|  22.9k|{
 2577|  22.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2578|  22.9k|    assert(OJPEG_BUFFER >= 6);
  ------------------
  |  Branch (2578:5): [True: 0, Folded]
  |  Branch (2578:5): [True: 22.9k, Folded]
  ------------------
 2579|  22.9k|    if (sp->restart_interval != 0)
  ------------------
  |  Branch (2579:9): [True: 14.5k, False: 8.32k]
  ------------------
 2580|  14.5k|    {
 2581|  14.5k|        sp->out_buffer[0] = 255;
 2582|  14.5k|        sp->out_buffer[1] = JPEG_MARKER_DRI;
  ------------------
  |  |  167|  14.5k|#define JPEG_MARKER_DRI 0xDD
  ------------------
 2583|  14.5k|        sp->out_buffer[2] = 0;
 2584|  14.5k|        sp->out_buffer[3] = 4;
 2585|  14.5k|        sp->out_buffer[4] = (uint8_t)(sp->restart_interval >> 8);
 2586|  14.5k|        sp->out_buffer[5] = (uint8_t)(sp->restart_interval & 255);
 2587|  14.5k|        *len = 6;
 2588|  14.5k|        *mem = (void *)sp->out_buffer;
 2589|  14.5k|    }
 2590|  22.9k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2591|  22.9k|}
tif_ojpeg.c:OJPEGWriteStreamSof:
 2594|  22.9k|{
 2595|  22.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2596|  22.9k|    uint8_t m;
 2597|  22.9k|    assert(OJPEG_BUFFER >= 2 + 8 + sp->samples_per_pixel_per_plane * 3);
  ------------------
  |  Branch (2597:5): [True: 0, False: 22.9k]
  |  Branch (2597:5): [True: 22.9k, False: 0]
  ------------------
 2598|  22.9k|    assert(255 >= 8 + sp->samples_per_pixel_per_plane * 3);
  ------------------
  |  Branch (2598:5): [True: 0, False: 22.9k]
  |  Branch (2598:5): [True: 22.9k, False: 0]
  ------------------
 2599|  22.9k|    sp->out_buffer[0] = 255;
 2600|  22.9k|    sp->out_buffer[1] = sp->sof_marker_id;
 2601|       |    /* Lf */
 2602|  22.9k|    sp->out_buffer[2] = 0;
 2603|  22.9k|    sp->out_buffer[3] = (uint8_t)(8 + sp->samples_per_pixel_per_plane * 3);
 2604|       |    /* P */
 2605|  22.9k|    sp->out_buffer[4] = 8;
 2606|       |    /* Y */
 2607|  22.9k|    sp->out_buffer[5] = (uint8_t)(sp->sof_y >> 8);
 2608|  22.9k|    sp->out_buffer[6] = (uint8_t)(sp->sof_y & 255);
 2609|       |    /* X */
 2610|  22.9k|    sp->out_buffer[7] = (uint8_t)(sp->sof_x >> 8);
 2611|  22.9k|    sp->out_buffer[8] = (uint8_t)(sp->sof_x & 255);
 2612|       |    /* Nf */
 2613|  22.9k|    sp->out_buffer[9] = sp->samples_per_pixel_per_plane;
 2614|  45.9k|    for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
  ------------------
  |  Branch (2614:17): [True: 23.0k, False: 22.9k]
  ------------------
 2615|  23.0k|    {
 2616|       |        /* C */
 2617|  23.0k|        sp->out_buffer[10 + m * 3] = sp->sof_c[sp->plane_sample_offset + m];
 2618|       |        /* H and V */
 2619|  23.0k|        sp->out_buffer[10 + m * 3 + 1] =
 2620|  23.0k|            sp->sof_hv[sp->plane_sample_offset + m];
 2621|       |        /* Tq */
 2622|  23.0k|        sp->out_buffer[10 + m * 3 + 2] =
 2623|  23.0k|            sp->sof_tq[sp->plane_sample_offset + m];
 2624|  23.0k|    }
 2625|  22.9k|    *len = 10 + (uint32_t)sp->samples_per_pixel_per_plane * 3;
 2626|  22.9k|    *mem = (void *)sp->out_buffer;
 2627|  22.9k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2628|  22.9k|}
tif_ojpeg.c:OJPEGWriteStreamSos:
 2631|  22.9k|{
 2632|  22.9k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2633|  22.9k|    uint8_t m;
 2634|  22.9k|    assert(OJPEG_BUFFER >= 2 + 6 + sp->samples_per_pixel_per_plane * 2);
  ------------------
  |  Branch (2634:5): [True: 0, False: 22.9k]
  |  Branch (2634:5): [True: 22.9k, False: 0]
  ------------------
 2635|  22.9k|    assert(255 >= 6 + sp->samples_per_pixel_per_plane * 2);
  ------------------
  |  Branch (2635:5): [True: 0, False: 22.9k]
  |  Branch (2635:5): [True: 22.9k, False: 0]
  ------------------
 2636|  22.9k|    sp->out_buffer[0] = 255;
 2637|  22.9k|    sp->out_buffer[1] = JPEG_MARKER_SOS;
  ------------------
  |  |  165|  22.9k|#define JPEG_MARKER_SOS 0xDA
  ------------------
 2638|       |    /* Ls */
 2639|  22.9k|    sp->out_buffer[2] = 0;
 2640|  22.9k|    sp->out_buffer[3] = (uint8_t)(6 + sp->samples_per_pixel_per_plane * 2);
 2641|       |    /* Ns */
 2642|  22.9k|    sp->out_buffer[4] = sp->samples_per_pixel_per_plane;
 2643|  45.9k|    for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
  ------------------
  |  Branch (2643:17): [True: 23.0k, False: 22.9k]
  ------------------
 2644|  23.0k|    {
 2645|       |        /* Cs */
 2646|  23.0k|        sp->out_buffer[5 + m * 2] = sp->sos_cs[sp->plane_sample_offset + m];
 2647|       |        /* Td and Ta */
 2648|  23.0k|        sp->out_buffer[5 + m * 2 + 1] =
 2649|  23.0k|            sp->sos_tda[sp->plane_sample_offset + m];
 2650|  23.0k|    }
 2651|       |    /* Ss */
 2652|  22.9k|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2] = 0;
 2653|       |    /* Se */
 2654|  22.9k|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 1] = 63;
 2655|       |    /* Ah and Al */
 2656|  22.9k|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 2] = 0;
 2657|  22.9k|    *len = 8 + (uint32_t)sp->samples_per_pixel_per_plane * 2;
 2658|  22.9k|    *mem = (void *)sp->out_buffer;
 2659|  22.9k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2660|  22.9k|}
tif_ojpeg.c:OJPEGWriteStreamCompressed:
 2663|  36.0k|{
 2664|  36.0k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2665|  36.0k|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2665:9): [True: 35.6k, False: 384]
  ------------------
 2666|  35.6k|    {
 2667|  35.6k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2667:13): [True: 1.02k, False: 34.6k]
  ------------------
 2668|  1.02k|            return (0);
 2669|  35.6k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2669:9): [True: 0, False: 34.6k]
  |  Branch (2669:9): [True: 34.6k, False: 0]
  ------------------
 2670|  34.6k|    }
 2671|  35.0k|    *len = sp->in_buffer_togo;
 2672|  35.0k|    *mem = (void *)sp->in_buffer_cur;
 2673|  35.0k|    sp->in_buffer_togo = 0;
 2674|  35.0k|    if (sp->in_buffer_file_togo == 0)
  ------------------
  |  Branch (2674:9): [True: 21.8k, False: 13.1k]
  ------------------
 2675|  21.8k|    {
 2676|  21.8k|        switch (sp->in_buffer_source)
 2677|  21.8k|        {
 2678|  21.8k|            case osibsStrile:
  ------------------
  |  Branch (2678:13): [True: 21.8k, False: 0]
  ------------------
 2679|  21.8k|                if (sp->in_buffer_next_strile < sp->in_buffer_strile_count)
  ------------------
  |  Branch (2679:21): [True: 21.7k, False: 65]
  ------------------
 2680|  21.7k|                    sp->out_state = ososRst;
 2681|     65|                else
 2682|     65|                    sp->out_state = ososEoi;
 2683|  21.8k|                break;
 2684|      0|            case osibsEof:
  ------------------
  |  Branch (2684:13): [True: 0, False: 21.8k]
  ------------------
 2685|      0|                sp->out_state = ososEoi;
 2686|      0|                break;
 2687|      0|            case osibsNotSetYet:
  ------------------
  |  Branch (2687:13): [True: 0, False: 21.8k]
  ------------------
 2688|      0|            case osibsJpegInterchangeFormat:
  ------------------
  |  Branch (2688:13): [True: 0, False: 21.8k]
  ------------------
 2689|      0|            default:
  ------------------
  |  Branch (2689:13): [True: 0, False: 21.8k]
  ------------------
 2690|      0|                break;
 2691|  21.8k|        }
 2692|  21.8k|    }
 2693|  35.0k|    return (1);
 2694|  35.0k|}
tif_ojpeg.c:OJPEGWriteStreamRst:
 2697|  10.7k|{
 2698|  10.7k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2699|  10.7k|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2699:5): [True: 0, Folded]
  |  Branch (2699:5): [True: 10.7k, Folded]
  ------------------
 2700|  10.7k|    sp->out_buffer[0] = 255;
 2701|  10.7k|    sp->out_buffer[1] = (uint8_t)(JPEG_MARKER_RST0 + sp->restart_index);
  ------------------
  |  |  162|  10.7k|#define JPEG_MARKER_RST0 0XD0
  ------------------
 2702|  10.7k|    sp->restart_index++;
 2703|  10.7k|    if (sp->restart_index == 8)
  ------------------
  |  Branch (2703:9): [True: 2, False: 10.7k]
  ------------------
 2704|      2|        sp->restart_index = 0;
 2705|  10.7k|    *len = 2;
 2706|  10.7k|    *mem = (void *)sp->out_buffer;
 2707|  10.7k|    sp->out_state = ososCompressed;
 2708|  10.7k|}
tif_ojpeg.c:OJPEGWriteStreamEoi:
 2711|     18|{
 2712|     18|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2713|     18|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2713:5): [True: 0, Folded]
  |  Branch (2713:5): [True: 18, Folded]
  ------------------
 2714|     18|    sp->out_buffer[0] = 255;
 2715|     18|    sp->out_buffer[1] = JPEG_MARKER_EOI;
  ------------------
  |  |  164|     18|#define JPEG_MARKER_EOI 0xD9
  ------------------
 2716|     18|    *len = 2;
 2717|     18|    *mem = (void *)sp->out_buffer;
 2718|     18|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrResyncToRestart:
 2857|  34.0k|{
 2858|  34.0k|    TIFF *tif = (TIFF *)cinfo->client_data;
 2859|  34.0k|    (void)desired;
 2860|  34.0k|    TIFFErrorExtR(tif, "LibJpeg", "Unexpected error");
 2861|  34.0k|    jpeg_encap_unwind(tif);
 2862|  34.0k|    return (0);
 2863|  34.0k|}
tif_ojpeg.c:jpeg_read_header_encap:
 2738|  22.9k|{
 2739|  22.9k|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|  22.9k|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2739:9): [True: 122, False: 22.8k]
  ------------------
 2740|    122|        return 0;
 2741|  22.8k|    else
 2742|  22.8k|    {
 2743|  22.8k|        jpeg_read_header(cinfo, require_image);
 2744|  22.8k|        return 1;
 2745|  22.8k|    }
 2746|  22.9k|}
tif_ojpeg.c:jpeg_start_decompress_encap:
 2752|  22.8k|{
 2753|  22.8k|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|  22.8k|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2753:9): [True: 40, False: 22.8k]
  ------------------
 2754|     40|        return 0;
 2755|  22.8k|    else
 2756|  22.8k|    {
 2757|  22.8k|        jpeg_start_decompress(cinfo);
 2758|  22.8k|        return 1;
 2759|  22.8k|    }
 2760|  22.8k|}
tif_ojpeg.c:jpeg_read_raw_data_encap:
 2782|  2.42k|{
 2783|  2.42k|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|  2.42k|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2783:9): [True: 0, False: 2.42k]
  ------------------
 2784|      0|        return 0;
 2785|  2.42k|    else
 2786|  2.42k|    {
 2787|  2.42k|        jpeg_read_raw_data(cinfo, (JSAMPIMAGE)data, max_lines);
 2788|  2.42k|        return 1;
 2789|  2.42k|    }
 2790|  2.42k|}
tif_ojpeg.c:OJPEGPreDecodeSkipScanlines:
  812|   350k|{
  813|   350k|    static const char module[] = "OJPEGPreDecodeSkipScanlines";
  814|   350k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  815|   350k|    uint32_t m;
  816|   350k|    if (sp->skip_buffer == NULL)
  ------------------
  |  Branch (816:9): [True: 188, False: 350k]
  ------------------
  817|    188|    {
  818|    188|        sp->skip_buffer = (uint8_t *)_TIFFmallocExt(tif, sp->bytes_per_line);
  819|    188|        if (sp->skip_buffer == NULL)
  ------------------
  |  Branch (819:13): [True: 0, False: 188]
  ------------------
  820|      0|        {
  821|      0|            TIFFErrorExtR(tif, module, "Out of memory");
  822|      0|            return (0);
  823|      0|        }
  824|    188|    }
  825|   282M|    for (m = 0; m < sp->lines_per_strile; m++)
  ------------------
  |  Branch (825:17): [True: 282M, False: 315k]
  ------------------
  826|   282M|    {
  827|   282M|        if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
  ------------------
  |  Branch (827:13): [True: 34.9k, False: 282M]
  ------------------
  828|   282M|                                      &sp->skip_buffer, 1) == 0)
  829|  34.9k|            return (0);
  830|   282M|    }
  831|   315k|    return (1);
  832|   350k|}
tif_ojpeg.c:jpeg_read_scanlines_encap:
 2767|   299M|{
 2768|   299M|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|   299M|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2768:9): [True: 35.0k, False: 299M]
  ------------------
 2769|  35.0k|        return 0;
 2770|   299M|    else
 2771|   299M|    {
 2772|   299M|        jpeg_read_scanlines(cinfo, (JSAMPARRAY)scanlines, max_lines);
 2773|   299M|        return 1;
 2774|   299M|    }
 2775|   299M|}
tif_ojpeg.c:OJPEGDecode:
  835|  16.8k|{
  836|  16.8k|    static const char module[] = "OJPEGDecode";
  837|  16.8k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  838|  16.8k|    (void)s;
  839|  16.8k|    if (!sp->decoder_ok)
  ------------------
  |  Branch (839:9): [True: 0, False: 16.8k]
  ------------------
  840|      0|    {
  841|      0|        memset(buf, 0, (size_t)cc);
  842|      0|        TIFFErrorExtR(tif, module,
  843|      0|                      "Cannot decode: decoder not correctly initialized");
  844|      0|        return 0;
  845|      0|    }
  846|  16.8k|    if (sp->libjpeg_session_active == 0)
  ------------------
  |  Branch (846:9): [True: 0, False: 16.8k]
  ------------------
  847|      0|    {
  848|      0|        memset(buf, 0, (size_t)cc);
  849|       |        /* This should normally not happen, except that it does when */
  850|       |        /* using TIFFReadScanline() which calls OJPEGPostDecode() for */
  851|       |        /* each scanline, which assumes that a whole strile was read */
  852|       |        /* and may thus incorrectly consider it has read the whole image,
  853|       |         * causing */
  854|       |        /* OJPEGLibjpegSessionAbort() to be called prematurely. */
  855|       |        /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */
  856|      0|        TIFFErrorExtR(tif, module,
  857|      0|                      "Cannot decode: libjpeg_session_active == 0");
  858|      0|        return 0;
  859|      0|    }
  860|  16.8k|    if (sp->error_in_raw_data_decoding)
  ------------------
  |  Branch (860:9): [True: 0, False: 16.8k]
  ------------------
  861|      0|    {
  862|      0|        memset(buf, 0, (size_t)cc);
  863|      0|        return 0;
  864|      0|    }
  865|  16.8k|    if (sp->libjpeg_jpeg_query_style == 0)
  ------------------
  |  Branch (865:9): [True: 364, False: 16.5k]
  ------------------
  866|    364|    {
  867|    364|        if (OJPEGDecodeRaw(tif, buf, cc) == 0)
  ------------------
  |  Branch (867:13): [True: 0, False: 364]
  ------------------
  868|      0|        {
  869|      0|            memset(buf, 0, (size_t)cc);
  870|      0|            return (0);
  871|      0|        }
  872|    364|    }
  873|  16.5k|    else
  874|  16.5k|    {
  875|  16.5k|        if (OJPEGDecodeScanlines(tif, buf, cc) == 0)
  ------------------
  |  Branch (875:13): [True: 188, False: 16.3k]
  ------------------
  876|    188|        {
  877|    188|            memset(buf, 0, (size_t)cc);
  878|    188|            return (0);
  879|    188|        }
  880|  16.5k|    }
  881|  16.6k|    return (1);
  882|  16.8k|}
tif_ojpeg.c:OJPEGDecodeRaw:
  885|    364|{
  886|    364|    static const char module[] = "OJPEGDecodeRaw";
  887|    364|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  888|    364|    uint8_t *m;
  889|    364|    tmsize_t n;
  890|    364|    uint8_t *oy;
  891|    364|    uint8_t *ocb;
  892|    364|    uint8_t *ocr;
  893|    364|    uint8_t *p;
  894|    364|    uint32_t q;
  895|    364|    uint8_t *r;
  896|    364|    uint8_t sx, sy;
  897|    364|    if (cc % sp->bytes_per_line != 0)
  ------------------
  |  Branch (897:9): [True: 0, False: 364]
  ------------------
  898|      0|    {
  899|      0|        TIFFErrorExtR(tif, module, "Fractional scanline not read");
  900|      0|        return (0);
  901|      0|    }
  902|    364|    assert(cc > 0);
  ------------------
  |  Branch (902:5): [True: 0, False: 364]
  |  Branch (902:5): [True: 364, False: 0]
  ------------------
  903|    364|    m = buf;
  904|    364|    n = cc;
  905|    364|    do
  906|  17.3k|    {
  907|  17.3k|        if (sp->subsampling_convert_state == 0)
  ------------------
  |  Branch (907:13): [True: 2.42k, False: 14.9k]
  ------------------
  908|  2.42k|        {
  909|  2.42k|            if (jpeg_read_raw_data_encap(
  ------------------
  |  Branch (909:17): [True: 0, False: 2.42k]
  ------------------
  910|  2.42k|                    sp, &(sp->libjpeg_jpeg_decompress_struct),
  911|  2.42k|                    sp->subsampling_convert_ycbcrimage,
  912|  2.42k|                    (uint32_t)sp->subsampling_ver * 8) == 0)
  913|      0|            {
  914|      0|                sp->error_in_raw_data_decoding = 1;
  915|      0|                return (0);
  916|      0|            }
  917|  2.42k|        }
  918|  17.3k|        oy = sp->subsampling_convert_ybuf +
  919|  17.3k|             sp->subsampling_convert_state * sp->subsampling_ver *
  920|  17.3k|                 sp->subsampling_convert_ylinelen;
  921|  17.3k|        ocb = sp->subsampling_convert_cbbuf +
  922|  17.3k|              sp->subsampling_convert_state * sp->subsampling_convert_clinelen;
  923|  17.3k|        ocr = sp->subsampling_convert_crbuf +
  924|  17.3k|              sp->subsampling_convert_state * sp->subsampling_convert_clinelen;
  925|  17.3k|        p = m;
  926|   220k|        for (q = 0; q < sp->subsampling_convert_clinelenout; q++)
  ------------------
  |  Branch (926:21): [True: 203k, False: 17.3k]
  ------------------
  927|   203k|        {
  928|   203k|            r = oy;
  929|   609k|            for (sy = 0; sy < sp->subsampling_ver; sy++)
  ------------------
  |  Branch (929:26): [True: 406k, False: 203k]
  ------------------
  930|   406k|            {
  931|  1.21M|                for (sx = 0; sx < sp->subsampling_hor; sx++)
  ------------------
  |  Branch (931:30): [True: 812k, False: 406k]
  ------------------
  932|   812k|                    *p++ = *r++;
  933|   406k|                r += sp->subsampling_convert_ylinelen - sp->subsampling_hor;
  934|   406k|            }
  935|   203k|            oy += sp->subsampling_hor;
  936|   203k|            *p++ = *ocb++;
  937|   203k|            *p++ = *ocr++;
  938|   203k|        }
  939|  17.3k|        sp->subsampling_convert_state++;
  940|  17.3k|        if (sp->subsampling_convert_state == sp->subsampling_convert_clines)
  ------------------
  |  Branch (940:13): [True: 2.08k, False: 15.2k]
  ------------------
  941|  2.08k|            sp->subsampling_convert_state = 0;
  942|  17.3k|        m += sp->bytes_per_line;
  943|  17.3k|        n -= sp->bytes_per_line;
  944|  17.3k|    } while (n > 0);
  ------------------
  |  Branch (944:14): [True: 16.9k, False: 364]
  ------------------
  945|    364|    return (1);
  946|    364|}
tif_ojpeg.c:OJPEGDecodeScanlines:
  949|  16.5k|{
  950|  16.5k|    static const char module[] = "OJPEGDecodeScanlines";
  951|  16.5k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  952|  16.5k|    uint8_t *m;
  953|  16.5k|    tmsize_t n;
  954|  16.5k|    if (cc % sp->bytes_per_line != 0)
  ------------------
  |  Branch (954:9): [True: 95, False: 16.4k]
  ------------------
  955|     95|    {
  956|     95|        TIFFErrorExtR(tif, module, "Fractional scanline not read");
  957|     95|        return (0);
  958|     95|    }
  959|  16.5k|    assert(cc > 0);
  ------------------
  |  Branch (959:5): [True: 0, False: 16.4k]
  |  Branch (959:5): [True: 16.4k, False: 0]
  ------------------
  960|  16.4k|    m = buf;
  961|  16.4k|    n = cc;
  962|  16.4k|    do
  963|  17.0M|    {
  964|  17.0M|        if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
  ------------------
  |  Branch (964:13): [True: 93, False: 17.0M]
  ------------------
  965|  17.0M|                                      &m, 1) == 0)
  966|     93|            return (0);
  967|  17.0M|        m += sp->bytes_per_line;
  968|  17.0M|        n -= sp->bytes_per_line;
  969|  17.0M|    } while (n > 0);
  ------------------
  |  Branch (969:14): [True: 16.9M, False: 16.3k]
  ------------------
  970|  16.3k|    return (1);
  971|  16.4k|}
tif_ojpeg.c:OJPEGPostDecode:
  974|  16.6k|{
  975|  16.6k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  976|  16.6k|    (void)buf;
  977|  16.6k|    (void)cc;
  978|       |    /* This function somehow incorrectly assumes that a whole strile was read,
  979|       |     */
  980|       |    /* which is not true when TIFFReadScanline() is called, */
  981|       |    /* and may thus incorrectly consider it has read the whole image, causing */
  982|       |    /* OJPEGLibjpegSessionAbort() to be called prematurely. */
  983|       |    /* So this logic should be fixed to take into account cc, or disable */
  984|       |    /* the scan line reading interface. */
  985|       |    /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */
  986|  16.6k|    sp->write_curstrile++;
  987|  16.6k|    if (sp->write_curstrile % tif->tif_dir.td_stripsperimage == 0)
  ------------------
  |  Branch (987:9): [True: 365, False: 16.3k]
  ------------------
  988|    365|    {
  989|    365|        assert(sp->libjpeg_session_active != 0);
  ------------------
  |  Branch (989:9): [True: 0, False: 365]
  |  Branch (989:9): [True: 365, False: 0]
  ------------------
  990|    365|        OJPEGLibjpegSessionAbort(tif);
  991|    365|        sp->writeheader_done = 0;
  992|    365|    }
  993|  16.6k|}
tif_ojpeg.c:OJPEGCleanup:
 1036|  1.42k|{
 1037|  1.42k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1038|  1.42k|    if (sp != 0)
  ------------------
  |  Branch (1038:9): [True: 1.42k, False: 0]
  ------------------
 1039|  1.42k|    {
 1040|  1.42k|        tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1041|  1.42k|        tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1042|  1.42k|        tif->tif_tagmethods.printdir = sp->printdir;
 1043|  1.42k|        if (sp->qtable[0] != 0)
  ------------------
  |  Branch (1043:13): [True: 338, False: 1.08k]
  ------------------
 1044|    338|            _TIFFfreeExt(tif, sp->qtable[0]);
 1045|  1.42k|        if (sp->qtable[1] != 0)
  ------------------
  |  Branch (1045:13): [True: 45, False: 1.38k]
  ------------------
 1046|     45|            _TIFFfreeExt(tif, sp->qtable[1]);
 1047|  1.42k|        if (sp->qtable[2] != 0)
  ------------------
  |  Branch (1047:13): [True: 10, False: 1.41k]
  ------------------
 1048|     10|            _TIFFfreeExt(tif, sp->qtable[2]);
 1049|  1.42k|        if (sp->qtable[3] != 0)
  ------------------
  |  Branch (1049:13): [True: 12, False: 1.41k]
  ------------------
 1050|     12|            _TIFFfreeExt(tif, sp->qtable[3]);
 1051|  1.42k|        if (sp->dctable[0] != 0)
  ------------------
  |  Branch (1051:13): [True: 118, False: 1.30k]
  ------------------
 1052|    118|            _TIFFfreeExt(tif, sp->dctable[0]);
 1053|  1.42k|        if (sp->dctable[1] != 0)
  ------------------
  |  Branch (1053:13): [True: 34, False: 1.39k]
  ------------------
 1054|     34|            _TIFFfreeExt(tif, sp->dctable[1]);
 1055|  1.42k|        if (sp->dctable[2] != 0)
  ------------------
  |  Branch (1055:13): [True: 53, False: 1.37k]
  ------------------
 1056|     53|            _TIFFfreeExt(tif, sp->dctable[2]);
 1057|  1.42k|        if (sp->dctable[3] != 0)
  ------------------
  |  Branch (1057:13): [True: 4, False: 1.42k]
  ------------------
 1058|      4|            _TIFFfreeExt(tif, sp->dctable[3]);
 1059|  1.42k|        if (sp->actable[0] != 0)
  ------------------
  |  Branch (1059:13): [True: 68, False: 1.35k]
  ------------------
 1060|     68|            _TIFFfreeExt(tif, sp->actable[0]);
 1061|  1.42k|        if (sp->actable[1] != 0)
  ------------------
  |  Branch (1061:13): [True: 28, False: 1.39k]
  ------------------
 1062|     28|            _TIFFfreeExt(tif, sp->actable[1]);
 1063|  1.42k|        if (sp->actable[2] != 0)
  ------------------
  |  Branch (1063:13): [True: 31, False: 1.39k]
  ------------------
 1064|     31|            _TIFFfreeExt(tif, sp->actable[2]);
 1065|  1.42k|        if (sp->actable[3] != 0)
  ------------------
  |  Branch (1065:13): [True: 7, False: 1.41k]
  ------------------
 1066|      7|            _TIFFfreeExt(tif, sp->actable[3]);
 1067|  1.42k|        if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (1067:13): [True: 237, False: 1.18k]
  ------------------
 1068|    237|            OJPEGLibjpegSessionAbort(tif);
 1069|  1.42k|        if (sp->subsampling_convert_ycbcrbuf != 0)
  ------------------
  |  Branch (1069:13): [True: 26, False: 1.40k]
  ------------------
 1070|     26|            _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrbuf);
 1071|  1.42k|        if (sp->subsampling_convert_ycbcrimage != 0)
  ------------------
  |  Branch (1071:13): [True: 26, False: 1.40k]
  ------------------
 1072|     26|            _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrimage);
 1073|  1.42k|        if (sp->skip_buffer != 0)
  ------------------
  |  Branch (1073:13): [True: 188, False: 1.23k]
  ------------------
 1074|    188|            _TIFFfreeExt(tif, sp->skip_buffer);
 1075|  1.42k|        _TIFFfreeExt(tif, sp);
 1076|       |        tif->tif_data = NULL;
 1077|  1.42k|        _TIFFSetDefaultCompressionState(tif);
 1078|  1.42k|    }
 1079|  1.42k|}

_TIFFgetMode:
   57|  1.28k|{
   58|  1.28k|    int m = -1;
   59|       |
   60|  1.28k|    switch (mode[0])
   61|  1.28k|    {
   62|  1.28k|        case 'r':
  ------------------
  |  Branch (62:9): [True: 1.28k, False: 0]
  ------------------
   63|  1.28k|            m = O_RDONLY;
   64|  1.28k|            if (mode[1] == '+')
  ------------------
  |  Branch (64:17): [True: 0, False: 1.28k]
  ------------------
   65|      0|                m = O_RDWR;
   66|  1.28k|            break;
   67|      0|        case 'w':
  ------------------
  |  Branch (67:9): [True: 0, False: 1.28k]
  ------------------
   68|      0|        case 'a':
  ------------------
  |  Branch (68:9): [True: 0, False: 1.28k]
  ------------------
   69|      0|            m = O_RDWR | O_CREAT;
   70|      0|            if (mode[0] == 'w')
  ------------------
  |  Branch (70:17): [True: 0, False: 0]
  ------------------
   71|      0|                m |= O_TRUNC;
   72|      0|            break;
   73|      0|        default:
  ------------------
  |  Branch (73:9): [True: 0, False: 1.28k]
  ------------------
   74|      0|            _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode);
   75|      0|            break;
   76|  1.28k|    }
   77|  1.28k|    return (m);
   78|  1.28k|}
_TIFFmallocExt:
  174|   395k|{
  175|   395k|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (175:9): [True: 393k, False: 1.28k]
  |  Branch (175:24): [True: 0, False: 393k]
  ------------------
  176|      0|        s > tif->tif_max_single_mem_alloc)
  ------------------
  |  Branch (176:9): [True: 0, False: 0]
  ------------------
  177|      0|    {
  178|      0|        _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFmallocExt", s);
  179|      0|        return NULL;
  180|      0|    }
  181|   395k|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (181:9): [True: 393k, False: 1.28k]
  |  Branch (181:24): [True: 0, False: 393k]
  ------------------
  182|      0|    {
  183|      0|        if (s > tif->tif_max_cumulated_mem_alloc -
  ------------------
  |  Branch (183:13): [True: 0, False: 0]
  ------------------
  184|      0|                    tif->tif_cur_cumulated_mem_alloc ||
  185|      0|            s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
  ------------------
  |  |   68|      0|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
                          s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  |  Branch (185:13): [True: 0, False: 0]
  ------------------
  186|      0|        {
  187|      0|            _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFmallocExt", s);
  188|      0|            return NULL;
  189|      0|        }
  190|      0|        void *ptr = _TIFFmalloc(LEADING_AREA_TO_STORE_ALLOC_SIZE + s);
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  191|      0|        if (!ptr)
  ------------------
  |  Branch (191:13): [True: 0, False: 0]
  ------------------
  192|      0|            return NULL;
  193|      0|        tif->tif_cur_cumulated_mem_alloc += s;
  194|      0|        memcpy(ptr, &s, sizeof(s));
  195|      0|        return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  196|      0|    }
  197|   395k|    return _TIFFmalloc(s);
  198|   395k|}
_TIFFcallocExt:
  202|    766|{
  203|    766|    if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz)
  ------------------
  |  |   68|    766|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (203:9): [True: 0, False: 766]
  |  Branch (203:23): [True: 0, False: 766]
  |  Branch (203:35): [True: 0, False: 766]
  ------------------
  204|      0|        return NULL;
  205|    766|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0)
  ------------------
  |  Branch (205:9): [True: 766, False: 0]
  |  Branch (205:24): [True: 0, False: 766]
  ------------------
  206|      0|    {
  207|      0|        if (nmemb * siz > tif->tif_max_single_mem_alloc)
  ------------------
  |  Branch (207:13): [True: 0, False: 0]
  ------------------
  208|      0|        {
  209|      0|            _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFcallocExt",
  210|      0|                                                 nmemb * siz);
  211|      0|            return NULL;
  212|      0|        }
  213|      0|    }
  214|    766|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (214:9): [True: 766, False: 0]
  |  Branch (214:24): [True: 0, False: 766]
  ------------------
  215|      0|    {
  216|      0|        const tmsize_t s = nmemb * siz;
  217|      0|        if (s > tif->tif_max_cumulated_mem_alloc -
  ------------------
  |  Branch (217:13): [True: 0, False: 0]
  ------------------
  218|      0|                    tif->tif_cur_cumulated_mem_alloc ||
  219|      0|            s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
  ------------------
  |  |   68|      0|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
                          s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|      0|        {
  221|      0|            _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFcallocExt", s);
  222|      0|            return NULL;
  223|      0|        }
  224|      0|        void *ptr = _TIFFcalloc(LEADING_AREA_TO_STORE_ALLOC_SIZE + s, 1);
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  225|      0|        if (!ptr)
  ------------------
  |  Branch (225:13): [True: 0, False: 0]
  ------------------
  226|      0|            return NULL;
  227|      0|        tif->tif_cur_cumulated_mem_alloc += s;
  228|      0|        memcpy(ptr, &s, sizeof(s));
  229|      0|        return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  230|      0|    }
  231|    766|    return _TIFFcalloc(nmemb, siz);
  232|    766|}
_TIFFreallocExt:
  236|   242k|{
  237|   242k|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (237:9): [True: 242k, False: 0]
  |  Branch (237:24): [True: 0, False: 242k]
  ------------------
  238|      0|        s > tif->tif_max_single_mem_alloc)
  ------------------
  |  Branch (238:9): [True: 0, False: 0]
  ------------------
  239|      0|    {
  240|      0|        _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFreallocExt", s);
  241|      0|        return NULL;
  242|      0|    }
  243|   242k|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (243:9): [True: 242k, False: 0]
  |  Branch (243:24): [True: 0, False: 242k]
  ------------------
  244|      0|    {
  245|      0|        void *oldPtr = p;
  246|      0|        tmsize_t oldSize = 0;
  247|      0|        if (p)
  ------------------
  |  Branch (247:13): [True: 0, False: 0]
  ------------------
  248|      0|        {
  249|      0|            oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  250|      0|            memcpy(&oldSize, oldPtr, sizeof(oldSize));
  251|      0|            assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
  ------------------
  |  Branch (251:13): [True: 0, False: 0]
  |  Branch (251:13): [True: 0, False: 0]
  ------------------
  252|      0|        }
  253|      0|        if (s > oldSize &&
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  ------------------
  254|      0|            (s > tif->tif_max_cumulated_mem_alloc -
  ------------------
  |  Branch (254:14): [True: 0, False: 0]
  ------------------
  255|      0|                     (tif->tif_cur_cumulated_mem_alloc - oldSize) ||
  256|      0|             s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE))
  ------------------
  |  |   68|      0|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
                           s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE))
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  |  Branch (256:14): [True: 0, False: 0]
  ------------------
  257|      0|        {
  258|      0|            _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFreallocExt",
  259|      0|                                                    s - oldSize);
  260|      0|            return NULL;
  261|      0|        }
  262|      0|        void *newPtr =
  263|      0|            _TIFFrealloc(oldPtr, LEADING_AREA_TO_STORE_ALLOC_SIZE + s);
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  264|      0|        if (newPtr == NULL)
  ------------------
  |  Branch (264:13): [True: 0, False: 0]
  ------------------
  265|      0|            return NULL;
  266|      0|        tif->tif_cur_cumulated_mem_alloc -= oldSize;
  267|      0|        tif->tif_cur_cumulated_mem_alloc += s;
  268|      0|        memcpy(newPtr, &s, sizeof(s));
  269|      0|        return (char *)newPtr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  270|      0|    }
  271|   242k|    return _TIFFrealloc(p, s);
  272|   242k|}
_TIFFfreeExt:
  276|   442k|{
  277|   442k|    if (p != NULL && tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (277:9): [True: 441k, False: 1.56k]
  |  Branch (277:22): [True: 439k, False: 1.28k]
  |  Branch (277:37): [True: 0, False: 439k]
  ------------------
  278|      0|    {
  279|      0|        void *oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
  ------------------
  |  |  170|      0|#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
  |  |  ------------------
  |  |  |  |  116|      0|#define SIZEOF_SIZE_T 8
  |  |  ------------------
  ------------------
  280|      0|        tmsize_t oldSize;
  281|      0|        memcpy(&oldSize, oldPtr, sizeof(oldSize));
  282|      0|        assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
  ------------------
  |  Branch (282:9): [True: 0, False: 0]
  |  Branch (282:9): [True: 0, False: 0]
  ------------------
  283|      0|        tif->tif_cur_cumulated_mem_alloc -= oldSize;
  284|      0|        p = oldPtr;
  285|      0|    }
  286|   442k|    _TIFFfree(p);
  287|   442k|}
TIFFClientOpen:
  294|  1.28k|{
  295|  1.28k|    return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc,
  296|  1.28k|                             seekproc, closeproc, sizeproc, mapproc, unmapproc,
  297|       |                             NULL);
  298|  1.28k|}
TIFFClientOpenExt:
  306|  1.28k|{
  307|  1.28k|    static const char module[] = "TIFFClientOpenExt";
  308|  1.28k|    TIFF *tif;
  309|  1.28k|    int m;
  310|  1.28k|    const char *cp;
  311|  1.28k|    tmsize_t size_to_alloc;
  312|       |
  313|       |    /* The following are configuration checks. They should be redundant, but
  314|       |     * should not compile to any actual code in an optimised release build
  315|       |     * anyway. If any of them fail, (makefile-based or other) configuration is
  316|       |     * not correct */
  317|  1.28k|    assert(sizeof(uint8_t) == 1);
  ------------------
  |  Branch (317:5): [True: 0, Folded]
  |  Branch (317:5): [True: 1.28k, Folded]
  ------------------
  318|  1.28k|    assert(sizeof(int8_t) == 1);
  ------------------
  |  Branch (318:5): [True: 0, Folded]
  |  Branch (318:5): [True: 1.28k, Folded]
  ------------------
  319|  1.28k|    assert(sizeof(uint16_t) == 2);
  ------------------
  |  Branch (319:5): [True: 0, Folded]
  |  Branch (319:5): [True: 1.28k, Folded]
  ------------------
  320|  1.28k|    assert(sizeof(int16_t) == 2);
  ------------------
  |  Branch (320:5): [True: 0, Folded]
  |  Branch (320:5): [True: 1.28k, Folded]
  ------------------
  321|  1.28k|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (321:5): [True: 0, Folded]
  |  Branch (321:5): [True: 1.28k, Folded]
  ------------------
  322|  1.28k|    assert(sizeof(int32_t) == 4);
  ------------------
  |  Branch (322:5): [True: 0, Folded]
  |  Branch (322:5): [True: 1.28k, Folded]
  ------------------
  323|  1.28k|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (323:5): [True: 0, Folded]
  |  Branch (323:5): [True: 1.28k, Folded]
  ------------------
  324|  1.28k|    assert(sizeof(int64_t) == 8);
  ------------------
  |  Branch (324:5): [True: 0, Folded]
  |  Branch (324:5): [True: 1.28k, Folded]
  ------------------
  325|  1.28k|    {
  326|  1.28k|        union
  327|  1.28k|        {
  328|  1.28k|            uint8_t a8[2];
  329|  1.28k|            uint16_t a16;
  330|  1.28k|        } n;
  331|  1.28k|        n.a8[0] = 1;
  332|  1.28k|        n.a8[1] = 0;
  333|  1.28k|        (void)n;
  334|       |#if WORDS_BIGENDIAN
  335|       |        assert(n.a16 == 256);
  336|       |#else
  337|  1.28k|        assert(n.a16 == 1);
  ------------------
  |  Branch (337:9): [True: 0, False: 1.28k]
  |  Branch (337:9): [True: 1.28k, False: 0]
  ------------------
  338|  1.28k|#endif
  339|  1.28k|    }
  340|       |
  341|  1.28k|    m = _TIFFgetMode(opts, clientdata, mode, module);
  342|  1.28k|    if (m == -1)
  ------------------
  |  Branch (342:9): [True: 0, False: 1.28k]
  ------------------
  343|      0|        goto bad2;
  344|  1.28k|    size_to_alloc = (tmsize_t)(sizeof(TIFF) + strlen(name) + 1);
  345|  1.28k|    if (opts && opts->max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (345:9): [True: 0, False: 1.28k]
  |  Branch (345:17): [True: 0, False: 0]
  ------------------
  346|      0|        size_to_alloc > opts->max_single_mem_alloc)
  ------------------
  |  Branch (346:9): [True: 0, False: 0]
  ------------------
  347|      0|    {
  348|      0|        _TIFFErrorEarly(opts, clientdata, module,
  349|      0|                        "%s: Memory allocation of %" PRIu64
  350|      0|                        " bytes is beyond the %" PRIu64
  351|      0|                        " byte limit defined in open options",
  352|      0|                        name, (uint64_t)size_to_alloc,
  353|      0|                        (uint64_t)opts->max_single_mem_alloc);
  354|      0|        goto bad2;
  355|      0|    }
  356|  1.28k|    if (opts && opts->max_cumulated_mem_alloc > 0 &&
  ------------------
  |  Branch (356:9): [True: 0, False: 1.28k]
  |  Branch (356:17): [True: 0, False: 0]
  ------------------
  357|      0|        size_to_alloc > opts->max_cumulated_mem_alloc)
  ------------------
  |  Branch (357:9): [True: 0, False: 0]
  ------------------
  358|      0|    {
  359|      0|        _TIFFErrorEarly(opts, clientdata, module,
  360|      0|                        "%s: Memory allocation of %" PRIu64
  361|      0|                        " bytes is beyond the %" PRIu64
  362|      0|                        " cumulated byte limit defined in open options",
  363|      0|                        name, (uint64_t)size_to_alloc,
  364|      0|                        (uint64_t)opts->max_cumulated_mem_alloc);
  365|      0|        goto bad2;
  366|      0|    }
  367|  1.28k|    tif = (TIFF *)_TIFFmallocExt(NULL, size_to_alloc);
  368|  1.28k|    if (tif == NULL)
  ------------------
  |  Branch (368:9): [True: 0, False: 1.28k]
  ------------------
  369|      0|    {
  370|      0|        _TIFFErrorEarly(opts, clientdata, module,
  371|      0|                        "%s: Out of memory (TIFF structure)", name);
  372|      0|        goto bad2;
  373|      0|    }
  374|  1.28k|    _TIFFmemset(tif, 0, sizeof(*tif));
  375|  1.28k|    tif->tif_name = (char *)tif + sizeof(TIFF);
  376|  1.28k|    strcpy(tif->tif_name, name);
  377|  1.28k|    tif->tif_mode = m & ~(O_CREAT | O_TRUNC);
  378|  1.28k|    tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; /* non-existent directory */
  ------------------
  |  |   65|  1.28k|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  379|  1.28k|    tif->tif_curdircount = TIFF_NON_EXISTENT_DIR_NUMBER;
  ------------------
  |  |   65|  1.28k|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  380|  1.28k|    tif->tif_curoff = 0;
  381|  1.28k|    tif->tif_clientdata = clientdata;
  382|  1.28k|    tif->tif_readproc = readproc;
  383|  1.28k|    tif->tif_writeproc = writeproc;
  384|  1.28k|    tif->tif_seekproc = seekproc;
  385|  1.28k|    tif->tif_closeproc = closeproc;
  386|  1.28k|    tif->tif_sizeproc = sizeproc;
  387|  1.28k|    tif->tif_mapproc = mapproc ? mapproc : _tiffDummyMapProc;
  ------------------
  |  Branch (387:24): [True: 1.28k, False: 0]
  ------------------
  388|  1.28k|    tif->tif_unmapproc = unmapproc ? unmapproc : _tiffDummyUnmapProc;
  ------------------
  |  Branch (388:26): [True: 1.28k, False: 0]
  ------------------
  389|  1.28k|    if (opts)
  ------------------
  |  Branch (389:9): [True: 0, False: 1.28k]
  ------------------
  390|      0|    {
  391|      0|        tif->tif_errorhandler = opts->errorhandler;
  392|      0|        tif->tif_errorhandler_user_data = opts->errorhandler_user_data;
  393|      0|        tif->tif_warnhandler = opts->warnhandler;
  394|      0|        tif->tif_warnhandler_user_data = opts->warnhandler_user_data;
  395|      0|        tif->tif_max_single_mem_alloc = opts->max_single_mem_alloc;
  396|      0|        tif->tif_max_cumulated_mem_alloc = opts->max_cumulated_mem_alloc;
  397|      0|        tif->tif_warn_about_unknown_tags = opts->warn_about_unknown_tags;
  398|      0|    }
  399|       |
  400|       |    /* Reset tif->tif_dir structure to zero and
  401|       |     * initialize some IFD strile counter and index parameters. */
  402|  1.28k|    _TIFFResetTifDirAndInitStrileCounters(&tif->tif_dir);
  403|       |
  404|  1.28k|    if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc)
  ------------------
  |  Branch (404:9): [True: 0, False: 1.28k]
  |  Branch (404:22): [True: 0, False: 1.28k]
  |  Branch (404:36): [True: 0, False: 1.28k]
  |  Branch (404:49): [True: 0, False: 1.28k]
  |  Branch (404:63): [True: 0, False: 1.28k]
  ------------------
  405|      0|    {
  406|      0|        TIFFErrorExtR(tif, module,
  407|      0|                      "One of the client procedures is NULL pointer.");
  408|      0|        _TIFFfreeExt(NULL, tif);
  409|      0|        goto bad2;
  410|      0|    }
  411|       |
  412|  1.28k|    _TIFFSetDefaultCompressionState(tif); /* setup default state */
  413|       |    /*
  414|       |     * Default is to return data MSB2LSB and enable the
  415|       |     * use of memory-mapped files and strip chopping when
  416|       |     * a file is opened read-only.
  417|       |     */
  418|  1.28k|    tif->tif_flags = FILLORDER_MSB2LSB;
  ------------------
  |  |  241|  1.28k|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  419|  1.28k|    if (m == O_RDONLY)
  ------------------
  |  Branch (419:9): [True: 1.28k, False: 0]
  ------------------
  420|  1.28k|        tif->tif_flags |= TIFF_MAPPED;
  ------------------
  |  |  130|  1.28k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  421|       |
  422|  1.28k|#ifdef STRIPCHOP_DEFAULT
  423|  1.28k|    if (m == O_RDONLY || m == O_RDWR)
  ------------------
  |  Branch (423:9): [True: 1.28k, False: 0]
  |  Branch (423:26): [True: 0, False: 0]
  ------------------
  424|  1.28k|        tif->tif_flags |= STRIPCHOP_DEFAULT;
  ------------------
  |  |  113|  1.28k|#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
  |  |  ------------------
  |  |  |  |  134|  1.28k|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  |  |  ------------------
  ------------------
  425|  1.28k|#endif
  426|       |
  427|       |    /*
  428|       |     * Process library-specific flags in the open mode string.
  429|       |     * The following flags may be used to control intrinsic library
  430|       |     * behavior that may or may not be desirable (usually for
  431|       |     * compatibility with some application that claims to support
  432|       |     * TIFF but only supports some brain dead idea of what the
  433|       |     * vendor thinks TIFF is):
  434|       |     *
  435|       |     * 'l' use little-endian byte order for creating a file
  436|       |     * 'b' use big-endian byte order for creating a file
  437|       |     * 'L' read/write information using LSB2MSB bit order
  438|       |     * 'B' read/write information using MSB2LSB bit order
  439|       |     * 'H' read/write information using host bit order
  440|       |     * 'M' enable use of memory-mapped files when supported
  441|       |     * 'm' disable use of memory-mapped files
  442|       |     * 'C' enable strip chopping support when reading
  443|       |     * 'c' disable strip chopping support
  444|       |     * 'h' read TIFF header only, do not load the first IFD
  445|       |     * '4' ClassicTIFF for creating a file (default)
  446|       |     * '8' BigTIFF for creating a file
  447|       |     * 'D' enable use of deferred strip/tile offset/bytecount array loading.
  448|       |     * 'O' on-demand loading of values instead of whole array loading (implies
  449|       |     * D)
  450|       |     *
  451|       |     * The use of the 'l' and 'b' flags is strongly discouraged.
  452|       |     * These flags are provided solely because numerous vendors,
  453|       |     * typically on the PC, do not correctly support TIFF; they
  454|       |     * only support the Intel little-endian byte order.  This
  455|       |     * support is not configured by default because it supports
  456|       |     * the violation of the TIFF spec that says that readers *MUST*
  457|       |     * support both byte orders.  It is strongly recommended that
  458|       |     * you not use this feature except to deal with busted apps
  459|       |     * that write invalid TIFF.  And even in those cases you should
  460|       |     * bang on the vendors to fix their software.
  461|       |     *
  462|       |     * The 'L', 'B', and 'H' flags are intended for applications
  463|       |     * that can optimize operations on data by using a particular
  464|       |     * bit order.  By default the library returns data in MSB2LSB
  465|       |     * bit order for compatibility with older versions of this
  466|       |     * library.  Returning data in the bit order of the native CPU
  467|       |     * makes the most sense but also requires applications to check
  468|       |     * the value of the FillOrder tag; something they probably do
  469|       |     * not do right now.
  470|       |     *
  471|       |     * The 'M' and 'm' flags are provided because some virtual memory
  472|       |     * systems exhibit poor behavior when large images are mapped.
  473|       |     * These options permit clients to control the use of memory-mapped
  474|       |     * files on a per-file basis.
  475|       |     *
  476|       |     * The 'C' and 'c' flags are provided because the library support
  477|       |     * for chopping up large strips into multiple smaller strips is not
  478|       |     * application-transparent and as such can cause problems.  The 'c'
  479|       |     * option permits applications that only want to look at the tags,
  480|       |     * for example, to get the unadulterated TIFF tag information.
  481|       |     */
  482|  3.84k|    for (cp = mode; *cp; cp++)
  ------------------
  |  Branch (482:21): [True: 2.56k, False: 1.28k]
  ------------------
  483|  2.56k|        switch (*cp)
  484|  2.56k|        {
  485|      0|            case 'b':
  ------------------
  |  Branch (485:13): [True: 0, False: 2.56k]
  ------------------
  486|      0|#if !WORDS_BIGENDIAN
  487|      0|                if (m & O_CREAT)
  ------------------
  |  Branch (487:21): [True: 0, False: 0]
  ------------------
  488|      0|                    tif->tif_flags |= TIFF_SWAB;
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  489|      0|#endif
  490|      0|                break;
  491|      0|            case 'l':
  ------------------
  |  Branch (491:13): [True: 0, False: 2.56k]
  ------------------
  492|       |#if WORDS_BIGENDIAN
  493|       |                if ((m & O_CREAT))
  494|       |                    tif->tif_flags |= TIFF_SWAB;
  495|       |#endif
  496|      0|                break;
  497|      0|            case 'B':
  ------------------
  |  Branch (497:13): [True: 0, False: 2.56k]
  ------------------
  498|      0|                tif->tif_flags =
  499|      0|                    (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
  ------------------
  |  |  120|      0|#define TIFF_FILLORDER 0x00003U   /* natural bit fill order for machine */
  ------------------
                                  (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
  ------------------
  |  |  241|      0|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  500|      0|                break;
  501|      0|            case 'L':
  ------------------
  |  Branch (501:13): [True: 0, False: 2.56k]
  ------------------
  502|      0|                tif->tif_flags =
  503|      0|                    (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
  ------------------
  |  |  120|      0|#define TIFF_FILLORDER 0x00003U   /* natural bit fill order for machine */
  ------------------
                                  (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
  ------------------
  |  |  242|      0|#define FILLORDER_LSB2MSB 2                /* least significant -> most */
  ------------------
  504|      0|                break;
  505|      0|            case 'H':
  ------------------
  |  Branch (505:13): [True: 0, False: 2.56k]
  ------------------
  506|      0|                TIFFWarningExtR(tif, name,
  507|      0|                                "H(ost) mode is deprecated. Since "
  508|      0|                                "libtiff 4.5.1, it is an alias of 'B' / "
  509|      0|                                "FILLORDER_MSB2LSB.");
  510|      0|                tif->tif_flags =
  511|      0|                    (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
  ------------------
  |  |  120|      0|#define TIFF_FILLORDER 0x00003U   /* natural bit fill order for machine */
  ------------------
                                  (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
  ------------------
  |  |  241|      0|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  512|      0|                break;
  513|      0|            case 'M':
  ------------------
  |  Branch (513:13): [True: 0, False: 2.56k]
  ------------------
  514|      0|                if (m == O_RDONLY)
  ------------------
  |  Branch (514:21): [True: 0, False: 0]
  ------------------
  515|      0|                    tif->tif_flags |= TIFF_MAPPED;
  ------------------
  |  |  130|      0|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  516|      0|                break;
  517|  1.28k|            case 'm':
  ------------------
  |  Branch (517:13): [True: 1.28k, False: 1.28k]
  ------------------
  518|  1.28k|                if (m == O_RDONLY)
  ------------------
  |  Branch (518:21): [True: 1.28k, False: 0]
  ------------------
  519|  1.28k|                    tif->tif_flags &= ~TIFF_MAPPED;
  ------------------
  |  |  130|  1.28k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  520|  1.28k|                break;
  521|      0|            case 'C':
  ------------------
  |  Branch (521:13): [True: 0, False: 2.56k]
  ------------------
  522|      0|                if (m == O_RDONLY)
  ------------------
  |  Branch (522:21): [True: 0, False: 0]
  ------------------
  523|      0|                    tif->tif_flags |= TIFF_STRIPCHOP;
  ------------------
  |  |  134|      0|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  524|      0|                break;
  525|      0|            case 'c':
  ------------------
  |  Branch (525:13): [True: 0, False: 2.56k]
  ------------------
  526|      0|                if (m == O_RDONLY)
  ------------------
  |  Branch (526:21): [True: 0, False: 0]
  ------------------
  527|      0|                    tif->tif_flags &= ~TIFF_STRIPCHOP;
  ------------------
  |  |  134|      0|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  528|      0|                break;
  529|      0|            case 'h':
  ------------------
  |  Branch (529:13): [True: 0, False: 2.56k]
  ------------------
  530|      0|                tif->tif_flags |= TIFF_HEADERONLY;
  ------------------
  |  |  136|      0|    0x10000U /* read header only, do not process the first directory */
  ------------------
  531|      0|                break;
  532|      0|            case '8':
  ------------------
  |  Branch (532:13): [True: 0, False: 2.56k]
  ------------------
  533|      0|                if (m & O_CREAT)
  ------------------
  |  Branch (533:21): [True: 0, False: 0]
  ------------------
  534|      0|                    tif->tif_flags |= TIFF_BIGTIFF;
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  535|      0|                break;
  536|      0|            case 'D':
  ------------------
  |  Branch (536:13): [True: 0, False: 2.56k]
  ------------------
  537|      0|                tif->tif_flags |= TIFF_DEFERSTRILELOAD;
  ------------------
  |  |  147|      0|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  538|      0|                break;
  539|      0|            case 'O':
  ------------------
  |  Branch (539:13): [True: 0, False: 2.56k]
  ------------------
  540|      0|                if (m == O_RDONLY)
  ------------------
  |  Branch (540:21): [True: 0, False: 0]
  ------------------
  541|      0|                    tif->tif_flags |=
  542|      0|                        (TIFF_LAZYSTRILELOAD_ASKED | TIFF_DEFERSTRILELOAD);
  ------------------
  |  |  156|      0|    0x8000000U /* set when lazy/ondemand loading of strip/tile                 \
  ------------------
                                      (TIFF_LAZYSTRILELOAD_ASKED | TIFF_DEFERSTRILELOAD);
  ------------------
  |  |  147|      0|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  543|      0|                break;
  544|  1.28k|            default:
  ------------------
  |  Branch (544:13): [True: 1.28k, False: 1.28k]
  ------------------
  545|  1.28k|                break;
  546|  2.56k|        }
  547|       |
  548|       |#ifdef DEFER_STRILE_LOAD
  549|       |    /* Compatibility with old DEFER_STRILE_LOAD compilation flag */
  550|       |    /* Probably unneeded, since to the best of my knowledge (E. Rouault) */
  551|       |    /* GDAL was the only user of this, and will now use the new 'D' flag */
  552|       |    tif->tif_flags |= TIFF_DEFERSTRILELOAD;
  553|       |#endif
  554|       |
  555|       |    /*
  556|       |     * Read in TIFF header.
  557|       |     */
  558|  1.28k|    if ((m & O_TRUNC) ||
  ------------------
  |  Branch (558:9): [True: 0, False: 1.28k]
  ------------------
  559|  1.28k|        !ReadOK(tif, &tif->tif_header, sizeof(TIFFHeaderClassic)))
  ------------------
  |  |  300|  1.28k|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|  1.28k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (559:9): [True: 0, False: 1.28k]
  ------------------
  560|      0|    {
  561|      0|        if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (561:13): [True: 0, False: 0]
  ------------------
  562|      0|        {
  563|      0|            TIFFErrorExtR(tif, name, "Cannot read TIFF header");
  564|      0|            goto bad;
  565|      0|        }
  566|       |        /*
  567|       |         * Setup header and write.
  568|       |         */
  569|       |#if WORDS_BIGENDIAN
  570|       |        tif->tif_header.common.tiff_magic =
  571|       |            (tif->tif_flags & TIFF_SWAB) ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN;
  572|       |#else
  573|      0|        tif->tif_header.common.tiff_magic =
  574|      0|            (tif->tif_flags & TIFF_SWAB) ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN;
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
                          (tif->tif_flags & TIFF_SWAB) ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN;
  ------------------
  |  |   51|      0|#define TIFF_BIGENDIAN 0x4d4d
  ------------------
                          (tif->tif_flags & TIFF_SWAB) ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN;
  ------------------
  |  |   52|      0|#define TIFF_LITTLEENDIAN 0x4949
  ------------------
  |  Branch (574:13): [True: 0, False: 0]
  ------------------
  575|      0|#endif
  576|      0|        TIFFHeaderUnion tif_header_swapped;
  577|      0|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      0|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (577:13): [True: 0, False: 0]
  ------------------
  578|      0|        {
  579|      0|            tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC;
  ------------------
  |  |   48|      0|#define TIFF_VERSION_CLASSIC 42
  ------------------
  580|      0|            tif->tif_header.classic.tiff_diroff = 0;
  581|      0|            tif->tif_header_size = sizeof(TIFFHeaderClassic);
  582|       |            /* Swapped copy for writing */
  583|      0|            _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
  584|      0|                        sizeof(TIFFHeaderUnion));
  585|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (585:17): [True: 0, False: 0]
  ------------------
  586|      0|                TIFFSwabShort(&tif_header_swapped.common.tiff_version);
  587|      0|        }
  588|      0|        else
  589|      0|        {
  590|      0|            tif->tif_header.common.tiff_version = TIFF_VERSION_BIG;
  ------------------
  |  |   49|      0|#define TIFF_VERSION_BIG 43
  ------------------
  591|      0|            tif->tif_header.big.tiff_offsetsize = 8;
  592|      0|            tif->tif_header.big.tiff_unused = 0;
  593|      0|            tif->tif_header.big.tiff_diroff = 0;
  594|      0|            tif->tif_header_size = sizeof(TIFFHeaderBig);
  595|       |            /* Swapped copy for writing */
  596|      0|            _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
  597|      0|                        sizeof(TIFFHeaderUnion));
  598|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (598:17): [True: 0, False: 0]
  ------------------
  599|      0|            {
  600|      0|                TIFFSwabShort(&tif_header_swapped.common.tiff_version);
  601|      0|                TIFFSwabShort(&tif_header_swapped.big.tiff_offsetsize);
  602|      0|            }
  603|      0|        }
  604|       |        /*
  605|       |         * The doc for "fopen" for some STD_C_LIBs says that if you
  606|       |         * open a file for modify ("+"), then you must fseek (or
  607|       |         * fflush?) between any freads and fwrites.  This is not
  608|       |         * necessary on most systems, but has been shown to be needed
  609|       |         * on Solaris.
  610|       |         */
  611|      0|        TIFFSeekFile(tif, 0, SEEK_SET);
  ------------------
  |  |  287|      0|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
  612|      0|        if (!WriteOK(tif, &tif_header_swapped,
  ------------------
  |  |  307|      0|    (TIFFWriteFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  285|      0|    ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (612:13): [True: 0, False: 0]
  ------------------
  613|      0|                     (tmsize_t)(tif->tif_header_size)))
  614|      0|        {
  615|      0|            TIFFErrorExtR(tif, name, "Error writing TIFF header");
  616|      0|            goto bad;
  617|      0|        }
  618|       |        /*
  619|       |         * Setup default directory.
  620|       |         */
  621|      0|        if (!TIFFDefaultDirectory(tif))
  ------------------
  |  Branch (621:13): [True: 0, False: 0]
  ------------------
  622|      0|            goto bad;
  623|      0|        tif->tif_diroff = 0;
  624|      0|        tif->tif_lastdiroff = 0;
  625|      0|        tif->tif_setdirectory_force_absolute = FALSE;
  ------------------
  |  |   72|      0|#define FALSE 0
  ------------------
  626|       |        /* tif_curdircount = 0 means 'empty file opened for writing, but no IFD
  627|       |         * written yet' */
  628|      0|        tif->tif_curdircount = 0;
  629|      0|        return (tif);
  630|      0|    }
  631|       |
  632|       |    /*
  633|       |     * Setup the byte order handling according to the opened file for reading.
  634|       |     */
  635|  1.28k|    if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN &&
  ------------------
  |  |   51|  2.56k|#define TIFF_BIGENDIAN 0x4d4d
  ------------------
  |  Branch (635:9): [True: 1.27k, False: 2]
  ------------------
  636|  1.27k|        tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN
  ------------------
  |  |   52|  2.55k|#define TIFF_LITTLEENDIAN 0x4949
  ------------------
  |  Branch (636:9): [True: 3, False: 1.27k]
  ------------------
  637|      3|#if MDI_SUPPORT
  638|      3|        &&
  639|       |#if HOST_BIGENDIAN
  640|       |        tif->tif_header.common.tiff_magic != MDI_BIGENDIAN
  641|       |#else
  642|      3|        tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN
  ------------------
  |  |   53|      3|#define MDI_LITTLEENDIAN 0x5045
  ------------------
  |  Branch (642:9): [True: 3, False: 0]
  ------------------
  643|  1.28k|#endif
  644|  1.28k|    )
  645|      3|    {
  646|      3|        TIFFErrorExtR(tif, name,
  647|      3|                      "Not a TIFF or MDI file, bad magic number %" PRIu16
  648|      3|                      " (0x%" PRIx16 ")",
  649|       |#else
  650|       |    )
  651|       |    {
  652|       |        TIFFErrorExtR(tif, name,
  653|       |                      "Not a TIFF file, bad magic number %" PRIu16
  654|       |                      " (0x%" PRIx16 ")",
  655|       |#endif
  656|      3|                      tif->tif_header.common.tiff_magic,
  657|      3|                      tif->tif_header.common.tiff_magic);
  658|      3|        goto bad;
  659|      3|    }
  660|  1.27k|    if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN)
  ------------------
  |  |   51|  1.27k|#define TIFF_BIGENDIAN 0x4d4d
  ------------------
  |  Branch (660:9): [True: 2, False: 1.27k]
  ------------------
  661|      2|    {
  662|      2|#if !WORDS_BIGENDIAN
  663|      2|        tif->tif_flags |= TIFF_SWAB;
  ------------------
  |  |  126|      2|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  664|      2|#endif
  665|      2|    }
  666|  1.27k|    else
  667|  1.27k|    {
  668|       |#if WORDS_BIGENDIAN
  669|       |        tif->tif_flags |= TIFF_SWAB;
  670|       |#endif
  671|  1.27k|    }
  672|  1.27k|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.27k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (672:9): [True: 2, False: 1.27k]
  ------------------
  673|      2|        TIFFSwabShort(&tif->tif_header.common.tiff_version);
  674|  1.27k|    if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC) &&
  ------------------
  |  |   48|  1.27k|#define TIFF_VERSION_CLASSIC 42
  ------------------
  |  Branch (674:9): [True: 255, False: 1.02k]
  ------------------
  675|    255|        (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG))
  ------------------
  |  |   49|    255|#define TIFF_VERSION_BIG 43
  ------------------
  |  Branch (675:9): [True: 0, False: 255]
  ------------------
  676|      0|    {
  677|      0|        TIFFErrorExtR(tif, name,
  678|      0|                      "Not a TIFF file, bad version number %" PRIu16
  679|      0|                      " (0x%" PRIx16 ")",
  680|      0|                      tif->tif_header.common.tiff_version,
  681|      0|                      tif->tif_header.common.tiff_version);
  682|      0|        goto bad;
  683|      0|    }
  684|  1.27k|    if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC)
  ------------------
  |  |   48|  1.27k|#define TIFF_VERSION_CLASSIC 42
  ------------------
  |  Branch (684:9): [True: 1.02k, False: 255]
  ------------------
  685|  1.02k|    {
  686|  1.02k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.02k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (686:13): [True: 2, False: 1.02k]
  ------------------
  687|      2|            TIFFSwabLong(&tif->tif_header.classic.tiff_diroff);
  688|  1.02k|        tif->tif_header_size = sizeof(TIFFHeaderClassic);
  689|  1.02k|    }
  690|    255|    else
  691|    255|    {
  692|    255|        if (!ReadOK(tif,
  ------------------
  |  |  300|    255|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    255|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (692:13): [True: 0, False: 255]
  ------------------
  693|    255|                    ((uint8_t *)(&tif->tif_header) + sizeof(TIFFHeaderClassic)),
  694|    255|                    (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic))))
  695|      0|        {
  696|      0|            TIFFErrorExtR(tif, name, "Cannot read TIFF header");
  697|      0|            goto bad;
  698|      0|        }
  699|    255|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    255|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (699:13): [True: 0, False: 255]
  ------------------
  700|      0|        {
  701|      0|            TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
  702|      0|            TIFFSwabLong8(&tif->tif_header.big.tiff_diroff);
  703|      0|        }
  704|    255|        if (tif->tif_header.big.tiff_offsetsize != 8)
  ------------------
  |  Branch (704:13): [True: 0, False: 255]
  ------------------
  705|      0|        {
  706|      0|            TIFFErrorExtR(tif, name,
  707|      0|                          "Not a TIFF file, bad BigTIFF offsetsize %" PRIu16
  708|      0|                          " (0x%" PRIx16 ")",
  709|      0|                          tif->tif_header.big.tiff_offsetsize,
  710|      0|                          tif->tif_header.big.tiff_offsetsize);
  711|      0|            goto bad;
  712|      0|        }
  713|    255|        if (tif->tif_header.big.tiff_unused != 0)
  ------------------
  |  Branch (713:13): [True: 0, False: 255]
  ------------------
  714|      0|        {
  715|      0|            TIFFErrorExtR(tif, name,
  716|      0|                          "Not a TIFF file, bad BigTIFF unused %" PRIu16
  717|      0|                          " (0x%" PRIx16 ")",
  718|      0|                          tif->tif_header.big.tiff_unused,
  719|      0|                          tif->tif_header.big.tiff_unused);
  720|      0|            goto bad;
  721|      0|        }
  722|    255|        tif->tif_header_size = sizeof(TIFFHeaderBig);
  723|    255|        tif->tif_flags |= TIFF_BIGTIFF;
  ------------------
  |  |  140|    255|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  724|    255|    }
  725|  1.27k|    tif->tif_flags |= TIFF_MYBUFFER;
  ------------------
  |  |  128|  1.27k|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  726|  1.27k|    tif->tif_rawcp = tif->tif_rawdata = 0;
  727|  1.27k|    tif->tif_rawdatasize = 0;
  728|  1.27k|    tif->tif_rawdataoff = 0;
  729|  1.27k|    tif->tif_rawdataloaded = 0;
  730|       |
  731|  1.27k|    switch (mode[0])
  732|  1.27k|    {
  733|  1.27k|        case 'r':
  ------------------
  |  Branch (733:9): [True: 1.27k, False: 0]
  ------------------
  734|  1.27k|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  1.27k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (734:17): [True: 1.02k, False: 255]
  ------------------
  735|  1.02k|                tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff;
  736|    255|            else
  737|    255|                tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff;
  738|       |            /*
  739|       |             * Try to use a memory-mapped file if the client
  740|       |             * has not explicitly suppressed usage with the
  741|       |             * 'm' flag in the open mode (see above).
  742|       |             */
  743|  1.27k|            if (tif->tif_flags & TIFF_MAPPED)
  ------------------
  |  |  130|  1.27k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  |  Branch (743:17): [True: 0, False: 1.27k]
  ------------------
  744|      0|            {
  745|      0|                toff_t n;
  746|      0|                if (TIFFMapFileContents(tif, (void **)(&tif->tif_base), &n))
  ------------------
  |  |  291|      0|    ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))
  |  |  ------------------
  |  |  |  Branch (291:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  747|      0|                {
  748|      0|                    tif->tif_size = (tmsize_t)n;
  749|      0|                    assert((toff_t)tif->tif_size == n);
  ------------------
  |  Branch (749:21): [True: 0, False: 0]
  |  Branch (749:21): [True: 0, False: 0]
  ------------------
  750|      0|                }
  751|      0|                else
  752|      0|                    tif->tif_flags &= ~TIFF_MAPPED;
  ------------------
  |  |  130|      0|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  753|      0|            }
  754|       |            /*
  755|       |             * Sometimes we do not want to read the first directory (for
  756|       |             * example, it may be broken) and want to proceed to other
  757|       |             * directories. I this case we use the TIFF_HEADERONLY flag to open
  758|       |             * file and return immediately after reading TIFF header.
  759|       |             * However, the pointer to TIFFSetField() and TIFFGetField()
  760|       |             * (i.e. tif->tif_tagmethods.vsetfield and
  761|       |             * tif->tif_tagmethods.vgetfield) need to be initialized, which is
  762|       |             * done in TIFFDefaultDirectory().
  763|       |             */
  764|  1.27k|            if (tif->tif_flags & TIFF_HEADERONLY)
  ------------------
  |  |  136|  1.27k|    0x10000U /* read header only, do not process the first directory */
  ------------------
  |  Branch (764:17): [True: 0, False: 1.27k]
  ------------------
  765|      0|            {
  766|      0|                if (!TIFFDefaultDirectory(tif))
  ------------------
  |  Branch (766:21): [True: 0, False: 0]
  ------------------
  767|      0|                    goto bad;
  768|      0|                return (tif);
  769|      0|            }
  770|       |
  771|       |            /*
  772|       |             * Setup initial directory.
  773|       |             */
  774|  1.27k|            if (TIFFReadDirectory(tif))
  ------------------
  |  Branch (774:17): [True: 993, False: 284]
  ------------------
  775|    993|            {
  776|    993|                return (tif);
  777|    993|            }
  778|    284|            break;
  779|    284|        case 'a':
  ------------------
  |  Branch (779:9): [True: 0, False: 1.27k]
  ------------------
  780|       |            /*
  781|       |             * New directories are automatically append
  782|       |             * to the end of the directory chain when they
  783|       |             * are written out (see TIFFWriteDirectory).
  784|       |             */
  785|      0|            if (!TIFFDefaultDirectory(tif))
  ------------------
  |  Branch (785:17): [True: 0, False: 0]
  ------------------
  786|      0|                goto bad;
  787|      0|            return (tif);
  788|      0|        default:
  ------------------
  |  Branch (788:9): [True: 0, False: 1.27k]
  ------------------
  789|      0|            break;
  790|  1.27k|    }
  791|    287|bad:
  792|    287|    tif->tif_mode = O_RDONLY; /* XXX avoid flush */
  793|    287|    TIFFCleanup(tif);
  794|    287|bad2:
  795|    287|    return ((TIFF *)0);
  796|    287|}
TIFFFileName:
  805|  1.12k|const char *TIFFFileName(TIFF *tif) { return (tif->tif_name); }
TIFFIsTiled:
  866|  4.72k|int TIFFIsTiled(TIFF *tif) { return (isTiled(tif)); }
  ------------------
  |  |  278|  4.72k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  4.72k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------

TIFFInitPackBits:
  331|     38|{
  332|     38|    (void)scheme;
  333|     38|    tif->tif_decoderow = PackBitsDecode;
  334|     38|    tif->tif_decodestrip = PackBitsDecode;
  335|     38|    tif->tif_decodetile = PackBitsDecode;
  336|     38|#ifndef PACKBITS_READ_ONLY
  337|     38|    tif->tif_preencode = PackBitsPreEncode;
  338|     38|    tif->tif_postencode = PackBitsPostEncode;
  339|     38|    tif->tif_encoderow = PackBitsEncode;
  340|     38|    tif->tif_encodestrip = PackBitsEncodeChunk;
  341|     38|    tif->tif_encodetile = PackBitsEncodeChunk;
  342|     38|#endif
  343|     38|    tif->tif_getmaxcompressionratio = PackBitsGetMaxCompressionRatio;
  344|       |
  345|     38|    return (1);
  346|     38|}
tif_packbits.c:PackBitsDecode:
  244|     51|{
  245|     51|    static const char module[] = "PackBitsDecode";
  246|     51|    int8_t *bp;
  247|     51|    tmsize_t cc;
  248|     51|    long n;
  249|     51|    int b;
  250|       |
  251|     51|    (void)s;
  252|     51|    bp = (int8_t *)tif->tif_rawcp;
  253|     51|    cc = tif->tif_rawcc;
  254|   357k|    while (cc > 0 && occ > 0)
  ------------------
  |  Branch (254:12): [True: 357k, False: 4]
  |  Branch (254:22): [True: 357k, False: 2]
  ------------------
  255|   357k|    {
  256|   357k|        n = (long)*bp++;
  257|   357k|        cc--;
  258|   357k|        if (n < 0)
  ------------------
  |  Branch (258:13): [True: 64.9k, False: 293k]
  ------------------
  259|  64.9k|        {                  /* replicate next byte -n+1 times */
  260|  64.9k|            if (n == -128) /* nop */
  ------------------
  |  Branch (260:17): [True: 5.57k, False: 59.3k]
  ------------------
  261|  5.57k|                continue;
  262|  59.3k|            n = -n + 1;
  263|  59.3k|            if (occ < (tmsize_t)n)
  ------------------
  |  Branch (263:17): [True: 0, False: 59.3k]
  ------------------
  264|      0|            {
  265|      0|                TIFFWarningExtR(tif, module,
  266|      0|                                "Discarding %" TIFF_SSIZE_FORMAT
  267|      0|                                " bytes to avoid buffer overrun",
  268|      0|                                (tmsize_t)n - occ);
  269|      0|                n = (long)occ;
  270|      0|            }
  271|  59.3k|            if (cc == 0)
  ------------------
  |  Branch (271:17): [True: 8, False: 59.3k]
  ------------------
  272|      8|            {
  273|      8|                TIFFWarningExtR(
  274|      8|                    tif, module,
  275|      8|                    "Terminating PackBitsDecode due to lack of data.");
  276|      8|                break;
  277|      8|            }
  278|  59.3k|            occ -= n;
  279|  59.3k|            b = *bp++;
  280|  59.3k|            cc--;
  281|  2.66M|            while (n-- > 0)
  ------------------
  |  Branch (281:20): [True: 2.60M, False: 59.3k]
  ------------------
  282|  2.60M|                *op++ = (uint8_t)b;
  283|  59.3k|        }
  284|   293k|        else
  285|   293k|        { /* copy next n+1 bytes literally */
  286|   293k|            if (occ < (tmsize_t)(n + 1))
  ------------------
  |  Branch (286:17): [True: 18, False: 292k]
  ------------------
  287|     18|            {
  288|     18|                TIFFWarningExtR(tif, module,
  289|     18|                                "Discarding %" TIFF_SSIZE_FORMAT
  290|     18|                                " bytes to avoid buffer overrun",
  291|     18|                                (tmsize_t)n - occ + 1);
  292|     18|                n = (long)occ - 1;
  293|     18|            }
  294|   293k|            if (cc < (tmsize_t)(n + 1))
  ------------------
  |  Branch (294:17): [True: 37, False: 292k]
  ------------------
  295|     37|            {
  296|     37|                TIFFWarningExtR(
  297|     37|                    tif, module,
  298|     37|                    "Terminating PackBitsDecode due to lack of data.");
  299|     37|                break;
  300|     37|            }
  301|   292k|            _TIFFmemcpy(op, bp, ++n);
  302|   292k|            op += n;
  303|   292k|            occ -= n;
  304|   292k|            bp += n;
  305|   292k|            cc -= n;
  306|   292k|        }
  307|   357k|    }
  308|     51|    tif->tif_rawcp = (uint8_t *)bp;
  309|     51|    tif->tif_rawcc = cc;
  310|     51|    if (occ > 0)
  ------------------
  |  Branch (310:9): [True: 49, False: 2]
  ------------------
  311|     49|    {
  312|     49|        memset(op, 0, (size_t)occ);
  313|     49|        TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
  314|     49|                      tif->tif_dir.td_row);
  315|     49|        return (0);
  316|     49|    }
  317|      2|    return (1);
  318|     51|}

TIFFInitPixarLog:
 1804|     63|{
 1805|     63|    static const char module[] = "TIFFInitPixarLog";
 1806|       |
 1807|     63|    PixarLogState *sp;
 1808|       |
 1809|     63|    (void)scheme;
 1810|     63|    assert(scheme == COMPRESSION_PIXARLOG);
  ------------------
  |  Branch (1810:5): [True: 0, False: 63]
  |  Branch (1810:5): [True: 63, False: 0]
  ------------------
 1811|       |
 1812|       |    /*
 1813|       |     * Merge codec-specific tag information.
 1814|       |     */
 1815|     63|    if (!_TIFFMergeFields(tif, pixarlogFields, TIFFArrayCount(pixarlogFields)))
  ------------------
  |  |  339|     63|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1815:9): [True: 0, False: 63]
  ------------------
 1816|      0|    {
 1817|      0|        TIFFErrorExtR(tif, module,
 1818|      0|                      "Merging PixarLog codec-specific tags failed");
 1819|      0|        return 0;
 1820|      0|    }
 1821|       |
 1822|       |    /*
 1823|       |     * Allocate state block so tag methods have storage to record values.
 1824|       |     */
 1825|     63|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(PixarLogState));
 1826|     63|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1826:9): [True: 0, False: 63]
  ------------------
 1827|      0|        goto bad;
 1828|     63|    sp = (PixarLogState *)tif->tif_data;
 1829|     63|    _TIFFmemset(sp, 0, sizeof(*sp));
 1830|     63|    sp->stream.data_type = Z_BINARY;
 1831|     63|    sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN;
  ------------------
  |  |  765|     63|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
 1832|       |
 1833|       |    /*
 1834|       |     * Install codec methods.
 1835|       |     */
 1836|     63|    tif->tif_fixuptags = PixarLogFixupTags;
 1837|     63|    tif->tif_setupdecode = PixarLogSetupDecode;
 1838|     63|    tif->tif_predecode = PixarLogPreDecode;
 1839|     63|    tif->tif_decoderow = PixarLogDecode;
 1840|     63|    tif->tif_decodestrip = PixarLogDecode;
 1841|     63|    tif->tif_decodetile = PixarLogDecode;
 1842|     63|    tif->tif_setupencode = PixarLogSetupEncode;
 1843|     63|    tif->tif_preencode = PixarLogPreEncode;
 1844|     63|    tif->tif_postencode = PixarLogPostEncode;
 1845|     63|    tif->tif_encoderow = PixarLogEncode;
 1846|     63|    tif->tif_encodestrip = PixarLogEncode;
 1847|     63|    tif->tif_encodetile = PixarLogEncode;
 1848|     63|    tif->tif_close = PixarLogClose;
 1849|     63|    tif->tif_cleanup = PixarLogCleanup;
 1850|     63|    tif->tif_getmaxcompressionratio = PixarLogGetMaxCompressionRatio;
 1851|       |
 1852|       |    /* Override SetField so we can handle our private pseudo-tag */
 1853|     63|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1854|     63|    tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */
 1855|     63|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1856|     63|    tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */
 1857|       |
 1858|       |    /* Default values for codec-specific fields */
 1859|     63|    sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */
 1860|     63|    sp->state = 0;
 1861|       |
 1862|       |    /* we don't wish to use the predictor,
 1863|       |     * the default is none, which predictor value 1
 1864|       |     */
 1865|     63|    (void)TIFFPredictorInit(tif);
 1866|       |
 1867|       |    /*
 1868|       |     * build the companding tables
 1869|       |     */
 1870|     63|    PixarLogMakeTables(tif, sp);
 1871|       |
 1872|     63|    return (1);
 1873|      0|bad:
 1874|      0|    TIFFErrorExtR(tif, module, "No space for PixarLog state block");
 1875|      0|    return (0);
 1876|     63|}
tif_pixarlog.c:PixarLogFixupTags:
  822|     60|{
  823|     60|    (void)tif;
  824|     60|    return (1);
  825|     60|}
tif_pixarlog.c:PixarLogSetupDecode:
  828|    229|{
  829|    229|    static const char module[] = "PixarLogSetupDecode";
  830|    229|    TIFFDirectory *td = &tif->tif_dir;
  831|    229|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|    229|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  832|    229|    tmsize_t tbuf_size;
  833|    229|    uint32_t strip_height;
  834|       |
  835|    229|    assert(sp != NULL);
  ------------------
  |  Branch (835:5): [True: 0, False: 229]
  |  Branch (835:5): [True: 229, False: 0]
  ------------------
  836|       |
  837|       |    /* This function can possibly be called several times by */
  838|       |    /* PredictorSetupDecode() if this function succeeds but */
  839|       |    /* PredictorSetup() fails */
  840|    229|    if ((sp->state & PLSTATE_INIT) != 0)
  ------------------
  |  |  615|    229|#define PLSTATE_INIT 1
  ------------------
  |  Branch (840:9): [True: 0, False: 229]
  ------------------
  841|      0|        return 1;
  842|       |
  843|    229|    strip_height = td->td_rowsperstrip;
  844|    229|    if (strip_height > td->td_imagelength)
  ------------------
  |  Branch (844:9): [True: 39, False: 190]
  ------------------
  845|     39|        strip_height = td->td_imagelength;
  846|       |
  847|       |    /* Make sure no byte swapping happens on the data
  848|       |     * after decompression. */
  849|    229|    tif->tif_postdecode = _TIFFNoPostDecode;
  850|       |
  851|       |    /* for some reason, we can't do this in TIFFInitPixarLog */
  852|       |
  853|    229|    sp->stride =
  854|    229|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|    229|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (854:10): [True: 149, False: 80]
  ------------------
  855|    229|                                                    : 1);
  856|    229|    tbuf_size = multiply_ms(
  857|    229|        multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), strip_height),
  858|    229|        sizeof(uint16_t));
  859|       |    /* add one more stride in case input ends mid-stride */
  860|    229|    tbuf_size =
  861|    229|        add_ms(tbuf_size, (tmsize_t)(sizeof(uint16_t) * (size_t)sp->stride));
  862|    229|    if (tbuf_size == 0)
  ------------------
  |  Branch (862:9): [True: 0, False: 229]
  ------------------
  863|      0|        return (0); /* TODO: this is an error return without error report
  864|       |                       through TIFFErrorExt */
  865|    229|    sp->tbuf = (uint16_t *)_TIFFmallocExt(tif, tbuf_size);
  866|    229|    if (sp->tbuf == NULL)
  ------------------
  |  Branch (866:9): [True: 0, False: 229]
  ------------------
  867|      0|        return (0);
  868|    229|    sp->tbuf_size = tbuf_size;
  869|    229|    if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
  ------------------
  |  |  765|    229|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (869:9): [True: 229, False: 0]
  ------------------
  870|    229|        sp->user_datafmt = PixarLogGuessDataFmt(td);
  871|    229|    if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
  ------------------
  |  |  765|    229|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (871:9): [True: 186, False: 43]
  ------------------
  872|    186|    {
  873|    186|        _TIFFfreeExt(tif, sp->tbuf);
  874|    186|        sp->tbuf = NULL;
  875|    186|        sp->tbuf_size = 0;
  876|    186|        TIFFErrorExtR(tif, module,
  877|    186|                      "PixarLog compression can't handle bits depth/data "
  878|    186|                      "format combination (depth: %" PRIu16 ")",
  879|    186|                      td->td_bitspersample);
  880|    186|        return (0);
  881|    186|    }
  882|       |
  883|     43|    if (inflateInit(&sp->stream) != Z_OK)
  ------------------
  |  Branch (883:9): [True: 0, False: 43]
  ------------------
  884|      0|    {
  885|      0|        _TIFFfreeExt(tif, sp->tbuf);
  886|      0|        sp->tbuf = NULL;
  887|      0|        sp->tbuf_size = 0;
  888|      0|        TIFFErrorExtR(tif, module, "%s",
  889|      0|                      sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (889:23): [True: 0, False: 0]
  ------------------
  890|      0|        return (0);
  891|      0|    }
  892|     43|    else
  893|     43|    {
  894|     43|        sp->state |= PLSTATE_INIT;
  ------------------
  |  |  615|     43|#define PLSTATE_INIT 1
  ------------------
  895|     43|        return (1);
  896|     43|    }
  897|     43|}
tif_pixarlog.c:multiply_ms:
  805|    687|{
  806|    687|    return _TIFFMultiplySSize(NULL, m1, m2, NULL);
  807|    687|}
tif_pixarlog.c:add_ms:
  810|    229|{
  811|    229|    assert(m1 >= 0 && m2 >= 0);
  ------------------
  |  Branch (811:5): [True: 0, False: 229]
  |  Branch (811:5): [True: 0, False: 0]
  |  Branch (811:5): [True: 229, False: 0]
  |  Branch (811:5): [True: 229, False: 0]
  ------------------
  812|       |    /* if either input is zero, assume overflow already occurred */
  813|    229|    if (m1 == 0 || m2 == 0)
  ------------------
  |  Branch (813:9): [True: 0, False: 229]
  |  Branch (813:20): [True: 0, False: 229]
  ------------------
  814|      0|        return 0;
  815|    229|    else if (m1 > TIFF_TMSIZE_T_MAX - m2)
  ------------------
  |  |   68|    229|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (815:14): [True: 0, False: 229]
  ------------------
  816|      0|        return 0;
  817|       |
  818|    229|    return m1 + m2;
  819|    229|}
tif_pixarlog.c:PixarLogGuessDataFmt:
  768|    229|{
  769|    229|    int guess = PIXARLOGDATAFMT_UNKNOWN;
  ------------------
  |  |  765|    229|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  770|    229|    int format = td->td_sampleformat;
  771|       |
  772|       |    /* If the user didn't tell us his datafmt,
  773|       |     * take our best guess from the bitspersample.
  774|       |     */
  775|    229|    switch (td->td_bitspersample)
  776|    229|    {
  777|    120|        case 32:
  ------------------
  |  Branch (777:9): [True: 120, False: 109]
  ------------------
  778|    120|            if (format == SAMPLEFORMAT_IEEEFP)
  ------------------
  |  |  336|    120|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (778:17): [True: 4, False: 116]
  ------------------
  779|      4|                guess = PIXARLOGDATAFMT_FLOAT;
  ------------------
  |  |  720|      4|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  780|    120|            break;
  781|     11|        case 16:
  ------------------
  |  Branch (781:9): [True: 11, False: 218]
  ------------------
  782|     11|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|     22|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      4|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (782:17): [True: 7, False: 4]
  |  Branch (782:48): [True: 4, False: 0]
  ------------------
  783|     11|                guess = PIXARLOGDATAFMT_16BIT;
  ------------------
  |  |  719|     11|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  784|     11|            break;
  785|      3|        case 12:
  ------------------
  |  Branch (785:9): [True: 3, False: 226]
  ------------------
  786|      3|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT)
  ------------------
  |  |  337|      6|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT)
  ------------------
  |  |  335|      0|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
  |  Branch (786:17): [True: 3, False: 0]
  |  Branch (786:48): [True: 0, False: 0]
  ------------------
  787|      3|                guess = PIXARLOGDATAFMT_12BITPICIO;
  ------------------
  |  |  718|      3|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  788|      3|            break;
  789|     10|        case 11:
  ------------------
  |  Branch (789:9): [True: 10, False: 219]
  ------------------
  790|     10|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|     20|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      7|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (790:17): [True: 3, False: 7]
  |  Branch (790:48): [True: 7, False: 0]
  ------------------
  791|     10|                guess = PIXARLOGDATAFMT_11BITLOG;
  ------------------
  |  |  717|     10|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  792|     10|            break;
  793|     15|        case 8:
  ------------------
  |  Branch (793:9): [True: 15, False: 214]
  ------------------
  794|     15|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|     30|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      8|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (794:17): [True: 7, False: 8]
  |  Branch (794:48): [True: 8, False: 0]
  ------------------
  795|     15|                guess = PIXARLOGDATAFMT_8BIT;
  ------------------
  |  |  715|     15|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  796|     15|            break;
  797|     70|        default:
  ------------------
  |  Branch (797:9): [True: 70, False: 159]
  ------------------
  798|     70|            break;
  799|    229|    }
  800|       |
  801|    229|    return guess;
  802|    229|}
tif_pixarlog.c:PixarLogPreDecode:
  903|    186|{
  904|    186|    static const char module[] = "PixarLogPreDecode";
  905|    186|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|    186|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  906|       |
  907|    186|    (void)s;
  908|    186|    assert(sp != NULL);
  ------------------
  |  Branch (908:5): [True: 0, False: 186]
  |  Branch (908:5): [True: 186, False: 0]
  ------------------
  909|    186|    sp->stream.next_in = tif->tif_rawdata;
  910|    186|    assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (910:5): [True: 0, Folded]
  |  Branch (910:5): [True: 186, Folded]
  ------------------
  911|       |         we need to simplify this code to reflect a ZLib that is likely updated
  912|       |         to deal with 8byte memory sizes, though this code will respond
  913|       |         appropriately even before we simplify it */
  914|    186|    sp->stream.avail_in = (uInt)tif->tif_rawcc;
  915|    186|    if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
  ------------------
  |  Branch (915:9): [True: 0, False: 186]
  ------------------
  916|      0|    {
  917|      0|        TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
  918|      0|        return (0);
  919|      0|    }
  920|    186|    return (inflateReset(&sp->stream) == Z_OK);
  921|    186|}
tif_pixarlog.c:PixarLogDecode:
  924|    186|{
  925|    186|    static const char module[] = "PixarLogDecode";
  926|    186|    TIFFDirectory *td = &tif->tif_dir;
  927|    186|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|    186|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  928|    186|    tmsize_t i;
  929|    186|    tmsize_t nsamples;
  930|    186|    tmsize_t llen;
  931|    186|    uint16_t *up;
  932|       |
  933|    186|    switch (sp->user_datafmt)
  934|    186|    {
  935|    116|        case PIXARLOGDATAFMT_FLOAT:
  ------------------
  |  |  720|    116|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  |  Branch (935:9): [True: 116, False: 70]
  ------------------
  936|    116|            nsamples = (tmsize_t)((uint64_t)occ /
  937|    116|                                  sizeof(float)); /* XXX float == 32 bits */
  938|    116|            break;
  939|     11|        case PIXARLOGDATAFMT_16BIT:
  ------------------
  |  |  719|     11|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  |  Branch (939:9): [True: 11, False: 175]
  ------------------
  940|     44|        case PIXARLOGDATAFMT_12BITPICIO:
  ------------------
  |  |  718|     44|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  |  Branch (940:9): [True: 33, False: 153]
  ------------------
  941|     54|        case PIXARLOGDATAFMT_11BITLOG:
  ------------------
  |  |  717|     54|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  |  Branch (941:9): [True: 10, False: 176]
  ------------------
  942|     54|            nsamples =
  943|     54|                (tmsize_t)((uint64_t)occ /
  944|     54|                           sizeof(uint16_t)); /* XXX uint16_t == 16 bits */
  945|     54|            break;
  946|     16|        case PIXARLOGDATAFMT_8BIT:
  ------------------
  |  |  715|     16|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  |  Branch (946:9): [True: 16, False: 170]
  ------------------
  947|     16|        case PIXARLOGDATAFMT_8BITABGR:
  ------------------
  |  |  716|     16|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (947:9): [True: 0, False: 186]
  ------------------
  948|     16|            nsamples = occ;
  949|     16|            break;
  950|      0|        default:
  ------------------
  |  Branch (950:9): [True: 0, False: 186]
  ------------------
  951|      0|            TIFFErrorExtR(tif, module,
  952|      0|                          "%" PRIu16 " bit input not supported in PixarLog",
  953|      0|                          td->td_bitspersample);
  954|      0|            memset(op, 0, (size_t)occ);
  955|      0|            return 0;
  956|    186|    }
  957|       |
  958|       |    /* stride (≤ td_samplesperpixel, max 65535) × imagewidth: fits tmsize_t */
  959|    186|    llen = (tmsize_t)sp->stride * td->td_imagewidth;
  960|       |
  961|       |    /* Fix: ABGR with stride=3 expands 3 samples to 4 output bytes per pixel */
  962|    186|    if (sp->user_datafmt == PIXARLOGDATAFMT_8BITABGR && sp->stride == 3)
  ------------------
  |  |  716|    372|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (962:9): [True: 0, False: 186]
  |  Branch (962:57): [True: 0, False: 0]
  ------------------
  963|      0|    {
  964|       |        /* imagewidth × 4: fits tmsize_t (imagewidth is uint32) */
  965|      0|        tmsize_t required = (tmsize_t)td->td_imagewidth * 4;
  966|      0|        tmsize_t max_rows;
  967|      0|        tmsize_t max_nsamples;
  968|       |
  969|       |        /*
  970|       |         * Ensure at least one expanded output row fits.
  971|       |         */
  972|      0|        if (occ < required)
  ------------------
  |  Branch (972:13): [True: 0, False: 0]
  ------------------
  973|      0|        {
  974|      0|            TIFFErrorExtR(tif, module,
  975|      0|                          "Output buffer too small for PixarLog ABGR data");
  976|      0|            memset(op, 0, (size_t)occ);
  977|      0|            return (0);
  978|      0|        }
  979|       |
  980|       |        /*
  981|       |         * The caller-provided output buffer size must represent a whole
  982|       |         * number of expanded ABGR scanlines.
  983|       |         */
  984|      0|        if (occ % required)
  ------------------
  |  Branch (984:13): [True: 0, False: 0]
  ------------------
  985|      0|        {
  986|      0|            TIFFErrorExtR(
  987|      0|                tif, module,
  988|      0|                "Fractional scanline not supported for PixarLog ABGR data");
  989|      0|            memset(op, 0, (size_t)occ);
  990|      0|            return (0);
  991|      0|        }
  992|       |
  993|       |        /*
  994|       |         * PixarLogDecode() may process multiple rows per call
  995|       |         * (e.g. strip decoding). Limit nsamples so the total
  996|       |         * output written by the loop below never exceeds occ.
  997|       |         */
  998|      0|        max_rows = occ / required;
  999|      0|        max_nsamples = max_rows * llen;
 1000|       |
 1001|      0|        if (nsamples > max_nsamples)
  ------------------
  |  Branch (1001:13): [True: 0, False: 0]
  ------------------
 1002|      0|        {
 1003|      0|            TIFFErrorExtR(tif, module,
 1004|      0|                          "Output buffer too small for PixarLog ABGR data");
 1005|      0|            memset(op, 0, (size_t)occ);
 1006|      0|            return (0);
 1007|      0|        }
 1008|      0|    }
 1009|       |
 1010|    186|    (void)s;
 1011|    186|    assert(sp != NULL);
  ------------------
  |  Branch (1011:5): [True: 0, False: 186]
  |  Branch (1011:5): [True: 186, False: 0]
  ------------------
 1012|       |
 1013|    186|    sp->stream.next_in = tif->tif_rawcp;
 1014|    186|    sp->stream.avail_in = (uInt)tif->tif_rawcc;
 1015|       |
 1016|    186|    sp->stream.next_out = (unsigned char *)sp->tbuf;
 1017|    186|    assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (1017:5): [True: 0, Folded]
  |  Branch (1017:5): [True: 186, Folded]
  ------------------
 1018|       |         we need to simplify this code to reflect a ZLib that is likely updated
 1019|       |         to deal with 8byte memory sizes, though this code will respond
 1020|       |         appropriately even before we simplify it */
 1021|    186|    sp->stream.avail_out = (uInt)((unsigned long)nsamples * sizeof(uint16_t));
 1022|    186|    if (sp->stream.avail_out != (unsigned long)nsamples * sizeof(uint16_t))
  ------------------
  |  Branch (1022:9): [True: 0, False: 186]
  ------------------
 1023|      0|    {
 1024|      0|        TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
 1025|      0|        memset(op, 0, (size_t)occ);
 1026|      0|        return (0);
 1027|      0|    }
 1028|       |    /* Check that we will not fill more than what was allocated */
 1029|    186|    if ((tmsize_t)sp->stream.avail_out > sp->tbuf_size)
  ------------------
  |  Branch (1029:9): [True: 2, False: 184]
  ------------------
 1030|      2|    {
 1031|      2|        TIFFErrorExtR(tif, module, "sp->stream.avail_out > sp->tbuf_size");
 1032|      2|        memset(op, 0, (size_t)occ);
 1033|      2|        return (0);
 1034|      2|    }
 1035|    184|    do
 1036|    191|    {
 1037|    191|        int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
 1038|    191|        if (state == Z_STREAM_END)
  ------------------
  |  Branch (1038:13): [True: 0, False: 191]
  ------------------
 1039|      0|        {
 1040|      0|            break; /* XXX */
 1041|      0|        }
 1042|    191|        if (state == Z_DATA_ERROR)
  ------------------
  |  Branch (1042:13): [True: 177, False: 14]
  ------------------
 1043|    177|        {
 1044|    177|            TIFFErrorExtR(tif, module,
 1045|    177|                          "Decoding error at scanline %" PRIu32 ", %s",
 1046|    177|                          tif->tif_dir.td_row,
 1047|    177|                          sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (1047:27): [True: 177, False: 0]
  ------------------
 1048|    177|            memset(op, 0, (size_t)occ);
 1049|    177|            return (0);
 1050|    177|        }
 1051|     14|        if (state != Z_OK)
  ------------------
  |  Branch (1051:13): [True: 7, False: 7]
  ------------------
 1052|      7|        {
 1053|      7|            TIFFErrorExtR(tif, module, "ZLib error: %s",
 1054|      7|                          sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (1054:27): [True: 0, False: 7]
  ------------------
 1055|      7|            memset(op, 0, (size_t)occ);
 1056|      7|            return (0);
 1057|      7|        }
 1058|     14|    } while (sp->stream.avail_out > 0);
  ------------------
  |  Branch (1058:14): [True: 7, False: 0]
  ------------------
 1059|       |
 1060|       |    /* hopefully, we got all the bytes we needed */
 1061|      0|    if (sp->stream.avail_out != 0)
  ------------------
  |  Branch (1061:9): [True: 0, False: 0]
  ------------------
 1062|      0|    {
 1063|      0|        TIFFErrorExtR(tif, module,
 1064|      0|                      "Not enough data at scanline %" PRIu32
 1065|      0|                      " (short %u bytes)",
 1066|      0|                      tif->tif_dir.td_row, sp->stream.avail_out);
 1067|      0|        memset(op, 0, (size_t)occ);
 1068|      0|        return (0);
 1069|      0|    }
 1070|       |
 1071|      0|    tif->tif_rawcp = sp->stream.next_in;
 1072|      0|    tif->tif_rawcc = sp->stream.avail_in;
 1073|       |
 1074|      0|    up = sp->tbuf;
 1075|       |    /* Swap bytes in the data if from a different endian machine. */
 1076|      0|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1076:9): [True: 0, False: 0]
  ------------------
 1077|      0|        TIFFSwabArrayOfShort(up, nsamples);
 1078|       |
 1079|       |    /*
 1080|       |     * if llen is not an exact multiple of nsamples, the decode operation
 1081|       |     * may overflow the output buffer, so truncate it enough to prevent
 1082|       |     * that but still salvage as much data as possible.
 1083|       |     */
 1084|      0|    if (nsamples % llen)
  ------------------
  |  Branch (1084:9): [True: 0, False: 0]
  ------------------
 1085|      0|    {
 1086|      0|        TIFFWarningExtR(tif, module,
 1087|      0|                        "stride %" TIFF_SSIZE_FORMAT
 1088|      0|                        " is not a multiple of sample count, "
 1089|      0|                        "%" TIFF_SSIZE_FORMAT ", data truncated.",
 1090|      0|                        llen, nsamples);
 1091|      0|        nsamples -= nsamples % llen;
 1092|      0|    }
 1093|       |
 1094|      0|    for (i = 0; i < nsamples; i += llen, up += llen)
  ------------------
  |  Branch (1094:17): [True: 0, False: 0]
  ------------------
 1095|      0|    {
 1096|      0|        switch (sp->user_datafmt)
 1097|      0|        {
 1098|      0|            case PIXARLOGDATAFMT_FLOAT:
  ------------------
  |  |  720|      0|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  |  Branch (1098:13): [True: 0, False: 0]
  ------------------
 1099|      0|                horizontalAccumulateF(up, llen, sp->stride, op, sp->ToLinearF);
 1100|      0|                op += (unsigned long)llen * sizeof(float);
 1101|      0|                break;
 1102|      0|            case PIXARLOGDATAFMT_16BIT:
  ------------------
  |  |  719|      0|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  |  Branch (1102:13): [True: 0, False: 0]
  ------------------
 1103|      0|                horizontalAccumulate16(up, llen, sp->stride, op,
 1104|      0|                                       sp->ToLinear16);
 1105|      0|                op += (unsigned long)llen * sizeof(uint16_t);
 1106|      0|                break;
 1107|      0|            case PIXARLOGDATAFMT_12BITPICIO:
  ------------------
  |  |  718|      0|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  |  Branch (1107:13): [True: 0, False: 0]
  ------------------
 1108|      0|                horizontalAccumulate12(up, llen, sp->stride, op, sp->ToLinearF);
 1109|      0|                op += (unsigned long)llen * sizeof(int16_t);
 1110|      0|                break;
 1111|      0|            case PIXARLOGDATAFMT_11BITLOG:
  ------------------
  |  |  717|      0|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  |  Branch (1111:13): [True: 0, False: 0]
  ------------------
 1112|      0|                horizontalAccumulate11(up, llen, sp->stride, op);
 1113|      0|                op += (unsigned long)llen * sizeof(uint16_t);
 1114|      0|                break;
 1115|      0|            case PIXARLOGDATAFMT_8BIT:
  ------------------
  |  |  715|      0|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  |  Branch (1115:13): [True: 0, False: 0]
  ------------------
 1116|      0|                horizontalAccumulate8(up, llen, sp->stride, (unsigned char *)op,
 1117|      0|                                      sp->ToLinear8);
 1118|      0|                op += (unsigned long)llen * sizeof(unsigned char);
 1119|      0|                break;
 1120|      0|            case PIXARLOGDATAFMT_8BITABGR:
  ------------------
  |  |  716|      0|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (1120:13): [True: 0, False: 0]
  ------------------
 1121|      0|                horizontalAccumulate8abgr(up, llen, sp->stride,
 1122|      0|                                          (unsigned char *)op, sp->ToLinear8);
 1123|       |
 1124|       |                /* For stride == 3 (RGB), horizontalAccumulate8abgr expands to 4
 1125|       |                 * bytes/pixel (ABGR) */
 1126|      0|                if (sp->stride == 3)
  ------------------
  |  Branch (1126:21): [True: 0, False: 0]
  ------------------
 1127|      0|                    op += (unsigned long)td->td_imagewidth * 4;
 1128|      0|                else
 1129|      0|                    op += (unsigned long)llen * sizeof(unsigned char);
 1130|      0|                break;
 1131|      0|            default:
  ------------------
  |  Branch (1131:13): [True: 0, False: 0]
  ------------------
 1132|      0|                TIFFErrorExtR(tif, module, "Unsupported bits/sample: %" PRIu16,
 1133|      0|                              td->td_bitspersample);
 1134|      0|                memset(op, 0, (size_t)occ);
 1135|      0|                return (0);
 1136|      0|        }
 1137|      0|    }
 1138|       |
 1139|      0|    return (1);
 1140|      0|}
tif_pixarlog.c:PixarLogCleanup:
 1663|     63|{
 1664|     63|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1665|       |
 1666|     63|    assert(sp != 0);
  ------------------
  |  Branch (1666:5): [True: 0, False: 63]
  |  Branch (1666:5): [True: 63, False: 0]
  ------------------
 1667|       |
 1668|     63|    (void)TIFFPredictorCleanup(tif);
 1669|       |
 1670|     63|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1671|     63|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1672|       |
 1673|     63|    if (sp->FromLT2)
  ------------------
  |  Branch (1673:9): [True: 63, False: 0]
  ------------------
 1674|     63|        _TIFFfreeExt(tif, sp->FromLT2);
 1675|     63|    if (sp->From14)
  ------------------
  |  Branch (1675:9): [True: 63, False: 0]
  ------------------
 1676|     63|        _TIFFfreeExt(tif, sp->From14);
 1677|     63|    if (sp->From8)
  ------------------
  |  Branch (1677:9): [True: 63, False: 0]
  ------------------
 1678|     63|        _TIFFfreeExt(tif, sp->From8);
 1679|     63|    if (sp->ToLinearF)
  ------------------
  |  Branch (1679:9): [True: 63, False: 0]
  ------------------
 1680|     63|        _TIFFfreeExt(tif, sp->ToLinearF);
 1681|     63|    if (sp->ToLinear16)
  ------------------
  |  Branch (1681:9): [True: 63, False: 0]
  ------------------
 1682|     63|        _TIFFfreeExt(tif, sp->ToLinear16);
 1683|     63|    if (sp->ToLinear8)
  ------------------
  |  Branch (1683:9): [True: 63, False: 0]
  ------------------
 1684|     63|        _TIFFfreeExt(tif, sp->ToLinear8);
 1685|     63|    if (sp->state & PLSTATE_INIT)
  ------------------
  |  |  615|     63|#define PLSTATE_INIT 1
  ------------------
  |  Branch (1685:9): [True: 43, False: 20]
  ------------------
 1686|     43|    {
 1687|     43|        if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (1687:13): [True: 43, False: 0]
  ------------------
 1688|     43|            inflateEnd(&sp->stream);
 1689|      0|        else
 1690|      0|            deflateEnd(&sp->stream);
 1691|     43|    }
 1692|     63|    if (sp->tbuf)
  ------------------
  |  Branch (1692:9): [True: 43, False: 20]
  ------------------
 1693|     43|        _TIFFfreeExt(tif, sp->tbuf);
 1694|     63|    _TIFFfreeExt(tif, sp);
 1695|     63|    tif->tif_data = NULL;
 1696|       |
 1697|     63|    _TIFFSetDefaultCompressionState(tif);
 1698|     63|}
tif_pixarlog.c:PixarLogVGetField:
 1770|    453|{
 1771|    453|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1772|       |
 1773|    453|    switch (tag)
 1774|    453|    {
 1775|      0|        case TIFFTAG_PIXARLOGQUALITY:
  ------------------
  |  |  740|      0|#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
  ------------------
  |  Branch (1775:9): [True: 0, False: 453]
  ------------------
 1776|      0|            *va_arg(ap, int *) = sp->quality;
 1777|      0|            break;
 1778|      0|        case TIFFTAG_PIXARLOGDATAFMT:
  ------------------
  |  |  714|      0|#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */
  ------------------
  |  Branch (1778:9): [True: 0, False: 453]
  ------------------
 1779|      0|            *va_arg(ap, int *) = sp->user_datafmt;
 1780|      0|            break;
 1781|    453|        default:
  ------------------
  |  Branch (1781:9): [True: 453, False: 0]
  ------------------
 1782|    453|            return (*sp->vgetparent)(tif, tag, ap);
 1783|    453|    }
 1784|      0|    return (1);
 1785|    453|}
tif_pixarlog.c:PixarLogVSetField:
 1701|    747|{
 1702|    747|    static const char module[] = "PixarLogVSetField";
 1703|    747|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1704|    747|    int result;
 1705|       |
 1706|    747|    switch (tag)
 1707|    747|    {
 1708|      0|        case TIFFTAG_PIXARLOGQUALITY:
  ------------------
  |  |  740|      0|#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
  ------------------
  |  Branch (1708:9): [True: 0, False: 747]
  ------------------
 1709|      0|            sp->quality = (int)va_arg(ap, int);
 1710|      0|            if (tif->tif_mode != O_RDONLY && (sp->state & PLSTATE_INIT))
  ------------------
  |  |  615|      0|#define PLSTATE_INIT 1
  ------------------
  |  Branch (1710:17): [True: 0, False: 0]
  |  Branch (1710:46): [True: 0, False: 0]
  ------------------
 1711|      0|            {
 1712|      0|                if (deflateParams(&sp->stream, sp->quality,
  ------------------
  |  Branch (1712:21): [True: 0, False: 0]
  ------------------
 1713|      0|                                  Z_DEFAULT_STRATEGY) != Z_OK)
 1714|      0|                {
 1715|      0|                    TIFFErrorExtR(tif, module, "ZLib error: %s",
 1716|      0|                                  sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (1716:35): [True: 0, False: 0]
  ------------------
 1717|      0|                    return (0);
 1718|      0|                }
 1719|      0|            }
 1720|      0|            return (1);
 1721|      0|        case TIFFTAG_PIXARLOGDATAFMT:
  ------------------
  |  |  714|      0|#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */
  ------------------
  |  Branch (1721:9): [True: 0, False: 747]
  ------------------
 1722|      0|            sp->user_datafmt = (int)va_arg(ap, int);
 1723|       |            /* Tweak the TIFF header so that the rest of libtiff knows what
 1724|       |             * size of data will be passed between app and library, and
 1725|       |             * assume that the app knows what it is doing and is not
 1726|       |             * confused by these header manipulations...
 1727|       |             */
 1728|      0|            switch (sp->user_datafmt)
 1729|      0|            {
 1730|      0|                case PIXARLOGDATAFMT_8BIT:
  ------------------
  |  |  715|      0|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  |  Branch (1730:17): [True: 0, False: 0]
  ------------------
 1731|      0|                case PIXARLOGDATAFMT_8BITABGR:
  ------------------
  |  |  716|      0|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (1731:17): [True: 0, False: 0]
  ------------------
 1732|      0|                    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
  ------------------
  |  |  180|      0|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1733|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
                                  TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1734|      0|                    break;
 1735|      0|                case PIXARLOGDATAFMT_11BITLOG:
  ------------------
  |  |  717|      0|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  |  Branch (1735:17): [True: 0, False: 0]
  ------------------
 1736|      0|                    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
  ------------------
  |  |  180|      0|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1737|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
                                  TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1738|      0|                    break;
 1739|      0|                case PIXARLOGDATAFMT_12BITPICIO:
  ------------------
  |  |  718|      0|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  |  Branch (1739:17): [True: 0, False: 0]
  ------------------
 1740|      0|                    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
  ------------------
  |  |  180|      0|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1741|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
                                  TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
  ------------------
  |  |  335|      0|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
 1742|      0|                    break;
 1743|      0|                case PIXARLOGDATAFMT_16BIT:
  ------------------
  |  |  719|      0|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  |  Branch (1743:17): [True: 0, False: 0]
  ------------------
 1744|      0|                    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
  ------------------
  |  |  180|      0|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1745|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
                                  TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1746|      0|                    break;
 1747|      0|                case PIXARLOGDATAFMT_FLOAT:
  ------------------
  |  |  720|      0|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  |  Branch (1747:17): [True: 0, False: 0]
  ------------------
 1748|      0|                    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32);
  ------------------
  |  |  180|      0|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1749|      0|                    TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT,
  ------------------
  |  |  333|      0|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
 1750|      0|                                 SAMPLEFORMAT_IEEEFP);
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
 1751|      0|                    break;
 1752|      0|                default:
  ------------------
  |  Branch (1752:17): [True: 0, False: 0]
  ------------------
 1753|      0|                    break;
 1754|      0|            }
 1755|       |            /*
 1756|       |             * Must recalculate sizes should bits/sample change.
 1757|       |             */
 1758|      0|            tif->tif_dir.td_tilesize =
 1759|      0|                isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1);
  ------------------
  |  |  278|      0|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      0|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1760|      0|            tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 1761|      0|            result = 1; /* NB: pseudo tag */
 1762|      0|            break;
 1763|    747|        default:
  ------------------
  |  Branch (1763:9): [True: 747, False: 0]
  ------------------
 1764|    747|            result = (*sp->vsetparent)(tif, tag, ap);
 1765|    747|    }
 1766|    747|    return (result);
 1767|    747|}
tif_pixarlog.c:PixarLogMakeTables:
  630|     63|{
  631|       |
  632|       |    /*
  633|       |     *    We make several tables here to convert between various external
  634|       |     *    representations (float, 16-bit, and 8-bit) and the internal
  635|       |     *    11-bit companded representation.  The 11-bit representation has two
  636|       |     *    distinct regions.  A linear bottom end up through .018316 in steps
  637|       |     *    of about .000073, and a region of constant ratio up to about 25.
  638|       |     *    These floating point numbers are stored in the main table ToLinearF.
  639|       |     *    All other tables are derived from this one.  The tables (and the
  640|       |     *    ratios) are continuous at the internal seam.
  641|       |     */
  642|       |
  643|     63|    int nlin, lt2size;
  644|     63|    int i, j;
  645|     63|    double b, c, linstep, v;
  646|     63|    float *ToLinearF;
  647|     63|    uint16_t *ToLinear16;
  648|     63|    unsigned char *ToLinear8;
  649|     63|    uint16_t *FromLT2;
  650|     63|    uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */
  651|     63|    uint16_t *From8;
  652|       |
  653|     63|    c = log(RATIO);
  ------------------
  |  |  102|     63|#define RATIO 1.004  /* nominal ratio for log part */
  ------------------
  654|     63|    nlin = (int)(1. / c); /* nlin must be an integer */
  655|     63|    c = 1. / nlin;
  656|     63|    b = exp(-c * ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */
  ------------------
  |  |  101|     63|#define ONE 1250     /* token value of 1.0 exactly */
  ------------------
  657|     63|    linstep = b * c * exp(1.);
  658|       |
  659|     63|    LogK1 = (float)(1. / c); /* if (v >= 2)  token = k1*log(v*k2) */
  660|     63|    LogK2 = (float)(1. / b);
  661|     63|    lt2size = (int)(2. / linstep) + 1;
  662|     63|    FromLT2 = (uint16_t *)_TIFFmallocExt(
  663|     63|        tif, (tmsize_t)((size_t)lt2size * sizeof(uint16_t)));
  664|     63|    From14 = (uint16_t *)_TIFFmallocExt(tif, 16384 * sizeof(uint16_t));
  665|     63|    From8 = (uint16_t *)_TIFFmallocExt(tif, 256 * sizeof(uint16_t));
  666|     63|    ToLinearF = (float *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(float));
  ------------------
  |  |  100|     63|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  667|     63|    ToLinear16 = (uint16_t *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(uint16_t));
  ------------------
  |  |  100|     63|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  668|     63|    ToLinear8 =
  669|     63|        (unsigned char *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(unsigned char));
  ------------------
  |  |  100|     63|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  670|     63|    if (FromLT2 == NULL || From14 == NULL || From8 == NULL ||
  ------------------
  |  Branch (670:9): [True: 0, False: 63]
  |  Branch (670:28): [True: 0, False: 63]
  |  Branch (670:46): [True: 0, False: 63]
  ------------------
  671|     63|        ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL)
  ------------------
  |  Branch (671:9): [True: 0, False: 63]
  |  Branch (671:30): [True: 0, False: 63]
  |  Branch (671:52): [True: 0, False: 63]
  ------------------
  672|      0|    {
  673|      0|        if (FromLT2)
  ------------------
  |  Branch (673:13): [True: 0, False: 0]
  ------------------
  674|      0|            _TIFFfreeExt(tif, FromLT2);
  675|      0|        if (From14)
  ------------------
  |  Branch (675:13): [True: 0, False: 0]
  ------------------
  676|      0|            _TIFFfreeExt(tif, From14);
  677|      0|        if (From8)
  ------------------
  |  Branch (677:13): [True: 0, False: 0]
  ------------------
  678|      0|            _TIFFfreeExt(tif, From8);
  679|      0|        if (ToLinearF)
  ------------------
  |  Branch (679:13): [True: 0, False: 0]
  ------------------
  680|      0|            _TIFFfreeExt(tif, ToLinearF);
  681|      0|        if (ToLinear16)
  ------------------
  |  Branch (681:13): [True: 0, False: 0]
  ------------------
  682|      0|            _TIFFfreeExt(tif, ToLinear16);
  683|      0|        if (ToLinear8)
  ------------------
  |  Branch (683:13): [True: 0, False: 0]
  ------------------
  684|      0|            _TIFFfreeExt(tif, ToLinear8);
  685|      0|        sp->FromLT2 = NULL;
  686|      0|        sp->From14 = NULL;
  687|      0|        sp->From8 = NULL;
  688|      0|        sp->ToLinearF = NULL;
  689|      0|        sp->ToLinear16 = NULL;
  690|      0|        sp->ToLinear8 = NULL;
  691|      0|        return 0;
  692|      0|    }
  693|       |
  694|     63|    j = 0;
  695|       |
  696|  15.8k|    for (i = 0; i < nlin; i++)
  ------------------
  |  Branch (696:17): [True: 15.7k, False: 63]
  ------------------
  697|  15.7k|    {
  698|  15.7k|        v = i * linstep;
  699|  15.7k|        ToLinearF[j++] = (float)v;
  700|  15.7k|    }
  701|       |
  702|   113k|    for (i = nlin; i < TSIZE; i++)
  ------------------
  |  |   99|   113k|#define TSIZE 2048   /* decode table size (11-bit tokens) */
  ------------------
  |  Branch (702:20): [True: 113k, False: 63]
  ------------------
  703|   113k|        ToLinearF[j++] = (float)(b * exp(c * i));
  704|       |
  705|     63|    ToLinearF[2048] = ToLinearF[2047];
  706|       |
  707|   129k|    for (i = 0; i < TSIZEP1; i++)
  ------------------
  |  |  100|   129k|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  |  Branch (707:17): [True: 129k, False: 63]
  ------------------
  708|   129k|    {
  709|   129k|        v = (double)ToLinearF[i] * 65535.0 + 0.5;
  710|   129k|        ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16_t)v;
  ------------------
  |  Branch (710:25): [True: 50.3k, False: 78.7k]
  ------------------
  711|   129k|        v = (double)ToLinearF[i] * 255.0 + 0.5;
  712|   129k|        ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v;
  ------------------
  |  Branch (712:24): [True: 50.3k, False: 78.7k]
  ------------------
  713|   129k|    }
  714|       |
  715|     63|    j = 0;
  716|  1.71M|    for (i = 0; i < lt2size; i++)
  ------------------
  |  Branch (716:17): [True: 1.71M, False: 63]
  ------------------
  717|  1.71M|    {
  718|  1.71M|        if ((i * linstep) * (i * linstep) >
  ------------------
  |  Branch (718:13): [True: 89.6k, False: 1.63M]
  ------------------
  719|  1.71M|            (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  720|  89.6k|            j++;
  721|  1.71M|        FromLT2[i] = (uint16_t)j;
  722|  1.71M|    }
  723|       |
  724|       |    /*
  725|       |     * Since we lose info anyway on 16-bit data, we set up a 14-bit
  726|       |     * table and shift 16-bit values down two bits on input.
  727|       |     * saves a little table space.
  728|       |     */
  729|     63|    j = 0;
  730|  1.03M|    for (i = 0; i < 16384; i++)
  ------------------
  |  Branch (730:17): [True: 1.03M, False: 63]
  ------------------
  731|  1.03M|    {
  732|  1.11M|        while ((i / 16383.) * (i / 16383.) >
  ------------------
  |  Branch (732:16): [True: 78.7k, False: 1.03M]
  ------------------
  733|  1.11M|               (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  734|  78.7k|            j++;
  735|  1.03M|        From14[i] = (uint16_t)j;
  736|  1.03M|    }
  737|       |
  738|     63|    j = 0;
  739|  16.1k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (739:17): [True: 16.1k, False: 63]
  ------------------
  740|  16.1k|    {
  741|  94.8k|        while ((i / 255.) * (i / 255.) >
  ------------------
  |  Branch (741:16): [True: 78.7k, False: 16.1k]
  ------------------
  742|  94.8k|               (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  743|  78.7k|            j++;
  744|  16.1k|        From8[i] = (uint16_t)j;
  745|  16.1k|    }
  746|       |
  747|     63|    Fltsize = (float)(lt2size / 2);
  748|       |
  749|     63|    sp->ToLinearF = ToLinearF;
  750|     63|    sp->ToLinear16 = ToLinear16;
  751|     63|    sp->ToLinear8 = ToLinear8;
  752|     63|    sp->FromLT2 = FromLT2;
  753|     63|    sp->From14 = From14;
  754|     63|    sp->From8 = From8;
  755|       |
  756|     63|    return 1;
  757|     63|}

TIFFPredictorInit:
 1205|    199|{
 1206|    199|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    199|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1207|       |
 1208|    199|    assert(sp != 0);
  ------------------
  |  Branch (1208:5): [True: 0, False: 199]
  |  Branch (1208:5): [True: 199, False: 0]
  ------------------
 1209|       |
 1210|       |    /*
 1211|       |     * Merge codec-specific tag information.
 1212|       |     */
 1213|    199|    if (!_TIFFMergeFields(tif, predictFields, TIFFArrayCount(predictFields)))
  ------------------
  |  |  339|    199|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1213:9): [True: 0, False: 199]
  ------------------
 1214|      0|    {
 1215|      0|        TIFFErrorExtR(tif, "TIFFPredictorInit",
 1216|      0|                      "Merging Predictor codec-specific tags failed");
 1217|      0|        return 0;
 1218|      0|    }
 1219|       |
 1220|       |    /*
 1221|       |     * Override parent get/set field methods.
 1222|       |     */
 1223|    199|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1224|    199|    tif->tif_tagmethods.vgetfield =
 1225|    199|        PredictorVGetField; /* hook for predictor tag */
 1226|    199|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1227|    199|    tif->tif_tagmethods.vsetfield =
 1228|    199|        PredictorVSetField; /* hook for predictor tag */
 1229|    199|    sp->printdir = tif->tif_tagmethods.printdir;
 1230|    199|    tif->tif_tagmethods.printdir =
 1231|    199|        PredictorPrintDir; /* hook for predictor tag */
 1232|       |
 1233|    199|    sp->setupdecode = tif->tif_setupdecode;
 1234|    199|    tif->tif_setupdecode = PredictorSetupDecode;
 1235|    199|    sp->setupencode = tif->tif_setupencode;
 1236|    199|    tif->tif_setupencode = PredictorSetupEncode;
 1237|       |
 1238|    199|    sp->predictor = 1;      /* default value */
 1239|    199|    sp->encodepfunc = NULL; /* no predictor routine */
 1240|       |    sp->decodepfunc = NULL; /* no predictor routine */
 1241|    199|    return 1;
 1242|    199|}
TIFFPredictorCleanup:
 1245|    199|{
 1246|    199|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    199|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1247|       |
 1248|    199|    assert(sp != 0);
  ------------------
  |  Branch (1248:5): [True: 0, False: 199]
  |  Branch (1248:5): [True: 199, False: 0]
  ------------------
 1249|       |
 1250|    199|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1251|    199|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1252|    199|    tif->tif_tagmethods.printdir = sp->printdir;
 1253|    199|    tif->tif_setupdecode = sp->setupdecode;
 1254|    199|    tif->tif_setupencode = sp->setupencode;
 1255|       |
 1256|    199|    return 1;
 1257|    199|}
tif_predict.c:PredictorVGetField:
 1159|  1.72k|{
 1160|  1.72k|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|  1.72k|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1161|       |
 1162|  1.72k|    assert(sp != NULL);
  ------------------
  |  Branch (1162:5): [True: 0, False: 1.72k]
  |  Branch (1162:5): [True: 1.72k, False: 0]
  ------------------
 1163|  1.72k|    assert(sp->vgetparent != NULL);
  ------------------
  |  Branch (1163:5): [True: 0, False: 1.72k]
  |  Branch (1163:5): [True: 1.72k, False: 0]
  ------------------
 1164|       |
 1165|  1.72k|    switch (tag)
 1166|  1.72k|    {
 1167|      0|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1167:9): [True: 0, False: 1.72k]
  ------------------
 1168|      0|            *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor;
 1169|      0|            break;
 1170|  1.72k|        default:
  ------------------
  |  Branch (1170:9): [True: 1.72k, False: 0]
  ------------------
 1171|  1.72k|            return (*sp->vgetparent)(tif, tag, ap);
 1172|  1.72k|    }
 1173|      0|    return 1;
 1174|  1.72k|}
tif_predict.c:PredictorVSetField:
 1139|  2.10k|{
 1140|  2.10k|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|  2.10k|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1141|       |
 1142|  2.10k|    assert(sp != NULL);
  ------------------
  |  Branch (1142:5): [True: 0, False: 2.10k]
  |  Branch (1142:5): [True: 2.10k, False: 0]
  ------------------
 1143|  2.10k|    assert(sp->vsetparent != NULL);
  ------------------
  |  Branch (1143:5): [True: 0, False: 2.10k]
  |  Branch (1143:5): [True: 2.10k, False: 0]
  ------------------
 1144|       |
 1145|  2.10k|    switch (tag)
 1146|  2.10k|    {
 1147|     37|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|     37|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1147:9): [True: 37, False: 2.06k]
  ------------------
 1148|     37|            sp->predictor = (uint16_t)va_arg(ap, uint16_vap);
 1149|     37|            TIFFSetFieldBit(tif, FIELD_PREDICTOR);
  ------------------
  |  |  249|     37|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     37|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     37|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1150|     37|            break;
 1151|  2.06k|        default:
  ------------------
  |  Branch (1151:9): [True: 2.06k, False: 37]
  ------------------
 1152|  2.06k|            return (*sp->vsetparent)(tif, tag, ap);
 1153|  2.10k|    }
 1154|     37|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|     37|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1155|     37|    return 1;
 1156|  2.10k|}
tif_predict.c:PredictorSetupDecode:
  128|    493|{
  129|    493|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    493|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
  130|    493|    TIFFDirectory *td = &tif->tif_dir;
  131|       |
  132|       |    /* Note: when PredictorSetup() fails, the effets of setupdecode() */
  133|       |    /* will not be "canceled" so setupdecode() might be robust to */
  134|       |    /* be called several times. */
  135|    493|    if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
  ------------------
  |  Branch (135:9): [True: 186, False: 307]
  |  Branch (135:37): [True: 123, False: 184]
  ------------------
  136|    309|        return 0;
  137|       |
  138|    184|    if (sp->predictor == 2)
  ------------------
  |  Branch (138:9): [True: 32, False: 152]
  ------------------
  139|     32|    {
  140|     32|        switch (td->td_bitspersample)
  141|     32|        {
  142|     16|            case 8:
  ------------------
  |  Branch (142:13): [True: 16, False: 16]
  ------------------
  143|     16|                sp->decodepfunc = horAcc8;
  144|     16|                break;
  145|     16|            case 16:
  ------------------
  |  Branch (145:13): [True: 16, False: 16]
  ------------------
  146|     16|                sp->decodepfunc = horAcc16;
  147|     16|                break;
  148|      0|            case 32:
  ------------------
  |  Branch (148:13): [True: 0, False: 32]
  ------------------
  149|      0|                sp->decodepfunc = horAcc32;
  150|      0|                break;
  151|      0|            case 64:
  ------------------
  |  Branch (151:13): [True: 0, False: 32]
  ------------------
  152|      0|                sp->decodepfunc = horAcc64;
  153|      0|                break;
  154|      0|            default:
  ------------------
  |  Branch (154:13): [True: 0, False: 32]
  ------------------
  155|      0|                break;
  156|     32|        }
  157|       |        /*
  158|       |         * Override default decoding method with one that does the
  159|       |         * predictor stuff.
  160|       |         */
  161|     32|        if (tif->tif_decoderow != PredictorDecodeRow)
  ------------------
  |  Branch (161:13): [True: 32, False: 0]
  ------------------
  162|     32|        {
  163|     32|            sp->decoderow = tif->tif_decoderow;
  164|     32|            tif->tif_decoderow = PredictorDecodeRow;
  165|     32|            sp->decodestrip = tif->tif_decodestrip;
  166|     32|            tif->tif_decodestrip = PredictorDecodeTile;
  167|     32|            sp->decodetile = tif->tif_decodetile;
  168|     32|            tif->tif_decodetile = PredictorDecodeTile;
  169|     32|        }
  170|       |
  171|       |        /*
  172|       |         * If the data is horizontally differenced 16-bit data that
  173|       |         * requires byte-swapping, then it must be byte swapped before
  174|       |         * the accumulation step.  We do this with a special-purpose
  175|       |         * routine and override the normal post decoding logic that
  176|       |         * the library setup when the directory was read.
  177|       |         */
  178|     32|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     32|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (178:13): [True: 0, False: 32]
  ------------------
  179|      0|        {
  180|      0|            if (sp->decodepfunc == horAcc16)
  ------------------
  |  Branch (180:17): [True: 0, False: 0]
  ------------------
  181|      0|            {
  182|      0|                sp->decodepfunc = swabHorAcc16;
  183|      0|                tif->tif_postdecode = _TIFFNoPostDecode;
  184|      0|            }
  185|      0|            else if (sp->decodepfunc == horAcc32)
  ------------------
  |  Branch (185:22): [True: 0, False: 0]
  ------------------
  186|      0|            {
  187|      0|                sp->decodepfunc = swabHorAcc32;
  188|      0|                tif->tif_postdecode = _TIFFNoPostDecode;
  189|      0|            }
  190|      0|            else if (sp->decodepfunc == horAcc64)
  ------------------
  |  Branch (190:22): [True: 0, False: 0]
  ------------------
  191|      0|            {
  192|      0|                sp->decodepfunc = swabHorAcc64;
  193|      0|                tif->tif_postdecode = _TIFFNoPostDecode;
  194|      0|            }
  195|      0|        }
  196|     32|    }
  197|       |
  198|    152|    else if (sp->predictor == 3)
  ------------------
  |  Branch (198:14): [True: 0, False: 152]
  ------------------
  199|      0|    {
  200|      0|        sp->decodepfunc = fpAcc;
  201|       |        /*
  202|       |         * Override default decoding method with one that does the
  203|       |         * predictor stuff.
  204|       |         */
  205|      0|        if (tif->tif_decoderow != PredictorDecodeRow)
  ------------------
  |  Branch (205:13): [True: 0, False: 0]
  ------------------
  206|      0|        {
  207|      0|            sp->decoderow = tif->tif_decoderow;
  208|      0|            tif->tif_decoderow = PredictorDecodeRow;
  209|      0|            sp->decodestrip = tif->tif_decodestrip;
  210|      0|            tif->tif_decodestrip = PredictorDecodeTile;
  211|      0|            sp->decodetile = tif->tif_decodetile;
  212|      0|            tif->tif_decodetile = PredictorDecodeTile;
  213|      0|        }
  214|       |        /*
  215|       |         * The data should not be swapped outside of the floating
  216|       |         * point predictor, the accumulation routine should return
  217|       |         * bytes in the native order.
  218|       |         */
  219|      0|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|      0|        {
  221|      0|            tif->tif_postdecode = _TIFFNoPostDecode;
  222|      0|        }
  223|      0|    }
  224|       |
  225|    184|    return 1;
  226|    184|}
tif_predict.c:PredictorSetup:
   64|    307|{
   65|    307|    static const char module[] = "PredictorSetup";
   66|       |
   67|    307|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    307|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
   68|    307|    TIFFDirectory *td = &tif->tif_dir;
   69|       |
   70|    307|    switch (sp->predictor) /* no differencing */
   71|    307|    {
   72|    152|        case PREDICTOR_NONE:
  ------------------
  |  |  304|    152|#define PREDICTOR_NONE 1                   /* no prediction scheme used */
  ------------------
  |  Branch (72:9): [True: 152, False: 155]
  ------------------
   73|    152|            return 1;
   74|    155|        case PREDICTOR_HORIZONTAL:
  ------------------
  |  |  305|    155|#define PREDICTOR_HORIZONTAL 2             /* horizontal differencing */
  ------------------
  |  Branch (74:9): [True: 155, False: 152]
  ------------------
   75|    155|            if (td->td_bitspersample != 8 && td->td_bitspersample != 16 &&
  ------------------
  |  Branch (75:17): [True: 139, False: 16]
  |  Branch (75:46): [True: 123, False: 16]
  ------------------
   76|    123|                td->td_bitspersample != 32 && td->td_bitspersample != 64)
  ------------------
  |  Branch (76:17): [True: 123, False: 0]
  |  Branch (76:47): [True: 123, False: 0]
  ------------------
   77|    123|            {
   78|    123|                TIFFErrorExtR(tif, module,
   79|    123|                              "Horizontal differencing \"Predictor\" not "
   80|    123|                              "supported with %" PRIu16 "-bit samples",
   81|    123|                              td->td_bitspersample);
   82|    123|                return 0;
   83|    123|            }
   84|     32|            break;
   85|     32|        case PREDICTOR_FLOATINGPOINT:
  ------------------
  |  |  306|      0|#define PREDICTOR_FLOATINGPOINT 3          /* floating point predictor */
  ------------------
  |  Branch (85:9): [True: 0, False: 307]
  ------------------
   86|      0|            if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP)
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (86:17): [True: 0, False: 0]
  ------------------
   87|      0|            {
   88|      0|                TIFFErrorExtR(
   89|      0|                    tif, module,
   90|      0|                    "Floating point \"Predictor\" not supported with %" PRIu16
   91|      0|                    " data format",
   92|      0|                    td->td_sampleformat);
   93|      0|                return 0;
   94|      0|            }
   95|      0|            if (td->td_bitspersample != 16 && td->td_bitspersample != 24 &&
  ------------------
  |  Branch (95:17): [True: 0, False: 0]
  |  Branch (95:47): [True: 0, False: 0]
  ------------------
   96|      0|                td->td_bitspersample != 32 && td->td_bitspersample != 64)
  ------------------
  |  Branch (96:17): [True: 0, False: 0]
  |  Branch (96:47): [True: 0, False: 0]
  ------------------
   97|      0|            { /* Should 64 be allowed? */
   98|      0|                TIFFErrorExtR(
   99|      0|                    tif, module,
  100|      0|                    "Floating point \"Predictor\" not supported with %" PRIu16
  101|      0|                    "-bit samples",
  102|      0|                    td->td_bitspersample);
  103|      0|                return 0;
  104|      0|            }
  105|      0|            break;
  106|      0|        default:
  ------------------
  |  Branch (106:9): [True: 0, False: 307]
  ------------------
  107|      0|            TIFFErrorExtR(tif, module, "\"Predictor\" value %d not supported",
  108|      0|                          sp->predictor);
  109|      0|            return 0;
  110|    307|    }
  111|     32|    sp->stride =
  112|     32|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|     32|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (112:10): [True: 24, False: 8]
  ------------------
  113|     32|                                                    : 1);
  114|       |    /*
  115|       |     * Calculate the scanline/tile-width size in bytes.
  116|       |     */
  117|     32|    if (isTiled(tif))
  ------------------
  |  |  278|     32|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     32|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 13, False: 19]
  |  |  ------------------
  ------------------
  118|     13|        sp->rowsize = TIFFTileRowSize(tif);
  119|     19|    else
  120|     19|        sp->rowsize = TIFFScanlineSize(tif);
  121|     32|    if (sp->rowsize == 0)
  ------------------
  |  Branch (121:9): [True: 0, False: 32]
  ------------------
  122|      0|        return 0;
  123|       |
  124|     32|    return 1;
  125|     32|}
tif_predict.c:PredictorDecodeTile:
  770|     35|{
  771|     35|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|     35|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
  772|       |
  773|     35|    assert(sp != NULL);
  ------------------
  |  Branch (773:5): [True: 0, False: 35]
  |  Branch (773:5): [True: 35, False: 0]
  ------------------
  774|     35|    assert(sp->decodetile != NULL);
  ------------------
  |  Branch (774:5): [True: 0, False: 35]
  |  Branch (774:5): [True: 35, False: 0]
  ------------------
  775|       |
  776|     35|    if ((*sp->decodetile)(tif, op0, occ0, s))
  ------------------
  |  Branch (776:9): [True: 0, False: 35]
  ------------------
  777|      0|    {
  778|      0|        tmsize_t rowsize = sp->rowsize;
  779|      0|        assert(rowsize > 0);
  ------------------
  |  Branch (779:9): [True: 0, False: 0]
  |  Branch (779:9): [True: 0, False: 0]
  ------------------
  780|      0|        if ((occ0 % rowsize) != 0)
  ------------------
  |  Branch (780:13): [True: 0, False: 0]
  ------------------
  781|      0|        {
  782|      0|            TIFFErrorExtR(tif, "PredictorDecodeTile", "%s",
  783|      0|                          "occ0%rowsize != 0");
  784|      0|            return 0;
  785|      0|        }
  786|      0|        assert(sp->decodepfunc != NULL);
  ------------------
  |  Branch (786:9): [True: 0, False: 0]
  |  Branch (786:9): [True: 0, False: 0]
  ------------------
  787|      0|        while (occ0 > 0)
  ------------------
  |  Branch (787:16): [True: 0, False: 0]
  ------------------
  788|      0|        {
  789|      0|            if (!(*sp->decodepfunc)(tif, op0, rowsize))
  ------------------
  |  Branch (789:17): [True: 0, False: 0]
  ------------------
  790|      0|                return 0;
  791|      0|            occ0 -= rowsize;
  792|      0|            op0 += rowsize;
  793|      0|        }
  794|      0|        return 1;
  795|      0|    }
  796|     35|    else
  797|     35|        return 0;
  798|     35|}

TIFFReadEncodedStrip:
  572|  89.3k|{
  573|  89.3k|    static const char module[] = "TIFFReadEncodedStrip";
  574|  89.3k|    TIFFDirectory *td = &tif->tif_dir;
  575|  89.3k|    tmsize_t stripsize;
  576|  89.3k|    uint16_t plane;
  577|       |
  578|  89.3k|    stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
  579|  89.3k|    if (stripsize == ((tmsize_t)(-1)))
  ------------------
  |  Branch (579:9): [True: 0, False: 89.3k]
  ------------------
  580|      0|        return ((tmsize_t)(-1));
  581|       |
  582|       |    /* shortcut to avoid an extra memcpy() */
  583|  89.3k|    if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
  ------------------
  |  |  182|   178k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (583:9): [True: 2.49k, False: 86.8k]
  |  Branch (583:51): [True: 82, False: 2.41k]
  ------------------
  584|     82|        size >= stripsize && !isMapped(tif) &&
  ------------------
  |  |  279|  89.4k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|     82|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (584:9): [True: 82, False: 0]
  |  Branch (584:30): [True: 82, False: 0]
  ------------------
  585|     82|        ((tif->tif_flags & TIFF_NOREADRAW) == 0))
  ------------------
  |  |  138|     82|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (585:9): [True: 82, False: 0]
  ------------------
  586|     82|    {
  587|     82|        if (TIFFReadRawStrip1(tif, strip, buf, stripsize, module) != stripsize)
  ------------------
  |  Branch (587:13): [True: 0, False: 82]
  ------------------
  588|      0|            return ((tmsize_t)(-1));
  589|       |
  590|     82|        if (!isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|    164|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (590:13): [True: 3, False: 79]
  ------------------
  591|      3|            (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|      3|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (591:13): [True: 3, False: 0]
  ------------------
  592|      3|            TIFFReverseBits((uint8_t *)buf, stripsize);
  593|       |
  594|     82|        (*tif->tif_postdecode)(tif, (uint8_t *)buf, stripsize);
  595|     82|        return (stripsize);
  596|     82|    }
  597|       |
  598|  89.2k|    if ((size != (tmsize_t)(-1)) && (size < stripsize))
  ------------------
  |  Branch (598:9): [True: 726, False: 88.5k]
  |  Branch (598:37): [True: 1, False: 725]
  ------------------
  599|      1|        stripsize = size;
  600|  89.2k|    if (!TIFFFillStrip(tif, strip))
  ------------------
  |  Branch (600:9): [True: 84.8k, False: 4.37k]
  ------------------
  601|  84.8k|    {
  602|       |        /* The output buf may be NULL, in particular if TIFFTAG_FAXFILLFUNC
  603|       |           is being used. Thus, memset must be conditional on buf not NULL. */
  604|  84.8k|        if (buf)
  ------------------
  |  Branch (604:13): [True: 84.8k, False: 0]
  ------------------
  605|  84.8k|            memset(buf, 0, (size_t)stripsize);
  606|  84.8k|        return ((tmsize_t)(-1));
  607|  84.8k|    }
  608|  4.37k|    if ((*tif->tif_decodestrip)(tif, (uint8_t *)buf, stripsize, plane) <= 0)
  ------------------
  |  Branch (608:9): [True: 1.88k, False: 2.49k]
  ------------------
  609|  1.88k|        return ((tmsize_t)(-1));
  610|  2.49k|    (*tif->tif_postdecode)(tif, (uint8_t *)buf, stripsize);
  611|  2.49k|    return (stripsize);
  612|  4.37k|}
_TIFFReadEncodedStripAndAllocBuffer:
  624|  1.89k|{
  625|  1.89k|    tmsize_t this_stripsize;
  626|  1.89k|    uint16_t plane;
  627|       |
  628|  1.89k|    if (*buf != NULL)
  ------------------
  |  Branch (628:9): [True: 634, False: 1.25k]
  ------------------
  629|    634|    {
  630|    634|        return TIFFReadEncodedStrip(tif, strip, *buf, size_to_read);
  631|    634|    }
  632|       |
  633|  1.25k|    this_stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
  634|  1.25k|    if (this_stripsize == ((tmsize_t)(-1)))
  ------------------
  |  Branch (634:9): [True: 0, False: 1.25k]
  ------------------
  635|      0|        return ((tmsize_t)(-1));
  636|       |
  637|  1.25k|    if ((size_to_read != (tmsize_t)(-1)) && (size_to_read < this_stripsize))
  ------------------
  |  Branch (637:9): [True: 1.25k, False: 0]
  |  Branch (637:45): [True: 3, False: 1.25k]
  ------------------
  638|      3|        this_stripsize = size_to_read;
  639|  1.25k|    if (!TIFFFillStrip(tif, strip))
  ------------------
  |  Branch (639:9): [True: 951, False: 307]
  ------------------
  640|    951|        return ((tmsize_t)(-1));
  641|       |
  642|       |    /* Sanity checks to avoid excessive memory allocation */
  643|       |    /* Max compression ratio experimentally determined. Might be fragile...
  644|       |     * Only apply this heuristics to situations where the memory allocation
  645|       |     * would be big, to avoid breaking nominal use cases.
  646|       |     */
  647|    307|    if (bufsizetoalloc > 100 * 1024 * 1024)
  ------------------
  |  Branch (647:9): [True: 12, False: 295]
  ------------------
  648|     12|    {
  649|     12|        const uint64_t maxCompressionRatio = TIFFGetMaxCompressionRatio(tif);
  650|     12|        if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (650:13): [True: 6, False: 6]
  ------------------
  651|      6|            (uint64_t)tif->tif_rawdatasize <
  ------------------
  |  Branch (651:13): [True: 0, False: 6]
  ------------------
  652|      6|                (uint64_t)this_stripsize / maxCompressionRatio)
  653|      0|        {
  654|      0|            TIFFErrorExtR(tif, TIFFFileName(tif),
  655|      0|                          "Likely invalid strip byte count for strip %u. "
  656|      0|                          "Uncompressed strip size is %" PRIu64 ", "
  657|      0|                          "compressed one is %" PRIu64,
  658|      0|                          strip, (uint64_t)this_stripsize,
  659|      0|                          (uint64_t)tif->tif_rawdatasize);
  660|      0|            return ((tmsize_t)(-1));
  661|      0|        }
  662|     12|    }
  663|       |
  664|    307|    *buf = _TIFFcallocExt(tif, 1, bufsizetoalloc);
  665|    307|    if (*buf == NULL)
  ------------------
  |  Branch (665:9): [True: 0, False: 307]
  ------------------
  666|      0|    {
  667|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
  668|      0|        return ((tmsize_t)(-1));
  669|      0|    }
  670|       |
  671|    307|    if ((*tif->tif_decodestrip)(tif, (uint8_t *)*buf, this_stripsize, plane) <=
  ------------------
  |  Branch (671:9): [True: 207, False: 100]
  ------------------
  672|    307|        0)
  673|    207|        return ((tmsize_t)(-1));
  674|    100|    (*tif->tif_postdecode)(tif, (uint8_t *)*buf, this_stripsize);
  675|    100|    return (this_stripsize);
  676|    307|}
TIFFFillStrip:
  818|  90.5k|{
  819|  90.5k|    static const char module[] = "TIFFFillStrip";
  820|  90.5k|    TIFFDirectory *td = &tif->tif_dir;
  821|       |
  822|  90.5k|    if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
  ------------------
  |  |  138|  90.5k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (822:9): [True: 73.7k, False: 16.7k]
  ------------------
  823|  73.7k|    {
  824|  73.7k|        uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
  825|  73.7k|        if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
  ------------------
  |  |   49|  42.8k|#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
  ------------------
  |  Branch (825:13): [True: 30.9k, False: 42.8k]
  |  Branch (825:31): [True: 225, False: 42.6k]
  ------------------
  826|  31.1k|        {
  827|  31.1k|            TIFFErrorExtR(tif, module,
  828|  31.1k|                          "Invalid strip byte count %" PRIu64
  829|  31.1k|                          ", strip %" PRIu32,
  830|  31.1k|                          bytecount, strip);
  831|  31.1k|            return (0);
  832|  31.1k|        }
  833|       |
  834|       |        /* To avoid excessive memory allocations: */
  835|  42.6k|        const tmsize_t stripsize = TIFFStripSize(tif);
  836|  42.6k|        if (stripsize > 0)
  ------------------
  |  Branch (836:13): [True: 42.6k, False: 0]
  ------------------
  837|  42.6k|        {
  838|  42.6k|            if (bytecount > 1024 * 1024 &&
  ------------------
  |  Branch (838:17): [True: 376, False: 42.2k]
  ------------------
  839|    376|                (bytecount - 4096) / 10 > (uint64_t)stripsize)
  ------------------
  |  Branch (839:17): [True: 375, False: 1]
  ------------------
  840|    375|            {
  841|       |                /* Byte count should normally not be larger than a number of */
  842|       |                /* times the uncompressed size plus some margin */
  843|       |                /* 10 and 4096 are just values that could be adjusted. */
  844|       |                /* Hopefully they are safe enough for all codecs */
  845|       |                /* What happens next will depend on whether only the bytecount
  846|       |                 */
  847|       |                /* was corrupted to a large value but the strip/tile data is */
  848|       |                /* fine. In that situation most codecs should work fine and */
  849|       |                /* only used part of the tile/strip data. If the strip/tile */
  850|       |                /* data is corrupted too, then codecs will later error out. */
  851|    375|                uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
  852|    375|                TIFFWarningExtR(tif, module,
  853|    375|                                "Too large strip byte count %" PRIu64
  854|    375|                                ", strip %" PRIu32 ". Limiting to %" PRIu64,
  855|    375|                                bytecount, strip, newbytecount);
  856|    375|                bytecount = newbytecount;
  857|    375|            }
  858|  42.2k|            else if (stripsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (858:22): [True: 17, False: 42.2k]
  ------------------
  859|     17|            {
  860|       |                /* Max compression ratio experimentally determined. Might be
  861|       |                 * fragile... Only apply this heuristics to situations where the
  862|       |                 * memory allocation would be big, to avoid breaking nominal use
  863|       |                 * cases.
  864|       |                 */
  865|     17|                const uint64_t maxCompressionRatio =
  866|     17|                    TIFFGetMaxCompressionRatio(tif);
  867|     17|                if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (867:21): [True: 8, False: 9]
  ------------------
  868|      8|                    bytecount < (uint64_t)stripsize / maxCompressionRatio)
  ------------------
  |  Branch (868:21): [True: 1, False: 7]
  ------------------
  869|      1|                {
  870|      1|                    TIFFErrorExtR(
  871|      1|                        tif, module,
  872|      1|                        "Likely invalid strip byte count for strip %u. "
  873|      1|                        "Uncompressed strip size is %" PRIu64 ", "
  874|      1|                        "compressed one is %" PRIu64,
  875|      1|                        strip, (uint64_t)stripsize, bytecount);
  876|      1|                    return 0;
  877|      1|                }
  878|     17|            }
  879|  42.6k|        }
  880|       |
  881|  42.6k|        if (isMapped(tif))
  ------------------
  |  |  279|  42.6k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  42.6k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 42.6k]
  |  |  ------------------
  ------------------
  882|      0|        {
  883|       |            /*
  884|       |             * We must check for overflow, potentially causing
  885|       |             * an OOB read. Instead of simple
  886|       |             *
  887|       |             *  TIFFGetStrileOffset(tif, strip)+bytecount > tif->tif_size
  888|       |             *
  889|       |             * comparison (which can overflow) we do the following
  890|       |             * two comparisons:
  891|       |             */
  892|      0|            if (bytecount > (uint64_t)tif->tif_size ||
  ------------------
  |  Branch (892:17): [True: 0, False: 0]
  ------------------
  893|      0|                TIFFGetStrileOffset(tif, strip) >
  ------------------
  |  Branch (893:17): [True: 0, False: 0]
  ------------------
  894|      0|                    (uint64_t)tif->tif_size - bytecount)
  895|      0|            {
  896|       |                /*
  897|       |                 * This error message might seem strange, but
  898|       |                 * it's what would happen if a read were done
  899|       |                 * instead.
  900|       |                 */
  901|      0|                TIFFErrorExtR(
  902|      0|                    tif, module,
  903|       |
  904|      0|                    "Read error on strip %" PRIu32 "; "
  905|      0|                    "got %" PRIu64 " bytes, expected %" PRIu64,
  906|      0|                    strip,
  907|      0|                    NoSanitizeSubUInt64((uint64_t)tif->tif_size,
  908|      0|                                        TIFFGetStrileOffset(tif, strip)),
  909|      0|                    bytecount);
  910|      0|                tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|      0|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
  911|      0|                return (0);
  912|      0|            }
  913|      0|        }
  914|       |
  915|  42.6k|        if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  279|  85.2k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  42.6k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 42.6k]
  |  |  ------------------
  ------------------
                      if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  280|      0|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  |  |  ------------------
  |  |  |  Branch (280:29): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  916|      0|                              (tif->tif_flags & TIFF_NOBITREV)))
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (916:31): [True: 0, False: 0]
  ------------------
  917|      0|        {
  918|       |            /*
  919|       |             * The image is mapped into memory and we either don't
  920|       |             * need to flip bits or the compression routine is
  921|       |             * going to handle this operation itself.  In this
  922|       |             * case, avoid copying the raw data and instead just
  923|       |             * reference the data from the memory mapped file
  924|       |             * image.  This assumes that the decompression
  925|       |             * routines do not modify the contents of the raw data
  926|       |             * buffer (if they try to, the application will get a
  927|       |             * fault since the file is mapped read-only).
  928|       |             */
  929|      0|            if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
  ------------------
  |  |  128|      0|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (929:17): [True: 0, False: 0]
  |  Branch (929:53): [True: 0, False: 0]
  ------------------
  930|      0|            {
  931|      0|                _TIFFfreeExt(tif, tif->tif_rawdata);
  932|      0|                tif->tif_rawdata = NULL;
  933|      0|                tif->tif_rawdatasize = 0;
  934|      0|            }
  935|      0|            tif->tif_flags &= ~TIFF_MYBUFFER;
  ------------------
  |  |  128|      0|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  936|      0|            tif->tif_rawdatasize = (tmsize_t)bytecount;
  937|      0|            tif->tif_rawdata =
  938|      0|                tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, strip);
  939|      0|            tif->tif_rawdataoff = 0;
  940|      0|            tif->tif_rawdataloaded = (tmsize_t)bytecount;
  941|       |
  942|       |            /*
  943|       |             * When we have tif_rawdata reference directly into the memory
  944|       |             * mapped file we need to be pretty careful about how we use the
  945|       |             * rawdata.  It is not a general purpose working buffer as it
  946|       |             * normally otherwise is.  So we keep track of this fact to avoid
  947|       |             * using it improperly.
  948|       |             */
  949|      0|            tif->tif_flags |= TIFF_BUFFERMMAP;
  ------------------
  |  |  145|      0|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  950|      0|        }
  951|  42.6k|        else
  952|  42.6k|        {
  953|       |            /*
  954|       |             * Expand raw data buffer, if needed, to hold data
  955|       |             * strip coming from file (perhaps should set upper
  956|       |             * bound on the size of a buffer we'll use?).
  957|       |             */
  958|  42.6k|            tmsize_t bytecountm;
  959|  42.6k|            bytecountm = (tmsize_t)bytecount;
  960|  42.6k|            if ((uint64_t)bytecountm != bytecount)
  ------------------
  |  Branch (960:17): [True: 0, False: 42.6k]
  ------------------
  961|      0|            {
  962|      0|                TIFFErrorExtR(tif, module, "Integer overflow");
  963|      0|                return (0);
  964|      0|            }
  965|  42.6k|            if (bytecountm > tif->tif_rawdatasize)
  ------------------
  |  Branch (965:17): [True: 774, False: 41.8k]
  ------------------
  966|    774|            {
  967|    774|                tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|    774|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
  968|    774|                if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
  ------------------
  |  |  128|    774|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (968:21): [True: 0, False: 774]
  ------------------
  969|      0|                {
  970|      0|                    TIFFErrorExtR(
  971|      0|                        tif, module,
  972|      0|                        "Data buffer too small to hold strip %" PRIu32, strip);
  973|      0|                    return (0);
  974|      0|                }
  975|    774|            }
  976|  42.6k|            if (tif->tif_flags & TIFF_BUFFERMMAP)
  ------------------
  |  |  145|  42.6k|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  |  Branch (976:17): [True: 0, False: 42.6k]
  ------------------
  977|      0|            {
  978|      0|                tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|      0|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
  979|      0|                tif->tif_rawdata = NULL;
  980|      0|                tif->tif_rawdatasize = 0;
  981|      0|                tif->tif_flags &= ~TIFF_BUFFERMMAP;
  ------------------
  |  |  145|      0|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  982|      0|            }
  983|       |
  984|  42.6k|            if (isMapped(tif))
  ------------------
  |  |  279|  42.6k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  42.6k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 42.6k]
  |  |  ------------------
  ------------------
  985|      0|            {
  986|      0|                if (bytecountm > tif->tif_rawdatasize &&
  ------------------
  |  Branch (986:21): [True: 0, False: 0]
  ------------------
  987|      0|                    !TIFFReadBufferSetup(tif, 0, bytecountm))
  ------------------
  |  Branch (987:21): [True: 0, False: 0]
  ------------------
  988|      0|                {
  989|      0|                    return (0);
  990|      0|                }
  991|      0|                if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, bytecountm,
  ------------------
  |  Branch (991:21): [True: 0, False: 0]
  ------------------
  992|      0|                                      module) != bytecountm)
  993|      0|                {
  994|      0|                    return (0);
  995|      0|                }
  996|      0|            }
  997|  42.6k|            else
  998|  42.6k|            {
  999|  42.6k|                if (TIFFReadRawStripOrTile2(tif, strip, 1, bytecountm,
  ------------------
  |  Branch (999:21): [True: 1.16k, False: 41.4k]
  ------------------
 1000|  42.6k|                                            module) != bytecountm)
 1001|  1.16k|                {
 1002|  1.16k|                    return (0);
 1003|  1.16k|                }
 1004|  42.6k|            }
 1005|       |
 1006|  41.4k|            tif->tif_rawdataoff = 0;
 1007|  41.4k|            tif->tif_rawdataloaded = bytecountm;
 1008|       |
 1009|  41.4k|            if (!isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|  82.9k|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (1009:17): [True: 30, False: 41.4k]
  ------------------
 1010|     30|                (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|     30|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (1010:17): [True: 30, False: 0]
  ------------------
 1011|     30|                TIFFReverseBits(tif->tif_rawdata, bytecountm);
 1012|  41.4k|        }
 1013|  42.6k|    }
 1014|  58.1k|    return (TIFFStartStrip(tif, strip));
 1015|  90.5k|}
TIFFReadTile:
 1028|  55.4k|{
 1029|  55.4k|    if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
  ------------------
  |  Branch (1029:9): [True: 0, False: 55.4k]
  |  Branch (1029:35): [True: 85, False: 55.3k]
  ------------------
 1030|     85|        return ((tmsize_t)(-1));
 1031|  55.3k|    return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf,
 1032|  55.3k|                                (tmsize_t)(-1)));
 1033|  55.4k|}
TIFFReadEncodedTile:
 1040|   309k|{
 1041|   309k|    static const char module[] = "TIFFReadEncodedTile";
 1042|   309k|    TIFFDirectory *td = &tif->tif_dir;
 1043|   309k|    tmsize_t tilesize = tif->tif_dir.td_tilesize;
 1044|       |
 1045|   309k|    if (!TIFFCheckRead(tif, 1))
  ------------------
  |  Branch (1045:9): [True: 0, False: 309k]
  ------------------
 1046|      0|        return ((tmsize_t)(-1));
 1047|   309k|    if (tile >= td->td_nstrips)
  ------------------
  |  Branch (1047:9): [True: 0, False: 309k]
  ------------------
 1048|      0|    {
 1049|      0|        TIFFErrorExtR(tif, module,
 1050|      0|                      "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
 1051|      0|                      td->td_nstrips);
 1052|      0|        return ((tmsize_t)(-1));
 1053|      0|    }
 1054|       |
 1055|       |    /* shortcut to avoid an extra memcpy() */
 1056|   309k|    if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
  ------------------
  |  |  182|   619k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (1056:9): [True: 29.6k, False: 279k]
  |  Branch (1056:51): [True: 0, False: 29.6k]
  ------------------
 1057|      0|        size >= tilesize && !isMapped(tif) &&
  ------------------
  |  |  279|   309k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|      0|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (1057:9): [True: 0, False: 0]
  |  Branch (1057:29): [True: 0, False: 0]
  ------------------
 1058|      0|        ((tif->tif_flags & TIFF_NOREADRAW) == 0))
  ------------------
  |  |  138|      0|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1058:9): [True: 0, False: 0]
  ------------------
 1059|      0|    {
 1060|      0|        if (TIFFReadRawTile1(tif, tile, buf, tilesize, module) != tilesize)
  ------------------
  |  Branch (1060:13): [True: 0, False: 0]
  ------------------
 1061|      0|            return ((tmsize_t)(-1));
 1062|       |
 1063|      0|        if (!isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|      0|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (1063:13): [True: 0, False: 0]
  ------------------
 1064|      0|            (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (1064:13): [True: 0, False: 0]
  ------------------
 1065|      0|            TIFFReverseBits((uint8_t *)buf, tilesize);
 1066|       |
 1067|      0|        (*tif->tif_postdecode)(tif, (uint8_t *)buf, tilesize);
 1068|      0|        return (tilesize);
 1069|      0|    }
 1070|       |
 1071|   309k|    if (size == (tmsize_t)(-1))
  ------------------
  |  Branch (1071:9): [True: 309k, False: 0]
  ------------------
 1072|   309k|        size = tilesize;
 1073|      0|    else if (size > tilesize)
  ------------------
  |  Branch (1073:14): [True: 0, False: 0]
  ------------------
 1074|      0|        size = tilesize;
 1075|   309k|    if (!TIFFFillTile(tif, tile))
  ------------------
  |  Branch (1075:9): [True: 286k, False: 23.0k]
  ------------------
 1076|   286k|    {
 1077|       |        /* See TIFFReadEncodedStrip comment regarding TIFFTAG_FAXFILLFUNC. */
 1078|   286k|        if (buf)
  ------------------
  |  Branch (1078:13): [True: 286k, False: 0]
  ------------------
 1079|   286k|            memset(buf, 0, (size_t)size);
 1080|   286k|        return ((tmsize_t)(-1));
 1081|   286k|    }
 1082|  23.0k|    else if ((*tif->tif_decodetile)(tif, (uint8_t *)buf, size,
  ------------------
  |  Branch (1082:14): [True: 22.8k, False: 249]
  ------------------
 1083|  23.0k|                                    (uint16_t)(tile / td->td_stripsperimage)))
 1084|  22.8k|    {
 1085|  22.8k|        (*tif->tif_postdecode)(tif, (uint8_t *)buf, size);
 1086|  22.8k|        return (size);
 1087|  22.8k|    }
 1088|    249|    else
 1089|    249|        return ((tmsize_t)(-1));
 1090|   309k|}
_TIFFReadTileAndAllocBuffer:
 1101|  5.82k|{
 1102|  5.82k|    if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
  ------------------
  |  Branch (1102:9): [True: 0, False: 5.82k]
  |  Branch (1102:35): [True: 0, False: 5.82k]
  ------------------
 1103|      0|        return ((tmsize_t)(-1));
 1104|  5.82k|    return (_TIFFReadEncodedTileAndAllocBuffer(
 1105|  5.82k|        tif, TIFFComputeTile(tif, x, y, z, s), buf, bufsizetoalloc,
 1106|  5.82k|        (tmsize_t)(-1)));
 1107|  5.82k|}
_TIFFReadEncodedTileAndAllocBuffer:
 1118|  5.82k|{
 1119|  5.82k|    static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer";
 1120|  5.82k|    TIFFDirectory *td = &tif->tif_dir;
 1121|  5.82k|    tmsize_t tilesize = tif->tif_dir.td_tilesize;
 1122|       |
 1123|  5.82k|    if (*buf != NULL)
  ------------------
  |  Branch (1123:9): [True: 5.49k, False: 328]
  ------------------
 1124|  5.49k|    {
 1125|  5.49k|        return TIFFReadEncodedTile(tif, tile, *buf, size_to_read);
 1126|  5.49k|    }
 1127|       |
 1128|    328|    if (!TIFFCheckRead(tif, 1))
  ------------------
  |  Branch (1128:9): [True: 0, False: 328]
  ------------------
 1129|      0|        return ((tmsize_t)(-1));
 1130|    328|    if (tile >= td->td_nstrips)
  ------------------
  |  Branch (1130:9): [True: 0, False: 328]
  ------------------
 1131|      0|    {
 1132|      0|        TIFFErrorExtR(tif, module,
 1133|      0|                      "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
 1134|      0|                      td->td_nstrips);
 1135|      0|        return ((tmsize_t)(-1));
 1136|      0|    }
 1137|       |
 1138|    328|    if (!TIFFFillTile(tif, tile))
  ------------------
  |  Branch (1138:9): [True: 178, False: 150]
  ------------------
 1139|    178|        return ((tmsize_t)(-1));
 1140|       |
 1141|       |    /* Sanity checks to avoid excessive memory allocation */
 1142|       |    /* Cf https://gitlab.com/libtiff/libtiff/-/issues/479 */
 1143|    150|    if (td->td_compression == COMPRESSION_NONE)
  ------------------
  |  |  182|    150|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (1143:9): [True: 13, False: 137]
  ------------------
 1144|     13|    {
 1145|     13|        if (tif->tif_rawdatasize != tilesize)
  ------------------
  |  Branch (1145:13): [True: 8, False: 5]
  ------------------
 1146|      8|        {
 1147|      8|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1148|      8|                          "Invalid tile byte count for tile %u. "
 1149|      8|                          "Expected %" PRIu64 ", got %" PRIu64,
 1150|      8|                          tile, (uint64_t)tilesize,
 1151|      8|                          (uint64_t)tif->tif_rawdatasize);
 1152|      8|            return ((tmsize_t)(-1));
 1153|      8|        }
 1154|     13|    }
 1155|    137|    else
 1156|    137|    {
 1157|       |        /* Max compression ratio experimentally determined. Might be fragile...
 1158|       |         * Only apply this heuristics to situations where the memory allocation
 1159|       |         * would be big, to avoid breaking nominal use cases.
 1160|       |         */
 1161|    137|        if (bufsizetoalloc > 100 * 1024 * 1024)
  ------------------
  |  Branch (1161:13): [True: 6, False: 131]
  ------------------
 1162|      6|        {
 1163|      6|            const uint64_t maxCompressionRatio =
 1164|      6|                TIFFGetMaxCompressionRatio(tif);
 1165|      6|            if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (1165:17): [True: 5, False: 1]
  ------------------
 1166|      5|                (uint64_t)tif->tif_rawdatasize <
  ------------------
  |  Branch (1166:17): [True: 5, False: 0]
  ------------------
 1167|      5|                    (uint64_t)tilesize / maxCompressionRatio)
 1168|      5|            {
 1169|      5|                TIFFErrorExtR(tif, TIFFFileName(tif),
 1170|      5|                              "Likely invalid tile byte count for tile %u. "
 1171|      5|                              "Uncompressed tile size is %" PRIu64 ", "
 1172|      5|                              "compressed one is %" PRIu64,
 1173|      5|                              tile, (uint64_t)tilesize,
 1174|      5|                              (uint64_t)tif->tif_rawdatasize);
 1175|      5|                return ((tmsize_t)(-1));
 1176|      5|            }
 1177|      6|        }
 1178|    137|    }
 1179|       |
 1180|    137|    *buf = _TIFFmallocExt(tif, bufsizetoalloc);
 1181|    137|    if (*buf == NULL)
  ------------------
  |  Branch (1181:9): [True: 1, False: 136]
  ------------------
 1182|      1|    {
 1183|      1|        TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
 1184|      1|        return ((tmsize_t)(-1));
 1185|      1|    }
 1186|    136|    _TIFFmemset(*buf, 0, bufsizetoalloc);
 1187|       |
 1188|    136|    if (size_to_read == (tmsize_t)(-1))
  ------------------
  |  Branch (1188:9): [True: 136, False: 0]
  ------------------
 1189|    136|        size_to_read = tilesize;
 1190|      0|    else if (size_to_read > tilesize)
  ------------------
  |  Branch (1190:14): [True: 0, False: 0]
  ------------------
 1191|      0|        size_to_read = tilesize;
 1192|    136|    if ((*tif->tif_decodetile)(tif, (uint8_t *)*buf, size_to_read,
  ------------------
  |  Branch (1192:9): [True: 101, False: 35]
  ------------------
 1193|    136|                               (uint16_t)(tile / td->td_stripsperimage)))
 1194|    101|    {
 1195|    101|        (*tif->tif_postdecode)(tif, (uint8_t *)*buf, size_to_read);
 1196|    101|        return (size_to_read);
 1197|    101|    }
 1198|     35|    else
 1199|     35|        return ((tmsize_t)(-1));
 1200|    136|}
TIFFFillTile:
 1300|   309k|{
 1301|   309k|    static const char module[] = "TIFFFillTile";
 1302|   309k|    TIFFDirectory *td = &tif->tif_dir;
 1303|       |
 1304|   309k|    if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
  ------------------
  |  |  138|   309k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1304:9): [True: 118k, False: 191k]
  ------------------
 1305|   118k|    {
 1306|   118k|        uint64_t bytecount = TIFFGetStrileByteCount(tif, tile);
 1307|   118k|        if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
  ------------------
  |  |   49|  9.58k|#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
  ------------------
  |  Branch (1307:13): [True: 108k, False: 9.58k]
  |  Branch (1307:31): [True: 4, False: 9.58k]
  ------------------
 1308|   108k|        {
 1309|   108k|            TIFFErrorExtR(tif, module,
 1310|   108k|                          "%" PRIu64 ": Invalid tile byte count, tile %" PRIu32,
 1311|   108k|                          bytecount, tile);
 1312|   108k|            return (0);
 1313|   108k|        }
 1314|       |
 1315|       |        /* To avoid excessive memory allocations: */
 1316|  9.58k|        const tmsize_t tilesize = TIFFTileSize(tif);
 1317|  9.58k|        if (tilesize > 0)
  ------------------
  |  Branch (1317:13): [True: 9.58k, False: 0]
  ------------------
 1318|  9.58k|        {
 1319|  9.58k|            if (bytecount > 1024 * 1024 &&
  ------------------
  |  Branch (1319:17): [True: 6, False: 9.57k]
  ------------------
 1320|      6|                (bytecount - 4096) / 10 > (uint64_t)tilesize)
  ------------------
  |  Branch (1320:17): [True: 5, False: 1]
  ------------------
 1321|      5|            {
 1322|       |                /* Byte count should normally not be larger than a number of */
 1323|       |                /* times the uncompressed size plus some margin */
 1324|       |                /* 10 and 4096 are just values that could be adjusted. */
 1325|       |                /* Hopefully they are safe enough for all codecs */
 1326|       |                /* What happens next will depend on whether only the bytecount
 1327|       |                 */
 1328|       |                /* was corrupted to a large value but the strip/tile data is */
 1329|       |                /* fine. In that situation most codecs should work fine and */
 1330|       |                /* only used part of the tile/strip data. If the strip/tile */
 1331|       |                /* data is corrupted too, then codecs will later error out. */
 1332|      5|                uint64_t newbytecount = (uint64_t)tilesize * 10 + 4096;
 1333|      5|                TIFFWarningExtR(tif, module,
 1334|      5|                                "Too large tile byte count %" PRIu64
 1335|      5|                                ", tile %" PRIu32 ". Limiting to %" PRIu64,
 1336|      5|                                bytecount, tile, newbytecount);
 1337|      5|                bytecount = newbytecount;
 1338|      5|            }
 1339|  9.57k|            else if (tilesize > 100 * 1024 * 1024)
  ------------------
  |  Branch (1339:22): [True: 2, False: 9.57k]
  ------------------
 1340|      2|            {
 1341|       |                /* Max compression ratio experimentally determined. Might be
 1342|       |                 * fragile... Only apply this heuristics to situations where the
 1343|       |                 * memory allocation would be big, to avoid breaking nominal use
 1344|       |                 * cases.
 1345|       |                 */
 1346|      2|                const uint64_t maxCompressionRatio =
 1347|      2|                    TIFFGetMaxCompressionRatio(tif);
 1348|      2|                if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (1348:21): [True: 0, False: 2]
  ------------------
 1349|      0|                    bytecount < (uint64_t)tilesize / maxCompressionRatio)
  ------------------
  |  Branch (1349:21): [True: 0, False: 0]
  ------------------
 1350|      0|                {
 1351|      0|                    TIFFErrorExtR(tif, module,
 1352|      0|                                  "Likely invalid tile byte count for tile %u. "
 1353|      0|                                  "Uncompressed tile size is %" PRIu64 ", "
 1354|      0|                                  "compressed one is %" PRIu64,
 1355|      0|                                  tile, (uint64_t)tilesize, bytecount);
 1356|      0|                    return 0;
 1357|      0|                }
 1358|      2|            }
 1359|  9.58k|        }
 1360|       |
 1361|  9.58k|        if (isMapped(tif))
  ------------------
  |  |  279|  9.58k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  9.58k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 9.58k]
  |  |  ------------------
  ------------------
 1362|      0|        {
 1363|       |            /*
 1364|       |             * We must check for overflow, potentially causing
 1365|       |             * an OOB read. Instead of simple
 1366|       |             *
 1367|       |             *  TIFFGetStrileOffset(tif, tile)+bytecount > tif->tif_size
 1368|       |             *
 1369|       |             * comparison (which can overflow) we do the following
 1370|       |             * two comparisons:
 1371|       |             */
 1372|      0|            if (bytecount > (uint64_t)tif->tif_size ||
  ------------------
  |  Branch (1372:17): [True: 0, False: 0]
  ------------------
 1373|      0|                TIFFGetStrileOffset(tif, tile) >
  ------------------
  |  Branch (1373:17): [True: 0, False: 0]
  ------------------
 1374|      0|                    (uint64_t)tif->tif_size - bytecount)
 1375|      0|            {
 1376|      0|                tif->tif_dir.td_curtile = NOTILE;
  ------------------
  |  |  116|      0|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1377|      0|                return (0);
 1378|      0|            }
 1379|      0|        }
 1380|       |
 1381|  9.58k|        if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  279|  19.1k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  9.58k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 9.58k]
  |  |  ------------------
  ------------------
                      if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  280|      0|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  |  |  ------------------
  |  |  |  Branch (280:29): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1382|      0|                              (tif->tif_flags & TIFF_NOBITREV)))
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (1382:31): [True: 0, False: 0]
  ------------------
 1383|      0|        {
 1384|       |            /*
 1385|       |             * The image is mapped into memory and we either don't
 1386|       |             * need to flip bits or the compression routine is
 1387|       |             * going to handle this operation itself.  In this
 1388|       |             * case, avoid copying the raw data and instead just
 1389|       |             * reference the data from the memory mapped file
 1390|       |             * image.  This assumes that the decompression
 1391|       |             * routines do not modify the contents of the raw data
 1392|       |             * buffer (if they try to, the application will get a
 1393|       |             * fault since the file is mapped read-only).
 1394|       |             */
 1395|      0|            if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
  ------------------
  |  |  128|      0|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (1395:17): [True: 0, False: 0]
  |  Branch (1395:53): [True: 0, False: 0]
  ------------------
 1396|      0|            {
 1397|      0|                _TIFFfreeExt(tif, tif->tif_rawdata);
 1398|      0|                tif->tif_rawdata = NULL;
 1399|      0|                tif->tif_rawdatasize = 0;
 1400|      0|            }
 1401|      0|            tif->tif_flags &= ~TIFF_MYBUFFER;
  ------------------
  |  |  128|      0|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
 1402|       |
 1403|      0|            tif->tif_rawdatasize = (tmsize_t)bytecount;
 1404|      0|            tif->tif_rawdata =
 1405|      0|                tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, tile);
 1406|      0|            tif->tif_rawdataoff = 0;
 1407|      0|            tif->tif_rawdataloaded = (tmsize_t)bytecount;
 1408|      0|            tif->tif_flags |= TIFF_BUFFERMMAP;
  ------------------
  |  |  145|      0|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
 1409|      0|        }
 1410|  9.58k|        else
 1411|  9.58k|        {
 1412|       |            /*
 1413|       |             * Expand raw data buffer, if needed, to hold data
 1414|       |             * tile coming from file (perhaps should set upper
 1415|       |             * bound on the size of a buffer we'll use?).
 1416|       |             */
 1417|  9.58k|            tmsize_t bytecountm;
 1418|  9.58k|            bytecountm = (tmsize_t)bytecount;
 1419|  9.58k|            if ((uint64_t)bytecountm != bytecount)
  ------------------
  |  Branch (1419:17): [True: 0, False: 9.58k]
  ------------------
 1420|      0|            {
 1421|      0|                TIFFErrorExtR(tif, module, "Integer overflow");
 1422|      0|                return (0);
 1423|      0|            }
 1424|  9.58k|            if (bytecountm > tif->tif_rawdatasize)
  ------------------
  |  Branch (1424:17): [True: 1.26k, False: 8.31k]
  ------------------
 1425|  1.26k|            {
 1426|  1.26k|                tif->tif_dir.td_curtile = NOTILE;
  ------------------
  |  |  116|  1.26k|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1427|  1.26k|                if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
  ------------------
  |  |  128|  1.26k|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (1427:21): [True: 0, False: 1.26k]
  ------------------
 1428|      0|                {
 1429|      0|                    TIFFErrorExtR(tif, module,
 1430|      0|                                  "Data buffer too small to hold tile %" PRIu32,
 1431|      0|                                  tile);
 1432|      0|                    return (0);
 1433|      0|                }
 1434|  1.26k|            }
 1435|  9.58k|            if (tif->tif_flags & TIFF_BUFFERMMAP)
  ------------------
  |  |  145|  9.58k|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  |  Branch (1435:17): [True: 0, False: 9.58k]
  ------------------
 1436|      0|            {
 1437|      0|                tif->tif_dir.td_curtile = NOTILE;
  ------------------
  |  |  116|      0|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1438|      0|                tif->tif_rawdata = NULL;
 1439|      0|                tif->tif_rawdatasize = 0;
 1440|      0|                tif->tif_flags &= ~TIFF_BUFFERMMAP;
  ------------------
  |  |  145|      0|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
 1441|      0|            }
 1442|       |
 1443|  9.58k|            if (isMapped(tif))
  ------------------
  |  |  279|  9.58k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  9.58k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 9.58k]
  |  |  ------------------
  ------------------
 1444|      0|            {
 1445|      0|                if (bytecountm > tif->tif_rawdatasize &&
  ------------------
  |  Branch (1445:21): [True: 0, False: 0]
  ------------------
 1446|      0|                    !TIFFReadBufferSetup(tif, 0, bytecountm))
  ------------------
  |  Branch (1446:21): [True: 0, False: 0]
  ------------------
 1447|      0|                {
 1448|      0|                    return (0);
 1449|      0|                }
 1450|      0|                if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, bytecountm,
  ------------------
  |  Branch (1450:21): [True: 0, False: 0]
  ------------------
 1451|      0|                                     module) != bytecountm)
 1452|      0|                {
 1453|      0|                    return (0);
 1454|      0|                }
 1455|      0|            }
 1456|  9.58k|            else
 1457|  9.58k|            {
 1458|  9.58k|                if (TIFFReadRawStripOrTile2(tif, tile, 0, bytecountm, module) !=
  ------------------
  |  Branch (1458:21): [True: 1.23k, False: 8.35k]
  ------------------
 1459|  9.58k|                    bytecountm)
 1460|  1.23k|                {
 1461|  1.23k|                    return (0);
 1462|  1.23k|                }
 1463|  9.58k|            }
 1464|       |
 1465|  8.35k|            tif->tif_rawdataoff = 0;
 1466|  8.35k|            tif->tif_rawdataloaded = bytecountm;
 1467|       |
 1468|  8.35k|            if (tif->tif_rawdata != NULL &&
  ------------------
  |  Branch (1468:17): [True: 8.35k, False: 0]
  ------------------
 1469|  8.35k|                !isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|  16.7k|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (1469:17): [True: 0, False: 8.35k]
  ------------------
 1470|      0|                (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (1470:17): [True: 0, False: 0]
  ------------------
 1471|      0|                TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdataloaded);
 1472|  8.35k|        }
 1473|  9.58k|    }
 1474|   199k|    return (TIFFStartTile(tif, tile));
 1475|   309k|}
_TIFFNoPostDecode:
 1799|  8.90k|{
 1800|  8.90k|    (void)tif;
 1801|  8.90k|    (void)buf;
 1802|  8.90k|    (void)cc;
 1803|  8.90k|}
tif_read.c:TIFFReadAndRealloc:
   56|  49.8k|{
   57|  49.8k|#if SIZEOF_SIZE_T == 8
   58|  49.8k|    tmsize_t threshold = INITIAL_THRESHOLD;
  ------------------
  |  |   43|  49.8k|#define INITIAL_THRESHOLD (1024 * 1024)
  ------------------
   59|  49.8k|#endif
   60|  49.8k|    tmsize_t already_read = 0;
   61|       |
   62|       |#if SIZEOF_SIZE_T != 8
   63|       |    /* On 32 bit processes, if the request is large enough, check against */
   64|       |    /* file size */
   65|       |    if (size > 1000 * 1000 * 1000)
   66|       |    {
   67|       |        uint64_t filesize = TIFFGetFileSize(tif);
   68|       |        if ((uint64_t)size >= filesize)
   69|       |        {
   70|       |            TIFFErrorExtR(tif, module,
   71|       |                          "Chunk size requested is larger than file size.");
   72|       |            return 0;
   73|       |        }
   74|       |    }
   75|       |#endif
   76|       |
   77|       |    /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */
   78|       |    /* so as to avoid allocating too much memory in case the file is too */
   79|       |    /* short. We could ask for the file size, but this might be */
   80|       |    /* expensive with some I/O layers (think of reading a gzipped file) */
   81|       |    /* Restrict to 64 bit processes, so as to avoid reallocs() */
   82|       |    /* on 32 bit processes where virtual memory is scarce.  */
   83|  99.6k|    while (already_read < size)
  ------------------
  |  Branch (83:12): [True: 49.8k, False: 49.8k]
  ------------------
   84|  49.8k|    {
   85|  49.8k|        tmsize_t bytes_read;
   86|  49.8k|        tmsize_t to_read = size - already_read;
   87|  49.8k|#if SIZEOF_SIZE_T == 8
   88|  49.8k|        if (to_read >= threshold && threshold < MAX_THRESHOLD &&
  ------------------
  |  |   46|  49.8k|    (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      4|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      4|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      4|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |   47|  49.8k|     INITIAL_THRESHOLD)
  |  |  ------------------
  |  |  |  |   43|      4|#define INITIAL_THRESHOLD (1024 * 1024)
  |  |  ------------------
  ------------------
  |  Branch (88:13): [True: 4, False: 49.8k]
  |  Branch (88:37): [True: 4, False: 0]
  ------------------
   89|      4|            already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
  ------------------
  |  Branch (89:13): [True: 4, False: 0]
  ------------------
   90|      4|        {
   91|      4|            to_read = threshold;
   92|      4|            threshold *= THRESHOLD_MULTIPLIER;
  ------------------
  |  |   44|      4|#define THRESHOLD_MULTIPLIER 10
  ------------------
   93|      4|        }
   94|  49.8k|#endif
   95|  49.8k|        if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
  ------------------
  |  Branch (95:13): [True: 565, False: 49.2k]
  ------------------
   96|    565|        {
   97|    565|            uint8_t *new_rawdata;
   98|    565|            assert((tif->tif_flags & TIFF_MYBUFFER) != 0);
  ------------------
  |  Branch (98:13): [True: 0, False: 565]
  |  Branch (98:13): [True: 565, False: 0]
  ------------------
   99|    565|            tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64(
  ------------------
  |  |  327|    565|#define TIFFroundup_64(x, y) ((uint64_t)(TIFFhowmany_64(x, y) * (uint64_t)(y)))
  |  |  ------------------
  |  |  |  |  324|    565|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  |  |  ------------------
  ------------------
  100|    565|                (uint64_t)already_read + (uint64_t)to_read +
  101|    565|                    (uint64_t)rawdata_offset,
  102|    565|                1024);
  103|    565|            if (tif->tif_rawdatasize == 0)
  ------------------
  |  Branch (103:17): [True: 0, False: 565]
  ------------------
  104|      0|            {
  105|      0|                TIFFErrorExtR(tif, module, "Invalid buffer size");
  106|      0|                return 0;
  107|      0|            }
  108|    565|            new_rawdata = (uint8_t *)_TIFFreallocExt(tif, tif->tif_rawdata,
  109|    565|                                                     tif->tif_rawdatasize);
  110|    565|            if (new_rawdata == 0)
  ------------------
  |  Branch (110:17): [True: 0, False: 565]
  ------------------
  111|      0|            {
  112|      0|                TIFFErrorExtR(tif, module,
  113|      0|                              "No space for data buffer at scanline %" PRIu32,
  114|      0|                              tif->tif_dir.td_row);
  115|      0|                _TIFFfreeExt(tif, tif->tif_rawdata);
  116|      0|                tif->tif_rawdata = 0;
  117|      0|                tif->tif_rawdatasize = 0;
  118|      0|                return 0;
  119|      0|            }
  120|    565|            tif->tif_rawdata = new_rawdata;
  121|    565|        }
  122|  49.8k|        if (tif->tif_rawdata == NULL)
  ------------------
  |  Branch (122:13): [True: 0, False: 49.8k]
  ------------------
  123|      0|        {
  124|       |            /* should not happen in practice but helps CoverityScan */
  125|      0|            return 0;
  126|      0|        }
  127|       |
  128|  49.8k|        bytes_read = TIFFReadFile(
  ------------------
  |  |  283|  49.8k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  129|  49.8k|            tif, tif->tif_rawdata + rawdata_offset + already_read, to_read);
  130|  49.8k|        if (bytes_read < 0)
  ------------------
  |  Branch (130:13): [True: 0, False: 49.8k]
  ------------------
  131|       |            /* Treat read errors as short reads before updating offsets. */
  132|      0|            bytes_read = 0;
  133|  49.8k|        already_read += bytes_read;
  134|  49.8k|        if (bytes_read != to_read)
  ------------------
  |  Branch (134:13): [True: 25, False: 49.8k]
  ------------------
  135|     25|        {
  136|     25|            memset(
  137|     25|                tif->tif_rawdata + rawdata_offset + already_read, 0,
  138|     25|                (size_t)(tif->tif_rawdatasize - rawdata_offset - already_read));
  139|     25|            if (is_strip)
  ------------------
  |  Branch (139:17): [True: 21, False: 4]
  ------------------
  140|     21|            {
  141|     21|                TIFFErrorExtR(tif, module,
  142|     21|                              "Read error at scanline %" PRIu32
  143|     21|                              "; got %" TIFF_SSIZE_FORMAT " bytes, "
  144|     21|                              "expected %" TIFF_SSIZE_FORMAT,
  ------------------
  |  |  142|     21|#  define TIFF_SSIZE_FORMAT PRId64
  ------------------
  145|     21|                              tif->tif_dir.td_row, already_read, size);
  146|     21|            }
  147|      4|            else
  148|      4|            {
  149|      4|                TIFFErrorExtR(tif, module,
  150|      4|                              "Read error at row %" PRIu32 ", col %" PRIu32
  151|      4|                              ", tile %" PRIu32 "; "
  152|      4|                              "got %" TIFF_SSIZE_FORMAT
  153|      4|                              " bytes, expected %" TIFF_SSIZE_FORMAT "",
  154|      4|                              tif->tif_dir.td_row, tif->tif_dir.td_col,
  155|      4|                              strip_or_tile, already_read, size);
  156|      4|            }
  157|     25|            return 0;
  158|     25|        }
  159|  49.8k|    }
  160|  49.8k|    return 1;
  161|  49.8k|}
tif_read.c:TIFFReadEncodedStripGetStripSize:
  526|  90.6k|{
  527|  90.6k|    static const char module[] = "TIFFReadEncodedStrip";
  528|  90.6k|    TIFFDirectory *td = &tif->tif_dir;
  529|  90.6k|    uint32_t rowsperstrip;
  530|  90.6k|    uint32_t stripsperplane;
  531|  90.6k|    uint32_t stripinplane;
  532|  90.6k|    uint32_t rows;
  533|  90.6k|    tmsize_t stripsize;
  534|  90.6k|    if (!TIFFCheckRead(tif, 0))
  ------------------
  |  Branch (534:9): [True: 0, False: 90.6k]
  ------------------
  535|      0|        return ((tmsize_t)(-1));
  536|  90.6k|    if (strip >= td->td_nstrips)
  ------------------
  |  Branch (536:9): [True: 0, False: 90.6k]
  ------------------
  537|      0|    {
  538|      0|        TIFFErrorExtR(tif, module,
  539|      0|                      "%" PRIu32 ": Strip out of range, max %" PRIu32, strip,
  540|      0|                      td->td_nstrips);
  541|      0|        return ((tmsize_t)(-1));
  542|      0|    }
  543|       |
  544|  90.6k|    rowsperstrip = td->td_rowsperstrip;
  545|  90.6k|    if (rowsperstrip > td->td_imagelength)
  ------------------
  |  Branch (545:9): [True: 20.7k, False: 69.8k]
  ------------------
  546|  20.7k|        rowsperstrip = td->td_imagelength;
  547|  90.6k|    if (rowsperstrip == 0)
  ------------------
  |  Branch (547:9): [True: 0, False: 90.6k]
  ------------------
  548|      0|    {
  549|      0|        TIFFErrorExtR(tif, module, "rowsperstrip is zero");
  550|      0|        return ((tmsize_t)(-1));
  551|      0|    }
  552|  90.6k|    stripsperplane =
  553|  90.6k|        TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  318|  90.6k|    (((uint32_t)(x) / (uint32_t)(y)) +                                         \
  |  |  319|  90.6k|     ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
  |  |  ------------------
  |  |  |  Branch (319:7): [True: 15.0k, False: 75.5k]
  |  |  ------------------
  ------------------
  554|  90.6k|    stripinplane = (strip % stripsperplane);
  555|  90.6k|    if (pplane)
  ------------------
  |  Branch (555:9): [True: 90.6k, False: 0]
  ------------------
  556|  90.6k|        *pplane = (uint16_t)(strip / stripsperplane);
  557|  90.6k|    rows = td->td_imagelength - stripinplane * rowsperstrip;
  558|  90.6k|    if (rows > rowsperstrip)
  ------------------
  |  Branch (558:9): [True: 68.3k, False: 22.2k]
  ------------------
  559|  68.3k|        rows = rowsperstrip;
  560|  90.6k|    stripsize = TIFFVStripSize(tif, rows);
  561|  90.6k|    if (stripsize == 0)
  ------------------
  |  Branch (561:9): [True: 0, False: 90.6k]
  ------------------
  562|      0|        return ((tmsize_t)(-1));
  563|  90.6k|    return stripsize;
  564|  90.6k|}
tif_read.c:TIFFReadRawStrip1:
  680|     82|{
  681|     82|    assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
  ------------------
  |  Branch (681:5): [True: 0, False: 82]
  |  Branch (681:5): [True: 82, False: 0]
  ------------------
  682|     82|    if (!isMapped(tif))
  ------------------
  |  |  279|     82|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|     82|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (682:9): [True: 82, False: 0]
  ------------------
  683|     82|    {
  684|     82|        tmsize_t cc;
  685|       |
  686|     82|        if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip)))
  ------------------
  |  |  303|     82|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (686:13): [True: 0, False: 82]
  ------------------
  687|      0|        {
  688|      0|            TIFFErrorExtR(tif, module,
  689|      0|                          "Seek error at scanline %" PRIu32 ", strip %" PRIu32,
  690|      0|                          tif->tif_dir.td_row, strip);
  691|      0|            return ((tmsize_t)(-1));
  692|      0|        }
  693|     82|        cc = TIFFReadFile(tif, buf, size);
  ------------------
  |  |  283|     82|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  694|     82|        if (cc != size)
  ------------------
  |  Branch (694:13): [True: 0, False: 82]
  ------------------
  695|      0|        {
  696|      0|            TIFFErrorExtR(tif, module,
  697|      0|                          "Read error at scanline %" PRIu32
  698|      0|                          "; got %" TIFF_SSIZE_FORMAT
  699|      0|                          " bytes, expected %" TIFF_SSIZE_FORMAT,
  ------------------
  |  |  142|      0|#  define TIFF_SSIZE_FORMAT PRId64
  ------------------
  700|      0|                          tif->tif_dir.td_row, cc, size);
  701|      0|            return ((tmsize_t)(-1));
  702|      0|        }
  703|     82|    }
  704|      0|    else
  705|      0|    {
  706|      0|        tmsize_t ma = 0;
  707|      0|        tmsize_t n;
  708|      0|        if ((TIFFGetStrileOffset(tif, strip) > (uint64_t)TIFF_TMSIZE_T_MAX) ||
  ------------------
  |  |   68|      0|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (708:13): [True: 0, False: 0]
  ------------------
  709|      0|            ((ma = (tmsize_t)TIFFGetStrileOffset(tif, strip)) > tif->tif_size))
  ------------------
  |  Branch (709:13): [True: 0, False: 0]
  ------------------
  710|      0|        {
  711|      0|            n = 0;
  712|      0|        }
  713|      0|        else if (ma > TIFF_TMSIZE_T_MAX - size)
  ------------------
  |  |   68|      0|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (713:18): [True: 0, False: 0]
  ------------------
  714|      0|        {
  715|      0|            n = 0;
  716|      0|        }
  717|      0|        else
  718|      0|        {
  719|      0|            tmsize_t mb = ma + size;
  720|      0|            if (mb > tif->tif_size)
  ------------------
  |  Branch (720:17): [True: 0, False: 0]
  ------------------
  721|      0|                n = tif->tif_size - ma;
  722|      0|            else
  723|      0|                n = size;
  724|      0|        }
  725|      0|        if (n != size)
  ------------------
  |  Branch (725:13): [True: 0, False: 0]
  ------------------
  726|      0|        {
  727|      0|            TIFFErrorExtR(tif, module,
  728|      0|                          "Read error at scanline %" PRIu32 ", strip %" PRIu32
  729|      0|                          "; got %" TIFF_SSIZE_FORMAT
  730|      0|                          " bytes, expected %" TIFF_SSIZE_FORMAT,
  ------------------
  |  |  142|      0|#  define TIFF_SSIZE_FORMAT PRId64
  ------------------
  731|      0|                          tif->tif_dir.td_row, strip, n, size);
  732|      0|            return ((tmsize_t)(-1));
  733|      0|        }
  734|      0|        _TIFFmemcpy(buf, tif->tif_base + ma, size);
  735|      0|    }
  736|     82|    return (size);
  737|     82|}
tif_read.c:TIFFReadRawStripOrTile2:
  742|  52.2k|{
  743|  52.2k|    assert(!isMapped(tif));
  ------------------
  |  Branch (743:5): [True: 0, False: 52.2k]
  |  Branch (743:5): [True: 52.2k, False: 0]
  ------------------
  744|  52.2k|    assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
  ------------------
  |  Branch (744:5): [True: 0, False: 52.2k]
  |  Branch (744:5): [True: 52.2k, False: 0]
  ------------------
  745|       |
  746|  52.2k|    if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile)))
  ------------------
  |  |  303|  52.2k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (746:9): [True: 2.37k, False: 49.8k]
  ------------------
  747|  2.37k|    {
  748|  2.37k|        if (is_strip)
  ------------------
  |  Branch (748:13): [True: 1.14k, False: 1.23k]
  ------------------
  749|  1.14k|        {
  750|  1.14k|            TIFFErrorExtR(tif, module,
  751|  1.14k|                          "Seek error at scanline %" PRIu32 ", strip %" PRIu32,
  752|  1.14k|                          tif->tif_dir.td_row, strip_or_tile);
  753|  1.14k|        }
  754|  1.23k|        else
  755|  1.23k|        {
  756|  1.23k|            TIFFErrorExtR(
  757|  1.23k|                tif, module,
  758|  1.23k|                "Seek error at row %" PRIu32 ", col %" PRIu32 ", tile %" PRIu32,
  759|  1.23k|                tif->tif_dir.td_row, tif->tif_dir.td_col, strip_or_tile);
  760|  1.23k|        }
  761|  2.37k|        return ((tmsize_t)(-1));
  762|  2.37k|    }
  763|       |
  764|  49.8k|    if (!TIFFReadAndRealloc(tif, size, 0, is_strip, strip_or_tile, module))
  ------------------
  |  Branch (764:9): [True: 25, False: 49.8k]
  ------------------
  765|     25|    {
  766|     25|        return ((tmsize_t)(-1));
  767|     25|    }
  768|       |
  769|  49.8k|    return (size);
  770|  49.8k|}
tif_read.c:TIFFStartStrip:
 1542|  58.1k|{
 1543|  58.1k|    TIFFDirectory *td = &tif->tif_dir;
 1544|       |
 1545|  58.1k|    if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
  ------------------
  |  |  124|  58.1k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  |  Branch (1545:9): [True: 2.56k, False: 55.6k]
  ------------------
 1546|  2.56k|    {
 1547|  2.56k|        if (!(*tif->tif_setupdecode)(tif))
  ------------------
  |  Branch (1547:13): [True: 1.07k, False: 1.48k]
  ------------------
 1548|  1.07k|            return (0);
 1549|  1.48k|        tif->tif_flags |= TIFF_CODERSETUP;
  ------------------
  |  |  124|  1.48k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
 1550|  1.48k|    }
 1551|  57.1k|    if (td->td_stripsperimage == 0)
  ------------------
  |  Branch (1551:9): [True: 0, False: 57.1k]
  ------------------
 1552|      0|    {
 1553|      0|        TIFFErrorExtR(tif, "TIFFStartStrip", "Zero strips per image");
 1554|      0|        return 0;
 1555|      0|    }
 1556|  57.1k|    tif->tif_dir.td_curstrip = strip;
 1557|  57.1k|    tif->tif_dir.td_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
 1558|  57.1k|    tif->tif_flags &= ~TIFF_BUF4WRITE;
  ------------------
  |  |  141|  57.1k|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 1559|       |
 1560|  57.1k|    if (tif->tif_flags & TIFF_NOREADRAW)
  ------------------
  |  |  138|  57.1k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1560:9): [True: 16.7k, False: 40.3k]
  ------------------
 1561|  16.7k|    {
 1562|  16.7k|        tif->tif_rawcp = NULL;
 1563|  16.7k|        tif->tif_rawcc = 0;
 1564|  16.7k|    }
 1565|  40.3k|    else
 1566|  40.3k|    {
 1567|  40.3k|        tif->tif_rawcp = tif->tif_rawdata;
 1568|  40.3k|        if (tif->tif_rawdataloaded > 0)
  ------------------
  |  Branch (1568:13): [True: 40.3k, False: 0]
  ------------------
 1569|  40.3k|            tif->tif_rawcc = tif->tif_rawdataloaded;
 1570|      0|        else
 1571|      0|            tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip);
 1572|  40.3k|    }
 1573|  57.1k|    if ((*tif->tif_predecode)(tif, (uint16_t)(strip / td->td_stripsperimage)) ==
  ------------------
  |  Branch (1573:9): [True: 52.4k, False: 4.67k]
  ------------------
 1574|  57.1k|        0)
 1575|  52.4k|    {
 1576|       |        /* Needed for example for scanline access, if tif_predecode */
 1577|       |        /* fails, and we try to read the same strip again. Without invalidating
 1578|       |         */
 1579|       |        /* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */
 1580|       |        /* codec state. */
 1581|  52.4k|        tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|  52.4k|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
 1582|  52.4k|        return 0;
 1583|  52.4k|    }
 1584|  4.67k|    return 1;
 1585|  57.1k|}
tif_read.c:TIFFStartTile:
 1592|   199k|{
 1593|   199k|    static const char module[] = "TIFFStartTile";
 1594|   199k|    TIFFDirectory *td = &tif->tif_dir;
 1595|   199k|    uint32_t howmany32;
 1596|   199k|    uint32_t tilemod;
 1597|       |
 1598|   199k|    if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
  ------------------
  |  |  124|   199k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  |  Branch (1598:9): [True: 556, False: 199k]
  ------------------
 1599|    556|    {
 1600|    556|        if (!(*tif->tif_setupdecode)(tif))
  ------------------
  |  Branch (1600:13): [True: 28, False: 528]
  ------------------
 1601|     28|            return (0);
 1602|    528|        tif->tif_flags |= TIFF_CODERSETUP;
  ------------------
  |  |  124|    528|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
 1603|    528|    }
 1604|   199k|    tif->tif_dir.td_curtile = tile;
 1605|   199k|    if (td->td_tilewidth == 0)
  ------------------
  |  Branch (1605:9): [True: 0, False: 199k]
  ------------------
 1606|      0|    {
 1607|      0|        TIFFErrorExtR(tif, module, "Zero tilewidth");
 1608|      0|        return 0;
 1609|      0|    }
 1610|   199k|    howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
  ------------------
  |  |  312|   199k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 199k, False: 0]
  |  |  ------------------
  |  |  313|   199k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|   199k|         : 0U)
  ------------------
 1611|   199k|    if (howmany32 == 0)
  ------------------
  |  Branch (1611:9): [True: 0, False: 199k]
  ------------------
 1612|      0|    {
 1613|      0|        TIFFErrorExtR(tif, module, "Zero tiles");
 1614|      0|        return 0;
 1615|      0|    }
 1616|   199k|    tilemod = tile % howmany32;
 1617|   199k|    if (td->td_tilelength == 0)
  ------------------
  |  Branch (1617:9): [True: 0, False: 199k]
  ------------------
 1618|      0|    {
 1619|      0|        TIFFErrorExtR(tif, module, "Zero tilelength");
 1620|      0|        return 0;
 1621|      0|    }
 1622|   199k|    if (tilemod == 0)
  ------------------
  |  Branch (1622:9): [True: 46.5k, False: 153k]
  ------------------
 1623|  46.5k|    {
 1624|  46.5k|        tif->tif_dir.td_row = 0;
 1625|  46.5k|    }
 1626|   153k|    else
 1627|   153k|    {
 1628|   153k|        tif->tif_dir.td_row =
 1629|   153k|            _TIFFMultiply32(tif, tilemod, td->td_tilelength, module);
 1630|   153k|        if (tif->tif_dir.td_row == 0)
  ------------------
  |  Branch (1630:13): [True: 0, False: 153k]
  ------------------
 1631|      0|            return 0;
 1632|   153k|    }
 1633|   199k|    howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
  ------------------
  |  |  312|   199k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 199k, False: 4]
  |  |  ------------------
  |  |  313|   199k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|   199k|         : 0U)
  ------------------
 1634|   199k|    if (howmany32 == 0)
  ------------------
  |  Branch (1634:9): [True: 4, False: 199k]
  ------------------
 1635|      4|    {
 1636|      4|        TIFFErrorExtR(tif, module, "Zero tiles");
 1637|      4|        return 0;
 1638|      4|    }
 1639|   199k|    tilemod = tile % howmany32;
 1640|   199k|    if (tilemod == 0)
  ------------------
  |  Branch (1640:9): [True: 133k, False: 65.8k]
  ------------------
 1641|   133k|    {
 1642|   133k|        tif->tif_dir.td_col = 0;
 1643|   133k|    }
 1644|  65.8k|    else
 1645|  65.8k|    {
 1646|  65.8k|        tif->tif_dir.td_col =
 1647|  65.8k|            _TIFFMultiply32(tif, tilemod, td->td_tilewidth, module);
 1648|  65.8k|        if (tif->tif_dir.td_col == 0)
  ------------------
  |  Branch (1648:13): [True: 0, False: 65.8k]
  ------------------
 1649|      0|            return 0;
 1650|  65.8k|    }
 1651|   199k|    tif->tif_flags &= ~TIFF_BUF4WRITE;
  ------------------
  |  |  141|   199k|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 1652|   199k|    if (tif->tif_flags & TIFF_NOREADRAW)
  ------------------
  |  |  138|   199k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1652:9): [True: 191k, False: 8.32k]
  ------------------
 1653|   191k|    {
 1654|   191k|        tif->tif_rawcp = NULL;
 1655|   191k|        tif->tif_rawcc = 0;
 1656|   191k|    }
 1657|  8.32k|    else
 1658|  8.32k|    {
 1659|  8.32k|        tif->tif_rawcp = tif->tif_rawdata;
 1660|  8.32k|        if (tif->tif_rawdataloaded > 0)
  ------------------
  |  Branch (1660:13): [True: 8.32k, False: 0]
  ------------------
 1661|  8.32k|            tif->tif_rawcc = tif->tif_rawdataloaded;
 1662|      0|        else
 1663|      0|            tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile);
 1664|  8.32k|    }
 1665|   199k|    return (
 1666|   199k|        (*tif->tif_predecode)(tif, (uint16_t)(tile / td->td_stripsperimage)));
 1667|   199k|}
tif_read.c:TIFFCheckRead:
 1670|   461k|{
 1671|   461k|    if (tif->tif_mode == O_WRONLY)
  ------------------
  |  Branch (1671:9): [True: 0, False: 461k]
  ------------------
 1672|      0|    {
 1673|      0|        TIFFErrorExtR(tif, tif->tif_name, "File not open for reading");
 1674|      0|        return (0);
 1675|      0|    }
 1676|   461k|    if (tiles ^ isTiled(tif))
  ------------------
  |  |  278|   461k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|   461k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (1676:9): [True: 0, False: 461k]
  ------------------
 1677|      0|    {
 1678|      0|        TIFFErrorExtR(tif, tif->tif_name,
 1679|      0|                      tiles ? "Can not read tiles from a striped image"
  ------------------
  |  Branch (1679:23): [True: 0, False: 0]
  ------------------
 1680|      0|                            : "Can not read scanlines from a tiled image");
 1681|      0|        return (0);
 1682|      0|    }
 1683|   461k|    return (1);
 1684|   461k|}

_Z14TIFFStreamOpenPKcPNSt3__113basic_istreamIcNS1_11char_traitsIcEEEE:
  456|  1.28k|{
  457|       |    // NB: We don't support mapped files with streams so add 'm'
  458|  1.28k|    return _tiffStreamOpen(name, "rm", is);
  459|  1.28k|}
tif_stream.cxx:_ZL15_tiffStreamOpenPKcS0_Pv:
  399|  1.28k|    {
  400|  1.28k|        TIFF *tif;
  401|       |
  402|  1.28k|        if (strchr(mode, 'w'))
  ------------------
  |  Branch (402:13): [True: 0, False: 1.28k]
  ------------------
  403|      0|        {
  404|      0|            tiffos_data *data = new tiffos_data;
  405|      0|            data->stream = reinterpret_cast<ostream *>(fd);
  406|      0|            data->start_pos = data->stream->tellp();
  407|       |
  408|       |            // Open for writing.
  409|      0|            tif = TIFFClientOpen(
  410|      0|                name, mode, reinterpret_cast<thandle_t>(data), _tiffosReadProc,
  411|      0|                _tiffosWriteProc, _tiffosSeekProc, _tiffosCloseProc,
  412|      0|                _tiffosSizeProc, _tiffDummyMapProcCxx, _tiffDummyUnmapProcCxx);
  413|      0|            if (!tif)
  ------------------
  |  Branch (413:17): [True: 0, False: 0]
  ------------------
  414|      0|            {
  415|      0|                delete data;
  416|      0|            }
  417|      0|        }
  418|  1.28k|        else
  419|  1.28k|        {
  420|  1.28k|            tiffis_data *data = new tiffis_data;
  421|  1.28k|            data->stream = reinterpret_cast<istream *>(fd);
  422|  1.28k|            data->start_pos = data->stream->tellg();
  423|       |            // Open for reading.
  424|  1.28k|            tif = TIFFClientOpen(
  425|  1.28k|                name, mode, reinterpret_cast<thandle_t>(data), _tiffisReadProc,
  426|  1.28k|                _tiffisWriteProc, _tiffisSeekProc, _tiffisCloseProc,
  427|  1.28k|                _tiffisSizeProc, _tiffDummyMapProcCxx, _tiffDummyUnmapProcCxx);
  428|  1.28k|            if (!tif)
  ------------------
  |  Branch (428:17): [True: 287, False: 993]
  ------------------
  429|    287|            {
  430|    287|                delete data;
  431|    287|            }
  432|  1.28k|        }
  433|       |
  434|  1.28k|        return (tif);
  435|  1.28k|    }
tif_stream.cxx:_ZL15_tiffisReadProcPvS_l:
  109|   189k|    {
  110|   189k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  111|       |
  112|       |        // Verify that type does not overflow.
  113|   189k|        streamsize request_size = size;
  114|   189k|        if (static_cast<tmsize_t>(request_size) != size)
  ------------------
  |  Branch (114:13): [True: 0, False: 189k]
  ------------------
  115|      0|            return static_cast<tmsize_t>(-1);
  116|       |
  117|   189k|        data->stream->read((char *)buf, request_size);
  118|       |
  119|   189k|        return static_cast<tmsize_t>(data->stream->gcount());
  120|   189k|    }
tif_stream.cxx:_ZL15_tiffisSeekProcPvmi:
  242|   165k|    {
  243|   165k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  244|       |
  245|   165k|        if (data->start_pos == ios::pos_type(-1))
  ------------------
  |  Branch (245:13): [True: 0, False: 165k]
  ------------------
  246|      0|            return static_cast<uint64_t>(-1);
  247|       |
  248|   165k|        switch (whence)
  ------------------
  |  Branch (248:17): [True: 165k, False: 0]
  ------------------
  249|   165k|        {
  250|   165k|            case SEEK_SET:
  ------------------
  |  Branch (250:13): [True: 165k, False: 0]
  ------------------
  251|   165k|            {
  252|       |                // Compute 64-bit offset
  253|   165k|                uint64_t new_offset =
  254|   165k|                    static_cast<uint64_t>(data->start_pos) + off;
  255|       |
  256|       |                // Verify that value does not overflow
  257|   165k|                ios::off_type offset = static_cast<ios::off_type>(new_offset);
  258|   165k|                if (static_cast<uint64_t>(offset) != new_offset)
  ------------------
  |  Branch (258:21): [True: 0, False: 165k]
  ------------------
  259|      0|                    return static_cast<uint64_t>(-1);
  260|       |
  261|   165k|                data->stream->seekg(offset, ios::beg);
  262|   165k|                break;
  263|   165k|            }
  264|      0|            case SEEK_CUR:
  ------------------
  |  Branch (264:13): [True: 0, False: 165k]
  ------------------
  265|      0|            {
  266|       |                // Verify that value does not overflow
  267|      0|                ios::off_type offset = static_cast<ios::off_type>(off);
  268|      0|                if (static_cast<uint64_t>(offset) != off)
  ------------------
  |  Branch (268:21): [True: 0, False: 0]
  ------------------
  269|      0|                    return static_cast<uint64_t>(-1);
  270|       |
  271|      0|                data->stream->seekg(offset, ios::cur);
  272|      0|                break;
  273|      0|            }
  274|      0|            case SEEK_END:
  ------------------
  |  Branch (274:13): [True: 0, False: 165k]
  ------------------
  275|      0|            {
  276|       |                // Verify that value does not overflow
  277|      0|                ios::off_type offset = static_cast<ios::off_type>(off);
  278|      0|                if (static_cast<uint64_t>(offset) != off)
  ------------------
  |  Branch (278:21): [True: 0, False: 0]
  ------------------
  279|      0|                    return static_cast<uint64_t>(-1);
  280|       |
  281|      0|                data->stream->seekg(offset, ios::end);
  282|      0|                break;
  283|      0|            }
  284|   165k|        }
  285|       |
  286|   165k|        ios::pos_type pos = data->stream->tellg();
  287|   165k|        if (pos == ios::pos_type(-1))
  ------------------
  |  Branch (287:13): [True: 3.55k, False: 161k]
  ------------------
  288|  3.55k|            return static_cast<uint64_t>(-1);
  289|       |
  290|   161k|        ios::off_type relative_pos = pos - data->start_pos;
  291|   161k|        if (relative_pos < 0)
  ------------------
  |  Branch (291:13): [True: 0, False: 161k]
  ------------------
  292|      0|            return static_cast<uint64_t>(-1);
  293|       |
  294|   161k|        return static_cast<uint64_t>(relative_pos);
  295|   161k|    }
tif_stream.cxx:_ZL16_tiffisCloseProcPv:
  376|    993|    {
  377|       |        // Our stream was not allocated by us, so it shouldn't be closed by us.
  378|    993|        delete reinterpret_cast<tiffis_data *>(fd);
  379|    993|        return 0;
  380|    993|    }
tif_stream.cxx:_ZL15_tiffisSizeProcPv:
  334|  3.97k|    {
  335|  3.97k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  336|  3.97k|        ios::pos_type pos = data->stream->tellg();
  337|  3.97k|        ios::pos_type len;
  338|       |
  339|       |        // Failed stream positions must not be converted to unsigned sizes.
  340|  3.97k|        if (pos == ios::pos_type(-1))
  ------------------
  |  Branch (340:13): [True: 112, False: 3.86k]
  ------------------
  341|    112|            return 0;
  342|       |
  343|  3.86k|        data->stream->seekg(0, ios::end);
  344|  3.86k|        if (data->stream->fail())
  ------------------
  |  Branch (344:13): [True: 0, False: 3.86k]
  ------------------
  345|      0|        {
  346|      0|            ios::iostate old_state = data->stream->rdstate();
  347|       |            // Temporarily clear failbit to restore the original position.
  348|      0|            data->stream->clear(data->stream->rdstate() & ~ios::failbit);
  349|      0|            data->stream->seekg(pos);
  350|      0|            data->stream->clear(old_state);
  351|      0|            return 0;
  352|      0|        }
  353|  3.86k|        len = data->stream->tellg();
  354|  3.86k|        if (len == ios::pos_type(-1))
  ------------------
  |  Branch (354:13): [True: 0, False: 3.86k]
  ------------------
  355|      0|        {
  356|      0|            ios::iostate old_state = data->stream->rdstate();
  357|       |            // Temporarily clear failbit to restore the original position.
  358|      0|            data->stream->clear(data->stream->rdstate() & ~ios::failbit);
  359|      0|            data->stream->seekg(pos);
  360|      0|            data->stream->clear(old_state);
  361|      0|            return 0;
  362|      0|        }
  363|  3.86k|        data->stream->seekg(pos);
  364|       |
  365|  3.86k|        return static_cast<uint64_t>(len);
  366|  3.86k|    }

TIFFComputeStrip:
   36|  2.06k|{
   37|  2.06k|    static const char module[] = "TIFFComputeStrip";
   38|  2.06k|    TIFFDirectory *td = &tif->tif_dir;
   39|  2.06k|    uint32_t strip;
   40|       |
   41|  2.06k|    if (td->td_rowsperstrip == 0)
  ------------------
  |  Branch (41:9): [True: 0, False: 2.06k]
  ------------------
   42|      0|    {
   43|      0|        TIFFErrorExtR(tif, module,
   44|      0|                      "Cannot compute strip: RowsPerStrip is zero");
   45|      0|        return 0;
   46|      0|    }
   47|  2.06k|    strip = row / td->td_rowsperstrip;
   48|  2.06k|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|  2.06k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (48:9): [True: 312, False: 1.75k]
  ------------------
   49|    312|    {
   50|    312|        uint64_t sample_offset;
   51|    312|        uint64_t strip64;
   52|    312|        if (sample >= td->td_samplesperpixel)
  ------------------
  |  Branch (52:13): [True: 18, False: 294]
  ------------------
   53|     18|        {
   54|     18|            TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu",
   55|     18|                          (unsigned long)sample,
   56|     18|                          (unsigned long)td->td_samplesperpixel);
   57|     18|            return (0);
   58|     18|        }
   59|    294|        sample_offset = _TIFFMultiply64(tif, sample, td->td_stripsperimage,
   60|    294|                                        "TIFFComputeStrip");
   61|    294|        if (sample_offset == 0 && sample != 0 && td->td_stripsperimage != 0)
  ------------------
  |  Branch (61:13): [True: 168, False: 126]
  |  Branch (61:35): [True: 0, False: 168]
  |  Branch (61:50): [True: 0, False: 0]
  ------------------
   62|      0|            return (0);
   63|    294|        strip64 = _TIFFAdd64(tif, sample_offset, strip, "TIFFComputeStrip");
   64|    294|        if (strip64 == 0 && (sample_offset != 0 || strip != 0))
  ------------------
  |  Branch (64:13): [True: 135, False: 159]
  |  Branch (64:30): [True: 0, False: 135]
  |  Branch (64:52): [True: 0, False: 135]
  ------------------
   65|      0|            return (0);
   66|    294|        strip = _TIFFCastUInt64ToUInt32(tif, strip64, "TIFFComputeStrip");
   67|    294|        if (strip == 0 && strip64 != 0)
  ------------------
  |  Branch (67:13): [True: 135, False: 159]
  |  Branch (67:27): [True: 0, False: 135]
  ------------------
   68|      0|            return (0);
   69|    294|    }
   70|  2.04k|    return (strip);
   71|  2.06k|}
TIFFNumberOfStrips:
   77|  3.49k|{
   78|  3.49k|    TIFFDirectory *td = &tif->tif_dir;
   79|  3.49k|    uint32_t nstrips;
   80|       |
   81|  3.49k|    if (td->td_rowsperstrip == 0)
  ------------------
  |  Branch (81:9): [True: 0, False: 3.49k]
  ------------------
   82|      0|    {
   83|      0|        TIFFWarningExtR(tif, "TIFFNumberOfStrips", "RowsPerStrip is zero");
   84|      0|        return 0;
   85|      0|    }
   86|  3.49k|    nstrips = (td->td_rowsperstrip == (uint32_t)-1
  ------------------
  |  Branch (86:16): [True: 883, False: 2.61k]
  ------------------
   87|  3.49k|                   ? 1
   88|  3.49k|                   : TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  ------------------
  |  |  312|  2.61k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 2.61k, False: 0]
  |  |  ------------------
  |  |  313|  2.61k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  2.61k|         : 0U)
  ------------------
   89|  3.49k|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|  3.49k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (89:9): [True: 624, False: 2.87k]
  ------------------
   90|    624|        nstrips =
   91|    624|            _TIFFMultiply32(tif, nstrips, (uint32_t)td->td_samplesperpixel,
   92|    624|                            "TIFFNumberOfStrips");
   93|  3.49k|    return (nstrips);
   94|  3.49k|}
_TIFFStrileSize64:
  101|   151k|{
  102|   151k|    static const char module[] = "_TIFFStrileSize64";
  103|   151k|    TIFFDirectory *td = &tif->tif_dir;
  104|   151k|    if (isStrip)
  ------------------
  |  Branch (104:9): [True: 139k, False: 11.3k]
  ------------------
  105|   139k|    {
  106|   139k|        if (nrows == (uint32_t)(-1))
  ------------------
  |  Branch (106:13): [True: 20, False: 139k]
  ------------------
  107|     20|            nrows = td->td_imagelength;
  108|   139k|    }
  109|  11.3k|    else
  110|  11.3k|    {
  111|  11.3k|        if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
  ------------------
  |  Branch (111:13): [True: 0, False: 11.3k]
  |  Branch (111:39): [True: 13, False: 11.3k]
  ------------------
  112|  11.3k|            td->td_tiledepth == 0)
  ------------------
  |  Branch (112:13): [True: 0, False: 11.3k]
  ------------------
  113|     13|            return (0);
  114|  11.3k|    }
  115|   151k|    if ((td->td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|   151k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (115:9): [True: 115k, False: 35.9k]
  ------------------
  116|   115k|        (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|   115k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
                      (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  281|  10.6k|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|  10.6k|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (116:9): [True: 10.6k, False: 104k]
  |  Branch (116:54): [True: 9.64k, False: 1.05k]
  ------------------
  117|  9.64k|    {
  118|       |        /*
  119|       |         * Packed YCbCr data contain one Cb+Cr for every
  120|       |         * HorizontalSampling*VerticalSampling Y values.
  121|       |         * Must also roundup width and height when calculating
  122|       |         * since images that are not a multiple of the
  123|       |         * horizontal/vertical subsampling area include
  124|       |         * YCbCr data for the extended image.
  125|       |         */
  126|  9.64k|        uint16_t ycbcrsubsampling[2];
  127|  9.64k|        uint16_t samplingblock_samples;
  128|  9.64k|        uint32_t samplingblocks_hor;
  129|  9.64k|        uint32_t samplingblocks_ver;
  130|  9.64k|        uint64_t samplingrow_samples;
  131|  9.64k|        uint64_t samplingrow_size;
  132|  9.64k|        if (td->td_samplesperpixel != 3)
  ------------------
  |  Branch (132:13): [True: 0, False: 9.64k]
  ------------------
  133|      0|        {
  134|      0|            TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
  135|      0|            return 0;
  136|      0|        }
  137|  9.64k|        TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|  9.64k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  138|  9.64k|                              ycbcrsubsampling + 0, ycbcrsubsampling + 1);
  139|  9.64k|        if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 &&
  ------------------
  |  Branch (139:14): [True: 9.25k, False: 393]
  |  Branch (139:42): [True: 56, False: 9.19k]
  ------------------
  140|     56|             ycbcrsubsampling[0] != 4) ||
  ------------------
  |  Branch (140:14): [True: 0, False: 56]
  ------------------
  141|  9.64k|            (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 &&
  ------------------
  |  Branch (141:14): [True: 9.26k, False: 381]
  |  Branch (141:42): [True: 219, False: 9.04k]
  ------------------
  142|    219|             ycbcrsubsampling[1] != 4) ||
  ------------------
  |  Branch (142:14): [True: 0, False: 219]
  ------------------
  143|  9.64k|            (ycbcrsubsampling[0] == 0 || ycbcrsubsampling[1] == 0))
  ------------------
  |  Branch (143:14): [True: 0, False: 9.64k]
  |  Branch (143:42): [True: 0, False: 9.64k]
  ------------------
  144|      0|        {
  145|      0|            TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling (%dx%d)",
  146|      0|                          ycbcrsubsampling[0], ycbcrsubsampling[1]);
  147|      0|            return 0;
  148|      0|        }
  149|  9.64k|        samplingblock_samples =
  150|  9.64k|            (uint16_t)(ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2);
  151|  9.64k|        const uint32_t width = isStrip ? td->td_imagewidth : td->td_tilewidth;
  ------------------
  |  Branch (151:32): [True: 9.34k, False: 300]
  ------------------
  152|  9.64k|        samplingblocks_hor = TIFFhowmany_32(width, ycbcrsubsampling[0]);
  ------------------
  |  |  312|  9.64k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 9.64k, False: 0]
  |  |  ------------------
  |  |  313|  9.64k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  9.64k|         : 0U)
  ------------------
  153|  9.64k|        samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]);
  ------------------
  |  |  312|  9.64k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 9.64k, False: 0]
  |  |  ------------------
  |  |  313|  9.64k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  9.64k|         : 0U)
  ------------------
  154|  9.64k|        samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor,
  155|  9.64k|                                              samplingblock_samples, module);
  156|  9.64k|        samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64(
  ------------------
  |  |  326|  9.64k|    (((x) & 0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
  |  |  ------------------
  |  |  |  Branch (326:6): [True: 110, False: 9.53k]
  |  |  ------------------
  ------------------
  157|  9.64k|            tif, samplingrow_samples, td->td_bitspersample, module));
  158|  9.64k|        return (
  159|  9.64k|            _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module));
  160|  9.64k|    }
  161|   141k|    else
  162|   141k|        return (_TIFFMultiply64(tif, nrows,
  163|   141k|                                isStrip ? TIFFScanlineSize64(tif)
  ------------------
  |  Branch (163:33): [True: 130k, False: 11.0k]
  ------------------
  164|   141k|                                        : TIFFTileRowSize64(tif),
  165|   141k|                                module));
  166|   151k|}
TIFFVStripSize64:
  172|   139k|{
  173|   139k|    return _TIFFStrileSize64(tif, nrows, /* isStrip = */ TRUE);
  ------------------
  |  |   71|   139k|#define TRUE 1
  ------------------
  174|   139k|}
TIFFVStripSize:
  177|  90.6k|{
  178|  90.6k|    static const char module[] = "TIFFVStripSize";
  179|  90.6k|    uint64_t m;
  180|  90.6k|    m = TIFFVStripSize64(tif, nrows);
  181|  90.6k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  182|  90.6k|}
TIFFStripSize64:
  231|  49.2k|{
  232|  49.2k|    TIFFDirectory *td = &tif->tif_dir;
  233|  49.2k|    uint32_t rps = td->td_rowsperstrip;
  234|  49.2k|    if (rps > td->td_imagelength)
  ------------------
  |  Branch (234:9): [True: 7.51k, False: 41.7k]
  ------------------
  235|  7.51k|        rps = td->td_imagelength;
  236|  49.2k|    return (TIFFVStripSize64(tif, rps));
  237|  49.2k|}
TIFFStripSize:
  239|  49.0k|{
  240|  49.0k|    static const char module[] = "TIFFStripSize";
  241|  49.0k|    uint64_t m;
  242|  49.0k|    m = TIFFStripSize64(tif);
  243|  49.0k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  244|  49.0k|}
TIFFScanlineSize64:
  292|   136k|{
  293|   136k|    static const char module[] = "TIFFScanlineSize64";
  294|   136k|    TIFFDirectory *td = &tif->tif_dir;
  295|   136k|    uint64_t scanline_size;
  296|   136k|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|   136k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (296:9): [True: 101k, False: 34.9k]
  ------------------
  297|   101k|    {
  298|   101k|        if ((td->td_photometric == PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|   101k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (298:13): [True: 2.95k, False: 98.5k]
  ------------------
  299|  2.95k|            (td->td_samplesperpixel == 3) && (!isUpSampled(tif)))
  ------------------
  |  |  281|  2.95k|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|  2.95k|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (299:13): [True: 2.95k, False: 0]
  |  Branch (299:46): [True: 1.30k, False: 1.65k]
  ------------------
  300|  1.30k|        {
  301|  1.30k|            uint16_t ycbcrsubsampling[2];
  302|  1.30k|            uint16_t samplingblock_samples;
  303|  1.30k|            uint32_t samplingblocks_hor;
  304|  1.30k|            uint64_t samplingrow_samples;
  305|  1.30k|            uint64_t samplingrow_size;
  306|  1.30k|            if (td->td_samplesperpixel != 3)
  ------------------
  |  Branch (306:17): [True: 0, False: 1.30k]
  ------------------
  307|      0|            {
  308|      0|                TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
  309|      0|                return 0;
  310|      0|            }
  311|  1.30k|            TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|  1.30k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  312|  1.30k|                                  ycbcrsubsampling + 0, ycbcrsubsampling + 1);
  313|  1.30k|            if (((ycbcrsubsampling[0] != 1) && (ycbcrsubsampling[0] != 2) &&
  ------------------
  |  Branch (313:18): [True: 1.19k, False: 110]
  |  Branch (313:48): [True: 20, False: 1.17k]
  ------------------
  314|     20|                 (ycbcrsubsampling[0] != 4)) ||
  ------------------
  |  Branch (314:18): [True: 0, False: 20]
  ------------------
  315|  1.30k|                ((ycbcrsubsampling[1] != 1) && (ycbcrsubsampling[1] != 2) &&
  ------------------
  |  Branch (315:18): [True: 1.19k, False: 106]
  |  Branch (315:48): [True: 9, False: 1.18k]
  ------------------
  316|      9|                 (ycbcrsubsampling[1] != 4)) ||
  ------------------
  |  Branch (316:18): [True: 0, False: 9]
  ------------------
  317|  1.30k|                ((ycbcrsubsampling[0] == 0) || (ycbcrsubsampling[1] == 0)))
  ------------------
  |  Branch (317:18): [True: 0, False: 1.30k]
  |  Branch (317:48): [True: 0, False: 1.30k]
  ------------------
  318|      0|            {
  319|      0|                TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling");
  320|      0|                return 0;
  321|      0|            }
  322|  1.30k|            samplingblock_samples =
  323|  1.30k|                (uint16_t)(ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2);
  324|  1.30k|            samplingblocks_hor =
  325|  1.30k|                TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]);
  ------------------
  |  |  312|  1.30k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 1.30k, False: 0]
  |  |  ------------------
  |  |  313|  1.30k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  1.30k|         : 0U)
  ------------------
  326|  1.30k|            samplingrow_samples = _TIFFMultiply64(
  327|  1.30k|                tif, samplingblocks_hor, samplingblock_samples, module);
  328|  1.30k|            samplingrow_size =
  329|  1.30k|                TIFFhowmany_64(_TIFFMultiply64(tif, samplingrow_samples,
  ------------------
  |  |  324|  1.30k|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  330|  1.30k|                                               td->td_bitspersample, module),
  331|  1.30k|                               8);
  332|  1.30k|            scanline_size = (samplingrow_size / ycbcrsubsampling[1]);
  333|  1.30k|        }
  334|   100k|        else
  335|   100k|        {
  336|   100k|            uint64_t scanline_samples;
  337|   100k|            uint32_t scanline_width = td->td_imagewidth;
  338|       |
  339|       |#if 0
  340|       |            // Tries to fix https://gitlab.com/libtiff/libtiff/-/merge_requests/564
  341|       |            // but causes regression when decoding legit files with tiffcp -c none
  342|       |            // Cf https://gitlab.com/libtiff/libtiff/-/merge_requests/644
  343|       |            if (td->td_photometric == PHOTOMETRIC_YCBCR)
  344|       |            {
  345|       |                uint16_t subsampling_hor;
  346|       |                uint16_t ignored;
  347|       |                TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
  348|       |                                      &subsampling_hor, &ignored);
  349|       |                if (subsampling_hor > 1) // roundup width for YCbCr
  350|       |                    scanline_width =
  351|       |                        TIFFroundup_32(scanline_width, subsampling_hor);
  352|       |            }
  353|       |#endif
  354|       |
  355|   100k|            scanline_samples = _TIFFMultiply64(tif, scanline_width,
  356|   100k|                                               td->td_samplesperpixel, module);
  357|   100k|            scanline_size =
  358|   100k|                TIFFhowmany_64(_TIFFMultiply64(tif, scanline_samples,
  ------------------
  |  |  324|   100k|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  359|   100k|                                               td->td_bitspersample, module),
  360|   100k|                               8);
  361|   100k|        }
  362|   101k|    }
  363|  34.9k|    else
  364|  34.9k|    {
  365|  34.9k|        scanline_size =
  366|  34.9k|            TIFFhowmany_64(_TIFFMultiply64(tif, td->td_imagewidth,
  ------------------
  |  |  324|  34.9k|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  367|  34.9k|                                           td->td_bitspersample, module),
  368|  34.9k|                           8);
  369|  34.9k|    }
  370|   136k|    if (scanline_size == 0)
  ------------------
  |  Branch (370:9): [True: 41, False: 136k]
  ------------------
  371|     41|    {
  372|     41|        TIFFErrorExtR(tif, module, "Computed scanline size is zero");
  373|     41|        return 0;
  374|     41|    }
  375|   136k|    return (scanline_size);
  376|   136k|}
TIFFScanlineSize:
  378|  5.86k|{
  379|  5.86k|    static const char module[] = "TIFFScanlineSize";
  380|  5.86k|    uint64_t m;
  381|  5.86k|    m = TIFFScanlineSize64(tif);
  382|  5.86k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  383|  5.86k|}

TIFFSwabShort:
   34|  5.35k|{
   35|  5.35k|    unsigned char *cp = (unsigned char *)wp;
   36|  5.35k|    unsigned char t;
   37|  5.35k|    assert(sizeof(uint16_t) == 2);
  ------------------
  |  Branch (37:5): [True: 0, Folded]
  |  Branch (37:5): [True: 5.35k, Folded]
  ------------------
   38|  5.35k|    t = cp[1];
   39|  5.35k|    cp[1] = cp[0];
   40|  5.35k|    cp[0] = t;
   41|  5.35k|}
TIFFSwabLong:
   46|  2.08k|{
   47|  2.08k|    unsigned char *cp = (unsigned char *)lp;
   48|  2.08k|    unsigned char t;
   49|  2.08k|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (49:5): [True: 0, Folded]
  |  Branch (49:5): [True: 2.08k, Folded]
  ------------------
   50|  2.08k|    t = cp[3];
   51|  2.08k|    cp[3] = cp[0];
   52|  2.08k|    cp[0] = t;
   53|  2.08k|    t = cp[2];
   54|  2.08k|    cp[2] = cp[1];
   55|  2.08k|    cp[1] = t;
   56|  2.08k|}
TIFFGetBitRevTable:
  306|  6.66k|{
  307|  6.66k|    return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
  ------------------
  |  Branch (307:13): [True: 6.66k, False: 0]
  ------------------
  308|  6.66k|}
TIFFReverseBits:
  311|     36|{
  312|  1.94k|    for (; n > 8; n -= 8)
  ------------------
  |  Branch (312:12): [True: 1.91k, False: 36]
  ------------------
  313|  1.91k|    {
  314|  1.91k|        cp[0] = TIFFBitRevTable[cp[0]];
  315|  1.91k|        cp[1] = TIFFBitRevTable[cp[1]];
  316|  1.91k|        cp[2] = TIFFBitRevTable[cp[2]];
  317|  1.91k|        cp[3] = TIFFBitRevTable[cp[3]];
  318|  1.91k|        cp[4] = TIFFBitRevTable[cp[4]];
  319|  1.91k|        cp[5] = TIFFBitRevTable[cp[5]];
  320|  1.91k|        cp[6] = TIFFBitRevTable[cp[6]];
  321|  1.91k|        cp[7] = TIFFBitRevTable[cp[7]];
  322|  1.91k|        cp += 8;
  323|  1.91k|    }
  324|    270|    while (n-- > 0)
  ------------------
  |  Branch (324:12): [True: 234, False: 36]
  ------------------
  325|    234|    {
  326|    234|        *cp = TIFFBitRevTable[*cp];
  327|    234|        cp++;
  328|    234|    }
  329|     36|}

TIFFInitThunderScan:
  196|     14|{
  197|     14|    (void)scheme;
  198|       |
  199|     14|    tif->tif_setupdecode = ThunderSetupDecode;
  200|     14|    tif->tif_decoderow = ThunderDecodeRow;
  201|     14|    tif->tif_decodestrip = ThunderDecodeRow;
  202|     14|    return (1);
  203|     14|}
tif_thunder.c:ThunderSetupDecode:
   70|      5|{
   71|      5|    static const char module[] = "ThunderSetupDecode";
   72|       |
   73|      5|    if (tif->tif_dir.td_bitspersample != 4)
  ------------------
  |  Branch (73:9): [True: 0, False: 5]
  ------------------
   74|      0|    {
   75|      0|        TIFFErrorExtR(tif, module,
   76|      0|                      "Wrong bitspersample value (%d), Thunder decoder only "
   77|      0|                      "supports 4bits per sample.",
   78|      0|                      (int)tif->tif_dir.td_bitspersample);
   79|      0|        return 0;
   80|      0|    }
   81|       |
   82|      5|    return (1);
   83|      5|}
tif_thunder.c:ThunderDecodeRow:
  175|      5|{
  176|      5|    static const char module[] = "ThunderDecodeRow";
  177|      5|    uint8_t *row = buf;
  178|       |
  179|      5|    (void)s;
  180|      5|    if (occ % tif->tif_dir.td_scanlinesize)
  ------------------
  |  Branch (180:9): [True: 0, False: 5]
  ------------------
  181|      0|    {
  182|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  183|      0|        return (0);
  184|      0|    }
  185|      5|    while (occ > 0)
  ------------------
  |  Branch (185:12): [True: 5, False: 0]
  ------------------
  186|      5|    {
  187|      5|        if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
  ------------------
  |  Branch (187:13): [True: 5, False: 0]
  ------------------
  188|      5|            return (0);
  189|      0|        occ -= tif->tif_dir.td_scanlinesize;
  190|      0|        row += tif->tif_dir.td_scanlinesize;
  191|      0|    }
  192|      0|    return (1);
  193|      5|}
tif_thunder.c:ThunderDecode:
   86|      5|{
   87|      5|    static const char module[] = "ThunderDecode";
   88|      5|    unsigned char *bp;
   89|      5|    tmsize_t cc;
   90|      5|    unsigned int lastpixel;
   91|      5|    tmsize_t npixels;
   92|      5|    uint8_t *op = op0;
   93|       |
   94|      5|    bp = (unsigned char *)tif->tif_rawcp;
   95|      5|    cc = tif->tif_rawcc;
   96|      5|    lastpixel = 0;
   97|      5|    npixels = 0;
   98|  10.2k|    while (cc > 0 && npixels < maxpixels)
  ------------------
  |  Branch (98:12): [True: 10.2k, False: 0]
  |  Branch (98:22): [True: 10.2k, False: 5]
  ------------------
   99|  10.2k|    {
  100|  10.2k|        int n, delta;
  101|       |
  102|  10.2k|        n = *bp++;
  103|  10.2k|        cc--;
  104|  10.2k|        switch (n & THUNDER_CODE)
  ------------------
  |  |   45|  10.2k|#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */
  ------------------
  105|  10.2k|        {
  106|  6.97k|            case THUNDER_RUN: /* pixel run */
  ------------------
  |  |   47|  6.97k|#define THUNDER_RUN 0x00        /* run of pixels w/ encoded count */
  ------------------
  |  Branch (106:13): [True: 6.97k, False: 3.27k]
  ------------------
  107|       |                /*
  108|       |                 * Replicate the last pixel n times,
  109|       |                 * where n is the lower-order 6 bits.
  110|       |                 */
  111|  6.97k|                if (n == 0)
  ------------------
  |  Branch (111:21): [True: 3.39k, False: 3.58k]
  ------------------
  112|  3.39k|                    break;
  113|  3.58k|                if (npixels & 1)
  ------------------
  |  Branch (113:21): [True: 1.80k, False: 1.78k]
  ------------------
  114|  1.80k|                {
  115|  1.80k|                    op[0] |= (uint8_t)lastpixel;
  116|  1.80k|                    lastpixel = *op++;
  117|  1.80k|                    npixels++;
  118|  1.80k|                    n--;
  119|  1.80k|                }
  120|  1.78k|                else
  121|  1.78k|                    lastpixel |= lastpixel << 4;
  122|  3.58k|                npixels += n;
  123|  3.58k|                if (npixels > maxpixels)
  ------------------
  |  Branch (123:21): [True: 5, False: 3.58k]
  ------------------
  124|      5|                    break;
  125|  33.7k|                for (; n > 0; n -= 2)
  ------------------
  |  Branch (125:24): [True: 30.1k, False: 3.58k]
  ------------------
  126|  30.1k|                    *op++ = (uint8_t)lastpixel;
  127|  3.58k|                if (n == -1)
  ------------------
  |  Branch (127:21): [True: 1.79k, False: 1.78k]
  ------------------
  128|  1.79k|                    *--op &= 0xf0;
  129|  3.58k|                lastpixel &= 0xf;
  130|  3.58k|                break;
  131|    828|            case THUNDER_2BITDELTAS: /* 2-bit deltas */
  ------------------
  |  |   48|    828|#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */
  ------------------
  |  Branch (131:13): [True: 828, False: 9.42k]
  ------------------
  132|    828|                if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    828|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (132:21): [True: 728, False: 100]
  ------------------
  133|    728|                    SETPIXEL(op,
  ------------------
  |  |   58|    728|    {                                                                          \
  |  |   59|    728|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    728|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 728, False: 0]
  |  |  ------------------
  |  |   61|    728|        {                                                                      \
  |  |   62|    728|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 362, False: 366]
  |  |  ------------------
  |  |   63|    728|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    728|            else                                                               \
  |  |   65|    728|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    728|        }                                                                      \
  |  |   67|    728|    }
  ------------------
  134|    828|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  135|    828|                if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    828|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (135:21): [True: 657, False: 171]
  ------------------
  136|    657|                    SETPIXEL(op,
  ------------------
  |  |   58|    657|    {                                                                          \
  |  |   59|    657|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    657|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 657, False: 0]
  |  |  ------------------
  |  |   61|    657|        {                                                                      \
  |  |   62|    657|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 341, False: 316]
  |  |  ------------------
  |  |   63|    657|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    657|            else                                                               \
  |  |   65|    657|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    657|        }                                                                      \
  |  |   67|    657|    }
  ------------------
  137|    828|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  138|    828|                if ((delta = (n & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    828|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (138:21): [True: 769, False: 59]
  ------------------
  139|    769|                    SETPIXEL(op,
  ------------------
  |  |   58|    769|    {                                                                          \
  |  |   59|    769|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    769|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 769, False: 0]
  |  |  ------------------
  |  |   61|    769|        {                                                                      \
  |  |   62|    769|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 371, False: 398]
  |  |  ------------------
  |  |   63|    769|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    769|            else                                                               \
  |  |   65|    769|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    769|        }                                                                      \
  |  |   67|    769|    }
  ------------------
  140|    828|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  141|    828|                break;
  142|    990|            case THUNDER_3BITDELTAS: /* 3-bit deltas */
  ------------------
  |  |   50|    990|#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */
  ------------------
  |  Branch (142:13): [True: 990, False: 9.26k]
  ------------------
  143|    990|                if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
  ------------------
  |  |   51|    990|#define DELTA3_SKIP 4           /* skip code for 3-bit deltas */
  ------------------
  |  Branch (143:21): [True: 861, False: 129]
  ------------------
  144|    861|                    SETPIXEL(
  ------------------
  |  |   58|    861|    {                                                                          \
  |  |   59|    861|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    861|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 861, False: 0]
  |  |  ------------------
  |  |   61|    861|        {                                                                      \
  |  |   62|    861|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 449, False: 412]
  |  |  ------------------
  |  |   63|    861|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    861|            else                                                               \
  |  |   65|    861|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    861|        }                                                                      \
  |  |   67|    861|    }
  ------------------
  145|    990|                        op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
  146|    990|                if ((delta = (n & 7)) != DELTA3_SKIP)
  ------------------
  |  |   51|    990|#define DELTA3_SKIP 4           /* skip code for 3-bit deltas */
  ------------------
  |  Branch (146:21): [True: 896, False: 94]
  ------------------
  147|    896|                    SETPIXEL(
  ------------------
  |  |   58|    896|    {                                                                          \
  |  |   59|    896|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    896|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 896, False: 0]
  |  |  ------------------
  |  |   61|    896|        {                                                                      \
  |  |   62|    896|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 433, False: 463]
  |  |  ------------------
  |  |   63|    896|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    896|            else                                                               \
  |  |   65|    896|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    896|        }                                                                      \
  |  |   67|    896|    }
  ------------------
  148|    990|                        op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
  149|    990|                break;
  150|  1.45k|            case THUNDER_RAW: /* raw data */
  ------------------
  |  |   52|  1.45k|#define THUNDER_RAW 0xc0        /* raw data encoded */
  ------------------
  |  Branch (150:13): [True: 1.45k, False: 8.79k]
  ------------------
  151|  1.45k|                SETPIXEL(op, n);
  ------------------
  |  |   58|  1.45k|    {                                                                          \
  |  |   59|  1.45k|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|  1.45k|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 1.45k, False: 0]
  |  |  ------------------
  |  |   61|  1.45k|        {                                                                      \
  |  |   62|  1.45k|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 724, False: 735]
  |  |  ------------------
  |  |   63|  1.45k|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|  1.45k|            else                                                               \
  |  |   65|  1.45k|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|  1.45k|        }                                                                      \
  |  |   67|  1.45k|    }
  ------------------
  152|  1.45k|                break;
  153|      0|            default:
  ------------------
  |  Branch (153:13): [True: 0, False: 10.2k]
  ------------------
  154|      0|                break;
  155|  10.2k|        }
  156|  10.2k|    }
  157|      5|    tif->tif_rawcp = (uint8_t *)bp;
  158|      5|    tif->tif_rawcc = cc;
  159|      5|    if (npixels != maxpixels)
  ------------------
  |  Branch (159:9): [True: 5, False: 0]
  ------------------
  160|      5|    {
  161|      5|        uint8_t *op_end = op0 + (maxpixels + 1) / 2;
  162|      5|        memset(op, 0, (size_t)(op_end - op));
  163|      5|        TIFFErrorExtR(tif, module,
  164|      5|                      "%s data at scanline %lu (%" PRIu64 " != %" PRIu64 ")",
  165|      5|                      npixels < maxpixels ? "Not enough" : "Too much",
  ------------------
  |  Branch (165:23): [True: 0, False: 5]
  ------------------
  166|      5|                      (unsigned long)tif->tif_dir.td_row, (uint64_t)npixels,
  167|      5|                      (uint64_t)maxpixels);
  168|      5|        return (0);
  169|      5|    }
  170|       |
  171|      0|    return (1);
  172|      5|}

TIFFComputeTile:
   37|  61.2k|{
   38|  61.2k|    TIFFDirectory *td = &tif->tif_dir;
   39|  61.2k|    uint32_t dx = td->td_tilewidth;
   40|  61.2k|    uint32_t dy = td->td_tilelength;
   41|  61.2k|    uint32_t dz = td->td_tiledepth;
   42|  61.2k|    uint32_t tile = 1;
   43|       |
   44|  61.2k|    if (td->td_imagedepth == 1)
  ------------------
  |  Branch (44:9): [True: 61.2k, False: 0]
  ------------------
   45|  61.2k|        z = 0;
   46|  61.2k|    if (dx == (uint32_t)-1)
  ------------------
  |  Branch (46:9): [True: 0, False: 61.2k]
  ------------------
   47|      0|        dx = td->td_imagewidth;
   48|  61.2k|    if (dy == (uint32_t)-1)
  ------------------
  |  Branch (48:9): [True: 4, False: 61.2k]
  ------------------
   49|      4|        dy = td->td_imagelength;
   50|  61.2k|    if (dz == (uint32_t)-1)
  ------------------
  |  Branch (50:9): [True: 22, False: 61.1k]
  ------------------
   51|     22|        dz = td->td_imagedepth;
   52|  61.2k|    if (dx != 0 && dy != 0 && dz != 0)
  ------------------
  |  Branch (52:9): [True: 61.2k, False: 0]
  |  Branch (52:20): [True: 61.2k, False: 0]
  |  Branch (52:31): [True: 61.2k, False: 0]
  ------------------
   53|  61.2k|    {
   54|  61.2k|        uint32_t xpt = TIFFhowmany_32(td->td_imagewidth, dx);
  ------------------
  |  |  312|  61.2k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 61.2k, False: 0]
  |  |  ------------------
  |  |  313|  61.2k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  61.2k|         : 0U)
  ------------------
   55|  61.2k|        uint32_t ypt = TIFFhowmany_32(td->td_imagelength, dy);
  ------------------
  |  |  312|  61.2k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 61.2k, False: 0]
  |  |  ------------------
  |  |  313|  61.2k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  61.2k|         : 0U)
  ------------------
   56|  61.2k|        uint32_t zpt = TIFFhowmany_32(td->td_imagedepth, dz);
  ------------------
  |  |  312|  61.2k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 61.2k, False: 0]
  |  |  ------------------
  |  |  313|  61.2k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  61.2k|         : 0U)
  ------------------
   57|  61.2k|        uint32_t xpt_ypt = _TIFFMultiply32(tif, xpt, ypt, "TIFFComputeTile");
   58|  61.2k|        uint32_t xpt_ypt_zpt =
   59|  61.2k|            _TIFFMultiply32(tif, xpt_ypt, zpt, "TIFFComputeTile");
   60|  61.2k|        uint64_t z_offset;
   61|  61.2k|        uint64_t y_offset;
   62|  61.2k|        uint64_t tile64;
   63|       |
   64|  61.2k|        if ((xpt_ypt == 0 && xpt != 0 && ypt != 0) ||
  ------------------
  |  Branch (64:14): [True: 0, False: 61.2k]
  |  Branch (64:30): [True: 0, False: 0]
  |  Branch (64:42): [True: 0, False: 0]
  ------------------
   65|  61.2k|            (xpt_ypt_zpt == 0 && xpt_ypt != 0 && zpt != 0))
  ------------------
  |  Branch (65:14): [True: 0, False: 61.2k]
  |  Branch (65:34): [True: 0, False: 0]
  |  Branch (65:50): [True: 0, False: 0]
  ------------------
   66|      0|            return (0);
   67|       |
   68|  61.2k|        z_offset = _TIFFMultiply64(tif, xpt_ypt, z / dz, "TIFFComputeTile");
   69|  61.2k|        y_offset = _TIFFMultiply64(tif, xpt, y / dy, "TIFFComputeTile");
   70|  61.2k|        if ((z_offset == 0 && xpt_ypt != 0 && (z / dz) != 0) ||
  ------------------
  |  Branch (70:14): [True: 61.2k, False: 0]
  |  Branch (70:31): [True: 61.2k, False: 0]
  |  Branch (70:47): [True: 0, False: 61.2k]
  ------------------
   71|  61.2k|            (y_offset == 0 && xpt != 0 && (y / dy) != 0))
  ------------------
  |  Branch (71:14): [True: 13.0k, False: 48.2k]
  |  Branch (71:31): [True: 13.0k, False: 0]
  |  Branch (71:43): [True: 0, False: 13.0k]
  ------------------
   72|      0|            return (0);
   73|  61.2k|        tile64 = _TIFFAdd64(tif, z_offset, y_offset, "TIFFComputeTile");
   74|  61.2k|        if (tile64 == 0 && (z_offset != 0 || y_offset != 0))
  ------------------
  |  Branch (74:13): [True: 13.0k, False: 48.2k]
  |  Branch (74:29): [True: 0, False: 13.0k]
  |  Branch (74:46): [True: 0, False: 13.0k]
  ------------------
   75|      0|            return (0);
   76|  61.2k|        tile64 = _TIFFAdd64(tif, tile64, x / dx, "TIFFComputeTile");
   77|  61.2k|        if (tile64 == 0 && (z_offset != 0 || y_offset != 0 || (x / dx) != 0))
  ------------------
  |  Branch (77:13): [True: 506, False: 60.7k]
  |  Branch (77:29): [True: 0, False: 506]
  |  Branch (77:46): [True: 0, False: 506]
  |  Branch (77:63): [True: 0, False: 506]
  ------------------
   78|      0|            return (0);
   79|  61.2k|        if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|  61.2k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (79:13): [True: 55.7k, False: 5.47k]
  ------------------
   80|  55.7k|        {
   81|  55.7k|            uint64_t sample_offset;
   82|  55.7k|            if (s >= td->td_samplesperpixel)
  ------------------
  |  Branch (82:17): [True: 0, False: 55.7k]
  ------------------
   83|      0|            {
   84|      0|                TIFFErrorExtR(
   85|      0|                    tif, "TIFFComputeTile", "%lu: Sample out of range, max %lu",
   86|      0|                    (unsigned long)s, (unsigned long)td->td_samplesperpixel);
   87|      0|                return (0);
   88|      0|            }
   89|  55.7k|            sample_offset =
   90|  55.7k|                _TIFFMultiply64(tif, xpt_ypt_zpt, s, "TIFFComputeTile");
   91|  55.7k|            if (sample_offset == 0 && xpt_ypt_zpt != 0 && s != 0)
  ------------------
  |  Branch (91:17): [True: 19.0k, False: 36.6k]
  |  Branch (91:39): [True: 19.0k, False: 0]
  |  Branch (91:59): [True: 0, False: 19.0k]
  ------------------
   92|      0|                return (0);
   93|  55.7k|            tile64 = _TIFFAdd64(tif, sample_offset, tile64, "TIFFComputeTile");
   94|  55.7k|            if (tile64 == 0 && (sample_offset != 0 || z_offset != 0 ||
  ------------------
  |  Branch (94:17): [True: 157, False: 55.5k]
  |  Branch (94:33): [True: 0, False: 157]
  |  Branch (94:55): [True: 0, False: 157]
  ------------------
   95|    157|                                y_offset != 0 || (x / dx) != 0))
  ------------------
  |  Branch (95:33): [True: 0, False: 157]
  |  Branch (95:50): [True: 0, False: 157]
  ------------------
   96|      0|                return (0);
   97|  55.7k|        }
   98|  61.2k|        tile = _TIFFCastUInt64ToUInt32(tif, tile64, "TIFFComputeTile");
   99|  61.2k|        if (tile == 0 && tile64 != 0)
  ------------------
  |  Branch (99:13): [True: 328, False: 60.8k]
  |  Branch (99:26): [True: 0, False: 328]
  ------------------
  100|      0|            return (0);
  101|  61.2k|    }
  102|  61.2k|    return (tile);
  103|  61.2k|}
TIFFCheckTile:
  110|  61.3k|{
  111|  61.3k|    TIFFDirectory *td = &tif->tif_dir;
  112|       |
  113|  61.3k|    if (x >= td->td_imagewidth)
  ------------------
  |  Branch (113:9): [True: 0, False: 61.3k]
  ------------------
  114|      0|    {
  115|      0|        TIFFErrorExtR(tif, tif->tif_name, "%lu: Col out of range, max %lu",
  116|      0|                      (unsigned long)x, (unsigned long)(td->td_imagewidth - 1));
  117|      0|        return (0);
  118|      0|    }
  119|  61.3k|    if (y >= td->td_imagelength)
  ------------------
  |  Branch (119:9): [True: 0, False: 61.3k]
  ------------------
  120|      0|    {
  121|      0|        TIFFErrorExtR(tif, tif->tif_name, "%lu: Row out of range, max %lu",
  122|      0|                      (unsigned long)y,
  123|      0|                      (unsigned long)(td->td_imagelength - 1));
  124|      0|        return (0);
  125|      0|    }
  126|  61.3k|    if (z >= td->td_imagedepth)
  ------------------
  |  Branch (126:9): [True: 0, False: 61.3k]
  ------------------
  127|      0|    {
  128|      0|        TIFFErrorExtR(tif, tif->tif_name, "%lu: Depth out of range, max %lu",
  129|      0|                      (unsigned long)z, (unsigned long)(td->td_imagedepth - 1));
  130|      0|        return (0);
  131|      0|    }
  132|  61.3k|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE &&
  ------------------
  |  |  266|   122k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (132:9): [True: 55.8k, False: 5.47k]
  ------------------
  133|  55.8k|        s >= td->td_samplesperpixel)
  ------------------
  |  Branch (133:9): [True: 85, False: 55.7k]
  ------------------
  134|     85|    {
  135|     85|        TIFFErrorExtR(tif, tif->tif_name, "%lu: Sample out of range, max %lu",
  136|     85|                      (unsigned long)s,
  137|     85|                      (unsigned long)(td->td_samplesperpixel - 1));
  138|     85|        return (0);
  139|     85|    }
  140|  61.2k|    return (1);
  141|  61.3k|}
TIFFNumberOfTiles:
  147|  1.28k|{
  148|  1.28k|    TIFFDirectory *td = &tif->tif_dir;
  149|  1.28k|    uint32_t dx = td->td_tilewidth;
  150|  1.28k|    uint32_t dy = td->td_tilelength;
  151|  1.28k|    uint32_t dz = td->td_tiledepth;
  152|  1.28k|    uint32_t ntiles;
  153|       |
  154|  1.28k|    if (dx == (uint32_t)-1)
  ------------------
  |  Branch (154:9): [True: 4, False: 1.28k]
  ------------------
  155|      4|        dx = td->td_imagewidth;
  156|  1.28k|    if (dy == (uint32_t)-1)
  ------------------
  |  Branch (156:9): [True: 4, False: 1.28k]
  ------------------
  157|      4|        dy = td->td_imagelength;
  158|  1.28k|    if (dz == (uint32_t)-1)
  ------------------
  |  Branch (158:9): [True: 2, False: 1.28k]
  ------------------
  159|      2|        dz = td->td_imagedepth;
  160|  1.28k|    ntiles =
  161|  1.28k|        (dx == 0 || dy == 0 || dz == 0)
  ------------------
  |  Branch (161:10): [True: 2, False: 1.28k]
  |  Branch (161:21): [True: 0, False: 1.28k]
  |  Branch (161:32): [True: 0, False: 1.28k]
  ------------------
  162|  1.28k|            ? 0
  163|  1.28k|            : _TIFFMultiply32(
  164|  1.28k|                  tif,
  165|  1.28k|                  _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
  ------------------
  |  |  312|  1.28k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 1.28k, False: 0]
  |  |  ------------------
  |  |  313|  1.28k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  1.28k|         : 0U)
  ------------------
  166|  1.28k|                                  TIFFhowmany_32(td->td_imagelength, dy),
  ------------------
  |  |  312|  1.28k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 1.28k, False: 0]
  |  |  ------------------
  |  |  313|  1.28k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  1.28k|         : 0U)
  ------------------
  167|  1.28k|                                  "TIFFNumberOfTiles"),
  168|  1.28k|                  TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
  ------------------
  |  |  312|  1.28k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 1.28k, False: 0]
  |  |  ------------------
  |  |  313|  1.28k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  1.28k|         : 0U)
  ------------------
  169|  1.28k|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|  1.28k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (169:9): [True: 714, False: 574]
  ------------------
  170|    714|        ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
  171|    714|                                 "TIFFNumberOfTiles");
  172|  1.28k|    return (ntiles);
  173|  1.28k|}
TIFFTileRowSize64:
  179|  35.4k|{
  180|  35.4k|    static const char module[] = "TIFFTileRowSize64";
  181|  35.4k|    TIFFDirectory *td = &tif->tif_dir;
  182|  35.4k|    uint64_t rowsize;
  183|  35.4k|    uint64_t tilerowsize;
  184|       |
  185|  35.4k|    if (td->td_tilelength == 0)
  ------------------
  |  Branch (185:9): [True: 0, False: 35.4k]
  ------------------
  186|      0|    {
  187|      0|        TIFFErrorExtR(tif, module, "Tile length is zero");
  188|      0|        return 0;
  189|      0|    }
  190|  35.4k|    if (td->td_tilewidth == 0)
  ------------------
  |  Branch (190:9): [True: 0, False: 35.4k]
  ------------------
  191|      0|    {
  192|      0|        TIFFErrorExtR(tif, module, "Tile width is zero");
  193|      0|        return (0);
  194|      0|    }
  195|  35.4k|    rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
  196|  35.4k|                              "TIFFTileRowSize");
  197|  35.4k|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|  35.4k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (197:9): [True: 14.5k, False: 20.8k]
  ------------------
  198|  14.5k|    {
  199|  14.5k|        if (td->td_samplesperpixel == 0)
  ------------------
  |  Branch (199:13): [True: 0, False: 14.5k]
  ------------------
  200|      0|        {
  201|      0|            TIFFErrorExtR(tif, module, "Samples per pixel is zero");
  202|      0|            return 0;
  203|      0|        }
  204|  14.5k|        rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
  205|  14.5k|                                  "TIFFTileRowSize");
  206|  14.5k|    }
  207|  35.4k|    tilerowsize = TIFFhowmany8_64(rowsize);
  ------------------
  |  |  326|  35.4k|    (((x) & 0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
  |  |  ------------------
  |  |  |  Branch (326:6): [True: 3.66k, False: 31.7k]
  |  |  ------------------
  ------------------
  208|  35.4k|    if (tilerowsize == 0)
  ------------------
  |  Branch (208:9): [True: 0, False: 35.4k]
  ------------------
  209|      0|    {
  210|      0|        TIFFErrorExtR(tif, module, "Computed tile row size is zero");
  211|      0|        return 0;
  212|      0|    }
  213|  35.4k|    return (tilerowsize);
  214|  35.4k|}
TIFFTileRowSize:
  216|  24.3k|{
  217|  24.3k|    static const char module[] = "TIFFTileRowSize";
  218|  24.3k|    uint64_t m;
  219|  24.3k|    m = TIFFTileRowSize64(tif);
  220|  24.3k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  221|  24.3k|}
TIFFVTileSize64:
  227|  11.3k|{
  228|  11.3k|    return _TIFFStrileSize64(tif, nrows, /* isStrip = */ FALSE);
  ------------------
  |  |   72|  11.3k|#define FALSE 0
  ------------------
  229|  11.3k|}
TIFFTileSize64:
  243|  11.2k|{
  244|  11.2k|    return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
  245|  11.2k|}
TIFFTileSize:
  247|  11.2k|{
  248|  11.2k|    static const char module[] = "TIFFTileSize";
  249|  11.2k|    uint64_t m;
  250|  11.2k|    m = TIFFTileSize64(tif);
  251|  11.2k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  252|  11.2k|}

_TIFFmalloc:
  335|   399k|{
  336|   399k|    if (s == 0)
  ------------------
  |  Branch (336:9): [True: 0, False: 399k]
  ------------------
  337|      0|        return ((void *)NULL);
  338|       |
  339|   399k|    return (malloc((size_t)s));
  340|   399k|}
_TIFFcalloc:
  343|    766|{
  344|    766|    if (nmemb == 0 || siz == 0)
  ------------------
  |  Branch (344:9): [True: 0, False: 766]
  |  Branch (344:23): [True: 0, False: 766]
  ------------------
  345|      0|        return ((void *)NULL);
  346|       |
  347|    766|    return calloc((size_t)nmemb, (size_t)siz);
  348|    766|}
_TIFFfree:
  350|   447k|void _TIFFfree(void *p) { free(p); }
_TIFFrealloc:
  352|   242k|void *_TIFFrealloc(void *p, tmsize_t s) { return (realloc(p, (size_t)s)); }
_TIFFmemset:
  354|   210k|void _TIFFmemset(void *p, int v, tmsize_t c) { memset(p, v, (size_t)c); }
_TIFFmemcpy:
  357|   379k|{
  358|   379k|    memcpy(d, s, (size_t)c);
  359|   379k|}

TIFFSetWarningHandler:
   33|  1.28k|{
   34|  1.28k|    TIFFErrorHandler prev = _TIFFwarningHandler;
   35|  1.28k|    _TIFFwarningHandler = handler;
   36|  1.28k|    return (prev);
   37|  1.28k|}
TIFFWarningExtR:
   81|   225k|{
   82|   225k|    va_list ap;
   83|   225k|    if (tif && tif->tif_warnhandler)
  ------------------
  |  Branch (83:9): [True: 225k, False: 0]
  |  Branch (83:16): [True: 0, False: 225k]
  ------------------
   84|      0|    {
   85|      0|        va_start(ap, fmt);
   86|      0|        int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data,
   87|      0|                                           module, fmt, ap);
   88|      0|        va_end(ap);
   89|      0|        if (stop)
  ------------------
  |  Branch (89:13): [True: 0, False: 0]
  ------------------
   90|      0|            return;
   91|      0|    }
   92|   225k|    if (_TIFFwarningHandler)
  ------------------
  |  Branch (92:9): [True: 225k, False: 0]
  ------------------
   93|   225k|    {
   94|   225k|        va_start(ap, fmt);
   95|   225k|        (*_TIFFwarningHandler)(module, fmt, ap);
   96|   225k|        va_end(ap);
   97|   225k|    }
   98|   225k|    if (_TIFFwarningHandlerExt)
  ------------------
  |  Branch (98:9): [True: 0, False: 225k]
  ------------------
   99|      0|    {
  100|      0|        va_start(ap, fmt);
  101|      0|        (*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt,
  ------------------
  |  Branch (101:35): [True: 0, False: 0]
  ------------------
  102|      0|                                  ap);
  103|       |        va_end(ap);
  104|      0|    }
  105|   225k|}

TIFFInitZIP:
  711|     28|{
  712|     28|    static const char module[] = "TIFFInitZIP";
  713|     28|    ZIPState *sp;
  714|       |
  715|     28|    assert((scheme == COMPRESSION_DEFLATE) ||
  ------------------
  |  Branch (715:5): [True: 28, False: 0]
  |  Branch (715:5): [True: 0, False: 0]
  |  Branch (715:5): [True: 6, False: 22]
  |  Branch (715:5): [True: 22, False: 0]
  ------------------
  716|     28|           (scheme == COMPRESSION_ADOBE_DEFLATE));
  717|       |#ifdef NDEBUG
  718|       |    (void)scheme;
  719|       |#endif
  720|       |
  721|       |    /*
  722|       |     * Merge codec-specific tag information.
  723|       |     */
  724|     28|    if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields)))
  ------------------
  |  |  339|     28|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (724:9): [True: 0, False: 28]
  ------------------
  725|      0|    {
  726|      0|        TIFFErrorExtR(tif, module,
  727|      0|                      "Merging Deflate codec-specific tags failed");
  728|      0|        return 0;
  729|      0|    }
  730|       |
  731|       |    /*
  732|       |     * Allocate state block so tag methods have storage to record values.
  733|       |     */
  734|     28|    tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, sizeof(ZIPState), 1);
  735|     28|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (735:9): [True: 0, False: 28]
  ------------------
  736|      0|        goto bad;
  737|     28|    sp = GetZIPState(tif);
  ------------------
  |  |   88|     28|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  738|     28|    sp->stream.zalloc = TIFF_zalloc;
  739|     28|    sp->stream.zfree = TIFF_zfree;
  740|     28|    sp->stream.opaque = tif;
  741|     28|    sp->stream.data_type = Z_BINARY;
  742|       |
  743|       |    /*
  744|       |     * Override parent get/set field methods.
  745|       |     */
  746|     28|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
  747|     28|    tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
  748|     28|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
  749|     28|    tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */
  750|       |
  751|       |    /* Default values for codec-specific fields */
  752|     28|    sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
  753|     28|    sp->state = 0;
  754|       |#if LIBDEFLATE_SUPPORT
  755|       |    sp->subcodec = DEFLATE_SUBCODEC_LIBDEFLATE;
  756|       |#else
  757|     28|    sp->subcodec = DEFLATE_SUBCODEC_ZLIB;
  ------------------
  |  |  767|     28|#define DEFLATE_SUBCODEC_ZLIB 0
  ------------------
  758|     28|#endif
  759|       |
  760|       |    /*
  761|       |     * Install codec methods.
  762|       |     */
  763|     28|    tif->tif_fixuptags = ZIPFixupTags;
  764|     28|    tif->tif_setupdecode = ZIPSetupDecode;
  765|     28|    tif->tif_predecode = ZIPPreDecode;
  766|     28|    tif->tif_decoderow = ZIPDecode;
  767|     28|    tif->tif_decodestrip = ZIPDecode;
  768|     28|    tif->tif_decodetile = ZIPDecode;
  769|     28|    tif->tif_setupencode = ZIPSetupEncode;
  770|     28|    tif->tif_preencode = ZIPPreEncode;
  771|     28|    tif->tif_postencode = ZIPPostEncode;
  772|     28|    tif->tif_encoderow = ZIPEncode;
  773|     28|    tif->tif_encodestrip = ZIPEncode;
  774|     28|    tif->tif_encodetile = ZIPEncode;
  775|     28|    tif->tif_cleanup = ZIPCleanup;
  776|     28|    tif->tif_getmaxcompressionratio = ZIPGetMaxCompressionRatio;
  777|       |    /*
  778|       |     * Setup predictor setup.
  779|       |     */
  780|     28|    (void)TIFFPredictorInit(tif);
  781|     28|    return (1);
  782|      0|bad:
  783|      0|    TIFFErrorExtR(tif, module, "No space for ZIP state block");
  784|      0|    return (0);
  785|     28|}
tif_zip.c:TIFF_zalloc:
  685|     17|{
  686|     17|    static const char module[] = "TIFF_zalloc";
  687|     17|    TIFF *tif = (TIFF *)opaque;
  688|       |
  689|     17|    if (items > ~(size_t)0 / size)
  ------------------
  |  Branch (689:9): [True: 0, False: 17]
  ------------------
  690|      0|    {
  691|      0|        TIFFErrorExtR(tif, module, "Overflow");
  692|      0|        return NULL;
  693|      0|    }
  694|       |
  695|     17|    return _TIFFmallocExt(tif, items * size);
  696|     17|}
tif_zip.c:TIFF_zfree:
  699|     17|{
  700|     17|    _TIFFfreeExt((TIFF *)opaque, ptr);
  701|     17|}
tif_zip.c:ZIPVGetField:
  658|    215|{
  659|    215|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|    215|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  660|       |
  661|    215|    switch (tag)
  662|    215|    {
  663|      0|        case TIFFTAG_ZIPQUALITY:
  ------------------
  |  |  739|      0|#define TIFFTAG_ZIPQUALITY 65557      /* compression quality level */
  ------------------
  |  Branch (663:9): [True: 0, False: 215]
  ------------------
  664|      0|            *va_arg(ap, int *) = sp->zipquality;
  665|      0|            break;
  666|       |
  667|      0|        case TIFFTAG_DEFLATE_SUBCODEC:
  ------------------
  |  |  766|      0|#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */
  ------------------
  |  Branch (667:9): [True: 0, False: 215]
  ------------------
  668|      0|            *va_arg(ap, int *) = sp->subcodec;
  669|      0|            break;
  670|       |
  671|    215|        default:
  ------------------
  |  Branch (671:9): [True: 215, False: 0]
  ------------------
  672|    215|            return (*sp->vgetparent)(tif, tag, ap);
  673|    215|    }
  674|      0|    return (1);
  675|    215|}
tif_zip.c:ZIPVSetField:
  591|    369|{
  592|    369|    static const char module[] = "ZIPVSetField";
  593|    369|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|    369|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  594|       |
  595|    369|    switch (tag)
  596|    369|    {
  597|      0|        case TIFFTAG_ZIPQUALITY:
  ------------------
  |  |  739|      0|#define TIFFTAG_ZIPQUALITY 65557      /* compression quality level */
  ------------------
  |  Branch (597:9): [True: 0, False: 369]
  ------------------
  598|      0|            sp->zipquality = (int)va_arg(ap, int);
  599|      0|            if (sp->zipquality < Z_DEFAULT_COMPRESSION ||
  ------------------
  |  Branch (599:17): [True: 0, False: 0]
  ------------------
  600|      0|                sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL)
  ------------------
  |  |   46|      0|#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12
  ------------------
  |  Branch (600:17): [True: 0, False: 0]
  ------------------
  601|      0|            {
  602|      0|                TIFFErrorExtR(
  603|      0|                    tif, module,
  604|      0|                    "Invalid ZipQuality value. Should be in [-1,%d] range",
  605|      0|                    LIBDEFLATE_MAX_COMPRESSION_LEVEL);
  ------------------
  |  |   46|      0|#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12
  ------------------
  606|      0|                return 0;
  607|      0|            }
  608|       |
  609|      0|            if (sp->state & ZSTATE_INIT_ENCODE)
  ------------------
  |  |   82|      0|#define ZSTATE_INIT_ENCODE 0x02
  ------------------
  |  Branch (609:17): [True: 0, False: 0]
  ------------------
  610|      0|            {
  611|      0|                int cappedQuality = sp->zipquality;
  612|      0|                if (cappedQuality > Z_BEST_COMPRESSION)
  ------------------
  |  Branch (612:21): [True: 0, False: 0]
  ------------------
  613|      0|                    cappedQuality = Z_BEST_COMPRESSION;
  614|      0|                if (deflateParams(&sp->stream, cappedQuality,
  ------------------
  |  Branch (614:21): [True: 0, False: 0]
  ------------------
  615|      0|                                  Z_DEFAULT_STRATEGY) != Z_OK)
  616|      0|                {
  617|      0|                    TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp));
  ------------------
  |  |   60|      0|#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  618|      0|                    return (0);
  619|      0|                }
  620|      0|            }
  621|       |
  622|       |#if LIBDEFLATE_SUPPORT
  623|       |            if (sp->libdeflate_enc)
  624|       |            {
  625|       |                libdeflate_free_compressor(sp->libdeflate_enc);
  626|       |                sp->libdeflate_enc = NULL;
  627|       |            }
  628|       |#endif
  629|       |
  630|      0|            return (1);
  631|       |
  632|      0|        case TIFFTAG_DEFLATE_SUBCODEC:
  ------------------
  |  |  766|      0|#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */
  ------------------
  |  Branch (632:9): [True: 0, False: 369]
  ------------------
  633|      0|            sp->subcodec = (int)va_arg(ap, int);
  634|      0|            if (sp->subcodec != DEFLATE_SUBCODEC_ZLIB &&
  ------------------
  |  |  767|      0|#define DEFLATE_SUBCODEC_ZLIB 0
  ------------------
  |  Branch (634:17): [True: 0, False: 0]
  ------------------
  635|      0|                sp->subcodec != DEFLATE_SUBCODEC_LIBDEFLATE)
  ------------------
  |  |  768|      0|#define DEFLATE_SUBCODEC_LIBDEFLATE 1
  ------------------
  |  Branch (635:17): [True: 0, False: 0]
  ------------------
  636|      0|            {
  637|      0|                TIFFErrorExtR(tif, module, "Invalid DeflateCodec value.");
  638|      0|                return 0;
  639|      0|            }
  640|      0|#if !LIBDEFLATE_SUPPORT
  641|      0|            if (sp->subcodec == DEFLATE_SUBCODEC_LIBDEFLATE)
  ------------------
  |  |  768|      0|#define DEFLATE_SUBCODEC_LIBDEFLATE 1
  ------------------
  |  Branch (641:17): [True: 0, False: 0]
  ------------------
  642|      0|            {
  643|      0|                TIFFErrorExtR(tif, module,
  644|      0|                              "DeflateCodec = DEFLATE_SUBCODEC_LIBDEFLATE "
  645|      0|                              "unsupported in this build");
  646|      0|                return 0;
  647|      0|            }
  648|      0|#endif
  649|      0|            return 1;
  650|       |
  651|    369|        default:
  ------------------
  |  Branch (651:9): [True: 369, False: 0]
  ------------------
  652|    369|            return (*sp->vsetparent)(tif, tag, ap);
  653|    369|    }
  654|       |    /*NOTREACHED*/
  655|    369|}
tif_zip.c:ZIPFixupTags:
   96|     26|{
   97|     26|    (void)tif;
   98|     26|    return (1);
   99|     26|}
tif_zip.c:ZIPSetupDecode:
  102|     17|{
  103|     17|    static const char module[] = "ZIPSetupDecode";
  104|     17|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|     17|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|     17|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  105|       |
  106|     17|    assert(sp != NULL);
  ------------------
  |  Branch (106:5): [True: 0, False: 17]
  |  Branch (106:5): [True: 17, False: 0]
  ------------------
  107|       |
  108|       |    /* if we were last encoding, terminate this mode */
  109|     17|    if (sp->state & ZSTATE_INIT_ENCODE)
  ------------------
  |  |   82|     17|#define ZSTATE_INIT_ENCODE 0x02
  ------------------
  |  Branch (109:9): [True: 0, False: 17]
  ------------------
  110|      0|    {
  111|      0|        deflateEnd(&sp->stream);
  112|      0|        sp->state = 0;
  113|      0|    }
  114|       |
  115|       |    /* This function can possibly be called several times by */
  116|       |    /* PredictorSetupDecode() if this function succeeds but */
  117|       |    /* PredictorSetup() fails */
  118|     17|    if ((sp->state & ZSTATE_INIT_DECODE) == 0 &&
  ------------------
  |  |   81|     17|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (118:9): [True: 17, False: 0]
  ------------------
  119|     17|        inflateInit(&sp->stream) != Z_OK)
  ------------------
  |  Branch (119:9): [True: 0, False: 17]
  ------------------
  120|      0|    {
  121|      0|        TIFFErrorExtR(tif, module, "%s", SAFE_MSG(sp));
  ------------------
  |  |   60|      0|#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  122|      0|        return (0);
  123|      0|    }
  124|     17|    else
  125|     17|    {
  126|     17|        sp->state |= ZSTATE_INIT_DECODE;
  ------------------
  |  |   81|     17|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  127|     17|        return (1);
  128|     17|    }
  129|     17|}
tif_zip.c:ZIPPreDecode:
  145|     17|{
  146|     17|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|     17|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|     17|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  147|       |
  148|     17|    (void)s;
  149|     17|    assert(sp != NULL);
  ------------------
  |  Branch (149:5): [True: 0, False: 17]
  |  Branch (149:5): [True: 17, False: 0]
  ------------------
  150|       |
  151|     17|    if ((sp->state & ZSTATE_INIT_DECODE) == 0)
  ------------------
  |  |   81|     17|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (151:9): [True: 0, False: 17]
  ------------------
  152|      0|        tif->tif_setupdecode(tif);
  153|       |
  154|       |#if LIBDEFLATE_SUPPORT
  155|       |    sp->libdeflate_state = -1;
  156|       |#endif
  157|     17|    sp->stream.next_in = tif->tif_rawdata;
  158|     17|    assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (158:5): [True: 0, Folded]
  |  Branch (158:5): [True: 17, Folded]
  ------------------
  159|       |         we need to simplify this code to reflect a ZLib that is likely updated
  160|       |         to deal with 8byte memory sizes, though this code will respond
  161|       |         appropriately even before we simplify it */
  162|     17|    sp->stream.avail_in =
  163|     17|        TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)tif->tif_rawcc);
  164|     17|    if (inflateReset(&sp->stream) == Z_OK)
  ------------------
  |  Branch (164:9): [True: 17, False: 0]
  ------------------
  165|     17|    {
  166|     17|        sp->read_error = 0;
  167|     17|        return 1;
  168|     17|    }
  169|      0|    return 0;
  170|     17|}
tif_zip.c:TIFF_CLAMP_UINT64_TO_INT32_MAX:
  137|     51|{
  138|       |    return (uInt)TIFF_MIN_UINT64(v, INT32_MAX);
  139|     51|}
tif_zip.c:TIFF_MIN_UINT64:
  132|     51|{
  133|     51|    return a < b ? a : b;
  ------------------
  |  Branch (133:12): [True: 51, False: 0]
  ------------------
  134|     51|}
tif_zip.c:ZIPDecode:
  173|     17|{
  174|     17|    static const char module[] = "ZIPDecode";
  175|     17|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|     17|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|     17|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  176|       |
  177|     17|    (void)s;
  178|     17|    assert(sp != NULL);
  ------------------
  |  Branch (178:5): [True: 0, False: 17]
  |  Branch (178:5): [True: 17, False: 0]
  ------------------
  179|     17|    assert(sp->state == ZSTATE_INIT_DECODE);
  ------------------
  |  Branch (179:5): [True: 0, False: 17]
  |  Branch (179:5): [True: 17, False: 0]
  ------------------
  180|       |
  181|     17|    if (sp->read_error)
  ------------------
  |  Branch (181:9): [True: 0, False: 17]
  ------------------
  182|      0|    {
  183|      0|        memset(op, 0, (size_t)occ);
  184|      0|        TIFFErrorExtR(tif, module,
  185|      0|                      "ZIPDecode: Scanline %" PRIu32 " cannot be read due to "
  186|      0|                      "previous error",
  187|      0|                      tif->tif_dir.td_row);
  188|      0|        return 0;
  189|      0|    }
  190|       |
  191|       |#if LIBDEFLATE_SUPPORT
  192|       |    if (sp->libdeflate_state == 1)
  193|       |        return 0;
  194|       |
  195|       |    /* If we have libdeflate support and we are asked to read a whole */
  196|       |    /* strip/tile, then go for using it */
  197|       |    do
  198|       |    {
  199|       |        TIFFDirectory *td = &tif->tif_dir;
  200|       |
  201|       |        if (sp->libdeflate_state == 0)
  202|       |            break;
  203|       |        if (sp->subcodec == DEFLATE_SUBCODEC_ZLIB)
  204|       |            break;
  205|       |
  206|       |        /* Check if we are in the situation where we can use libdeflate */
  207|       |        if (isTiled(tif))
  208|       |        {
  209|       |            if (TIFFTileSize64(tif) != (uint64_t)occ)
  210|       |                break;
  211|       |        }
  212|       |        else
  213|       |        {
  214|       |            uint32_t strip_height = td->td_imagelength - tif->tif_dir.td_row;
  215|       |            if (strip_height > td->td_rowsperstrip)
  216|       |                strip_height = td->td_rowsperstrip;
  217|       |            if (TIFFVStripSize64(tif, strip_height) != (uint64_t)occ)
  218|       |                break;
  219|       |        }
  220|       |
  221|       |        /* Check for overflow */
  222|       |        if ((size_t)tif->tif_rawcc != (uint64_t)tif->tif_rawcc)
  223|       |            break;
  224|       |        if ((size_t)occ != (uint64_t)occ)
  225|       |            break;
  226|       |
  227|       |        /* Go for decompression using libdeflate */
  228|       |        {
  229|       |            enum libdeflate_result res;
  230|       |            if (sp->libdeflate_dec == NULL)
  231|       |            {
  232|       |                sp->libdeflate_dec = libdeflate_alloc_decompressor();
  233|       |                if (sp->libdeflate_dec == NULL)
  234|       |                {
  235|       |                    break;
  236|       |                }
  237|       |            }
  238|       |
  239|       |            sp->libdeflate_state = 1;
  240|       |
  241|       |            res = libdeflate_zlib_decompress(sp->libdeflate_dec, tif->tif_rawcp,
  242|       |                                             (size_t)tif->tif_rawcc, op,
  243|       |                                             (size_t)occ, NULL);
  244|       |
  245|       |            tif->tif_rawcp += tif->tif_rawcc;
  246|       |            tif->tif_rawcc = 0;
  247|       |
  248|       |            /* We accept LIBDEFLATE_INSUFFICIENT_SPACE has a return */
  249|       |            /* There are odd files in the wild where the last strip, when */
  250|       |            /* it is smaller in height than td_rowsperstrip, actually contains
  251|       |             */
  252|       |            /* data for td_rowsperstrip lines. Just ignore that silently. */
  253|       |            if (res != LIBDEFLATE_SUCCESS &&
  254|       |                res != LIBDEFLATE_INSUFFICIENT_SPACE)
  255|       |            {
  256|       |                memset(op, 0, (size_t)occ);
  257|       |                TIFFErrorExtR(tif, module, "Decoding error at scanline %lu",
  258|       |                              (unsigned long)tif->tif_dir.td_row);
  259|       |                sp->read_error = 1;
  260|       |                return 0;
  261|       |            }
  262|       |
  263|       |            return 1;
  264|       |        }
  265|       |    } while (0);
  266|       |    sp->libdeflate_state = 0;
  267|       |#endif /* LIBDEFLATE_SUPPORT */
  268|       |
  269|     17|    sp->stream.next_in = tif->tif_rawcp;
  270|       |
  271|     17|    sp->stream.next_out = op;
  272|     17|    assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (272:5): [True: 0, Folded]
  |  Branch (272:5): [True: 17, Folded]
  ------------------
  273|       |         we need to simplify this code to reflect a ZLib that is likely updated
  274|       |         to deal with 8byte memory sizes, though this code will respond
  275|       |         appropriately even before we simplify it */
  276|     17|    do
  277|     17|    {
  278|     17|        int state;
  279|     17|        uInt avail_in_before =
  280|     17|            TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)tif->tif_rawcc);
  281|     17|        uInt avail_out_before = TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)occ);
  282|     17|        sp->stream.avail_in = avail_in_before;
  283|     17|        sp->stream.avail_out = avail_out_before;
  284|     17|        state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
  285|     17|        tif->tif_rawcc -= (avail_in_before - sp->stream.avail_in);
  286|     17|        occ -= (avail_out_before - sp->stream.avail_out);
  287|     17|        if (state == Z_STREAM_END)
  ------------------
  |  Branch (287:13): [True: 0, False: 17]
  ------------------
  288|      0|            break;
  289|     17|        if (state == Z_DATA_ERROR)
  ------------------
  |  Branch (289:13): [True: 17, False: 0]
  ------------------
  290|     17|        {
  291|     17|            memset(sp->stream.next_out, 0, (size_t)occ);
  292|     17|            TIFFErrorExtR(tif, module, "Decoding error at scanline %lu, %s",
  293|     17|                          (unsigned long)tif->tif_dir.td_row, SAFE_MSG(sp));
  ------------------
  |  |   60|     17|#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 0, False: 17]
  |  |  ------------------
  ------------------
  294|     17|            sp->read_error = 1;
  295|     17|            return (0);
  296|     17|        }
  297|      0|        if (state != Z_OK)
  ------------------
  |  Branch (297:13): [True: 0, False: 0]
  ------------------
  298|      0|        {
  299|      0|            memset(sp->stream.next_out, 0, (size_t)occ);
  300|      0|            TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp));
  ------------------
  |  |   60|      0|#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  301|      0|            sp->read_error = 1;
  302|      0|            return (0);
  303|      0|        }
  304|      0|    } while (occ > 0);
  ------------------
  |  Branch (304:14): [True: 0, False: 0]
  ------------------
  305|      0|    if (occ != 0)
  ------------------
  |  Branch (305:9): [True: 0, False: 0]
  ------------------
  306|      0|    {
  307|      0|        TIFFErrorExtR(tif, module,
  308|      0|                      "Not enough data at scanline %lu (short %" PRIu64
  309|      0|                      " bytes)",
  310|      0|                      (unsigned long)tif->tif_dir.td_row, (uint64_t)occ);
  311|      0|        memset(sp->stream.next_out, 0, (size_t)occ);
  312|      0|        sp->read_error = 1;
  313|      0|        return (0);
  314|      0|    }
  315|       |
  316|      0|    tif->tif_rawcp = sp->stream.next_in;
  317|       |
  318|      0|    return (1);
  319|      0|}
tif_zip.c:ZIPCleanup:
  556|     28|{
  557|     28|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|     28|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  558|       |
  559|     28|    assert(sp != 0);
  ------------------
  |  Branch (559:5): [True: 0, False: 28]
  |  Branch (559:5): [True: 28, False: 0]
  ------------------
  560|       |
  561|     28|    (void)TIFFPredictorCleanup(tif);
  562|       |
  563|     28|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
  564|     28|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
  565|       |
  566|     28|    if (sp->state & ZSTATE_INIT_ENCODE)
  ------------------
  |  |   82|     28|#define ZSTATE_INIT_ENCODE 0x02
  ------------------
  |  Branch (566:9): [True: 0, False: 28]
  ------------------
  567|      0|    {
  568|      0|        deflateEnd(&sp->stream);
  569|      0|        sp->state = 0;
  570|      0|    }
  571|     28|    else if (sp->state & ZSTATE_INIT_DECODE)
  ------------------
  |  |   81|     28|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (571:14): [True: 17, False: 11]
  ------------------
  572|     17|    {
  573|     17|        inflateEnd(&sp->stream);
  574|     17|        sp->state = 0;
  575|     17|    }
  576|       |
  577|       |#if LIBDEFLATE_SUPPORT
  578|       |    if (sp->libdeflate_dec)
  579|       |        libdeflate_free_decompressor(sp->libdeflate_dec);
  580|       |    if (sp->libdeflate_enc)
  581|       |        libdeflate_free_compressor(sp->libdeflate_enc);
  582|       |#endif
  583|       |
  584|     28|    _TIFFfreeExt(tif, sp);
  585|     28|    tif->tif_data = NULL;
  586|       |
  587|     28|    _TIFFSetDefaultCompressionState(tif);
  588|     28|}

adler32_z:
   61|      4|uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
   62|      4|    unsigned long sum2;
   63|      4|    unsigned n;
   64|       |
   65|       |    /* split Adler-32 into component sums */
   66|      4|    sum2 = (adler >> 16) & 0xffff;
   67|      4|    adler &= 0xffff;
   68|       |
   69|       |    /* in case user likes doing a byte at a time, keep it fast */
   70|      4|    if (len == 1) {
  ------------------
  |  Branch (70:9): [True: 0, False: 4]
  ------------------
   71|      0|        adler += buf[0];
   72|      0|        if (adler >= BASE)
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  |  Branch (72:13): [True: 0, False: 0]
  ------------------
   73|      0|            adler -= BASE;
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
   74|      0|        sum2 += adler;
   75|      0|        if (sum2 >= BASE)
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  |  Branch (75:13): [True: 0, False: 0]
  ------------------
   76|      0|            sum2 -= BASE;
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
   77|      0|        return adler | (sum2 << 16);
   78|      0|    }
   79|       |
   80|       |    /* initial Adler-32 value (deferred check for len == 1 speed) */
   81|      4|    if (buf == Z_NULL)
  ------------------
  |  |  216|      4|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (81:9): [True: 2, False: 2]
  ------------------
   82|      2|        return 1L;
   83|       |
   84|       |    /* in case short lengths are provided, keep it somewhat fast */
   85|      2|    if (len < 16) {
  ------------------
  |  Branch (85:9): [True: 0, False: 2]
  ------------------
   86|      0|        while (len--) {
  ------------------
  |  Branch (86:16): [True: 0, False: 0]
  ------------------
   87|      0|            adler += *buf++;
   88|      0|            sum2 += adler;
   89|      0|        }
   90|      0|        if (adler >= BASE)
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  |  Branch (90:13): [True: 0, False: 0]
  ------------------
   91|      0|            adler -= BASE;
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
   92|      0|        MOD28(sum2);            /* only added so many BASE's */
  ------------------
  |  |   56|      0|#  define MOD28(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
   93|      0|        return adler | (sum2 << 16);
   94|      0|    }
   95|       |
   96|       |    /* do length NMAX blocks -- requires just one modulo operation */
   97|      2|    while (len >= NMAX) {
  ------------------
  |  |   11|      2|#define NMAX 5552
  ------------------
  |  Branch (97:12): [True: 0, False: 2]
  ------------------
   98|      0|        len -= NMAX;
  ------------------
  |  |   11|      0|#define NMAX 5552
  ------------------
   99|      0|        n = NMAX / 16;          /* NMAX is divisible by 16 */
  ------------------
  |  |   11|      0|#define NMAX 5552
  ------------------
  100|      0|        do {
  101|      0|            DO16(buf);          /* 16 sums unrolled */
  ------------------
  |  |   18|      0|#define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|      0|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      0|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      0|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|      0|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      0|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      0|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      0|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      0|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  102|      0|            buf += 16;
  103|      0|        } while (--n);
  ------------------
  |  Branch (103:18): [True: 0, False: 0]
  ------------------
  104|      0|        MOD(adler);
  ------------------
  |  |   55|      0|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  105|      0|        MOD(sum2);
  ------------------
  |  |   55|      0|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  106|      0|    }
  107|       |
  108|       |    /* do remaining bytes (less than NMAX, still just one modulo) */
  109|      2|    if (len) {                  /* avoid modulos if none remaining */
  ------------------
  |  Branch (109:9): [True: 2, False: 0]
  ------------------
  110|      6|        while (len >= 16) {
  ------------------
  |  Branch (110:16): [True: 4, False: 2]
  ------------------
  111|      4|            len -= 16;
  112|      4|            DO16(buf);
  ------------------
  |  |   18|      4|#define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|      4|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      4|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      4|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|      4|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      4|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|      4|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|      4|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|      4|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|      4|            buf += 16;
  114|      4|        }
  115|      6|        while (len--) {
  ------------------
  |  Branch (115:16): [True: 4, False: 2]
  ------------------
  116|      4|            adler += *buf++;
  117|      4|            sum2 += adler;
  118|      4|        }
  119|      2|        MOD(adler);
  ------------------
  |  |   55|      2|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      2|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  120|      2|        MOD(sum2);
  ------------------
  |  |   55|      2|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      2|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  121|      2|    }
  122|       |
  123|       |    /* return recombined sums */
  124|      2|    return adler | (sum2 << 16);
  125|      2|}
adler32:
  128|      4|uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
  129|      4|    return adler32_z(adler, buf, len);
  130|      4|}

inflate_fast:
   50|      2|void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
   51|      2|    struct inflate_state FAR *state;
   52|      2|    z_const unsigned char FAR *in;      /* local strm->next_in */
   53|      2|    z_const unsigned char FAR *last;    /* have enough input while in < last */
   54|      2|    unsigned char FAR *out;     /* local strm->next_out */
   55|      2|    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
   56|      2|    unsigned char FAR *end;     /* while out < end, enough space available */
   57|       |#ifdef INFLATE_STRICT
   58|       |    unsigned dmax;              /* maximum distance from zlib header */
   59|       |#endif
   60|      2|    unsigned wsize;             /* window size or zero if not using window */
   61|      2|    unsigned whave;             /* valid bytes in the window */
   62|      2|    unsigned wnext;             /* window write index */
   63|      2|    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
   64|      2|    unsigned long hold;         /* local strm->hold */
   65|      2|    unsigned bits;              /* local strm->bits */
   66|      2|    code const FAR *lcode;      /* local strm->lencode */
   67|      2|    code const FAR *dcode;      /* local strm->distcode */
   68|      2|    unsigned lmask;             /* mask for first level of length codes */
   69|      2|    unsigned dmask;             /* mask for first level of distance codes */
   70|      2|    code const *here;           /* retrieved table entry */
   71|      2|    unsigned op;                /* code bits, operation, extra bits, or */
   72|       |                                /*  window position, window bytes to copy */
   73|      2|    unsigned len;               /* match length, unused bytes */
   74|      2|    unsigned dist;              /* match distance */
   75|      2|    unsigned char FAR *from;    /* where to copy match from */
   76|       |
   77|       |    /* copy state to local variables */
   78|      2|    state = (struct inflate_state FAR *)strm->state;
   79|      2|    in = strm->next_in;
   80|      2|    last = in + (strm->avail_in - 5);
   81|      2|    out = strm->next_out;
   82|      2|    beg = out - (start - strm->avail_out);
   83|      2|    end = out + (strm->avail_out - 257);
   84|       |#ifdef INFLATE_STRICT
   85|       |    dmax = state->dmax;
   86|       |#endif
   87|      2|    wsize = state->wsize;
   88|      2|    whave = state->whave;
   89|      2|    wnext = state->wnext;
   90|      2|    window = state->window;
   91|      2|    hold = state->hold;
   92|      2|    bits = state->bits;
   93|      2|    lcode = state->lencode;
   94|      2|    dcode = state->distcode;
   95|      2|    lmask = (1U << state->lenbits) - 1;
   96|      2|    dmask = (1U << state->distbits) - 1;
   97|       |
   98|       |    /* decode literals and length/distances until end-of-block or not enough
   99|       |       input data or output space */
  100|     24|    do {
  101|     24|        if (bits < 15) {
  ------------------
  |  Branch (101:13): [True: 14, False: 10]
  ------------------
  102|     14|            hold += (unsigned long)(*in++) << bits;
  103|     14|            bits += 8;
  104|     14|            hold += (unsigned long)(*in++) << bits;
  105|     14|            bits += 8;
  106|     14|        }
  107|     24|        here = lcode + (hold & lmask);
  108|     24|      dolen:
  109|     24|        op = (unsigned)(here->bits);
  110|     24|        hold >>= op;
  111|     24|        bits -= op;
  112|     24|        op = (unsigned)(here->op);
  113|     24|        if (op == 0) {                          /* literal */
  ------------------
  |  Branch (113:13): [True: 24, False: 0]
  ------------------
  114|     24|            Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
  115|     24|                    "inflate:         literal '%c'\n" :
  116|     24|                    "inflate:         literal 0x%02x\n", here->val));
  117|     24|            *out++ = (unsigned char)(here->val);
  118|     24|        }
  119|      0|        else if (op & 16) {                     /* length base */
  ------------------
  |  Branch (119:18): [True: 0, False: 0]
  ------------------
  120|      0|            len = (unsigned)(here->val);
  121|      0|            op &= 15;                           /* number of extra bits */
  122|      0|            if (op) {
  ------------------
  |  Branch (122:17): [True: 0, False: 0]
  ------------------
  123|      0|                if (bits < op) {
  ------------------
  |  Branch (123:21): [True: 0, False: 0]
  ------------------
  124|      0|                    hold += (unsigned long)(*in++) << bits;
  125|      0|                    bits += 8;
  126|      0|                }
  127|      0|                len += (unsigned)hold & ((1U << op) - 1);
  128|      0|                hold >>= op;
  129|      0|                bits -= op;
  130|      0|            }
  131|      0|            Tracevv((stderr, "inflate:         length %u\n", len));
  132|      0|            if (bits < 15) {
  ------------------
  |  Branch (132:17): [True: 0, False: 0]
  ------------------
  133|      0|                hold += (unsigned long)(*in++) << bits;
  134|      0|                bits += 8;
  135|      0|                hold += (unsigned long)(*in++) << bits;
  136|      0|                bits += 8;
  137|      0|            }
  138|      0|            here = dcode + (hold & dmask);
  139|      0|          dodist:
  140|      0|            op = (unsigned)(here->bits);
  141|      0|            hold >>= op;
  142|      0|            bits -= op;
  143|      0|            op = (unsigned)(here->op);
  144|      0|            if (op & 16) {                      /* distance base */
  ------------------
  |  Branch (144:17): [True: 0, False: 0]
  ------------------
  145|      0|                dist = (unsigned)(here->val);
  146|      0|                op &= 15;                       /* number of extra bits */
  147|      0|                if (bits < op) {
  ------------------
  |  Branch (147:21): [True: 0, False: 0]
  ------------------
  148|      0|                    hold += (unsigned long)(*in++) << bits;
  149|      0|                    bits += 8;
  150|      0|                    if (bits < op) {
  ------------------
  |  Branch (150:25): [True: 0, False: 0]
  ------------------
  151|      0|                        hold += (unsigned long)(*in++) << bits;
  152|      0|                        bits += 8;
  153|      0|                    }
  154|      0|                }
  155|      0|                dist += (unsigned)hold & ((1U << op) - 1);
  156|       |#ifdef INFLATE_STRICT
  157|       |                if (dist > dmax) {
  158|       |                    strm->msg = (z_const char *)
  159|       |                        "invalid distance too far back";
  160|       |                    state->mode = BAD;
  161|       |                    break;
  162|       |                }
  163|       |#endif
  164|      0|                hold >>= op;
  165|      0|                bits -= op;
  166|      0|                Tracevv((stderr, "inflate:         distance %u\n", dist));
  167|      0|                op = (unsigned)(out - beg);     /* max distance in output */
  168|      0|                if (dist > op) {                /* see if copy from window */
  ------------------
  |  Branch (168:21): [True: 0, False: 0]
  ------------------
  169|      0|                    op = dist - op;             /* distance back in window */
  170|      0|                    if (op > whave) {
  ------------------
  |  Branch (170:25): [True: 0, False: 0]
  ------------------
  171|      0|                        if (state->sane) {
  ------------------
  |  Branch (171:29): [True: 0, False: 0]
  ------------------
  172|      0|                            strm->msg = (z_const char *)
  173|      0|                                "invalid distance too far back";
  174|      0|                            state->mode = BAD;
  175|      0|                            break;
  176|      0|                        }
  177|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
  178|       |                        if (len <= op - whave) {
  179|       |                            do {
  180|       |                                *out++ = 0;
  181|       |                            } while (--len);
  182|       |                            continue;
  183|       |                        }
  184|       |                        len -= op - whave;
  185|       |                        do {
  186|       |                            *out++ = 0;
  187|       |                        } while (--op > whave);
  188|       |                        if (op == 0) {
  189|       |                            from = out - dist;
  190|       |                            do {
  191|       |                                *out++ = *from++;
  192|       |                            } while (--len);
  193|       |                            continue;
  194|       |                        }
  195|       |#endif
  196|      0|                    }
  197|      0|                    from = window;
  198|      0|                    if (wnext == 0) {           /* very common case */
  ------------------
  |  Branch (198:25): [True: 0, False: 0]
  ------------------
  199|      0|                        from += wsize - op;
  200|      0|                        if (op < len) {         /* some from window */
  ------------------
  |  Branch (200:29): [True: 0, False: 0]
  ------------------
  201|      0|                            len -= op;
  202|      0|                            do {
  203|      0|                                *out++ = *from++;
  204|      0|                            } while (--op);
  ------------------
  |  Branch (204:38): [True: 0, False: 0]
  ------------------
  205|      0|                            from = out - dist;  /* rest from output */
  206|      0|                        }
  207|      0|                    }
  208|      0|                    else if (wnext < op) {      /* wrap around window */
  ------------------
  |  Branch (208:30): [True: 0, False: 0]
  ------------------
  209|      0|                        from += wsize + wnext - op;
  210|      0|                        op -= wnext;
  211|      0|                        if (op < len) {         /* some from end of window */
  ------------------
  |  Branch (211:29): [True: 0, False: 0]
  ------------------
  212|      0|                            len -= op;
  213|      0|                            do {
  214|      0|                                *out++ = *from++;
  215|      0|                            } while (--op);
  ------------------
  |  Branch (215:38): [True: 0, False: 0]
  ------------------
  216|      0|                            from = window;
  217|      0|                            if (wnext < len) {  /* some from start of window */
  ------------------
  |  Branch (217:33): [True: 0, False: 0]
  ------------------
  218|      0|                                op = wnext;
  219|      0|                                len -= op;
  220|      0|                                do {
  221|      0|                                    *out++ = *from++;
  222|      0|                                } while (--op);
  ------------------
  |  Branch (222:42): [True: 0, False: 0]
  ------------------
  223|      0|                                from = out - dist;      /* rest from output */
  224|      0|                            }
  225|      0|                        }
  226|      0|                    }
  227|      0|                    else {                      /* contiguous in window */
  228|      0|                        from += wnext - op;
  229|      0|                        if (op < len) {         /* some from window */
  ------------------
  |  Branch (229:29): [True: 0, False: 0]
  ------------------
  230|      0|                            len -= op;
  231|      0|                            do {
  232|      0|                                *out++ = *from++;
  233|      0|                            } while (--op);
  ------------------
  |  Branch (233:38): [True: 0, False: 0]
  ------------------
  234|      0|                            from = out - dist;  /* rest from output */
  235|      0|                        }
  236|      0|                    }
  237|      0|                    while (len > 2) {
  ------------------
  |  Branch (237:28): [True: 0, False: 0]
  ------------------
  238|      0|                        *out++ = *from++;
  239|      0|                        *out++ = *from++;
  240|      0|                        *out++ = *from++;
  241|      0|                        len -= 3;
  242|      0|                    }
  243|      0|                    if (len) {
  ------------------
  |  Branch (243:25): [True: 0, False: 0]
  ------------------
  244|      0|                        *out++ = *from++;
  245|      0|                        if (len > 1)
  ------------------
  |  Branch (245:29): [True: 0, False: 0]
  ------------------
  246|      0|                            *out++ = *from++;
  247|      0|                    }
  248|      0|                }
  249|      0|                else {
  250|      0|                    from = out - dist;          /* copy direct from output */
  251|      0|                    do {                        /* minimum length is three */
  252|      0|                        *out++ = *from++;
  253|      0|                        *out++ = *from++;
  254|      0|                        *out++ = *from++;
  255|      0|                        len -= 3;
  256|      0|                    } while (len > 2);
  ------------------
  |  Branch (256:30): [True: 0, False: 0]
  ------------------
  257|      0|                    if (len) {
  ------------------
  |  Branch (257:25): [True: 0, False: 0]
  ------------------
  258|      0|                        *out++ = *from++;
  259|      0|                        if (len > 1)
  ------------------
  |  Branch (259:29): [True: 0, False: 0]
  ------------------
  260|      0|                            *out++ = *from++;
  261|      0|                    }
  262|      0|                }
  263|      0|            }
  264|      0|            else if ((op & 64) == 0) {          /* 2nd level distance code */
  ------------------
  |  Branch (264:22): [True: 0, False: 0]
  ------------------
  265|      0|                here = dcode + here->val + (hold & ((1U << op) - 1));
  266|      0|                goto dodist;
  267|      0|            }
  268|      0|            else {
  269|      0|                strm->msg = (z_const char *)"invalid distance code";
  270|      0|                state->mode = BAD;
  271|      0|                break;
  272|      0|            }
  273|      0|        }
  274|      0|        else if ((op & 64) == 0) {              /* 2nd level length code */
  ------------------
  |  Branch (274:18): [True: 0, False: 0]
  ------------------
  275|      0|            here = lcode + here->val + (hold & ((1U << op) - 1));
  276|      0|            goto dolen;
  277|      0|        }
  278|      0|        else if (op & 32) {                     /* end-of-block */
  ------------------
  |  Branch (278:18): [True: 0, False: 0]
  ------------------
  279|      0|            Tracevv((stderr, "inflate:         end of block\n"));
  280|      0|            state->mode = TYPE;
  281|      0|            break;
  282|      0|        }
  283|      0|        else {
  284|      0|            strm->msg = (z_const char *)"invalid literal/length code";
  285|      0|            state->mode = BAD;
  286|      0|            break;
  287|      0|        }
  288|     24|    } while (in < last && out < end);
  ------------------
  |  Branch (288:14): [True: 24, False: 0]
  |  Branch (288:27): [True: 22, False: 2]
  ------------------
  289|       |
  290|       |    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
  291|      2|    len = bits >> 3;
  292|      2|    in -= len;
  293|      2|    bits -= len << 3;
  294|      2|    hold &= (1U << bits) - 1;
  295|       |
  296|       |    /* update state and return */
  297|      2|    strm->next_in = in;
  298|      2|    strm->next_out = out;
  299|      2|    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
  ------------------
  |  Branch (299:33): [True: 2, False: 0]
  ------------------
  300|      2|    strm->avail_out = (unsigned)(out < end ?
  ------------------
  |  Branch (300:34): [True: 0, False: 2]
  ------------------
  301|      2|                                 257 + (end - out) : 257 - (out - end));
  302|      2|    state->hold = hold;
  303|      2|    state->bits = bits;
  304|      2|    return;
  305|      2|}

inflateResetKeep:
  100|    263|int ZEXPORT inflateResetKeep(z_streamp strm) {
  101|    263|    struct inflate_state FAR *state;
  102|       |
  103|    263|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (103:9): [True: 0, False: 263]
  ------------------
  104|    263|    state = (struct inflate_state FAR *)strm->state;
  105|    263|    strm->total_in = strm->total_out = state->total = 0;
  106|    263|    strm->msg = Z_NULL;
  ------------------
  |  |  216|    263|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  107|    263|    strm->data_type = 0;
  108|    263|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (108:9): [True: 263, False: 0]
  ------------------
  109|    263|        strm->adler = state->wrap & 1;
  110|    263|    state->mode = HEAD;
  111|    263|    state->last = 0;
  112|    263|    state->havedict = 0;
  113|    263|    state->flags = -1;
  114|    263|    state->dmax = 32768U;
  115|    263|    state->head = Z_NULL;
  ------------------
  |  |  216|    263|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  116|    263|    state->hold = 0;
  117|    263|    state->bits = 0;
  118|    263|    state->lencode = state->distcode = state->next = state->codes;
  119|    263|    state->sane = 1;
  120|    263|    state->back = -1;
  121|    263|    Tracev((stderr, "inflate: reset\n"));
  122|    263|    return Z_OK;
  ------------------
  |  |  181|    263|#define Z_OK            0
  ------------------
  123|    263|}
inflateReset:
  125|    263|int ZEXPORT inflateReset(z_streamp strm) {
  126|    263|    struct inflate_state FAR *state;
  127|       |
  128|    263|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (128:9): [True: 0, False: 263]
  ------------------
  129|    263|    state = (struct inflate_state FAR *)strm->state;
  130|    263|    state->wsize = 0;
  131|    263|    state->whave = 0;
  132|    263|    state->wnext = 0;
  133|    263|    return inflateResetKeep(strm);
  134|    263|}
inflateReset2:
  136|     60|int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
  137|     60|    int wrap;
  138|     60|    struct inflate_state FAR *state;
  139|       |
  140|       |    /* get the state */
  141|     60|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (141:9): [True: 0, False: 60]
  ------------------
  142|     60|    state = (struct inflate_state FAR *)strm->state;
  143|       |
  144|       |    /* extract wrap request from windowBits parameter */
  145|     60|    if (windowBits < 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 60]
  ------------------
  146|      0|        if (windowBits < -15)
  ------------------
  |  Branch (146:13): [True: 0, False: 0]
  ------------------
  147|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  148|      0|        wrap = 0;
  149|      0|        windowBits = -windowBits;
  150|      0|    }
  151|     60|    else {
  152|     60|        wrap = (windowBits >> 4) + 5;
  153|     60|#ifdef GUNZIP
  154|     60|        if (windowBits < 48)
  ------------------
  |  Branch (154:13): [True: 60, False: 0]
  ------------------
  155|     60|            windowBits &= 15;
  156|     60|#endif
  157|     60|    }
  158|       |
  159|       |    /* set number of window bits, free window if different */
  160|     60|    if (windowBits && (windowBits < 8 || windowBits > 15))
  ------------------
  |  Branch (160:9): [True: 60, False: 0]
  |  Branch (160:24): [True: 0, False: 60]
  |  Branch (160:42): [True: 0, False: 60]
  ------------------
  161|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  162|     60|    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
  ------------------
  |  |  216|    120|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (162:9): [True: 0, False: 60]
  |  Branch (162:36): [True: 0, False: 0]
  ------------------
  163|      0|        ZFREE(strm, state->window);
  ------------------
  |  |  254|      0|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  164|      0|        state->window = Z_NULL;
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  165|      0|    }
  166|       |
  167|       |    /* update state and reset the rest of it */
  168|     60|    state->wrap = wrap;
  169|     60|    state->wbits = (unsigned)windowBits;
  170|     60|    return inflateReset(strm);
  171|     60|}
inflateInit2_:
  174|     60|                          const char *version, int stream_size) {
  175|     60|    int ret;
  176|     60|    struct inflate_state FAR *state;
  177|       |
  178|     60|    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |  216|    120|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |   44|     60|#define ZLIB_VERSION "1.3.2.1-motley"
  ------------------
  |  Branch (178:9): [True: 0, False: 60]
  |  Branch (178:30): [True: 0, False: 60]
  ------------------
  179|     60|        stream_size != (int)(sizeof(z_stream)))
  ------------------
  |  Branch (179:9): [True: 0, False: 60]
  ------------------
  180|      0|        return Z_VERSION_ERROR;
  ------------------
  |  |  189|      0|#define Z_VERSION_ERROR (-6)
  ------------------
  181|     60|    if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (181:9): [True: 0, False: 60]
  ------------------
  182|     60|    strm->msg = Z_NULL;                 /* in case we return an error */
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  183|     60|    if (strm->zalloc == (alloc_func)0) {
  ------------------
  |  Branch (183:9): [True: 43, False: 17]
  ------------------
  184|       |#ifdef Z_SOLO
  185|       |        return Z_STREAM_ERROR;
  186|       |#else
  187|     43|        strm->zalloc = zcalloc;
  188|     43|        strm->opaque = (voidpf)0;
  189|     43|#endif
  190|     43|    }
  191|     60|    if (strm->zfree == (free_func)0)
  ------------------
  |  Branch (191:9): [True: 43, False: 17]
  ------------------
  192|       |#ifdef Z_SOLO
  193|       |        return Z_STREAM_ERROR;
  194|       |#else
  195|     43|        strm->zfree = zcfree;
  196|     60|#endif
  197|     60|    state = (struct inflate_state FAR *)
  198|     60|            ZALLOC(strm, 1, sizeof(struct inflate_state));
  ------------------
  |  |  253|     60|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  199|     60|    if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
  |  Branch (199:9): [True: 0, False: 60]
  ------------------
  200|     60|    zmemzero(state, sizeof(struct inflate_state));
  ------------------
  |  |  218|     60|#    define zmemzero(dest, len) memset(dest, 0, len)
  ------------------
  201|     60|    Tracev((stderr, "inflate: allocated\n"));
  202|     60|    strm->state = (struct internal_state FAR *)state;
  203|     60|    state->strm = strm;
  204|     60|    state->window = Z_NULL;
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  205|     60|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  206|     60|    ret = inflateReset2(strm, windowBits);
  207|     60|    if (ret != Z_OK) {
  ------------------
  |  |  181|     60|#define Z_OK            0
  ------------------
  |  Branch (207:9): [True: 0, False: 60]
  ------------------
  208|      0|        ZFREE(strm, state);
  ------------------
  |  |  254|      0|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  209|      0|        strm->state = Z_NULL;
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  210|      0|    }
  211|     60|    return ret;
  212|     60|}
inflateInit_:
  215|     60|                         int stream_size) {
  216|     60|    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
  ------------------
  |  |   76|     60|#  define DEF_WBITS MAX_WBITS
  |  |  ------------------
  |  |  |  |  287|     60|#  define MAX_WBITS   15 /* 32K LZ77 window */
  |  |  ------------------
  ------------------
  217|     60|}
inflate:
  474|    208|int ZEXPORT inflate(z_streamp strm, int flush) {
  475|    208|    struct inflate_state FAR *state;
  476|    208|    z_const unsigned char FAR *next;    /* next input */
  477|    208|    unsigned char FAR *put;     /* next output */
  478|    208|    unsigned have, left;        /* available input and output */
  479|    208|    unsigned long hold;         /* bit buffer */
  480|    208|    unsigned bits;              /* bits in bit buffer */
  481|    208|    unsigned in, out;           /* save starting available input and output */
  482|    208|    unsigned copy;              /* number of stored or match bytes to copy */
  483|    208|    unsigned char FAR *from;    /* where to copy match bytes from */
  484|    208|    code here;                  /* current decoding table entry */
  485|    208|    code last;                  /* parent table entry */
  486|    208|    unsigned len;               /* length to copy for repeats, bits to drop */
  487|    208|    int ret;                    /* return code */
  488|    208|#ifdef GUNZIP
  489|    208|    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  490|    208|#endif
  491|    208|    static const unsigned short order[19] = /* permutation of code lengths */
  492|    208|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  493|       |
  494|    208|    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
  ------------------
  |  |  216|    416|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (494:9): [True: 0, False: 208]
  |  Branch (494:36): [True: 0, False: 208]
  ------------------
  495|    208|        (strm->next_in == Z_NULL && strm->avail_in != 0))
  ------------------
  |  |  216|    416|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (495:10): [True: 0, False: 208]
  |  Branch (495:37): [True: 0, False: 0]
  ------------------
  496|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  497|       |
  498|    208|    state = (struct inflate_state FAR *)strm->state;
  499|    208|    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
  ------------------
  |  Branch (499:9): [True: 0, False: 208]
  ------------------
  500|    208|    LOAD();
  ------------------
  |  |  329|    208|    do { \
  |  |  330|    208|        put = strm->next_out; \
  |  |  331|    208|        left = strm->avail_out; \
  |  |  332|    208|        next = strm->next_in; \
  |  |  333|    208|        have = strm->avail_in; \
  |  |  334|    208|        hold = state->hold; \
  |  |  335|    208|        bits = state->bits; \
  |  |  336|    208|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 208]
  |  |  ------------------
  ------------------
  501|    208|    in = have;
  502|    208|    out = left;
  503|    208|    ret = Z_OK;
  ------------------
  |  |  181|    208|#define Z_OK            0
  ------------------
  504|    208|    for (;;)
  505|    500|        switch (state->mode) {
  506|    208|        case HEAD:
  ------------------
  |  Branch (506:9): [True: 208, False: 292]
  ------------------
  507|    208|            if (state->wrap == 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 208]
  ------------------
  508|      0|                state->mode = TYPEDO;
  509|      0|                break;
  510|      0|            }
  511|    208|            NEEDBITS(16);
  ------------------
  |  |  369|    208|    do { \
  |  |  370|    603|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 409, False: 194]
  |  |  ------------------
  |  |  371|    409|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|    409|    do { \
  |  |  |  |  360|    409|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 14, False: 395]
  |  |  |  |  ------------------
  |  |  |  |  361|    409|        have--; \
  |  |  |  |  362|    395|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|    395|        bits += 8; \
  |  |  |  |  364|    395|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 395]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|    208|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 194]
  |  |  ------------------
  ------------------
  512|    194|#ifdef GUNZIP
  513|    194|            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
  ------------------
  |  Branch (513:17): [True: 0, False: 194]
  |  Branch (513:38): [True: 0, False: 0]
  ------------------
  514|      0|                if (state->wbits == 0)
  ------------------
  |  Branch (514:21): [True: 0, False: 0]
  ------------------
  515|      0|                    state->wbits = 15;
  516|      0|                state->check = crc32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  517|      0|                CRC2(state->check, hold);
  ------------------
  |  |  311|      0|    do { \
  |  |  312|      0|        hbuf[0] = (unsigned char)(word); \
  |  |  313|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |  314|      0|        check = crc32(check, hbuf, 2); \
  |  |  315|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (315:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  518|      0|                INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  519|      0|                state->mode = FLAGS;
  520|      0|                break;
  521|      0|            }
  522|    194|            if (state->head != Z_NULL)
  ------------------
  |  |  216|    194|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (522:17): [True: 0, False: 194]
  ------------------
  523|      0|                state->head->done = -1;
  524|    194|            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
  ------------------
  |  Branch (524:17): [True: 0, False: 194]
  ------------------
  525|       |#else
  526|       |            if (
  527|       |#endif
  528|    194|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  376|    194|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  |  Branch (528:17): [True: 161, False: 33]
  ------------------
  529|    161|                strm->msg = (z_const char *)"incorrect header check";
  530|    161|                state->mode = BAD;
  531|    161|                break;
  532|    161|            }
  533|     33|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  376|     33|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  213|     33|#define Z_DEFLATED   8
  ------------------
  |  Branch (533:17): [True: 31, False: 2]
  ------------------
  534|     31|                strm->msg = (z_const char *)"unknown compression method";
  535|     31|                state->mode = BAD;
  536|     31|                break;
  537|     31|            }
  538|      2|            DROPBITS(4);
  ------------------
  |  |  380|      2|    do { \
  |  |  381|      2|        hold >>= (n); \
  |  |  382|      2|        bits -= (unsigned)(n); \
  |  |  383|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  539|      2|            len = BITS(4) + 8;
  ------------------
  |  |  376|      2|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  540|      2|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 2]
  ------------------
  541|      0|                state->wbits = len;
  542|      2|            if (len > 15 || len > state->wbits) {
  ------------------
  |  Branch (542:17): [True: 0, False: 2]
  |  Branch (542:29): [True: 0, False: 2]
  ------------------
  543|      0|                strm->msg = (z_const char *)"invalid window size";
  544|      0|                state->mode = BAD;
  545|      0|                break;
  546|      0|            }
  547|      2|            state->dmax = 1U << len;
  548|      2|            state->flags = 0;               /* indicate zlib header */
  549|      2|            Tracev((stderr, "inflate:   zlib header ok\n"));
  550|      2|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      2|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  551|      2|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (551:27): [True: 0, False: 2]
  ------------------
  552|      2|            INITBITS();
  ------------------
  |  |  351|      2|    do { \
  |  |  352|      2|        hold = 0; \
  |  |  353|      2|        bits = 0; \
  |  |  354|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  553|      2|            break;
  554|      0|#ifdef GUNZIP
  555|      0|        case FLAGS:
  ------------------
  |  Branch (555:9): [True: 0, False: 500]
  ------------------
  556|      0|            NEEDBITS(16);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  557|      0|            state->flags = (int)(hold);
  558|      0|            if ((state->flags & 0xff) != Z_DEFLATED) {
  ------------------
  |  |  213|      0|#define Z_DEFLATED   8
  ------------------
  |  Branch (558:17): [True: 0, False: 0]
  ------------------
  559|      0|                strm->msg = (z_const char *)"unknown compression method";
  560|      0|                state->mode = BAD;
  561|      0|                break;
  562|      0|            }
  563|      0|            if (state->flags & 0xe000) {
  ------------------
  |  Branch (563:17): [True: 0, False: 0]
  ------------------
  564|      0|                strm->msg = (z_const char *)"unknown header flags set";
  565|      0|                state->mode = BAD;
  566|      0|                break;
  567|      0|            }
  568|      0|            if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (568:17): [True: 0, False: 0]
  ------------------
  569|      0|                state->head->text = (int)((hold >> 8) & 1);
  570|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (570:17): [True: 0, False: 0]
  |  Branch (570:44): [True: 0, False: 0]
  ------------------
  571|      0|                CRC2(state->check, hold);
  ------------------
  |  |  311|      0|    do { \
  |  |  312|      0|        hbuf[0] = (unsigned char)(word); \
  |  |  313|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |  314|      0|        check = crc32(check, hbuf, 2); \
  |  |  315|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (315:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  572|      0|            INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  573|      0|            state->mode = TIME;
  574|       |                /* fallthrough */
  575|      0|        case TIME:
  ------------------
  |  Branch (575:9): [True: 0, False: 500]
  ------------------
  576|      0|            NEEDBITS(32);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  577|      0|            if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (577:17): [True: 0, False: 0]
  ------------------
  578|      0|                state->head->time = hold;
  579|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (579:17): [True: 0, False: 0]
  |  Branch (579:44): [True: 0, False: 0]
  ------------------
  580|      0|                CRC4(state->check, hold);
  ------------------
  |  |  318|      0|    do { \
  |  |  319|      0|        hbuf[0] = (unsigned char)(word); \
  |  |  320|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |  321|      0|        hbuf[2] = (unsigned char)((word) >> 16); \
  |  |  322|      0|        hbuf[3] = (unsigned char)((word) >> 24); \
  |  |  323|      0|        check = crc32(check, hbuf, 4); \
  |  |  324|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (324:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  581|      0|            INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  582|      0|            state->mode = OS;
  583|       |                /* fallthrough */
  584|      0|        case OS:
  ------------------
  |  Branch (584:9): [True: 0, False: 500]
  ------------------
  585|      0|            NEEDBITS(16);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  586|      0|            if (state->head != Z_NULL) {
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (586:17): [True: 0, False: 0]
  ------------------
  587|      0|                state->head->xflags = (int)(hold & 0xff);
  588|      0|                state->head->os = (int)(hold >> 8);
  589|      0|            }
  590|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (590:17): [True: 0, False: 0]
  |  Branch (590:44): [True: 0, False: 0]
  ------------------
  591|      0|                CRC2(state->check, hold);
  ------------------
  |  |  311|      0|    do { \
  |  |  312|      0|        hbuf[0] = (unsigned char)(word); \
  |  |  313|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |  314|      0|        check = crc32(check, hbuf, 2); \
  |  |  315|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (315:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  592|      0|            INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  593|      0|            state->mode = EXLEN;
  594|       |                /* fallthrough */
  595|      0|        case EXLEN:
  ------------------
  |  Branch (595:9): [True: 0, False: 500]
  ------------------
  596|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (596:17): [True: 0, False: 0]
  ------------------
  597|      0|                NEEDBITS(16);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  598|      0|                state->length = (unsigned)(hold);
  599|      0|                if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (599:21): [True: 0, False: 0]
  ------------------
  600|      0|                    state->head->extra_len = (unsigned)hold;
  601|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (601:21): [True: 0, False: 0]
  |  Branch (601:48): [True: 0, False: 0]
  ------------------
  602|      0|                    CRC2(state->check, hold);
  ------------------
  |  |  311|      0|    do { \
  |  |  312|      0|        hbuf[0] = (unsigned char)(word); \
  |  |  313|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |  314|      0|        check = crc32(check, hbuf, 2); \
  |  |  315|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (315:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  603|      0|                INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  604|      0|            }
  605|      0|            else if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (605:22): [True: 0, False: 0]
  ------------------
  606|      0|                state->head->extra = Z_NULL;
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  607|      0|            state->mode = EXTRA;
  608|       |                /* fallthrough */
  609|      0|        case EXTRA:
  ------------------
  |  Branch (609:9): [True: 0, False: 500]
  ------------------
  610|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (610:17): [True: 0, False: 0]
  ------------------
  611|      0|                copy = state->length;
  612|      0|                if (copy > have) copy = have;
  ------------------
  |  Branch (612:21): [True: 0, False: 0]
  ------------------
  613|      0|                if (copy) {
  ------------------
  |  Branch (613:21): [True: 0, False: 0]
  ------------------
  614|      0|                    if (state->head != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (614:25): [True: 0, False: 0]
  ------------------
  615|      0|                        state->head->extra != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (615:25): [True: 0, False: 0]
  ------------------
  616|      0|                        (len = state->head->extra_len - state->length) <
  ------------------
  |  Branch (616:25): [True: 0, False: 0]
  ------------------
  617|      0|                            state->head->extra_max) {
  618|      0|                        zmemcpy(state->head->extra + len, next,
  ------------------
  |  |  216|      0|#    define zmemcpy memcpy
  ------------------
  619|      0|                                len + copy > state->head->extra_max ?
  ------------------
  |  Branch (619:33): [True: 0, False: 0]
  ------------------
  620|      0|                                state->head->extra_max - len : copy);
  621|      0|                    }
  622|      0|                    if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (622:25): [True: 0, False: 0]
  |  Branch (622:52): [True: 0, False: 0]
  ------------------
  623|      0|                        state->check = crc32(state->check, next, copy);
  624|      0|                    have -= copy;
  625|      0|                    next += copy;
  626|      0|                    state->length -= copy;
  627|      0|                }
  628|      0|                if (state->length) goto inf_leave;
  ------------------
  |  Branch (628:21): [True: 0, False: 0]
  ------------------
  629|      0|            }
  630|      0|            state->length = 0;
  631|      0|            state->mode = NAME;
  632|       |                /* fallthrough */
  633|      0|        case NAME:
  ------------------
  |  Branch (633:9): [True: 0, False: 500]
  ------------------
  634|      0|            if (state->flags & 0x0800) {
  ------------------
  |  Branch (634:17): [True: 0, False: 0]
  ------------------
  635|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (635:21): [True: 0, False: 0]
  ------------------
  636|      0|                copy = 0;
  637|      0|                do {
  638|      0|                    len = (unsigned)(next[copy++]);
  639|      0|                    if (state->head != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (639:25): [True: 0, False: 0]
  ------------------
  640|      0|                            state->head->name != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (640:29): [True: 0, False: 0]
  ------------------
  641|      0|                            state->length < state->head->name_max)
  ------------------
  |  Branch (641:29): [True: 0, False: 0]
  ------------------
  642|      0|                        state->head->name[state->length++] = (Bytef)len;
  643|      0|                } while (len && copy < have);
  ------------------
  |  Branch (643:26): [True: 0, False: 0]
  |  Branch (643:33): [True: 0, False: 0]
  ------------------
  644|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (644:21): [True: 0, False: 0]
  |  Branch (644:48): [True: 0, False: 0]
  ------------------
  645|      0|                    state->check = crc32(state->check, next, copy);
  646|      0|                have -= copy;
  647|      0|                next += copy;
  648|      0|                if (len) goto inf_leave;
  ------------------
  |  Branch (648:21): [True: 0, False: 0]
  ------------------
  649|      0|            }
  650|      0|            else if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (650:22): [True: 0, False: 0]
  ------------------
  651|      0|                state->head->name = Z_NULL;
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  652|      0|            state->length = 0;
  653|      0|            state->mode = COMMENT;
  654|       |                /* fallthrough */
  655|      0|        case COMMENT:
  ------------------
  |  Branch (655:9): [True: 0, False: 500]
  ------------------
  656|      0|            if (state->flags & 0x1000) {
  ------------------
  |  Branch (656:17): [True: 0, False: 0]
  ------------------
  657|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (657:21): [True: 0, False: 0]
  ------------------
  658|      0|                copy = 0;
  659|      0|                do {
  660|      0|                    len = (unsigned)(next[copy++]);
  661|      0|                    if (state->head != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (661:25): [True: 0, False: 0]
  ------------------
  662|      0|                            state->head->comment != Z_NULL &&
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (662:29): [True: 0, False: 0]
  ------------------
  663|      0|                            state->length < state->head->comm_max)
  ------------------
  |  Branch (663:29): [True: 0, False: 0]
  ------------------
  664|      0|                        state->head->comment[state->length++] = (Bytef)len;
  665|      0|                } while (len && copy < have);
  ------------------
  |  Branch (665:26): [True: 0, False: 0]
  |  Branch (665:33): [True: 0, False: 0]
  ------------------
  666|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (666:21): [True: 0, False: 0]
  |  Branch (666:48): [True: 0, False: 0]
  ------------------
  667|      0|                    state->check = crc32(state->check, next, copy);
  668|      0|                have -= copy;
  669|      0|                next += copy;
  670|      0|                if (len) goto inf_leave;
  ------------------
  |  Branch (670:21): [True: 0, False: 0]
  ------------------
  671|      0|            }
  672|      0|            else if (state->head != Z_NULL)
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (672:22): [True: 0, False: 0]
  ------------------
  673|      0|                state->head->comment = Z_NULL;
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  674|      0|            state->mode = HCRC;
  675|       |                /* fallthrough */
  676|      0|        case HCRC:
  ------------------
  |  Branch (676:9): [True: 0, False: 500]
  ------------------
  677|      0|            if (state->flags & 0x0200) {
  ------------------
  |  Branch (677:17): [True: 0, False: 0]
  ------------------
  678|      0|                NEEDBITS(16);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  679|      0|                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
  ------------------
  |  Branch (679:21): [True: 0, False: 0]
  |  Branch (679:42): [True: 0, False: 0]
  ------------------
  680|      0|                    strm->msg = (z_const char *)"header crc mismatch";
  681|      0|                    state->mode = BAD;
  682|      0|                    break;
  683|      0|                }
  684|      0|                INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  685|      0|            }
  686|      0|            if (state->head != Z_NULL) {
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (686:17): [True: 0, False: 0]
  ------------------
  687|      0|                state->head->hcrc = (int)((state->flags >> 9) & 1);
  688|      0|                state->head->done = 1;
  689|      0|            }
  690|      0|            strm->adler = state->check = crc32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  691|      0|            state->mode = TYPE;
  692|      0|            break;
  693|      0|#endif
  694|      0|        case DICTID:
  ------------------
  |  Branch (694:9): [True: 0, False: 500]
  ------------------
  695|      0|            NEEDBITS(32);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  696|      0|            strm->adler = state->check = ZSWAP32(hold);
  ------------------
  |  |  258|      0|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|      0|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
  697|      0|            INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  698|      0|            state->mode = DICT;
  699|       |                /* fallthrough */
  700|      0|        case DICT:
  ------------------
  |  Branch (700:9): [True: 0, False: 500]
  ------------------
  701|      0|            if (state->havedict == 0) {
  ------------------
  |  Branch (701:17): [True: 0, False: 0]
  ------------------
  702|      0|                RESTORE();
  ------------------
  |  |  340|      0|    do { \
  |  |  341|      0|        strm->next_out = put; \
  |  |  342|      0|        strm->avail_out = left; \
  |  |  343|      0|        strm->next_in = next; \
  |  |  344|      0|        strm->avail_in = have; \
  |  |  345|      0|        state->hold = hold; \
  |  |  346|      0|        state->bits = bits; \
  |  |  347|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  703|      0|                return Z_NEED_DICT;
  ------------------
  |  |  183|      0|#define Z_NEED_DICT     2
  ------------------
  704|      0|            }
  705|      0|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  706|      0|            state->mode = TYPE;
  707|       |                /* fallthrough */
  708|      4|        case TYPE:
  ------------------
  |  Branch (708:9): [True: 4, False: 496]
  ------------------
  709|      4|            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  177|      8|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|      4|#define Z_TREES         6
  ------------------
  |  Branch (709:17): [True: 0, False: 4]
  |  Branch (709:37): [True: 0, False: 4]
  ------------------
  710|       |                /* fallthrough */
  711|      4|        case TYPEDO:
  ------------------
  |  Branch (711:9): [True: 0, False: 500]
  ------------------
  712|      4|            if (state->last) {
  ------------------
  |  Branch (712:17): [True: 2, False: 2]
  ------------------
  713|      2|                BYTEBITS();
  ------------------
  |  |  387|      2|    do { \
  |  |  388|      2|        hold >>= bits & 7; \
  |  |  389|      2|        bits -= bits & 7; \
  |  |  390|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  714|      2|                state->mode = CHECK;
  715|      2|                break;
  716|      2|            }
  717|      2|            NEEDBITS(3);
  ------------------
  |  |  369|      2|    do { \
  |  |  370|      4|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 2, False: 2]
  |  |  ------------------
  |  |  371|      2|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      2|    do { \
  |  |  |  |  360|      2|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  361|      2|        have--; \
  |  |  |  |  362|      2|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      2|        bits += 8; \
  |  |  |  |  364|      2|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  718|      2|            state->last = BITS(1);
  ------------------
  |  |  376|      2|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  719|      2|            DROPBITS(1);
  ------------------
  |  |  380|      2|    do { \
  |  |  381|      2|        hold >>= (n); \
  |  |  382|      2|        bits -= (unsigned)(n); \
  |  |  383|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  720|      2|            switch (BITS(2)) {
  ------------------
  |  |  376|      2|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  721|      0|            case 0:                             /* stored block */
  ------------------
  |  Branch (721:13): [True: 0, False: 2]
  ------------------
  722|      0|                Tracev((stderr, "inflate:     stored block%s\n",
  723|      0|                        state->last ? " (last)" : ""));
  724|      0|                state->mode = STORED;
  725|      0|                break;
  726|      2|            case 1:                             /* fixed block */
  ------------------
  |  Branch (726:13): [True: 2, False: 0]
  ------------------
  727|      2|                inflate_fixed(state);
  728|      2|                Tracev((stderr, "inflate:     fixed codes block%s\n",
  729|      2|                        state->last ? " (last)" : ""));
  730|      2|                state->mode = LEN_;             /* decode codes */
  731|      2|                if (flush == Z_TREES) {
  ------------------
  |  |  178|      2|#define Z_TREES         6
  ------------------
  |  Branch (731:21): [True: 0, False: 2]
  ------------------
  732|      0|                    DROPBITS(2);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  733|      0|                    goto inf_leave;
  734|      0|                }
  735|      2|                break;
  736|      2|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (736:13): [True: 0, False: 2]
  ------------------
  737|      0|                Tracev((stderr, "inflate:     dynamic codes block%s\n",
  738|      0|                        state->last ? " (last)" : ""));
  739|      0|                state->mode = TABLE;
  740|      0|                break;
  741|      0|            default:
  ------------------
  |  Branch (741:13): [True: 0, False: 2]
  ------------------
  742|      0|                strm->msg = (z_const char *)"invalid block type";
  743|      0|                state->mode = BAD;
  744|      2|            }
  745|      2|            DROPBITS(2);
  ------------------
  |  |  380|      2|    do { \
  |  |  381|      2|        hold >>= (n); \
  |  |  382|      2|        bits -= (unsigned)(n); \
  |  |  383|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  746|      2|            break;
  747|      0|        case STORED:
  ------------------
  |  Branch (747:9): [True: 0, False: 500]
  ------------------
  748|      0|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  387|      0|    do { \
  |  |  388|      0|        hold >>= bits & 7; \
  |  |  389|      0|        bits -= bits & 7; \
  |  |  390|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  749|      0|            NEEDBITS(32);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  750|      0|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (750:17): [True: 0, False: 0]
  ------------------
  751|      0|                strm->msg = (z_const char *)"invalid stored block lengths";
  752|      0|                state->mode = BAD;
  753|      0|                break;
  754|      0|            }
  755|      0|            state->length = (unsigned)hold & 0xffff;
  756|      0|            Tracev((stderr, "inflate:       stored length %u\n",
  757|      0|                    state->length));
  758|      0|            INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  759|      0|            state->mode = COPY_;
  760|      0|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|      0|#define Z_TREES         6
  ------------------
  |  Branch (760:17): [True: 0, False: 0]
  ------------------
  761|       |                /* fallthrough */
  762|      0|        case COPY_:
  ------------------
  |  Branch (762:9): [True: 0, False: 500]
  ------------------
  763|      0|            state->mode = COPY;
  764|       |                /* fallthrough */
  765|      0|        case COPY:
  ------------------
  |  Branch (765:9): [True: 0, False: 500]
  ------------------
  766|      0|            copy = state->length;
  767|      0|            if (copy) {
  ------------------
  |  Branch (767:17): [True: 0, False: 0]
  ------------------
  768|      0|                if (copy > have) copy = have;
  ------------------
  |  Branch (768:21): [True: 0, False: 0]
  ------------------
  769|      0|                if (copy > left) copy = left;
  ------------------
  |  Branch (769:21): [True: 0, False: 0]
  ------------------
  770|      0|                if (copy == 0) goto inf_leave;
  ------------------
  |  Branch (770:21): [True: 0, False: 0]
  ------------------
  771|      0|                zmemcpy(put, next, copy);
  ------------------
  |  |  216|      0|#    define zmemcpy memcpy
  ------------------
  772|      0|                have -= copy;
  773|      0|                next += copy;
  774|      0|                left -= copy;
  775|      0|                put += copy;
  776|      0|                state->length -= copy;
  777|      0|                break;
  778|      0|            }
  779|      0|            Tracev((stderr, "inflate:       stored end\n"));
  780|      0|            state->mode = TYPE;
  781|      0|            break;
  782|      0|        case TABLE:
  ------------------
  |  Branch (782:9): [True: 0, False: 500]
  ------------------
  783|      0|            NEEDBITS(14);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  784|      0|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  785|      0|            DROPBITS(5);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  786|      0|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  787|      0|            DROPBITS(5);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  788|      0|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  789|      0|            DROPBITS(4);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  790|      0|#ifndef PKZIP_BUG_WORKAROUND
  791|      0|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (791:17): [True: 0, False: 0]
  |  Branch (791:38): [True: 0, False: 0]
  ------------------
  792|      0|                strm->msg = (z_const char *)
  793|      0|                    "too many length or distance symbols";
  794|      0|                state->mode = BAD;
  795|      0|                break;
  796|      0|            }
  797|      0|#endif
  798|      0|            Tracev((stderr, "inflate:       table sizes ok\n"));
  799|      0|            state->have = 0;
  800|      0|            state->mode = LENLENS;
  801|       |                /* fallthrough */
  802|      0|        case LENLENS:
  ------------------
  |  Branch (802:9): [True: 0, False: 500]
  ------------------
  803|      0|            while (state->have < state->ncode) {
  ------------------
  |  Branch (803:20): [True: 0, False: 0]
  ------------------
  804|      0|                NEEDBITS(3);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  805|      0|                state->lens[order[state->have++]] = (unsigned short)BITS(3);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  806|      0|                DROPBITS(3);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  807|      0|            }
  808|      0|            while (state->have < 19)
  ------------------
  |  Branch (808:20): [True: 0, False: 0]
  ------------------
  809|      0|                state->lens[order[state->have++]] = 0;
  810|      0|            state->next = state->codes;
  811|      0|            state->lencode = state->distcode = (const code FAR *)(state->next);
  812|      0|            state->lenbits = 7;
  813|      0|            ret = inflate_table(CODES, state->lens, 19, &(state->next),
  814|      0|                                &(state->lenbits), state->work);
  815|      0|            if (ret) {
  ------------------
  |  Branch (815:17): [True: 0, False: 0]
  ------------------
  816|      0|                strm->msg = (z_const char *)"invalid code lengths set";
  817|      0|                state->mode = BAD;
  818|      0|                break;
  819|      0|            }
  820|      0|            Tracev((stderr, "inflate:       code lengths ok\n"));
  821|      0|            state->have = 0;
  822|      0|            state->mode = CODELENS;
  823|       |                /* fallthrough */
  824|      0|        case CODELENS:
  ------------------
  |  Branch (824:9): [True: 0, False: 500]
  ------------------
  825|      0|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (825:20): [True: 0, False: 0]
  ------------------
  826|      0|                for (;;) {
  827|      0|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  828|      0|                    if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (828:25): [True: 0, False: 0]
  ------------------
  829|      0|                    PULLBYTE();
  ------------------
  |  |  359|      0|    do { \
  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  361|      0|        have--; \
  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|      0|        bits += 8; \
  |  |  364|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  830|      0|                }
  831|      0|                if (here.val < 16) {
  ------------------
  |  Branch (831:21): [True: 0, False: 0]
  ------------------
  832|      0|                    DROPBITS(here.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  833|      0|                    state->lens[state->have++] = here.val;
  834|      0|                }
  835|      0|                else {
  836|      0|                    if (here.val == 16) {
  ------------------
  |  Branch (836:25): [True: 0, False: 0]
  ------------------
  837|      0|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  838|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  839|      0|                        if (state->have == 0) {
  ------------------
  |  Branch (839:29): [True: 0, False: 0]
  ------------------
  840|      0|                            strm->msg = (z_const char *)
  841|      0|                                "invalid bit length repeat";
  842|      0|                            state->mode = BAD;
  843|      0|                            break;
  844|      0|                        }
  845|      0|                        len = state->lens[state->have - 1];
  846|      0|                        copy = 3 + BITS(2);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  847|      0|                        DROPBITS(2);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  848|      0|                    }
  849|      0|                    else if (here.val == 17) {
  ------------------
  |  Branch (849:30): [True: 0, False: 0]
  ------------------
  850|      0|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  851|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  852|      0|                        len = 0;
  853|      0|                        copy = 3 + BITS(3);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  854|      0|                        DROPBITS(3);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  855|      0|                    }
  856|      0|                    else {
  857|      0|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  858|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  859|      0|                        len = 0;
  860|      0|                        copy = 11 + BITS(7);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  861|      0|                        DROPBITS(7);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  862|      0|                    }
  863|      0|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (863:25): [True: 0, False: 0]
  ------------------
  864|      0|                        strm->msg = (z_const char *)
  865|      0|                            "invalid bit length repeat";
  866|      0|                        state->mode = BAD;
  867|      0|                        break;
  868|      0|                    }
  869|      0|                    while (copy--)
  ------------------
  |  Branch (869:28): [True: 0, False: 0]
  ------------------
  870|      0|                        state->lens[state->have++] = (unsigned short)len;
  871|      0|                }
  872|      0|            }
  873|       |
  874|       |            /* handle error breaks in while */
  875|      0|            if (state->mode == BAD) break;
  ------------------
  |  Branch (875:17): [True: 0, False: 0]
  ------------------
  876|       |
  877|       |            /* check for end-of-block code (better have one) */
  878|      0|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (878:17): [True: 0, False: 0]
  ------------------
  879|      0|                strm->msg = (z_const char *)
  880|      0|                    "invalid code -- missing end-of-block";
  881|      0|                state->mode = BAD;
  882|      0|                break;
  883|      0|            }
  884|       |
  885|       |            /* build code tables -- note: do not change the lenbits or distbits
  886|       |               values here (9 and 6) without reading the comments in inftrees.h
  887|       |               concerning the ENOUGH constants, which depend on those values */
  888|      0|            state->next = state->codes;
  889|      0|            state->lencode = (const code FAR *)(state->next);
  890|      0|            state->lenbits = 9;
  891|      0|            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
  892|      0|                                &(state->lenbits), state->work);
  893|      0|            if (ret) {
  ------------------
  |  Branch (893:17): [True: 0, False: 0]
  ------------------
  894|      0|                strm->msg = (z_const char *)"invalid literal/lengths set";
  895|      0|                state->mode = BAD;
  896|      0|                break;
  897|      0|            }
  898|      0|            state->distcode = (const code FAR *)(state->next);
  899|      0|            state->distbits = 6;
  900|      0|            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  901|      0|                            &(state->next), &(state->distbits), state->work);
  902|      0|            if (ret) {
  ------------------
  |  Branch (902:17): [True: 0, False: 0]
  ------------------
  903|      0|                strm->msg = (z_const char *)"invalid distances set";
  904|      0|                state->mode = BAD;
  905|      0|                break;
  906|      0|            }
  907|      0|            Tracev((stderr, "inflate:       codes ok\n"));
  908|      0|            state->mode = LEN_;
  909|      0|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|      0|#define Z_TREES         6
  ------------------
  |  Branch (909:17): [True: 0, False: 0]
  ------------------
  910|       |                /* fallthrough */
  911|      2|        case LEN_:
  ------------------
  |  Branch (911:9): [True: 2, False: 498]
  ------------------
  912|      2|            state->mode = LEN;
  913|       |                /* fallthrough */
  914|     48|        case LEN:
  ------------------
  |  Branch (914:9): [True: 46, False: 454]
  ------------------
  915|     48|            if (have >= 6 && left >= 258) {
  ------------------
  |  Branch (915:17): [True: 48, False: 0]
  |  Branch (915:30): [True: 2, False: 46]
  ------------------
  916|      2|                RESTORE();
  ------------------
  |  |  340|      2|    do { \
  |  |  341|      2|        strm->next_out = put; \
  |  |  342|      2|        strm->avail_out = left; \
  |  |  343|      2|        strm->next_in = next; \
  |  |  344|      2|        strm->avail_in = have; \
  |  |  345|      2|        state->hold = hold; \
  |  |  346|      2|        state->bits = bits; \
  |  |  347|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  917|      2|                inflate_fast(strm, out);
  918|      2|                LOAD();
  ------------------
  |  |  329|      2|    do { \
  |  |  330|      2|        put = strm->next_out; \
  |  |  331|      2|        left = strm->avail_out; \
  |  |  332|      2|        next = strm->next_in; \
  |  |  333|      2|        have = strm->avail_in; \
  |  |  334|      2|        hold = state->hold; \
  |  |  335|      2|        bits = state->bits; \
  |  |  336|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  919|      2|                if (state->mode == TYPE)
  ------------------
  |  Branch (919:21): [True: 0, False: 2]
  ------------------
  920|      0|                    state->back = -1;
  921|      2|                break;
  922|      2|            }
  923|     46|            state->back = 0;
  924|     96|            for (;;) {
  925|     96|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|     96|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  926|     96|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (926:21): [True: 46, False: 50]
  ------------------
  927|     50|                PULLBYTE();
  ------------------
  |  |  359|     50|    do { \
  |  |  360|     50|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 0, False: 50]
  |  |  ------------------
  |  |  361|     50|        have--; \
  |  |  362|     50|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|     50|        bits += 8; \
  |  |  364|     50|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 50]
  |  |  ------------------
  ------------------
  928|     50|            }
  929|     46|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (929:17): [True: 2, False: 44]
  |  Branch (929:28): [True: 0, False: 2]
  ------------------
  930|      0|                last = here;
  931|      0|                for (;;) {
  932|      0|                    here = state->lencode[last.val +
  933|      0|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  934|      0|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (934:25): [True: 0, False: 0]
  ------------------
  935|      0|                    PULLBYTE();
  ------------------
  |  |  359|      0|    do { \
  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  361|      0|        have--; \
  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|      0|        bits += 8; \
  |  |  364|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  936|      0|                }
  937|      0|                DROPBITS(last.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  938|      0|                state->back += last.bits;
  939|      0|            }
  940|     46|            DROPBITS(here.bits);
  ------------------
  |  |  380|     46|    do { \
  |  |  381|     46|        hold >>= (n); \
  |  |  382|     46|        bits -= (unsigned)(n); \
  |  |  383|     46|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 46]
  |  |  ------------------
  ------------------
  941|     46|            state->back += here.bits;
  942|     46|            state->length = (unsigned)here.val;
  943|     46|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (943:17): [True: 44, False: 2]
  ------------------
  944|     44|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  945|     44|                        "inflate:         literal '%c'\n" :
  946|     44|                        "inflate:         literal 0x%02x\n", here.val));
  947|     44|                state->mode = LIT;
  948|     44|                break;
  949|     44|            }
  950|      2|            if (here.op & 32) {
  ------------------
  |  Branch (950:17): [True: 2, False: 0]
  ------------------
  951|      2|                Tracevv((stderr, "inflate:         end of block\n"));
  952|      2|                state->back = -1;
  953|      2|                state->mode = TYPE;
  954|      2|                break;
  955|      2|            }
  956|      0|            if (here.op & 64) {
  ------------------
  |  Branch (956:17): [True: 0, False: 0]
  ------------------
  957|      0|                strm->msg = (z_const char *)"invalid literal/length code";
  958|      0|                state->mode = BAD;
  959|      0|                break;
  960|      0|            }
  961|      0|            state->extra = (unsigned)(here.op) & 15;
  962|      0|            state->mode = LENEXT;
  963|       |                /* fallthrough */
  964|      0|        case LENEXT:
  ------------------
  |  Branch (964:9): [True: 0, False: 500]
  ------------------
  965|      0|            if (state->extra) {
  ------------------
  |  Branch (965:17): [True: 0, False: 0]
  ------------------
  966|      0|                NEEDBITS(state->extra);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  967|      0|                state->length += BITS(state->extra);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  968|      0|                DROPBITS(state->extra);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  969|      0|                state->back += state->extra;
  970|      0|            }
  971|      0|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  972|      0|            state->was = state->length;
  973|      0|            state->mode = DIST;
  974|       |                /* fallthrough */
  975|      0|        case DIST:
  ------------------
  |  Branch (975:9): [True: 0, False: 500]
  ------------------
  976|      0|            for (;;) {
  977|      0|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  978|      0|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (978:21): [True: 0, False: 0]
  ------------------
  979|      0|                PULLBYTE();
  ------------------
  |  |  359|      0|    do { \
  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  361|      0|        have--; \
  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|      0|        bits += 8; \
  |  |  364|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  980|      0|            }
  981|      0|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (981:17): [True: 0, False: 0]
  ------------------
  982|      0|                last = here;
  983|      0|                for (;;) {
  984|      0|                    here = state->distcode[last.val +
  985|      0|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  986|      0|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (986:25): [True: 0, False: 0]
  ------------------
  987|      0|                    PULLBYTE();
  ------------------
  |  |  359|      0|    do { \
  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  361|      0|        have--; \
  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|      0|        bits += 8; \
  |  |  364|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  988|      0|                }
  989|      0|                DROPBITS(last.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  990|      0|                state->back += last.bits;
  991|      0|            }
  992|      0|            DROPBITS(here.bits);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  993|      0|            state->back += here.bits;
  994|      0|            if (here.op & 64) {
  ------------------
  |  Branch (994:17): [True: 0, False: 0]
  ------------------
  995|      0|                strm->msg = (z_const char *)"invalid distance code";
  996|      0|                state->mode = BAD;
  997|      0|                break;
  998|      0|            }
  999|      0|            state->offset = (unsigned)here.val;
 1000|      0|            state->extra = (unsigned)(here.op) & 15;
 1001|      0|            state->mode = DISTEXT;
 1002|       |                /* fallthrough */
 1003|      0|        case DISTEXT:
  ------------------
  |  Branch (1003:9): [True: 0, False: 500]
  ------------------
 1004|      0|            if (state->extra) {
  ------------------
  |  Branch (1004:17): [True: 0, False: 0]
  ------------------
 1005|      0|                NEEDBITS(state->extra);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1006|      0|                state->offset += BITS(state->extra);
  ------------------
  |  |  376|      0|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
 1007|      0|                DROPBITS(state->extra);
  ------------------
  |  |  380|      0|    do { \
  |  |  381|      0|        hold >>= (n); \
  |  |  382|      0|        bits -= (unsigned)(n); \
  |  |  383|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1008|      0|                state->back += state->extra;
 1009|      0|            }
 1010|       |#ifdef INFLATE_STRICT
 1011|       |            if (state->offset > state->dmax) {
 1012|       |                strm->msg = (z_const char *)"invalid distance too far back";
 1013|       |                state->mode = BAD;
 1014|       |                break;
 1015|       |            }
 1016|       |#endif
 1017|      0|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1018|      0|            state->mode = MATCH;
 1019|       |                /* fallthrough */
 1020|      0|        case MATCH:
  ------------------
  |  Branch (1020:9): [True: 0, False: 500]
  ------------------
 1021|      0|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1021:17): [True: 0, False: 0]
  ------------------
 1022|      0|            copy = out - left;
 1023|      0|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1023:17): [True: 0, False: 0]
  ------------------
 1024|      0|                copy = state->offset - copy;
 1025|      0|                if (copy > state->whave) {
  ------------------
  |  Branch (1025:21): [True: 0, False: 0]
  ------------------
 1026|      0|                    if (state->sane) {
  ------------------
  |  Branch (1026:25): [True: 0, False: 0]
  ------------------
 1027|      0|                        strm->msg = (z_const char *)
 1028|      0|                            "invalid distance too far back";
 1029|      0|                        state->mode = BAD;
 1030|      0|                        break;
 1031|      0|                    }
 1032|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
 1033|       |                    Trace((stderr, "inflate.c too far\n"));
 1034|       |                    copy -= state->whave;
 1035|       |                    if (copy > state->length) copy = state->length;
 1036|       |                    if (copy > left) copy = left;
 1037|       |                    left -= copy;
 1038|       |                    state->length -= copy;
 1039|       |                    do {
 1040|       |                        *put++ = 0;
 1041|       |                    } while (--copy);
 1042|       |                    if (state->length == 0) state->mode = LEN;
 1043|       |                    break;
 1044|       |#endif
 1045|      0|                }
 1046|      0|                if (copy > state->wnext) {
  ------------------
  |  Branch (1046:21): [True: 0, False: 0]
  ------------------
 1047|      0|                    copy -= state->wnext;
 1048|      0|                    from = state->window + (state->wsize - copy);
 1049|      0|                }
 1050|      0|                else
 1051|      0|                    from = state->window + (state->wnext - copy);
 1052|      0|                if (copy > state->length) copy = state->length;
  ------------------
  |  Branch (1052:21): [True: 0, False: 0]
  ------------------
 1053|      0|            }
 1054|      0|            else {                              /* copy from output */
 1055|      0|                from = put - state->offset;
 1056|      0|                copy = state->length;
 1057|      0|            }
 1058|      0|            if (copy > left) copy = left;
  ------------------
  |  Branch (1058:17): [True: 0, False: 0]
  ------------------
 1059|      0|            left -= copy;
 1060|      0|            state->length -= copy;
 1061|      0|            do {
 1062|      0|                *put++ = *from++;
 1063|      0|            } while (--copy);
  ------------------
  |  Branch (1063:22): [True: 0, False: 0]
  ------------------
 1064|      0|            if (state->length == 0) state->mode = LEN;
  ------------------
  |  Branch (1064:17): [True: 0, False: 0]
  ------------------
 1065|      0|            break;
 1066|     44|        case LIT:
  ------------------
  |  Branch (1066:9): [True: 44, False: 456]
  ------------------
 1067|     44|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1067:17): [True: 0, False: 44]
  ------------------
 1068|     44|            *put++ = (unsigned char)(state->length);
 1069|     44|            left--;
 1070|     44|            state->mode = LEN;
 1071|     44|            break;
 1072|      2|        case CHECK:
  ------------------
  |  Branch (1072:9): [True: 2, False: 498]
  ------------------
 1073|      2|            if (state->wrap) {
  ------------------
  |  Branch (1073:17): [True: 2, False: 0]
  ------------------
 1074|      2|                NEEDBITS(32);
  ------------------
  |  |  369|      2|    do { \
  |  |  370|     10|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 8, False: 2]
  |  |  ------------------
  |  |  371|      8|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      8|    do { \
  |  |  |  |  360|      8|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  361|      8|        have--; \
  |  |  |  |  362|      8|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      8|        bits += 8; \
  |  |  |  |  364|      8|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1075|      2|                out -= left;
 1076|      2|                strm->total_out += out;
 1077|      2|                state->total += out;
 1078|      2|                if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1078:21): [True: 2, False: 0]
  |  Branch (1078:42): [True: 2, False: 0]
  ------------------
 1079|      2|                    strm->adler = state->check =
 1080|      2|                        UPDATE_CHECK(state->check, put - out, out);
  ------------------
  |  |  303|      2|    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
  |  |  ------------------
  |  |  |  Branch (303:6): [True: 0, False: 2]
  |  |  ------------------
  ------------------
 1081|      2|                out = left;
 1082|      2|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1082:21): [True: 2, False: 0]
  |  Branch (1082:42): [True: 2, False: 0]
  ------------------
 1083|      2|#ifdef GUNZIP
 1084|      2|                     state->flags ? hold :
  ------------------
  |  Branch (1084:22): [True: 0, False: 2]
  ------------------
 1085|      2|#endif
 1086|      2|                     ZSWAP32(hold)) != state->check) {
  ------------------
  |  |  258|      2|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|      2|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
 1087|      2|                    strm->msg = (z_const char *)"incorrect data check";
 1088|      2|                    state->mode = BAD;
 1089|      2|                    break;
 1090|      2|                }
 1091|      0|                INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1092|      0|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1093|      0|            }
 1094|      0|#ifdef GUNZIP
 1095|      0|            state->mode = LENGTH;
 1096|       |                /* fallthrough */
 1097|      0|        case LENGTH:
  ------------------
  |  Branch (1097:9): [True: 0, False: 500]
  ------------------
 1098|      0|            if (state->wrap && state->flags) {
  ------------------
  |  Branch (1098:17): [True: 0, False: 0]
  |  Branch (1098:32): [True: 0, False: 0]
  ------------------
 1099|      0|                NEEDBITS(32);
  ------------------
  |  |  369|      0|    do { \
  |  |  370|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  371|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|      0|    do { \
  |  |  |  |  360|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  361|      0|        have--; \
  |  |  |  |  362|      0|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|      0|        bits += 8; \
  |  |  |  |  364|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1100|      0|                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
  ------------------
  |  Branch (1100:21): [True: 0, False: 0]
  |  Branch (1100:42): [True: 0, False: 0]
  ------------------
 1101|      0|                    strm->msg = (z_const char *)"incorrect length check";
 1102|      0|                    state->mode = BAD;
 1103|      0|                    break;
 1104|      0|                }
 1105|      0|                INITBITS();
  ------------------
  |  |  351|      0|    do { \
  |  |  352|      0|        hold = 0; \
  |  |  353|      0|        bits = 0; \
  |  |  354|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1106|      0|                Tracev((stderr, "inflate:   length matches trailer\n"));
 1107|      0|            }
 1108|      0|#endif
 1109|      0|            state->mode = DONE;
 1110|       |                /* fallthrough */
 1111|      0|        case DONE:
  ------------------
  |  Branch (1111:9): [True: 0, False: 500]
  ------------------
 1112|      0|            ret = Z_STREAM_END;
  ------------------
  |  |  182|      0|#define Z_STREAM_END    1
  ------------------
 1113|      0|            goto inf_leave;
 1114|    194|        case BAD:
  ------------------
  |  Branch (1114:9): [True: 194, False: 306]
  ------------------
 1115|    194|            ret = Z_DATA_ERROR;
  ------------------
  |  |  186|    194|#define Z_DATA_ERROR   (-3)
  ------------------
 1116|    194|            goto inf_leave;
 1117|      0|        case MEM:
  ------------------
  |  Branch (1117:9): [True: 0, False: 500]
  ------------------
 1118|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1119|      0|        case SYNC:
  ------------------
  |  Branch (1119:9): [True: 0, False: 500]
  ------------------
 1120|       |                /* fallthrough */
 1121|      0|        default:
  ------------------
  |  Branch (1121:9): [True: 0, False: 500]
  ------------------
 1122|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1123|    500|        }
 1124|       |
 1125|       |    /*
 1126|       |       Return from inflate(), updating the total counts and the check value.
 1127|       |       If there was no progress during the inflate() call, return a buffer
 1128|       |       error.  Call updatewindow() to create and/or update the window state.
 1129|       |       Note: a memory error from inflate() is non-recoverable.
 1130|       |     */
 1131|    208|  inf_leave:
 1132|    208|    RESTORE();
  ------------------
  |  |  340|    208|    do { \
  |  |  341|    208|        strm->next_out = put; \
  |  |  342|    208|        strm->avail_out = left; \
  |  |  343|    208|        strm->next_in = next; \
  |  |  344|    208|        strm->avail_in = have; \
  |  |  345|    208|        state->hold = hold; \
  |  |  346|    208|        state->bits = bits; \
  |  |  347|    208|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 208]
  |  |  ------------------
  ------------------
 1133|    208|    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1133:9): [True: 0, False: 208]
  |  Branch (1133:26): [True: 0, False: 208]
  |  Branch (1133:52): [True: 0, False: 0]
  ------------------
 1134|      0|            (state->mode < CHECK || flush != Z_FINISH)))
  ------------------
  |  |  176|      0|#define Z_FINISH        4
  ------------------
  |  Branch (1134:14): [True: 0, False: 0]
  |  Branch (1134:37): [True: 0, False: 0]
  ------------------
 1135|      0|        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
  ------------------
  |  Branch (1135:13): [True: 0, False: 0]
  ------------------
 1136|      0|            state->mode = MEM;
 1137|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1138|      0|        }
 1139|    208|    in -= strm->avail_in;
 1140|    208|    out -= strm->avail_out;
 1141|    208|    strm->total_in += in;
 1142|    208|    strm->total_out += out;
 1143|    208|    state->total += out;
 1144|    208|    if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1144:9): [True: 208, False: 0]
  |  Branch (1144:30): [True: 0, False: 208]
  ------------------
 1145|      0|        strm->adler = state->check =
 1146|      0|            UPDATE_CHECK(state->check, strm->next_out - out, out);
  ------------------
  |  |  303|      0|    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
  |  |  ------------------
  |  |  |  Branch (303:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1147|    208|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1147:43): [True: 2, False: 206]
  ------------------
 1148|    208|                      (state->mode == TYPE ? 128 : 0) +
  ------------------
  |  Branch (1148:24): [True: 0, False: 208]
  ------------------
 1149|    208|                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1149:24): [True: 0, False: 208]
  |  Branch (1149:47): [True: 0, False: 208]
  ------------------
 1150|    208|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  176|    201|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  181|      7|#define Z_OK            0
  ------------------
  |  Branch (1150:11): [True: 7, False: 201]
  |  Branch (1150:22): [True: 7, False: 0]
  |  Branch (1150:35): [True: 0, False: 201]
  |  Branch (1150:57): [True: 7, False: 0]
  ------------------
 1151|      7|        ret = Z_BUF_ERROR;
  ------------------
  |  |  188|      7|#define Z_BUF_ERROR    (-5)
  ------------------
 1152|    208|    return ret;
 1153|    208|}
inflateEnd:
 1155|     60|int ZEXPORT inflateEnd(z_streamp strm) {
 1156|     60|    struct inflate_state FAR *state;
 1157|     60|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1157:9): [True: 0, False: 60]
  ------------------
 1158|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1159|     60|    state = (struct inflate_state FAR *)strm->state;
 1160|     60|    if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  254|      0|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  |  Branch (1160:9): [True: 0, False: 60]
  ------------------
 1161|     60|    ZFREE(strm, strm->state);
  ------------------
  |  |  254|     60|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
 1162|     60|    strm->state = Z_NULL;
  ------------------
  |  |  216|     60|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
 1163|     60|    Tracev((stderr, "inflate: end\n"));
 1164|     60|    return Z_OK;
  ------------------
  |  |  181|     60|#define Z_OK            0
  ------------------
 1165|     60|}
inflate.c:inflateStateCheck:
   88|    854|local int inflateStateCheck(z_streamp strm) {
   89|    854|    struct inflate_state FAR *state;
   90|    854|    if (strm == Z_NULL ||
  ------------------
  |  |  216|  1.70k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (90:9): [True: 0, False: 854]
  ------------------
   91|    854|        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (91:9): [True: 0, False: 854]
  |  Branch (91:42): [True: 0, False: 854]
  ------------------
   92|      0|        return 1;
   93|    854|    state = (struct inflate_state FAR *)strm->state;
   94|    854|    if (state == Z_NULL || state->strm != strm ||
  ------------------
  |  |  216|  1.70k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (94:9): [True: 0, False: 854]
  |  Branch (94:28): [True: 0, False: 854]
  ------------------
   95|    854|        state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (95:9): [True: 0, False: 854]
  |  Branch (95:31): [True: 0, False: 854]
  ------------------
   96|      0|        return 1;
   97|    854|    return 0;
   98|    854|}

inflate_fixed:
  364|      2|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|      2|    state->lencode = lenfix;
  369|      2|    state->lenbits = 9;
  370|      2|    state->distcode = distfix;
  371|      2|    state->distbits = 5;
  372|      2|}

zcalloc:
  299|     43|voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
  300|     43|    (void)opaque;
  301|     43|    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
  ------------------
  |  Branch (301:12): [True: 43, Folded]
  ------------------
  302|     43|                              (voidpf)calloc(items, size);
  303|     43|}
zcfree:
  305|     43|void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
  306|     43|    (void)opaque;
  307|     43|    free(ptr);
  308|     43|}

