jsimd_set_idct_islow:
 1153|    888|{
 1154|    888|  init_simd((j_common_ptr)cinfo);
 1155|       |
 1156|    888|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1156:7): [Folded, False: 888]
  ------------------
 1157|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1158|    888|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|    888|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (1158:7): [Folded, False: 888]
  ------------------
 1159|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1160|    888|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (1160:7): [Folded, False: 888]
  ------------------
 1161|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1162|    888|  if (sizeof(ISLOW_MULT_TYPE) != 2)
  ------------------
  |  Branch (1162:7): [Folded, False: 888]
  ------------------
 1163|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1164|    888|  if (!cinfo->idct)
  ------------------
  |  Branch (1164:7): [True: 0, False: 888]
  ------------------
 1165|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1166|       |
 1167|    888|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1168|    888|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|    888|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (1168:7): [True: 888, False: 0]
  ------------------
 1169|    888|      IS_ALIGNED_AVX(jconst_idct_islow_avx2)) {
  ------------------
  |  |   46|    888|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|    888|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 888, False: 0]
  |  |  ------------------
  ------------------
 1170|    888|    cinfo->idct->idct_simd = jsimd_idct_islow_avx2;
 1171|    888|    return JSIMD_AVX2;
  ------------------
  |  |   46|    888|#define JSIMD_AVX2       0x80
  ------------------
 1172|    888|  }
 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.25M|{
 1215|  1.25M|  cinfo->idct->idct_simd(compptr->dct_table, coef_block, output_buf,
 1216|  1.25M|                         output_col);
 1217|  1.25M|}
jsimd.c:init_simd:
   56|    888|{
   57|    888|#ifndef NO_GETENV
   58|    888|  char env[2] = { 0 };
   59|    888|#endif
   60|    888|  unsigned int simd_support = cinfo->is_decompressor ?
  ------------------
  |  Branch (60:31): [True: 888, False: 0]
  ------------------
   61|    888|                              ((j_decompress_ptr)cinfo)->master->simd_support :
   62|    888|                              ((j_compress_ptr)cinfo)->master->simd_support;
   63|    888|  unsigned int simd_huffman = cinfo->is_decompressor ?
  ------------------
  |  Branch (63:31): [True: 888, False: 0]
  ------------------
   64|    888|                              ((j_decompress_ptr)cinfo)->master->simd_huffman :
   65|    888|                              ((j_compress_ptr)cinfo)->master->simd_huffman;
   66|       |
   67|    888|  if (simd_support != JSIMD_UNDEFINED)
  ------------------
  |  |   49|    888|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|    888|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  |  Branch (67:7): [True: 0, False: 888]
  ------------------
   68|      0|    return;
   69|       |
   70|    888|  simd_support = jpeg_simd_cpu_support();
   71|       |
   72|    888|#ifndef NO_GETENV
   73|       |  /* Force different settings through environment variables */
   74|    888|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
   75|    888|  if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
  ------------------
  |  Branch (75:7): [True: 888, False: 0]
  |  Branch (75:47): [True: 0, False: 888]
  ------------------
   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|    888|  if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
  ------------------
  |  Branch (95:7): [True: 888, False: 0]
  |  Branch (95:47): [True: 0, False: 888]
  ------------------
   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|    888|  if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
  ------------------
  |  Branch (101:7): [True: 888, False: 0]
  |  Branch (101:47): [True: 0, False: 888]
  ------------------
  102|      0|    simd_huffman = 0;
  103|    888|#endif
  104|    888|#endif
  105|       |
  106|    888|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (106:7): [True: 888, False: 0]
  ------------------
  107|    888|    ((j_decompress_ptr)cinfo)->master->simd_support = simd_support;
  108|    888|    ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  109|    888|  } 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|    888|}

jpeg_abort:
   37|  2.66k|{
   38|  2.66k|  int pool;
   39|       |
   40|       |  /* Do nothing if called on a not-initialized or destroyed JPEG object. */
   41|  2.66k|  if (cinfo->mem == NULL)
  ------------------
  |  Branch (41:7): [True: 0, False: 2.66k]
  ------------------
   42|      0|    return;
   43|       |
   44|       |  /* Releasing pools in reverse order might help avoid fragmentation
   45|       |   * with some (brain-damaged) malloc libraries.
   46|       |   */
   47|  5.32k|  for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  2.66k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|  5.32k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (47:35): [True: 2.66k, False: 2.66k]
  ------------------
   48|  2.66k|    (*cinfo->mem->free_pool) (cinfo, pool);
   49|  2.66k|  }
   50|       |
   51|       |  /* Reset overall state for possible reuse of object */
   52|  2.66k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (52:7): [True: 2.66k, False: 0]
  ------------------
   53|  2.66k|    cinfo->global_state = DSTATE_START;
  ------------------
  |  |   48|  2.66k|#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|  2.66k|    ((j_decompress_ptr)cinfo)->marker_list = NULL;
   58|  2.66k|    ((j_decompress_ptr)cinfo)->master->marker_list_end = NULL;
   59|  2.66k|  } 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|  2.66k|}
jpeg_destroy:
   90|  1.15k|{
   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|  1.15k|  if (cinfo->mem != NULL)
  ------------------
  |  Branch (210:7): [True: 1.15k, False: 0]
  ------------------
  211|  1.15k|    (*cinfo->mem->self_destruct) (cinfo);
  212|       |  cinfo->mem = NULL;            /* be safe if jpeg_destroy is called twice */
  213|  1.15k|  cinfo->global_state = 0;      /* mark it destroyed */
  214|  1.15k|}
jpeg_alloc_quant_table:
  224|    951|{
  225|    951|  JQUANT_TBL *tbl;
  226|       |
  227|    951|  tbl = (JQUANT_TBL *)
  228|    951|    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JQUANT_TBL));
  ------------------
  |  |  888|    951|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  229|    951|  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
  ------------------
  |  |  207|    951|#define FALSE   0               /* values of boolean */
  ------------------
  230|    951|  return tbl;
  231|    951|}
jpeg_alloc_huff_table:
  236|  3.57k|{
  237|  3.57k|  JHUFF_TBL *tbl;
  238|       |
  239|  3.57k|  tbl = (JHUFF_TBL *)
  240|  3.57k|    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JHUFF_TBL));
  ------------------
  |  |  888|  3.57k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  241|  3.57k|  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
  ------------------
  |  |  207|  3.57k|#define FALSE   0               /* values of boolean */
  ------------------
  242|  3.57k|  return tbl;
  243|  3.57k|}

jpeg_CreateDecompress:
   40|  1.15k|{
   41|  1.15k|  int i;
   42|       |
   43|       |  /* Guard against version mismatches between library and caller. */
   44|  1.15k|  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
   45|  1.15k|  if (version != JPEG_LIB_VERSION)
  ------------------
  |  |    4|  1.15k|#define JPEG_LIB_VERSION  62
  ------------------
  |  Branch (45:7): [True: 0, False: 1.15k]
  ------------------
   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|  1.15k|  if (structsize != sizeof(struct jpeg_decompress_struct))
  ------------------
  |  Branch (47:7): [True: 0, False: 1.15k]
  ------------------
   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|  1.15k|             (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|  1.15k|  {
   58|  1.15k|    struct jpeg_error_mgr *err = cinfo->err;
   59|  1.15k|    void *client_data = cinfo->client_data; /* ignore Purify complaint here */
   60|  1.15k|    memset(cinfo, 0, sizeof(struct jpeg_decompress_struct));
   61|  1.15k|    cinfo->err = err;
   62|  1.15k|    cinfo->client_data = client_data;
   63|  1.15k|  }
   64|  1.15k|  cinfo->is_decompressor = TRUE;
  ------------------
  |  |  210|  1.15k|#define TRUE    1
  ------------------
   65|       |
   66|       |  /* Initialize a memory manager instance for this object */
   67|  1.15k|  jinit_memory_mgr((j_common_ptr)cinfo);
   68|       |
   69|       |  /* Zero out pointers to permanent structures. */
   70|  1.15k|  cinfo->progress = NULL;
   71|  1.15k|  cinfo->src = NULL;
   72|       |
   73|  5.77k|  for (i = 0; i < NUM_QUANT_TBLS; i++)
  ------------------
  |  |   68|  5.77k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (73:15): [True: 4.62k, False: 1.15k]
  ------------------
   74|  4.62k|    cinfo->quant_tbl_ptrs[i] = NULL;
   75|       |
   76|  5.77k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  5.77k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (76:15): [True: 4.62k, False: 1.15k]
  ------------------
   77|  4.62k|    cinfo->dc_huff_tbl_ptrs[i] = NULL;
   78|  4.62k|    cinfo->ac_huff_tbl_ptrs[i] = NULL;
   79|  4.62k|  }
   80|       |
   81|       |  /* Initialize marker processor so application can override methods
   82|       |   * for COM, APPn markers before calling jpeg_read_header.
   83|       |   */
   84|  1.15k|  cinfo->marker_list = NULL;
   85|  1.15k|  jinit_marker_reader(cinfo);
   86|       |
   87|       |  /* And initialize the overall input controller. */
   88|  1.15k|  jinit_input_controller(cinfo);
   89|       |
   90|  1.15k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  |   34|  1.15k|#define BITS_IN_JSAMPLE  8
  ------------------
   91|       |
   92|       |  /* OK, I'm ready */
   93|  1.15k|  cinfo->global_state = DSTATE_START;
  ------------------
  |  |   48|  1.15k|#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|  1.15k|  cinfo->master = (struct jpeg_decomp_master *)
   99|  1.15k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  1.15k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  100|  1.15k|                                sizeof(my_decomp_master));
  101|  1.15k|  memset(cinfo->master, 0, sizeof(my_decomp_master));
  102|  1.15k|#ifdef WITH_SIMD
  103|  1.15k|  cinfo->master->simd_support = JSIMD_UNDEFINED;
  ------------------
  |  |   49|  1.15k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  1.15k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  104|  1.15k|#ifndef WITH_SIMDE
  105|  1.15k|  cinfo->master->simd_huffman = 1;
  106|  1.15k|#endif
  107|  1.15k|#endif
  108|  1.15k|}
jpeg_read_header:
  277|  2.27k|{
  278|  2.27k|  int retcode;
  279|       |
  280|  2.27k|  if (cinfo->global_state != DSTATE_START &&
  ------------------
  |  |   48|  4.54k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
  |  Branch (280:7): [True: 0, False: 2.27k]
  ------------------
  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|  2.27k|  retcode = jpeg_consume_input(cinfo);
  285|       |
  286|  2.27k|  switch (retcode) {
  ------------------
  |  Branch (286:11): [True: 1.16k, False: 1.10k]
  ------------------
  287|    960|  case JPEG_REACHED_SOS:
  ------------------
  |  | 1111|    960|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (287:3): [True: 960, False: 1.31k]
  ------------------
  288|    960|    retcode = JPEG_HEADER_OK;
  ------------------
  |  | 1066|    960|#define JPEG_HEADER_OK           1 /* Found valid image datastream */
  ------------------
  289|    960|    break;
  290|    202|  case JPEG_REACHED_EOI:
  ------------------
  |  | 1112|    202|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  |  Branch (290:3): [True: 202, False: 2.06k]
  ------------------
  291|    202|    if (require_image)          /* Complain if application wanted an image */
  ------------------
  |  Branch (291:9): [True: 202, False: 0]
  ------------------
  292|    202|      ERREXIT(cinfo, JERR_NO_IMAGE);
  ------------------
  |  |  240|    202|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    202|   (*(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|    202|    jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
  298|    202|    retcode = JPEG_HEADER_TABLES_ONLY;
  ------------------
  |  | 1067|    202|#define JPEG_HEADER_TABLES_ONLY  2 /* Found valid table-specs-only datastream */
  ------------------
  299|    202|    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: 2.27k]
  ------------------
  301|       |    /* no work */
  302|      0|    break;
  303|  2.27k|  }
  304|       |
  305|    960|  return retcode;
  306|  2.27k|}
jpeg_consume_input:
  323|  2.27k|{
  324|  2.27k|  int retcode = JPEG_SUSPENDED;
  ------------------
  |  | 1065|  2.27k|#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|  2.27k|  switch (cinfo->global_state) {
  328|  2.27k|  case DSTATE_START:
  ------------------
  |  |   48|  2.27k|#define DSTATE_START     200    /* after create_decompress */
  ------------------
  |  Branch (328:3): [True: 2.27k, False: 0]
  ------------------
  329|       |    /* Start-of-datastream actions: reset appropriate modules */
  330|  2.27k|    (*cinfo->inputctl->reset_input_controller) (cinfo);
  331|       |    /* Initialize application's data source module */
  332|  2.27k|    (*cinfo->src->init_source) (cinfo);
  333|  2.27k|    cinfo->global_state = DSTATE_INHEADER;
  ------------------
  |  |   49|  2.27k|#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
  ------------------
  334|  2.27k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  2.27k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  335|  2.27k|  case DSTATE_INHEADER:
  ------------------
  |  |   49|  2.27k|#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
  ------------------
  |  Branch (335:3): [True: 0, False: 2.27k]
  ------------------
  336|  2.27k|    retcode = (*cinfo->inputctl->consume_input) (cinfo);
  337|  2.27k|    if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
  ------------------
  |  | 1111|  2.27k|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (337:9): [True: 960, False: 1.31k]
  ------------------
  338|       |      /* Set up default parameters based on header data */
  339|    960|      default_decompress_parms(cinfo);
  340|       |      /* Set global state: ready for start_decompress */
  341|    960|      cinfo->global_state = DSTATE_READY;
  ------------------
  |  |   50|    960|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  342|    960|    }
  343|  2.27k|    break;
  344|      0|  case DSTATE_READY:
  ------------------
  |  |   50|      0|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (344:3): [True: 0, False: 2.27k]
  ------------------
  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: 2.27k]
  ------------------
  349|      0|  case DSTATE_PRESCAN:
  ------------------
  |  |   52|      0|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (349:3): [True: 0, False: 2.27k]
  ------------------
  350|      0|  case DSTATE_SCANNING:
  ------------------
  |  |   53|      0|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (350:3): [True: 0, False: 2.27k]
  ------------------
  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: 2.27k]
  ------------------
  352|      0|  case DSTATE_BUFIMAGE:
  ------------------
  |  |   55|      0|#define DSTATE_BUFIMAGE  207    /* expecting jpeg_start_output */
  ------------------
  |  Branch (352:3): [True: 0, False: 2.27k]
  ------------------
  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: 2.27k]
  ------------------
  354|      0|  case DSTATE_STOPPING:
  ------------------
  |  |   58|      0|#define DSTATE_STOPPING  210    /* looking for EOI in jpeg_finish_decompress */
  ------------------
  |  Branch (354:3): [True: 0, False: 2.27k]
  ------------------
  355|      0|    retcode = (*cinfo->inputctl->consume_input) (cinfo);
  356|      0|    break;
  357|      0|  default:
  ------------------
  |  Branch (357:3): [True: 0, False: 2.27k]
  ------------------
  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|  2.27k|  }
  360|  1.16k|  return retcode;
  361|  2.27k|}
jpeg_has_multiple_scans:
  385|     32|{
  386|       |  /* Only valid after jpeg_read_header completes */
  387|     32|  if (cinfo->global_state < DSTATE_READY ||
  ------------------
  |  |   50|     64|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (387:7): [True: 0, False: 32]
  ------------------
  388|     32|      cinfo->global_state > DSTATE_STOPPING)
  ------------------
  |  |   58|     32|#define DSTATE_STOPPING  210    /* looking for EOI in jpeg_finish_decompress */
  ------------------
  |  Branch (388:7): [True: 0, False: 32]
  ------------------
  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|     32|  return cinfo->inputctl->has_multiple_scans;
  391|     32|}
jdapimin.c:default_decompress_parms:
  140|    960|{
  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|    960|  switch (cinfo->num_components) {
  145|    891|  case 1:
  ------------------
  |  Branch (145:3): [True: 891, False: 69]
  ------------------
  146|    891|    cinfo->jpeg_color_space = JCS_GRAYSCALE;
  147|    891|    cinfo->out_color_space = JCS_GRAYSCALE;
  148|    891|    break;
  149|       |
  150|     69|  case 3:
  ------------------
  |  Branch (150:3): [True: 69, False: 891]
  ------------------
  151|     69|    if (cinfo->saw_JFIF_marker) {
  ------------------
  |  Branch (151:9): [True: 0, False: 69]
  ------------------
  152|      0|      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
  153|     69|    } else if (cinfo->saw_Adobe_marker) {
  ------------------
  |  Branch (153:16): [True: 34, False: 35]
  ------------------
  154|     34|      switch (cinfo->Adobe_transform) {
  155|      0|      case 0:
  ------------------
  |  Branch (155:7): [True: 0, False: 34]
  ------------------
  156|      0|        cinfo->jpeg_color_space = JCS_RGB;
  157|      0|        break;
  158|      0|      case 1:
  ------------------
  |  Branch (158:7): [True: 0, False: 34]
  ------------------
  159|      0|        cinfo->jpeg_color_space = JCS_YCbCr;
  160|      0|        break;
  161|     34|      default:
  ------------------
  |  Branch (161:7): [True: 34, False: 0]
  ------------------
  162|     34|        WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
  ------------------
  |  |  286|     34|  ((cinfo)->err->msg_code = (code), \
  |  |  287|     34|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  288|     34|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  163|     34|        cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
  164|     34|        break;
  165|     34|      }
  166|     35|    } else {
  167|       |      /* Saw no special markers, try to guess from the component IDs */
  168|     35|      int cid0 = cinfo->comp_info[0].component_id;
  169|     35|      int cid1 = cinfo->comp_info[1].component_id;
  170|     35|      int cid2 = cinfo->comp_info[2].component_id;
  171|       |
  172|     35|      if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
  ------------------
  |  Branch (172:11): [True: 0, False: 35]
  |  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|     35|      } else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
  ------------------
  |  Branch (179:18): [True: 0, False: 35]
  |  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|     35|      else {
  182|     35|        TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
  ------------------
  |  |  309|     35|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|     35|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|     35|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|     35|           (cinfo)->err->msg_code = (code); \
  |  |  312|     35|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  183|     35|#ifdef D_LOSSLESS_SUPPORTED
  184|     35|        if (cinfo->master->lossless)
  ------------------
  |  Branch (184:13): [True: 0, False: 35]
  ------------------
  185|      0|          cinfo->jpeg_color_space = JCS_RGB; /* assume it's RGB */
  186|     35|        else
  187|     35|#endif
  188|     35|          cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
  189|     35|      }
  190|     35|    }
  191|       |    /* Always guess RGB is proper output colorspace. */
  192|     69|    cinfo->out_color_space = JCS_RGB;
  193|     69|    break;
  194|       |
  195|      0|  case 4:
  ------------------
  |  Branch (195:3): [True: 0, False: 960]
  ------------------
  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: 960]
  ------------------
  217|      0|    cinfo->jpeg_color_space = JCS_UNKNOWN;
  218|      0|    cinfo->out_color_space = JCS_UNKNOWN;
  219|      0|    break;
  220|    960|  }
  221|       |
  222|       |  /* Set defaults for other decompression parameters. */
  223|    960|  cinfo->scale_num = 1;         /* 1:1 scaling */
  224|    960|  cinfo->scale_denom = 1;
  225|    960|  cinfo->output_gamma = 1.0;
  226|    960|  cinfo->buffered_image = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  227|    960|  cinfo->raw_data_out = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  228|    960|  cinfo->dct_method = JDCT_DEFAULT;
  ------------------
  |  |  301|    960|#define JDCT_DEFAULT  JDCT_ISLOW
  ------------------
  229|    960|  cinfo->do_fancy_upsampling = TRUE;
  ------------------
  |  |  210|    960|#define TRUE    1
  ------------------
  230|    960|  cinfo->do_block_smoothing = TRUE;
  ------------------
  |  |  210|    960|#define TRUE    1
  ------------------
  231|    960|  cinfo->quantize_colors = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  232|       |  /* We set these in case application only sets quantize_colors. */
  233|    960|  cinfo->dither_mode = JDITHER_FS;
  234|    960|#ifdef QUANT_2PASS_SUPPORTED
  235|    960|  cinfo->two_pass_quantize = TRUE;
  ------------------
  |  |  210|    960|#define TRUE    1
  ------------------
  236|       |#else
  237|       |  cinfo->two_pass_quantize = FALSE;
  238|       |#endif
  239|    960|  cinfo->desired_number_of_colors = 256;
  240|    960|  cinfo->colormap = NULL;
  241|       |  /* Initialize for no mode change in buffered-image mode. */
  242|    960|  cinfo->enable_1pass_quant = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  243|    960|  cinfo->enable_external_quant = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  244|    960|  cinfo->enable_2pass_quant = FALSE;
  ------------------
  |  |  207|    960|#define FALSE   0               /* values of boolean */
  ------------------
  245|    960|}

jpeg_start_decompress:
   56|    923|{
   57|    923|  if (cinfo->global_state == DSTATE_READY) {
  ------------------
  |  |   50|    923|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (57:7): [True: 923, False: 0]
  ------------------
   58|       |    /* First call: initialize master control, select active modules */
   59|    923|    jinit_master_decompress(cinfo);
   60|    923|    if (cinfo->buffered_image) {
  ------------------
  |  Branch (60:9): [True: 0, False: 923]
  ------------------
   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|    923|    cinfo->global_state = DSTATE_PRELOAD;
  ------------------
  |  |   51|    923|#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
  ------------------
   66|    923|  }
   67|    923|  if (cinfo->global_state == DSTATE_PRELOAD) {
  ------------------
  |  |   51|    923|#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
  ------------------
  |  Branch (67:7): [True: 888, False: 35]
  ------------------
   68|       |    /* If file has multiple scans, absorb them all into the coef buffer */
   69|    888|    if (cinfo->inputctl->has_multiple_scans) {
  ------------------
  |  Branch (69:9): [True: 0, False: 888]
  ------------------
   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|    888|    cinfo->output_scan_number = cinfo->input_scan_number;
   96|    888|  } else if (cinfo->global_state != DSTATE_PRESCAN)
  ------------------
  |  |   52|     35|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (96:14): [True: 0, False: 35]
  ------------------
   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|    923|  return output_pass_setup(cinfo);
  100|    923|}
jpeg_read_scanlines:
  328|  9.09M|{
  329|  9.09M|#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
  330|  9.09M|  JDIMENSION row_ctr;
  331|       |
  332|  9.09M|#ifdef D_LOSSLESS_SUPPORTED
  333|  9.09M|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (333:7): [True: 0, False: 9.09M]
  ------------------
  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|  9.09M|#endif
  343|  9.09M|  {
  344|  9.09M|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  9.09M|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (344:9): [True: 0, False: 9.09M]
  ------------------
  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|  9.09M|  }
  347|       |
  348|  9.09M|  if (cinfo->global_state != DSTATE_SCANNING)
  ------------------
  |  |   53|  9.09M|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (348:7): [True: 0, False: 9.09M]
  ------------------
  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|  9.09M|  if (cinfo->output_scanline >= cinfo->output_height) {
  ------------------
  |  Branch (350:7): [True: 8.22M, False: 869k]
  ------------------
  351|  8.22M|    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
  ------------------
  |  |  283|  8.22M|  ((cinfo)->err->msg_code = (code), \
  |  |  284|  8.22M|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  352|  8.22M|    return 0;
  353|  8.22M|  }
  354|       |
  355|       |  /* Call progress monitor hook if present */
  356|   869k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (356:7): [True: 0, False: 869k]
  ------------------
  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|   869k|  row_ctr = 0;
  364|   869k|  if (cinfo->main->_process_data == NULL)
  ------------------
  |  |  256|   869k|#define _process_data  process_data
  ------------------
  |  Branch (364:7): [True: 0, False: 869k]
  ------------------
  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|   869k|  (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, max_lines);
  ------------------
  |  |  256|   869k|#define _process_data  process_data
  ------------------
  367|   869k|  cinfo->output_scanline += row_ctr;
  368|   869k|  return row_ctr;
  369|       |#else
  370|       |  ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  371|       |  return 0;
  372|       |#endif
  373|  9.09M|}
jdapistd-8.c:output_pass_setup:
  113|    888|{
  114|    888|  if (cinfo->global_state != DSTATE_PRESCAN) {
  ------------------
  |  |   52|    888|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  |  Branch (114:7): [True: 888, False: 0]
  ------------------
  115|       |    /* First call: do pass setup */
  116|    888|    (*cinfo->master->prepare_for_output_pass) (cinfo);
  117|    888|    cinfo->output_scanline = 0;
  118|    888|    cinfo->global_state = DSTATE_PRESCAN;
  ------------------
  |  |   52|    888|#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
  ------------------
  119|    888|  }
  120|       |  /* Loop over any required dummy passes */
  121|    888|  while (cinfo->master->is_dummy_pass) {
  ------------------
  |  Branch (121:10): [True: 0, False: 888]
  ------------------
  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|    888|  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
  ------------------
  |  |   54|      0|#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|  1.77k|#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
  ------------------
  |  Branch (170:25): [True: 0, False: 888]
  ------------------
  171|    888|  return TRUE;
  ------------------
  |  |  210|    888|#define TRUE    1
  ------------------
  172|    888|}

jinit_arith_decoder:
  751|     32|{
  752|     32|  arith_entropy_ptr entropy;
  753|     32|  int i;
  754|       |
  755|     32|  entropy = (arith_entropy_ptr)
  756|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  757|     32|                                sizeof(arith_entropy_decoder));
  758|     32|  cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
  759|     32|  entropy->pub.start_pass = start_pass;
  760|       |
  761|       |  /* Mark tables unallocated */
  762|    544|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|    544|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (762:15): [True: 512, False: 32]
  ------------------
  763|    512|    entropy->dc_stats[i] = NULL;
  764|    512|    entropy->ac_stats[i] = NULL;
  765|    512|  }
  766|       |
  767|       |  /* Initialize index for fixed probability estimation */
  768|     32|  entropy->fixed_bin[0] = 113;
  769|       |
  770|     32|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (770:7): [True: 32, False: 0]
  ------------------
  771|       |    /* Create progression status table */
  772|     32|    int *coef_bit_ptr, ci;
  773|     32|    cinfo->coef_bits = (int (*)[DCTSIZE2])
  774|     32|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  775|     32|                                  cinfo->num_components * 2 * DCTSIZE2 *
  ------------------
  |  |   67|     32|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  776|     32|                                  sizeof(int));
  777|     32|    coef_bit_ptr = &cinfo->coef_bits[0][0];
  778|    128|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (778:18): [True: 96, False: 32]
  ------------------
  779|  6.24k|      for (i = 0; i < DCTSIZE2; i++)
  ------------------
  |  |   67|  6.24k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (779:19): [True: 6.14k, False: 96]
  ------------------
  780|  6.14k|        *coef_bit_ptr++ = -1;
  781|     32|  }
  782|     32|}

jinit_d_coef_controller:
  869|    891|{
  870|    891|  my_coef_ptr coef;
  871|       |
  872|    891|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (872:7): [True: 0, False: 891]
  ------------------
  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|    891|  coef = (my_coef_ptr)
  876|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  877|    891|                                sizeof(my_coef_controller));
  878|    891|  memset(coef, 0, sizeof(my_coef_controller));
  879|    891|  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
  880|    891|  coef->pub.start_input_pass = start_input_pass;
  881|    891|  coef->pub.start_output_pass = start_output_pass;
  882|    891|#ifdef BLOCK_SMOOTHING_SUPPORTED
  883|    891|  coef->coef_bits_latch = NULL;
  884|    891|#endif
  885|       |
  886|       |  /* Create the coefficient buffer. */
  887|    891|  if (need_full_buffer) {
  ------------------
  |  Branch (887:7): [True: 0, False: 891]
  ------------------
  888|      0|#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|      0|    int ci, access_rows;
  893|      0|    jpeg_component_info *compptr;
  894|       |
  895|      0|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (895:46): [True: 0, False: 0]
  ------------------
  896|      0|         ci++, compptr++) {
  897|      0|      access_rows = compptr->v_samp_factor;
  898|      0|#ifdef BLOCK_SMOOTHING_SUPPORTED
  899|       |      /* If block smoothing could be used, need a bigger window */
  900|      0|      if (cinfo->progressive_mode)
  ------------------
  |  Branch (900:11): [True: 0, False: 0]
  ------------------
  901|      0|        access_rows *= 5;
  902|      0|#endif
  903|      0|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  904|      0|        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  905|      0|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  906|      0|                               (long)compptr->h_samp_factor),
  907|      0|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  908|      0|                               (long)compptr->v_samp_factor),
  909|      0|         (JDIMENSION)access_rows);
  910|      0|    }
  911|      0|    coef->pub.consume_data = consume_data;
  912|      0|    coef->pub._decompress_data = decompress_data;
  ------------------
  |  |  258|      0|#define _decompress_data  decompress_data
  ------------------
  913|      0|    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
  914|       |#else
  915|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  916|       |#endif
  917|    891|  } else {
  918|       |    /* We only need a single-MCU buffer. */
  919|    891|    JBLOCKROW buffer;
  920|    891|    int i;
  921|       |
  922|    891|    buffer = (JBLOCKROW)
  923|    891|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  924|    891|                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   82|    891|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  925|  9.80k|    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   82|  9.80k|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  |  Branch (925:17): [True: 8.91k, False: 891]
  ------------------
  926|  8.91k|      coef->MCU_buffer[i] = buffer + i;
  927|  8.91k|    }
  928|    891|    coef->pub.consume_data = dummy_consume_data;
  929|    891|    coef->pub._decompress_data = decompress_onepass;
  ------------------
  |  |  258|    891|#define _decompress_data  decompress_data
  ------------------
  930|    891|    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
  931|    891|  }
  932|       |
  933|       |  /* Allocate the workspace buffer */
  934|    891|  coef->workspace = (JCOEF *)
  935|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  936|    891|                                sizeof(JCOEF) * DCTSIZE2);
  ------------------
  |  |   67|    891|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  937|    891|}
jdcoefct-8.c:start_input_pass:
   50|    888|{
   51|    888|  cinfo->input_iMCU_row = 0;
   52|    888|  start_iMCU_row(cinfo);
   53|    888|}
jdcoefct-8.c:start_output_pass:
   62|    888|{
   63|    888|#ifdef BLOCK_SMOOTHING_SUPPORTED
   64|    888|  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|    888|  if (coef->pub.coef_arrays != NULL) {
  ------------------
  |  Branch (67:7): [True: 0, False: 888]
  ------------------
   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|    888|#endif
   74|    888|  cinfo->output_iMCU_row = 0;
   75|    888|}
jdcoefct-8.c:decompress_onepass:
   90|   107k|{
   91|   107k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
   92|   107k|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
   93|   107k|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
   94|   107k|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
   95|   107k|  int blkn, ci, xindex, yindex, yoffset, useful_width;
   96|   107k|  _JSAMPARRAY output_ptr;
  ------------------
  |  |  230|   107k|#define _JSAMPARRAY  JSAMPARRAY
  ------------------
   97|   107k|  JDIMENSION start_col, output_col;
   98|   107k|  jpeg_component_info *compptr;
   99|   107k|  _inverse_DCT_method_ptr inverse_DCT;
  ------------------
  |  |  262|   107k|#define _inverse_DCT_method_ptr  inverse_DCT_method_ptr
  ------------------
  100|       |
  101|       |  /* Loop to process as much as one whole iMCU row */
  102|   216k|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (102:41): [True: 108k, False: 107k]
  ------------------
  103|   108k|       yoffset++) {
  104|  1.36M|    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (104:39): [True: 1.25M, False: 108k]
  ------------------
  105|  1.25M|         MCU_col_num++) {
  106|       |      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
  107|  1.25M|      jzero_far((void *)coef->MCU_buffer[0],
  108|  1.25M|                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
  109|  1.25M|      if (!cinfo->entropy->insufficient_data)
  ------------------
  |  Branch (109:11): [True: 502k, False: 752k]
  ------------------
  110|   502k|        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
  111|       |#ifdef WITH_PROFILE
  112|       |      cinfo->master->start = getTime();
  113|       |#endif
  114|  1.25M|      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (114:11): [True: 0, False: 1.25M]
  ------------------
  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.25M|      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
  ------------------
  |  Branch (134:11): [True: 1.25M, False: 265]
  ------------------
  135|  1.25M|          MCU_col_num <= cinfo->master->last_iMCU_col) {
  ------------------
  |  Branch (135:11): [True: 1.25M, 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.25M|        blkn = 0;               /* index of current DCT block within MCU */
  142|  2.51M|        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (142:22): [True: 1.25M, False: 1.25M]
  ------------------
  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: 1.14M, False: 108k]
  ------------------
  151|  1.14M|                         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.24M, False: 9.94k]
  ------------------
  158|  1.25M|                yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (158:17): [True: 9.94k, False: 0]
  ------------------
  159|  1.25M|              output_col = start_col;
  160|  2.51M|              for (xindex = 0; xindex < useful_width; xindex++) {
  ------------------
  |  Branch (160:32): [True: 1.25M, False: 1.25M]
  ------------------
  161|       |#ifdef WITH_PROFILE
  162|       |                cinfo->master->start = getTime();
  163|       |#endif
  164|  1.25M|                (*inverse_DCT) (cinfo, compptr,
  165|  1.25M|                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
  166|  1.25M|                                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.25M|                output_col += compptr->_DCT_scaled_size;
  ------------------
  |  |   24|  1.25M|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  173|  1.25M|              }
  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.25M|      }
  180|  1.25M|    }
  181|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  182|   108k|    coef->MCU_ctr = 0;
  183|   108k|  }
  184|       |  /* Completed the iMCU row, advance counters for next one */
  185|   107k|  cinfo->output_iMCU_row++;
  186|   107k|  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
  ------------------
  |  Branch (186:7): [True: 106k, False: 1.13k]
  ------------------
  187|   106k|    start_iMCU_row(cinfo);
  188|   106k|    return JPEG_ROW_COMPLETED;
  ------------------
  |  | 1113|   106k|#define JPEG_ROW_COMPLETED      3 /* Completed one iMCU row */
  ------------------
  189|   106k|  }
  190|       |  /* Completed the scan */
  191|  1.13k|  (*cinfo->inputctl->finish_input_pass) (cinfo);
  192|  1.13k|  return JPEG_SCAN_COMPLETED;
  ------------------
  |  | 1114|  1.13k|#define JPEG_SCAN_COMPLETED     4 /* Completed last iMCU row of a scan */
  ------------------
  193|   107k|}
j12init_d_coef_controller:
  869|     32|{
  870|     32|  my_coef_ptr coef;
  871|       |
  872|     32|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (872:7): [True: 0, False: 32]
  ------------------
  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|     32|  coef = (my_coef_ptr)
  876|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  877|     32|                                sizeof(my_coef_controller));
  878|     32|  memset(coef, 0, sizeof(my_coef_controller));
  879|     32|  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
  880|     32|  coef->pub.start_input_pass = start_input_pass;
  881|     32|  coef->pub.start_output_pass = start_output_pass;
  882|     32|#ifdef BLOCK_SMOOTHING_SUPPORTED
  883|     32|  coef->coef_bits_latch = NULL;
  884|     32|#endif
  885|       |
  886|       |  /* Create the coefficient buffer. */
  887|     32|  if (need_full_buffer) {
  ------------------
  |  Branch (887:7): [True: 32, False: 0]
  ------------------
  888|     32|#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|     32|    int ci, access_rows;
  893|     32|    jpeg_component_info *compptr;
  894|       |
  895|    128|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (895:46): [True: 96, False: 32]
  ------------------
  896|     96|         ci++, compptr++) {
  897|     96|      access_rows = compptr->v_samp_factor;
  898|     96|#ifdef BLOCK_SMOOTHING_SUPPORTED
  899|       |      /* If block smoothing could be used, need a bigger window */
  900|     96|      if (cinfo->progressive_mode)
  ------------------
  |  Branch (900:11): [True: 96, False: 0]
  ------------------
  901|     96|        access_rows *= 5;
  902|     96|#endif
  903|     96|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  904|     96|        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  889|     96|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
  ------------------
  |  |  210|     96|#define TRUE    1
  ------------------
  905|     96|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  906|     96|                               (long)compptr->h_samp_factor),
  907|     96|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  908|     96|                               (long)compptr->v_samp_factor),
  909|     96|         (JDIMENSION)access_rows);
  910|     96|    }
  911|     32|    coef->pub.consume_data = consume_data;
  912|     32|    coef->pub._decompress_data = decompress_data;
  ------------------
  |  |  142|     32|#define _decompress_data  decompress_data_12
  ------------------
  913|     32|    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
  914|       |#else
  915|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  916|       |#endif
  917|     32|  } else {
  918|       |    /* We only need a single-MCU buffer. */
  919|      0|    JBLOCKROW buffer;
  920|      0|    int i;
  921|       |
  922|      0|    buffer = (JBLOCKROW)
  923|      0|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  924|      0|                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   82|      0|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  925|      0|    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   82|      0|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  |  Branch (925:17): [True: 0, False: 0]
  ------------------
  926|      0|      coef->MCU_buffer[i] = buffer + i;
  927|      0|    }
  928|      0|    coef->pub.consume_data = dummy_consume_data;
  929|      0|    coef->pub._decompress_data = decompress_onepass;
  ------------------
  |  |  142|      0|#define _decompress_data  decompress_data_12
  ------------------
  930|      0|    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
  931|      0|  }
  932|       |
  933|       |  /* Allocate the workspace buffer */
  934|     32|  coef->workspace = (JCOEF *)
  935|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  936|     32|                                sizeof(JCOEF) * DCTSIZE2);
  ------------------
  |  |   67|     32|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  937|     32|}

jdcoefct-8.c:start_iMCU_row:
   68|   107k|{
   69|   107k|  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|   107k|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (75:7): [True: 0, False: 107k]
  ------------------
   76|      0|    coef->MCU_rows_per_iMCU_row = 1;
   77|   107k|  } else {
   78|   107k|    if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (78:9): [True: 106k, False: 872]
  ------------------
   79|   106k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   80|    872|    else
   81|    872|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   82|   107k|  }
   83|       |
   84|   107k|  coef->MCU_ctr = 0;
   85|   107k|  coef->MCU_vert_offset = 0;
   86|   107k|}

jinit_color_deconverter:
  625|    891|{
  626|    891|  my_cconvert_ptr cconvert;
  627|    891|  int ci;
  628|       |
  629|    891|#ifdef D_LOSSLESS_SUPPORTED
  630|    891|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (630:7): [True: 0, False: 891]
  ------------------
  631|      0|#if BITS_IN_JSAMPLE == 8
  632|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (632:9): [True: 0, False: 0]
  |  Branch (632:52): [True: 0, False: 0]
  ------------------
  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|      0|  } else
  639|    891|#endif
  640|    891|  {
  641|    891|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (641:9): [True: 0, False: 891]
  ------------------
  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|    891|  }
  644|       |
  645|    891|  cconvert = (my_cconvert_ptr)
  646|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  647|    891|                                sizeof(my_color_deconverter));
  648|    891|  cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
  649|    891|  cconvert->pub.start_pass = start_pass_dcolor;
  650|       |
  651|       |  /* Make sure num_components agrees with jpeg_color_space */
  652|    891|  switch (cinfo->jpeg_color_space) {
  653|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (653:3): [True: 0, False: 891]
  ------------------
  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: 891]
  ------------------
  659|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (659:3): [True: 0, False: 891]
  ------------------
  660|      0|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (660:9): [True: 0, False: 0]
  ------------------
  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|      0|    break;
  663|       |
  664|      0|  case JCS_CMYK:
  ------------------
  |  Branch (664:3): [True: 0, False: 891]
  ------------------
  665|      0|  case JCS_YCCK:
  ------------------
  |  Branch (665:3): [True: 0, False: 891]
  ------------------
  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|    891|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (670:3): [True: 891, False: 0]
  ------------------
  671|    891|    if (cinfo->num_components < 1)
  ------------------
  |  Branch (671:9): [True: 0, False: 891]
  ------------------
  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|    891|    break;
  674|    891|  }
  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|    891|  switch (cinfo->out_color_space) {
  684|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (684:3): [True: 0, False: 891]
  ------------------
  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|      0|  case JCS_RGB:
  ------------------
  |  Branch (704:3): [True: 0, False: 891]
  ------------------
  705|      0|  case JCS_EXT_RGB:
  ------------------
  |  Branch (705:3): [True: 0, False: 891]
  ------------------
  706|      0|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (706:3): [True: 0, False: 891]
  ------------------
  707|      0|  case JCS_EXT_BGR:
  ------------------
  |  Branch (707:3): [True: 0, False: 891]
  ------------------
  708|      0|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (708:3): [True: 0, False: 891]
  ------------------
  709|      0|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (709:3): [True: 0, False: 891]
  ------------------
  710|      0|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (710:3): [True: 0, False: 891]
  ------------------
  711|      0|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (711:3): [True: 0, False: 891]
  ------------------
  712|      0|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (712:3): [True: 0, False: 891]
  ------------------
  713|      0|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (713:3): [True: 0, False: 891]
  ------------------
  714|      0|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (714:3): [True: 0, False: 891]
  ------------------
  715|      0|#ifdef D_LOSSLESS_SUPPORTED
  716|      0|    if (cinfo->master->lossless && cinfo->jpeg_color_space != JCS_RGB)
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  |  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|      0|#endif
  719|      0|    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
  720|      0|    if (cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (720:9): [True: 0, False: 0]
  ------------------
  721|      0|#ifdef WITH_SIMD
  722|      0|      if (jsimd_set_ycc_rgb(cinfo))
  ------------------
  |  Branch (722:11): [True: 0, False: 0]
  ------------------
  723|      0|        cconvert->pub._color_convert = jsimd_color_deconvert;
  ------------------
  |  |  267|      0|#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|      0|    } 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|      0|    break;
  819|       |
  820|      0|  case JCS_RGB565:
  ------------------
  |  Branch (820:3): [True: 0, False: 891]
  ------------------
  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: 891]
  ------------------
  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|    891|  default:
  ------------------
  |  Branch (873:3): [True: 891, False: 0]
  ------------------
  874|       |    /* Permit null conversion to same output space */
  875|    891|    if (cinfo->out_color_space == cinfo->jpeg_color_space) {
  ------------------
  |  Branch (875:9): [True: 891, False: 0]
  ------------------
  876|    891|      cinfo->out_color_components = cinfo->num_components;
  877|    891|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|    891|#define _color_convert  color_convert
  ------------------
  878|    891|    } 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|    891|    break;
  881|    891|  }
  882|       |
  883|    891|  if (cinfo->quantize_colors)
  ------------------
  |  Branch (883:7): [True: 0, False: 891]
  ------------------
  884|      0|    cinfo->output_components = 1; /* single colormapped output component */
  885|    891|  else
  886|    891|    cinfo->output_components = cinfo->out_color_components;
  887|    891|}
jdcolor-8.c:start_pass_dcolor:
  614|    888|{
  615|       |  /* no work needed */
  616|    888|}
jdcolor-8.c:null_convert:
  336|   869k|{
  337|   869k|  register _JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
  338|   869k|  register JDIMENSION col;
  339|   869k|  register int num_components = cinfo->num_components;
  340|   869k|  JDIMENSION num_cols = cinfo->output_width;
  341|   869k|  int ci;
  342|       |
  343|   869k|  if (num_components == 3) {
  ------------------
  |  Branch (343:7): [True: 0, False: 869k]
  ------------------
  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|   869k|  } else if (num_components == 4) {
  ------------------
  |  Branch (356:14): [True: 0, False: 869k]
  ------------------
  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|   869k|  } else {
  372|  1.73M|    while (--num_rows >= 0) {
  ------------------
  |  Branch (372:12): [True: 869k, False: 869k]
  ------------------
  373|  1.73M|      for (ci = 0; ci < num_components; ci++) {
  ------------------
  |  Branch (373:20): [True: 869k, False: 869k]
  ------------------
  374|   869k|        inptr = input_buf[ci][input_row];
  375|   869k|        outptr = *output_buf;
  376|  78.0M|        for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (376:23): [True: 77.2M, False: 869k]
  ------------------
  377|  77.2M|          outptr[ci] = inptr[col];
  378|  77.2M|          outptr += num_components;
  379|  77.2M|        }
  380|   869k|      }
  381|   869k|      output_buf++;
  382|   869k|      input_row++;
  383|   869k|    }
  384|   869k|  }
  385|   869k|}
j12init_color_deconverter:
  625|     32|{
  626|     32|  my_cconvert_ptr cconvert;
  627|     32|  int ci;
  628|       |
  629|     32|#ifdef D_LOSSLESS_SUPPORTED
  630|     32|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (630:7): [True: 0, False: 32]
  ------------------
  631|       |#if BITS_IN_JSAMPLE == 8
  632|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  633|       |#else
  634|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (634:9): [True: 0, False: 0]
  ------------------
  635|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (635:9): [True: 0, False: 0]
  ------------------
  636|      0|#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|      0|  } else
  639|     32|#endif
  640|     32|  {
  641|     32|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (641:9): [True: 0, False: 32]
  ------------------
  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|     32|  }
  644|       |
  645|     32|  cconvert = (my_cconvert_ptr)
  646|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  647|     32|                                sizeof(my_color_deconverter));
  648|     32|  cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
  649|     32|  cconvert->pub.start_pass = start_pass_dcolor;
  650|       |
  651|       |  /* Make sure num_components agrees with jpeg_color_space */
  652|     32|  switch (cinfo->jpeg_color_space) {
  653|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (653:3): [True: 0, False: 32]
  ------------------
  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: 32]
  ------------------
  659|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (659:3): [True: 0, False: 32]
  ------------------
  660|      0|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (660:9): [True: 0, False: 0]
  ------------------
  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|      0|    break;
  663|       |
  664|      0|  case JCS_CMYK:
  ------------------
  |  Branch (664:3): [True: 0, False: 32]
  ------------------
  665|      0|  case JCS_YCCK:
  ------------------
  |  Branch (665:3): [True: 0, False: 32]
  ------------------
  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|     32|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (670:3): [True: 32, False: 0]
  ------------------
  671|     32|    if (cinfo->num_components < 1)
  ------------------
  |  Branch (671:9): [True: 0, False: 32]
  ------------------
  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|     32|    break;
  674|     32|  }
  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|     32|  switch (cinfo->out_color_space) {
  684|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (684:3): [True: 0, False: 32]
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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|      0|  case JCS_RGB:
  ------------------
  |  Branch (704:3): [True: 0, False: 32]
  ------------------
  705|      0|  case JCS_EXT_RGB:
  ------------------
  |  Branch (705:3): [True: 0, False: 32]
  ------------------
  706|      0|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (706:3): [True: 0, False: 32]
  ------------------
  707|      0|  case JCS_EXT_BGR:
  ------------------
  |  Branch (707:3): [True: 0, False: 32]
  ------------------
  708|      0|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (708:3): [True: 0, False: 32]
  ------------------
  709|      0|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (709:3): [True: 0, False: 32]
  ------------------
  710|      0|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (710:3): [True: 0, False: 32]
  ------------------
  711|      0|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (711:3): [True: 0, False: 32]
  ------------------
  712|      0|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (712:3): [True: 0, False: 32]
  ------------------
  713|      0|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (713:3): [True: 0, False: 32]
  ------------------
  714|      0|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (714:3): [True: 0, False: 32]
  ------------------
  715|      0|#ifdef D_LOSSLESS_SUPPORTED
  716|      0|    if (cinfo->master->lossless && cinfo->jpeg_color_space != JCS_RGB)
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  |  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|      0|#endif
  719|      0|    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
  720|      0|    if (cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (720:9): [True: 0, False: 0]
  ------------------
  721|       |#ifdef WITH_SIMD
  722|       |      if (jsimd_set_ycc_rgb(cinfo))
  723|       |        cconvert->pub._color_convert = jsimd_color_deconvert;
  724|       |      else
  725|       |#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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  749|      0|          break;
  750|      0|        default:
  ------------------
  |  Branch (750:9): [True: 0, False: 0]
  ------------------
  751|      0|          cconvert->pub._color_convert = ycc_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  752|      0|        }
  753|      0|        build_ycc_rgb_table(cinfo);
  754|      0|      }
  755|      0|    } 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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  778|      0|        break;
  779|      0|      default:
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  ------------------
  780|      0|        cconvert->pub._color_convert = gray_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  811|      0|          break;
  812|      0|        default:
  ------------------
  |  Branch (812:9): [True: 0, False: 0]
  ------------------
  813|      0|          cconvert->pub._color_convert = rgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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|      0|    break;
  819|       |
  820|      0|  case JCS_RGB565:
  ------------------
  |  Branch (820:3): [True: 0, False: 32]
  ------------------
  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|       |#ifdef WITH_SIMD
  829|       |        if (jsimd_set_ycc_rgb565(cinfo))
  830|       |          cconvert->pub._color_convert = jsimd_color_deconvert;
  831|       |        else
  832|       |#endif
  833|      0|        {
  834|      0|          cconvert->pub._color_convert = ycc_rgb565_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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: 32]
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  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|     32|  default:
  ------------------
  |  Branch (873:3): [True: 32, False: 0]
  ------------------
  874|       |    /* Permit null conversion to same output space */
  875|     32|    if (cinfo->out_color_space == cinfo->jpeg_color_space) {
  ------------------
  |  Branch (875:9): [True: 32, False: 0]
  ------------------
  876|     32|      cinfo->out_color_components = cinfo->num_components;
  877|     32|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|     32|#define _color_convert  color_convert_12
  ------------------
  878|     32|    } 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|     32|    break;
  881|     32|  }
  882|       |
  883|     32|  if (cinfo->quantize_colors)
  ------------------
  |  Branch (883:7): [True: 0, False: 32]
  ------------------
  884|      0|    cinfo->output_components = 1; /* single colormapped output component */
  885|     32|  else
  886|     32|    cinfo->output_components = cinfo->out_color_components;
  887|     32|}

jinit_inverse_dct:
  335|    891|{
  336|    891|  my_idct_ptr idct;
  337|    891|  int ci;
  338|    891|  jpeg_component_info *compptr;
  339|       |
  340|    891|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (340:7): [True: 0, False: 891]
  ------------------
  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|    891|  idct = (my_idct_ptr)
  344|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  345|    891|                                sizeof(my_idct_controller));
  346|    891|  cinfo->idct = (struct jpeg_inverse_dct *)idct;
  347|    891|  idct->pub.start_pass = start_pass;
  348|       |
  349|  1.78k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (349:44): [True: 891, False: 891]
  ------------------
  350|    891|       ci++, compptr++) {
  351|       |    /* Allocate and pre-zero a multiplier table for each component */
  352|    891|    compptr->dct_table =
  353|    891|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|    891|                                  sizeof(multiplier_table));
  355|    891|    memset(compptr->dct_table, 0, sizeof(multiplier_table));
  356|       |    /* Mark multiplier table not yet set up for any method */
  357|    891|    idct->cur_method[ci] = -1;
  358|    891|  }
  359|    891|}
jddctmgr-8.c:start_pass:
  102|    888|{
  103|    888|  my_idct_ptr idct = (my_idct_ptr)cinfo->idct;
  104|    888|  int ci, i;
  105|    888|  jpeg_component_info *compptr;
  106|    888|  int method = 0;
  107|    888|  _inverse_DCT_method_ptr method_ptr = NULL;
  ------------------
  |  |  262|    888|#define _inverse_DCT_method_ptr  inverse_DCT_method_ptr
  ------------------
  108|    888|  JQUANT_TBL *qtbl;
  109|       |
  110|  1.77k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (110:44): [True: 888, False: 888]
  ------------------
  111|    888|       ci++, compptr++) {
  112|       |    /* Select the proper IDCT routine for this component's scaling */
  113|    888|    switch (compptr->_DCT_scaled_size) {
  ------------------
  |  |   24|    888|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  114|      0|#ifdef IDCT_SCALING_SUPPORTED
  115|      0|    case 1:
  ------------------
  |  Branch (115:5): [True: 0, False: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|    case DCTSIZE:
  ------------------
  |  |   66|    888|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (154:5): [True: 888, False: 0]
  ------------------
  155|    888|      switch (cinfo->dct_method) {
  156|      0|#ifdef DCT_ISLOW_SUPPORTED
  157|    888|      case JDCT_ISLOW:
  ------------------
  |  Branch (157:7): [True: 888, False: 0]
  ------------------
  158|    888|#ifdef WITH_SIMD
  159|    888|        if (jsimd_set_idct_islow(cinfo))
  ------------------
  |  Branch (159:13): [True: 888, False: 0]
  ------------------
  160|    888|          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|    888|        method = JDCT_ISLOW;
  165|    888|        break;
  166|      0|#endif
  167|      0|#ifdef DCT_IFAST_SUPPORTED
  168|      0|      case JDCT_IFAST:
  ------------------
  |  Branch (168:7): [True: 0, False: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|      }
  193|    888|      break;
  194|    888|#ifdef IDCT_SCALING_SUPPORTED
  195|    888|    case 9:
  ------------------
  |  Branch (195:5): [True: 0, False: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|    }
  232|    888|    idct->pub._inverse_DCT[ci] = method_ptr;
  ------------------
  |  |  263|    888|#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|    888|    if (!compptr->component_needed || idct->cur_method[ci] == method)
  ------------------
  |  Branch (240:9): [True: 0, False: 888]
  |  Branch (240:39): [True: 0, False: 888]
  ------------------
  241|      0|      continue;
  242|    888|    qtbl = compptr->quant_table;
  243|    888|    if (qtbl == NULL)           /* happens if no data yet for component */
  ------------------
  |  Branch (243:9): [True: 0, False: 888]
  ------------------
  244|      0|      continue;
  245|    888|    idct->cur_method[ci] = method;
  246|    888|    switch (method) {
  247|      0|#ifdef PROVIDE_ISLOW_TABLES
  248|    888|    case JDCT_ISLOW:
  ------------------
  |  Branch (248:5): [True: 888, False: 0]
  ------------------
  249|    888|      {
  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|    888|        ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table;
  254|  57.7k|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  57.7k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (254:21): [True: 56.8k, False: 888]
  ------------------
  255|  56.8k|          ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i];
  256|  56.8k|        }
  257|    888|      }
  258|    888|      break;
  259|      0|#endif
  260|      0|#ifdef DCT_IFAST_SUPPORTED
  261|      0|    case JDCT_IFAST:
  ------------------
  |  Branch (261:5): [True: 0, False: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|    }
  325|    888|  }
  326|    888|}
j12init_inverse_dct:
  335|     32|{
  336|     32|  my_idct_ptr idct;
  337|     32|  int ci;
  338|     32|  jpeg_component_info *compptr;
  339|       |
  340|     32|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (340:7): [True: 0, False: 32]
  ------------------
  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|     32|  idct = (my_idct_ptr)
  344|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  345|     32|                                sizeof(my_idct_controller));
  346|     32|  cinfo->idct = (struct jpeg_inverse_dct *)idct;
  347|     32|  idct->pub.start_pass = start_pass;
  348|       |
  349|    128|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (349:44): [True: 96, False: 32]
  ------------------
  350|     96|       ci++, compptr++) {
  351|       |    /* Allocate and pre-zero a multiplier table for each component */
  352|     96|    compptr->dct_table =
  353|     96|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     96|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|     96|                                  sizeof(multiplier_table));
  355|     96|    memset(compptr->dct_table, 0, sizeof(multiplier_table));
  356|       |    /* Mark multiplier table not yet set up for any method */
  357|     96|    idct->cur_method[ci] = -1;
  358|     96|  }
  359|     32|}

jpeg_make_d_derived_tbl:
  145|  1.77k|{
  146|  1.77k|  JHUFF_TBL *htbl;
  147|  1.77k|  d_derived_tbl *dtbl;
  148|  1.77k|  int p, i, l, si, numsymbols;
  149|  1.77k|  int lookbits, ctr;
  150|  1.77k|  char huffsize[257];
  151|  1.77k|  unsigned int huffcode[257];
  152|  1.77k|  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|  1.77k|  if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  1.77k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (159:7): [True: 0, False: 1.77k]
  |  Branch (159:20): [True: 0, False: 1.77k]
  ------------------
  160|      0|    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
  ------------------
  |  |  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)))
  ------------------
  161|  1.77k|  htbl =
  162|  1.77k|    isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
  ------------------
  |  Branch (162:5): [True: 891, False: 888]
  ------------------
  163|  1.77k|  if (htbl == NULL)
  ------------------
  |  Branch (163:7): [True: 3, False: 1.77k]
  ------------------
  164|      3|    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
  ------------------
  |  |  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)))
  ------------------
  165|       |
  166|       |  /* Allocate a workspace if we haven't already done so. */
  167|  1.77k|  if (*pdtbl == NULL)
  ------------------
  |  Branch (167:7): [True: 1.77k, False: 3]
  ------------------
  168|  1.77k|    *pdtbl = (d_derived_tbl *)
  169|  1.77k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  1.77k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  170|  1.77k|                                  sizeof(d_derived_tbl));
  171|  1.77k|  dtbl = *pdtbl;
  172|  1.77k|  dtbl->pub = htbl;             /* fill in back link */
  173|       |
  174|       |  /* Figure C.1: make table of Huffman code length for each symbol */
  175|       |
  176|  1.77k|  p = 0;
  177|  30.1k|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (177:15): [True: 28.4k, False: 1.77k]
  ------------------
  178|  28.4k|    i = (int)htbl->bits[l];
  179|  28.4k|    if (i < 0 || p + i > 256)   /* protect against table overrun */
  ------------------
  |  Branch (179:9): [True: 0, False: 28.4k]
  |  Branch (179:18): [True: 0, False: 28.4k]
  ------------------
  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|   178k|    while (i--)
  ------------------
  |  Branch (181:12): [True: 149k, False: 28.4k]
  ------------------
  182|   149k|      huffsize[p++] = (char)l;
  183|  28.4k|  }
  184|  1.77k|  huffsize[p] = 0;
  185|  1.77k|  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|  1.77k|  code = 0;
  191|  1.77k|  si = huffsize[0];
  192|  1.77k|  p = 0;
  193|  22.1k|  while (huffsize[p]) {
  ------------------
  |  Branch (193:10): [True: 20.3k, False: 1.77k]
  ------------------
  194|   170k|    while (((int)huffsize[p]) == si) {
  ------------------
  |  Branch (194:12): [True: 149k, False: 20.3k]
  ------------------
  195|   149k|      huffcode[p++] = code;
  196|   149k|      code++;
  197|   149k|    }
  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|  20.3k|    if (((JLONG)code) >= (((JLONG)1) << si))
  ------------------
  |  Branch (201:9): [True: 0, False: 20.3k]
  ------------------
  202|      0|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  203|  20.3k|    code <<= 1;
  204|  20.3k|    si++;
  205|  20.3k|  }
  206|       |
  207|       |  /* Figure F.15: generate decoding tables for bit-sequential decoding */
  208|       |
  209|  1.77k|  p = 0;
  210|  30.1k|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (210:15): [True: 28.4k, False: 1.77k]
  ------------------
  211|  28.4k|    if (htbl->bits[l]) {
  ------------------
  |  Branch (211:9): [True: 18.2k, False: 10.1k]
  ------------------
  212|       |      /* valoffset[l] = huffval[] index of 1st symbol of code length l,
  213|       |       * minus the minimum code of length l
  214|       |       */
  215|  18.2k|      dtbl->valoffset[l] = (JLONG)p - (JLONG)huffcode[p];
  216|  18.2k|      p += htbl->bits[l];
  217|  18.2k|      dtbl->maxcode[l] = huffcode[p - 1]; /* maximum code of length l */
  218|  18.2k|    } else {
  219|  10.1k|      dtbl->maxcode[l] = -1;    /* -1 if no codes of this length */
  220|  10.1k|    }
  221|  28.4k|  }
  222|  1.77k|  dtbl->valoffset[17] = 0;
  223|  1.77k|  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|   456k|  for (i = 0; i < (1 << HUFF_LOOKAHEAD); i++)
  ------------------
  |  |   25|   456k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (232:15): [True: 454k, False: 1.77k]
  ------------------
  233|   454k|    dtbl->lookup[i] = (HUFF_LOOKAHEAD + 1) << HUFF_LOOKAHEAD;
  ------------------
  |  |   25|   454k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
                  dtbl->lookup[i] = (HUFF_LOOKAHEAD + 1) << HUFF_LOOKAHEAD;
  ------------------
  |  |   25|   454k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  234|       |
  235|  1.77k|  p = 0;
  236|  15.9k|  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
  ------------------
  |  |   25|  15.9k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (236:15): [True: 14.2k, False: 1.77k]
  ------------------
  237|  39.8k|    for (i = 1; i <= (int)htbl->bits[l]; i++, p++) {
  ------------------
  |  Branch (237:17): [True: 25.6k, False: 14.2k]
  ------------------
  238|       |      /* l = current code's length, p = its index in huffcode[] & huffval[]. */
  239|       |      /* Generate left-justified code followed by all possible bit sequences */
  240|  25.6k|      lookbits = huffcode[p] << (HUFF_LOOKAHEAD - l);
  ------------------
  |  |   25|  25.6k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  241|   465k|      for (ctr = 1 << (HUFF_LOOKAHEAD - l); ctr > 0; ctr--) {
  ------------------
  |  |   25|  25.6k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  |  Branch (241:45): [True: 439k, False: 25.6k]
  ------------------
  242|   439k|        dtbl->lookup[lookbits] = (l << HUFF_LOOKAHEAD) | htbl->huffval[p];
  ------------------
  |  |   25|   439k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  ------------------
  243|   439k|        lookbits++;
  244|   439k|      }
  245|  25.6k|    }
  246|  14.2k|  }
  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|  1.77k|  if (isDC) {
  ------------------
  |  Branch (254:7): [True: 888, False: 891]
  ------------------
  255|  11.3k|    for (i = 0; i < numsymbols; i++) {
  ------------------
  |  Branch (255:17): [True: 10.5k, False: 888]
  ------------------
  256|  10.5k|      int sym = htbl->huffval[i];
  257|  10.5k|      if (sym < 0 || sym > (cinfo->master->lossless ? 16 : 15))
  ------------------
  |  Branch (257:11): [True: 0, False: 10.5k]
  |  Branch (257:22): [True: 0, False: 10.5k]
  |  Branch (257:29): [True: 0, False: 10.5k]
  ------------------
  258|      0|        ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  259|  10.5k|    }
  260|    888|  }
  261|  1.77k|}
jpeg_fill_bit_buffer:
  291|   133k|{
  292|       |  /* Copy heavily used state fields into locals (hopefully registers) */
  293|   133k|  register const JOCTET *next_input_byte = state->next_input_byte;
  294|   133k|  register size_t bytes_in_buffer = state->bytes_in_buffer;
  295|   133k|  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|   133k|  if (cinfo->unread_marker == 0) {      /* cannot advance past a marker */
  ------------------
  |  Branch (301:7): [True: 126k, False: 6.95k]
  ------------------
  302|  1.01M|    while (bits_left < MIN_GET_BITS) {
  ------------------
  |  |  282|  1.01M|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  1.01M|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  |  Branch (302:12): [True: 888k, False: 125k]
  ------------------
  303|   888k|      register int c;
  304|       |
  305|       |      /* Attempt to read a byte */
  306|   888k|      if (bytes_in_buffer == 0) {
  ------------------
  |  Branch (306:11): [True: 2.41k, False: 886k]
  ------------------
  307|  2.41k|        if (!(*cinfo->src->fill_input_buffer) (cinfo))
  ------------------
  |  Branch (307:13): [True: 0, False: 2.41k]
  ------------------
  308|      0|          return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  309|  2.41k|        next_input_byte = cinfo->src->next_input_byte;
  310|  2.41k|        bytes_in_buffer = cinfo->src->bytes_in_buffer;
  311|  2.41k|      }
  312|   888k|      bytes_in_buffer--;
  313|   888k|      c = *next_input_byte++;
  314|       |
  315|       |      /* If it's 0xFF, check and discard stuffed zero byte */
  316|   888k|      if (c == 0xFF) {
  ------------------
  |  Branch (316:11): [True: 23.1k, False: 865k]
  ------------------
  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|  2.59M|        do {
  323|  2.59M|          if (bytes_in_buffer == 0) {
  ------------------
  |  Branch (323:15): [True: 1.24k, False: 2.58M]
  ------------------
  324|  1.24k|            if (!(*cinfo->src->fill_input_buffer) (cinfo))
  ------------------
  |  Branch (324:17): [True: 0, False: 1.24k]
  ------------------
  325|      0|              return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  326|  1.24k|            next_input_byte = cinfo->src->next_input_byte;
  327|  1.24k|            bytes_in_buffer = cinfo->src->bytes_in_buffer;
  328|  1.24k|          }
  329|  2.59M|          bytes_in_buffer--;
  330|  2.59M|          c = *next_input_byte++;
  331|  2.59M|        } while (c == 0xFF);
  ------------------
  |  Branch (331:18): [True: 2.56M, False: 23.1k]
  ------------------
  332|       |
  333|  23.1k|        if (c == 0) {
  ------------------
  |  Branch (333:13): [True: 22.1k, False: 929]
  ------------------
  334|       |          /* Found FF/00, which represents an FF data byte */
  335|  22.1k|          c = 0xFF;
  336|  22.1k|        } 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|    929|          cinfo->unread_marker = c;
  346|       |          /* See if we need to insert some fake zero bits. */
  347|    929|          goto no_more_bytes;
  348|    929|        }
  349|  23.1k|      }
  350|       |
  351|       |      /* OK, load c into get_buffer */
  352|   887k|      get_buffer = (get_buffer << 8) | c;
  353|   887k|      bits_left += 8;
  354|   887k|    } /* end while */
  355|   126k|  } else {
  356|  7.88k|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|  7.88k|    if (nbits > bits_left) {
  ------------------
  |  Branch (361:9): [True: 2.19k, False: 5.69k]
  ------------------
  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|  2.19k|      if (!cinfo->entropy->insufficient_data) {
  ------------------
  |  Branch (367:11): [True: 929, False: 1.26k]
  ------------------
  368|    929|        WARNMS(cinfo, JWRN_HIT_MARKER);
  ------------------
  |  |  283|    929|  ((cinfo)->err->msg_code = (code), \
  |  |  284|    929|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  369|    929|        cinfo->entropy->insufficient_data = TRUE;
  ------------------
  |  |  210|    929|#define TRUE    1
  ------------------
  370|    929|      }
  371|       |      /* Fill the buffer with zero bits */
  372|  2.19k|      get_buffer <<= MIN_GET_BITS - bits_left;
  ------------------
  |  |  282|  2.19k|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  2.19k|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  373|  2.19k|      bits_left = MIN_GET_BITS;
  ------------------
  |  |  282|  2.19k|#define MIN_GET_BITS  (BIT_BUF_SIZE - 7)
  |  |  ------------------
  |  |  |  |   83|  2.19k|#define BIT_BUF_SIZE  64                /* size of buffer in bits */
  |  |  ------------------
  ------------------
  374|  2.19k|    }
  375|  7.88k|  }
  376|       |
  377|       |  /* Unload the local registers */
  378|   133k|  state->next_input_byte = next_input_byte;
  379|   133k|  state->bytes_in_buffer = bytes_in_buffer;
  380|   133k|  state->get_buffer = get_buffer;
  381|   133k|  state->bits_left = bits_left;
  382|       |
  383|   133k|  return TRUE;
  ------------------
  |  |  210|   133k|#define TRUE    1
  ------------------
  384|   133k|}
jpeg_huff_decode:
  439|   115k|{
  440|   115k|  register int l = min_bits;
  441|   115k|  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|   115k|  CHECK_BIT_BUFFER(*state, l, return -1);
  ------------------
  |  |  160|   115k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|   115k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 1.92k, False: 113k]
  |  |  ------------------
  |  |  162|  1.92k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 1.92k]
  |  |  ------------------
  |  |  163|  1.92k|      { action; } \
  |  |  164|  1.92k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  1.92k|  } \
  |  |  166|   115k|}
  ------------------
  447|   115k|  code = GET_BITS(l);
  ------------------
  |  |  169|   115k|  (((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|   984k|  while (code > htbl->maxcode[l]) {
  ------------------
  |  Branch (452:10): [True: 869k, False: 115k]
  ------------------
  453|   869k|    code <<= 1;
  454|   869k|    CHECK_BIT_BUFFER(*state, 1, return -1);
  ------------------
  |  |  160|   869k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|   869k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 15.5k, False: 853k]
  |  |  ------------------
  |  |  162|  15.5k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 15.5k]
  |  |  ------------------
  |  |  163|  15.5k|      { action; } \
  |  |  164|  15.5k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  15.5k|  } \
  |  |  166|   869k|}
  ------------------
  455|   869k|    code |= GET_BITS(1);
  ------------------
  |  |  169|   869k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  456|   869k|    l++;
  457|   869k|  }
  458|       |
  459|       |  /* Unload the local registers */
  460|   115k|  state->get_buffer = get_buffer;
  461|   115k|  state->bits_left = bits_left;
  462|       |
  463|       |  /* With garbage input we may reach the sentinel value l = 17. */
  464|       |
  465|   115k|  if (l > 16) {
  ------------------
  |  Branch (465:7): [True: 106k, False: 8.73k]
  ------------------
  466|   106k|    WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
  ------------------
  |  |  283|   106k|  ((cinfo)->err->msg_code = (code), \
  |  |  284|   106k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  467|   106k|    return 0;                   /* fake a zero as the safest result */
  468|   106k|  }
  469|       |
  470|  8.73k|  return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
  471|   115k|}
jinit_huff_decoder:
  815|    891|{
  816|    891|  huff_entropy_ptr entropy;
  817|    891|  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|    891|  std_huff_tables((j_common_ptr)cinfo);
  824|       |
  825|    891|  entropy = (huff_entropy_ptr)
  826|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  827|    891|                                sizeof(huff_entropy_decoder));
  828|    891|  cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
  829|    891|  entropy->pub.start_pass = start_pass_huff_decoder;
  830|    891|  entropy->pub.decode_mcu = decode_mcu;
  831|       |
  832|       |  /* Mark tables unallocated */
  833|  4.45k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  4.45k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (833:15): [True: 3.56k, False: 891]
  ------------------
  834|       |    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
  835|  3.56k|  }
  836|    891|}
jdhuff.c:start_pass_huff_decoder:
   80|    891|{
   81|    891|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
   82|    891|  int ci, blkn, dctbl, actbl;
   83|    891|  d_derived_tbl **pdtbl;
   84|    891|  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|    891|  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
  ------------------
  |  |   67|    891|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (90:7): [True: 0, False: 891]
  |  Branch (90:25): [True: 0, False: 891]
  ------------------
   91|    891|      cinfo->Ah != 0 || cinfo->Al != 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 891]
  |  Branch (91:25): [True: 0, False: 891]
  ------------------
   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|  1.78k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (94:16): [True: 891, False: 891]
  ------------------
   95|    891|    compptr = cinfo->cur_comp_info[ci];
   96|    891|    dctbl = compptr->dc_tbl_no;
   97|    891|    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|    891|    pdtbl = (d_derived_tbl **)(entropy->dc_derived_tbls) + dctbl;
  101|    891|    jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
  ------------------
  |  |  210|    891|#define TRUE    1
  ------------------
  102|    891|    pdtbl = (d_derived_tbl **)(entropy->ac_derived_tbls) + actbl;
  103|    891|    jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
  ------------------
  |  |  207|    891|#define FALSE   0               /* values of boolean */
  ------------------
  104|       |    /* Initialize DC predictions to 0 */
  105|    891|    entropy->saved.last_dc_val[ci] = 0;
  106|    891|  }
  107|       |
  108|       |  /* Precalculate decoding info for each block in an MCU of this scan */
  109|  1.77k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (109:18): [True: 888, False: 891]
  ------------------
  110|    888|    ci = cinfo->MCU_membership[blkn];
  111|    888|    compptr = cinfo->cur_comp_info[ci];
  112|       |    /* Precalculate which table to use for each block */
  113|    888|    entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
  114|    888|    entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
  115|       |    /* Decide whether we really care about the coefficient values */
  116|    888|    if (compptr->component_needed) {
  ------------------
  |  Branch (116:9): [True: 888, False: 0]
  ------------------
  117|    888|      entropy->dc_needed[blkn] = TRUE;
  ------------------
  |  |  210|    888|#define TRUE    1
  ------------------
  118|       |      /* we don't need the ACs if producing a 1/8th-size image */
  119|    888|      entropy->ac_needed[blkn] = (compptr->_DCT_scaled_size > 1);
  ------------------
  |  |   24|    888|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  120|    888|    } else {
  121|      0|      entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  122|      0|    }
  123|    888|  }
  124|       |
  125|       |  /* Initialize bitread state variables */
  126|    891|  entropy->bitstate.bits_left = 0;
  127|    891|  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
  128|    891|  entropy->pub.insufficient_data = FALSE;
  ------------------
  |  |  207|    891|#define FALSE   0               /* values of boolean */
  ------------------
  129|       |
  130|       |  /* Initialize restart counter */
  131|    891|  entropy->restarts_to_go = cinfo->restart_interval;
  132|    891|}
jdhuff.c:decode_mcu:
  771|  1.25M|{
  772|  1.25M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  773|  1.25M|  int usefast = 1;
  774|       |
  775|       |  /* Process restart marker if needed; may have to suspend */
  776|  1.25M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (776:7): [True: 22.7k, False: 1.23M]
  ------------------
  777|  22.7k|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (777:9): [True: 329, False: 22.3k]
  ------------------
  778|    329|      if (!process_restart(cinfo))
  ------------------
  |  Branch (778:11): [True: 0, False: 329]
  ------------------
  779|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  780|  22.7k|    usefast = 0;
  781|  22.7k|  }
  782|       |
  783|  1.25M|  if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU ||
  ------------------
  |  |  767|  1.25M|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  ------------------
  |  |  |  |   67|  1.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  ------------------
  ------------------
  |  Branch (783:7): [True: 489k, False: 766k]
  ------------------
  784|   766k|      cinfo->unread_marker != 0)
  ------------------
  |  Branch (784:7): [True: 386k, False: 379k]
  ------------------
  785|   875k|    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.25M|  if (!entropy->pub.insufficient_data) {
  ------------------
  |  Branch (790:7): [True: 502k, False: 753k]
  ------------------
  791|       |
  792|   502k|    if (usefast) {
  ------------------
  |  Branch (792:9): [True: 374k, False: 127k]
  ------------------
  793|   374k|      if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
  ------------------
  |  Branch (793:11): [True: 9.72k, False: 365k]
  ------------------
  794|   374k|    } else {
  795|   137k|use_slow:
  796|   137k|      if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (796:11): [True: 0, False: 137k]
  ------------------
  797|   137k|    }
  798|       |
  799|   502k|  }
  800|       |
  801|       |  /* Account for restart interval (no-op if not using restarts) */
  802|  1.25M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (802:7): [True: 22.4k, False: 1.23M]
  ------------------
  803|  22.4k|    entropy->restarts_to_go--;
  804|       |
  805|  1.25M|  return TRUE;
  ------------------
  |  |  210|  1.25M|#define TRUE    1
  ------------------
  806|  1.25M|}
jdhuff.c:process_restart:
  513|    329|{
  514|    329|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  515|    329|  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|    329|  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
  520|    329|  entropy->bitstate.bits_left = 0;
  521|       |
  522|       |  /* Advance past the RSTn marker */
  523|    329|  if (!(*cinfo->marker->read_restart_marker) (cinfo))
  ------------------
  |  Branch (523:7): [True: 0, False: 329]
  ------------------
  524|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  525|       |
  526|       |  /* Re-initialize DC predictions to 0 */
  527|    393|  for (ci = 0; ci < cinfo->comps_in_scan; ci++)
  ------------------
  |  Branch (527:16): [True: 64, False: 329]
  ------------------
  528|     64|    entropy->saved.last_dc_val[ci] = 0;
  529|       |
  530|       |  /* Reset restart counter */
  531|    329|  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|    329|  if (cinfo->unread_marker == 0)
  ------------------
  |  Branch (538:7): [True: 64, False: 265]
  ------------------
  539|     64|    entropy->pub.insufficient_data = FALSE;
  ------------------
  |  |  207|     64|#define FALSE   0               /* values of boolean */
  ------------------
  540|       |
  541|    329|  return TRUE;
  ------------------
  |  |  210|    329|#define TRUE    1
  ------------------
  542|    329|}
jdhuff.c:decode_mcu_fast:
  664|   374k|{
  665|   374k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  666|   374k|  BITREAD_STATE_VARS;
  ------------------
  |  |  125|   374k|  register bit_buf_type get_buffer; \
  |  |  126|   374k|  register int bits_left; \
  |  |  127|   374k|  bitread_working_state br_state
  ------------------
  667|   374k|  JOCTET *buffer;
  668|   374k|  int blkn;
  669|   374k|  savable_state state;
  670|       |  /* Outer loop handles each block in the MCU */
  671|       |
  672|       |  /* Load up working state */
  673|   374k|  BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  130|   374k|  br_state.cinfo = cinfop; \
  |  |  131|   374k|  br_state.next_input_byte = cinfop->src->next_input_byte; \
  |  |  132|   374k|  br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
  |  |  133|   374k|  get_buffer = permstate.get_buffer; \
  |  |  134|   374k|  bits_left = permstate.bits_left;
  ------------------
  674|   374k|  buffer = (JOCTET *)br_state.next_input_byte;
  675|   374k|  state = entropy->saved;
  676|       |
  677|   749k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (677:18): [True: 374k, False: 374k]
  ------------------
  678|   374k|    JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
  ------------------
  |  Branch (678:23): [True: 374k, False: 0]
  ------------------
  679|   374k|    d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
  680|   374k|    d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
  681|   374k|    register int s, k, r, l;
  682|       |
  683|   374k|    HUFF_DECODE_FAST(s, l, dctbl);
  ------------------
  |  |  224|   374k|  FILL_BIT_BUFFER_FAST; \
  |  |  ------------------
  |  |  |  |  415|   374k|  if (bits_left <= 16) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (415:7): [True: 61.9k, False: 312k]
  |  |  |  |  ------------------
  |  |  |  |  416|  61.9k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 708, False: 61.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|    708|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|    708|    buffer++; \
  |  |  |  |  |  |  401|    708|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 466, False: 242]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    466|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    466|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    466|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    466|      buffer -= 2; \
  |  |  |  |  |  |  406|    466|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    466|    } \
  |  |  |  |  |  |  408|    708|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 1.04k, False: 60.8k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  1.04k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  1.04k|    buffer++; \
  |  |  |  |  |  |  401|  1.04k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 717, False: 330]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    717|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    717|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    717|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    717|      buffer -= 2; \
  |  |  |  |  |  |  406|    717|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    717|    } \
  |  |  |  |  |  |  408|  1.04k|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 1.89k, False: 60.0k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  1.89k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  1.89k|    buffer++; \
  |  |  |  |  |  |  401|  1.89k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 917, False: 976]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|    917|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|    917|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|    917|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|    917|      buffer -= 2; \
  |  |  |  |  |  |  406|    917|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|    917|    } \
  |  |  |  |  |  |  408|  1.89k|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 1.69k, False: 60.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  1.69k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  1.69k|    buffer++; \
  |  |  |  |  |  |  401|  1.69k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 1.18k, False: 508]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  1.18k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  1.18k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  1.18k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  1.18k|      buffer -= 2; \
  |  |  |  |  |  |  406|  1.18k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  1.18k|    } \
  |  |  |  |  |  |  408|  1.69k|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 1.95k, False: 59.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  1.95k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  1.95k|    buffer++; \
  |  |  |  |  |  |  401|  1.95k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 1.36k, False: 590]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  1.36k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  1.36k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  1.36k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  1.36k|      buffer -= 2; \
  |  |  |  |  |  |  406|  1.36k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  1.36k|    } \
  |  |  |  |  |  |  408|  1.95k|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|  61.9k|#define GET_BYTE { \
  |  |  |  |  |  |  392|  61.9k|  register int c0, c1; \
  |  |  |  |  |  |  393|  61.9k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|  61.9k|  c1 = *buffer; \
  |  |  |  |  |  |  395|  61.9k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|  61.9k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|  61.9k|  bits_left += 8; \
  |  |  |  |  |  |  398|  61.9k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 2.57k, False: 59.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  2.57k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  2.57k|    buffer++; \
  |  |  |  |  |  |  401|  2.57k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 2.03k, False: 538]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  2.03k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  2.03k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  2.03k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  2.03k|      buffer -= 2; \
  |  |  |  |  |  |  406|  2.03k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  2.03k|    } \
  |  |  |  |  |  |  408|  2.57k|  } \
  |  |  |  |  |  |  409|  61.9k|}
  |  |  |  |  ------------------
  |  |  |  |  417|  61.9k|  }
  |  |  ------------------
  |  |  225|   374k|  s = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|   374k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  226|   374k|  s = htbl->lookup[s]; \
  |  |  227|   374k|  nb = s >> HUFF_LOOKAHEAD; \
  |  |  ------------------
  |  |  |  |   25|   374k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  228|   374k|  /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
  |  |  229|   374k|  DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|   374k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  230|   374k|  s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|   374k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  231|   374k|  if (nb > HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   749k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (231:7): [True: 236k, False: 137k]
  |  |  ------------------
  |  |  232|   236k|    /* Equivalent of jpeg_huff_decode() */ \
  |  |  233|   236k|    /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
  |  |  234|   236k|    s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
  |  |  235|  2.13M|    while (s > htbl->maxcode[nb]) { \
  |  |  ------------------
  |  |  |  Branch (235:12): [True: 1.89M, False: 236k]
  |  |  ------------------
  |  |  236|  1.89M|      s <<= 1; \
  |  |  237|  1.89M|      s |= GET_BITS(1); \
  |  |  ------------------
  |  |  |  |  169|  1.89M|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  238|  1.89M|      nb++; \
  |  |  239|  1.89M|    } \
  |  |  240|   236k|    if (nb > 16) \
  |  |  ------------------
  |  |  |  Branch (240:9): [True: 236k, False: 56]
  |  |  ------------------
  |  |  241|   236k|      s = 0; \
  |  |  242|   236k|    else \
  |  |  243|   236k|      s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
  |  |  244|   236k|  }
  ------------------
  684|   374k|    if (s) {
  ------------------
  |  Branch (684:9): [True: 124k, False: 250k]
  ------------------
  685|   124k|      FILL_BIT_BUFFER_FAST
  ------------------
  |  |  415|   124k|  if (bits_left <= 16) { \
  |  |  ------------------
  |  |  |  Branch (415:7): [True: 6.89k, False: 117k]
  |  |  ------------------
  |  |  416|  6.89k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 44, False: 6.84k]
  |  |  |  |  ------------------
  |  |  |  |  399|     44|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|     44|    buffer++; \
  |  |  |  |  401|     44|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 28, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  402|     28|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     28|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     28|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     28|      buffer -= 2; \
  |  |  |  |  406|     28|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     28|    } \
  |  |  |  |  408|     44|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 318, False: 6.57k]
  |  |  |  |  ------------------
  |  |  |  |  399|    318|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    318|    buffer++; \
  |  |  |  |  401|    318|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 60, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  402|     60|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     60|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     60|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     60|      buffer -= 2; \
  |  |  |  |  406|     60|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     60|    } \
  |  |  |  |  408|    318|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 138, False: 6.75k]
  |  |  |  |  ------------------
  |  |  |  |  399|    138|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    138|    buffer++; \
  |  |  |  |  401|    138|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 96, False: 42]
  |  |  |  |  ------------------
  |  |  |  |  402|     96|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|     96|      cinfo->unread_marker = c1; \
  |  |  |  |  404|     96|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|     96|      buffer -= 2; \
  |  |  |  |  406|     96|      get_buffer &= ~0xFF; \
  |  |  |  |  407|     96|    } \
  |  |  |  |  408|    138|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 160, False: 6.73k]
  |  |  |  |  ------------------
  |  |  |  |  399|    160|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    160|    buffer++; \
  |  |  |  |  401|    160|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 148, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  402|    148|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|    148|      cinfo->unread_marker = c1; \
  |  |  |  |  404|    148|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|    148|      buffer -= 2; \
  |  |  |  |  406|    148|      get_buffer &= ~0xFF; \
  |  |  |  |  407|    148|    } \
  |  |  |  |  408|    160|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 367, False: 6.52k]
  |  |  |  |  ------------------
  |  |  |  |  399|    367|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    367|    buffer++; \
  |  |  |  |  401|    367|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 267, False: 100]
  |  |  |  |  ------------------
  |  |  |  |  402|    267|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|    267|      cinfo->unread_marker = c1; \
  |  |  |  |  404|    267|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|    267|      buffer -= 2; \
  |  |  |  |  406|    267|      get_buffer &= ~0xFF; \
  |  |  |  |  407|    267|    } \
  |  |  |  |  408|    367|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  6.89k|#define GET_BYTE { \
  |  |  |  |  392|  6.89k|  register int c0, c1; \
  |  |  |  |  393|  6.89k|  c0 = *buffer++; \
  |  |  |  |  394|  6.89k|  c1 = *buffer; \
  |  |  |  |  395|  6.89k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  6.89k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  6.89k|  bits_left += 8; \
  |  |  |  |  398|  6.89k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 545, False: 6.34k]
  |  |  |  |  ------------------
  |  |  |  |  399|    545|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|    545|    buffer++; \
  |  |  |  |  401|    545|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 383, False: 162]
  |  |  |  |  ------------------
  |  |  |  |  402|    383|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|    383|      cinfo->unread_marker = c1; \
  |  |  |  |  404|    383|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|    383|      buffer -= 2; \
  |  |  |  |  406|    383|      get_buffer &= ~0xFF; \
  |  |  |  |  407|    383|    } \
  |  |  |  |  408|    545|  } \
  |  |  |  |  409|  6.89k|}
  |  |  ------------------
  |  |  417|  6.89k|  }
  ------------------
  686|   124k|      r = GET_BITS(s);
  ------------------
  |  |  169|   124k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  687|   124k|      s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|   124k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|   124k|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  688|   124k|    }
  689|       |
  690|   374k|    if (entropy->dc_needed[blkn]) {
  ------------------
  |  Branch (690:9): [True: 374k, False: 0]
  ------------------
  691|   374k|      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|   374k|      s += state.last_dc_val[ci];
  696|   374k|      state.last_dc_val[ci] = s;
  697|   374k|      if (block)
  ------------------
  |  Branch (697:11): [True: 374k, False: 0]
  ------------------
  698|   374k|        (*block)[0] = (JCOEF)s;
  699|   374k|    }
  700|       |
  701|   374k|    if (entropy->ac_needed[blkn] && block) {
  ------------------
  |  Branch (701:9): [True: 374k, False: 0]
  |  Branch (701:37): [True: 374k, False: 0]
  ------------------
  702|       |
  703|  1.00M|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|  1.00M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (703:19): [True: 952k, False: 50.4k]
  ------------------
  704|   952k|        HUFF_DECODE_FAST(s, l, actbl);
  ------------------
  |  |  224|   952k|  FILL_BIT_BUFFER_FAST; \
  |  |  ------------------
  |  |  |  |  415|   952k|  if (bits_left <= 16) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (415:7): [True: 226k, False: 726k]
  |  |  |  |  ------------------
  |  |  |  |  416|   226k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 5.42k, False: 220k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  5.42k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  5.42k|    buffer++; \
  |  |  |  |  |  |  401|  5.42k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 3.62k, False: 1.79k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  3.62k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  3.62k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  3.62k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  3.62k|      buffer -= 2; \
  |  |  |  |  |  |  406|  3.62k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  3.62k|    } \
  |  |  |  |  |  |  408|  5.42k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 5.65k, False: 220k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  5.65k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  5.65k|    buffer++; \
  |  |  |  |  |  |  401|  5.65k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 4.42k, False: 1.22k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  4.42k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  4.42k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  4.42k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  4.42k|      buffer -= 2; \
  |  |  |  |  |  |  406|  4.42k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  4.42k|    } \
  |  |  |  |  |  |  408|  5.65k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 7.41k, False: 218k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  7.41k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  7.41k|    buffer++; \
  |  |  |  |  |  |  401|  7.41k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 5.45k, False: 1.96k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  5.45k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  5.45k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  5.45k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  5.45k|      buffer -= 2; \
  |  |  |  |  |  |  406|  5.45k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  5.45k|    } \
  |  |  |  |  |  |  408|  7.41k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 8.06k, False: 218k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  8.06k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  8.06k|    buffer++; \
  |  |  |  |  |  |  401|  8.06k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 6.68k, False: 1.38k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  6.68k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  6.68k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  6.68k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  6.68k|      buffer -= 2; \
  |  |  |  |  |  |  406|  6.68k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  6.68k|    } \
  |  |  |  |  |  |  408|  8.06k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 9.27k, False: 216k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  9.27k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  9.27k|    buffer++; \
  |  |  |  |  |  |  401|  9.27k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 7.62k, False: 1.65k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  7.62k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  7.62k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  7.62k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  7.62k|      buffer -= 2; \
  |  |  |  |  |  |  406|  7.62k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  7.62k|    } \
  |  |  |  |  |  |  408|  9.27k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  |  |  ------------------
  |  |  |  |  |  |  391|   226k|#define GET_BYTE { \
  |  |  |  |  |  |  392|   226k|  register int c0, c1; \
  |  |  |  |  |  |  393|   226k|  c0 = *buffer++; \
  |  |  |  |  |  |  394|   226k|  c1 = *buffer; \
  |  |  |  |  |  |  395|   226k|  /* Pre-execute most common case */ \
  |  |  |  |  |  |  396|   226k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  |  |  397|   226k|  bits_left += 8; \
  |  |  |  |  |  |  398|   226k|  if (c0 == 0xFF) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (398:7): [True: 9.73k, False: 216k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  399|  9.73k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  |  |  400|  9.73k|    buffer++; \
  |  |  |  |  |  |  401|  9.73k|    if (c1 != 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (401:9): [True: 8.09k, False: 1.64k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  402|  8.09k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  |  |  403|  8.09k|      cinfo->unread_marker = c1; \
  |  |  |  |  |  |  404|  8.09k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  |  |  405|  8.09k|      buffer -= 2; \
  |  |  |  |  |  |  406|  8.09k|      get_buffer &= ~0xFF; \
  |  |  |  |  |  |  407|  8.09k|    } \
  |  |  |  |  |  |  408|  9.73k|  } \
  |  |  |  |  |  |  409|   226k|}
  |  |  |  |  ------------------
  |  |  |  |  417|   226k|  }
  |  |  ------------------
  |  |  225|   952k|  s = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|   952k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  226|   952k|  s = htbl->lookup[s]; \
  |  |  227|   952k|  nb = s >> HUFF_LOOKAHEAD; \
  |  |  ------------------
  |  |  |  |   25|   952k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  228|   952k|  /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
  |  |  229|   952k|  DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|   952k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  230|   952k|  s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|   952k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  231|   952k|  if (nb > HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  1.90M|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (231:7): [True: 83.2k, False: 869k]
  |  |  ------------------
  |  |  232|  83.2k|    /* Equivalent of jpeg_huff_decode() */ \
  |  |  233|  83.2k|    /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
  |  |  234|  83.2k|    s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
  |  |  235|   728k|    while (s > htbl->maxcode[nb]) { \
  |  |  ------------------
  |  |  |  Branch (235:12): [True: 645k, False: 83.2k]
  |  |  ------------------
  |  |  236|   645k|      s <<= 1; \
  |  |  237|   645k|      s |= GET_BITS(1); \
  |  |  ------------------
  |  |  |  |  169|   645k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  238|   645k|      nb++; \
  |  |  239|   645k|    } \
  |  |  240|  83.2k|    if (nb > 16) \
  |  |  ------------------
  |  |  |  Branch (240:9): [True: 80.5k, False: 2.68k]
  |  |  ------------------
  |  |  241|  83.2k|      s = 0; \
  |  |  242|  83.2k|    else \
  |  |  243|  83.2k|      s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
  |  |  244|  83.2k|  }
  ------------------
  705|   952k|        r = s >> 4;
  706|   952k|        s &= 15;
  707|       |
  708|   952k|        if (s) {
  ------------------
  |  Branch (708:13): [True: 627k, False: 324k]
  ------------------
  709|   627k|          k += r;
  710|   627k|          FILL_BIT_BUFFER_FAST
  ------------------
  |  |  415|   627k|  if (bits_left <= 16) { \
  |  |  ------------------
  |  |  |  Branch (415:7): [True: 31.0k, False: 596k]
  |  |  ------------------
  |  |  416|  31.0k|    GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 1.39k, False: 29.7k]
  |  |  |  |  ------------------
  |  |  |  |  399|  1.39k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  1.39k|    buffer++; \
  |  |  |  |  401|  1.39k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 1.32k, False: 64]
  |  |  |  |  ------------------
  |  |  |  |  402|  1.32k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  1.32k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  1.32k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  1.32k|      buffer -= 2; \
  |  |  |  |  406|  1.32k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  1.32k|    } \
  |  |  |  |  408|  1.39k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 2.26k, False: 28.8k]
  |  |  |  |  ------------------
  |  |  |  |  399|  2.26k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  2.26k|    buffer++; \
  |  |  |  |  401|  2.26k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 1.97k, False: 292]
  |  |  |  |  ------------------
  |  |  |  |  402|  1.97k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  1.97k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  1.97k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  1.97k|      buffer -= 2; \
  |  |  |  |  406|  1.97k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  1.97k|    } \
  |  |  |  |  408|  2.26k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 2.59k, False: 28.5k]
  |  |  |  |  ------------------
  |  |  |  |  399|  2.59k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  2.59k|    buffer++; \
  |  |  |  |  401|  2.59k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 2.42k, False: 171]
  |  |  |  |  ------------------
  |  |  |  |  402|  2.42k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  2.42k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  2.42k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  2.42k|      buffer -= 2; \
  |  |  |  |  406|  2.42k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  2.42k|    } \
  |  |  |  |  408|  2.59k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 2.83k, False: 28.2k]
  |  |  |  |  ------------------
  |  |  |  |  399|  2.83k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  2.83k|    buffer++; \
  |  |  |  |  401|  2.83k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 2.61k, False: 224]
  |  |  |  |  ------------------
  |  |  |  |  402|  2.61k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  2.61k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  2.61k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  2.61k|      buffer -= 2; \
  |  |  |  |  406|  2.61k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  2.61k|    } \
  |  |  |  |  408|  2.83k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 3.12k, False: 27.9k]
  |  |  |  |  ------------------
  |  |  |  |  399|  3.12k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  3.12k|    buffer++; \
  |  |  |  |  401|  3.12k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 2.79k, False: 332]
  |  |  |  |  ------------------
  |  |  |  |  402|  2.79k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  2.79k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  2.79k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  2.79k|      buffer -= 2; \
  |  |  |  |  406|  2.79k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  2.79k|    } \
  |  |  |  |  408|  3.12k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |                   GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
  |  |  ------------------
  |  |  |  |  391|  31.0k|#define GET_BYTE { \
  |  |  |  |  392|  31.0k|  register int c0, c1; \
  |  |  |  |  393|  31.0k|  c0 = *buffer++; \
  |  |  |  |  394|  31.0k|  c1 = *buffer; \
  |  |  |  |  395|  31.0k|  /* Pre-execute most common case */ \
  |  |  |  |  396|  31.0k|  get_buffer = (get_buffer << 8) | c0; \
  |  |  |  |  397|  31.0k|  bits_left += 8; \
  |  |  |  |  398|  31.0k|  if (c0 == 0xFF) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:7): [True: 3.23k, False: 27.8k]
  |  |  |  |  ------------------
  |  |  |  |  399|  3.23k|    /* Pre-execute case of FF/00, which represents an FF data byte */ \
  |  |  |  |  400|  3.23k|    buffer++; \
  |  |  |  |  401|  3.23k|    if (c1 != 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (401:9): [True: 3.04k, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  402|  3.04k|      /* Oops, it's actually a marker indicating end of compressed data. */ \
  |  |  |  |  403|  3.04k|      cinfo->unread_marker = c1; \
  |  |  |  |  404|  3.04k|      /* Back out pre-execution and fill the buffer with zero bits */ \
  |  |  |  |  405|  3.04k|      buffer -= 2; \
  |  |  |  |  406|  3.04k|      get_buffer &= ~0xFF; \
  |  |  |  |  407|  3.04k|    } \
  |  |  |  |  408|  3.23k|  } \
  |  |  |  |  409|  31.0k|}
  |  |  ------------------
  |  |  417|  31.0k|  }
  ------------------
  711|   627k|          r = GET_BITS(s);
  ------------------
  |  |  169|   627k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  712|   627k|          s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|   627k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|   627k|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  713|   627k|          (*block)[jpeg_natural_order[k]] = (JCOEF)s;
  714|   627k|        } else {
  715|   324k|          if (r != 15) break;
  ------------------
  |  Branch (715:15): [True: 324k, False: 388]
  ------------------
  716|    388|          k += 15;
  717|    388|        }
  718|   952k|      }
  719|       |
  720|   374k|    } 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|   374k|  }
  738|       |
  739|   374k|  if (cinfo->unread_marker != 0) {
  ------------------
  |  Branch (739:7): [True: 9.72k, False: 365k]
  ------------------
  740|  9.72k|    cinfo->unread_marker = 0;
  741|  9.72k|    return FALSE;
  ------------------
  |  |  207|  9.72k|#define FALSE   0               /* values of boolean */
  ------------------
  742|  9.72k|  }
  743|       |
  744|   365k|  br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
  745|   365k|  br_state.next_input_byte = buffer;
  746|   365k|  BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  137|   365k|  cinfop->src->next_input_byte = br_state.next_input_byte; \
  |  |  138|   365k|  cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
  |  |  139|   365k|  permstate.get_buffer = get_buffer; \
  |  |  140|   365k|  permstate.bits_left = bits_left
  ------------------
  747|   365k|  entropy->saved = state;
  748|   365k|  return TRUE;
  ------------------
  |  |  210|   365k|#define TRUE    1
  ------------------
  749|   374k|}
jdhuff.c:decode_mcu_slow:
  553|   137k|{
  554|   137k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  555|   137k|  BITREAD_STATE_VARS;
  ------------------
  |  |  125|   137k|  register bit_buf_type get_buffer; \
  |  |  126|   137k|  register int bits_left; \
  |  |  127|   137k|  bitread_working_state br_state
  ------------------
  556|   137k|  int blkn;
  557|   137k|  savable_state state;
  558|       |  /* Outer loop handles each block in the MCU */
  559|       |
  560|       |  /* Load up working state */
  561|   137k|  BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  130|   137k|  br_state.cinfo = cinfop; \
  |  |  131|   137k|  br_state.next_input_byte = cinfop->src->next_input_byte; \
  |  |  132|   137k|  br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
  |  |  133|   137k|  get_buffer = permstate.get_buffer; \
  |  |  134|   137k|  bits_left = permstate.bits_left;
  ------------------
  562|   137k|  state = entropy->saved;
  563|       |
  564|   274k|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (564:18): [True: 137k, False: 137k]
  ------------------
  565|   137k|    JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
  ------------------
  |  Branch (565:23): [True: 137k, False: 0]
  ------------------
  566|   137k|    d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
  567|   137k|    d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
  568|   137k|    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|   137k|    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
  ------------------
  |  |  200|   137k|#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
  |  |  201|   137k|  register int nb, look; \
  |  |  202|   137k|  if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   137k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (202:7): [True: 14.4k, False: 122k]
  |  |  ------------------
  |  |  203|  14.4k|    if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
  |  |  ------------------
  |  |  |  Branch (203:9): [True: 0, False: 14.4k]
  |  |  ------------------
  |  |  204|  14.4k|      { failaction; } \
  |  |  205|  14.4k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  206|  14.4k|    if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  14.4k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (206:9): [True: 6, False: 14.4k]
  |  |  ------------------
  |  |  207|      6|      nb = 1;  goto slowlabel; \
  |  |  208|      6|    } \
  |  |  209|  14.4k|  } \
  |  |  210|   137k|  look = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|   137k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  211|   137k|  if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   137k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |                 if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   137k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (211:7): [True: 61.4k, False: 75.7k]
  |  |  ------------------
  |  |  212|  61.4k|    DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|  61.4k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  213|  61.4k|    result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|  61.4k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  214|  75.7k|  } else { \
  |  |  215|  75.7k|slowlabel: \
  |  |  216|  75.7k|    if ((result = \
  |  |  ------------------
  |  |  |  Branch (216:9): [True: 0, False: 75.7k]
  |  |  ------------------
  |  |  217|  75.7k|         jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
  |  |  218|  75.7k|      { failaction; } \
  |  |  219|  75.7k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  220|  75.7k|  } \
  |  |  221|   137k|}
  ------------------
  574|   137k|    if (s) {
  ------------------
  |  Branch (574:9): [True: 52.8k, False: 84.3k]
  ------------------
  575|  52.8k|      CHECK_BIT_BUFFER(br_state, s, return FALSE);
  ------------------
  |  |  160|  52.8k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|  52.8k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 2.38k, False: 50.4k]
  |  |  ------------------
  |  |  162|  2.38k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 2.38k]
  |  |  ------------------
  |  |  163|  2.38k|      { action; } \
  |  |  164|  2.38k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  2.38k|  } \
  |  |  166|  52.8k|}
  ------------------
  576|  52.8k|      r = GET_BITS(s);
  ------------------
  |  |  169|  52.8k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  577|  52.8k|      s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|  52.8k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|  52.8k|#define NEG_1  ((unsigned int)-1)
  |  |  ------------------
  ------------------
  578|  52.8k|    }
  579|       |
  580|   137k|    if (entropy->dc_needed[blkn]) {
  ------------------
  |  Branch (580:9): [True: 137k, False: 0]
  ------------------
  581|       |      /* Convert DC difference to actual value, update last_dc_val */
  582|   137k|      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|   137k|      s += state.last_dc_val[ci];
  592|   137k|      state.last_dc_val[ci] = s;
  593|   137k|      if (block) {
  ------------------
  |  Branch (593:11): [True: 137k, False: 0]
  ------------------
  594|       |        /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
  595|   137k|        (*block)[0] = (JCOEF)s;
  596|   137k|      }
  597|   137k|    }
  598|       |
  599|   137k|    if (entropy->ac_needed[blkn] && block) {
  ------------------
  |  Branch (599:9): [True: 137k, False: 0]
  |  Branch (599:37): [True: 137k, 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|   725k|      for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|   725k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (603:19): [True: 702k, False: 22.9k]
  ------------------
  604|   702k|        HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
  ------------------
  |  |  200|   702k|#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
  |  |  201|   702k|  register int nb, look; \
  |  |  202|   702k|  if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   702k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (202:7): [True: 72.5k, False: 630k]
  |  |  ------------------
  |  |  203|  72.5k|    if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
  |  |  ------------------
  |  |  |  Branch (203:9): [True: 0, False: 72.5k]
  |  |  ------------------
  |  |  204|  72.5k|      { failaction; } \
  |  |  205|  72.5k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  206|  72.5k|    if (bits_left < HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|  72.5k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (206:9): [True: 4.76k, False: 67.8k]
  |  |  ------------------
  |  |  207|  4.76k|      nb = 1;  goto slowlabel; \
  |  |  208|  4.76k|    } \
  |  |  209|  72.5k|  } \
  |  |  210|   702k|  look = PEEK_BITS(HUFF_LOOKAHEAD); \
  |  |  ------------------
  |  |  |  |  172|   697k|  (((int)(get_buffer >> (bits_left -  (nbits)))) & ((1 << (nbits)) - 1))
  |  |  ------------------
  |  |  211|   697k|  if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   697k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |                 if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
  |  |  ------------------
  |  |  |  |   25|   697k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  |  Branch (211:7): [True: 663k, False: 34.7k]
  |  |  ------------------
  |  |  212|   663k|    DROP_BITS(nb); \
  |  |  ------------------
  |  |  |  |  175|   663k|  (bits_left -= (nbits))
  |  |  ------------------
  |  |  213|   663k|    result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
  |  |  ------------------
  |  |  |  |   25|   663k|#define HUFF_LOOKAHEAD  8       /* # of bits of lookahead */
  |  |  ------------------
  |  |  214|   663k|  } else { \
  |  |  215|  39.5k|slowlabel: \
  |  |  216|  39.5k|    if ((result = \
  |  |  ------------------
  |  |  |  Branch (216:9): [True: 0, False: 39.5k]
  |  |  ------------------
  |  |  217|  39.5k|         jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
  |  |  218|  39.5k|      { failaction; } \
  |  |  219|  39.5k|    get_buffer = state.get_buffer;  bits_left = state.bits_left; \
  |  |  220|  39.5k|  } \
  |  |  221|   697k|}
  ------------------
  605|       |
  606|   702k|        r = s >> 4;
  607|   702k|        s &= 15;
  608|       |
  609|   702k|        if (s) {
  ------------------
  |  Branch (609:13): [True: 588k, False: 114k]
  ------------------
  610|   588k|          k += r;
  611|   588k|          CHECK_BIT_BUFFER(br_state, s, return FALSE);
  ------------------
  |  |  160|   588k|#define CHECK_BIT_BUFFER(state, nbits, action) { \
  |  |  161|   588k|  if (bits_left < (nbits)) { \
  |  |  ------------------
  |  |  |  Branch (161:7): [True: 26.2k, False: 562k]
  |  |  ------------------
  |  |  162|  26.2k|    if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
  |  |  ------------------
  |  |  |  Branch (162:9): [True: 0, False: 26.2k]
  |  |  ------------------
  |  |  163|  26.2k|      { action; } \
  |  |  164|  26.2k|    get_buffer = (state).get_buffer;  bits_left = (state).bits_left; \
  |  |  165|  26.2k|  } \
  |  |  166|   588k|}
  ------------------
  612|   588k|          r = GET_BITS(s);
  ------------------
  |  |  169|   588k|  (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
  ------------------
  613|   588k|          s = HUFF_EXTEND(r, s);
  ------------------
  |  |  484|   588k|  ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
  |  |  ------------------
  |  |  |  |  482|   588k|#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|   588k|          (*block)[jpeg_natural_order[k]] = (JCOEF)s;
  619|   588k|        } else {
  620|   114k|          if (r != 15)
  ------------------
  |  Branch (620:15): [True: 114k, False: 164]
  ------------------
  621|   114k|            break;
  622|    164|          k += 15;
  623|    164|        }
  624|   702k|      }
  625|       |
  626|   137k|    } 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|   137k|  }
  648|       |
  649|       |  /* Completed MCU, so update state */
  650|   137k|  BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
  ------------------
  |  |  137|   137k|  cinfop->src->next_input_byte = br_state.next_input_byte; \
  |  |  138|   137k|  cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
  |  |  139|   137k|  permstate.get_buffer = get_buffer; \
  |  |  140|   137k|  permstate.bits_left = bits_left
  ------------------
  651|   137k|  entropy->saved = state;
  652|   137k|  return TRUE;
  ------------------
  |  |  210|   137k|#define TRUE    1
  ------------------
  653|   137k|}

jinit_input_controller:
  405|  1.15k|{
  406|  1.15k|  my_inputctl_ptr inputctl;
  407|       |
  408|       |  /* Create subobject in permanent pool */
  409|  1.15k|  inputctl = (my_inputctl_ptr)
  410|  1.15k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  1.15k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  411|  1.15k|                                sizeof(my_input_controller));
  412|  1.15k|  cinfo->inputctl = (struct jpeg_input_controller *)inputctl;
  413|       |  /* Initialize method pointers */
  414|  1.15k|  inputctl->pub.consume_input = consume_markers;
  415|  1.15k|  inputctl->pub.reset_input_controller = reset_input_controller;
  416|  1.15k|  inputctl->pub.start_input_pass = start_input_pass;
  417|  1.15k|  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|  1.15k|  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
  ------------------
  |  |  207|  1.15k|#define FALSE   0               /* values of boolean */
  ------------------
  422|  1.15k|  inputctl->pub.eoi_reached = FALSE;
  ------------------
  |  |  207|  1.15k|#define FALSE   0               /* values of boolean */
  ------------------
  423|  1.15k|  inputctl->inheaders = TRUE;
  ------------------
  |  |  210|  1.15k|#define TRUE    1
  ------------------
  424|  1.15k|}
jdinput.c:consume_markers:
  332|  2.27k|{
  333|  2.27k|  my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
  334|  2.27k|  int val;
  335|       |
  336|  2.27k|  if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
  ------------------
  |  Branch (336:7): [True: 0, False: 2.27k]
  ------------------
  337|      0|    return JPEG_REACHED_EOI;
  ------------------
  |  | 1112|      0|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  338|       |
  339|  2.27k|  val = (*cinfo->marker->read_markers) (cinfo);
  340|       |
  341|  2.27k|  switch (val) {
  ------------------
  |  Branch (341:11): [True: 1.16k, False: 1.10k]
  ------------------
  342|    961|  case JPEG_REACHED_SOS:        /* Found SOS */
  ------------------
  |  | 1111|    961|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
  |  Branch (342:3): [True: 961, False: 1.30k]
  ------------------
  343|    961|    if (inputctl->inheaders) {  /* 1st SOS */
  ------------------
  |  Branch (343:9): [True: 961, False: 0]
  ------------------
  344|    961|      initial_setup(cinfo);
  345|    961|      inputctl->inheaders = FALSE;
  ------------------
  |  |  207|    961|#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|    961|    } 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|    961|    break;
  356|    202|  case JPEG_REACHED_EOI:        /* Found EOI */
  ------------------
  |  | 1112|    202|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
  |  Branch (356:3): [True: 202, False: 2.06k]
  ------------------
  357|    202|    inputctl->pub.eoi_reached = TRUE;
  ------------------
  |  |  210|    202|#define TRUE    1
  ------------------
  358|    202|    if (inputctl->inheaders) {  /* Tables-only datastream, apparently */
  ------------------
  |  Branch (358:9): [True: 202, False: 0]
  ------------------
  359|    202|      if (cinfo->marker->saw_SOF)
  ------------------
  |  Branch (359:11): [True: 0, False: 202]
  ------------------
  360|      0|        ERREXIT(cinfo, JERR_SOF_NO_SOS);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  361|    202|    } 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|    202|    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: 2.27k]
  ------------------
  370|      0|    break;
  371|  2.27k|  }
  372|       |
  373|  1.16k|  return val;
  374|  2.27k|}
jdinput.c:initial_setup:
   49|    961|{
   50|    961|  int ci;
   51|    961|  jpeg_component_info *compptr;
   52|    961|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|    959|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (52:19): [True: 2, False: 959]
  ------------------
   53|       |
   54|       |  /* Make sure image isn't bigger than I can handle */
   55|    961|  if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  1.92k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (55:7): [True: 0, False: 961]
  ------------------
   56|    961|      (long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|    961|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (56:7): [True: 0, False: 961]
  ------------------
   57|      0|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
  ------------------
  |  |  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)))
  ------------------
   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|    961|#ifdef D_LOSSLESS_SUPPORTED
   63|    961|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (63:7): [True: 2, False: 959]
  ------------------
   64|      2|    if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
  ------------------
  |  Branch (64:9): [True: 0, False: 2]
  |  Branch (64:38): [True: 0, False: 2]
  ------------------
   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|      2|  } else
   67|    959|#endif
   68|    959|  {
   69|    959|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (69:9): [True: 67, False: 892]
  |  Branch (69:39): [True: 0, False: 67]
  ------------------
   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|    959|  }
   72|       |
   73|       |  /* Check that number of components won't exceed internal array sizes */
   74|    961|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|    961|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (74:7): [True: 0, False: 961]
  ------------------
   75|      0|    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
  ------------------
  |  |  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)))
  ------------------
   76|    961|             MAX_COMPONENTS);
   77|       |
   78|       |  /* Compute maximum sampling factors; check factor validity */
   79|    961|  cinfo->max_h_samp_factor = 1;
   80|    961|  cinfo->max_v_samp_factor = 1;
   81|  2.06k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (81:44): [True: 1.10k, False: 961]
  ------------------
   82|  1.10k|       ci++, compptr++) {
   83|  1.10k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (83:9): [True: 0, False: 1.10k]
  ------------------
   84|  1.10k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|  2.20k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (84:9): [True: 0, False: 1.10k]
  ------------------
   85|  1.10k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (85:9): [True: 0, False: 1.10k]
  ------------------
   86|  1.10k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  1.10k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (86:9): [True: 1, False: 1.09k]
  ------------------
   87|      1|      ERREXIT(cinfo, JERR_BAD_SAMPLING);
  ------------------
  |  |  240|      1|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      1|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   88|  1.10k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  1.10k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 0, False: 1.10k]
  |  |  ------------------
  ------------------
   89|  1.10k|                                   compptr->h_samp_factor);
   90|  1.10k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  1.10k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 0, False: 1.10k]
  |  |  ------------------
  ------------------
   91|  1.10k|                                   compptr->v_samp_factor);
   92|  1.10k|  }
   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|    961|  cinfo->min_DCT_scaled_size = data_unit;
  108|    961|#endif
  109|       |
  110|       |  /* Compute dimensions of components */
  111|  2.05k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (111:44): [True: 1.09k, False: 961]
  ------------------
  112|  1.09k|       ci++, compptr++) {
  113|       |#if JPEG_LIB_VERSION >= 70
  114|       |    compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
  115|       |#else
  116|  1.09k|    compptr->DCT_scaled_size = data_unit;
  117|  1.09k|#endif
  118|       |    /* Size in data units */
  119|  1.09k|    compptr->width_in_blocks = (JDIMENSION)
  120|  1.09k|      jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
  121|  1.09k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  122|  1.09k|    compptr->height_in_blocks = (JDIMENSION)
  123|  1.09k|      jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
  124|  1.09k|                    (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|  1.09k|    cinfo->master->first_MCU_col[ci] = 0;
  129|  1.09k|    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|  1.09k|    compptr->downsampled_width = (JDIMENSION)
  136|  1.09k|      jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
  137|  1.09k|                    (long)cinfo->max_h_samp_factor);
  138|  1.09k|    compptr->downsampled_height = (JDIMENSION)
  139|  1.09k|      jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
  140|  1.09k|                    (long)cinfo->max_v_samp_factor);
  141|       |    /* Mark component needed, until color conversion says otherwise */
  142|  1.09k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  1.09k|#define TRUE    1
  ------------------
  143|       |    /* Mark no quantization table yet saved for component */
  144|  1.09k|    compptr->quant_table = NULL;
  145|  1.09k|  }
  146|       |
  147|       |  /* Compute number of fully interleaved MCU rows. */
  148|    961|  cinfo->total_iMCU_rows = (JDIMENSION)
  149|    961|    jdiv_round_up((long)cinfo->image_height,
  150|    961|                  (long)(cinfo->max_v_samp_factor * data_unit));
  151|       |
  152|       |  /* Decide whether file contains multiple scans */
  153|    961|  if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
  ------------------
  |  Branch (153:7): [True: 70, False: 891]
  |  Branch (153:55): [True: 0, False: 891]
  ------------------
  154|     69|    cinfo->inputctl->has_multiple_scans = TRUE;
  ------------------
  |  |  210|     69|#define TRUE    1
  ------------------
  155|    892|  else
  156|    892|    cinfo->inputctl->has_multiple_scans = FALSE;
  ------------------
  |  |  207|    892|#define FALSE   0               /* values of boolean */
  ------------------
  157|    961|}
jdinput.c:reset_input_controller:
  383|  2.27k|{
  384|  2.27k|  my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
  385|       |
  386|  2.27k|  inputctl->pub.consume_input = consume_markers;
  387|  2.27k|  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
  ------------------
  |  |  207|  2.27k|#define FALSE   0               /* values of boolean */
  ------------------
  388|  2.27k|  inputctl->pub.eoi_reached = FALSE;
  ------------------
  |  |  207|  2.27k|#define FALSE   0               /* values of boolean */
  ------------------
  389|  2.27k|  inputctl->inheaders = TRUE;
  ------------------
  |  |  210|  2.27k|#define TRUE    1
  ------------------
  390|       |  /* Reset other modules */
  391|  2.27k|  (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
  392|  2.27k|  (*cinfo->marker->reset_marker_reader) (cinfo);
  393|       |  /* Reset progression state -- would be cleaner if entropy decoder did this */
  394|       |  cinfo->coef_bits = NULL;
  395|  2.27k|}
jdinput.c:start_input_pass:
  297|    923|{
  298|    923|  per_scan_setup(cinfo);
  299|    923|  if (!cinfo->master->lossless)
  ------------------
  |  Branch (299:7): [True: 923, False: 0]
  ------------------
  300|    923|    latch_quant_tables(cinfo);
  301|    923|  (*cinfo->entropy->start_pass) (cinfo);
  302|    923|  (*cinfo->coef->start_input_pass) (cinfo);
  303|    923|  cinfo->inputctl->consume_input = cinfo->coef->consume_data;
  304|    923|}
jdinput.c:per_scan_setup:
  164|    923|{
  165|    923|  int ci, mcublks, tmp;
  166|    923|  jpeg_component_info *compptr;
  167|    923|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (167:19): [True: 0, False: 923]
  ------------------
  168|       |
  169|    923|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (169:7): [True: 923, False: 0]
  ------------------
  170|       |
  171|       |    /* Noninterleaved (single-component) scan */
  172|    923|    compptr = cinfo->cur_comp_info[0];
  173|       |
  174|       |    /* Overall image size in MCUs */
  175|    923|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  176|    923|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  177|       |
  178|       |    /* For noninterleaved scan, always one data unit per MCU */
  179|    923|    compptr->MCU_width = 1;
  180|    923|    compptr->MCU_height = 1;
  181|    923|    compptr->MCU_blocks = 1;
  182|    923|    compptr->MCU_sample_width = compptr->_DCT_scaled_size;
  ------------------
  |  |   24|    923|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  183|    923|    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|    923|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  188|    923|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (188:9): [True: 922, False: 1]
  ------------------
  189|    923|    compptr->last_row_height = tmp;
  190|       |
  191|       |    /* Prepare array describing MCU composition */
  192|    923|    cinfo->blocks_in_MCU = 1;
  193|    923|    cinfo->MCU_membership[0] = 0;
  194|       |
  195|    923|  } else {
  196|       |
  197|       |    /* Interleaved (multi-component) scan */
  198|      0|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|      0|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  |  Branch (198:38): [True: 0, False: 0]
  ------------------
  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|      0|               MAX_COMPS_IN_SCAN);
  201|       |
  202|       |    /* Overall image size in MCUs */
  203|      0|    cinfo->MCUs_per_row = (JDIMENSION)
  204|      0|      jdiv_round_up((long)cinfo->image_width,
  205|      0|                    (long)(cinfo->max_h_samp_factor * data_unit));
  206|      0|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  207|      0|      jdiv_round_up((long)cinfo->image_height,
  208|      0|                    (long)(cinfo->max_v_samp_factor * data_unit));
  209|       |
  210|      0|    cinfo->blocks_in_MCU = 0;
  211|       |
  212|      0|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (212:18): [True: 0, False: 0]
  ------------------
  213|      0|      compptr = cinfo->cur_comp_info[ci];
  214|       |      /* Sampling factors give # of data units of component in each MCU */
  215|      0|      compptr->MCU_width = compptr->h_samp_factor;
  216|      0|      compptr->MCU_height = compptr->v_samp_factor;
  217|      0|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  218|      0|      compptr->MCU_sample_width = compptr->MCU_width *
  219|      0|                                  compptr->_DCT_scaled_size;
  ------------------
  |  |   24|      0|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  220|       |      /* Figure number of non-dummy data units in last MCU column & row */
  221|      0|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  222|      0|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (222:11): [True: 0, False: 0]
  ------------------
  223|      0|      compptr->last_col_width = tmp;
  224|      0|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  225|      0|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (225:11): [True: 0, False: 0]
  ------------------
  226|      0|      compptr->last_row_height = tmp;
  227|       |      /* Prepare array describing MCU composition */
  228|      0|      mcublks = compptr->MCU_blocks;
  229|      0|      if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   82|      0|#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on data units/MCU */
  ------------------
  |  Branch (229:11): [True: 0, False: 0]
  ------------------
  230|      0|        ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  231|      0|      while (mcublks-- > 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 0]
  ------------------
  232|      0|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  233|      0|      }
  234|      0|    }
  235|       |
  236|      0|  }
  237|    923|}
jdinput.c:latch_quant_tables:
  263|    923|{
  264|    923|  int ci, qtblno;
  265|    923|  jpeg_component_info *compptr;
  266|    923|  JQUANT_TBL *qtbl;
  267|       |
  268|  1.84k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (268:16): [True: 923, False: 923]
  ------------------
  269|    923|    compptr = cinfo->cur_comp_info[ci];
  270|       |    /* No work if we already saved Q-table for this component */
  271|    923|    if (compptr->quant_table != NULL)
  ------------------
  |  Branch (271:9): [True: 0, False: 923]
  ------------------
  272|      0|      continue;
  273|       |    /* Make sure specified quantization table is present */
  274|    923|    qtblno = compptr->quant_tbl_no;
  275|    923|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|  1.84k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (275:9): [True: 0, False: 923]
  |  Branch (275:23): [True: 32, False: 891]
  ------------------
  276|    891|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (276:9): [True: 0, False: 891]
  ------------------
  277|     32|      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
  ------------------
  |  |  243|     32|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     32|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     32|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  278|       |    /* OK, save away the quantization table */
  279|    923|    qtbl = (JQUANT_TBL *)
  280|    923|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    923|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  281|    923|                                  sizeof(JQUANT_TBL));
  282|    923|    memcpy(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
  283|    923|    compptr->quant_table = qtbl;
  284|    923|  }
  285|    923|}
jdinput.c:finish_input_pass:
  315|    872|{
  316|    872|  cinfo->inputctl->consume_input = consume_markers;
  317|    872|}

jinit_d_main_controller:
  429|    891|{
  430|    891|  my_main_ptr main_ptr;
  431|    891|  int ci, rgroup, ngroups;
  432|    891|  jpeg_component_info *compptr;
  433|       |
  434|    891|#ifdef D_LOSSLESS_SUPPORTED
  435|    891|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (435:7): [True: 0, False: 891]
  ------------------
  436|      0|#if BITS_IN_JSAMPLE == 8
  437|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (437:9): [True: 0, False: 0]
  |  Branch (437:52): [True: 0, False: 0]
  ------------------
  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|      0|  } else
  444|    891|#endif
  445|    891|  {
  446|    891|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (446:9): [True: 0, False: 891]
  ------------------
  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|    891|  }
  449|       |
  450|    891|  main_ptr = (my_main_ptr)
  451|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  452|    891|                                sizeof(my_main_controller));
  453|    891|  memset(main_ptr, 0, sizeof(my_main_controller));
  454|    891|  cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
  455|    891|  main_ptr->pub.start_pass = start_pass_main;
  456|       |
  457|    891|  if (need_full_buffer)         /* shouldn't happen */
  ------------------
  |  Branch (457:7): [True: 0, False: 891]
  ------------------
  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|    891|  if (cinfo->upsample->need_context_rows) {
  ------------------
  |  Branch (463:7): [True: 0, False: 891]
  ------------------
  464|      0|    if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (464:9): [True: 0, False: 0]
  ------------------
  465|      0|      ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  466|      0|    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
  467|      0|    ngroups = cinfo->_min_DCT_scaled_size + 2;
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  468|    891|  } else {
  469|    891|    ngroups = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|    891|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  470|    891|  }
  471|       |
  472|  1.78k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (472:44): [True: 891, False: 891]
  ------------------
  473|    891|       ci++, compptr++) {
  474|    891|    rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|    891|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  475|    891|      cinfo->_min_DCT_scaled_size; /* height of a row group of component */
  ------------------
  |  |   27|    891|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  476|    891|    main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  477|    891|                        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|    891|                         compptr->width_in_blocks * compptr->_DCT_scaled_size,
  ------------------
  |  |   24|    891|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  479|    891|                         (JDIMENSION)(rgroup * ngroups));
  480|    891|  }
  481|    891|}
jdmainct-8.c:start_pass_main:
  259|    888|{
  260|    888|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  261|       |
  262|    888|  switch (pass_mode) {
  263|    888|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (263:3): [True: 888, False: 0]
  ------------------
  264|    888|    if (cinfo->upsample->need_context_rows) {
  ------------------
  |  Branch (264:9): [True: 0, False: 888]
  ------------------
  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|    888|    } else {
  271|       |      /* Simple case with no context needed */
  272|    888|      main_ptr->pub._process_data = process_data_simple_main;
  ------------------
  |  |  256|    888|#define _process_data  process_data
  ------------------
  273|    888|    }
  274|    888|    main_ptr->buffer_full = FALSE;      /* Mark buffer empty */
  ------------------
  |  |  207|    888|#define FALSE   0               /* values of boolean */
  ------------------
  275|    888|    main_ptr->rowgroup_ctr = 0;
  276|    888|    break;
  277|      0|#ifdef QUANT_2PASS_SUPPORTED
  278|      0|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (278:3): [True: 0, False: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|  }
  287|    888|}
jdmainct-8.c:process_data_simple_main:
  298|   869k|{
  299|   869k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  300|   869k|  JDIMENSION rowgroups_avail;
  301|       |
  302|       |  /* Read input data if we haven't filled the main buffer yet */
  303|   869k|  if (!main_ptr->buffer_full) {
  ------------------
  |  Branch (303:7): [True: 107k, False: 762k]
  ------------------
  304|   107k|    if (!(*cinfo->coef->_decompress_data) (cinfo, main_ptr->buffer))
  ------------------
  |  |  258|   107k|#define _decompress_data  decompress_data
  ------------------
  |  Branch (304:9): [True: 0, False: 107k]
  ------------------
  305|      0|      return;                   /* suspension forced, can do nothing more */
  306|   107k|    main_ptr->buffer_full = TRUE;       /* OK, we have an iMCU row to work with */
  ------------------
  |  |  210|   107k|#define TRUE    1
  ------------------
  307|   107k|  }
  308|       |
  309|       |  /* There are always min_DCT_scaled_size row groups in an iMCU row. */
  310|   869k|  rowgroups_avail = (JDIMENSION)cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|   869k|#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|   869k|  (*cinfo->post->_post_process_data) (cinfo, main_ptr->buffer,
  ------------------
  |  |  260|   869k|#define _post_process_data  post_process_data
  ------------------
  318|   869k|                                      &main_ptr->rowgroup_ctr, rowgroups_avail,
  319|   869k|                                      output_buf, out_row_ctr, out_rows_avail);
  320|       |
  321|       |  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */
  322|   869k|  if (main_ptr->rowgroup_ctr >= rowgroups_avail) {
  ------------------
  |  Branch (322:7): [True: 107k, False: 762k]
  ------------------
  323|   107k|    main_ptr->buffer_full = FALSE;
  ------------------
  |  |  207|   107k|#define FALSE   0               /* values of boolean */
  ------------------
  324|   107k|    main_ptr->rowgroup_ctr = 0;
  325|   107k|  }
  326|   869k|}
j12init_d_main_controller:
  429|     32|{
  430|     32|  my_main_ptr main_ptr;
  431|     32|  int ci, rgroup, ngroups;
  432|     32|  jpeg_component_info *compptr;
  433|       |
  434|     32|#ifdef D_LOSSLESS_SUPPORTED
  435|     32|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (435:7): [True: 0, False: 32]
  ------------------
  436|       |#if BITS_IN_JSAMPLE == 8
  437|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  438|       |#else
  439|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (439:9): [True: 0, False: 0]
  ------------------
  440|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (440:9): [True: 0, False: 0]
  ------------------
  441|      0|#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|      0|  } else
  444|     32|#endif
  445|     32|  {
  446|     32|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (446:9): [True: 0, False: 32]
  ------------------
  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|     32|  }
  449|       |
  450|     32|  main_ptr = (my_main_ptr)
  451|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  452|     32|                                sizeof(my_main_controller));
  453|     32|  memset(main_ptr, 0, sizeof(my_main_controller));
  454|     32|  cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
  455|     32|  main_ptr->pub.start_pass = start_pass_main;
  456|       |
  457|     32|  if (need_full_buffer)         /* shouldn't happen */
  ------------------
  |  Branch (457:7): [True: 0, False: 32]
  ------------------
  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|     32|  if (cinfo->upsample->need_context_rows) {
  ------------------
  |  Branch (463:7): [True: 0, False: 32]
  ------------------
  464|      0|    if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (464:9): [True: 0, False: 0]
  ------------------
  465|      0|      ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  466|      0|    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
  467|      0|    ngroups = cinfo->_min_DCT_scaled_size + 2;
  ------------------
  |  |   27|      0|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  468|     32|  } else {
  469|     32|    ngroups = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|     32|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  470|     32|  }
  471|       |
  472|    128|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (472:44): [True: 96, False: 32]
  ------------------
  473|     96|       ci++, compptr++) {
  474|     96|    rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|     96|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  475|     96|      cinfo->_min_DCT_scaled_size; /* height of a row group of component */
  ------------------
  |  |   27|     96|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  476|     96|    main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  477|     96|                        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     96|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|     96|                         compptr->width_in_blocks * compptr->_DCT_scaled_size,
  ------------------
  |  |   24|     96|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  479|     96|                         (JDIMENSION)(rgroup * ngroups));
  480|     96|  }
  481|     32|}

jinit_marker_reader:
 1288|  1.15k|{
 1289|  1.15k|  my_marker_ptr marker;
 1290|  1.15k|  int i;
 1291|       |
 1292|       |  /* Create subobject in permanent pool */
 1293|  1.15k|  marker = (my_marker_ptr)
 1294|  1.15k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  1.15k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
 1295|  1.15k|                                sizeof(my_marker_reader));
 1296|  1.15k|  cinfo->marker = (struct jpeg_marker_reader *)marker;
 1297|       |  /* Initialize public method pointers */
 1298|  1.15k|  marker->pub.reset_marker_reader = reset_marker_reader;
 1299|  1.15k|  marker->pub.read_markers = read_markers;
 1300|  1.15k|  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|  1.15k|  marker->process_COM = skip_variable;
 1306|  1.15k|  marker->length_limit_COM = 0;
 1307|  19.6k|  for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (1307:15): [True: 18.4k, False: 1.15k]
  ------------------
 1308|  18.4k|    marker->process_APPn[i] = skip_variable;
 1309|  18.4k|    marker->length_limit_APPn[i] = 0;
 1310|  18.4k|  }
 1311|  1.15k|  marker->process_APPn[0] = get_interesting_appn;
 1312|  1.15k|  marker->process_APPn[14] = get_interesting_appn;
 1313|       |  /* Reset marker processing state */
 1314|  1.15k|  reset_marker_reader(cinfo);
 1315|  1.15k|}
jdmarker.c:next_marker:
  892|  38.4k|{
  893|  38.4k|  int c;
  894|  38.4k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  38.4k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  38.4k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  38.4k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  895|       |
  896|  41.7k|  for (;;) {
  897|  41.7k|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  41.7k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  50.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 2.87k]
  |  |  |  |  |  Branch (279:38): [True: 2.87k, False: 38.8k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 41.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  41.7k|            bytes_in_buffer--; \
  |  |  156|  41.7k|            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|  15.5M|    while (c != 0xFF) {
  ------------------
  |  Branch (903:12): [True: 15.5M, False: 41.7k]
  ------------------
  904|  15.5M|      cinfo->marker->discarded_bytes++;
  905|  15.5M|      INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  15.5M|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  15.5M|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  906|  15.5M|      INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  15.5M|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  15.5M|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 4.75k]
  |  |  |  |  |  Branch (279:38): [True: 4.75k, False: 15.5M]
  |  |  |  |  |  Branch (279:53): [Folded, False: 15.5M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  15.5M|            bytes_in_buffer--; \
  |  |  156|  15.5M|            V = *next_input_byte++; )
  ------------------
  907|  15.5M|    }
  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|  53.4k|    do {
  914|  53.4k|      INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  53.4k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  53.5k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 27]
  |  |  |  |  |  Branch (279:38): [True: 27, False: 53.4k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 53.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  53.4k|            bytes_in_buffer--; \
  |  |  156|  53.4k|            V = *next_input_byte++; )
  ------------------
  915|  53.4k|    } while (c == 0xFF);
  ------------------
  |  Branch (915:14): [True: 11.7k, False: 41.7k]
  ------------------
  916|  41.7k|    if (c != 0)
  ------------------
  |  Branch (916:9): [True: 38.4k, False: 3.26k]
  ------------------
  917|  38.4k|      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|  3.26k|    cinfo->marker->discarded_bytes += 2;
  922|  3.26k|    INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  3.26k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  3.26k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  923|  3.26k|  }
  924|       |
  925|  38.4k|  if (cinfo->marker->discarded_bytes != 0) {
  ------------------
  |  Branch (925:7): [True: 35.3k, False: 3.07k]
  ------------------
  926|  35.3k|    WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
  ------------------
  |  |  290|  35.3k|  ((cinfo)->err->msg_code = (code), \
  |  |  291|  35.3k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  292|  35.3k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  293|  35.3k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  927|  35.3k|    cinfo->marker->discarded_bytes = 0;
  928|  35.3k|  }
  929|       |
  930|  38.4k|  cinfo->unread_marker = c;
  931|       |
  932|  38.4k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  38.4k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  38.4k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  933|  38.4k|  return TRUE;
  ------------------
  |  |  210|  38.4k|#define TRUE    1
  ------------------
  934|  38.4k|}
jdmarker.c:reset_marker_reader:
 1268|  3.42k|{
 1269|  3.42k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
 1270|       |
 1271|  3.42k|  cinfo->comp_info = NULL;              /* until allocated by get_sof */
 1272|  3.42k|  cinfo->input_scan_number = 0;         /* no SOS seen yet */
 1273|  3.42k|  cinfo->unread_marker = 0;             /* no pending marker */
 1274|  3.42k|  marker->pub.saw_SOI = FALSE;          /* set internal state too */
  ------------------
  |  |  207|  3.42k|#define FALSE   0               /* values of boolean */
  ------------------
 1275|  3.42k|  marker->pub.saw_SOF = FALSE;
  ------------------
  |  |  207|  3.42k|#define FALSE   0               /* values of boolean */
  ------------------
 1276|  3.42k|  marker->pub.discarded_bytes = 0;
 1277|       |  marker->cur_marker = NULL;
 1278|  3.42k|}
jdmarker.c:read_markers:
  970|  2.27k|{
  971|       |  /* Outer loop repeats once for each marker. */
  972|  40.7k|  for (;;) {
  973|       |    /* Collect the marker proper, unless we already did. */
  974|       |    /* NB: first_marker() enforces the requirement that SOI appear first. */
  975|  40.7k|    if (cinfo->unread_marker == 0) {
  ------------------
  |  Branch (975:9): [True: 40.7k, False: 0]
  ------------------
  976|  40.7k|      if (!cinfo->marker->saw_SOI) {
  ------------------
  |  Branch (976:11): [True: 2.27k, False: 38.4k]
  ------------------
  977|  2.27k|        if (!first_marker(cinfo))
  ------------------
  |  Branch (977:13): [True: 0, False: 2.27k]
  ------------------
  978|      0|          return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  979|  38.4k|      } else {
  980|  38.4k|        if (!next_marker(cinfo))
  ------------------
  |  Branch (980:13): [True: 0, False: 38.4k]
  ------------------
  981|      0|          return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  982|  38.4k|      }
  983|  40.7k|    }
  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|  40.7k|    switch (cinfo->unread_marker) {
  989|  1.80k|    case M_SOI:
  ------------------
  |  Branch (989:5): [True: 1.80k, False: 38.9k]
  ------------------
  990|  1.80k|      if (!get_soi(cinfo))
  ------------------
  |  Branch (990:11): [True: 0, False: 1.80k]
  ------------------
  991|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  992|  1.80k|      break;
  993|       |
  994|  1.80k|    case M_SOF0:                /* Baseline */
  ------------------
  |  Branch (994:5): [True: 979, False: 39.7k]
  ------------------
  995|    979|    case M_SOF1:                /* Extended sequential, Huffman */
  ------------------
  |  Branch (995:5): [True: 0, False: 40.7k]
  ------------------
  996|    979|      if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|    979|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|    979|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, FALSE))
  ------------------
  |  |  207|    979|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (996:11): [True: 0, False: 979]
  ------------------
  997|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
  998|    979|      break;
  999|       |
 1000|    979|    case M_SOF2:                /* Progressive, Huffman */
  ------------------
  |  Branch (1000:5): [True: 3, False: 40.7k]
  ------------------
 1001|      3|      if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  210|      3|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  207|      3|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, FALSE))
  ------------------
  |  |  207|      3|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (1001:11): [True: 0, False: 3]
  ------------------
 1002|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1003|      3|      break;
 1004|       |
 1005|      4|    case M_SOF3:                /* Lossless, Huffman */
  ------------------
  |  Branch (1005:5): [True: 4, False: 40.7k]
  ------------------
 1006|      4|      if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  207|      4|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  210|      4|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, FALSE))
  ------------------
  |  |  207|      4|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (1006:11): [True: 0, False: 4]
  ------------------
 1007|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1008|      4|      break;
 1009|       |
 1010|      4|    case M_SOF9:                /* Extended sequential, arithmetic */
  ------------------
  |  Branch (1010:5): [True: 0, False: 40.7k]
  ------------------
 1011|      0|      if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, FALSE, TRUE))
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  |  Branch (1011:11): [True: 0, False: 0]
  ------------------
 1012|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1013|      0|      break;
 1014|       |
 1015|     68|    case M_SOF10:               /* Progressive, arithmetic */
  ------------------
  |  Branch (1015:5): [True: 68, False: 40.6k]
  ------------------
 1016|     68|      if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  210|     68|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  207|     68|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, TRUE, FALSE, TRUE))
  ------------------
  |  |  210|     68|#define TRUE    1
  ------------------
  |  Branch (1016:11): [True: 0, False: 68]
  ------------------
 1017|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1018|     68|      break;
 1019|       |
 1020|     68|    case M_SOF11:               /* Lossless, arithmetic */
  ------------------
  |  Branch (1020:5): [True: 0, False: 40.7k]
  ------------------
 1021|      0|      if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
                    if (!get_sof(cinfo, FALSE, TRUE, TRUE))
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  |  Branch (1021:11): [True: 0, False: 0]
  ------------------
 1022|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1023|      0|      break;
 1024|       |
 1025|       |    /* Currently unsupported SOFn types */
 1026|      0|    case M_SOF5:                /* Differential sequential, Huffman */
  ------------------
  |  Branch (1026:5): [True: 0, False: 40.7k]
  ------------------
 1027|      0|    case M_SOF6:                /* Differential progressive, Huffman */
  ------------------
  |  Branch (1027:5): [True: 0, False: 40.7k]
  ------------------
 1028|      0|    case M_SOF7:                /* Differential lossless, Huffman */
  ------------------
  |  Branch (1028:5): [True: 0, False: 40.7k]
  ------------------
 1029|      0|    case M_JPG:                 /* Reserved for JPEG extensions */
  ------------------
  |  Branch (1029:5): [True: 0, False: 40.7k]
  ------------------
 1030|      0|    case M_SOF13:               /* Differential sequential, arithmetic */
  ------------------
  |  Branch (1030:5): [True: 0, False: 40.7k]
  ------------------
 1031|      0|    case M_SOF14:               /* Differential progressive, arithmetic */
  ------------------
  |  Branch (1031:5): [True: 0, False: 40.7k]
  ------------------
 1032|      0|    case M_SOF15:               /* Differential lossless, arithmetic */
  ------------------
  |  Branch (1032:5): [True: 0, False: 40.7k]
  ------------------
 1033|      0|      ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, 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)))
  ------------------
 1034|      0|      break;
 1035|       |
 1036|    995|    case M_SOS:
  ------------------
  |  Branch (1036:5): [True: 995, False: 39.7k]
  ------------------
 1037|    995|      if (!get_sos(cinfo))
  ------------------
  |  Branch (1037:11): [True: 0, False: 995]
  ------------------
 1038|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1039|    995|      cinfo->unread_marker = 0; /* processed the marker */
 1040|    995|      return JPEG_REACHED_SOS;
  ------------------
  |  | 1111|    995|#define JPEG_REACHED_SOS        1 /* Reached start of new scan */
  ------------------
 1041|       |
 1042|    202|    case M_EOI:
  ------------------
  |  Branch (1042:5): [True: 202, False: 40.5k]
  ------------------
 1043|    202|      TRACEMS(cinfo, 1, JTRC_EOI);
  ------------------
  |  |  297|    202|  ((cinfo)->err->msg_code = (code), \
  |  |  298|    202|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1044|    202|      cinfo->unread_marker = 0; /* processed the marker */
 1045|    202|      return JPEG_REACHED_EOI;
  ------------------
  |  | 1112|    202|#define JPEG_REACHED_EOI        2 /* Reached end of image */
  ------------------
 1046|       |
 1047|    511|    case M_DAC:
  ------------------
  |  Branch (1047:5): [True: 511, False: 40.2k]
  ------------------
 1048|    511|      if (!get_dac(cinfo))
  ------------------
  |  Branch (1048:11): [True: 0, False: 511]
  ------------------
 1049|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1050|    511|      break;
 1051|       |
 1052|    511|    case M_DHT:
  ------------------
  |  Branch (1052:5): [True: 97, False: 40.6k]
  ------------------
 1053|     97|      if (!get_dht(cinfo))
  ------------------
  |  Branch (1053:11): [True: 0, False: 97]
  ------------------
 1054|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1055|     97|      break;
 1056|       |
 1057|  1.04k|    case M_DQT:
  ------------------
  |  Branch (1057:5): [True: 1.04k, False: 39.6k]
  ------------------
 1058|  1.04k|      if (!get_dqt(cinfo))
  ------------------
  |  Branch (1058:11): [True: 0, False: 1.04k]
  ------------------
 1059|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1060|  1.04k|      break;
 1061|       |
 1062|  1.04k|    case M_DRI:
  ------------------
  |  Branch (1062:5): [True: 610, False: 40.1k]
  ------------------
 1063|    610|      if (!get_dri(cinfo))
  ------------------
  |  Branch (1063:11): [True: 0, False: 610]
  ------------------
 1064|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1065|    610|      break;
 1066|       |
 1067|  9.31k|    case M_APP0:
  ------------------
  |  Branch (1067:5): [True: 9.31k, False: 31.4k]
  ------------------
 1068|  19.6k|    case M_APP1:
  ------------------
  |  Branch (1068:5): [True: 10.3k, False: 30.3k]
  ------------------
 1069|  20.2k|    case M_APP2:
  ------------------
  |  Branch (1069:5): [True: 609, False: 40.1k]
  ------------------
 1070|  20.2k|    case M_APP3:
  ------------------
  |  Branch (1070:5): [True: 3, False: 40.7k]
  ------------------
 1071|  20.7k|    case M_APP4:
  ------------------
  |  Branch (1071:5): [True: 438, False: 40.2k]
  ------------------
 1072|  21.0k|    case M_APP5:
  ------------------
  |  Branch (1072:5): [True: 300, False: 40.4k]
  ------------------
 1073|  24.8k|    case M_APP6:
  ------------------
  |  Branch (1073:5): [True: 3.77k, False: 36.9k]
  ------------------
 1074|  25.1k|    case M_APP7:
  ------------------
  |  Branch (1074:5): [True: 381, False: 40.3k]
  ------------------
 1075|  25.8k|    case M_APP8:
  ------------------
  |  Branch (1075:5): [True: 693, False: 40.0k]
  ------------------
 1076|  29.7k|    case M_APP9:
  ------------------
  |  Branch (1076:5): [True: 3.82k, False: 36.8k]
  ------------------
 1077|  29.8k|    case M_APP10:
  ------------------
  |  Branch (1077:5): [True: 108, False: 40.6k]
  ------------------
 1078|  30.4k|    case M_APP11:
  ------------------
  |  Branch (1078:5): [True: 668, False: 40.0k]
  ------------------
 1079|  30.4k|    case M_APP12:
  ------------------
  |  Branch (1079:5): [True: 9, False: 40.7k]
  ------------------
 1080|  30.5k|    case M_APP13:
  ------------------
  |  Branch (1080:5): [True: 58, False: 40.6k]
  ------------------
 1081|  31.7k|    case M_APP14:
  ------------------
  |  Branch (1081:5): [True: 1.15k, False: 39.5k]
  ------------------
 1082|  31.7k|    case M_APP15:
  ------------------
  |  Branch (1082:5): [True: 35, False: 40.6k]
  ------------------
 1083|  31.7k|      if (!(*((my_marker_ptr)cinfo->marker)->process_APPn[
  ------------------
  |  Branch (1083:11): [True: 0, False: 31.7k]
  ------------------
 1084|  31.7k|               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|  31.7k|      break;
 1087|       |
 1088|  31.7k|    case M_COM:
  ------------------
  |  Branch (1088:5): [True: 375, False: 40.3k]
  ------------------
 1089|    375|      if (!(*((my_marker_ptr)cinfo->marker)->process_COM) (cinfo))
  ------------------
  |  Branch (1089:11): [True: 0, False: 375]
  ------------------
 1090|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1091|    375|      break;
 1092|       |
 1093|    570|    case M_RST0:                /* these are all parameterless */
  ------------------
  |  Branch (1093:5): [True: 570, False: 40.1k]
  ------------------
 1094|    819|    case M_RST1:
  ------------------
  |  Branch (1094:5): [True: 249, False: 40.4k]
  ------------------
 1095|    821|    case M_RST2:
  ------------------
  |  Branch (1095:5): [True: 2, False: 40.7k]
  ------------------
 1096|    959|    case M_RST3:
  ------------------
  |  Branch (1096:5): [True: 138, False: 40.5k]
  ------------------
 1097|    976|    case M_RST4:
  ------------------
  |  Branch (1097:5): [True: 17, False: 40.7k]
  ------------------
 1098|  1.00k|    case M_RST5:
  ------------------
  |  Branch (1098:5): [True: 31, False: 40.6k]
  ------------------
 1099|  1.00k|    case M_RST6:
  ------------------
  |  Branch (1099:5): [True: 1, False: 40.7k]
  ------------------
 1100|  1.14k|    case M_RST7:
  ------------------
  |  Branch (1100:5): [True: 138, False: 40.5k]
  ------------------
 1101|  1.56k|    case M_TEM:
  ------------------
  |  Branch (1101:5): [True: 415, False: 40.3k]
  ------------------
 1102|  1.56k|      TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
  ------------------
  |  |  300|  1.56k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  1.56k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  1.56k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1103|  1.56k|      break;
 1104|       |
 1105|     18|    case M_DNL:                 /* Ignore DNL ... perhaps the wrong thing */
  ------------------
  |  Branch (1105:5): [True: 18, False: 40.7k]
  ------------------
 1106|     18|      if (!skip_variable(cinfo))
  ------------------
  |  Branch (1106:11): [True: 0, False: 18]
  ------------------
 1107|      0|        return JPEG_SUSPENDED;
  ------------------
  |  | 1065|      0|#define JPEG_SUSPENDED           0 /* Suspended due to lack of input data */
  ------------------
 1108|     18|      break;
 1109|       |
 1110|    219|    default:                    /* must be DHP, EXP, JPGn, or RESn */
  ------------------
  |  Branch (1110:5): [True: 219, False: 40.5k]
  ------------------
 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|    219|      ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
  ------------------
  |  |  243|    219|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    219|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    219|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1117|    219|      break;
 1118|  40.7k|    }
 1119|       |    /* Successfully processed marker, so reset state variable */
 1120|  38.4k|    cinfo->unread_marker = 0;
 1121|  38.4k|  } /* end loop */
 1122|  2.27k|}
jdmarker.c:first_marker:
  945|  2.27k|{
  946|  2.27k|  int c, c2;
  947|  2.27k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  2.27k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  2.27k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  2.27k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  948|       |
  949|  2.27k|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  2.27k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  5.02k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 919]
  |  |  |  |  |  Branch (279:38): [True: 919, False: 1.35k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 2.27k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  2.27k|            bytes_in_buffer--; \
  |  |  156|  2.27k|            V = *next_input_byte++; )
  ------------------
  950|  2.27k|  INPUT_BYTE(cinfo, c2, return FALSE);
  ------------------
  |  |  154|  2.27k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  2.42k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 53]
  |  |  |  |  |  Branch (279:38): [True: 53, False: 2.21k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 2.27k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  2.27k|            bytes_in_buffer--; \
  |  |  156|  2.27k|            V = *next_input_byte++; )
  ------------------
  951|  2.27k|  if (c != 0xFF || c2 != (int)M_SOI)
  ------------------
  |  Branch (951:7): [True: 445, False: 1.82k]
  |  Branch (951:20): [True: 42, False: 1.78k]
  ------------------
  952|    487|    ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
  ------------------
  |  |  247|    487|  ((cinfo)->err->msg_code = (code), \
  |  |  248|    487|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|    487|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|    487|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  953|       |
  954|  2.27k|  cinfo->unread_marker = c2;
  955|       |
  956|  2.27k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  2.27k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  2.27k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  957|  2.27k|  return TRUE;
  ------------------
  |  |  210|  2.27k|#define TRUE    1
  ------------------
  958|  2.27k|}
jdmarker.c:get_soi:
  204|  1.80k|{
  205|  1.80k|  int i;
  206|       |
  207|  1.80k|  TRACEMS(cinfo, 1, JTRC_SOI);
  ------------------
  |  |  297|  1.80k|  ((cinfo)->err->msg_code = (code), \
  |  |  298|  1.80k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  208|       |
  209|  1.80k|  if (cinfo->marker->saw_SOI)
  ------------------
  |  Branch (209:7): [True: 21, False: 1.78k]
  ------------------
  210|     21|    ERREXIT(cinfo, JERR_SOI_DUPLICATE);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  211|       |
  212|       |  /* Reset all parameters that are defined to be reset by SOI */
  213|       |
  214|  30.3k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|  30.3k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (214:15): [True: 28.5k, False: 1.80k]
  ------------------
  215|  28.5k|    cinfo->arith_dc_L[i] = 0;
  216|  28.5k|    cinfo->arith_dc_U[i] = 1;
  217|  28.5k|    cinfo->arith_ac_K[i] = 5;
  218|  28.5k|  }
  219|  1.80k|  cinfo->restart_interval = 0;
  220|       |
  221|       |  /* Set initial assumptions for colorspace etc */
  222|       |
  223|  1.80k|  cinfo->jpeg_color_space = JCS_UNKNOWN;
  224|  1.80k|  cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
  ------------------
  |  |  207|  1.80k|#define FALSE   0               /* values of boolean */
  ------------------
  225|       |
  226|  1.80k|  cinfo->saw_JFIF_marker = FALSE;
  ------------------
  |  |  207|  1.80k|#define FALSE   0               /* values of boolean */
  ------------------
  227|  1.80k|  cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */
  228|  1.80k|  cinfo->JFIF_minor_version = 1;
  229|  1.80k|  cinfo->density_unit = 0;
  230|  1.80k|  cinfo->X_density = 1;
  231|  1.80k|  cinfo->Y_density = 1;
  232|  1.80k|  cinfo->saw_Adobe_marker = FALSE;
  ------------------
  |  |  207|  1.80k|#define FALSE   0               /* values of boolean */
  ------------------
  233|  1.80k|  cinfo->Adobe_transform = 0;
  234|       |
  235|  1.80k|  cinfo->marker->saw_SOI = TRUE;
  ------------------
  |  |  210|  1.80k|#define TRUE    1
  ------------------
  236|       |
  237|  1.80k|  return TRUE;
  ------------------
  |  |  210|  1.80k|#define TRUE    1
  ------------------
  238|  1.80k|}
jdmarker.c:get_sof:
  245|  1.05k|{
  246|  1.05k|  JLONG length;
  247|  1.05k|  int c, ci;
  248|  1.05k|  jpeg_component_info *compptr;
  249|  1.05k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  1.05k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  1.05k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  1.05k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  250|       |
  251|  1.05k|  if (cinfo->marker->saw_SOF)
  ------------------
  |  Branch (251:7): [True: 3, False: 1.05k]
  ------------------
  252|      3|    ERREXIT(cinfo, JERR_SOF_DUPLICATE);
  ------------------
  |  |  240|      3|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      3|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  253|       |
  254|  1.05k|  cinfo->progressive_mode = is_prog;
  255|  1.05k|  cinfo->master->lossless = is_lossless;
  256|  1.05k|  cinfo->arith_code = is_arith;
  257|       |
  258|  1.05k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  1.05k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  2.10k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  1.05k|            bytes_in_buffer--; \
  |  |  164|  1.05k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  1.05k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  1.05k|            bytes_in_buffer--; \
  |  |  167|  1.05k|            V += *next_input_byte++; )
  ------------------
  259|       |
  260|  1.05k|  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
  ------------------
  |  |  154|  1.05k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.05k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.05k|            bytes_in_buffer--; \
  |  |  156|  1.05k|            V = *next_input_byte++; )
  ------------------
  261|  1.05k|  cinfo->master->jpeg_data_precision = cinfo->data_precision;
  262|  1.05k|  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
  ------------------
  |  |  162|  1.05k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  2.10k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  1.05k|            bytes_in_buffer--; \
  |  |  164|  1.05k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  1.05k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  1.05k|            bytes_in_buffer--; \
  |  |  167|  1.05k|            V += *next_input_byte++; )
  ------------------
  263|  1.05k|  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
  ------------------
  |  |  162|  1.05k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  2.10k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  1.05k|            bytes_in_buffer--; \
  |  |  164|  1.05k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  1.05k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  1.05k|            bytes_in_buffer--; \
  |  |  167|  1.05k|            V += *next_input_byte++; )
  ------------------
  264|  1.05k|  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);
  ------------------
  |  |  154|  1.05k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.05k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.05k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.05k|            bytes_in_buffer--; \
  |  |  156|  1.05k|            V = *next_input_byte++; )
  ------------------
  265|       |
  266|  1.05k|  length -= 8;
  267|       |
  268|  1.05k|  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
  ------------------
  |  |  314|  1.05k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.05k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|  1.05k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|  1.05k|           (cinfo)->err->msg_code = (code); \
  |  |  317|  1.05k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  269|  1.05k|           (int)cinfo->image_width, (int)cinfo->image_height,
  270|  1.05k|           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|  1.05k|  if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
  ------------------
  |  Branch (275:7): [True: 3, False: 1.05k]
  |  Branch (275:35): [True: 0, False: 1.05k]
  ------------------
  276|  1.05k|      cinfo->num_components <= 0)
  ------------------
  |  Branch (276:7): [True: 0, False: 1.05k]
  ------------------
  277|      0|    ERREXIT(cinfo, JERR_EMPTY_IMAGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  278|       |
  279|  1.05k|  if (length != (cinfo->num_components * 3))
  ------------------
  |  Branch (279:7): [True: 4, False: 1.05k]
  ------------------
  280|      4|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  281|       |
  282|  1.05k|  if (cinfo->comp_info == NULL) /* do only once, even if suspend */
  ------------------
  |  Branch (282:7): [True: 1.04k, False: 7]
  ------------------
  283|  1.04k|    cinfo->comp_info = (jpeg_component_info *)(*cinfo->mem->alloc_small)
  284|  1.04k|                        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  1.04k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  285|  1.04k|                         cinfo->num_components * sizeof(jpeg_component_info));
  286|       |
  287|  2.35k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (287:44): [True: 1.30k, False: 1.05k]
  ------------------
  288|  1.30k|       ci++, compptr++) {
  289|  1.30k|    compptr->component_index = ci;
  290|  1.30k|    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
  ------------------
  |  |  154|  1.30k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.30k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.30k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.30k|            bytes_in_buffer--; \
  |  |  156|  1.30k|            V = *next_input_byte++; )
  ------------------
  291|  1.30k|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|  1.30k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.30k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.30k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.30k|            bytes_in_buffer--; \
  |  |  156|  1.30k|            V = *next_input_byte++; )
  ------------------
  292|  1.30k|    compptr->h_samp_factor = (c >> 4) & 15;
  293|  1.30k|    compptr->v_samp_factor = (c     ) & 15;
  294|  1.30k|    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);
  ------------------
  |  |  154|  1.30k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.30k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.30k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.30k|            bytes_in_buffer--; \
  |  |  156|  1.30k|            V = *next_input_byte++; )
  ------------------
  295|       |
  296|  1.30k|    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
  ------------------
  |  |  314|  1.30k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.30k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|  1.30k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|  1.30k|           (cinfo)->err->msg_code = (code); \
  |  |  317|  1.30k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  297|  1.30k|             compptr->component_id, compptr->h_samp_factor,
  298|  1.30k|             compptr->v_samp_factor, compptr->quant_tbl_no);
  299|  1.30k|  }
  300|       |
  301|  1.05k|  cinfo->marker->saw_SOF = TRUE;
  ------------------
  |  |  210|  1.05k|#define TRUE    1
  ------------------
  302|       |
  303|  1.05k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  1.05k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  1.05k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  304|  1.05k|  return TRUE;
  ------------------
  |  |  210|  1.05k|#define TRUE    1
  ------------------
  305|  1.05k|}
jdmarker.c:get_sos:
  311|    995|{
  312|    995|  JLONG length;
  313|    995|  int i, ci, n, c, cc, pi;
  314|    995|  jpeg_component_info *compptr;
  315|    995|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|    995|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|    995|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|    995|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  316|       |
  317|    995|  if (!cinfo->marker->saw_SOF)
  ------------------
  |  Branch (317:7): [True: 6, False: 989]
  ------------------
  318|      6|    ERREXIT(cinfo, JERR_SOS_NO_SOF);
  ------------------
  |  |  240|      6|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      6|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  319|       |
  320|    995|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|    995|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.99k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 995]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 995]
  |  |  |  |  |  Branch (279:53): [Folded, False: 995]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    995|            bytes_in_buffer--; \
  |  |  164|    995|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    995|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    995|            bytes_in_buffer--; \
  |  |  167|    995|            V += *next_input_byte++; )
  ------------------
  321|       |
  322|    995|  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */
  ------------------
  |  |  154|    995|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    995|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 995]
  |  |  |  |  |  Branch (279:53): [Folded, False: 995]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    995|            bytes_in_buffer--; \
  |  |  156|    995|            V = *next_input_byte++; )
  ------------------
  323|       |
  324|    995|  TRACEMS1(cinfo, 1, JTRC_SOS, n);
  ------------------
  |  |  300|    995|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    995|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    995|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  325|       |
  326|    995|  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|    989|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (326:7): [True: 6, False: 989]
  |  Branch (326:32): [True: 0, False: 989]
  |  Branch (326:41): [True: 0, False: 989]
  ------------------
  327|      0|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  328|       |
  329|    995|  cinfo->comps_in_scan = n;
  330|       |
  331|       |  /* Collect the component-spec parameters */
  332|       |
  333|  4.95k|  for (i = 0; i < MAX_COMPS_IN_SCAN; i++)
  ------------------
  |  |   71|  4.95k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:15): [True: 3.95k, False: 995]
  ------------------
  334|  3.95k|    cinfo->cur_comp_info[i] = NULL;
  335|       |
  336|  1.95k|  for (i = 0; i < n; i++) {
  ------------------
  |  Branch (336:15): [True: 989, False: 967]
  ------------------
  337|    989|    INPUT_BYTE(cinfo, cc, return FALSE);
  ------------------
  |  |  154|    989|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    989|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 989]
  |  |  |  |  |  Branch (279:53): [Folded, False: 989]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    989|            bytes_in_buffer--; \
  |  |  156|    989|            V = *next_input_byte++; )
  ------------------
  338|    989|    INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|    989|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    989|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 989]
  |  |  |  |  |  Branch (279:53): [Folded, False: 989]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    989|            bytes_in_buffer--; \
  |  |  156|    989|            V = *next_input_byte++; )
  ------------------
  339|       |
  340|    989|    for (ci = 0, compptr = cinfo->comp_info;
  341|  1.04k|         ci < cinfo->num_components && ci < MAX_COMPS_IN_SCAN;
  ------------------
  |  |   71|  1.02k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (341:10): [True: 1.02k, False: 28]
  |  Branch (341:40): [True: 1.02k, False: 0]
  ------------------
  342|  1.02k|         ci++, compptr++) {
  343|  1.02k|      if (cc == compptr->component_id && !cinfo->cur_comp_info[ci])
  ------------------
  |  Branch (343:11): [True: 961, False: 60]
  |  Branch (343:42): [True: 961, False: 0]
  ------------------
  344|    961|        goto id_found;
  345|  1.02k|    }
  346|       |
  347|     28|    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
  ------------------
  |  |  243|     28|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     28|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     28|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  348|       |
  349|    961|id_found:
  350|       |
  351|    961|    cinfo->cur_comp_info[i] = compptr;
  352|    961|    compptr->dc_tbl_no = (c >> 4) & 15;
  353|    961|    compptr->ac_tbl_no = (c     ) & 15;
  354|       |
  355|    961|    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
  ------------------
  |  |  309|    961|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    961|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 961]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    961|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    961|           (cinfo)->err->msg_code = (code); \
  |  |  312|    961|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  356|    961|             compptr->dc_tbl_no, compptr->ac_tbl_no);
  357|       |
  358|       |    /* This CSi (cc) should differ from the previous CSi */
  359|    961|    for (pi = 0; pi < i; pi++) {
  ------------------
  |  Branch (359:18): [True: 0, False: 961]
  ------------------
  360|      0|      if (cinfo->cur_comp_info[pi] == compptr) {
  ------------------
  |  Branch (360:11): [True: 0, False: 0]
  ------------------
  361|      0|        ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
  ------------------
  |  |  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)))
  ------------------
  362|      0|      }
  363|      0|    }
  364|    961|  }
  365|       |
  366|       |  /* Collect the additional scan parameters Ss, Se, Ah/Al. */
  367|    967|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|    967|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    967|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 967]
  |  |  |  |  |  Branch (279:53): [Folded, False: 967]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    967|            bytes_in_buffer--; \
  |  |  156|    967|            V = *next_input_byte++; )
  ------------------
  368|    967|  cinfo->Ss = c;
  369|    967|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|    967|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    967|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 967]
  |  |  |  |  |  Branch (279:53): [Folded, False: 967]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    967|            bytes_in_buffer--; \
  |  |  156|    967|            V = *next_input_byte++; )
  ------------------
  370|    967|  cinfo->Se = c;
  371|    967|  INPUT_BYTE(cinfo, c, return FALSE);
  ------------------
  |  |  154|    967|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    967|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 967]
  |  |  |  |  |  Branch (279:53): [Folded, False: 967]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    967|            bytes_in_buffer--; \
  |  |  156|    967|            V = *next_input_byte++; )
  ------------------
  372|    967|  cinfo->Ah = (c >> 4) & 15;
  373|    967|  cinfo->Al = (c     ) & 15;
  374|       |
  375|    967|  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
  ------------------
  |  |  314|    967|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    967|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 967]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|    967|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|    967|           (cinfo)->err->msg_code = (code); \
  |  |  317|    967|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  376|    967|           cinfo->Ah, cinfo->Al);
  377|       |
  378|       |  /* Prepare to scan data & restart markers */
  379|    967|  cinfo->marker->next_restart_num = 0;
  380|       |
  381|       |  /* Count another SOS marker */
  382|    967|  cinfo->input_scan_number++;
  383|       |
  384|    967|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|    967|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|    967|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  385|    967|  return TRUE;
  ------------------
  |  |  210|    967|#define TRUE    1
  ------------------
  386|    967|}
jdmarker.c:get_dac:
  394|    511|{
  395|    511|  JLONG length;
  396|    511|  int index, val;
  397|    511|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|    511|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|    511|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|    511|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  398|       |
  399|    511|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|    511|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.88k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 285]
  |  |  |  |  |  Branch (279:38): [True: 285, False: 226]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 3]
  |  |  |  |  |  Branch (279:38): [True: 3, False: 508]
  |  |  |  |  |  Branch (279:53): [Folded, False: 511]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    511|            bytes_in_buffer--; \
  |  |  164|    511|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    511|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    511|            bytes_in_buffer--; \
  |  |  167|    511|            V += *next_input_byte++; )
  ------------------
  400|    511|  length -= 2;
  401|       |
  402|    801|  while (length > 0) {
  ------------------
  |  Branch (402:10): [True: 290, False: 511]
  ------------------
  403|    290|    INPUT_BYTE(cinfo, index, return FALSE);
  ------------------
  |  |  154|    290|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.14k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 285]
  |  |  |  |  |  Branch (279:38): [True: 285, False: 5]
  |  |  |  |  |  Branch (279:53): [Folded, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    290|            bytes_in_buffer--; \
  |  |  156|    290|            V = *next_input_byte++; )
  ------------------
  404|    290|    INPUT_BYTE(cinfo, val, return FALSE);
  ------------------
  |  |  154|    290|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    299|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 3]
  |  |  |  |  |  Branch (279:38): [True: 3, False: 287]
  |  |  |  |  |  Branch (279:53): [Folded, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|    290|            bytes_in_buffer--; \
  |  |  156|    290|            V = *next_input_byte++; )
  ------------------
  405|       |
  406|    290|    length -= 2;
  407|       |
  408|    290|    TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
  ------------------
  |  |  304|    290|  ((cinfo)->err->msg_code = (code), \
  |  |  305|    290|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|    290|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|    290|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  409|       |
  410|    290|    if (index < 0 || index >= (2 * NUM_ARITH_TBLS))
  ------------------
  |  |   70|    290|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (410:9): [True: 0, False: 290]
  |  Branch (410:22): [True: 289, False: 1]
  ------------------
  411|    289|      ERREXIT1(cinfo, JERR_DAC_INDEX, index);
  ------------------
  |  |  243|    289|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    289|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    289|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|       |
  413|    290|    if (index >= NUM_ARITH_TBLS) { /* define AC table */
  ------------------
  |  |   70|    290|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (413:9): [True: 0, False: 290]
  ------------------
  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|    290|    } else {                    /* define DC table */
  416|    290|      cinfo->arith_dc_L[index] = (UINT8)(val & 0x0F);
  417|    290|      cinfo->arith_dc_U[index] = (UINT8)(val >> 4);
  418|    290|      if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
  ------------------
  |  Branch (418:11): [True: 1, False: 289]
  ------------------
  419|      1|        ERREXIT1(cinfo, JERR_DAC_VALUE, val);
  ------------------
  |  |  243|      1|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      1|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      1|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  420|    290|    }
  421|    290|  }
  422|       |
  423|    511|  if (length != 0)
  ------------------
  |  Branch (423:7): [True: 0, False: 511]
  ------------------
  424|      0|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  425|       |
  426|    511|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|    511|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|    511|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  427|    511|  return TRUE;
  ------------------
  |  |  210|    511|#define TRUE    1
  ------------------
  428|    511|}
jdmarker.c:get_dht:
  440|     97|{
  441|     97|  JLONG length;
  442|     97|  UINT8 bits[17];
  443|     97|  UINT8 huffval[256];
  444|     97|  int i, index, count;
  445|     97|  JHUFF_TBL **htblptr;
  446|     97|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|     97|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|     97|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|     97|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  447|       |
  448|     97|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|     97|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|    194|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 97]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 97]
  |  |  |  |  |  Branch (279:53): [Folded, False: 97]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|     97|            bytes_in_buffer--; \
  |  |  164|     97|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|     97|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|     97|            bytes_in_buffer--; \
  |  |  167|     97|            V += *next_input_byte++; )
  ------------------
  449|     97|  length -= 2;
  450|       |
  451|  6.43k|  while (length > 16) {
  ------------------
  |  Branch (451:10): [True: 6.34k, False: 97]
  ------------------
  452|  6.34k|    INPUT_BYTE(cinfo, index, return FALSE);
  ------------------
  |  |  154|  6.34k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  6.34k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 6.34k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 6.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  6.34k|            bytes_in_buffer--; \
  |  |  156|  6.34k|            V = *next_input_byte++; )
  ------------------
  453|       |
  454|  6.34k|    TRACEMS1(cinfo, 1, JTRC_DHT, index);
  ------------------
  |  |  300|  6.34k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  6.34k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  6.34k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  455|       |
  456|  6.34k|    bits[0] = 0;
  457|  6.34k|    count = 0;
  458|   107k|    for (i = 1; i <= 16; i++) {
  ------------------
  |  Branch (458:17): [True: 101k, False: 6.34k]
  ------------------
  459|   101k|      INPUT_BYTE(cinfo, bits[i], return FALSE);
  ------------------
  |  |  154|   101k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   101k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 101k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 101k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|   101k|            bytes_in_buffer--; \
  |  |  156|   101k|            V = *next_input_byte++; )
  ------------------
  460|   101k|      count += bits[i];
  461|   101k|    }
  462|       |
  463|  6.34k|    length -= 1 + 16;
  464|       |
  465|  6.34k|    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
  ------------------
  |  |  325|  6.34k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  6.34k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 6.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  326|  6.34k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  327|  6.34k|           _mp[4] = (p5);  _mp[5] = (p6);  _mp[6] = (p7);  _mp[7] = (p8); \
  |  |  328|  6.34k|           (cinfo)->err->msg_code = (code); \
  |  |  329|  6.34k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  466|  6.34k|             bits[1], bits[2], bits[3], bits[4],
  467|  6.34k|             bits[5], bits[6], bits[7], bits[8]);
  468|  6.34k|    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
  ------------------
  |  |  325|  6.34k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  6.34k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 6.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  326|  6.34k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  327|  6.34k|           _mp[4] = (p5);  _mp[5] = (p6);  _mp[6] = (p7);  _mp[7] = (p8); \
  |  |  328|  6.34k|           (cinfo)->err->msg_code = (code); \
  |  |  329|  6.34k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  469|  6.34k|             bits[9], bits[10], bits[11], bits[12],
  470|  6.34k|             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|  6.34k|    if (count > 256 || ((JLONG)count) > length)
  ------------------
  |  Branch (475:9): [True: 15, False: 6.32k]
  |  Branch (475:24): [True: 0, False: 6.32k]
  ------------------
  476|     15|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|     15|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     15|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  477|       |
  478|  13.6k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (478:17): [True: 7.31k, False: 6.34k]
  ------------------
  479|  7.31k|      INPUT_BYTE(cinfo, huffval[i], return FALSE);
  ------------------
  |  |  154|  7.31k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  13.6k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 7.31k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 7.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  6.34k|            bytes_in_buffer--; \
  |  |  156|  6.34k|            V = *next_input_byte++; )
  ------------------
  480|       |
  481|  6.34k|    memset(&huffval[count], 0, (256 - count) * sizeof(UINT8));
  482|       |
  483|  6.34k|    length -= count;
  484|       |
  485|  6.34k|    if (index & 0x10) {         /* AC table definition */
  ------------------
  |  Branch (485:9): [True: 39, False: 6.30k]
  ------------------
  486|     39|      index -= 0x10;
  487|     39|      if (index < 0 || index >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|     39|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (487:11): [True: 0, False: 39]
  |  Branch (487:24): [True: 1, False: 38]
  ------------------
  488|      1|        ERREXIT1(cinfo, JERR_DHT_INDEX, index);
  ------------------
  |  |  243|      1|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      1|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      1|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  489|     39|      htblptr = &cinfo->ac_huff_tbl_ptrs[index];
  490|  6.30k|    } else {                    /* DC table definition */
  491|  6.30k|      if (index < 0 || index >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  6.28k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (491:11): [True: 15, False: 6.28k]
  |  Branch (491:24): [True: 1, False: 6.28k]
  ------------------
  492|      1|        ERREXIT1(cinfo, JERR_DHT_INDEX, index);
  ------------------
  |  |  243|      1|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      1|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      1|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  493|  6.30k|      htblptr = &cinfo->dc_huff_tbl_ptrs[index];
  494|  6.30k|    }
  495|       |
  496|  6.34k|    if (*htblptr == NULL)
  ------------------
  |  Branch (496:9): [True: 85, False: 6.25k]
  ------------------
  497|     85|      *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
  498|       |
  499|  6.34k|    memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
  500|  6.34k|    memcpy((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
  501|  6.34k|  }
  502|       |
  503|     97|  if (length != 0)
  ------------------
  |  Branch (503:7): [True: 4, False: 93]
  ------------------
  504|      4|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      4|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      4|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  505|       |
  506|     97|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|     97|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|     97|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  507|     97|  return TRUE;
  ------------------
  |  |  210|     97|#define TRUE    1
  ------------------
  508|     97|}
jdmarker.c:get_dqt:
  514|  1.04k|{
  515|  1.04k|  JLONG length;
  516|  1.04k|  int n, i, prec;
  517|  1.04k|  unsigned int tmp;
  518|  1.04k|  JQUANT_TBL *quant_ptr;
  519|  1.04k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  1.04k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  1.04k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  1.04k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  520|       |
  521|  1.04k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  1.04k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  2.08k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.04k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.04k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  1.04k|            bytes_in_buffer--; \
  |  |  164|  1.04k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  1.04k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  1.04k|            bytes_in_buffer--; \
  |  |  167|  1.04k|            V += *next_input_byte++; )
  ------------------
  522|  1.04k|  length -= 2;
  523|       |
  524|  2.08k|  while (length > 0) {
  ------------------
  |  Branch (524:10): [True: 1.04k, False: 1.04k]
  ------------------
  525|  1.04k|    INPUT_BYTE(cinfo, n, return FALSE);
  ------------------
  |  |  154|  1.04k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.04k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.04k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  1.04k|            bytes_in_buffer--; \
  |  |  156|  1.04k|            V = *next_input_byte++; )
  ------------------
  526|  1.04k|    prec = n >> 4;
  527|  1.04k|    n &= 0x0F;
  528|       |
  529|  1.04k|    TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
  ------------------
  |  |  304|  1.04k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  1.04k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  1.04k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  1.04k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  530|       |
  531|  1.04k|    if (n >= NUM_QUANT_TBLS)
  ------------------
  |  |   68|  1.04k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (531:9): [True: 12, False: 1.03k]
  ------------------
  532|     12|      ERREXIT1(cinfo, JERR_DQT_INDEX, n);
  ------------------
  |  |  243|     12|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     12|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     12|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  533|       |
  534|  1.04k|    if (cinfo->quant_tbl_ptrs[n] == NULL)
  ------------------
  |  Branch (534:9): [True: 951, False: 93]
  ------------------
  535|    951|      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
  536|  1.04k|    quant_ptr = cinfo->quant_tbl_ptrs[n];
  537|       |
  538|  67.0k|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  67.0k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (538:17): [True: 66.0k, False: 1.04k]
  ------------------
  539|  66.0k|      if (prec)
  ------------------
  |  Branch (539:11): [True: 1.66k, False: 64.3k]
  ------------------
  540|  66.0k|        INPUT_2BYTES(cinfo, tmp, return FALSE);
  ------------------
  |  |  162|  1.66k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  3.32k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.66k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 1.66k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  66.0k|            bytes_in_buffer--; \
  |  |  164|  66.0k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  66.0k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  66.0k|            bytes_in_buffer--; \
  |  |  167|  66.0k|            V += *next_input_byte++; )
  ------------------
  541|  64.3k|      else
  542|  66.0k|        INPUT_BYTE(cinfo, tmp, return FALSE);
  ------------------
  |  |  154|  64.3k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  64.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 64.3k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 64.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  66.0k|            bytes_in_buffer--; \
  |  |  156|  66.0k|            V = *next_input_byte++; )
  ------------------
  543|       |      /* We convert the zigzag-order table to natural array order. */
  544|  66.0k|      quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16)tmp;
  545|  66.0k|    }
  546|       |
  547|  1.04k|    if (cinfo->err->trace_level >= 2) {
  ------------------
  |  Branch (547:9): [True: 0, False: 1.04k]
  ------------------
  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|  1.04k|    length -= DCTSIZE2 + 1;
  ------------------
  |  |   67|  1.04k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  558|  1.04k|    if (prec) length -= DCTSIZE2;
  ------------------
  |  |   67|     26|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (558:9): [True: 26, False: 1.01k]
  ------------------
  559|  1.04k|  }
  560|       |
  561|  1.04k|  if (length != 0)
  ------------------
  |  Branch (561:7): [True: 6, False: 1.03k]
  ------------------
  562|      6|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      6|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      6|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|       |
  564|  1.04k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  1.04k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  1.04k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  565|  1.04k|  return TRUE;
  ------------------
  |  |  210|  1.04k|#define TRUE    1
  ------------------
  566|  1.04k|}
jdmarker.c:get_dri:
  572|    610|{
  573|    610|  JLONG length;
  574|    610|  unsigned int tmp;
  575|    610|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|    610|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|    610|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|    610|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  576|       |
  577|    610|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|    610|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.22k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 610]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 610]
  |  |  |  |  |  Branch (279:53): [Folded, False: 610]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    610|            bytes_in_buffer--; \
  |  |  164|    610|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    610|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    610|            bytes_in_buffer--; \
  |  |  167|    610|            V += *next_input_byte++; )
  ------------------
  578|       |
  579|    610|  if (length != 4)
  ------------------
  |  Branch (579:7): [True: 10, False: 600]
  ------------------
  580|     10|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|     10|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     10|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  581|       |
  582|    610|  INPUT_2BYTES(cinfo, tmp, return FALSE);
  ------------------
  |  |  162|    610|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  1.22k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 610]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 610]
  |  |  |  |  |  Branch (279:53): [Folded, False: 610]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|    610|            bytes_in_buffer--; \
  |  |  164|    610|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|    610|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|    610|            bytes_in_buffer--; \
  |  |  167|    610|            V += *next_input_byte++; )
  ------------------
  583|       |
  584|    610|  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
  ------------------
  |  |  300|    610|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    610|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    610|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  585|       |
  586|    610|  cinfo->restart_interval = tmp;
  587|       |
  588|    610|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|    610|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|    610|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  589|    610|  return TRUE;
  ------------------
  |  |  210|    610|#define TRUE    1
  ------------------
  590|    610|}
jdmarker.c:read_restart_marker:
 1139|    329|{
 1140|       |  /* Obtain a marker unless we already did. */
 1141|       |  /* Note that next_marker will complain if it skips any data. */
 1142|    329|  if (cinfo->unread_marker == 0) {
  ------------------
  |  Branch (1142:7): [True: 20, False: 309]
  ------------------
 1143|     20|    if (!next_marker(cinfo))
  ------------------
  |  Branch (1143:9): [True: 0, False: 20]
  ------------------
 1144|      0|      return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1145|     20|  }
 1146|       |
 1147|    329|  if (cinfo->unread_marker ==
  ------------------
  |  Branch (1147:7): [True: 64, False: 265]
  ------------------
 1148|    329|      ((int)M_RST0 + cinfo->marker->next_restart_num)) {
 1149|       |    /* Normal case --- swallow the marker and let entropy decoder continue */
 1150|     64|    TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
  ------------------
  |  |  300|     64|  ((cinfo)->err->msg_code = (code), \
  |  |  301|     64|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|     64|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
 1151|     64|    cinfo->unread_marker = 0;
 1152|    265|  } else {
 1153|       |    /* Uh-oh, the restart markers have been messed up. */
 1154|       |    /* Let the data source manager determine how to resync. */
 1155|    265|    if (!(*cinfo->src->resync_to_restart) (cinfo,
  ------------------
  |  Branch (1155:9): [True: 0, False: 265]
  ------------------
 1156|    265|                                           cinfo->marker->next_restart_num))
 1157|      0|      return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1158|    265|  }
 1159|       |
 1160|       |  /* Update next-restart state */
 1161|    329|  cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
 1162|       |
 1163|    329|  return TRUE;
  ------------------
  |  |  210|    329|#define TRUE    1
  ------------------
 1164|    329|}
jdmarker.c:skip_variable:
  864|  21.6k|{
  865|  21.6k|  JLONG length;
  866|  21.6k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  21.6k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  21.6k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  21.6k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  867|       |
  868|  21.6k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  21.6k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  43.3k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 21.6k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 21.6k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 21.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  21.6k|            bytes_in_buffer--; \
  |  |  164|  21.6k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  21.6k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  21.6k|            bytes_in_buffer--; \
  |  |  167|  21.6k|            V += *next_input_byte++; )
  ------------------
  869|  21.6k|  length -= 2;
  870|       |
  871|  21.6k|  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int)length);
  ------------------
  |  |  304|  21.6k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  21.6k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  21.6k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  21.6k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  872|       |
  873|  21.6k|  INPUT_SYNC(cinfo);            /* do before skip_input_data */
  ------------------
  |  |  131|  21.6k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  21.6k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  874|  21.6k|  if (length > 0)
  ------------------
  |  Branch (874:7): [True: 6.16k, False: 15.4k]
  ------------------
  875|  6.16k|    (*cinfo->src->skip_input_data) (cinfo, (long)length);
  876|       |
  877|  21.6k|  return TRUE;
  ------------------
  |  |  210|  21.6k|#define TRUE    1
  ------------------
  878|  21.6k|}
jdmarker.c:get_interesting_appn:
  712|  10.4k|{
  713|  10.4k|  JLONG length;
  714|  10.4k|  JOCTET b[APPN_DATA_LEN];
  715|  10.4k|  unsigned int i, numtoread;
  716|  10.4k|  INPUT_VARS(cinfo);
  ------------------
  |  |  125|  10.4k|  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
  |  |  126|  10.4k|  const JOCTET *next_input_byte = datasrc->next_input_byte; \
  |  |  127|  10.4k|  size_t bytes_in_buffer = datasrc->bytes_in_buffer
  ------------------
  717|       |
  718|  10.4k|  INPUT_2BYTES(cinfo, length, return FALSE);
  ------------------
  |  |  162|  10.4k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|  20.9k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 10.4k]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 0]
  |  |  |  |  |  Branch (279:38): [True: 0, False: 10.4k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 10.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  163|  10.4k|            bytes_in_buffer--; \
  |  |  164|  10.4k|            V = ((unsigned int)(*next_input_byte++)) << 8; \
  |  |  165|  10.4k|            MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  166|  10.4k|            bytes_in_buffer--; \
  |  |  167|  10.4k|            V += *next_input_byte++; )
  ------------------
  719|  10.4k|  length -= 2;
  720|       |
  721|       |  /* get the interesting part of the marker data */
  722|  10.4k|  if (length >= APPN_DATA_LEN)
  ------------------
  |  |  602|  10.4k|#define APPN_DATA_LEN   14      /* Must be the largest of the above!! */
  ------------------
  |  Branch (722:7): [True: 9.36k, False: 1.10k]
  ------------------
  723|  9.36k|    numtoread = APPN_DATA_LEN;
  ------------------
  |  |  602|  9.36k|#define APPN_DATA_LEN   14      /* Must be the largest of the above!! */
  ------------------
  724|  1.10k|  else if (length > 0)
  ------------------
  |  Branch (724:12): [True: 1.01k, False: 88]
  ------------------
  725|  1.01k|    numtoread = (unsigned int)length;
  726|     88|  else
  727|     88|    numtoread = 0;
  728|   146k|  for (i = 0; i < numtoread; i++)
  ------------------
  |  Branch (728:15): [True: 136k, False: 10.4k]
  ------------------
  729|   136k|    INPUT_BYTE(cinfo, b[i], return FALSE);
  ------------------
  |  |  154|   136k|  MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
  |  |  ------------------
  |  |  |  |  279|   146k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:38): [True: 0, False: 4]
  |  |  |  |  |  Branch (279:38): [True: 4, False: 136k]
  |  |  |  |  |  Branch (279:53): [Folded, False: 136k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  155|  10.4k|            bytes_in_buffer--; \
  |  |  156|  10.4k|            V = *next_input_byte++; )
  ------------------
  730|  10.4k|  length -= numtoread;
  731|       |
  732|       |  /* process it */
  733|  10.4k|  switch (cinfo->unread_marker) {
  734|  9.31k|  case M_APP0:
  ------------------
  |  Branch (734:3): [True: 9.31k, False: 1.15k]
  ------------------
  735|  9.31k|    examine_app0(cinfo, (JOCTET *)b, numtoread, length);
  736|  9.31k|    break;
  737|  1.15k|  case M_APP14:
  ------------------
  |  Branch (737:3): [True: 1.15k, False: 9.31k]
  ------------------
  738|  1.15k|    examine_app14(cinfo, (JOCTET *)b, numtoread, length);
  739|  1.15k|    break;
  740|      0|  default:
  ------------------
  |  Branch (740:3): [True: 0, False: 10.4k]
  ------------------
  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|  10.4k|  }
  745|       |
  746|       |  /* skip any remaining data -- could be lots */
  747|  10.4k|  INPUT_SYNC(cinfo);
  ------------------
  |  |  131|  10.4k|  ( datasrc->next_input_byte = next_input_byte, \
  |  |  132|  10.4k|    datasrc->bytes_in_buffer = bytes_in_buffer )
  ------------------
  748|  10.4k|  if (length > 0)
  ------------------
  |  Branch (748:7): [True: 1.31k, False: 9.15k]
  ------------------
  749|  1.31k|    (*cinfo->src->skip_input_data) (cinfo, (long)length);
  750|       |
  751|  10.4k|  return TRUE;
  ------------------
  |  |  210|  10.4k|#define TRUE    1
  ------------------
  752|  10.4k|}
jdmarker.c:examine_app0:
  612|  9.31k|{
  613|  9.31k|  JLONG totallen = (JLONG)datalen + remaining;
  614|       |
  615|  9.31k|  if (datalen >= APP0_DATA_LEN &&
  ------------------
  |  |  600|  18.6k|#define APP0_DATA_LEN   14      /* Length of interesting data in APP0 */
  ------------------
  |  Branch (615:7): [True: 8.20k, False: 1.10k]
  ------------------
  616|  8.20k|      data[0] == 0x4A &&
  ------------------
  |  Branch (616:7): [True: 4.27k, False: 3.93k]
  ------------------
  617|  4.27k|      data[1] == 0x46 &&
  ------------------
  |  Branch (617:7): [True: 4.02k, False: 255]
  ------------------
  618|  4.02k|      data[2] == 0x49 &&
  ------------------
  |  Branch (618:7): [True: 1.23k, False: 2.78k]
  ------------------
  619|  1.23k|      data[3] == 0x46 &&
  ------------------
  |  Branch (619:7): [True: 1.05k, False: 178]
  ------------------
  620|  1.05k|      data[4] == 0) {
  ------------------
  |  Branch (620:7): [True: 1.05k, False: 0]
  ------------------
  621|       |    /* Found JFIF APP0 marker: save info */
  622|  1.05k|    cinfo->saw_JFIF_marker = TRUE;
  ------------------
  |  |  210|  1.05k|#define TRUE    1
  ------------------
  623|  1.05k|    cinfo->JFIF_major_version = data[5];
  624|  1.05k|    cinfo->JFIF_minor_version = data[6];
  625|  1.05k|    cinfo->density_unit = data[7];
  626|  1.05k|    cinfo->X_density = (data[8] << 8) + data[9];
  627|  1.05k|    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.05k|    if (cinfo->JFIF_major_version != 1)
  ------------------
  |  Branch (634:9): [True: 263, False: 795]
  ------------------
  635|    263|      WARNMS2(cinfo, JWRN_JFIF_MAJOR,
  ------------------
  |  |  290|    263|  ((cinfo)->err->msg_code = (code), \
  |  |  291|    263|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  292|    263|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  293|    263|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  636|  1.05k|              cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
  637|       |    /* Generate trace messages */
  638|  1.05k|    TRACEMS5(cinfo, 1, JTRC_JFIF,
  ------------------
  |  |  319|  1.05k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.05k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  320|  1.05k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  321|  1.05k|           _mp[4] = (p5); \
  |  |  322|  1.05k|           (cinfo)->err->msg_code = (code); \
  |  |  323|  1.05k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  639|  1.05k|             cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
  640|  1.05k|             cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
  641|       |    /* Validate thumbnail dimensions and issue appropriate messages */
  642|  1.05k|    if (data[12] | data[13])
  ------------------
  |  Branch (642:9): [True: 398, False: 660]
  ------------------
  643|    398|      TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, data[12], data[13]);
  ------------------
  |  |  304|    398|  ((cinfo)->err->msg_code = (code), \
  |  |  305|    398|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|    398|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|    398|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  644|  1.05k|    totallen -= APP0_DATA_LEN;
  ------------------
  |  |  600|  1.05k|#define APP0_DATA_LEN   14      /* Length of interesting data in APP0 */
  ------------------
  645|  1.05k|    if (totallen != ((JLONG)data[12] * (JLONG)data[13] * (JLONG)3))
  ------------------
  |  Branch (645:9): [True: 462, False: 596]
  ------------------
  646|    462|      TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)totallen);
  ------------------
  |  |  300|    462|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    462|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    462|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  647|  8.25k|  } else if (datalen >= 6 &&
  ------------------
  |  Branch (647:14): [True: 7.18k, False: 1.06k]
  ------------------
  648|  7.18k|             data[0] == 0x4A &&
  ------------------
  |  Branch (648:14): [True: 3.24k, False: 3.93k]
  ------------------
  649|  3.24k|             data[1] == 0x46 &&
  ------------------
  |  Branch (649:14): [True: 2.99k, False: 255]
  ------------------
  650|  2.99k|             data[2] == 0x58 &&
  ------------------
  |  Branch (650:14): [True: 2.03k, False: 960]
  ------------------
  651|  2.03k|             data[3] == 0x58 &&
  ------------------
  |  Branch (651:14): [True: 1.40k, False: 628]
  ------------------
  652|  1.40k|             data[4] == 0) {
  ------------------
  |  Branch (652:14): [True: 1.27k, False: 129]
  ------------------
  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|  1.27k|    switch (data[5]) {
  658|    364|    case 0x10:
  ------------------
  |  Branch (658:5): [True: 364, False: 912]
  ------------------
  659|    364|      TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int)totallen);
  ------------------
  |  |  300|    364|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    364|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    364|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  660|    364|      break;
  661|    301|    case 0x11:
  ------------------
  |  Branch (661:5): [True: 301, False: 975]
  ------------------
  662|    301|      TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int)totallen);
  ------------------
  |  |  300|    301|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    301|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    301|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  663|    301|      break;
  664|    215|    case 0x13:
  ------------------
  |  Branch (664:5): [True: 215, False: 1.06k]
  ------------------
  665|    215|      TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int)totallen);
  ------------------
  |  |  300|    215|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    215|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    215|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  666|    215|      break;
  667|    396|    default:
  ------------------
  |  Branch (667:5): [True: 396, False: 880]
  ------------------
  668|    396|      TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, data[5], (int)totallen);
  ------------------
  |  |  304|    396|  ((cinfo)->err->msg_code = (code), \
  |  |  305|    396|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|    396|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|    396|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  669|    396|      break;
  670|  1.27k|    }
  671|  6.97k|  } else {
  672|       |    /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
  673|  6.97k|    TRACEMS1(cinfo, 1, JTRC_APP0, (int)totallen);
  ------------------
  |  |  300|  6.97k|  ((cinfo)->err->msg_code = (code), \
  |  |  301|  6.97k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|  6.97k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  674|  6.97k|  }
  675|  9.31k|}
jdmarker.c:examine_app14:
  685|  1.15k|{
  686|  1.15k|  unsigned int version, flags0, flags1, transform;
  687|       |
  688|  1.15k|  if (datalen >= APP14_DATA_LEN &&
  ------------------
  |  |  601|  2.31k|#define APP14_DATA_LEN  12      /* Length of interesting data in APP14 */
  ------------------
  |  Branch (688:7): [True: 1.15k, False: 2]
  ------------------
  689|  1.15k|      data[0] == 0x41 &&
  ------------------
  |  Branch (689:7): [True: 862, False: 295]
  ------------------
  690|    862|      data[1] == 0x64 &&
  ------------------
  |  Branch (690:7): [True: 733, False: 129]
  ------------------
  691|    733|      data[2] == 0x6F &&
  ------------------
  |  Branch (691:7): [True: 536, False: 197]
  ------------------
  692|    536|      data[3] == 0x62 &&
  ------------------
  |  Branch (692:7): [True: 408, False: 128]
  ------------------
  693|    408|      data[4] == 0x65) {
  ------------------
  |  Branch (693:7): [True: 288, False: 120]
  ------------------
  694|       |    /* Found Adobe APP14 marker */
  695|    288|    version = (data[5] << 8) + data[6];
  696|    288|    flags0 = (data[7] << 8) + data[8];
  697|    288|    flags1 = (data[9] << 8) + data[10];
  698|    288|    transform = data[11];
  699|    288|    TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
  ------------------
  |  |  314|    288|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    288|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 288]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  315|    288|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3);  _mp[3] = (p4); \
  |  |  316|    288|           (cinfo)->err->msg_code = (code); \
  |  |  317|    288|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  700|    288|    cinfo->saw_Adobe_marker = TRUE;
  ------------------
  |  |  210|    288|#define TRUE    1
  ------------------
  701|    288|    cinfo->Adobe_transform = (UINT8)transform;
  702|    871|  } else {
  703|       |    /* Start of APP14 does not match "Adobe", or too short */
  704|    871|    TRACEMS1(cinfo, 1, JTRC_APP14, (int)(datalen + remaining));
  ------------------
  |  |  300|    871|  ((cinfo)->err->msg_code = (code), \
  |  |  301|    871|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  302|    871|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  705|    871|  }
  706|  1.15k|}

jpeg_calc_output_dimensions:
  269|    923|{
  270|    923|#ifdef IDCT_SCALING_SUPPORTED
  271|    923|  int ci;
  272|    923|  jpeg_component_info *compptr;
  273|    923|#endif
  274|       |
  275|       |  /* Prevent application from calling me at wrong times */
  276|    923|  if (cinfo->global_state != DSTATE_READY)
  ------------------
  |  |   50|    923|#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
  ------------------
  |  Branch (276:7): [True: 0, False: 923]
  ------------------
  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|    923|  jpeg_core_output_dimensions(cinfo);
  281|       |
  282|    923|#ifdef IDCT_SCALING_SUPPORTED
  283|       |
  284|    923|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (284:7): [True: 923, False: 0]
  ------------------
  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|  1.91k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (290:46): [True: 987, False: 923]
  ------------------
  291|    987|         ci++, compptr++) {
  292|    987|      int ssize = cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|    987|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  293|    987|      while (ssize < DCTSIZE &&
  ------------------
  |  |   66|  1.97k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (293:14): [True: 0, False: 987]
  ------------------
  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|    987|      compptr->DCT_scaled_size = ssize;
  304|    987|#endif
  305|    987|    }
  306|       |
  307|       |    /* Recompute downsampled dimensions of components;
  308|       |     * application needs to know these if using raw downsampled data.
  309|       |     */
  310|  1.91k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:46): [True: 987, False: 923]
  ------------------
  311|    987|         ci++, compptr++) {
  312|       |      /* Size in samples, after IDCT scaling */
  313|    987|      compptr->downsampled_width = (JDIMENSION)
  314|    987|        jdiv_round_up((long)cinfo->image_width *
  315|    987|                      (long)(compptr->h_samp_factor *
  316|    987|                             compptr->_DCT_scaled_size),
  ------------------
  |  |   24|    987|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  317|    987|                      (long)(cinfo->max_h_samp_factor * DCTSIZE));
  ------------------
  |  |   66|    987|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  318|    987|      compptr->downsampled_height = (JDIMENSION)
  319|    987|        jdiv_round_up((long)cinfo->image_height *
  320|    987|                      (long)(compptr->v_samp_factor *
  321|    987|                             compptr->_DCT_scaled_size),
  ------------------
  |  |   24|    987|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  322|    987|                      (long)(cinfo->max_v_samp_factor * DCTSIZE));
  ------------------
  |  |   66|    987|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  323|    987|    }
  324|    923|  } else
  325|      0|#endif /* IDCT_SCALING_SUPPORTED */
  326|      0|  {
  327|       |    /* Hardwire it to "no scaling" */
  328|      0|    cinfo->output_width = cinfo->image_width;
  329|      0|    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|      0|  }
  334|       |
  335|       |  /* Report number of components in selected colorspace. */
  336|       |  /* Probably this should be in the color conversion module... */
  337|    923|  switch (cinfo->out_color_space) {
  338|      0|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (338:3): [True: 0, False: 923]
  ------------------
  339|      0|    cinfo->out_color_components = 1;
  340|      0|    break;
  341|      0|  case JCS_RGB:
  ------------------
  |  Branch (341:3): [True: 0, False: 923]
  ------------------
  342|      0|  case JCS_EXT_RGB:
  ------------------
  |  Branch (342:3): [True: 0, False: 923]
  ------------------
  343|      0|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (343:3): [True: 0, False: 923]
  ------------------
  344|      0|  case JCS_EXT_BGR:
  ------------------
  |  Branch (344:3): [True: 0, False: 923]
  ------------------
  345|      0|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (345:3): [True: 0, False: 923]
  ------------------
  346|      0|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (346:3): [True: 0, False: 923]
  ------------------
  347|      0|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (347:3): [True: 0, False: 923]
  ------------------
  348|      0|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (348:3): [True: 0, False: 923]
  ------------------
  349|      0|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (349:3): [True: 0, False: 923]
  ------------------
  350|      0|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (350:3): [True: 0, False: 923]
  ------------------
  351|      0|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (351:3): [True: 0, False: 923]
  ------------------
  352|      0|    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
  353|      0|    break;
  354|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (354:3): [True: 0, False: 923]
  ------------------
  355|      0|  case JCS_RGB565:
  ------------------
  |  Branch (355:3): [True: 0, False: 923]
  ------------------
  356|      0|    cinfo->out_color_components = 3;
  357|      0|    break;
  358|      0|  case JCS_CMYK:
  ------------------
  |  Branch (358:3): [True: 0, False: 923]
  ------------------
  359|      0|  case JCS_YCCK:
  ------------------
  |  Branch (359:3): [True: 0, False: 923]
  ------------------
  360|      0|    cinfo->out_color_components = 4;
  361|      0|    break;
  362|    923|  default:                      /* else must be same colorspace as in file */
  ------------------
  |  Branch (362:3): [True: 923, False: 0]
  ------------------
  363|    923|    cinfo->out_color_components = cinfo->num_components;
  364|    923|    break;
  365|    923|  }
  366|    923|  cinfo->output_components = (cinfo->quantize_colors ? 1 :
  ------------------
  |  Branch (366:31): [True: 0, False: 923]
  ------------------
  367|    923|                              cinfo->out_color_components);
  368|       |
  369|       |  /* See if upsampler will want to emit more than one row at a time */
  370|    923|  if (use_merged_upsample(cinfo))
  ------------------
  |  Branch (370:7): [True: 0, False: 923]
  ------------------
  371|      0|    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
  372|    923|  else
  373|    923|    cinfo->rec_outbuf_height = 1;
  374|    923|}
jinit_master_decompress:
  902|    923|{
  903|    923|  my_master_ptr master = (my_master_ptr)cinfo->master;
  904|       |
  905|       |#ifdef WITH_PROFILE
  906|       |  master->pub.total_start = getTime();
  907|       |#endif
  908|       |
  909|    923|  master->pub.prepare_for_output_pass = prepare_for_output_pass;
  910|    923|  master->pub.finish_output_pass = finish_output_pass;
  911|       |
  912|    923|  master->pub.is_dummy_pass = FALSE;
  ------------------
  |  |  207|    923|#define FALSE   0               /* values of boolean */
  ------------------
  913|    923|  master->pub.jinit_upsampler_no_alloc = FALSE;
  ------------------
  |  |  207|    923|#define FALSE   0               /* values of boolean */
  ------------------
  914|       |
  915|    923|  master_selection(cinfo);
  916|    923|}
jdmaster.c:jpeg_core_output_dimensions:
  103|    923|{
  104|    923|#ifdef IDCT_SCALING_SUPPORTED
  105|    923|  int ci;
  106|    923|  jpeg_component_info *compptr;
  107|       |
  108|    923|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (108:7): [True: 923, False: 0]
  ------------------
  109|       |    /* Compute actual output image dimensions and DCT scaling choices. */
  110|    923|    if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (110:9): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (118:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (126:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (134:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (142:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (150:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:16): [True: 0, False: 923]
  ------------------
  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|    923|    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (166:16): [True: 923, False: 0]
  ------------------
  167|       |      /* Provide 8/block_size scaling */
  168|    923|      cinfo->output_width = (JDIMENSION)
  169|    923|        jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  170|    923|      cinfo->output_height = (JDIMENSION)
  171|    923|        jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
  ------------------
  |  |   66|    923|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  172|    923|      cinfo->_min_DCT_h_scaled_size = 8;
  ------------------
  |  |   28|    923|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  173|    923|      cinfo->_min_DCT_v_scaled_size = 8;
  ------------------
  |  |   29|    923|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  174|    923|    } 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|  1.91k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (241:46): [True: 987, False: 923]
  ------------------
  242|    987|         ci++, compptr++) {
  243|    987|      compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
  ------------------
  |  |   25|    987|#define _DCT_h_scaled_size  DCT_scaled_size
  ------------------
                    compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
  ------------------
  |  |   28|    987|#define _min_DCT_h_scaled_size  min_DCT_scaled_size
  ------------------
  244|    987|      compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
  ------------------
  |  |   26|    987|#define _DCT_v_scaled_size  DCT_scaled_size
  ------------------
                    compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
  ------------------
  |  |   29|    987|#define _min_DCT_v_scaled_size  min_DCT_scaled_size
  ------------------
  245|    987|    }
  246|    923|  } else
  247|      0|#endif /* !IDCT_SCALING_SUPPORTED */
  248|      0|  {
  249|       |    /* Hardwire it to "no scaling" */
  250|      0|    cinfo->output_width = cinfo->image_width;
  251|      0|    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|      0|  }
  256|    923|}
jdmaster.c:use_merged_upsample:
   39|  1.84k|{
   40|  1.84k|#ifdef UPSAMPLE_MERGING_SUPPORTED
   41|       |  /* Colorspace conversion is not supported with lossless JPEG images */
   42|  1.84k|  if (cinfo->master->lossless)
  ------------------
  |  Branch (42:7): [True: 0, False: 1.84k]
  ------------------
   43|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   44|       |  /* Merging is the equivalent of plain box-filter upsampling */
   45|  1.84k|  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
  ------------------
  |  Branch (45:7): [True: 1.84k, False: 0]
  |  Branch (45:37): [True: 0, False: 0]
  ------------------
   46|  1.84k|    return FALSE;
  ------------------
  |  |  207|  1.84k|#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|    888|{
  798|    888|  my_master_ptr master = (my_master_ptr)cinfo->master;
  799|       |
  800|    888|  if (master->pub.is_dummy_pass) {
  ------------------
  |  Branch (800:7): [True: 0, False: 888]
  ------------------
  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|    888|  } else {
  811|    888|    if (cinfo->quantize_colors && cinfo->colormap == NULL) {
  ------------------
  |  Branch (811:9): [True: 0, False: 888]
  |  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|    888|    (*cinfo->idct->start_pass) (cinfo);
  823|    888|    (*cinfo->coef->start_output_pass) (cinfo);
  824|    888|    if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (824:9): [True: 888, False: 0]
  ------------------
  825|    888|      if (!master->using_merged_upsample)
  ------------------
  |  Branch (825:11): [True: 888, False: 0]
  ------------------
  826|    888|        (*cinfo->cconvert->start_pass) (cinfo);
  827|    888|      (*cinfo->upsample->start_pass) (cinfo);
  828|    888|      if (cinfo->quantize_colors)
  ------------------
  |  Branch (828:11): [True: 0, False: 888]
  ------------------
  829|      0|        (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
  830|    888|      (*cinfo->post->start_pass) (cinfo,
  831|    888|            (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  ------------------
  |  Branch (831:14): [True: 0, False: 888]
  ------------------
  832|    888|      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  833|    888|    }
  834|    888|  }
  835|       |
  836|       |  /* Set up progress monitor's pass info if present */
  837|    888|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (837:7): [True: 0, False: 888]
  ------------------
  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|    888|}
jdmaster.c:master_selection:
  515|    923|{
  516|    923|  my_master_ptr master = (my_master_ptr)cinfo->master;
  517|    923|  boolean use_c_buffer;
  518|    923|  long samplesperrow;
  519|    923|  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|    923|  if (cinfo->master->jpeg_data_precision &&
  ------------------
  |  Branch (527:7): [True: 923, False: 0]
  ------------------
  528|    923|      cinfo->data_precision != cinfo->master->jpeg_data_precision &&
  ------------------
  |  Branch (528:7): [True: 0, False: 923]
  ------------------
  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|    923|#ifdef D_LOSSLESS_SUPPORTED
  539|    923|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (539:7): [True: 0, False: 923]
  ------------------
  540|      0|    cinfo->raw_data_out = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  541|      0|    cinfo->scale_num = cinfo->scale_denom = 1;
  542|      0|  }
  543|    923|#endif
  544|       |
  545|       |  /* Initialize dimensions and other stuff */
  546|    923|  jpeg_calc_output_dimensions(cinfo);
  547|    923|  prepare_range_limit_table(cinfo);
  548|       |
  549|       |  /* Width of an output scanline must be representable as JDIMENSION. */
  550|    923|  samplesperrow = (long)cinfo->output_width *
  551|    923|                  (long)cinfo->out_color_components;
  552|    923|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  553|    923|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (553:7): [True: 0, False: 923]
  ------------------
  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|    923|  master->pass_number = 0;
  558|    923|  master->using_merged_upsample = use_merged_upsample(cinfo);
  559|       |
  560|       |  /* Color quantizer selection */
  561|    923|  master->quantizer_1pass = NULL;
  562|    923|  master->quantizer_2pass = NULL;
  563|       |  /* No mode changes if not using buffered-image mode. */
  564|    923|  if (!cinfo->quantize_colors || !cinfo->buffered_image) {
  ------------------
  |  Branch (564:7): [True: 923, False: 0]
  |  Branch (564:34): [True: 0, False: 0]
  ------------------
  565|    923|    cinfo->enable_1pass_quant = FALSE;
  ------------------
  |  |  207|    923|#define FALSE   0               /* values of boolean */
  ------------------
  566|    923|    cinfo->enable_external_quant = FALSE;
  ------------------
  |  |  207|    923|#define FALSE   0               /* values of boolean */
  ------------------
  567|    923|    cinfo->enable_2pass_quant = FALSE;
  ------------------
  |  |  207|    923|#define FALSE   0               /* values of boolean */
  ------------------
  568|    923|  }
  569|    923|  if (cinfo->quantize_colors) {
  ------------------
  |  Branch (569:7): [True: 0, False: 923]
  ------------------
  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|    923|  if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (621:7): [True: 923, False: 0]
  ------------------
  622|    923|    if (master->using_merged_upsample) {
  ------------------
  |  Branch (622:9): [True: 0, False: 923]
  ------------------
  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|    923|    } else {
  634|    923|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (634:11): [True: 891, False: 32]
  ------------------
  635|    891|        jinit_color_deconverter(cinfo);
  636|    891|        jinit_upsampler(cinfo);
  637|    891|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (637:18): [True: 32, False: 0]
  ------------------
  638|     32|        j12init_color_deconverter(cinfo);
  639|     32|        j12init_upsampler(cinfo);
  640|     32|      } 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|    923|    }
  649|    923|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (649:9): [True: 891, False: 32]
  ------------------
  650|    891|      jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
  651|     32|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (651:14): [True: 32, False: 0]
  ------------------
  652|     32|      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|    923|  }
  660|       |
  661|    923|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (661:7): [True: 0, False: 923]
  ------------------
  662|      0|#ifdef D_LOSSLESS_SUPPORTED
  663|       |    /* Prediction, sample undifferencing, point transform, and sample size
  664|       |     * scaling
  665|       |     */
  666|      0|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (666:9): [True: 0, False: 0]
  ------------------
  667|      0|      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|      0|    if (cinfo->arith_code) {
  ------------------
  |  Branch (673:9): [True: 0, False: 0]
  ------------------
  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|      0|    } else {
  676|      0|      jinit_lhuff_decoder(cinfo);
  677|      0|    }
  678|       |
  679|       |    /* Initialize principal buffer controllers. */
  680|      0|    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
  ------------------
  |  Branch (680:20): [True: 0, False: 0]
  ------------------
  681|      0|                   cinfo->buffered_image;
  ------------------
  |  Branch (681:20): [True: 0, False: 0]
  ------------------
  682|      0|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (682:9): [True: 0, False: 0]
  ------------------
  683|      0|      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|    923|  } else {
  692|    923|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) || \
  693|    923|    defined(DCT_FLOAT_SUPPORTED)
  694|       |    /* Inverse DCT */
  695|    923|    if (cinfo->data_precision == 8)
  ------------------
  |  Branch (695:9): [True: 891, False: 32]
  ------------------
  696|    891|      jinit_inverse_dct(cinfo);
  697|     32|    else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (697:14): [True: 32, False: 0]
  ------------------
  698|     32|      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|    923|    if (cinfo->arith_code) {
  ------------------
  |  Branch (702:9): [True: 32, False: 891]
  ------------------
  703|     32|#ifdef D_ARITH_CODING_SUPPORTED
  704|     32|      jinit_arith_decoder(cinfo);
  705|       |#else
  706|       |      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  707|       |#endif
  708|    891|    } else {
  709|    891|      if (cinfo->progressive_mode) {
  ------------------
  |  Branch (709:11): [True: 0, False: 891]
  ------------------
  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|    891|        jinit_huff_decoder(cinfo);
  717|    891|    }
  718|       |
  719|       |    /* Initialize principal buffer controllers. */
  720|    923|    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
  ------------------
  |  Branch (720:20): [True: 32, False: 891]
  ------------------
  721|    891|                   cinfo->buffered_image;
  ------------------
  |  Branch (721:20): [True: 0, False: 891]
  ------------------
  722|    923|    if (cinfo->data_precision == 12)
  ------------------
  |  Branch (722:9): [True: 32, False: 891]
  ------------------
  723|     32|      j12init_d_coef_controller(cinfo, use_c_buffer);
  724|    891|    else
  725|    891|      jinit_d_coef_controller(cinfo, use_c_buffer);
  726|       |#else
  727|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  728|       |#endif
  729|    923|  }
  730|       |
  731|    923|  if (!cinfo->raw_data_out) {
  ------------------
  |  Branch (731:7): [True: 923, False: 0]
  ------------------
  732|    923|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (732:9): [True: 891, False: 32]
  ------------------
  733|    891|      jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|    891|#define FALSE   0               /* values of boolean */
  ------------------
  734|     32|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (734:14): [True: 32, False: 0]
  ------------------
  735|     32|      j12init_d_main_controller(cinfo,
  736|     32|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|     32|#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|    923|  }
  745|       |
  746|       |  /* We can now tell the memory manager to allocate virtual arrays. */
  747|    923|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  748|       |
  749|       |  /* Initialize input side of decompressor to consume first scan. */
  750|    923|  (*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|    923|  cinfo->master->first_iMCU_col = 0;
  756|    923|  cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
  757|    923|  cinfo->master->last_good_iMCU_row = 0;
  758|       |
  759|    923|#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|    923|  if (cinfo->progress != NULL && !cinfo->buffered_image &&
  ------------------
  |  Branch (764:7): [True: 0, False: 923]
  |  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|    923|#endif /* D_MULTISCAN_FILES_SUPPORTED */
  783|    923|}
jdmaster.c:prepare_range_limit_table:
  420|    923|{
  421|    923|  JSAMPLE *table;
  422|    923|  J12SAMPLE *table12;
  423|    923|#ifdef D_LOSSLESS_SUPPORTED
  424|    923|  J16SAMPLE *table16;
  425|    923|#endif
  426|    923|  int i;
  427|       |
  428|    923|  if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (428:7): [True: 891, False: 32]
  ------------------
  429|    891|    table = (JSAMPLE *)
  430|    891|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  431|    891|                  (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
                                (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
  432|    891|    table += (MAXJSAMPLE + 1);  /* allow negative subscripts of simple table */
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
  433|    891|    cinfo->sample_range_limit = table;
  434|       |    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
  435|    891|    memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
                  memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
  436|       |    /* Main part of "simple" table: limit[x] = x */
  437|   228k|    for (i = 0; i <= MAXJSAMPLE; i++)
  ------------------
  |  |   52|   228k|#define MAXJSAMPLE       255
  ------------------
  |  Branch (437:17): [True: 228k, False: 891]
  ------------------
  438|   228k|      table[i] = (JSAMPLE)i;
  439|    891|    table += CENTERJSAMPLE;     /* Point to where post-IDCT table starts */
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
  440|       |    /* End of simple table, rest of first half of post-IDCT table */
  441|   343k|    for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
                  for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
  ------------------
  |  |   52|   343k|#define MAXJSAMPLE       255
  ------------------
  |  Branch (441:29): [True: 342k, False: 891]
  ------------------
  442|   342k|      table[i] = MAXJSAMPLE;
  ------------------
  |  |   52|   342k|#define MAXJSAMPLE       255
  ------------------
  443|       |    /* Second half of post-IDCT table */
  444|    891|    memset(table + (2 * (MAXJSAMPLE + 1)), 0,
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
  445|    891|           (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
                         (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
  446|    891|    memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
  ------------------
  |  |   52|    891|#define MAXJSAMPLE       255
  ------------------
                  memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
  447|    891|           cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
  ------------------
  |  |   53|    891|#define CENTERJSAMPLE    128
  ------------------
  448|    891|  } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (448:14): [True: 32, False: 0]
  ------------------
  449|     32|    table12 = (J12SAMPLE *)
  450|     32|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  451|     32|                  (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
                                (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
  452|     32|                  sizeof(J12SAMPLE));
  453|     32|    table12 += (MAXJ12SAMPLE + 1);  /* allow negative subscripts of simple
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
  454|       |                                       table */
  455|     32|    cinfo->sample_range_limit = (JSAMPLE *)table12;
  456|       |    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
  457|     32|    memset(table12 - (MAXJ12SAMPLE + 1), 0,
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
  458|     32|           (MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
  459|       |    /* Main part of "simple" table: limit[x] = x */
  460|   131k|    for (i = 0; i <= MAXJ12SAMPLE; i++)
  ------------------
  |  |   60|   131k|#define MAXJ12SAMPLE     4095
  ------------------
  |  Branch (460:17): [True: 131k, False: 32]
  ------------------
  461|   131k|      table12[i] = (J12SAMPLE)i;
  462|     32|    table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
  463|       |    /* End of simple table, rest of first half of post-IDCT table */
  464|   196k|    for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
                  for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
  ------------------
  |  |   60|   196k|#define MAXJ12SAMPLE     4095
  ------------------
  |  Branch (464:31): [True: 196k, False: 32]
  ------------------
  465|   196k|      table12[i] = MAXJ12SAMPLE;
  ------------------
  |  |   60|   196k|#define MAXJ12SAMPLE     4095
  ------------------
  466|       |    /* Second half of post-IDCT table */
  467|     32|    memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
  468|     32|           (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
                         (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
  469|     32|    memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
  ------------------
  |  |   60|     32|#define MAXJ12SAMPLE     4095
  ------------------
                  memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
  470|     32|           cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
  ------------------
  |  |   61|     32|#define CENTERJ12SAMPLE  2048
  ------------------
  471|     32|  } 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|    923|}

jinit_d_post_controller:
  267|    891|{
  268|    891|  my_post_ptr post;
  269|       |
  270|    891|#ifdef D_LOSSLESS_SUPPORTED
  271|    891|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (271:7): [True: 0, False: 891]
  ------------------
  272|      0|#if BITS_IN_JSAMPLE == 8
  273|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (273:9): [True: 0, False: 0]
  |  Branch (273:52): [True: 0, False: 0]
  ------------------
  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|      0|  } else
  280|    891|#endif
  281|    891|  {
  282|    891|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (282:9): [True: 0, False: 891]
  ------------------
  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|    891|  }
  285|       |
  286|    891|  post = (my_post_ptr)
  287|    891|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  288|    891|                                sizeof(my_post_controller));
  289|    891|  cinfo->post = (struct jpeg_d_post_controller *)post;
  290|    891|  post->pub.start_pass = start_pass_dpost;
  291|    891|  post->whole_image = NULL;     /* flag for no virtual arrays */
  292|    891|  post->buffer = NULL;          /* flag for no strip buffer */
  293|       |
  294|       |  /* Create the quantization buffer, if needed */
  295|    891|  if (cinfo->quantize_colors) {
  ------------------
  |  Branch (295:7): [True: 0, False: 891]
  ------------------
  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|    891|}
jdpostct-8.c:start_pass_dpost:
   85|    888|{
   86|    888|  my_post_ptr post = (my_post_ptr)cinfo->post;
   87|       |
   88|    888|  switch (pass_mode) {
   89|    888|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (89:3): [True: 888, False: 0]
  ------------------
   90|    888|#if BITS_IN_JSAMPLE != 16
   91|    888|    if (cinfo->quantize_colors) {
  ------------------
  |  Branch (91:9): [True: 0, False: 888]
  ------------------
   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|    888|#endif
  105|    888|    {
  106|       |      /* For single-pass processing without color quantization,
  107|       |       * I have no work to do; just call the upsampler directly.
  108|       |       */
  109|    888|      post->pub._post_process_data = cinfo->upsample->_upsample;
  ------------------
  |  |  260|    888|#define _post_process_data  post_process_data
  ------------------
                    post->pub._post_process_data = cinfo->upsample->_upsample;
  ------------------
  |  |  265|    888|#define _upsample  upsample
  ------------------
  110|    888|    }
  111|    888|    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: 888]
  ------------------
  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: 888]
  ------------------
  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: 888]
  ------------------
  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|    888|  }
  130|    888|  post->starting_row = post->next_row = 0;
  131|    888|}
j12init_d_post_controller:
  267|     32|{
  268|     32|  my_post_ptr post;
  269|       |
  270|     32|#ifdef D_LOSSLESS_SUPPORTED
  271|     32|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (271:7): [True: 0, False: 32]
  ------------------
  272|       |#if BITS_IN_JSAMPLE == 8
  273|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  274|       |#else
  275|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (275:9): [True: 0, False: 0]
  ------------------
  276|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (276:9): [True: 0, False: 0]
  ------------------
  277|      0|#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|      0|  } else
  280|     32|#endif
  281|     32|  {
  282|     32|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (282:9): [True: 0, False: 32]
  ------------------
  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|     32|  }
  285|       |
  286|     32|  post = (my_post_ptr)
  287|     32|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  288|     32|                                sizeof(my_post_controller));
  289|     32|  cinfo->post = (struct jpeg_d_post_controller *)post;
  290|     32|  post->pub.start_pass = start_pass_dpost;
  291|     32|  post->whole_image = NULL;     /* flag for no virtual arrays */
  292|     32|  post->buffer = NULL;          /* flag for no strip buffer */
  293|       |
  294|       |  /* Create the quantization buffer, if needed */
  295|     32|  if (cinfo->quantize_colors) {
  ------------------
  |  Branch (295:7): [True: 0, False: 32]
  ------------------
  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|     32|}

jinit_upsampler:
  438|    891|{
  439|    891|  my_upsample_ptr upsample;
  440|    891|  int ci;
  441|    891|  jpeg_component_info *compptr;
  442|    891|  boolean need_buffer, do_fancy;
  443|    891|  int h_in_group, v_in_group, h_out_group, v_out_group;
  444|       |
  445|    891|#ifdef D_LOSSLESS_SUPPORTED
  446|    891|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (446:7): [True: 0, False: 891]
  ------------------
  447|      0|#if BITS_IN_JSAMPLE == 8
  448|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (448:9): [True: 0, False: 0]
  |  Branch (448:52): [True: 0, False: 0]
  ------------------
  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|      0|  } else
  455|    891|#endif
  456|    891|  {
  457|    891|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|    891|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (457:9): [True: 0, False: 891]
  ------------------
  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|    891|  }
  460|       |
  461|    891|  if (!cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (461:7): [True: 891, False: 0]
  ------------------
  462|    891|    upsample = (my_upsample_ptr)
  463|    891|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|    891|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  464|    891|                                  sizeof(my_upsampler));
  465|    891|    cinfo->upsample = (struct jpeg_upsampler *)upsample;
  466|    891|    upsample->pub.start_pass = start_pass_upsample;
  467|    891|    upsample->pub._upsample = sep_upsample;
  ------------------
  |  |  265|    891|#define _upsample  upsample
  ------------------
  468|    891|    upsample->pub.need_context_rows = FALSE; /* until we find out differently */
  ------------------
  |  |  207|    891|#define FALSE   0               /* values of boolean */
  ------------------
  469|    891|  } else
  470|      0|    upsample = (my_upsample_ptr)cinfo->upsample;
  471|       |
  472|    891|  if (cinfo->CCIR601_sampling)  /* this isn't supported */
  ------------------
  |  Branch (472:7): [True: 0, False: 891]
  ------------------
  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|    891|  do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;
  ------------------
  |  |   27|    891|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (478:14): [True: 891, False: 0]
  |  Branch (478:44): [True: 891, False: 0]
  ------------------
  479|       |
  480|       |  /* Verify we can handle the sampling factors, select per-component methods,
  481|       |   * and create storage as needed.
  482|       |   */
  483|  1.78k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (483:44): [True: 891, False: 891]
  ------------------
  484|    891|       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|    891|    h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|    891|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  489|    891|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|    891|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  490|    891|    v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|    891|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  491|    891|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|    891|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  492|    891|    h_out_group = cinfo->max_h_samp_factor;
  493|    891|    v_out_group = cinfo->max_v_samp_factor;
  494|    891|    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
  495|    891|    need_buffer = TRUE;
  ------------------
  |  |  210|    891|#define TRUE    1
  ------------------
  496|    891|    if (!compptr->component_needed) {
  ------------------
  |  Branch (496:9): [True: 0, False: 891]
  ------------------
  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|    891|    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (500:16): [True: 891, False: 0]
  |  Branch (500:45): [True: 891, False: 0]
  ------------------
  501|       |      /* Fullsize components can be processed without any work. */
  502|    891|      upsample->methods[ci] = fullsize_upsample;
  503|    891|      need_buffer = FALSE;
  ------------------
  |  |  207|    891|#define FALSE   0               /* values of boolean */
  ------------------
  504|    891|    } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (504:16): [True: 0, False: 0]
  |  Branch (504:49): [True: 0, False: 0]
  ------------------
  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|      0|    } else if (h_in_group == h_out_group &&
  ------------------
  |  Branch (521:16): [True: 0, False: 0]
  ------------------
  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|      0|    } else if (h_in_group * 2 == h_out_group &&
  ------------------
  |  Branch (531:16): [True: 0, False: 0]
  ------------------
  532|      0|               v_in_group * 2 == v_out_group) {
  ------------------
  |  Branch (532:16): [True: 0, False: 0]
  ------------------
  533|       |      /* Special cases for 2h2v upsampling */
  534|      0|      if (do_fancy && compptr->downsampled_width > 2) {
  ------------------
  |  Branch (534:11): [True: 0, False: 0]
  |  Branch (534:23): [True: 0, False: 0]
  ------------------
  535|      0|#ifdef WITH_SIMD
  536|      0|        if (jsimd_set_h2v2_fancy_upsample(cinfo))
  ------------------
  |  Branch (536:13): [True: 0, False: 0]
  ------------------
  537|      0|          upsample->methods[ci] = jsimd_h2v2_fancy_upsample;
  538|      0|        else
  539|      0|#endif
  540|      0|          upsample->methods[ci] = h2v2_fancy_upsample;
  541|      0|        upsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  542|      0|      } 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|      0|    } 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|    891|    if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (558:9): [True: 0, False: 891]
  |  Branch (558:24): [True: 0, False: 0]
  ------------------
  559|      0|      upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  560|      0|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  561|      0|         (JDIMENSION)jround_up((long)cinfo->output_width,
  562|      0|                               (long)cinfo->max_h_samp_factor),
  563|      0|         (JDIMENSION)cinfo->max_v_samp_factor);
  564|      0|    }
  565|    891|  }
  566|    891|}
jdsample-8.c:start_pass_upsample:
   47|    888|{
   48|    888|  my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
   49|       |
   50|       |  /* Mark the conversion buffer empty */
   51|    888|  upsample->next_row_out = cinfo->max_v_samp_factor;
   52|       |  /* Initialize total-height counter for detecting bottom of image */
   53|    888|  upsample->rows_to_go = cinfo->output_height;
   54|    888|}
jdsample-8.c:sep_upsample:
   70|   869k|{
   71|   869k|  my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
   72|   869k|  int ci;
   73|   869k|  jpeg_component_info *compptr;
   74|   869k|  JDIMENSION num_rows;
   75|       |
   76|       |  /* Fill the conversion buffer, if it's empty */
   77|   869k|  if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (77:7): [True: 857k, False: 11.6k]
  ------------------
   78|  1.71M|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (78:46): [True: 857k, False: 857k]
  ------------------
   79|   857k|         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|   857k|      (*upsample->methods[ci]) (cinfo, compptr,
   87|   857k|        input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
   88|   857k|        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|   857k|    }
   95|   857k|    upsample->next_row_out = 0;
   96|   857k|  }
   97|       |
   98|       |  /* Color-convert and emit rows */
   99|       |
  100|       |  /* How many we have in the buffer: */
  101|   869k|  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|   869k|  if (num_rows > upsample->rows_to_go)
  ------------------
  |  Branch (105:7): [True: 2, False: 869k]
  ------------------
  106|      2|    num_rows = upsample->rows_to_go;
  107|       |  /* And not more than what the client can accept: */
  108|   869k|  out_rows_avail -= *out_row_ctr;
  109|   869k|  if (num_rows > out_rows_avail)
  ------------------
  |  Branch (109:7): [True: 11.6k, False: 857k]
  ------------------
  110|  11.6k|    num_rows = out_rows_avail;
  111|       |
  112|       |#ifdef WITH_PROFILE
  113|       |  cinfo->master->start = getTime();
  114|       |#endif
  115|   869k|  (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf,
  ------------------
  |  |  267|   869k|#define _color_convert  color_convert
  ------------------
  116|   869k|                                      (JDIMENSION)upsample->next_row_out,
  117|   869k|                                      output_buf + *out_row_ctr,
  118|   869k|                                      (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|   869k|  *out_row_ctr += num_rows;
  127|   869k|  upsample->rows_to_go -= num_rows;
  128|   869k|  upsample->next_row_out += num_rows;
  129|       |  /* When the buffer is emptied, declare this input row group consumed */
  130|   869k|  if (upsample->next_row_out >= cinfo->max_v_samp_factor)
  ------------------
  |  Branch (130:7): [True: 857k, False: 11.6k]
  ------------------
  131|   857k|    (*in_row_group_ctr)++;
  132|   869k|}
jdsample-8.c:fullsize_upsample:
  151|   857k|{
  152|   857k|  *output_data_ptr = input_data;
  153|   857k|}
j12init_upsampler:
  438|     32|{
  439|     32|  my_upsample_ptr upsample;
  440|     32|  int ci;
  441|     32|  jpeg_component_info *compptr;
  442|     32|  boolean need_buffer, do_fancy;
  443|     32|  int h_in_group, v_in_group, h_out_group, v_out_group;
  444|       |
  445|     32|#ifdef D_LOSSLESS_SUPPORTED
  446|     32|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (446:7): [True: 0, False: 32]
  ------------------
  447|       |#if BITS_IN_JSAMPLE == 8
  448|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  449|       |#else
  450|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (450:9): [True: 0, False: 0]
  ------------------
  451|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (451:9): [True: 0, False: 0]
  ------------------
  452|      0|#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|      0|  } else
  455|     32|#endif
  456|     32|  {
  457|     32|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|     32|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (457:9): [True: 0, False: 32]
  ------------------
  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|     32|  }
  460|       |
  461|     32|  if (!cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (461:7): [True: 32, False: 0]
  ------------------
  462|     32|    upsample = (my_upsample_ptr)
  463|     32|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     32|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  464|     32|                                  sizeof(my_upsampler));
  465|     32|    cinfo->upsample = (struct jpeg_upsampler *)upsample;
  466|     32|    upsample->pub.start_pass = start_pass_upsample;
  467|     32|    upsample->pub._upsample = sep_upsample;
  ------------------
  |  |  149|     32|#define _upsample  upsample_12
  ------------------
  468|     32|    upsample->pub.need_context_rows = FALSE; /* until we find out differently */
  ------------------
  |  |  207|     32|#define FALSE   0               /* values of boolean */
  ------------------
  469|     32|  } else
  470|      0|    upsample = (my_upsample_ptr)cinfo->upsample;
  471|       |
  472|     32|  if (cinfo->CCIR601_sampling)  /* this isn't supported */
  ------------------
  |  Branch (472:7): [True: 0, False: 32]
  ------------------
  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|     32|  do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;
  ------------------
  |  |   27|     32|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  |  Branch (478:14): [True: 32, False: 0]
  |  Branch (478:44): [True: 32, False: 0]
  ------------------
  479|       |
  480|       |  /* Verify we can handle the sampling factors, select per-component methods,
  481|       |   * and create storage as needed.
  482|       |   */
  483|    128|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (483:44): [True: 96, False: 32]
  ------------------
  484|     96|       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|     96|    h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|     96|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  489|     96|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|     96|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  490|     96|    v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  ------------------
  |  |   24|     96|#define _DCT_scaled_size  DCT_scaled_size
  ------------------
  491|     96|                 cinfo->_min_DCT_scaled_size;
  ------------------
  |  |   27|     96|#define _min_DCT_scaled_size  min_DCT_scaled_size
  ------------------
  492|     96|    h_out_group = cinfo->max_h_samp_factor;
  493|     96|    v_out_group = cinfo->max_v_samp_factor;
  494|     96|    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
  495|     96|    need_buffer = TRUE;
  ------------------
  |  |  210|     96|#define TRUE    1
  ------------------
  496|     96|    if (!compptr->component_needed) {
  ------------------
  |  Branch (496:9): [True: 0, False: 96]
  ------------------
  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|     96|    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (500:16): [True: 96, False: 0]
  |  Branch (500:45): [True: 96, False: 0]
  ------------------
  501|       |      /* Fullsize components can be processed without any work. */
  502|     96|      upsample->methods[ci] = fullsize_upsample;
  503|     96|      need_buffer = FALSE;
  ------------------
  |  |  207|     96|#define FALSE   0               /* values of boolean */
  ------------------
  504|     96|    } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
  ------------------
  |  Branch (504:16): [True: 0, False: 0]
  |  Branch (504:49): [True: 0, False: 0]
  ------------------
  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|       |#ifdef WITH_SIMD
  508|       |        if (jsimd_set_h2v1_fancy_upsample(cinfo))
  509|       |          upsample->methods[ci] = jsimd_h2v1_fancy_upsample;
  510|       |        else
  511|       |#endif
  512|      0|          upsample->methods[ci] = h2v1_fancy_upsample;
  513|      0|      } else {
  514|       |#ifdef WITH_SIMD
  515|       |        if (jsimd_set_h2v1_upsample(cinfo))
  516|       |          upsample->methods[ci] = jsimd_h2v1_upsample;
  517|       |        else
  518|       |#endif
  519|      0|          upsample->methods[ci] = h2v1_upsample;
  520|      0|      }
  521|      0|    } else if (h_in_group == h_out_group &&
  ------------------
  |  Branch (521:16): [True: 0, False: 0]
  ------------------
  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|      0|    } else if (h_in_group * 2 == h_out_group &&
  ------------------
  |  Branch (531:16): [True: 0, False: 0]
  ------------------
  532|      0|               v_in_group * 2 == v_out_group) {
  ------------------
  |  Branch (532:16): [True: 0, False: 0]
  ------------------
  533|       |      /* Special cases for 2h2v upsampling */
  534|      0|      if (do_fancy && compptr->downsampled_width > 2) {
  ------------------
  |  Branch (534:11): [True: 0, False: 0]
  |  Branch (534:23): [True: 0, False: 0]
  ------------------
  535|       |#ifdef WITH_SIMD
  536|       |        if (jsimd_set_h2v2_fancy_upsample(cinfo))
  537|       |          upsample->methods[ci] = jsimd_h2v2_fancy_upsample;
  538|       |        else
  539|       |#endif
  540|      0|          upsample->methods[ci] = h2v2_fancy_upsample;
  541|      0|        upsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  542|      0|      } else {
  543|       |#ifdef WITH_SIMD
  544|       |        if (jsimd_set_h2v2_upsample(cinfo))
  545|       |          upsample->methods[ci] = jsimd_h2v2_upsample;
  546|       |        else
  547|       |#endif
  548|      0|          upsample->methods[ci] = h2v2_upsample;
  549|      0|      }
  550|      0|    } 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|     96|    if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
  ------------------
  |  Branch (558:9): [True: 0, False: 96]
  |  Branch (558:24): [True: 0, False: 0]
  ------------------
  559|      0|      upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  560|      0|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  561|      0|         (JDIMENSION)jround_up((long)cinfo->output_width,
  562|      0|                               (long)cinfo->max_h_samp_factor),
  563|      0|         (JDIMENSION)cinfo->max_v_samp_factor);
  564|      0|    }
  565|     96|  }
  566|     32|}

jpeg_std_error:
  229|  1.15k|{
  230|  1.15k|  memset(err, 0, sizeof(struct jpeg_error_mgr));
  231|       |
  232|  1.15k|  err->error_exit = error_exit;
  233|  1.15k|  err->emit_message = emit_message;
  234|  1.15k|  err->output_message = output_message;
  235|  1.15k|  err->format_message = format_message;
  236|  1.15k|  err->reset_error_mgr = reset_error_mgr;
  237|       |
  238|       |  /* Initialize message table pointers */
  239|  1.15k|  err->jpeg_message_table = jpeg_std_message_table;
  240|  1.15k|  err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
  241|       |
  242|  1.15k|  return err;
  243|  1.15k|}
jerror.c:emit_message:
  126|  8.42M|{
  127|  8.42M|  struct jpeg_error_mgr *err = cinfo->err;
  128|       |
  129|  8.42M|  if (msg_level < 0) {
  ------------------
  |  Branch (129:7): [True: 8.36M, False: 62.8k]
  ------------------
  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|  8.36M|    if (err->num_warnings == 0 || err->trace_level >= 3)
  ------------------
  |  Branch (134:9): [True: 1.80k, False: 8.36M]
  |  Branch (134:35): [True: 0, False: 8.36M]
  ------------------
  135|  1.80k|      (*err->output_message) (cinfo);
  136|       |    /* Always count warnings in num_warnings. */
  137|  8.36M|    err->num_warnings++;
  138|  8.36M|  } else {
  139|       |    /* It's a trace message.  Show it if trace_level >= msg_level. */
  140|  62.8k|    if (err->trace_level >= msg_level)
  ------------------
  |  Branch (140:9): [True: 0, False: 62.8k]
  ------------------
  141|      0|      (*err->output_message) (cinfo);
  142|  62.8k|  }
  143|  8.42M|}
jerror.c:format_message:
  155|  3.15k|{
  156|  3.15k|  struct jpeg_error_mgr *err = cinfo->err;
  157|  3.15k|  int msg_code = err->msg_code;
  158|  3.15k|  const char *msgtext = NULL;
  159|  3.15k|  const char *msgptr;
  160|  3.15k|  char ch;
  161|  3.15k|  boolean isstring;
  162|       |
  163|       |  /* Look up message string in proper table */
  164|  3.15k|  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
  ------------------
  |  Branch (164:7): [True: 3.15k, False: 0]
  |  Branch (164:23): [True: 3.15k, False: 0]
  ------------------
  165|  3.15k|    msgtext = err->jpeg_message_table[msg_code];
  166|  3.15k|  } 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|  3.15k|  if (msgtext == NULL) {
  ------------------
  |  Branch (173:7): [True: 0, False: 3.15k]
  ------------------
  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|  3.15k|  isstring = FALSE;
  ------------------
  |  |  207|  3.15k|#define FALSE   0               /* values of boolean */
  ------------------
  180|  3.15k|  msgptr = msgtext;
  181|  99.1k|  while ((ch = *msgptr++) != '\0') {
  ------------------
  |  Branch (181:10): [True: 97.9k, False: 1.25k]
  ------------------
  182|  97.9k|    if (ch == '%') {
  ------------------
  |  Branch (182:9): [True: 1.89k, False: 96.0k]
  ------------------
  183|  1.89k|      if (*msgptr == 's') isstring = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  |  Branch (183:11): [True: 0, False: 1.89k]
  ------------------
  184|  1.89k|      break;
  185|  1.89k|    }
  186|  97.9k|  }
  187|       |
  188|       |  /* Format the message into the passed buffer */
  189|  3.15k|  if (isstring)
  ------------------
  |  Branch (189:7): [True: 0, False: 3.15k]
  ------------------
  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|  3.15k|  else
  192|  3.15k|    SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext,
  ------------------
  |  |   55|  3.15k|#define SNPRINTF  snprintf
  ------------------
                  SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext,
  ------------------
  |  |  792|  3.15k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  193|  3.15k|             err->msg_parm.i[0], err->msg_parm.i[1],
  194|  3.15k|             err->msg_parm.i[2], err->msg_parm.i[3],
  195|  3.15k|             err->msg_parm.i[4], err->msg_parm.i[5],
  196|  3.15k|             err->msg_parm.i[6], err->msg_parm.i[7]);
  197|  3.15k|}
jerror.c:reset_error_mgr:
  210|  2.27k|{
  211|  2.27k|  cinfo->err->num_warnings = 0;
  212|       |  /* trace_level is not reset since it is an application-supplied parameter */
  213|  2.27k|  cinfo->err->msg_code = 0;     /* may be useful as a flag for "no error" */
  214|  2.27k|}

jmemmgr.c:GETENV_S:
   80|  1.15k|{
   81|  1.15k|  char *env;
   82|       |
   83|  1.15k|  if (!buffer) {
  ------------------
  |  Branch (83:7): [True: 0, False: 1.15k]
  ------------------
   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|  1.15k|  if (buffer_size == 0)
  ------------------
  |  Branch (89:7): [True: 0, False: 1.15k]
  ------------------
   90|      0|    return (errno = EINVAL);
   91|  1.15k|  if (!name) {
  ------------------
  |  Branch (91:7): [True: 0, False: 1.15k]
  ------------------
   92|      0|    *buffer = 0;
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  1.15k|  env = getenv(name);
   97|  1.15k|  if (!env)
  ------------------
  |  Branch (97:7): [True: 1.15k, False: 0]
  ------------------
   98|  1.15k|  {
   99|  1.15k|    *buffer = 0;
  100|  1.15k|    return 0;
  101|  1.15k|  }
  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|  2.66k|{
   81|  2.66k|  char *env;
   82|       |
   83|  2.66k|  if (!buffer) {
  ------------------
  |  Branch (83:7): [True: 0, False: 2.66k]
  ------------------
   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|  2.66k|  if (buffer_size == 0)
  ------------------
  |  Branch (89:7): [True: 0, False: 2.66k]
  ------------------
   90|      0|    return (errno = EINVAL);
   91|  2.66k|  if (!name) {
  ------------------
  |  Branch (91:7): [True: 0, False: 2.66k]
  ------------------
   92|      0|    *buffer = 0;
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  2.66k|  env = getenv(name);
   97|  2.66k|  if (!env)
  ------------------
  |  Branch (97:7): [True: 2.66k, False: 0]
  ------------------
   98|  2.66k|  {
   99|  2.66k|    *buffer = 0;
  100|  2.66k|    return 0;
  101|  2.66k|  }
  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|  1.15k|{
 1197|  1.15k|  my_mem_ptr mem;
 1198|  1.15k|  long max_to_use;
 1199|  1.15k|  int pool;
 1200|  1.15k|  size_t test_mac;
 1201|       |
 1202|  1.15k|  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|  1.15k|  if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  1.15k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  1.15k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (1211:7): [Folded, False: 1.15k]
  ------------------
 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|  1.15k|  test_mac = (size_t)MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  1.15k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1219|  1.15k|  if ((long)test_mac != MAX_ALLOC_CHUNK ||
  ------------------
  |  |   62|  2.31k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (1219:7): [True: 0, False: 1.15k]
  ------------------
 1220|  1.15k|      (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   62|  1.15k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
                    (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|  1.15k|#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|  1.15k|  max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
 1224|       |
 1225|       |  /* Attempt to allocate memory manager's control block */
 1226|  1.15k|  mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
 1227|       |
 1228|  1.15k|  if (mem == NULL) {
  ------------------
  |  Branch (1228:7): [True: 0, False: 1.15k]
  ------------------
 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|  1.15k|  mem->pub.alloc_small = alloc_small;
 1235|  1.15k|  mem->pub.alloc_large = alloc_large;
 1236|  1.15k|  mem->pub.alloc_sarray = alloc_sarray;
 1237|  1.15k|  mem->pub.alloc_barray = alloc_barray;
 1238|  1.15k|  mem->pub.request_virt_sarray = request_virt_sarray;
 1239|  1.15k|  mem->pub.request_virt_barray = request_virt_barray;
 1240|  1.15k|  mem->pub.realize_virt_arrays = realize_virt_arrays;
 1241|  1.15k|  mem->pub.access_virt_sarray = access_virt_sarray;
 1242|  1.15k|  mem->pub.access_virt_barray = access_virt_barray;
 1243|  1.15k|  mem->pub.free_pool = free_pool;
 1244|  1.15k|  mem->pub.self_destruct = self_destruct;
 1245|       |
 1246|       |  /* Make MAX_ALLOC_CHUNK accessible to other modules */
 1247|  1.15k|  mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  1.15k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1248|       |
 1249|       |  /* Initialize working state */
 1250|  1.15k|  mem->pub.max_memory_to_use = max_to_use;
 1251|       |
 1252|  3.46k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  1.15k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|  3.46k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1252:35): [True: 2.31k, False: 1.15k]
  ------------------
 1253|  2.31k|    mem->small_list[pool] = NULL;
 1254|  2.31k|    mem->large_list[pool] = NULL;
 1255|  2.31k|  }
 1256|  1.15k|  mem->virt_sarray_list = NULL;
 1257|  1.15k|  mem->virt_barray_list = NULL;
 1258|       |
 1259|  1.15k|  mem->total_space_allocated = sizeof(my_memory_mgr);
 1260|       |
 1261|       |  /* Declare ourselves open for business */
 1262|  1.15k|  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|  1.15k|#ifndef NO_GETENV
 1271|  1.15k|  {
 1272|  1.15k|    char memenv[30] = { 0 };
 1273|       |
 1274|  1.15k|    if (!GETENV_S(memenv, 30, "JPEGMEM") && strlen(memenv) > 0) {
  ------------------
  |  Branch (1274:9): [True: 1.15k, False: 0]
  |  Branch (1274:45): [True: 0, False: 1.15k]
  ------------------
 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|  1.15k|  }
 1288|  1.15k|#endif
 1289|       |
 1290|  1.15k|}
jmemmgr.c:alloc_small:
  269|  22.2k|{
  270|  22.2k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  271|  22.2k|  small_pool_ptr hdr_ptr, prev_hdr_ptr;
  272|  22.2k|  char *data_ptr;
  273|  22.2k|  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|  22.2k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|  22.2k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (281:7): [True: 0, False: 22.2k]
  ------------------
  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|  22.2k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|  22.2k|#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|  22.2k|  if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|  22.2k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (289:7): [True: 0, False: 22.2k]
  ------------------
  290|  22.2k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|  22.2k|#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|  22.2k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|  22.2k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (294:7): [True: 0, False: 22.2k]
  |  Branch (294:22): [True: 0, False: 22.2k]
  ------------------
  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|  22.2k|  prev_hdr_ptr = NULL;
  297|  22.2k|  hdr_ptr = mem->small_list[pool_id];
  298|  22.2k|  while (hdr_ptr != NULL) {
  ------------------
  |  Branch (298:10): [True: 20.0k, False: 2.23k]
  ------------------
  299|  20.0k|    if (hdr_ptr->bytes_left >= sizeofobject)
  ------------------
  |  Branch (299:9): [True: 19.9k, False: 32]
  ------------------
  300|  19.9k|      break;                    /* found pool with enough space */
  301|     32|    prev_hdr_ptr = hdr_ptr;
  302|     32|    hdr_ptr = hdr_ptr->next;
  303|     32|  }
  304|       |
  305|       |  /* Time to make a new pool? */
  306|  22.2k|  if (hdr_ptr == NULL) {
  ------------------
  |  Branch (306:7): [True: 2.23k, False: 19.9k]
  ------------------
  307|       |    /* min_request is what we need now, slop is what will be leftover */
  308|  2.23k|    min_request = sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  2.23k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  309|  2.23k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (309:9): [True: 2.20k, False: 32]
  ------------------
  310|  2.20k|      slop = first_pool_slop[pool_id];
  311|     32|    else
  312|     32|      slop = extra_pool_slop[pool_id];
  313|       |    /* Don't ask for more than MAX_ALLOC_CHUNK */
  314|  2.23k|    if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
  ------------------
  |  |   62|  2.23k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (314:9): [True: 0, False: 2.23k]
  ------------------
  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|  2.23k|    for (;;) {
  318|  2.23k|      hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
  319|  2.23k|      if (hdr_ptr != NULL)
  ------------------
  |  Branch (319:11): [True: 2.23k, False: 0]
  ------------------
  320|  2.23k|        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|  2.23k|    mem->total_space_allocated += min_request + slop;
  326|       |    /* Success, initialize the new pool header and add to end of list */
  327|  2.23k|    hdr_ptr->next = NULL;
  328|  2.23k|    hdr_ptr->bytes_used = 0;
  329|  2.23k|    hdr_ptr->bytes_left = sizeofobject + slop;
  330|  2.23k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (330:9): [True: 2.20k, False: 32]
  ------------------
  331|  2.20k|      mem->small_list[pool_id] = hdr_ptr;
  332|     32|    else
  333|     32|      prev_hdr_ptr->next = hdr_ptr;
  334|  2.23k|  }
  335|       |
  336|       |  /* OK, allocate the object from the current pool */
  337|  22.2k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  338|  22.2k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  339|  22.2k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|  22.2k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (339:7): [True: 22.2k, False: 0]
  ------------------
  340|  22.2k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  22.2k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  22.2k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  341|  22.2k|  data_ptr += hdr_ptr->bytes_used; /* point to place for object */
  342|  22.2k|  hdr_ptr->bytes_used += sizeofobject;
  343|  22.2k|  hdr_ptr->bytes_left -= sizeofobject;
  344|       |
  345|  22.2k|  return (void *)data_ptr;
  346|  22.2k|}
jmemmgr.c:round_up_pow2:
   45|  25.1k|{
   46|  25.1k|  return ((a + b - 1) & (~(b - 1)));
   47|  25.1k|}
jmemmgr.c:alloc_large:
  366|  1.97k|{
  367|  1.97k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  368|  1.97k|  large_pool_ptr hdr_ptr;
  369|  1.97k|  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|  1.97k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|  1.97k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (376:7): [True: 0, False: 1.97k]
  ------------------
  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|  1.97k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|  1.97k|#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|  1.97k|  if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (384:7): [True: 0, False: 1.97k]
  ------------------
  385|  1.97k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|  1.97k|#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|  1.97k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|  1.97k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (389:7): [True: 0, False: 1.97k]
  |  Branch (389:22): [True: 0, False: 1.97k]
  ------------------
  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|  1.97k|  hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
  393|  1.97k|                                           sizeof(large_pool_hdr) +
  394|  1.97k|                                           ALIGN_SIZE - 1);
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  395|  1.97k|  if (hdr_ptr == NULL)
  ------------------
  |  Branch (395:7): [True: 0, False: 1.97k]
  ------------------
  396|      0|    out_of_memory(cinfo, 4);    /* jpeg_get_large failed */
  397|  1.97k|  mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
  398|  1.97k|                                ALIGN_SIZE - 1;
  ------------------
  |  |   89|  1.97k|#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|  1.97k|  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|  1.97k|  hdr_ptr->bytes_used = sizeofobject;
  406|  1.97k|  hdr_ptr->bytes_left = 0;
  407|  1.97k|  mem->large_list[pool_id] = hdr_ptr;
  408|       |
  409|  1.97k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  410|  1.97k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  411|  1.97k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (411:7): [True: 1.97k, False: 0]
  ------------------
  412|  1.97k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  413|       |
  414|  1.97k|  return (void *)data_ptr;
  415|  1.97k|}
jmemmgr.c:alloc_sarray:
  438|    987|{
  439|    987|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  440|    987|  JSAMPARRAY result;
  441|    987|  JSAMPROW workspace;
  442|    987|  JDIMENSION rowsperchunk, currow, i;
  443|    987|  long ltemp;
  444|    987|  J12SAMPARRAY result12;
  445|    987|  J12SAMPROW workspace12;
  446|    987|#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
  447|    987|  J16SAMPARRAY result16;
  448|    987|  J16SAMPROW workspace16;
  449|    987|#endif
  450|    987|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (450:24): [True: 987, False: 0]
  ------------------
  451|    987|                        ((j_decompress_ptr)cinfo)->data_precision :
  452|    987|                        ((j_compress_ptr)cinfo)->data_precision;
  453|    987|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (453:24): [True: 0, False: 987]
  ------------------
  454|    987|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (454:45): [True: 96, False: 891]
  ------------------
  455|     96|                                            sizeof(J12SAMPLE) :
  456|    987|                                            sizeof(JSAMPLE));
  457|       |
  458|       |  /* Make sure each row is properly aligned */
  459|    987|  if ((ALIGN_SIZE % sample_size) != 0)
  ------------------
  |  |   89|    987|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (459:7): [True: 0, False: 987]
  ------------------
  460|      0|    out_of_memory(cinfo, 5);    /* safety check */
  461|       |
  462|    987|  if (samplesperrow == 0 || samplesperrow > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|    987|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (462:7): [True: 0, False: 987]
  |  Branch (462:29): [True: 0, False: 987]
  ------------------
  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|    987|  samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
  ------------------
  |  |   89|    987|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  468|    987|                                                           sample_size);
  469|       |
  470|       |  /* Calculate max # of rows allowed in one allocation chunk */
  471|    987|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|    987|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  472|    987|          ((long)samplesperrow * (long)sample_size);
  473|    987|  if (ltemp <= 0)
  ------------------
  |  Branch (473:7): [True: 0, False: 987]
  ------------------
  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|    987|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (475:7): [True: 0, False: 987]
  ------------------
  476|      0|    rowsperchunk = (JDIMENSION)ltemp;
  477|    987|  else
  478|    987|    rowsperchunk = numrows;
  479|    987|  mem->last_rowsperchunk = rowsperchunk;
  480|       |
  481|    987|  if (data_precision <= 8) {
  ------------------
  |  Branch (481:7): [True: 891, False: 96]
  ------------------
  482|       |    /* Get space for row pointers (small object) */
  483|    891|    result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
  484|    891|                                     (size_t)(numrows * sizeof(JSAMPROW)));
  485|       |
  486|       |    /* Get the rows themselves (large objects) */
  487|    891|    currow = 0;
  488|  1.78k|    while (currow < numrows) {
  ------------------
  |  Branch (488:12): [True: 891, False: 891]
  ------------------
  489|    891|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|    891|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 891]
  |  |  ------------------
  ------------------
  490|    891|      workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
  491|    891|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  492|  8.21k|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (492:30): [True: 7.32k, False: 891]
  ------------------
  493|  7.32k|        result[currow++] = workspace;
  494|  7.32k|        workspace += samplesperrow;
  495|  7.32k|      }
  496|    891|    }
  497|       |
  498|    891|    return result;
  499|    891|  } else if (data_precision <= 12) {
  ------------------
  |  Branch (499:14): [True: 96, False: 0]
  ------------------
  500|       |    /* Get space for row pointers (small object) */
  501|     96|    result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
  502|     96|                                         (size_t)(numrows *
  503|     96|                                                  sizeof(J12SAMPROW)));
  504|       |
  505|       |    /* Get the rows themselves (large objects) */
  506|     96|    currow = 0;
  507|    192|    while (currow < numrows) {
  ------------------
  |  Branch (507:12): [True: 96, False: 96]
  ------------------
  508|     96|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|     96|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 96]
  |  |  ------------------
  ------------------
  509|     96|      workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
  510|     96|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  511|    864|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (511:30): [True: 768, False: 96]
  ------------------
  512|    768|        result12[currow++] = workspace12;
  513|    768|        workspace12 += samplesperrow;
  514|    768|      }
  515|     96|    }
  516|       |
  517|     96|    return (JSAMPARRAY)result12;
  518|     96|  } 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|    987|}
jmemmgr.c:alloc_barray:
  555|     96|{
  556|     96|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  557|     96|  JBLOCKARRAY result;
  558|     96|  JBLOCKROW workspace;
  559|     96|  JDIMENSION rowsperchunk, currow, i;
  560|     96|  long ltemp;
  561|       |
  562|       |  /* Make sure each row is properly aligned */
  563|     96|  if (blocksperrow == 0 || (sizeof(JBLOCK) % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|     96|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (563:7): [True: 0, False: 96]
  |  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|     96|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|     96|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  568|     96|          ((long)blocksperrow * sizeof(JBLOCK));
  569|     96|  if (ltemp <= 0)
  ------------------
  |  Branch (569:7): [True: 0, False: 96]
  ------------------
  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|     96|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (571:7): [True: 0, False: 96]
  ------------------
  572|      0|    rowsperchunk = (JDIMENSION)ltemp;
  573|     96|  else
  574|     96|    rowsperchunk = numrows;
  575|     96|  mem->last_rowsperchunk = rowsperchunk;
  576|       |
  577|       |  /* Get space for row pointers (small object) */
  578|     96|  result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
  579|     96|                                    (size_t)(numrows * sizeof(JBLOCKROW)));
  580|       |
  581|       |  /* Get the rows themselves (large objects) */
  582|     96|  currow = 0;
  583|    192|  while (currow < numrows) {
  ------------------
  |  Branch (583:10): [True: 96, False: 96]
  ------------------
  584|     96|    rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|     96|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 96]
  |  |  ------------------
  ------------------
  585|     96|    workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
  586|     96|        (size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
  587|     96|                  sizeof(JBLOCK)));
  588|    192|    for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (588:28): [True: 96, False: 96]
  ------------------
  589|     96|      result[currow++] = workspace;
  590|     96|      workspace += blocksperrow;
  591|     96|    }
  592|     96|  }
  593|       |
  594|     96|  return result;
  595|     96|}
jmemmgr.c:request_virt_barray:
  670|     96|{
  671|     96|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  672|     96|  jvirt_barray_ptr result;
  673|       |
  674|       |  /* Only IMAGE-lifetime virtual arrays are currently supported */
  675|     96|  if (pool_id != JPOOL_IMAGE)
  ------------------
  |  |  889|     96|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (675:7): [True: 0, False: 96]
  ------------------
  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|     96|  result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
  680|     96|                                         sizeof(struct jvirt_barray_control));
  681|       |
  682|     96|  result->mem_buffer = NULL;    /* marks array not yet realized */
  683|     96|  result->rows_in_array = numrows;
  684|     96|  result->blocksperrow = blocksperrow;
  685|     96|  result->maxaccess = maxaccess;
  686|     96|  result->pre_zero = pre_zero;
  687|     96|  result->b_s_open = FALSE;     /* no associated backing-store object */
  ------------------
  |  |  207|     96|#define FALSE   0               /* values of boolean */
  ------------------
  688|     96|  result->next = mem->virt_barray_list; /* add to list of virtual arrays */
  689|     96|  mem->virt_barray_list = result;
  690|       |
  691|     96|  return result;
  692|     96|}
jmemmgr.c:realize_virt_arrays:
  698|    923|{
  699|    923|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  700|    923|  size_t space_per_minheight, maximum_space, avail_mem;
  701|    923|  size_t minheights, max_minheights;
  702|    923|  jvirt_sarray_ptr sptr;
  703|    923|  jvirt_barray_ptr bptr;
  704|    923|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (704:24): [True: 923, False: 0]
  ------------------
  705|    923|                        ((j_decompress_ptr)cinfo)->data_precision :
  706|    923|                        ((j_compress_ptr)cinfo)->data_precision;
  707|    923|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (707:24): [True: 0, False: 923]
  ------------------
  708|    923|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (708:45): [True: 32, False: 891]
  ------------------
  709|     32|                                            sizeof(J12SAMPLE) :
  710|    923|                                            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|    923|  space_per_minheight = 0;
  717|    923|  maximum_space = 0;
  718|    923|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (718:38): [True: 0, False: 923]
  ------------------
  719|      0|    if (sptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (719:9): [True: 0, False: 0]
  ------------------
  720|      0|      size_t new_space = (size_t)sptr->rows_in_array *
  721|      0|                         (size_t)sptr->samplesperrow * sample_size;
  722|       |
  723|      0|      space_per_minheight += (size_t)sptr->maxaccess *
  724|      0|                             (size_t)sptr->samplesperrow * sample_size;
  725|      0|      if (SIZE_MAX - maximum_space < new_space)
  ------------------
  |  Branch (725:11): [True: 0, False: 0]
  ------------------
  726|      0|        out_of_memory(cinfo, 10);
  727|      0|      maximum_space += new_space;
  728|      0|    }
  729|      0|  }
  730|  1.01k|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (730:38): [True: 96, False: 923]
  ------------------
  731|     96|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (731:9): [True: 96, False: 0]
  ------------------
  732|     96|      size_t new_space = (size_t)bptr->rows_in_array *
  733|     96|                         (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  734|       |
  735|     96|      space_per_minheight += (size_t)bptr->maxaccess *
  736|     96|                             (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  737|     96|      if (SIZE_MAX - maximum_space < new_space)
  ------------------
  |  Branch (737:11): [True: 0, False: 96]
  ------------------
  738|      0|        out_of_memory(cinfo, 11);
  739|     96|      maximum_space += new_space;
  740|     96|    }
  741|     96|  }
  742|       |
  743|    923|  if (space_per_minheight <= 0)
  ------------------
  |  Branch (743:7): [True: 891, False: 32]
  ------------------
  744|    891|    return;                     /* no unrealized arrays, no work */
  745|       |
  746|       |  /* Determine amount of memory to actually use; this is system-dependent. */
  747|     32|  avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
  748|     32|                                 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|     32|  if (avail_mem >= maximum_space)
  ------------------
  |  Branch (754:7): [True: 32, False: 0]
  ------------------
  755|     32|    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|     32|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (767:38): [True: 0, False: 32]
  ------------------
  768|      0|    if (sptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (768:9): [True: 0, False: 0]
  ------------------
  769|      0|      minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
  770|      0|      if (minheights <= max_minheights) {
  ------------------
  |  Branch (770:11): [True: 0, False: 0]
  ------------------
  771|       |        /* This buffer fits in memory */
  772|      0|        sptr->rows_in_mem = sptr->rows_in_array;
  773|      0|      } 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|      0|      sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  783|      0|                                      sptr->samplesperrow, sptr->rows_in_mem);
  784|      0|      sptr->rowsperchunk = mem->last_rowsperchunk;
  785|      0|      sptr->cur_start_row = 0;
  786|      0|      sptr->first_undef_row = 0;
  787|      0|      sptr->dirty = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  788|      0|    }
  789|      0|  }
  790|       |
  791|    128|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (791:38): [True: 96, False: 32]
  ------------------
  792|     96|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (792:9): [True: 96, False: 0]
  ------------------
  793|     96|      minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
  794|     96|      if (minheights <= max_minheights) {
  ------------------
  |  Branch (794:11): [True: 96, False: 0]
  ------------------
  795|       |        /* This buffer fits in memory */
  796|     96|        bptr->rows_in_mem = bptr->rows_in_array;
  797|     96|      } 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|     96|      bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     96|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  807|     96|                                      bptr->blocksperrow, bptr->rows_in_mem);
  808|     96|      bptr->rowsperchunk = mem->last_rowsperchunk;
  809|     96|      bptr->cur_start_row = 0;
  810|     96|      bptr->first_undef_row = 0;
  811|     96|      bptr->dirty = FALSE;
  ------------------
  |  |  207|     96|#define FALSE   0               /* values of boolean */
  ------------------
  812|     96|    }
  813|     96|  }
  814|     32|}
jmemmgr.c:free_pool:
 1099|  4.97k|{
 1100|  4.97k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
 1101|  4.97k|  small_pool_ptr shdr_ptr;
 1102|  4.97k|  large_pool_ptr lhdr_ptr;
 1103|  4.97k|  size_t space_freed;
 1104|       |
 1105|  4.97k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|  4.97k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (1105:7): [True: 0, False: 4.97k]
  |  Branch (1105:22): [True: 0, False: 4.97k]
  ------------------
 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|  4.97k|  if (pool_id == JPOOL_IMAGE) {
  ------------------
  |  |  889|  4.97k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (1114:7): [True: 3.81k, False: 1.15k]
  ------------------
 1115|  3.81k|    jvirt_sarray_ptr sptr;
 1116|  3.81k|    jvirt_barray_ptr bptr;
 1117|       |
 1118|  3.81k|    for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (1118:40): [True: 0, False: 3.81k]
  ------------------
 1119|      0|      if (sptr->b_s_open) {     /* there may be no backing store */
  ------------------
  |  Branch (1119:11): [True: 0, False: 0]
  ------------------
 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|      0|    }
 1124|  3.81k|    mem->virt_sarray_list = NULL;
 1125|  3.91k|    for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (1125:40): [True: 96, False: 3.81k]
  ------------------
 1126|     96|      if (bptr->b_s_open) {     /* there may be no backing store */
  ------------------
  |  Branch (1126:11): [True: 0, False: 96]
  ------------------
 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|     96|    }
 1131|  3.81k|    mem->virt_barray_list = NULL;
 1132|  3.81k|  }
 1133|       |
 1134|       |  /* Release large objects */
 1135|  4.97k|  lhdr_ptr = mem->large_list[pool_id];
 1136|  4.97k|  mem->large_list[pool_id] = NULL;
 1137|       |
 1138|  6.94k|  while (lhdr_ptr != NULL) {
  ------------------
  |  Branch (1138:10): [True: 1.97k, False: 4.97k]
  ------------------
 1139|  1.97k|    large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
 1140|  1.97k|    space_freed = lhdr_ptr->bytes_used +
 1141|  1.97k|                  lhdr_ptr->bytes_left +
 1142|  1.97k|                  sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  1.97k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1143|  1.97k|    jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
 1144|  1.97k|    mem->total_space_allocated -= space_freed;
 1145|  1.97k|    lhdr_ptr = next_lhdr_ptr;
 1146|  1.97k|  }
 1147|       |
 1148|       |  /* Release small objects */
 1149|  4.97k|  shdr_ptr = mem->small_list[pool_id];
 1150|  4.97k|  mem->small_list[pool_id] = NULL;
 1151|       |
 1152|  7.20k|  while (shdr_ptr != NULL) {
  ------------------
  |  Branch (1152:10): [True: 2.23k, False: 4.97k]
  ------------------
 1153|  2.23k|    small_pool_ptr next_shdr_ptr = shdr_ptr->next;
 1154|  2.23k|    space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
 1155|  2.23k|                  sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|  2.23k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1156|  2.23k|    jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
 1157|  2.23k|    mem->total_space_allocated -= space_freed;
 1158|  2.23k|    shdr_ptr = next_shdr_ptr;
 1159|  2.23k|  }
 1160|  4.97k|}
jmemmgr.c:self_destruct:
 1170|  1.15k|{
 1171|  1.15k|  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|  3.46k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  1.15k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|  3.46k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1177:35): [True: 2.31k, False: 1.15k]
  ------------------
 1178|  2.31k|    free_pool(cinfo, pool);
 1179|  2.31k|  }
 1180|       |
 1181|       |  /* Release the memory manager control block too. */
 1182|  1.15k|  jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
 1183|  1.15k|  cinfo->mem = NULL;            /* ensures I will be called only once */
 1184|       |
 1185|  1.15k|  jpeg_mem_term(cinfo);         /* system-dependent cleanup */
 1186|  1.15k|}

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

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

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

handle_error:
   45|   109k|{
   46|   109k|    return;
   47|   109k|}
LLVMFuzzerTestOneInput:
  125|    402|{
  126|    402|#ifndef STANDALONE
  127|    402|    TIFFSetErrorHandler(handle_error);
  128|    402|    TIFFSetWarningHandler(handle_error);
  129|    402|#endif
  130|    402|#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|    402|#endif
  138|    402|    std::istringstream s(std::string(Data, Data + Size));
  139|    402|    TIFF *tif = TIFFStreamOpen("MemTIFF", &s);
  140|    402|    if (!tif)
  ------------------
  |  Branch (140:9): [True: 35, False: 367]
  ------------------
  141|     35|    {
  142|     35|        return 0;
  143|     35|    }
  144|       |
  145|    367|    int dirs = 0;
  146|    367|    do
  147|    598|    {
  148|    598|        if (++dirs > MAX_DIRS)
  ------------------
  |  Branch (148:13): [True: 0, False: 598]
  ------------------
  149|      0|        {
  150|      0|            break;
  151|      0|        }
  152|       |
  153|    598|        read_striles(tif);
  154|       |
  155|    598|        uint32_t w = 0, h = 0;
  156|    598|        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
  ------------------
  |  |  178|    598|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  157|    598|        TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
  ------------------
  |  |  179|    598|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  158|    598|        uint32_t size = __TIFFSafeMultiply(uint32_t, w, h);
  ------------------
  |  |   35|    598|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 598, False: 0]
  |  |  |  Branch (35:27): [True: 593, False: 5]
  |  |  ------------------
  |  |   36|    598|         ? (t)((v) * (m))                                                      \
  |  |   37|    598|         : (t)0)
  ------------------
  159|    598|        if (size != 0 && size <= MAX_SIZE)
  ------------------
  |  Branch (159:13): [True: 593, False: 5]
  |  Branch (159:26): [True: 593, False: 0]
  ------------------
  160|    593|        {
  161|    593|            uint32_t *raster =
  162|    593|                (uint32_t *)_TIFFmalloc(size * sizeof(uint32_t));
  163|    593|            if (raster != NULL)
  ------------------
  |  Branch (163:17): [True: 593, False: 0]
  ------------------
  164|    593|            {
  165|    593|                TIFFReadRGBAImageOriented(tif, w, h, raster,
  166|    593|                                          ORIENTATION_TOPLEFT, 0);
  ------------------
  |  |  249|    593|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  167|    593|                _TIFFfree(raster);
  168|    593|            }
  169|    593|        }
  170|    598|    } while (TIFFReadDirectory(tif));
  ------------------
  |  Branch (170:14): [True: 231, False: 367]
  ------------------
  171|       |
  172|    367|    TIFFClose(tif);
  173|    367|    return 0;
  174|    402|}
tiff_decode_fuzzer.cc:_ZL12read_strilesP4tiff:
   50|    598|{
   51|    598|    if (TIFFIsTiled(tif))
  ------------------
  |  Branch (51:9): [True: 70, False: 528]
  ------------------
   52|     70|    {
   53|       |        /* another hack to work around an OOM in tif_fax3.c */
   54|     70|        uint32_t tilewidth = 0;
   55|     70|        uint32_t imagewidth = 0;
   56|     70|        TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth);
  ------------------
  |  |  311|     70|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
   57|     70|        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth);
  ------------------
  |  |  178|     70|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
   58|     70|        tilewidth = __TIFFSafeMultiply(uint32_t, tilewidth, 2);
  ------------------
  |  |   35|     70|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 70, Folded]
  |  |  |  Branch (35:27): [True: 70, False: 0]
  |  |  ------------------
  |  |   36|     70|         ? (t)((v) * (m))                                                      \
  |  |   37|     70|         : (t)0)
  ------------------
   59|     70|        imagewidth = __TIFFSafeMultiply(uint32_t, imagewidth, 2);
  ------------------
  |  |   35|     70|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 70, Folded]
  |  |  |  Branch (35:27): [True: 70, False: 0]
  |  |  ------------------
  |  |   36|     70|         ? (t)((v) * (m))                                                      \
  |  |   37|     70|         : (t)0)
  ------------------
   60|     70|        if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE ||
  ------------------
  |  Branch (60:13): [True: 0, False: 70]
  |  Branch (60:41): [True: 0, False: 70]
  ------------------
   61|     70|            tilewidth == 0 || imagewidth == 0)
  ------------------
  |  Branch (61:13): [True: 0, False: 70]
  |  Branch (61:31): [True: 0, False: 70]
  ------------------
   62|      0|        {
   63|      0|            return;
   64|      0|        }
   65|       |
   66|     70|        tmsize_t tilesize = TIFFTileSize(tif);
   67|     70|        if (tilesize <= 0 || (uint64_t)tilesize > MAX_SIZE)
  ------------------
  |  Branch (67:13): [True: 0, False: 70]
  |  Branch (67:30): [True: 2, False: 68]
  ------------------
   68|      2|        {
   69|      2|            return;
   70|      2|        }
   71|     68|        void *buf = _TIFFmalloc(tilesize);
   72|     68|        if (buf == NULL)
  ------------------
  |  Branch (72:13): [True: 0, False: 68]
  ------------------
   73|      0|        {
   74|      0|            return;
   75|      0|        }
   76|     68|        uint32_t ntiles = TIFFNumberOfTiles(tif);
   77|     68|        if (ntiles > MAX_STRILES)
  ------------------
  |  Branch (77:13): [True: 3, False: 65]
  ------------------
   78|      3|        {
   79|      3|            ntiles = MAX_STRILES;
   80|      3|        }
   81|  14.1k|        for (uint32_t tile = 0; tile < ntiles; tile++)
  ------------------
  |  Branch (81:33): [True: 14.0k, False: 68]
  ------------------
   82|  14.0k|        {
   83|  14.0k|            TIFFReadEncodedTile(tif, tile, buf, (tmsize_t)-1);
   84|  14.0k|        }
   85|     68|        _TIFFfree(buf);
   86|     68|    }
   87|    528|    else
   88|    528|    {
   89|       |        // check the size of the non-tiled image
   90|    528|        uint32_t rowsize = 0;
   91|    528|        TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsize);
  ------------------
  |  |  258|    528|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
   92|    528|        uint32_t stripbytes = TIFFStripSize(tif);
   93|    528|        rowsize = __TIFFSafeMultiply(uint32_t, rowsize, 2);
  ------------------
  |  |   35|    528|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 528, Folded]
  |  |  |  Branch (35:27): [True: 528, False: 0]
  |  |  ------------------
  |  |   36|    528|         ? (t)((v) * (m))                                                      \
  |  |   37|    528|         : (t)0)
  ------------------
   94|    528|        stripbytes = __TIFFSafeMultiply(uint32_t, stripbytes, 2);
  ------------------
  |  |   35|    528|    ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v)))                \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 528, Folded]
  |  |  |  Branch (35:27): [True: 527, False: 1]
  |  |  ------------------
  |  |   36|    528|         ? (t)((v) * (m))                                                      \
  |  |   37|    528|         : (t)0)
  ------------------
   95|    528|        if (rowsize * 2 > MAX_SIZE || stripbytes * 2 > MAX_SIZE ||
  ------------------
  |  Branch (95:13): [True: 0, False: 528]
  |  Branch (95:39): [True: 39, False: 489]
  ------------------
   96|    489|            rowsize == 0 || stripbytes == 0)
  ------------------
  |  Branch (96:13): [True: 215, False: 274]
  |  Branch (96:29): [True: 0, False: 274]
  ------------------
   97|    254|        {
   98|    254|            return;
   99|    254|        }
  100|       |
  101|    274|        tmsize_t stripsize = TIFFStripSize(tif);
  102|    274|        if (stripsize <= 0 || (uint64_t)stripsize > MAX_SIZE)
  ------------------
  |  Branch (102:13): [True: 0, False: 274]
  |  Branch (102:31): [True: 0, False: 274]
  ------------------
  103|      0|        {
  104|      0|            return;
  105|      0|        }
  106|    274|        void *buf = _TIFFmalloc(stripsize);
  107|    274|        if (buf == NULL)
  ------------------
  |  Branch (107:13): [True: 0, False: 274]
  ------------------
  108|      0|        {
  109|      0|            return;
  110|      0|        }
  111|    274|        uint32_t nstrips = TIFFNumberOfStrips(tif);
  112|    274|        if (nstrips > MAX_STRILES)
  ------------------
  |  Branch (112:13): [True: 0, False: 274]
  ------------------
  113|      0|        {
  114|      0|            nstrips = MAX_STRILES;
  115|      0|        }
  116|  6.48k|        for (uint32_t strip = 0; strip < nstrips; strip++)
  ------------------
  |  Branch (116:34): [True: 6.21k, False: 274]
  ------------------
  117|  6.21k|        {
  118|  6.21k|            TIFFReadEncodedStrip(tif, strip, buf, (tmsize_t)-1);
  119|  6.21k|        }
  120|    274|        _TIFFfree(buf);
  121|    274|    }
  122|    598|}

_TIFFMultiply32:
   37|  17.4k|{
   38|  17.4k|    if (second && first > UINT32_MAX / second)
  ------------------
  |  Branch (38:9): [True: 17.4k, False: 0]
  |  Branch (38:19): [True: 0, False: 17.4k]
  ------------------
   39|      0|    {
   40|      0|        TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   41|      0|        return 0;
   42|      0|    }
   43|       |
   44|  17.4k|    return first * second;
   45|  17.4k|}
_TIFFMultiply64:
   49|  47.5k|{
   50|  47.5k|    if (second && first > UINT64_MAX / second)
  ------------------
  |  Branch (50:9): [True: 45.3k, False: 2.14k]
  |  Branch (50:19): [True: 0, False: 45.3k]
  ------------------
   51|      0|    {
   52|      0|        TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
   53|      0|        return 0;
   54|      0|    }
   55|       |
   56|  47.5k|    return first * second;
   57|  47.5k|}
_TIFFAdd64:
   61|  2.66k|{
   62|  2.66k|    if (first > UINT64_MAX - second)
  ------------------
  |  Branch (62:9): [True: 0, False: 2.66k]
  ------------------
   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|  2.66k|    return first + second;
   72|  2.66k|}
_TIFFMultiplySSize:
   76|  38.2k|{
   77|  38.2k|    if (first <= 0 || second <= 0)
  ------------------
  |  Branch (77:9): [True: 24, False: 38.1k]
  |  Branch (77:23): [True: 0, False: 38.1k]
  ------------------
   78|     24|    {
   79|     24|        if (tif != NULL && where != NULL)
  ------------------
  |  Branch (79:13): [True: 24, False: 0]
  |  Branch (79:28): [True: 0, False: 24]
  ------------------
   80|      0|        {
   81|      0|            TIFFErrorExtR(tif, where,
   82|      0|                          "Invalid argument to _TIFFMultiplySSize() in %s",
   83|      0|                          where);
   84|      0|        }
   85|     24|        return 0;
   86|     24|    }
   87|       |
   88|  38.1k|    if (first > TIFF_TMSIZE_T_MAX / second)
  ------------------
  |  |   68|  38.1k|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (88:9): [True: 0, False: 38.1k]
  ------------------
   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|  38.1k|    return first * second;
   97|  38.1k|}
_TIFFCastUInt64ToSSize:
  124|  14.8k|{
  125|  14.8k|    if (val > (uint64_t)TIFF_TMSIZE_T_MAX)
  ------------------
  |  |   68|  14.8k|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (125:9): [True: 0, False: 14.8k]
  ------------------
  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|  14.8k|    return (tmsize_t)val;
  134|  14.8k|}
_TIFFCastUInt64ToUInt32:
  137|    894|{
  138|    894|    if (val > UINT32_MAX)
  ------------------
  |  Branch (138:9): [True: 0, False: 894]
  ------------------
  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|    894|    return (uint32_t)val;
  147|    894|}
_TIFFCheckRealloc:
  187|  37.1k|{
  188|  37.1k|    void *cp = NULL;
  189|  37.1k|    tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
  190|       |    /*
  191|       |     * Check for integer overflow.
  192|       |     */
  193|  37.1k|    if (count != 0)
  ------------------
  |  Branch (193:9): [True: 37.1k, False: 24]
  ------------------
  194|  37.1k|    {
  195|  37.1k|        cp = _TIFFreallocExt(tif, buffer, count);
  196|  37.1k|    }
  197|       |
  198|  37.1k|    if (cp == NULL)
  ------------------
  |  Branch (198:9): [True: 24, False: 37.1k]
  ------------------
  199|     24|    {
  200|     24|        TIFFErrorExtR(tif, tif->tif_name,
  201|     24|                      "Failed to allocate memory for %s "
  202|     24|                      "(%" TIFF_SSIZE_FORMAT " elements of %" TIFF_SSIZE_FORMAT
  203|     24|                      " bytes each)",
  204|     24|                      what, nmemb, elem_size);
  205|     24|    }
  206|       |
  207|  37.1k|    return cp;
  208|  37.1k|}
_TIFFCheckMalloc:
  212|  6.16k|{
  213|       |    return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
  214|  6.16k|}
TIFFVGetFieldDefaulted:
  309|  7.48k|{
  310|  7.48k|    TIFFDirectory *td = &tif->tif_dir;
  311|       |
  312|  7.48k|    if (TIFFVGetField(tif, tag, ap))
  ------------------
  |  Branch (312:9): [True: 4.32k, False: 3.15k]
  ------------------
  313|  4.32k|        return (1);
  314|  3.15k|    switch (tag)
  315|  3.15k|    {
  316|      0|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|      0|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (316:9): [True: 0, False: 3.15k]
  ------------------
  317|      0|            *va_arg(ap, uint32_t *) = td->td_subfiletype;
  318|      0|            return (1);
  319|     22|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|     22|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (319:9): [True: 22, False: 3.13k]
  ------------------
  320|     22|            *va_arg(ap, uint16_t *) = td->td_bitspersample;
  321|     22|            return (1);
  322|      0|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|      0|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (322:9): [True: 0, False: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  326|      0|            *va_arg(ap, uint16_t *) = td->td_fillorder;
  327|      0|            return (1);
  328|    448|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|    448|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (328:9): [True: 448, False: 2.70k]
  ------------------
  329|    448|            *va_arg(ap, uint16_t *) = td->td_orientation;
  330|    448|            return (1);
  331|     38|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|     38|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (331:9): [True: 38, False: 3.11k]
  ------------------
  332|     38|            *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
  333|     38|            return (1);
  334|    219|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|    219|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (334:9): [True: 219, False: 2.93k]
  ------------------
  335|    219|            *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
  336|    219|            return (1);
  337|      0|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      0|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (337:9): [True: 0, False: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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|      2|        case TIFFTAG_INKSET:
  ------------------
  |  |  322|      2|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  |  Branch (395:9): [True: 2, False: 3.15k]
  ------------------
  396|      2|            *va_arg(ap, uint16_t *) = INKSET_CMYK;
  ------------------
  |  |  323|      2|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  397|      2|            return 1;
  398|      0|        case TIFFTAG_NUMBEROFINKS:
  ------------------
  |  |  326|      0|#define TIFFTAG_NUMBEROFINKS 334           /* !number of inks */
  ------------------
  |  Branch (398:9): [True: 0, False: 3.15k]
  ------------------
  399|      0|            *va_arg(ap, uint16_t *) = 4;
  400|      0|            return (1);
  401|    271|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|    271|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (401:9): [True: 271, False: 2.88k]
  ------------------
  402|    271|            *va_arg(ap, uint16_t *) = td->td_extrasamples;
  403|    271|            *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
  404|    271|            return (1);
  405|      0|        case TIFFTAG_MATTEING:
  ------------------
  |  |  405|      0|#define TIFFTAG_MATTEING 32995   /* $use ExtraSamples */
  ------------------
  |  Branch (405:9): [True: 0, False: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  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: 3.15k]
  ------------------
  420|      0|            *va_arg(ap, uint32_t *) = td->td_imagedepth;
  421|      0|            return (1);
  422|     74|        case TIFFTAG_YCBCRCOEFFICIENTS:
  ------------------
  |  |  387|     74|#define TIFFTAG_YCBCRCOEFFICIENTS 529      /* !RGB -> YCbCr transform */
  ------------------
  |  Branch (422:9): [True: 74, False: 3.08k]
  ------------------
  423|     74|        {
  424|       |            /* defaults are from CCIR Recommendation 601-1 */
  425|     74|            static const float ycbcrcoeffs[] = {0.299f, 0.587f, 0.114f};
  426|     74|            *va_arg(ap, const float **) = ycbcrcoeffs;
  427|     74|            return 1;
  428|      0|        }
  429|  2.00k|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|  2.00k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (429:9): [True: 2.00k, False: 1.15k]
  ------------------
  430|  2.00k|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
  431|  2.00k|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
  432|  2.00k|            return (1);
  433|      0|        case TIFFTAG_YCBCRPOSITIONING:
  ------------------
  |  |  389|      0|#define TIFFTAG_YCBCRPOSITIONING 531       /* !subsample positioning */
  ------------------
  |  Branch (433:9): [True: 0, False: 3.15k]
  ------------------
  434|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
  435|      0|            return (1);
  436|      0|        case TIFFTAG_WHITEPOINT:
  ------------------
  |  |  307|      0|#define TIFFTAG_WHITEPOINT 318             /* image white point */
  ------------------
  |  Branch (436:9): [True: 0, False: 3.15k]
  ------------------
  437|      0|        {
  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|      0|            static const float whitepoint[] = {
  442|      0|                D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  132|      0|#define D50_X0 (96.4250f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  132|      0|#define D50_X0 (96.4250f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  133|      0|#define D50_Y0 (100.0f)
  ------------------
                              D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
  ------------------
  |  |  134|      0|#define D50_Z0 (82.4680f)
  ------------------
  443|      0|                D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  133|      0|#define D50_Y0 (100.0f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  132|      0|#define D50_X0 (96.4250f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  133|      0|#define D50_Y0 (100.0f)
  ------------------
                              D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
  ------------------
  |  |  134|      0|#define D50_Z0 (82.4680f)
  ------------------
  444|      0|            *va_arg(ap, const float **) = whitepoint;
  445|      0|            return 1;
  446|      0|        }
  447|      0|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      0|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (447:9): [True: 0, False: 3.15k]
  ------------------
  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|     80|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|     80|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (462:9): [True: 80, False: 3.07k]
  ------------------
  463|     80|            if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(tif, td))
  ------------------
  |  Branch (463:17): [True: 80, False: 0]
  |  Branch (463:42): [True: 0, False: 80]
  ------------------
  464|      0|                return (0);
  465|     80|            *va_arg(ap, const float **) = td->td_refblackwhite;
  466|     80|            return (1);
  467|      0|        default:
  ------------------
  |  Branch (467:9): [True: 0, False: 3.15k]
  ------------------
  468|      0|            break;
  469|  3.15k|    }
  470|      0|    return 0;
  471|  3.15k|}
TIFFGetFieldDefaulted:
  478|  7.48k|{
  479|  7.48k|    int ok;
  480|  7.48k|    va_list ap;
  481|       |
  482|  7.48k|    va_start(ap, tag);
  483|  7.48k|    ok = TIFFVGetFieldDefaulted(tif, tag, ap);
  484|       |    va_end(ap);
  485|  7.48k|    return (ok);
  486|  7.48k|}
_TIFFClampDoubleToFloat:
  489|    178|{
  490|    178|    if (val > (double)FLT_MAX)
  ------------------
  |  Branch (490:9): [True: 0, False: 178]
  ------------------
  491|      0|        return FLT_MAX;
  492|    178|    if (val < -(double)FLT_MAX)
  ------------------
  |  Branch (492:9): [True: 0, False: 178]
  ------------------
  493|      0|        return -FLT_MAX;
  494|    178|    return (float)val;
  495|    178|}
_TIFFSeekOK:
  507|  6.84k|{
  508|       |    /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
  509|       |    /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
  510|  6.84k|    return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off;
  ------------------
  |  |  287|  6.84k|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
  |  Branch (510:12): [True: 6.84k, False: 1]
  |  Branch (510:41): [True: 4.68k, False: 2.15k]
  ------------------
  511|  6.84k|}
tif_aux.c:TIFFDefaultRefBlackWhite:
  265|     80|{
  266|     80|    int i;
  267|       |
  268|     80|    td->td_refblackwhite = (float *)_TIFFmallocExt(tif, 6 * sizeof(float));
  269|     80|    if (td->td_refblackwhite == NULL)
  ------------------
  |  Branch (269:9): [True: 0, False: 80]
  ------------------
  270|      0|        return 0;
  271|     80|    if (td->td_photometric == PHOTOMETRIC_YCBCR)
  ------------------
  |  |  227|     80|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (271:9): [True: 80, False: 0]
  ------------------
  272|     80|    {
  273|       |        /*
  274|       |         * YCbCr (Class Y) images must have the ReferenceBlackWhite
  275|       |         * tag set. Fix the broken images, which lacks that tag.
  276|       |         */
  277|     80|        td->td_refblackwhite[0] = 0.0f;
  278|     80|        td->td_refblackwhite[1] = td->td_refblackwhite[3] =
  279|     80|            td->td_refblackwhite[5] = 255.0f;
  280|     80|        td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0f;
  281|     80|    }
  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|     80|    return 1;
  298|     80|}

TIFFCleanup:
   45|    402|{
   46|       |    /*
   47|       |     * Flush buffered data and directory (if dirty).
   48|       |     */
   49|    402|    if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (49:9): [True: 0, False: 402]
  ------------------
   50|      0|        TIFFFlush(tif);
   51|    402|    TIFFFreeDirectory(tif);
   52|       |
   53|    402|    _TIFFCleanupIFDOffsetAndNumberMaps(tif);
   54|       |
   55|       |    /*
   56|       |     * Clean up client info links.
   57|       |     */
   58|    402|    while (tif->tif_clientinfo)
  ------------------
  |  Branch (58:12): [True: 0, False: 402]
  ------------------
   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|    402|    if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER))
  ------------------
  |  |  128|    299|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (67:9): [True: 299, False: 103]
  |  Branch (67:29): [True: 299, False: 0]
  ------------------
   68|    299|        _TIFFfreeExt(tif, tif->tif_rawdata);
   69|    402|    if (isMapped(tif))
  ------------------
  |  |  279|    402|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|    402|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 402]
  |  |  ------------------
  ------------------
   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|    402|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (75:9): [True: 398, False: 4]
  |  Branch (75:28): [True: 398, False: 0]
  ------------------
   76|    398|    {
   77|    398|        uint32_t i;
   78|       |
   79|  89.5k|        for (i = 0; i < tif->tif_nfields; i++)
  ------------------
  |  Branch (79:21): [True: 89.1k, False: 398]
  ------------------
   80|  89.1k|        {
   81|  89.1k|            TIFFField *fld = tif->tif_fields[i];
   82|  89.1k|            if (fld->field_name != NULL)
  ------------------
  |  Branch (82:17): [True: 89.1k, False: 0]
  ------------------
   83|  89.1k|            {
   84|  89.1k|                if (fld->field_bit == FIELD_CUSTOM &&
  ------------------
  |  |  346|   178k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (84:21): [True: 67.7k, False: 21.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|  67.7k|                    TIFFFieldIsAnonymous(fld))
  ------------------
  |  Branch (89:21): [True: 26.7k, False: 40.9k]
  ------------------
   90|  26.7k|                {
   91|  26.7k|                    _TIFFfreeExt(tif, (void *)fld->field_name);
   92|  26.7k|                    _TIFFfreeExt(tif, fld);
   93|  26.7k|                }
   94|  89.1k|            }
   95|  89.1k|        }
   96|       |
   97|    398|        _TIFFfreeExt(tif, tif->tif_fields);
   98|    398|    }
   99|       |
  100|    402|    if (tif->tif_nfieldscompat > 0)
  ------------------
  |  Branch (100:9): [True: 0, False: 402]
  ------------------
  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|    402|    if (tif->tif_cur_cumulated_mem_alloc != 0)
  ------------------
  |  Branch (112:9): [True: 0, False: 402]
  ------------------
  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|    402|}
_TIFFCleanupIFDOffsetAndNumberMaps:
  128|    402|{
  129|    402|    if (tif->tif_map_dir_offset_to_number)
  ------------------
  |  Branch (129:9): [True: 398, False: 4]
  ------------------
  130|    398|    {
  131|    398|        TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
  132|    398|        tif->tif_map_dir_offset_to_number = NULL;
  133|    398|    }
  134|    402|    if (tif->tif_map_dir_number_to_offset)
  ------------------
  |  Branch (134:9): [True: 398, False: 4]
  ------------------
  135|    398|    {
  136|    398|        TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
  137|       |        tif->tif_map_dir_number_to_offset = NULL;
  138|    398|    }
  139|    402|}
TIFFClose:
  156|    367|{
  157|    367|    if (tif != NULL)
  ------------------
  |  Branch (157:9): [True: 367, False: 0]
  ------------------
  158|    367|    {
  159|    367|        TIFFCloseProc closeproc = tif->tif_closeproc;
  160|    367|        thandle_t fd = tif->tif_clientdata;
  161|       |
  162|    367|        TIFFCleanup(tif);
  163|    367|        (void)(*closeproc)(fd);
  164|    367|    }
  165|    367|}

TIFFIsCODECConfigured:
  147|    616|{
  148|    616|    const TIFFCodec *codec = TIFFFindCODEC(scheme);
  149|       |
  150|    616|    if (codec == NULL)
  ------------------
  |  Branch (150:9): [True: 6, False: 610]
  ------------------
  151|      6|    {
  152|      6|        return 0;
  153|      6|    }
  154|    610|    if (codec->init == NULL)
  ------------------
  |  Branch (154:9): [True: 0, False: 610]
  ------------------
  155|      0|    {
  156|      0|        return 0;
  157|      0|    }
  158|    610|    if (codec->init != NotConfigured)
  ------------------
  |  Branch (158:9): [True: 610, False: 0]
  ------------------
  159|    610|    {
  160|    610|        return 1;
  161|    610|    }
  162|      0|    return 0;
  163|    610|}

TIFFYCbCrtoRGB:
  208|  36.0k|{
  209|  36.0k|    int32_t i;
  210|       |
  211|       |    /* XXX: Only 8-bit YCbCr input supported for now */
  212|  36.0k|    Y = HICLAMP(Y, 255);
  ------------------
  |  |  204|  36.0k|#define HICLAMP(f, max) ((f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (204:26): [True: 0, False: 36.0k]
  |  |  ------------------
  ------------------
  213|  36.0k|    Cb = CLAMP(Cb, 0, 255);
  ------------------
  |  |  203|  36.0k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 0, False: 36.0k]
  |  |  |  Branch (203:34): [True: 0, False: 36.0k]
  |  |  ------------------
  ------------------
  214|  36.0k|    Cr = CLAMP(Cr, 0, 255);
  ------------------
  |  |  203|  36.0k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 0, False: 36.0k]
  |  |  |  Branch (203:34): [True: 0, False: 36.0k]
  |  |  ------------------
  ------------------
  215|       |
  216|  36.0k|    i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
  217|  36.0k|    *r = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|  36.0k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 28.3k, False: 7.77k]
  |  |  |  Branch (203:34): [True: 4.47k, False: 3.30k]
  |  |  ------------------
  ------------------
  218|  36.0k|    i = ycbcr->Y_tab[Y] +
  219|  36.0k|        ((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
  ------------------
  |  |  195|  36.0k|#define SHIFT 16
  ------------------
  220|  36.0k|    *g = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|  36.0k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 3.89k, False: 32.2k]
  |  |  |  Branch (203:34): [True: 11.6k, False: 20.5k]
  |  |  ------------------
  ------------------
  221|  36.0k|    i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
  222|  36.0k|    *b = (uint32_t)CLAMP(i, 0, 255);
  ------------------
  |  |  203|  36.0k|    ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
  |  |  ------------------
  |  |  |  Branch (203:6): [True: 11.9k, False: 24.1k]
  |  |  |  Branch (203:34): [True: 13.5k, False: 10.5k]
  |  |  ------------------
  ------------------
  223|  36.0k|}
TIFFYCbCrToRGBInit:
  259|     80|{
  260|     80|    TIFFRGBValue *clamptab;
  261|     80|    int i;
  262|       |
  263|     80|#define LumaRed luma[0]
  264|     80|#define LumaGreen luma[1]
  265|     80|#define LumaBlue luma[2]
  266|       |
  267|     80|    clamptab =
  268|     80|        (uint8_t *)ycbcr + TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long));
  ------------------
  |  |  322|     80|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|     80|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 80, Folded]
  |  |  |  |  ------------------
  |  |  |  |  313|     80|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|     80|         : 0U)
  |  |  ------------------
  ------------------
  269|     80|    _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
  270|     80|    ycbcr->clamptab = (clamptab += 256);
  271|  20.5k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (271:17): [True: 20.4k, False: 80]
  ------------------
  272|  20.4k|        clamptab[i] = (TIFFRGBValue)i;
  273|     80|    _TIFFmemset(clamptab + 256, 255, 2 * 256); /* v > 255 => 255 */
  274|     80|    ycbcr->Cr_r_tab = (int *)(clamptab + 3 * 256);
  275|     80|    ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
  276|     80|    ycbcr->Cr_g_tab = (int32_t *)(ycbcr->Cb_b_tab + 256);
  277|     80|    ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
  278|     80|    ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
  279|       |
  280|     80|    {
  281|     80|        float f1 = 2 - 2 * LumaRed;
  ------------------
  |  |  263|     80|#define LumaRed luma[0]
  ------------------
  282|     80|        int32_t D1 = FIX(CLAMP(f1, 0.0f, 2.0f));
  ------------------
  |  |  196|    306|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|     80|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 73]
  |  |  |  Branch (196:36): [True: 7, False: 73]
  |  |  ------------------
  ------------------
  283|     80|        float f2 = LumaRed * f1 / LumaGreen;
  ------------------
  |  |  263|     80|#define LumaRed luma[0]
  ------------------
                      float f2 = LumaRed * f1 / LumaGreen;
  ------------------
  |  |  264|     80|#define LumaGreen luma[1]
  ------------------
  284|     80|        int32_t D2 = -FIX(CLAMP(f2, 0.0f, 2.0f));
  ------------------
  |  |  196|    306|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|     80|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 73]
  |  |  |  Branch (196:36): [True: 7, False: 73]
  |  |  ------------------
  ------------------
  285|     80|        float f3 = 2 - 2 * LumaBlue;
  ------------------
  |  |  265|     80|#define LumaBlue luma[2]
  ------------------
  286|     80|        int32_t D3 = FIX(CLAMP(f3, 0.0f, 2.0f));
  ------------------
  |  |  196|    306|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|     80|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 73]
  |  |  |  Branch (196:36): [True: 7, False: 73]
  |  |  ------------------
  ------------------
  287|     80|        float f4 = LumaBlue * f3 / LumaGreen;
  ------------------
  |  |  265|     80|#define LumaBlue luma[2]
  ------------------
                      float f4 = LumaBlue * f3 / LumaGreen;
  ------------------
  |  |  264|     80|#define LumaGreen luma[1]
  ------------------
  288|     80|        int32_t D4 = -FIX(CLAMP(f4, 0.0f, 2.0f));
  ------------------
  |  |  196|    306|#define FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5))
  |  |  ------------------
  |  |  |  |  195|     80|#define SHIFT 16
  |  |  ------------------
  |  |  |  Branch (196:36): [True: 0, False: 73]
  |  |  |  Branch (196:36): [True: 7, False: 73]
  |  |  ------------------
  ------------------
  289|     80|        int x;
  290|       |
  291|     80|#undef LumaBlue
  292|     80|#undef LumaGreen
  293|     80|#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|  20.5k|        for (i = 0, x = -128; i < 256; i++, x++)
  ------------------
  |  Branch (302:31): [True: 20.4k, False: 80]
  ------------------
  303|  20.4k|        {
  304|  20.4k|            int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0f,
  ------------------
  |  |  199|  20.4k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|  20.4k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|  20.4k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 20.4k, False: 0]
  |  |  ------------------
  ------------------
  305|  20.4k|                                                refBlackWhite[5] - 128.0f, 127),
  306|  20.4k|                                         -128.0f * 32, 128.0f * 32);
  307|  20.4k|            int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0f,
  ------------------
  |  |  199|  20.4k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|  20.4k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|  20.4k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 20.4k, False: 0]
  |  |  ------------------
  ------------------
  308|  20.4k|                                                refBlackWhite[3] - 128.0f, 127),
  309|  20.4k|                                         -128.0f * 32, 128.0f * 32);
  310|       |
  311|  20.4k|            ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT);
  ------------------
  |  |  197|  20.4k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|  20.4k|#define SHIFT 16
  |  |  ------------------
  ------------------
                          ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT);
  ------------------
  |  |  195|  20.4k|#define SHIFT 16
  ------------------
  312|  20.4k|            ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT);
  ------------------
  |  |  197|  20.4k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|  20.4k|#define SHIFT 16
  |  |  ------------------
  ------------------
                          ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT);
  ------------------
  |  |  195|  20.4k|#define SHIFT 16
  ------------------
  313|  20.4k|            ycbcr->Cr_g_tab[i] = D2 * Cr;
  314|  20.4k|            ycbcr->Cb_g_tab[i] = D4 * Cb + ONE_HALF;
  ------------------
  |  |  197|  20.4k|#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
  |  |  ------------------
  |  |  |  |  195|  20.4k|#define SHIFT 16
  |  |  ------------------
  ------------------
  315|  20.4k|            ycbcr->Y_tab[i] = (int32_t)CLAMPw(
  316|  20.4k|                Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
  ------------------
  |  |  199|  20.4k|    (((float)((c) - (int32_t)(RB)) * (float)(CR)) /                            \
  |  |  200|  20.4k|     ((!TIFF_FLOAT_EQ((RW), (RB))) ? ((RW) - (RB)) : 1.0f))
  |  |  ------------------
  |  |  |  |  342|  20.4k|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (200:7): [True: 20.4k, False: 0]
  |  |  ------------------
  ------------------
  317|  20.4k|                -128.0f * 32, 128.0f * 32);
  318|  20.4k|        }
  319|     80|    }
  320|       |
  321|     80|    return 0;
  322|     80|}
tif_color.c:CLAMPw:
  228|  61.4k|{
  229|  61.4k|    if (v < vmin)
  ------------------
  |  Branch (229:9): [True: 0, False: 61.4k]
  ------------------
  230|      0|    {
  231|       |        /* printf("%f clamped to %f\n", v, vmin); */
  232|      0|        return vmin;
  233|      0|    }
  234|  61.4k|    if (v > vmax)
  ------------------
  |  Branch (234:9): [True: 0, False: 61.4k]
  ------------------
  235|      0|    {
  236|       |        /* printf("%f clamped to %f\n", v, vmax); */
  237|      0|        return vmax;
  238|      0|    }
  239|  61.4k|    return v;
  240|  61.4k|}

_TIFFNoStripDecode:
  105|      1|{
  106|      1|    (void)pp;
  107|      1|    (void)cc;
  108|      1|    (void)s;
  109|      1|    return (TIFFNoDecode(tif, "strip"));
  110|      1|}
_TIFFNoPreCode:
  129|     40|{
  130|     40|    (void)tif;
  131|     40|    (void)s;
  132|     40|    return (1);
  133|     40|}
_TIFFSetDefaultCompressionState:
  155|  2.37k|{
  156|  2.37k|    tif->tif_fixuptags = _TIFFNoFixupTags;
  157|  2.37k|    tif->tif_decodestatus = TRUE;
  ------------------
  |  |   71|  2.37k|#define TRUE 1
  ------------------
  158|  2.37k|    tif->tif_setupdecode = _TIFFtrue;
  159|  2.37k|    tif->tif_predecode = _TIFFNoPreCode;
  160|  2.37k|    tif->tif_decoderow = _TIFFNoRowDecode;
  161|  2.37k|    tif->tif_decodestrip = _TIFFNoStripDecode;
  162|  2.37k|    tif->tif_decodetile = _TIFFNoTileDecode;
  163|  2.37k|    tif->tif_encodestatus = TRUE;
  ------------------
  |  |   71|  2.37k|#define TRUE 1
  ------------------
  164|  2.37k|    tif->tif_setupencode = _TIFFtrue;
  165|  2.37k|    tif->tif_preencode = _TIFFNoPreCode;
  166|  2.37k|    tif->tif_postencode = _TIFFtrue;
  167|  2.37k|    tif->tif_encoderow = _TIFFNoRowEncode;
  168|  2.37k|    tif->tif_encodestrip = _TIFFNoStripEncode;
  169|  2.37k|    tif->tif_encodetile = _TIFFNoTileEncode;
  170|  2.37k|    tif->tif_close = _TIFFvoid;
  171|  2.37k|    tif->tif_seek = _TIFFNoSeek;
  172|  2.37k|    tif->tif_cleanup = _TIFFvoid;
  173|  2.37k|    tif->tif_defstripsize = _TIFFDefaultStripSize;
  174|  2.37k|    tif->tif_deftilesize = _TIFFDefaultTileSize;
  175|  2.37k|    tif->tif_getmaxcompressionratio = _TIFFDefaultGetMaxCompressionRatio;
  176|  2.37k|    tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW);
  ------------------
  |  |  127|  2.37k|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
                  tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW);
  ------------------
  |  |  138|  2.37k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  177|  2.37k|}
TIFFSetCompressionScheme:
  180|  1.34k|{
  181|  1.34k|    const TIFFCodec *c = TIFFFindCODEC((uint16_t)scheme);
  182|       |
  183|  1.34k|    _TIFFSetDefaultCompressionState(tif);
  184|  1.34k|    if (scheme == COMPRESSION_NONE)
  ------------------
  |  |  182|  1.34k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (184:9): [True: 690, False: 654]
  ------------------
  185|    690|        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|  1.34k|    return (c ? (*c->init)(tif, scheme) : 1);
  ------------------
  |  Branch (192:13): [True: 1.34k, False: 4]
  ------------------
  193|  1.34k|}
TIFFGetMaxCompressionRatio:
  196|     56|{
  197|     56|    if (tif->tif_getmaxcompressionratio)
  ------------------
  |  Branch (197:9): [True: 56, False: 0]
  ------------------
  198|     56|        return tif->tif_getmaxcompressionratio(tif);
  199|      0|    return 0;
  200|     56|}
TIFFFindCODEC:
  215|  1.96k|{
  216|  1.96k|    const TIFFCodec *c;
  217|  1.96k|    codec_t *cd;
  218|       |
  219|  1.96k|    for (cd = registeredCODECS; cd; cd = cd->next)
  ------------------
  |  Branch (219:33): [True: 0, False: 1.96k]
  ------------------
  220|      0|        if (cd->info->scheme == scheme)
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|      0|            return ((const TIFFCodec *)cd->info);
  222|  8.55k|    for (c = _TIFFBuiltinCODECS; c->name; c++)
  ------------------
  |  Branch (222:34): [True: 8.54k, False: 11]
  ------------------
  223|  8.54k|        if (c->scheme == scheme)
  ------------------
  |  Branch (223:13): [True: 1.95k, False: 6.59k]
  ------------------
  224|  1.95k|            return (c);
  225|     11|    return NULL;
  226|  1.96k|}
tif_compress.c:TIFFNoDecode:
   76|      1|{
   77|      1|    const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
   78|       |
   79|      1|    if (c)
  ------------------
  |  Branch (79:9): [True: 0, False: 1]
  ------------------
   80|      0|        TIFFErrorExtR(tif, tif->tif_name, "%s %s decoding is not implemented",
   81|      0|                      c->name, method);
   82|      1|    else
   83|      1|        TIFFErrorExtR(tif, tif->tif_name,
   84|      1|                      "Compression scheme %" PRIu16
   85|      1|                      " %s decoding is not implemented",
   86|      1|                      tif->tif_dir.td_compression, method);
   87|      1|    return (0);
   88|      1|}
tif_compress.c:_TIFFNoFixupTags:
   91|     23|{
   92|     23|    (void)tif;
   93|     23|    return (1);
   94|     23|}
tif_compress.c:_TIFFtrue:
  136|     24|{
  137|     24|    (void)tif;
  138|     24|    return (1);
  139|     24|}
tif_compress.c:_TIFFvoid:
  140|  1.11k|static void _TIFFvoid(TIFF *tif) { (void)tif; }
tif_compress.c:_TIFFDefaultGetMaxCompressionRatio:
  143|      2|{
  144|      2|    (void)tif;
  145|      2|    return 0; /* unknown */
  146|      2|}
tif_compress.c:_TIFFGetMaxCompressionRatioOne:
  149|      1|{
  150|      1|    (void)tif;
  151|      1|    return 1; /* no compression */
  152|      1|}

_TIFFsetByteArrayExt:
   67|      2|{
   68|      2|    setByteArray(tif, vpp, vp, n, 1);
   69|      2|}
_TIFFsetShortArrayExt:
   82|    474|{
   83|    474|    setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t));
   84|    474|}
_TIFFsetFloatArrayExt:
  107|      2|{
  108|      2|    setByteArray(tif, (void **)fpp, fp, n, sizeof(float));
  109|      2|}
_TIFFsetDoubleArrayExt:
  117|      7|{
  118|      7|    setByteArray(tif, (void **)dpp, dp, n, sizeof(double));
  119|      7|}
TIFFSetField:
 1168|  9.34k|{
 1169|  9.34k|    va_list ap;
 1170|  9.34k|    int status;
 1171|       |
 1172|  9.34k|    va_start(ap, tag);
 1173|  9.34k|    status = TIFFVSetField(tif, tag, ap);
 1174|       |    va_end(ap);
 1175|  9.34k|    return (status);
 1176|  9.34k|}
TIFFVSetField:
 1227|  9.34k|{
 1228|  9.34k|    return OkToChangeTag(tif, tag)
  ------------------
  |  Branch (1228:12): [True: 9.34k, False: 0]
  ------------------
 1229|  9.34k|               ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap)
 1230|  9.34k|               : 0;
 1231|  9.34k|}
TIFFGetField:
 1608|  4.82k|{
 1609|  4.82k|    int status;
 1610|  4.82k|    va_list ap;
 1611|       |
 1612|  4.82k|    va_start(ap, tag);
 1613|  4.82k|    status = TIFFVGetField(tif, tag, ap);
 1614|       |    va_end(ap);
 1615|  4.82k|    return (status);
 1616|  4.82k|}
TIFFVGetField:
 1625|  12.3k|{
 1626|  12.3k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  12.3k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1627|  12.3k|    return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
  ------------------
  |  |  276|  24.6k|#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
  |  |  ------------------
  |  |  |  Branch (276:24): [True: 0, False: 12.3k]
  |  |  ------------------
  ------------------
                  return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
  ------------------
  |  |  248|  12.3k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  12.3k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  12.3k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 8.70k, False: 3.60k]
  |  |  ------------------
  ------------------
  |  Branch (1627:13): [True: 12.3k, False: 0]
  ------------------
 1628|  12.3k|                ? (*tif->tif_tagmethods.vgetfield)(tif, tag, ap)
 1629|  12.3k|                : 0);
 1630|  12.3k|}
_TIFFResetTifDirAndInitStrileCounters:
 1646|  1.09k|{
 1647|  1.09k|    _TIFFmemset(td, 0, sizeof(*td));
 1648|  1.09k|    td->td_curstrip = NOSTRIP;      /* invalid strip = NOSTRIP */
  ------------------
  |  |  111|  1.09k|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
 1649|  1.09k|    td->td_row = (uint32_t)-1;      /* read/write pre-increment */
 1650|  1.09k|    td->td_col = (uint32_t)-1;      /* read/write pre-increment */
 1651|  1.09k|    td->td_scanlinesize = 0;        /* initialize to zero */
 1652|  1.09k|    td->td_curtile = NOTILE;        /* invalid tile = NOTILE */
  ------------------
  |  |  116|  1.09k|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1653|  1.09k|    td->td_tilesize = (tmsize_t)-1; /* invalidate tilezize */
 1654|  1.09k|}
TIFFFreeDirectory:
 1660|  1.09k|{
 1661|  1.09k|    TIFFDirectory *td = &tif->tif_dir;
 1662|  1.09k|    int i;
 1663|       |
 1664|  1.09k|    (*tif->tif_cleanup)(tif);
 1665|  1.09k|    _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
 1666|  1.09k|    CleanupField(td_sminsamplevalue);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1667|  1.09k|    CleanupField(td_smaxsamplevalue);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1668|  1.09k|    CleanupField(td_colormap[0]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      2|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      2|            td->member = 0;                                                    \
  |  | 1638|      2|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1669|  1.09k|    CleanupField(td_colormap[1]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      2|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      2|            td->member = 0;                                                    \
  |  | 1638|      2|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1670|  1.09k|    CleanupField(td_colormap[2]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 2, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      2|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      2|            td->member = 0;                                                    \
  |  | 1638|      2|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1671|  1.09k|    CleanupField(td_sampleinfo);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 441, False: 651]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|    441|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|    441|            td->member = 0;                                                    \
  |  | 1638|    441|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1672|  1.09k|    CleanupField(td_subifd);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1673|  1.09k|    CleanupField(td_inknames);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 5, False: 1.08k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      5|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      5|            td->member = 0;                                                    \
  |  | 1638|      5|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1674|  1.09k|    CleanupField(td_refblackwhite);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 82, False: 1.01k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|     82|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|     82|            td->member = 0;                                                    \
  |  | 1638|     82|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1675|  1.09k|    CleanupField(td_transferfunction[0]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1676|  1.09k|    CleanupField(td_transferfunction[1]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1677|  1.09k|    CleanupField(td_transferfunction[2]);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 0, False: 1.09k]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|      0|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|      0|            td->member = 0;                                                    \
  |  | 1638|      0|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1678|  1.09k|    CleanupField(td_stripoffset_p);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 625, False: 467]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|    625|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|    625|            td->member = 0;                                                    \
  |  | 1638|    625|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1679|  1.09k|    CleanupField(td_stripbytecount_p);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 586, False: 506]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|    586|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|    586|            td->member = 0;                                                    \
  |  | 1638|    586|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1680|  1.09k|    td->td_stripoffsetbyteallocsize = 0;
 1681|  1.09k|    TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
  ------------------
  |  |  250|  1.09k|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.09k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.09k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1682|  1.09k|    TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
  ------------------
  |  |  250|  1.09k|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.09k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.09k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1683|       |
 1684|       |    /* Cleanup custom tag values */
 1685|  3.05k|    for (i = 0; i < td->td_customValueCount; i++)
  ------------------
  |  Branch (1685:17): [True: 1.96k, False: 1.09k]
  ------------------
 1686|  1.96k|    {
 1687|  1.96k|        if (td->td_customValues[i].value)
  ------------------
  |  Branch (1687:13): [True: 1.47k, False: 488]
  ------------------
 1688|  1.47k|            _TIFFfreeExt(tif, td->td_customValues[i].value);
 1689|  1.96k|    }
 1690|       |
 1691|  1.09k|    td->td_customValueCount = 0;
 1692|  1.09k|    CleanupField(td_customValues);
  ------------------
  |  | 1633|  1.09k|    {                                                                          \
  |  | 1634|  1.09k|        if (td->member)                                                        \
  |  |  ------------------
  |  |  |  Branch (1634:13): [True: 662, False: 430]
  |  |  ------------------
  |  | 1635|  1.09k|        {                                                                      \
  |  | 1636|    662|            _TIFFfreeExt(tif, td->member);                                     \
  |  | 1637|    662|            td->member = 0;                                                    \
  |  | 1638|    662|        }                                                                      \
  |  | 1639|  1.09k|    }
  ------------------
 1693|       |
 1694|  1.09k|    _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
 1695|  1.09k|    _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
 1696|       |
 1697|       |    /* Reset some internal parameters for IFD data size checking. */
 1698|  1.09k|    tif->tif_dir.td_dirdatasize_read = 0;
 1699|  1.09k|    tif->tif_dir.td_dirdatasize_write = 0;
 1700|  1.09k|    if (tif->tif_dir.td_dirdatasize_offsets != NULL)
  ------------------
  |  Branch (1700:9): [True: 690, False: 402]
  ------------------
 1701|    690|    {
 1702|    690|        _TIFFfreeExt(tif, tif->tif_dir.td_dirdatasize_offsets);
 1703|    690|        tif->tif_dir.td_dirdatasize_offsets = NULL;
 1704|    690|        tif->tif_dir.td_dirdatasize_Noffsets = 0;
 1705|    690|    }
 1706|  1.09k|    tif->tif_dir.td_iswrittentofile = FALSE;
  ------------------
  |  |   72|  1.09k|#define FALSE 0
  ------------------
 1707|       |    /* Note: tif->tif_dir structure is set to zero in TIFFDefaultDirectory() */
 1708|  1.09k|}
TIFFDefaultDirectory:
 1788|    690|{
 1789|    690|    TIFFDirectory *td = &tif->tif_dir;
 1790|    690|    const TIFFFieldArray *tiffFieldArray;
 1791|       |
 1792|    690|    tiffFieldArray = _TIFFGetFields();
 1793|    690|    _TIFFSetupFields(tif, tiffFieldArray);
 1794|       |    /* Reset tif->tif_dir structure to zero and
 1795|       |     * initialize some IFD strile counter and index parameters. */
 1796|    690|    _TIFFResetTifDirAndInitStrileCounters(td);
 1797|    690|    td->td_fillorder = FILLORDER_MSB2LSB;
  ------------------
  |  |  241|    690|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
 1798|    690|    td->td_bitspersample = 1;
 1799|    690|    td->td_threshholding = THRESHHOLD_BILEVEL;
  ------------------
  |  |  235|    690|#define THRESHHOLD_BILEVEL 1               /* b&w art scan */
  ------------------
 1800|    690|    td->td_orientation = ORIENTATION_TOPLEFT;
  ------------------
  |  |  249|    690|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
 1801|    690|    td->td_samplesperpixel = 1;
 1802|    690|    td->td_rowsperstrip = (uint32_t)-1;
 1803|    690|    td->td_tilewidth = 0;
 1804|    690|    td->td_tilelength = 0;
 1805|    690|    td->td_tiledepth = 1;
 1806|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 1807|       |    td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
 1808|       |#endif
 1809|    690|    td->td_resolutionunit = RESUNIT_INCH;
  ------------------
  |  |  289|    690|#define RESUNIT_INCH 2                     /* english */
  ------------------
 1810|    690|    td->td_sampleformat = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|    690|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1811|    690|    td->td_imagedepth = 1;
 1812|    690|    td->td_ycbcrsubsampling[0] = 2;
 1813|    690|    td->td_ycbcrsubsampling[1] = 2;
 1814|    690|    td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
  ------------------
  |  |  390|    690|#define YCBCRPOSITION_CENTERED 1           /* !as in PostScript Level 2 */
  ------------------
 1815|    690|    tif->tif_postdecode = _TIFFNoPostDecode;
 1816|    690|    tif->tif_foundfield = NULL;
 1817|    690|    tif->tif_tagmethods.vsetfield = _TIFFVSetField;
 1818|    690|    tif->tif_tagmethods.vgetfield = _TIFFVGetField;
 1819|    690|    tif->tif_tagmethods.printdir = NULL;
 1820|       |    /* additional default values */
 1821|    690|    td->td_planarconfig = PLANARCONFIG_CONTIG;
  ------------------
  |  |  265|    690|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
 1822|    690|    td->td_compression = COMPRESSION_NONE;
  ------------------
  |  |  182|    690|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
 1823|    690|    td->td_subfiletype = 0;
 1824|    690|    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|    690|    td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */
 1829|    690|    td->td_extrasamples = 0;
 1830|    690|    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|    690|    if (tif->tif_nfieldscompat > 0)
  ------------------
  |  Branch (1838:9): [True: 0, False: 690]
  ------------------
 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|    690|    if (_TIFFextender)
  ------------------
  |  Branch (1851:9): [True: 0, False: 690]
  ------------------
 1852|      0|        (*_TIFFextender)(tif);
 1853|    690|    (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  ------------------
  |  |  181|    690|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
                  (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  ------------------
  |  |  182|    690|#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|    690|    tif->tif_flags &= ~TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|    690|#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|    690|    tif->tif_flags &= ~TIFF_ISTILED;
  ------------------
  |  |  129|    690|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 1870|       |
 1871|    690|    return (1);
 1872|    690|}
tif_dir.c:setByteArray:
   46|  1.01k|{
   47|  1.01k|    if (*vpp)
  ------------------
  |  Branch (47:9): [True: 26, False: 990]
  ------------------
   48|     26|    {
   49|     26|        _TIFFfreeExt(tif, *vpp);
   50|     26|        *vpp = 0;
   51|     26|    }
   52|  1.01k|    if (vp)
  ------------------
  |  Branch (52:9): [True: 1.01k, False: 5]
  ------------------
   53|  1.01k|    {
   54|  1.01k|        tmsize_t bytes = _TIFFMultiplySSize(NULL, (tmsize_t)nmemb,
   55|  1.01k|                                            (tmsize_t)elem_size, NULL);
   56|  1.01k|        if (bytes)
  ------------------
  |  Branch (56:13): [True: 1.01k, False: 0]
  ------------------
   57|  1.01k|            *vpp = (void *)_TIFFmallocExt(tif, bytes);
   58|  1.01k|        if (*vpp)
  ------------------
  |  Branch (58:13): [True: 1.01k, False: 0]
  ------------------
   59|  1.01k|            _TIFFmemcpy(*vpp, vp, bytes);
   60|  1.01k|    }
   61|  1.01k|}
tif_dir.c:OkToChangeTag:
 1135|  9.34k|{
 1136|  9.34k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  9.34k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1137|  9.34k|    if (!fip)
  ------------------
  |  Branch (1137:9): [True: 0, False: 9.34k]
  ------------------
 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|  9.34k|    if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
  ------------------
  |  |  179|  18.6k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
                  if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
  ------------------
  |  |  125|  8.67k|#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
  ------------------
  |  Branch (1143:9): [True: 8.67k, False: 666]
  |  Branch (1143:39): [True: 0, False: 8.67k]
  ------------------
 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|  9.34k|    return (1);
 1158|  9.34k|}
tif_dir.c:_TIFFVSetField:
  224|  8.75k|{
  225|  8.75k|    static const char module[] = "_TIFFVSetField";
  226|       |
  227|  8.75k|    TIFFDirectory *td = &tif->tif_dir;
  228|  8.75k|    int status = 1;
  229|  8.75k|    uint32_t v32, v;
  230|  8.75k|    double dblval;
  231|  8.75k|    char *s;
  232|  8.75k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  8.75k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  233|  8.75k|    uint32_t standard_tag = tag;
  234|  8.75k|    if (fip == NULL) /* cannot happen since OkToChangeTag() already checks it */
  ------------------
  |  Branch (234:9): [True: 0, False: 8.75k]
  ------------------
  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|  8.75k|    if (fip->field_bit == FIELD_CUSTOM)
  ------------------
  |  |  346|  8.75k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (242:9): [True: 2.00k, False: 6.75k]
  ------------------
  243|  2.00k|    {
  244|  2.00k|        standard_tag = 0;
  245|  2.00k|    }
  246|       |
  247|  8.75k|    switch (standard_tag)
  248|  8.75k|    {
  249|      1|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|      1|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (249:9): [True: 1, False: 8.75k]
  ------------------
  250|      1|            td->td_subfiletype = (uint32_t)va_arg(ap, uint32_t);
  251|      1|            break;
  252|    675|        case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|    675|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (252:9): [True: 675, False: 8.08k]
  ------------------
  253|    675|            td->td_imagewidth = (uint32_t)va_arg(ap, uint32_t);
  254|    675|            break;
  255|    666|        case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|    666|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (255:9): [True: 666, False: 8.09k]
  ------------------
  256|    666|            td->td_imagelength = (uint32_t)va_arg(ap, uint32_t);
  257|    666|            break;
  258|    627|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|    627|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (258:9): [True: 627, False: 8.12k]
  ------------------
  259|    627|            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|    627|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    627|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (267:17): [True: 0, False: 627]
  ------------------
  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|    627|            break;
  283|  1.37k|        case TIFFTAG_COMPRESSION:
  ------------------
  |  |  181|  1.37k|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (283:9): [True: 1.37k, False: 7.38k]
  ------------------
  284|  1.37k|            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|  1.37k|            if (TIFFFieldSet(tif, FIELD_COMPRESSION))
  ------------------
  |  |  248|  1.37k|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|  1.37k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|  1.37k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 686, False: 690]
  |  |  ------------------
  ------------------
  291|    686|            {
  292|    686|                if ((uint32_t)td->td_compression == v)
  ------------------
  |  Branch (292:21): [True: 32, False: 654]
  ------------------
  293|     32|                    break;
  294|    654|                (*tif->tif_cleanup)(tif);
  295|    654|                tif->tif_flags &= ~TIFF_CODERSETUP;
  ------------------
  |  |  124|    654|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  296|    654|            }
  297|       |            /*
  298|       |             * Setup new compression routine state.
  299|       |             */
  300|  1.34k|            if ((status = TIFFSetCompressionScheme(tif, (int)v)) != 0)
  ------------------
  |  Branch (300:17): [True: 1.34k, False: 0]
  ------------------
  301|  1.34k|                td->td_compression = (uint16_t)v;
  302|      0|            else
  303|      0|                status = 0;
  304|  1.34k|            break;
  305|    540|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|    540|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (305:9): [True: 540, False: 8.21k]
  ------------------
  306|    540|            td->td_photometric = (uint16_t)va_arg(ap, uint16_vap);
  307|    540|            break;
  308|      0|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|      0|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (308:9): [True: 0, False: 8.75k]
  ------------------
  309|      0|            td->td_threshholding = (uint16_t)va_arg(ap, uint16_vap);
  310|      0|            break;
  311|    117|        case TIFFTAG_FILLORDER:
  ------------------
  |  |  240|    117|#define TIFFTAG_FILLORDER 266              /* data order within a byte */
  ------------------
  |  Branch (311:9): [True: 117, False: 8.63k]
  ------------------
  312|    117|            v = (uint16_t)va_arg(ap, uint16_vap);
  313|    117|            if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
  ------------------
  |  |  242|    234|#define FILLORDER_LSB2MSB 2                /* least significant -> most */
  ------------------
                          if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
  ------------------
  |  |  241|    117|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  |  Branch (313:17): [True: 117, False: 0]
  |  Branch (313:43): [True: 51, False: 66]
  ------------------
  314|     51|                goto badvalue;
  315|     66|            td->td_fillorder = (uint16_t)v;
  316|     66|            break;
  317|    146|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|    146|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (317:9): [True: 146, False: 8.61k]
  ------------------
  318|    146|            v = (uint16_t)va_arg(ap, uint16_vap);
  319|    146|            if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
  ------------------
  |  |  249|    292|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
                          if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
  ------------------
  |  |  256|    146|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (319:17): [True: 0, False: 146]
  |  Branch (319:44): [True: 1, False: 145]
  ------------------
  320|      1|                goto badvalue;
  321|    145|            else
  322|    145|                td->td_orientation = (uint16_t)v;
  323|    145|            break;
  324|    631|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|    631|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (324:9): [True: 631, False: 8.12k]
  ------------------
  325|    631|            v = (uint16_t)va_arg(ap, uint16_vap);
  326|    631|            if (v == 0)
  ------------------
  |  Branch (326:17): [True: 0, False: 631]
  ------------------
  327|      0|                goto badvalue;
  328|    631|            if (v != td->td_samplesperpixel)
  ------------------
  |  Branch (328:17): [True: 608, False: 23]
  ------------------
  329|    608|            {
  330|       |                /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
  331|    608|                if (td->td_sminsamplevalue != NULL)
  ------------------
  |  Branch (331:21): [True: 7, False: 601]
  ------------------
  332|      7|                {
  333|      7|                    TIFFWarningExtR(tif, module,
  334|      7|                                    "SamplesPerPixel tag value is changing, "
  335|      7|                                    "but SMinSampleValue tag was read with a "
  336|      7|                                    "different value. Canceling it");
  337|      7|                    TIFFClrFieldBit(tif, FIELD_SMINSAMPLEVALUE);
  ------------------
  |  |  250|      7|#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  247|      7|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
  |  |  ------------------
  |  |  |  |  246|      7|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  338|      7|                    _TIFFfreeExt(tif, td->td_sminsamplevalue);
  339|      7|                    td->td_sminsamplevalue = NULL;
  340|      7|                }
  341|    608|                if (td->td_smaxsamplevalue != NULL)
  ------------------
  |  Branch (341:21): [True: 0, False: 608]
  ------------------
  342|      0|                {
  343|      0|                    TIFFWarningExtR(tif, module,
  344|      0|                                    "SamplesPerPixel tag value is changing, "
  345|      0|                                    "but SMaxSampleValue tag was read with a "
  346|      0|                                    "different value. Canceling it");
  347|      0|                    TIFFClrFieldBit(tif, FIELD_SMAXSAMPLEVALUE);
  ------------------
  |  |  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))
  |  |  ------------------
  ------------------
  348|      0|                    _TIFFfreeExt(tif, td->td_smaxsamplevalue);
  349|      0|                    td->td_smaxsamplevalue = NULL;
  350|      0|                }
  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|    608|                if (td->td_transferfunction[0] != NULL &&
  ------------------
  |  Branch (354:21): [True: 0, False: 608]
  ------------------
  355|      0|                    (v - td->td_extrasamples > 1) &&
  ------------------
  |  Branch (355:21): [True: 0, False: 0]
  ------------------
  356|      0|                    !(td->td_samplesperpixel - td->td_extrasamples > 1))
  ------------------
  |  Branch (356:21): [True: 0, False: 0]
  ------------------
  357|      0|                {
  358|      0|                    TIFFWarningExtR(tif, module,
  359|      0|                                    "SamplesPerPixel tag value is changing, "
  360|      0|                                    "but TransferFunction was read with a "
  361|      0|                                    "different value. Canceling it");
  362|      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))
  |  |  ------------------
  ------------------
  363|      0|                    _TIFFfreeExt(tif, td->td_transferfunction[0]);
  364|      0|                    td->td_transferfunction[0] = NULL;
  365|      0|                }
  366|    608|            }
  367|    631|            td->td_samplesperpixel = (uint16_t)v;
  368|    631|            break;
  369|    426|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|    426|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (369:9): [True: 426, False: 8.33k]
  ------------------
  370|    426|            v32 = (uint32_t)va_arg(ap, uint32_t);
  371|    426|            if (v32 == 0)
  ------------------
  |  Branch (371:17): [True: 0, False: 426]
  ------------------
  372|      0|                goto badvalue32;
  373|    426|            td->td_rowsperstrip = v32;
  374|    426|            if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
  ------------------
  |  |  248|    426|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    426|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    426|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (374:17): [True: 425, False: 1]
  ------------------
  375|    425|            {
  376|    425|                td->td_tilelength = v32;
  377|    425|                td->td_tilewidth = td->td_imagewidth;
  378|    425|            }
  379|    426|            break;
  380|      0|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      0|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (380:9): [True: 0, False: 8.75k]
  ------------------
  381|      0|            td->td_minsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
  382|      0|            break;
  383|      0|        case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|      0|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (383:9): [True: 0, False: 8.75k]
  ------------------
  384|      0|            td->td_maxsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
  385|      0|            break;
  386|      7|        case TIFFTAG_SMINSAMPLEVALUE:
  ------------------
  |  |  340|      7|#define TIFFTAG_SMINSAMPLEVALUE 340        /* !variable MinSampleValue */
  ------------------
  |  Branch (386:9): [True: 7, False: 8.74k]
  ------------------
  387|      7|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|      7|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (387:17): [True: 7, False: 0]
  ------------------
  388|      7|                _TIFFsetDoubleArrayExt(tif, &td->td_sminsamplevalue,
  389|      7|                                       va_arg(ap, double *),
  390|      7|                                       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|      7|            break;
  396|      0|        case TIFFTAG_SMAXSAMPLEVALUE:
  ------------------
  |  |  341|      0|#define TIFFTAG_SMAXSAMPLEVALUE 341        /* !variable MaxSampleValue */
  ------------------
  |  Branch (396:9): [True: 0, False: 8.75k]
  ------------------
  397|      0|            if (tif->tif_flags & TIFF_PERSAMPLE)
  ------------------
  |  |  143|      0|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
  |  Branch (397:17): [True: 0, False: 0]
  ------------------
  398|      0|                _TIFFsetDoubleArrayExt(tif, &td->td_smaxsamplevalue,
  399|      0|                                       va_arg(ap, double *),
  400|      0|                                       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|      0|            break;
  406|     79|        case TIFFTAG_XRESOLUTION:
  ------------------
  |  |  262|     79|#define TIFFTAG_XRESOLUTION 282            /* pixels/resolution in x */
  ------------------
  |  Branch (406:9): [True: 79, False: 8.67k]
  ------------------
  407|     79|            dblval = va_arg(ap, double);
  408|     79|            if (isnan(dblval) || dblval < 0)
  ------------------
  |  Branch (408:17): [True: 0, False: 79]
  |  Branch (408:34): [True: 0, False: 79]
  ------------------
  409|      0|                goto badvaluedouble;
  410|     79|            td->td_xresolution = _TIFFClampDoubleToFloat(dblval);
  411|     79|            break;
  412|     97|        case TIFFTAG_YRESOLUTION:
  ------------------
  |  |  263|     97|#define TIFFTAG_YRESOLUTION 283            /* pixels/resolution in y */
  ------------------
  |  Branch (412:9): [True: 97, False: 8.65k]
  ------------------
  413|     97|            dblval = va_arg(ap, double);
  414|     97|            if (isnan(dblval) || dblval < 0)
  ------------------
  |  Branch (414:17): [True: 0, False: 97]
  |  Branch (414:34): [True: 0, False: 97]
  ------------------
  415|      0|                goto badvaluedouble;
  416|     97|            td->td_yresolution = _TIFFClampDoubleToFloat(dblval);
  417|     97|            break;
  418|    786|        case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|    786|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (418:9): [True: 786, False: 7.97k]
  ------------------
  419|    786|            v = (uint16_t)va_arg(ap, uint16_vap);
  420|    786|            if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  265|  1.57k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
                          if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|     73|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (420:17): [True: 73, False: 713]
  |  Branch (420:45): [True: 0, False: 73]
  ------------------
  421|      0|                goto badvalue;
  422|    786|            td->td_planarconfig = (uint16_t)v;
  423|    786|            break;
  424|      2|        case TIFFTAG_XPOSITION:
  ------------------
  |  |  268|      2|#define TIFFTAG_XPOSITION 286              /* x page offset of image lhs */
  ------------------
  |  Branch (424:9): [True: 2, False: 8.75k]
  ------------------
  425|      2|            td->td_xposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
  426|      2|            break;
  427|      0|        case TIFFTAG_YPOSITION:
  ------------------
  |  |  269|      0|#define TIFFTAG_YPOSITION 287              /* y page offset of image lhs */
  ------------------
  |  Branch (427:9): [True: 0, False: 8.75k]
  ------------------
  428|      0|            td->td_yposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
  429|      0|            break;
  430|      9|        case TIFFTAG_RESOLUTIONUNIT:
  ------------------
  |  |  287|      9|#define TIFFTAG_RESOLUTIONUNIT 296         /* units of resolutions */
  ------------------
  |  Branch (430:9): [True: 9, False: 8.74k]
  ------------------
  431|      9|            v = (uint16_t)va_arg(ap, uint16_vap);
  432|      9|            if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
  ------------------
  |  |  288|     18|#define RESUNIT_NONE 1                     /* no meaningful units */
  ------------------
                          if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
  ------------------
  |  |  290|      5|#define RESUNIT_CENTIMETER 3               /* metric */
  ------------------
  |  Branch (432:17): [True: 4, False: 5]
  |  Branch (432:37): [True: 4, False: 1]
  ------------------
  433|      8|                goto badvalue;
  434|      1|            td->td_resolutionunit = (uint16_t)v;
  435|      1|            break;
  436|      8|        case TIFFTAG_PAGENUMBER:
  ------------------
  |  |  291|      8|#define TIFFTAG_PAGENUMBER 297             /* page numbers of multi-page */
  ------------------
  |  Branch (436:9): [True: 8, False: 8.74k]
  ------------------
  437|      8|            td->td_pagenumber[0] = (uint16_t)va_arg(ap, uint16_vap);
  438|      8|            td->td_pagenumber[1] = (uint16_t)va_arg(ap, uint16_vap);
  439|      8|            break;
  440|      0|        case TIFFTAG_HALFTONEHINTS:
  ------------------
  |  |  310|      0|#define TIFFTAG_HALFTONEHINTS 321          /* !highlight+shadow info */
  ------------------
  |  Branch (440:9): [True: 0, False: 8.75k]
  ------------------
  441|      0|            td->td_halftonehints[0] = (uint16_t)va_arg(ap, uint16_vap);
  442|      0|            td->td_halftonehints[1] = (uint16_t)va_arg(ap, uint16_vap);
  443|      0|            break;
  444|      2|        case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|      2|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (444:9): [True: 2, False: 8.75k]
  ------------------
  445|      2|            if (td->td_bitspersample >= 32)
  ------------------
  |  Branch (445:17): [True: 0, False: 2]
  ------------------
  446|      0|            {
  447|      0|                v = td->td_bitspersample;
  448|      0|                goto badvalue;
  449|      0|            }
  450|      2|            v32 = 1U << td->td_bitspersample;
  451|      2|            _TIFFsetShortArrayExt(tif, &td->td_colormap[0],
  452|      2|                                  va_arg(ap, uint16_t *), v32);
  453|      2|            _TIFFsetShortArrayExt(tif, &td->td_colormap[1],
  454|      2|                                  va_arg(ap, uint16_t *), v32);
  455|      2|            _TIFFsetShortArrayExt(tif, &td->td_colormap[2],
  456|      2|                                  va_arg(ap, uint16_t *), v32);
  457|      2|            break;
  458|    338|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|    338|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (458:9): [True: 338, False: 8.41k]
  ------------------
  459|    338|            if (!setExtraSamples(tif, ap, &v))
  ------------------
  |  Branch (459:17): [True: 1, False: 337]
  ------------------
  460|      1|                goto badvalue;
  461|    337|            break;
  462|    337|        case TIFFTAG_MATTEING:
  ------------------
  |  |  405|      0|#define TIFFTAG_MATTEING 32995   /* $use ExtraSamples */
  ------------------
  |  Branch (462:9): [True: 0, False: 8.75k]
  ------------------
  463|      0|            td->td_extrasamples = (((uint16_t)va_arg(ap, uint16_vap)) != 0);
  464|      0|            if (td->td_extrasamples)
  ------------------
  |  Branch (464:17): [True: 0, False: 0]
  ------------------
  465|      0|            {
  466|      0|                uint16_t sv = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|      0|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  467|      0|                _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, &sv, 1);
  468|      0|            }
  469|      0|            break;
  470|     71|        case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|     71|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (470:9): [True: 71, False: 8.68k]
  ------------------
  471|     71|            v32 = (uint32_t)va_arg(ap, uint32_t);
  472|     71|            if (v32 % 16)
  ------------------
  |  Branch (472:17): [True: 71, False: 0]
  ------------------
  473|     71|            {
  474|     71|                if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (474:21): [True: 0, False: 71]
  ------------------
  475|      0|                    goto badvalue32;
  476|     71|                TIFFWarningExtR(
  477|     71|                    tif, tif->tif_name,
  478|     71|                    "Nonstandard tile width %" PRIu32 ", convert file", v32);
  479|     71|            }
  480|     71|            td->td_tilewidth = v32;
  481|     71|            tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|     71|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  482|     71|            break;
  483|      3|        case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|      3|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (483:9): [True: 3, False: 8.75k]
  ------------------
  484|      3|            v32 = (uint32_t)va_arg(ap, uint32_t);
  485|      3|            if (v32 % 16)
  ------------------
  |  Branch (485:17): [True: 1, False: 2]
  ------------------
  486|      1|            {
  487|      1|                if (tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (487:21): [True: 0, False: 1]
  ------------------
  488|      0|                    goto badvalue32;
  489|      1|                TIFFWarningExtR(
  490|      1|                    tif, tif->tif_name,
  491|      1|                    "Nonstandard tile length %" PRIu32 ", convert file", v32);
  492|      1|            }
  493|      3|            td->td_tilelength = v32;
  494|      3|            tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|      3|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  495|      3|            break;
  496|      0|        case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|      0|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (496:9): [True: 0, False: 8.75k]
  ------------------
  497|      0|            v32 = (uint32_t)va_arg(ap, uint32_t);
  498|      0|            if (v32 == 0)
  ------------------
  |  Branch (498:17): [True: 0, False: 0]
  ------------------
  499|      0|                goto badvalue32;
  500|      0|            td->td_tiledepth = v32;
  501|      0|            break;
  502|      0|        case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|      0|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (502:9): [True: 0, False: 8.75k]
  ------------------
  503|      0|            v = (uint16_t)va_arg(ap, uint16_vap);
  504|      0|            switch (v)
  505|      0|            {
  506|      0|                case DATATYPE_VOID:
  ------------------
  |  |   39|      0|#define DATATYPE_VOID 0   /* !untyped data */
  ------------------
  |  Branch (506:17): [True: 0, False: 0]
  ------------------
  507|      0|                    v = SAMPLEFORMAT_VOID;
  ------------------
  |  |  337|      0|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
  508|      0|                    break;
  509|      0|                case DATATYPE_INT:
  ------------------
  |  |   40|      0|#define DATATYPE_INT 1    /* !signed integer data */
  ------------------
  |  Branch (509:17): [True: 0, False: 0]
  ------------------
  510|      0|                    v = SAMPLEFORMAT_INT;
  ------------------
  |  |  335|      0|#define SAMPLEFORMAT_INT 2                 /* !signed integer data */
  ------------------
  511|      0|                    break;
  512|      0|                case DATATYPE_UINT:
  ------------------
  |  |   41|      0|#define DATATYPE_UINT 2   /* !unsigned integer data */
  ------------------
  |  Branch (512:17): [True: 0, False: 0]
  ------------------
  513|      0|                    v = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  514|      0|                    break;
  515|      0|                case DATATYPE_IEEEFP:
  ------------------
  |  |   42|      0|#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
  ------------------
  |  Branch (515:17): [True: 0, False: 0]
  ------------------
  516|      0|                    v = SAMPLEFORMAT_IEEEFP;
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  517|      0|                    break;
  518|      0|                default:
  ------------------
  |  Branch (518:17): [True: 0, False: 0]
  ------------------
  519|      0|                    goto badvalue;
  520|      0|            }
  521|      0|            td->td_sampleformat = (uint16_t)v;
  522|      0|            break;
  523|      2|        case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|      2|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (523:9): [True: 2, False: 8.75k]
  ------------------
  524|      2|            v = (uint16_t)va_arg(ap, uint16_vap);
  525|      2|            if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
  ------------------
  |  |  334|      4|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
                          if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
  ------------------
  |  |  339|      2|#define SAMPLEFORMAT_COMPLEXIEEEFP 6       /* !complex ieee floating */
  ------------------
  |  Branch (525:17): [True: 0, False: 2]
  |  Branch (525:42): [True: 0, False: 2]
  ------------------
  526|      0|                goto badvalue;
  527|      2|            td->td_sampleformat = (uint16_t)v;
  528|       |
  529|       |            /*  Try to fix up the SWAB function for complex data. */
  530|      2|            if (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT &&
  ------------------
  |  |  338|      4|#define SAMPLEFORMAT_COMPLEXINT 5          /* !complex signed int */
  ------------------
  |  Branch (530:17): [True: 0, False: 2]
  ------------------
  531|      0|                td->td_bitspersample == 32 &&
  ------------------
  |  Branch (531:17): [True: 0, False: 0]
  ------------------
  532|      0|                tif->tif_postdecode == _TIFFSwab32BitData)
  ------------------
  |  Branch (532:17): [True: 0, False: 0]
  ------------------
  533|      0|                tif->tif_postdecode = _TIFFSwab16BitData;
  534|      2|            else if ((td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT ||
  ------------------
  |  |  338|      4|#define SAMPLEFORMAT_COMPLEXINT 5          /* !complex signed int */
  ------------------
  |  Branch (534:23): [True: 0, False: 2]
  ------------------
  535|      2|                      td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) &&
  ------------------
  |  |  339|      2|#define SAMPLEFORMAT_COMPLEXIEEEFP 6       /* !complex ieee floating */
  ------------------
  |  Branch (535:23): [True: 0, False: 2]
  ------------------
  536|      0|                     td->td_bitspersample == 64 &&
  ------------------
  |  Branch (536:22): [True: 0, False: 0]
  ------------------
  537|      0|                     tif->tif_postdecode == _TIFFSwab64BitData)
  ------------------
  |  Branch (537:22): [True: 0, False: 0]
  ------------------
  538|      0|                tif->tif_postdecode = _TIFFSwab32BitData;
  539|      2|            break;
  540|      0|        case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|      0|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (540:9): [True: 0, False: 8.75k]
  ------------------
  541|      0|            td->td_imagedepth = (uint32_t)va_arg(ap, uint32_t);
  542|      0|            break;
  543|      0|        case TIFFTAG_SUBIFD:
  ------------------
  |  |  321|      0|#define TIFFTAG_SUBIFD 330                 /* subimage descriptors */
  ------------------
  |  Branch (543:9): [True: 0, False: 8.75k]
  ------------------
  544|      0|            if ((tif->tif_flags & TIFF_INSUBIFD) == 0)
  ------------------
  |  |  132|      0|#define TIFF_INSUBIFD 0x02000U    /* currently writing a subifd */
  ------------------
  |  Branch (544:17): [True: 0, False: 0]
  ------------------
  545|      0|            {
  546|      0|                td->td_nsubifd = (uint16_t)va_arg(ap, uint16_vap);
  547|      0|                _TIFFsetLong8Array(tif, &td->td_subifd,
  548|      0|                                   (uint64_t *)va_arg(ap, uint64_t *),
  549|      0|                                   (uint32_t)td->td_nsubifd);
  550|      0|            }
  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|      0|            break;
  558|      0|        case TIFFTAG_YCBCRPOSITIONING:
  ------------------
  |  |  389|      0|#define TIFFTAG_YCBCRPOSITIONING 531       /* !subsample positioning */
  ------------------
  |  Branch (558:9): [True: 0, False: 8.75k]
  ------------------
  559|      0|            td->td_ycbcrpositioning = (uint16_t)va_arg(ap, uint16_vap);
  560|      0|            break;
  561|    138|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|    138|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (561:9): [True: 138, False: 8.61k]
  ------------------
  562|    138|            td->td_ycbcrsubsampling[0] = (uint16_t)va_arg(ap, uint16_vap);
  563|    138|            td->td_ycbcrsubsampling[1] = (uint16_t)va_arg(ap, uint16_vap);
  564|    138|            break;
  565|      0|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      0|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (565:9): [True: 0, False: 8.75k]
  ------------------
  566|      0|        {
  567|      0|            uint32_t i;
  568|      0|            uint32_t count;
  569|      0|            if (td->td_bitspersample >= 32)
  ------------------
  |  Branch (569:17): [True: 0, False: 0]
  ------------------
  570|      0|            {
  571|      0|                v = td->td_bitspersample;
  572|      0|                goto badvalue;
  573|      0|            }
  574|      0|            count = 1U << td->td_bitspersample;
  575|      0|            v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
  ------------------
  |  Branch (575:17): [True: 0, False: 0]
  ------------------
  576|      0|            for (i = 0; i < v; i++)
  ------------------
  |  Branch (576:25): [True: 0, False: 0]
  ------------------
  577|      0|                _TIFFsetShortArrayExt(tif, &td->td_transferfunction[i],
  578|      0|                                      va_arg(ap, uint16_t *), count);
  579|      0|            break;
  580|      0|        }
  581|      2|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|      2|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (581:9): [True: 2, False: 8.75k]
  ------------------
  582|       |            /* XXX should check for null range */
  583|      2|            _TIFFsetFloatArrayExt(tif, &td->td_refblackwhite,
  584|      2|                                  va_arg(ap, float *), 6);
  585|      2|            break;
  586|      5|        case TIFFTAG_INKNAMES:
  ------------------
  |  |  325|      5|#define TIFFTAG_INKNAMES 333               /* !ascii names of inks */
  ------------------
  |  Branch (586:9): [True: 5, False: 8.75k]
  ------------------
  587|      5|        {
  588|      5|            v = (uint16_t)va_arg(ap, uint16_vap);
  589|      5|            s = va_arg(ap, char *);
  590|      5|            uint16_t ninksinstring;
  591|      5|            ninksinstring = countInkNamesString(tif, v, s);
  592|      5|            status = ninksinstring > 0;
  593|      5|            if (ninksinstring > 0)
  ------------------
  |  Branch (593:17): [True: 5, False: 0]
  ------------------
  594|      5|            {
  595|      5|                _TIFFsetNString(tif, &td->td_inknames, s, v);
  596|      5|                td->td_inknameslen = (int)v;
  597|       |                /* Set NumberOfInks to the value ninksinstring */
  598|      5|                if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
  ------------------
  |  |  248|      5|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      5|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      5|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 0, False: 5]
  |  |  ------------------
  ------------------
  599|      0|                {
  600|      0|                    if (td->td_numberofinks != ninksinstring)
  ------------------
  |  Branch (600:25): [True: 0, False: 0]
  ------------------
  601|      0|                    {
  602|      0|                        TIFFErrorExtR(
  603|      0|                            tif, module,
  604|      0|                            "Warning %s; Tag %s:\n  Value %" PRIu16
  605|      0|                            " of NumberOfInks is different from the number of "
  606|      0|                            "inks %" PRIu16
  607|      0|                            ".\n  -> NumberOfInks value adapted to %" PRIu16 "",
  608|      0|                            tif->tif_name, fip->field_name, td->td_numberofinks,
  609|      0|                            ninksinstring, ninksinstring);
  610|      0|                        td->td_numberofinks = ninksinstring;
  611|      0|                    }
  612|      0|                }
  613|      5|                else
  614|      5|                {
  615|      5|                    td->td_numberofinks = ninksinstring;
  616|      5|                    TIFFSetFieldBit(tif, FIELD_NUMBEROFINKS);
  ------------------
  |  |  249|      5|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|      5|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|      5|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  617|      5|                }
  618|      5|                if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|      5|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      5|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      5|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 5, False: 0]
  |  |  ------------------
  ------------------
  619|      5|                {
  620|      5|                    if (td->td_numberofinks != td->td_samplesperpixel)
  ------------------
  |  Branch (620:25): [True: 5, False: 0]
  ------------------
  621|      5|                    {
  622|      5|                        TIFFErrorExtR(tif, module,
  623|      5|                                      "Warning %s; Tag %s:\n  Value %" PRIu16
  624|      5|                                      " of NumberOfInks is different from the "
  625|      5|                                      "SamplesPerPixel value %" PRIu16 "",
  626|      5|                                      tif->tif_name, fip->field_name,
  627|      5|                                      td->td_numberofinks,
  628|      5|                                      td->td_samplesperpixel);
  629|      5|                    }
  630|      5|                }
  631|      5|            }
  632|      5|        }
  633|      5|        break;
  634|      1|        case TIFFTAG_NUMBEROFINKS:
  ------------------
  |  |  326|      1|#define TIFFTAG_NUMBEROFINKS 334           /* !number of inks */
  ------------------
  |  Branch (634:9): [True: 1, False: 8.75k]
  ------------------
  635|      1|            v = (uint16_t)va_arg(ap, uint16_vap);
  636|       |            /* If InkNames already set also NumberOfInks is set accordingly and
  637|       |             * should be equal */
  638|      1|            if (TIFFFieldSet(tif, FIELD_INKNAMES))
  ------------------
  |  |  248|      1|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      1|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      1|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  639|      0|            {
  640|      0|                if (v != td->td_numberofinks)
  ------------------
  |  Branch (640:21): [True: 0, False: 0]
  ------------------
  641|      0|                {
  642|      0|                    TIFFErrorExtR(
  643|      0|                        tif, module,
  644|      0|                        "Error %s; Tag %s:\n  It is not possible to set the "
  645|      0|                        "value %" PRIu32
  646|      0|                        " for NumberOfInks\n  which is different from the "
  647|      0|                        "number of inks in the InkNames tag (%" PRIu16 ")",
  648|      0|                        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|      0|                    status = 0;
  652|      0|                }
  653|      0|            }
  654|      1|            else
  655|      1|            {
  656|      1|                td->td_numberofinks = (uint16_t)v;
  657|      1|                if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|      1|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      1|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      1|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  658|      1|                {
  659|      1|                    if (td->td_numberofinks != td->td_samplesperpixel)
  ------------------
  |  Branch (659:25): [True: 1, False: 0]
  ------------------
  660|      1|                    {
  661|      1|                        TIFFErrorExtR(tif, module,
  662|      1|                                      "Warning %s; Tag %s:\n  Value %" PRIu32
  663|      1|                                      " of NumberOfInks is different from the "
  664|      1|                                      "SamplesPerPixel value %" PRIu16 "",
  665|      1|                                      tif->tif_name, fip->field_name, v,
  666|      1|                                      td->td_samplesperpixel);
  667|      1|                    }
  668|      1|                }
  669|      1|            }
  670|      1|            break;
  671|      0|        case TIFFTAG_PERSAMPLE:
  ------------------
  |  |  752|      0|#define TIFFTAG_PERSAMPLE 65563        /* interface for per sample tags */
  ------------------
  |  Branch (671:9): [True: 0, False: 8.75k]
  ------------------
  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|  2.00k|        default:
  ------------------
  |  Branch (678:9): [True: 2.00k, False: 6.75k]
  ------------------
  679|  2.00k|        {
  680|  2.00k|            TIFFTagValue *tv;
  681|  2.00k|            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|  2.00k|            if (fip->field_bit == FIELD_IGNORE)
  ------------------
  |  |  190|  2.00k|#define FIELD_IGNORE 0
  ------------------
  |  Branch (694:17): [True: 0, False: 2.00k]
  ------------------
  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|  2.00k|            if (fip->field_bit != FIELD_CUSTOM)
  ------------------
  |  |  346|  2.00k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (704:17): [True: 0, False: 2.00k]
  ------------------
  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|  2.00k|            tv = NULL;
  719|  4.76k|            for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++)
  ------------------
  |  Branch (719:31): [True: 2.76k, False: 2.00k]
  ------------------
  720|  2.76k|            {
  721|  2.76k|                if (td->td_customValues[iCustom].info->field_tag == tag)
  ------------------
  |  Branch (721:21): [True: 0, False: 2.76k]
  ------------------
  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|  2.76k|            }
  732|       |
  733|       |            /*
  734|       |             * Grow the custom list if the entry was not found.
  735|       |             */
  736|  2.00k|            if (tv == NULL)
  ------------------
  |  Branch (736:17): [True: 2.00k, False: 0]
  ------------------
  737|  2.00k|            {
  738|  2.00k|                TIFFTagValue *new_customValues;
  739|       |
  740|  2.00k|                new_customValues = (TIFFTagValue *)_TIFFreallocExt(
  741|  2.00k|                    tif, td->td_customValues,
  742|  2.00k|                    (tmsize_t)(sizeof(TIFFTagValue) *
  743|  2.00k|                               (size_t)(td->td_customValueCount + 1)));
  744|  2.00k|                if (!new_customValues)
  ------------------
  |  Branch (744:21): [True: 0, False: 2.00k]
  ------------------
  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|  2.00k|                td->td_customValueCount++;
  755|  2.00k|                td->td_customValues = new_customValues;
  756|       |
  757|  2.00k|                tv = td->td_customValues + (td->td_customValueCount - 1);
  758|  2.00k|                tv->info = fip;
  759|  2.00k|                tv->value = NULL;
  760|  2.00k|                tv->count = 0;
  761|  2.00k|            }
  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|  2.00k|            tv_size = TIFFFieldSetGetSize(fip);
  769|  2.00k|            if (tv_size == 0)
  ------------------
  |  Branch (769:17): [True: 0, False: 2.00k]
  ------------------
  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|  2.00k|            if (fip->field_type == TIFF_ASCII)
  ------------------
  |  Branch (777:17): [True: 526, False: 1.47k]
  ------------------
  778|    526|            {
  779|    526|                uint32_t ma;
  780|    526|                const char *mb;
  781|    526|                if (fip->field_passcount)
  ------------------
  |  Branch (781:21): [True: 15, False: 511]
  ------------------
  782|     15|                {
  783|     15|                    assert(fip->field_writecount == TIFF_VARIABLE2);
  ------------------
  |  Branch (783:21): [True: 0, False: 15]
  |  Branch (783:21): [True: 15, False: 0]
  ------------------
  784|     15|                    ma = (uint32_t)va_arg(ap, uint32_t);
  785|     15|                    mb = (const char *)va_arg(ap, const char *);
  786|     15|                }
  787|    511|                else
  788|    511|                {
  789|    511|                    mb = (const char *)va_arg(ap, const char *);
  790|    511|                    size_t len = strlen(mb) + 1;
  791|    511|                    if (len >= 0x80000000U)
  ------------------
  |  Branch (791:25): [True: 0, False: 511]
  ------------------
  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|    511|                    ma = (uint32_t)len;
  801|    511|                }
  802|    526|                tv->count = (int)ma;
  803|    526|                setByteArray(tif, &tv->value, mb, ma, 1);
  804|    526|            }
  805|  1.47k|            else
  806|  1.47k|            {
  807|  1.47k|                if (fip->field_passcount)
  ------------------
  |  Branch (807:21): [True: 1.41k, False: 65]
  ------------------
  808|  1.41k|                {
  809|  1.41k|                    if (fip->field_writecount == TIFF_VARIABLE2)
  ------------------
  |  |  344|  1.41k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (809:25): [True: 1.40k, False: 4]
  ------------------
  810|  1.40k|                        tv->count = (int)va_arg(ap, uint32_t);
  811|      4|                    else
  812|      4|                        tv->count = va_arg(ap, int);
  813|  1.41k|                }
  814|     65|                else if (fip->field_writecount == TIFF_VARIABLE ||
  ------------------
  |  |  342|    130|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (814:26): [True: 0, False: 65]
  ------------------
  815|     65|                         fip->field_writecount == TIFF_VARIABLE2)
  ------------------
  |  |  344|     65|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (815:26): [True: 0, False: 65]
  ------------------
  816|      0|                    tv->count = 1;
  817|     65|                else if (fip->field_writecount == TIFF_SPP)
  ------------------
  |  |  343|     65|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (817:26): [True: 0, False: 65]
  ------------------
  818|      0|                    tv->count = td->td_samplesperpixel;
  819|     65|                else
  820|     65|                    tv->count = fip->field_writecount;
  821|       |
  822|  1.47k|                if (tv->count == 0)
  ------------------
  |  Branch (822:21): [True: 484, False: 991]
  ------------------
  823|    484|                {
  824|    484|                    TIFFWarningExtR(tif, module,
  825|    484|                                    "%s: Null count for \"%s\" (type "
  826|    484|                                    "%u, writecount %d, passcount %d)",
  827|    484|                                    tif->tif_name, fip->field_name,
  828|    484|                                    fip->field_type, fip->field_writecount,
  829|    484|                                    fip->field_passcount);
  830|    484|                    break;
  831|    484|                }
  832|       |
  833|    991|                tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
  834|    991|                                             "custom tag binary object");
  835|    991|                if (!tv->value)
  ------------------
  |  Branch (835:21): [True: 0, False: 991]
  ------------------
  836|      0|                {
  837|      0|                    status = 0;
  838|      0|                    goto end;
  839|      0|                }
  840|       |
  841|    991|                if (fip->field_tag == TIFFTAG_DOTRANGE &&
  ------------------
  |  |  327|  1.98k|#define TIFFTAG_DOTRANGE 336               /* !0% and 100% dot codes */
  ------------------
  |  Branch (841:21): [True: 0, False: 991]
  ------------------
  842|      0|                    strcmp(fip->field_name, "DotRange") == 0)
  ------------------
  |  Branch (842:21): [True: 0, False: 0]
  ------------------
  843|      0|                {
  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|      0|                    uint16_t v2[2];
  849|      0|                    v2[0] = (uint16_t)va_arg(ap, int);
  850|      0|                    v2[1] = (uint16_t)va_arg(ap, int);
  851|      0|                    _TIFFmemcpy(tv->value, &v2, 4);
  852|      0|                }
  853|       |
  854|    991|                else if (fip->field_passcount ||
  ------------------
  |  Branch (854:26): [True: 926, False: 65]
  ------------------
  855|     65|                         fip->field_writecount == TIFF_VARIABLE ||
  ------------------
  |  |  342|  1.05k|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (855:26): [True: 0, False: 65]
  ------------------
  856|     65|                         fip->field_writecount == TIFF_VARIABLE2 ||
  ------------------
  |  |  344|  1.05k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (856:26): [True: 0, False: 65]
  ------------------
  857|     65|                         fip->field_writecount == TIFF_SPP || tv->count > 1)
  ------------------
  |  |  343|  1.05k|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (857:26): [True: 0, False: 65]
  |  Branch (857:63): [True: 7, False: 58]
  ------------------
  858|    933|                {
  859|       |                    /*--: Rational2Double: For Rationals tv_size is set above to
  860|       |                     * 4 or 8 according to fip->set_get_field_type! */
  861|    933|                    _TIFFmemcpy(tv->value, va_arg(ap, void *),
  862|    933|                                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|    933|                    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    933|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (865:25): [True: 928, False: 5]
  ------------------
  866|    928|                    {
  867|    928|                        if (tv->info->field_type == TIFF_LONG8 ||
  ------------------
  |  Branch (867:29): [True: 33, False: 895]
  ------------------
  868|    895|                            tv->info->field_type == TIFF_IFD8)
  ------------------
  |  Branch (868:29): [True: 4, False: 891]
  ------------------
  869|     37|                        {
  870|     37|                            uint64_t *pui64 = (uint64_t *)tv->value;
  871|     56|                            for (int i = 0; i < tv->count; i++)
  ------------------
  |  Branch (871:45): [True: 55, False: 1]
  ------------------
  872|     55|                            {
  873|     55|                                if (pui64[i] > 0xffffffffu)
  ------------------
  |  Branch (873:37): [True: 36, False: 19]
  ------------------
  874|     36|                                {
  875|     36|                                    TIFFErrorExtR(
  876|     36|                                        tif, module,
  877|     36|                                        "%s: Bad %s value %" PRIu64
  878|     36|                                        " at %d. array position for \"%s\" tag "
  879|     36|                                        "%u in ClassicTIFF. Tag won't be "
  880|     36|                                        "written to file",
  881|     36|                                        tif->tif_name,
  882|     36|                                        (tv->info->field_type == TIFF_LONG8
  ------------------
  |  Branch (882:42): [True: 32, False: 4]
  ------------------
  883|     36|                                             ? "LONG8"
  884|     36|                                             : "IFD8"),
  885|     36|                                        pui64[i], i, fip->field_name, tag);
  886|     36|                                    goto badvalueifd8long8;
  887|     36|                                }
  888|     55|                            }
  889|     37|                        }
  890|    891|                        else if (tv->info->field_type == TIFF_SLONG8)
  ------------------
  |  Branch (890:34): [True: 0, False: 891]
  ------------------
  891|      0|                        {
  892|      0|                            int64_t *pi64 = (int64_t *)tv->value;
  893|      0|                            for (int i = 0; i < tv->count; i++)
  ------------------
  |  Branch (893:45): [True: 0, False: 0]
  ------------------
  894|      0|                            {
  895|      0|                                if (pi64[i] > 2147483647 ||
  ------------------
  |  Branch (895:37): [True: 0, False: 0]
  ------------------
  896|      0|                                    pi64[i] < (-2147483647 - 1))
  ------------------
  |  Branch (896:37): [True: 0, False: 0]
  ------------------
  897|      0|                                {
  898|      0|                                    TIFFErrorExtR(
  899|      0|                                        tif, module,
  900|      0|                                        "%s: Bad SLONG8 value %" PRIi64
  901|      0|                                        " at %d. array position for \"%s\" tag "
  902|      0|                                        "%u in ClassicTIFF. Tag won't be "
  903|      0|                                        "written to file",
  904|      0|                                        tif->tif_name, pi64[i], i,
  905|      0|                                        fip->field_name, tag);
  906|      0|                                    goto badvalueifd8long8;
  907|      0|                                }
  908|      0|                            }
  909|      0|                        }
  910|    928|                    }
  911|    933|                }
  912|     58|                else
  913|     58|                {
  914|     58|                    char *val = (char *)tv->value;
  915|     58|                    assert(tv->count == 1);
  ------------------
  |  Branch (915:21): [True: 0, False: 58]
  |  Branch (915:21): [True: 58, False: 0]
  ------------------
  916|       |
  917|     58|                    switch (fip->field_type)
  918|     58|                    {
  919|      7|                        case TIFF_BYTE:
  ------------------
  |  Branch (919:25): [True: 7, False: 51]
  ------------------
  920|      7|                        case TIFF_UNDEFINED:
  ------------------
  |  Branch (920:25): [True: 0, False: 58]
  ------------------
  921|      7|                        {
  922|      7|                            uint8_t v2 = (uint8_t)va_arg(ap, int);
  923|      7|                            _TIFFmemcpy(val, &v2, tv_size);
  924|      7|                        }
  925|      7|                        break;
  926|      0|                        case TIFF_SBYTE:
  ------------------
  |  Branch (926:25): [True: 0, False: 58]
  ------------------
  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|      8|                        case TIFF_SHORT:
  ------------------
  |  Branch (932:25): [True: 8, False: 50]
  ------------------
  933|      8|                        {
  934|      8|                            uint16_t v2 = (uint16_t)va_arg(ap, int);
  935|      8|                            _TIFFmemcpy(val, &v2, tv_size);
  936|      8|                        }
  937|      8|                        break;
  938|      0|                        case TIFF_SSHORT:
  ------------------
  |  Branch (938:25): [True: 0, False: 58]
  ------------------
  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|     42|                        case TIFF_LONG:
  ------------------
  |  Branch (944:25): [True: 42, False: 16]
  ------------------
  945|     42|                        case TIFF_IFD:
  ------------------
  |  Branch (945:25): [True: 0, False: 58]
  ------------------
  946|     42|                        {
  947|     42|                            uint32_t v2 = va_arg(ap, uint32_t);
  948|     42|                            _TIFFmemcpy(val, &v2, tv_size);
  949|     42|                        }
  950|     42|                        break;
  951|      0|                        case TIFF_SLONG:
  ------------------
  |  Branch (951:25): [True: 0, False: 58]
  ------------------
  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|      0|                        case TIFF_LONG8:
  ------------------
  |  Branch (957:25): [True: 0, False: 58]
  ------------------
  958|      1|                        case TIFF_IFD8:
  ------------------
  |  Branch (958:25): [True: 1, False: 57]
  ------------------
  959|      1|                        {
  960|      1|                            uint64_t v2 = va_arg(ap, uint64_t);
  961|      1|                            _TIFFmemcpy(val, &v2, tv_size);
  962|       |                            /* Test here for too big values for ClassicTIFF and
  963|       |                             * delete custom field from custom list */
  964|      1|                            if (!(tif->tif_flags & TIFF_BIGTIFF) &&
  ------------------
  |  |  140|      1|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (964:33): [True: 1, False: 0]
  ------------------
  965|      1|                                (v2 > 0xffffffffu))
  ------------------
  |  Branch (965:33): [True: 0, False: 1]
  ------------------
  966|      0|                            {
  967|      0|                                TIFFErrorExtR(
  968|      0|                                    tif, module,
  969|      0|                                    "%s: Bad LONG8 or IFD8 value %" PRIu64
  970|      0|                                    " for \"%s\" tag %u in ClassicTIFF. Tag "
  971|      0|                                    "won't be written to file",
  972|      0|                                    tif->tif_name, v2, fip->field_name, tag);
  973|      0|                                goto badvalueifd8long8;
  974|      0|                            }
  975|      1|                        }
  976|      1|                        break;
  977|      1|                        case TIFF_SLONG8:
  ------------------
  |  Branch (977:25): [True: 0, False: 58]
  ------------------
  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: 58]
  ------------------
  997|      0|                        case TIFF_SRATIONAL:
  ------------------
  |  Branch (997:25): [True: 0, False: 58]
  ------------------
  998|       |                            /*-- Rational2Double: For Rationals tv_size is set
  999|       |                             * above to 4 or 8 according to
 1000|       |                             * fip->set_get_field_type!
 1001|       |                             */
 1002|      0|                            {
 1003|      0|                                if (tv_size == 8)
  ------------------
  |  Branch (1003:37): [True: 0, False: 0]
  ------------------
 1004|      0|                                {
 1005|      0|                                    double v2 = va_arg(ap, double);
 1006|      0|                                    _TIFFmemcpy(val, &v2, tv_size);
 1007|      0|                                }
 1008|      0|                                else
 1009|      0|                                {
 1010|       |                                    /*-- default should be tv_size == 4 */
 1011|      0|                                    float v3 = (float)va_arg(ap, double);
 1012|      0|                                    _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|      0|                                    if (tv_size != 4)
  ------------------
  |  Branch (1016:41): [True: 0, False: 0]
  ------------------
 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|      0|                                }
 1025|      0|                            }
 1026|      0|                            break;
 1027|      0|                        case TIFF_FLOAT:
  ------------------
  |  Branch (1027:25): [True: 0, False: 58]
  ------------------
 1028|      0|                        {
 1029|      0|                            float v2 =
 1030|      0|                                _TIFFClampDoubleToFloat(va_arg(ap, double));
 1031|      0|                            _TIFFmemcpy(val, &v2, tv_size);
 1032|      0|                        }
 1033|      0|                        break;
 1034|      0|                        case TIFF_DOUBLE:
  ------------------
  |  Branch (1034:25): [True: 0, False: 58]
  ------------------
 1035|      0|                        {
 1036|      0|                            double v2 = va_arg(ap, double);
 1037|      0|                            _TIFFmemcpy(val, &v2, tv_size);
 1038|      0|                        }
 1039|      0|                        break;
 1040|      0|                        case TIFF_NOTYPE:
  ------------------
  |  Branch (1040:25): [True: 0, False: 58]
  ------------------
 1041|      0|                        case TIFF_ASCII:
  ------------------
  |  Branch (1041:25): [True: 0, False: 58]
  ------------------
 1042|      0|                        default:
  ------------------
  |  Branch (1042:25): [True: 0, False: 58]
  ------------------
 1043|      0|                            _TIFFmemset(val, 0, tv_size);
 1044|      0|                            status = 0;
 1045|      0|                            break;
 1046|     58|                    }
 1047|     58|                }
 1048|    991|            }
 1049|  2.00k|        }
 1050|  8.75k|    }
 1051|  8.65k|    if (status)
  ------------------
  |  Branch (1051:9): [True: 8.65k, False: 0]
  ------------------
 1052|  8.65k|    {
 1053|  8.65k|        const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1054|  8.65k|        if (fip2)
  ------------------
  |  Branch (1054:13): [True: 8.65k, False: 0]
  ------------------
 1055|  8.65k|            TIFFSetFieldBit(tif, fip2->field_bit);
  ------------------
  |  |  249|  8.65k|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|  8.65k|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|  8.65k|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1056|  8.65k|        tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|  8.65k|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1057|  8.65k|    }
 1058|       |
 1059|  8.65k|end:
 1060|  8.65k|    va_end(ap);
 1061|  8.65k|    return (status);
 1062|     61|badvalue:
 1063|     61|{
 1064|     61|    const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1065|     61|    TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
 1066|     61|                  tif->tif_name, v, fip2 ? fip2->field_name : "Unknown");
  ------------------
  |  Branch (1066:37): [True: 61, False: 0]
  ------------------
 1067|     61|    va_end(ap);
 1068|     61|}
 1069|     61|    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|      0|badvaluedouble:
 1079|      0|{
 1080|      0|    const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
 1081|      0|    TIFFErrorExtR(tif, module, "%s: Bad value %f for \"%s\" tag", tif->tif_name,
 1082|      0|                  dblval, fip2 ? fip2->field_name : "Unknown");
  ------------------
  |  Branch (1082:27): [True: 0, False: 0]
  ------------------
 1083|      0|    va_end(ap);
 1084|      0|}
 1085|      0|    return (0);
 1086|     36|badvalueifd8long8:
 1087|     36|{
 1088|       |    /* Error message issued already above. */
 1089|     36|    TIFFTagValue *tv2 = NULL;
 1090|     36|    int iCustom2, iC2;
 1091|       |    /* Find the existing entry for this custom value. */
 1092|     90|    for (iCustom2 = 0; iCustom2 < td->td_customValueCount; iCustom2++)
  ------------------
  |  Branch (1092:24): [True: 90, False: 0]
  ------------------
 1093|     90|    {
 1094|     90|        if (td->td_customValues[iCustom2].info->field_tag == tag)
  ------------------
  |  Branch (1094:13): [True: 36, False: 54]
  ------------------
 1095|     36|        {
 1096|     36|            tv2 = td->td_customValues + (iCustom2);
 1097|     36|            break;
 1098|     36|        }
 1099|     90|    }
 1100|     36|    if (tv2 != NULL)
  ------------------
  |  Branch (1100:9): [True: 36, False: 0]
  ------------------
 1101|     36|    {
 1102|       |        /* Remove custom field from custom list */
 1103|     36|        if (tv2->value != NULL)
  ------------------
  |  Branch (1103:13): [True: 36, False: 0]
  ------------------
 1104|     36|        {
 1105|     36|            _TIFFfreeExt(tif, tv2->value);
 1106|     36|            tv2->value = NULL;
 1107|     36|        }
 1108|       |        /* Shorten list and close gap in customValues list.
 1109|       |         * Re-allocation of td_customValues not necessary here. */
 1110|     36|        td->td_customValueCount--;
 1111|     36|        for (iC2 = iCustom2; iC2 < td->td_customValueCount; iC2++)
  ------------------
  |  Branch (1111:30): [True: 0, False: 36]
  ------------------
 1112|      0|        {
 1113|      0|            td->td_customValues[iC2] = td->td_customValues[iC2 + 1];
 1114|      0|        }
 1115|     36|    }
 1116|      0|    else
 1117|      0|    {
 1118|      0|        assert(0);
  ------------------
  |  Branch (1118:9): [Folded, False: 0]
  |  Branch (1118:9): [Folded, False: 0]
  ------------------
 1119|      0|    }
 1120|     36|    va_end(ap);
 1121|     36|}
 1122|     36|    return (0);
 1123|     36|} /*-- _TIFFVSetField() --*/
tif_dir.c:setExtraSamples:
  139|    338|{
  140|       |/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
  141|    338|#define EXTRASAMPLE_COREL_UNASSALPHA 999
  142|       |
  143|    338|    uint16_t *va;
  144|    338|    uint32_t i;
  145|    338|    TIFFDirectory *td = &tif->tif_dir;
  146|    338|    static const char module[] = "setExtraSamples";
  147|       |
  148|    338|    *v = (uint16_t)va_arg(ap, uint16_vap);
  149|    338|    if ((uint16_t)*v > td->td_samplesperpixel)
  ------------------
  |  Branch (149:9): [True: 0, False: 338]
  ------------------
  150|      0|        return 0;
  151|    338|    va = va_arg(ap, uint16_t *);
  152|    338|    if (*v > 0 && va == NULL) /* typically missing param */
  ------------------
  |  Branch (152:9): [True: 337, False: 1]
  |  Branch (152:19): [True: 0, False: 337]
  ------------------
  153|      0|        return 0;
  154|    773|    for (i = 0; i < *v; i++)
  ------------------
  |  Branch (154:17): [True: 436, False: 337]
  ------------------
  155|    436|    {
  156|    436|        if (va[i] > EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|    436|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (156:13): [True: 1, False: 435]
  ------------------
  157|      1|        {
  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|      1|            if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
  ------------------
  |  |  141|      1|#define EXTRASAMPLE_COREL_UNASSALPHA 999
  ------------------
  |  Branch (164:17): [True: 0, False: 1]
  ------------------
  165|      0|                va[i] = EXTRASAMPLE_UNASSALPHA;
  ------------------
  |  |  332|      0|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  166|      1|            else
  167|      1|                return 0;
  168|      1|        }
  169|    436|    }
  170|       |
  171|    337|    if (td->td_transferfunction[0] != NULL &&
  ------------------
  |  Branch (171:9): [True: 0, False: 337]
  ------------------
  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|    337|    td->td_extrasamples = (uint16_t)*v;
  185|    337|    _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, va, td->td_extrasamples);
  186|    337|    return 1;
  187|       |
  188|    338|#undef EXTRASAMPLE_COREL_UNASSALPHA
  189|    338|}
tif_dir.c:countInkNamesString:
  196|      5|{
  197|      5|    uint16_t i = 0;
  198|       |
  199|      5|    if (slen > 0)
  ------------------
  |  Branch (199:9): [True: 5, False: 0]
  ------------------
  200|      5|    {
  201|      5|        const char *ep = s + slen;
  202|      5|        const char *cp = s;
  203|      5|        do
  204|  1.02k|        {
  205|  8.96k|            for (; cp < ep && *cp != '\0'; cp++)
  ------------------
  |  Branch (205:20): [True: 8.96k, False: 0]
  |  Branch (205:31): [True: 7.93k, False: 1.02k]
  ------------------
  206|  7.93k|            {
  207|  7.93k|            }
  208|  1.02k|            if (cp >= ep)
  ------------------
  |  Branch (208:17): [True: 0, False: 1.02k]
  ------------------
  209|      0|                goto bad;
  210|  1.02k|            cp++; /* skip \0 */
  211|  1.02k|            i++;
  212|  1.02k|        } while (cp < ep);
  ------------------
  |  Branch (212:18): [True: 1.01k, False: 5]
  ------------------
  213|      5|        return (i);
  214|      5|    }
  215|      0|bad:
  216|      0|    TIFFErrorExtR(tif, "TIFFSetField",
  217|      0|                  "%s: Invalid InkNames value; no null at given buffer end "
  218|      0|                  "location %" PRIu32 ", after %" PRIu16 " ink",
  219|      0|                  tif->tif_name, slen, i);
  220|      0|    return (0);
  221|      5|}
tif_dir.c:_TIFFsetNString:
   72|      5|{
   73|      5|    setByteArray(tif, (void **)cpp, cp, n, 1);
   74|      5|}
tif_dir.c:_TIFFVGetField:
 1234|  7.20k|{
 1235|  7.20k|    TIFFDirectory *td = &tif->tif_dir;
 1236|  7.20k|    int ret_val = 1;
 1237|  7.20k|    uint32_t standard_tag = tag;
 1238|  7.20k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  7.20k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
 1239|  7.20k|    if (fip == NULL) /* cannot happen since TIFFGetField() already checks it */
  ------------------
  |  Branch (1239:9): [True: 0, False: 7.20k]
  ------------------
 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|  7.20k|    if (fip->field_bit == FIELD_CUSTOM)
  ------------------
  |  |  346|  7.20k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (1248:9): [True: 82, False: 7.12k]
  ------------------
 1249|     82|    {
 1250|     82|        standard_tag = 0;
 1251|     82|    }
 1252|       |
 1253|  7.20k|    switch (standard_tag)
 1254|  7.20k|    {
 1255|      0|        case TIFFTAG_SUBFILETYPE:
  ------------------
  |  |  170|      0|#define TIFFTAG_SUBFILETYPE 254       /* subfile data descriptor */
  ------------------
  |  Branch (1255:9): [True: 0, False: 7.20k]
  ------------------
 1256|      0|            *va_arg(ap, uint32_t *) = td->td_subfiletype;
 1257|      0|            break;
 1258|  1.22k|        case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|  1.22k|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (1258:9): [True: 1.22k, False: 5.98k]
  ------------------
 1259|  1.22k|            *va_arg(ap, uint32_t *) = td->td_imagewidth;
 1260|  1.22k|            break;
 1261|  1.15k|        case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|  1.15k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (1261:9): [True: 1.15k, False: 6.05k]
  ------------------
 1262|  1.15k|            *va_arg(ap, uint32_t *) = td->td_imagelength;
 1263|  1.15k|            break;
 1264|    537|        case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|    537|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (1264:9): [True: 537, False: 6.67k]
  ------------------
 1265|    537|            *va_arg(ap, uint16_t *) = td->td_bitspersample;
 1266|    537|            break;
 1267|    657|        case TIFFTAG_COMPRESSION:
  ------------------
  |  |  181|    657|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (1267:9): [True: 657, False: 6.55k]
  ------------------
 1268|    657|            *va_arg(ap, uint16_t *) = td->td_compression;
 1269|    657|            break;
 1270|  1.38k|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|  1.38k|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (1270:9): [True: 1.38k, False: 5.82k]
  ------------------
 1271|  1.38k|            *va_arg(ap, uint16_t *) = td->td_photometric;
 1272|  1.38k|            break;
 1273|      0|        case TIFFTAG_THRESHHOLDING:
  ------------------
  |  |  234|      0|#define TIFFTAG_THRESHHOLDING 263          /* +thresholding used on data */
  ------------------
  |  Branch (1273:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 1277|      0|            *va_arg(ap, uint16_t *) = td->td_fillorder;
 1278|      0|            break;
 1279|    111|        case TIFFTAG_ORIENTATION:
  ------------------
  |  |  248|    111|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  |  Branch (1279:9): [True: 111, False: 7.09k]
  ------------------
 1280|    111|            *va_arg(ap, uint16_t *) = td->td_orientation;
 1281|    111|            break;
 1282|    521|        case TIFFTAG_SAMPLESPERPIXEL:
  ------------------
  |  |  257|    521|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (1282:9): [True: 521, False: 6.68k]
  ------------------
 1283|    521|            *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
 1284|    521|            break;
 1285|    548|        case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|    548|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (1285:9): [True: 548, False: 6.66k]
  ------------------
 1286|    548|            *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
 1287|    548|            break;
 1288|      0|        case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      0|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (1288:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 1326|      0|            *va_arg(ap, float *) = td->td_yresolution;
 1327|      0|            break;
 1328|    559|        case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|    559|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (1328:9): [True: 559, False: 6.64k]
  ------------------
 1329|    559|            *va_arg(ap, uint16_t *) = td->td_planarconfig;
 1330|    559|            break;
 1331|      0|        case TIFFTAG_XPOSITION:
  ------------------
  |  |  268|      0|#define TIFFTAG_XPOSITION 286              /* x page offset of image lhs */
  ------------------
  |  Branch (1331:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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|      0|        case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|      0|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (1348:9): [True: 0, False: 7.20k]
  ------------------
 1349|      0|            *va_arg(ap, const uint16_t **) = td->td_colormap[0];
 1350|      0|            *va_arg(ap, const uint16_t **) = td->td_colormap[1];
 1351|      0|            *va_arg(ap, const uint16_t **) = td->td_colormap[2];
 1352|      0|            break;
 1353|      0|        case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|      0|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (1353:9): [True: 0, False: 7.20k]
  ------------------
 1354|      0|        case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|      0|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (1354:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 1361|      0|        case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|      0|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (1361:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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|    288|        case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|    288|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (1372:9): [True: 288, False: 6.92k]
  ------------------
 1373|    288|            *va_arg(ap, uint16_t *) = td->td_extrasamples;
 1374|    288|            *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
 1375|    288|            break;
 1376|    103|        case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|    103|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (1376:9): [True: 103, False: 7.10k]
  ------------------
 1377|    103|            *va_arg(ap, uint32_t *) = td->td_tilewidth;
 1378|    103|            break;
 1379|     33|        case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|     33|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (1379:9): [True: 33, False: 7.17k]
  ------------------
 1380|     33|            *va_arg(ap, uint32_t *) = td->td_tilelength;
 1381|     33|            break;
 1382|      0|        case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|      0|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (1382:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 1415|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
 1416|      0|            break;
 1417|      0|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|      0|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (1417:9): [True: 0, False: 7.20k]
  ------------------
 1418|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
 1419|      0|            *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
 1420|      0|            break;
 1421|      0|        case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|      0|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (1421:9): [True: 0, False: 7.20k]
  ------------------
 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|      1|        case TIFFTAG_REFERENCEBLACKWHITE:
  ------------------
  |  |  392|      1|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
  |  Branch (1434:9): [True: 1, False: 7.20k]
  ------------------
 1435|      1|            *va_arg(ap, const float **) = td->td_refblackwhite;
 1436|      1|            break;
 1437|      0|        case TIFFTAG_INKNAMES:
  ------------------
  |  |  325|      0|#define TIFFTAG_INKNAMES 333               /* !ascii names of inks */
  ------------------
  |  Branch (1437:9): [True: 0, False: 7.20k]
  ------------------
 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: 7.20k]
  ------------------
 1441|      0|            *va_arg(ap, uint16_t *) = td->td_numberofinks;
 1442|      0|            break;
 1443|     82|        default:
  ------------------
  |  Branch (1443:9): [True: 82, False: 7.12k]
  ------------------
 1444|     82|        {
 1445|     82|            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|     82|            if (fip->field_bit != FIELD_CUSTOM)
  ------------------
  |  |  346|     82|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (1456:17): [True: 0, False: 82]
  ------------------
 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|     82|            ret_val = 0;
 1471|    426|            for (i = 0; i < td->td_customValueCount; i++)
  ------------------
  |  Branch (1471:25): [True: 351, False: 75]
  ------------------
 1472|    351|            {
 1473|    351|                TIFFTagValue *tv = td->td_customValues + i;
 1474|       |
 1475|    351|                if (tv->info->field_tag != tag)
  ------------------
  |  Branch (1475:21): [True: 344, False: 7]
  ------------------
 1476|    344|                    continue;
 1477|       |
 1478|      7|                if (fip->field_passcount)
  ------------------
  |  Branch (1478:21): [True: 0, False: 7]
  ------------------
 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|      7|                else if (fip->field_tag == TIFFTAG_DOTRANGE &&
  ------------------
  |  |  327|     14|#define TIFFTAG_DOTRANGE 336               /* !0% and 100% dot codes */
  ------------------
  |  Branch (1487:26): [True: 0, False: 7]
  ------------------
 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|      7|                else
 1499|      7|                {
 1500|      7|                    if (fip->field_type == TIFF_ASCII ||
  ------------------
  |  Branch (1500:25): [True: 0, False: 7]
  ------------------
 1501|      7|                        fip->field_readcount == TIFF_VARIABLE ||
  ------------------
  |  |  342|     14|#define TIFF_VARIABLE -1     /* marker for variable length tags */
  ------------------
  |  Branch (1501:25): [True: 0, False: 7]
  ------------------
 1502|      7|                        fip->field_readcount == TIFF_VARIABLE2 ||
  ------------------
  |  |  344|     14|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
  |  Branch (1502:25): [True: 0, False: 7]
  ------------------
 1503|      7|                        fip->field_readcount == TIFF_SPP || tv->count > 1)
  ------------------
  |  |  343|     14|#define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
  ------------------
  |  Branch (1503:25): [True: 0, False: 7]
  |  Branch (1503:61): [True: 7, False: 0]
  ------------------
 1504|      7|                    {
 1505|      7|                        *va_arg(ap, void **) = tv->value;
 1506|      7|                        ret_val = 1;
 1507|      7|                    }
 1508|      0|                    else
 1509|      0|                    {
 1510|      0|                        char *val = (char *)tv->value;
 1511|      0|                        assert(tv->count == 1);
  ------------------
  |  Branch (1511:25): [True: 0, False: 0]
  |  Branch (1511:25): [True: 0, False: 0]
  ------------------
 1512|      0|                        switch (fip->field_type)
 1513|      0|                        {
 1514|      0|                            case TIFF_BYTE:
  ------------------
  |  Branch (1514:29): [True: 0, False: 0]
  ------------------
 1515|      0|                            case TIFF_UNDEFINED:
  ------------------
  |  Branch (1515:29): [True: 0, False: 0]
  ------------------
 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: 0]
  ------------------
 1520|      0|                                *va_arg(ap, int8_t *) = *(int8_t *)val;
 1521|      0|                                ret_val = 1;
 1522|      0|                                break;
 1523|      0|                            case TIFF_SHORT:
  ------------------
  |  Branch (1523:29): [True: 0, False: 0]
  ------------------
 1524|      0|                                *va_arg(ap, uint16_t *) = *(uint16_t *)val;
 1525|      0|                                ret_val = 1;
 1526|      0|                                break;
 1527|      0|                            case TIFF_SSHORT:
  ------------------
  |  Branch (1527:29): [True: 0, False: 0]
  ------------------
 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: 0]
  ------------------
 1532|      0|                            case TIFF_IFD:
  ------------------
  |  Branch (1532:29): [True: 0, False: 0]
  ------------------
 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: 0]
  ------------------
 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: 0]
  ------------------
 1541|      0|                            case TIFF_IFD8:
  ------------------
  |  Branch (1541:29): [True: 0, False: 0]
  ------------------
 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: 0]
  ------------------
 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: 0]
  ------------------
 1550|      0|                            case TIFF_SRATIONAL:
  ------------------
  |  Branch (1550:29): [True: 0, False: 0]
  ------------------
 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: 0]
  ------------------
 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: 0]
  ------------------
 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: 0]
  ------------------
 1589|      0|                            case TIFF_ASCII:
  ------------------
  |  Branch (1589:29): [True: 0, False: 0]
  ------------------
 1590|      0|                            default:
  ------------------
  |  Branch (1590:29): [True: 0, False: 0]
  ------------------
 1591|      0|                                ret_val = 0;
 1592|      0|                                break;
 1593|      0|                        }
 1594|      0|                    }
 1595|      7|                }
 1596|      7|                break;
 1597|      7|            }
 1598|     82|        }
 1599|  7.20k|    }
 1600|  7.20k|    return (ret_val);
 1601|  7.20k|}

_TIFFGetFields:
  561|    690|const TIFFFieldArray *_TIFFGetFields(void) { return (&tiffFieldArray); }
_TIFFSetupFields:
  568|    690|{
  569|    690|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (569:9): [True: 292, False: 398]
  |  Branch (569:28): [True: 292, False: 0]
  ------------------
  570|    292|    {
  571|    292|        uint32_t i;
  572|       |
  573|  49.7k|        for (i = 0; i < tif->tif_nfields; i++)
  ------------------
  |  Branch (573:21): [True: 49.4k, False: 292]
  ------------------
  574|  49.4k|        {
  575|  49.4k|            TIFFField *fld = tif->tif_fields[i];
  576|  49.4k|            if (fld->field_name != NULL)
  ------------------
  |  Branch (576:17): [True: 49.4k, False: 0]
  ------------------
  577|  49.4k|            {
  578|  49.4k|                if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld))
  ------------------
  |  |  346|  98.9k|#define FIELD_CUSTOM 65
  ------------------
  |  Branch (578:21): [True: 33.6k, False: 15.8k]
  |  Branch (578:55): [True: 3.56k, False: 30.0k]
  ------------------
  579|  3.56k|                {
  580|  3.56k|                    _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|  3.56k|                    _TIFFfreeExt(tif, fld);
  586|  3.56k|                }
  587|  49.4k|            }
  588|  49.4k|        }
  589|       |
  590|    292|        _TIFFfreeExt(tif, tif->tif_fields);
  591|    292|        tif->tif_fields = NULL;
  592|    292|        tif->tif_nfields = 0;
  593|    292|    }
  594|    690|    if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
  ------------------
  |  Branch (594:9): [True: 0, False: 690]
  ------------------
  595|      0|    {
  596|      0|        TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
  597|      0|    }
  598|    690|}
_TIFFMergeFields:
  628|  31.6k|{
  629|  31.6k|    static const char module[] = "_TIFFMergeFields";
  630|  31.6k|    static const char reason[] = "for fields array";
  631|       |    /* TIFFField** tp; */
  632|  31.6k|    uint32_t i;
  633|       |
  634|  31.6k|    tif->tif_foundfield = NULL;
  635|       |
  636|  31.6k|    TIFFField **tif_newfields = NULL;
  637|       |
  638|  31.6k|    if (tif->tif_fields && tif->tif_nfields > 0)
  ------------------
  |  Branch (638:9): [True: 30.9k, False: 690]
  |  Branch (638:28): [True: 30.9k, False: 0]
  ------------------
  639|  30.9k|    {
  640|  30.9k|        tif_newfields = (TIFFField **)_TIFFCheckRealloc(
  641|  30.9k|            tif, tif->tif_fields, (tmsize_t)tif->tif_nfields + n,
  642|  30.9k|            (tmsize_t)sizeof(TIFFField *), reason);
  643|  30.9k|    }
  644|    690|    else
  645|    690|    {
  646|    690|        tif_newfields =
  647|    690|            (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
  648|    690|    }
  649|  31.6k|    if (!tif_newfields)
  ------------------
  |  Branch (649:9): [True: 0, False: 31.6k]
  ------------------
  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|  31.6k|    tif->tif_fields = tif_newfields;
  656|       |
  657|       |    /* tp = tif->tif_fields + tif->tif_nfields; */
  658|   170k|    for (i = 0; i < n; i++)
  ------------------
  |  Branch (658:17): [True: 138k, False: 31.6k]
  ------------------
  659|   138k|    {
  660|   138k|        const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
  ------------------
  |  |  341|   138k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  661|       |
  662|       |        /* only add definitions that aren't already present */
  663|   138k|        if (!fip)
  ------------------
  |  Branch (663:13): [True: 138k, False: 0]
  ------------------
  664|   138k|        {
  665|   138k|            tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
  666|   138k|            tif->tif_nfields++;
  667|   138k|        }
  668|   138k|    }
  669|       |
  670|       |    /* Sort the field info by tag number */
  671|  31.6k|    qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
  672|       |
  673|  31.6k|    return (int)n;
  674|  31.6k|}
TIFFDataWidth:
  696|  14.7k|{
  697|  14.7k|    switch (type)
  698|  14.7k|    {
  699|  1.30k|        case 0: /* nothing */
  ------------------
  |  Branch (699:9): [True: 1.30k, False: 13.3k]
  ------------------
  700|  2.98k|        case TIFF_BYTE:
  ------------------
  |  Branch (700:9): [True: 1.67k, False: 13.0k]
  ------------------
  701|  4.40k|        case TIFF_ASCII:
  ------------------
  |  Branch (701:9): [True: 1.42k, False: 13.2k]
  ------------------
  702|  4.84k|        case TIFF_SBYTE:
  ------------------
  |  Branch (702:9): [True: 440, False: 14.2k]
  ------------------
  703|  4.90k|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (703:9): [True: 56, False: 14.6k]
  ------------------
  704|  4.90k|            return 1;
  705|  6.26k|        case TIFF_SHORT:
  ------------------
  |  Branch (705:9): [True: 6.26k, False: 8.44k]
  ------------------
  706|  6.30k|        case TIFF_SSHORT:
  ------------------
  |  Branch (706:9): [True: 37, False: 14.6k]
  ------------------
  707|  6.30k|            return 2;
  708|  2.19k|        case TIFF_LONG:
  ------------------
  |  Branch (708:9): [True: 2.19k, False: 12.5k]
  ------------------
  709|  2.23k|        case TIFF_SLONG:
  ------------------
  |  Branch (709:9): [True: 41, False: 14.6k]
  ------------------
  710|  2.23k|        case TIFF_FLOAT:
  ------------------
  |  Branch (710:9): [True: 1, False: 14.7k]
  ------------------
  711|  2.24k|        case TIFF_IFD:
  ------------------
  |  Branch (711:9): [True: 5, False: 14.7k]
  ------------------
  712|  2.24k|            return 4;
  713|    461|        case TIFF_RATIONAL:
  ------------------
  |  Branch (713:9): [True: 461, False: 14.2k]
  ------------------
  714|    481|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (714:9): [True: 20, False: 14.6k]
  ------------------
  715|    505|        case TIFF_DOUBLE:
  ------------------
  |  Branch (715:9): [True: 24, False: 14.6k]
  ------------------
  716|  1.01k|        case TIFF_LONG8:
  ------------------
  |  Branch (716:9): [True: 511, False: 14.1k]
  ------------------
  717|  1.21k|        case TIFF_SLONG8:
  ------------------
  |  Branch (717:9): [True: 195, False: 14.5k]
  ------------------
  718|  1.24k|        case TIFF_IFD8:
  ------------------
  |  Branch (718:9): [True: 30, False: 14.6k]
  ------------------
  719|  1.24k|            return 8;
  720|     23|        default:
  ------------------
  |  Branch (720:9): [True: 23, False: 14.6k]
  ------------------
  721|     23|            return 0; /* will return 0 for unknown types */
  722|  14.7k|    }
  723|  14.7k|}
TIFFFieldSetGetSize:
  732|  2.00k|{
  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|  2.00k|    if (fip == NULL)
  ------------------
  |  Branch (744:9): [True: 0, False: 2.00k]
  ------------------
  745|      0|        return 0;
  746|       |
  747|  2.00k|    switch (fip->set_get_field_type)
  748|  2.00k|    {
  749|      0|        case TIFF_SETGET_UNDEFINED:
  ------------------
  |  Branch (749:9): [True: 0, False: 2.00k]
  ------------------
  750|    511|        case TIFF_SETGET_ASCII:
  ------------------
  |  Branch (750:9): [True: 511, False: 1.49k]
  ------------------
  751|    511|        case TIFF_SETGET_C0_ASCII:
  ------------------
  |  Branch (751:9): [True: 0, False: 2.00k]
  ------------------
  752|    511|        case TIFF_SETGET_C16_ASCII:
  ------------------
  |  Branch (752:9): [True: 0, False: 2.00k]
  ------------------
  753|    526|        case TIFF_SETGET_C32_ASCII:
  ------------------
  |  Branch (753:9): [True: 15, False: 1.98k]
  ------------------
  754|    526|        case TIFF_SETGET_OTHER:
  ------------------
  |  Branch (754:9): [True: 0, False: 2.00k]
  ------------------
  755|    526|            return 1;
  756|      7|        case TIFF_SETGET_UINT8:
  ------------------
  |  Branch (756:9): [True: 7, False: 1.99k]
  ------------------
  757|      7|        case TIFF_SETGET_SINT8:
  ------------------
  |  Branch (757:9): [True: 0, False: 2.00k]
  ------------------
  758|      7|        case TIFF_SETGET_C0_UINT8:
  ------------------
  |  Branch (758:9): [True: 0, False: 2.00k]
  ------------------
  759|      7|        case TIFF_SETGET_C0_SINT8:
  ------------------
  |  Branch (759:9): [True: 0, False: 2.00k]
  ------------------
  760|      7|        case TIFF_SETGET_C16_UINT8:
  ------------------
  |  Branch (760:9): [True: 0, False: 2.00k]
  ------------------
  761|      7|        case TIFF_SETGET_C16_SINT8:
  ------------------
  |  Branch (761:9): [True: 0, False: 2.00k]
  ------------------
  762|    600|        case TIFF_SETGET_C32_UINT8:
  ------------------
  |  Branch (762:9): [True: 593, False: 1.40k]
  ------------------
  763|    687|        case TIFF_SETGET_C32_SINT8:
  ------------------
  |  Branch (763:9): [True: 87, False: 1.91k]
  ------------------
  764|    687|            return 1;
  765|      8|        case TIFF_SETGET_UINT16:
  ------------------
  |  Branch (765:9): [True: 8, False: 1.99k]
  ------------------
  766|      8|        case TIFF_SETGET_SINT16:
  ------------------
  |  Branch (766:9): [True: 0, False: 2.00k]
  ------------------
  767|      8|        case TIFF_SETGET_C0_UINT16:
  ------------------
  |  Branch (767:9): [True: 0, False: 2.00k]
  ------------------
  768|      8|        case TIFF_SETGET_C0_SINT16:
  ------------------
  |  Branch (768:9): [True: 0, False: 2.00k]
  ------------------
  769|      8|        case TIFF_SETGET_C16_UINT16:
  ------------------
  |  Branch (769:9): [True: 0, False: 2.00k]
  ------------------
  770|      8|        case TIFF_SETGET_C16_SINT16:
  ------------------
  |  Branch (770:9): [True: 0, False: 2.00k]
  ------------------
  771|    487|        case TIFF_SETGET_C32_UINT16:
  ------------------
  |  Branch (771:9): [True: 479, False: 1.52k]
  ------------------
  772|    488|        case TIFF_SETGET_C32_SINT16:
  ------------------
  |  Branch (772:9): [True: 1, False: 2.00k]
  ------------------
  773|    488|            return 2;
  774|      0|        case TIFF_SETGET_INT:
  ------------------
  |  Branch (774:9): [True: 0, False: 2.00k]
  ------------------
  775|     42|        case TIFF_SETGET_UINT32:
  ------------------
  |  Branch (775:9): [True: 42, False: 1.95k]
  ------------------
  776|     42|        case TIFF_SETGET_SINT32:
  ------------------
  |  Branch (776:9): [True: 0, False: 2.00k]
  ------------------
  777|     42|        case TIFF_SETGET_FLOAT:
  ------------------
  |  Branch (777:9): [True: 0, False: 2.00k]
  ------------------
  778|     42|        case TIFF_SETGET_UINT16_PAIR:
  ------------------
  |  Branch (778:9): [True: 0, False: 2.00k]
  ------------------
  779|     42|        case TIFF_SETGET_C0_UINT32:
  ------------------
  |  Branch (779:9): [True: 0, False: 2.00k]
  ------------------
  780|     42|        case TIFF_SETGET_C0_SINT32:
  ------------------
  |  Branch (780:9): [True: 0, False: 2.00k]
  ------------------
  781|     49|        case TIFF_SETGET_C0_FLOAT:
  ------------------
  |  Branch (781:9): [True: 7, False: 1.99k]
  ------------------
  782|     49|        case TIFF_SETGET_C16_UINT32:
  ------------------
  |  Branch (782:9): [True: 0, False: 2.00k]
  ------------------
  783|     49|        case TIFF_SETGET_C16_SINT32:
  ------------------
  |  Branch (783:9): [True: 0, False: 2.00k]
  ------------------
  784|     53|        case TIFF_SETGET_C16_FLOAT:
  ------------------
  |  Branch (784:9): [True: 4, False: 1.99k]
  ------------------
  785|    213|        case TIFF_SETGET_C32_UINT32:
  ------------------
  |  Branch (785:9): [True: 160, False: 1.84k]
  ------------------
  786|    227|        case TIFF_SETGET_C32_SINT32:
  ------------------
  |  Branch (786:9): [True: 14, False: 1.98k]
  ------------------
  787|    255|        case TIFF_SETGET_C32_FLOAT:
  ------------------
  |  Branch (787:9): [True: 28, False: 1.97k]
  ------------------
  788|    255|            return 4;
  789|      0|        case TIFF_SETGET_UINT64:
  ------------------
  |  Branch (789:9): [True: 0, False: 2.00k]
  ------------------
  790|      0|        case TIFF_SETGET_SINT64:
  ------------------
  |  Branch (790:9): [True: 0, False: 2.00k]
  ------------------
  791|      0|        case TIFF_SETGET_DOUBLE:
  ------------------
  |  Branch (791:9): [True: 0, False: 2.00k]
  ------------------
  792|      1|        case TIFF_SETGET_IFD8:
  ------------------
  |  Branch (792:9): [True: 1, False: 2.00k]
  ------------------
  793|      1|        case TIFF_SETGET_C0_UINT64:
  ------------------
  |  Branch (793:9): [True: 0, False: 2.00k]
  ------------------
  794|      1|        case TIFF_SETGET_C0_SINT64:
  ------------------
  |  Branch (794:9): [True: 0, False: 2.00k]
  ------------------
  795|      1|        case TIFF_SETGET_C0_DOUBLE:
  ------------------
  |  Branch (795:9): [True: 0, False: 2.00k]
  ------------------
  796|      1|        case TIFF_SETGET_C0_IFD8:
  ------------------
  |  Branch (796:9): [True: 0, False: 2.00k]
  ------------------
  797|      1|        case TIFF_SETGET_C16_UINT64:
  ------------------
  |  Branch (797:9): [True: 0, False: 2.00k]
  ------------------
  798|      1|        case TIFF_SETGET_C16_SINT64:
  ------------------
  |  Branch (798:9): [True: 0, False: 2.00k]
  ------------------
  799|      1|        case TIFF_SETGET_C16_DOUBLE:
  ------------------
  |  Branch (799:9): [True: 0, False: 2.00k]
  ------------------
  800|      1|        case TIFF_SETGET_C16_IFD8:
  ------------------
  |  Branch (800:9): [True: 0, False: 2.00k]
  ------------------
  801|     36|        case TIFF_SETGET_C32_UINT64:
  ------------------
  |  Branch (801:9): [True: 35, False: 1.96k]
  ------------------
  802|     36|        case TIFF_SETGET_C32_SINT64:
  ------------------
  |  Branch (802:9): [True: 0, False: 2.00k]
  ------------------
  803|     41|        case TIFF_SETGET_C32_DOUBLE:
  ------------------
  |  Branch (803:9): [True: 5, False: 1.99k]
  ------------------
  804|     45|        case TIFF_SETGET_C32_IFD8:
  ------------------
  |  Branch (804:9): [True: 4, False: 1.99k]
  ------------------
  805|     45|            return 8;
  806|      0|        default:
  ------------------
  |  Branch (806:9): [True: 0, False: 2.00k]
  ------------------
  807|      0|            return 0;
  808|  2.00k|    }
  809|  2.00k|} /*-- TIFFFieldSetGetSize() --- */
TIFFFindField:
  882|   185k|{
  883|   185k|    TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0,   TIFF_SETGET_UNDEFINED,
  884|   185k|                     0, 0, 0, NULL,        NULL};
  885|   185k|    TIFFField *pkey = &key;
  886|   185k|    const TIFFField **ret;
  887|   185k|    if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
  ------------------
  |  Branch (887:9): [True: 43.5k, False: 141k]
  |  Branch (887:32): [True: 26.5k, False: 17.0k]
  ------------------
  888|  26.5k|        (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
  ------------------
  |  |  341|  53.0k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  |  Branch (888:10): [True: 26.5k, False: 0]
  |  Branch (888:28): [True: 0, False: 0]
  ------------------
  889|  26.5k|        return tif->tif_foundfield;
  890|       |
  891|       |    /* If we are invoked with no field information, then just return. */
  892|   158k|    if (!tif->tif_fields)
  ------------------
  |  Branch (892:9): [True: 0, False: 158k]
  ------------------
  893|      0|        return NULL;
  894|       |
  895|       |    /* NB: use sorted search (e.g. binary search) */
  896|       |
  897|   158k|    key.field_tag = tag;
  898|   158k|    key.field_type = dt;
  899|       |
  900|   158k|    ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
  901|   158k|                                      sizeof(TIFFField *), tagCompare);
  902|   158k|    return tif->tif_foundfield = (ret ? *ret : NULL);
  ------------------
  |  Branch (902:35): [True: 20.1k, False: 138k]
  ------------------
  903|   158k|}
TIFFFieldWithTag:
  934|  9.07k|{
  935|  9.07k|    const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
  ------------------
  |  |  341|  9.07k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  936|  9.07k|    if (!fip)
  ------------------
  |  Branch (936:9): [True: 0, False: 9.07k]
  ------------------
  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|  9.07k|    return (fip);
  945|  9.07k|}
TIFFFieldIsAnonymous:
  974|   101k|{
  975|   101k|    return (int)fip->field_anonymous;
  976|   101k|}
_TIFFCreateAnonField:
  997|  30.3k|{
  998|  30.3k|    TIFFField *fld;
  999|  30.3k|    (void)tif;
 1000|       |
 1001|  30.3k|    fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
 1002|  30.3k|    if (fld == NULL)
  ------------------
  |  Branch (1002:9): [True: 0, False: 30.3k]
  ------------------
 1003|      0|        return NULL;
 1004|  30.3k|    _TIFFmemset(fld, 0, sizeof(TIFFField));
 1005|       |
 1006|  30.3k|    fld->field_tag = tag;
 1007|  30.3k|    fld->field_readcount = TIFF_VARIABLE2;
  ------------------
  |  |  344|  30.3k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
 1008|  30.3k|    fld->field_writecount = TIFF_VARIABLE2;
  ------------------
  |  |  344|  30.3k|#define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
  ------------------
 1009|  30.3k|    fld->field_type = field_type;
 1010|  30.3k|    fld->field_anonymous =
 1011|  30.3k|        1; /* indicate that this is an anonymous / unknown tag */
 1012|  30.3k|    switch (field_type)
 1013|  30.3k|    {
 1014|    863|        case TIFF_BYTE:
  ------------------
  |  Branch (1014:9): [True: 863, False: 29.4k]
  ------------------
 1015|    893|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1015:9): [True: 30, False: 30.3k]
  ------------------
 1016|    893|            fld->set_get_field_type = TIFF_SETGET_C32_UINT8;
 1017|    893|            break;
 1018|     43|        case TIFF_ASCII:
  ------------------
  |  Branch (1018:9): [True: 43, False: 30.3k]
  ------------------
 1019|     43|            fld->set_get_field_type = TIFF_SETGET_C32_ASCII;
 1020|     43|            break;
 1021|    887|        case TIFF_SHORT:
  ------------------
  |  Branch (1021:9): [True: 887, False: 29.4k]
  ------------------
 1022|    887|            fld->set_get_field_type = TIFF_SETGET_C32_UINT16;
 1023|    887|            break;
 1024|    257|        case TIFF_LONG:
  ------------------
  |  Branch (1024:9): [True: 257, False: 30.0k]
  ------------------
 1025|    257|            fld->set_get_field_type = TIFF_SETGET_C32_UINT32;
 1026|    257|            break;
 1027|     56|        case TIFF_RATIONAL:
  ------------------
  |  Branch (1027:9): [True: 56, False: 30.2k]
  ------------------
 1028|     61|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (1028:9): [True: 5, False: 30.3k]
  ------------------
 1029|     62|        case TIFF_FLOAT:
  ------------------
  |  Branch (1029:9): [True: 1, False: 30.3k]
  ------------------
 1030|     62|            fld->set_get_field_type = TIFF_SETGET_C32_FLOAT;
 1031|     62|            break;
 1032|    148|        case TIFF_SBYTE:
  ------------------
  |  Branch (1032:9): [True: 148, False: 30.1k]
  ------------------
 1033|    148|            fld->set_get_field_type = TIFF_SETGET_C32_SINT8;
 1034|    148|            break;
 1035|     15|        case TIFF_SSHORT:
  ------------------
  |  Branch (1035:9): [True: 15, False: 30.3k]
  ------------------
 1036|     15|            fld->set_get_field_type = TIFF_SETGET_C32_SINT16;
 1037|     15|            break;
 1038|     17|        case TIFF_SLONG:
  ------------------
  |  Branch (1038:9): [True: 17, False: 30.3k]
  ------------------
 1039|     17|            fld->set_get_field_type = TIFF_SETGET_C32_SINT32;
 1040|     17|            break;
 1041|     16|        case TIFF_DOUBLE:
  ------------------
  |  Branch (1041:9): [True: 16, False: 30.3k]
  ------------------
 1042|     16|            fld->set_get_field_type = TIFF_SETGET_C32_DOUBLE;
 1043|     16|            break;
 1044|      3|        case TIFF_IFD:
  ------------------
  |  Branch (1044:9): [True: 3, False: 30.3k]
  ------------------
 1045|     24|        case TIFF_IFD8:
  ------------------
  |  Branch (1045:9): [True: 21, False: 30.3k]
  ------------------
 1046|     24|            fld->set_get_field_type = TIFF_SETGET_C32_IFD8;
 1047|     24|            break;
 1048|     52|        case TIFF_LONG8:
  ------------------
  |  Branch (1048:9): [True: 52, False: 30.2k]
  ------------------
 1049|     52|            fld->set_get_field_type = TIFF_SETGET_C32_UINT64;
 1050|     52|            break;
 1051|    193|        case TIFF_SLONG8:
  ------------------
  |  Branch (1051:9): [True: 193, False: 30.1k]
  ------------------
 1052|    193|            fld->set_get_field_type = TIFF_SETGET_C32_SINT64;
 1053|    193|            break;
 1054|  3.43k|        case TIFF_NOTYPE:
  ------------------
  |  Branch (1054:9): [True: 3.43k, False: 26.9k]
  ------------------
 1055|  27.7k|        default:
  ------------------
  |  Branch (1055:9): [True: 24.2k, False: 6.04k]
  ------------------
 1056|  27.7k|            fld->set_get_field_type = TIFF_SETGET_UNDEFINED;
 1057|  27.7k|            break;
 1058|  30.3k|    }
 1059|  30.3k|    fld->field_bit = FIELD_CUSTOM;
  ------------------
  |  |  346|  30.3k|#define FIELD_CUSTOM 65
  ------------------
 1060|  30.3k|    fld->field_oktochange = TRUE;
  ------------------
  |  |   71|  30.3k|#define TRUE 1
  ------------------
 1061|  30.3k|    fld->field_passcount = TRUE;
  ------------------
  |  |   71|  30.3k|#define TRUE 1
  ------------------
 1062|  30.3k|    char *field_name_buf = (char *)_TIFFmallocExt(tif, 32);
 1063|  30.3k|    if (field_name_buf == NULL)
  ------------------
  |  Branch (1063:9): [True: 0, False: 30.3k]
  ------------------
 1064|      0|    {
 1065|      0|        _TIFFfreeExt(tif, fld);
 1066|      0|        return NULL;
 1067|      0|    }
 1068|  30.3k|    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|  30.3k|    (void)snprintf(field_name_buf, 32, "Tag %d", (int)tag);
 1077|  30.3k|    fld->field_name = field_name_buf;
 1078|       |
 1079|  30.3k|    return fld;
 1080|  30.3k|}
_TIFFCheckFieldIsValidForCodec:
 1354|  34.1k|{
 1355|       |    /* Filter out non-codec specific tags */
 1356|  34.1k|    switch (tag)
 1357|  34.1k|    {
 1358|       |        /* Shared tags */
 1359|      8|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|      8|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1359:9): [True: 8, False: 34.1k]
  ------------------
 1360|       |        /* JPEG tags */
 1361|     11|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|     11|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (1361:9): [True: 3, False: 34.1k]
  ------------------
 1362|       |        /* OJPEG tags */
 1363|     70|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|     70|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (1363:9): [True: 59, False: 34.0k]
  ------------------
 1364|     99|        case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|     99|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (1364:9): [True: 29, False: 34.1k]
  ------------------
 1365|    203|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|    203|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (1365:9): [True: 104, False: 34.0k]
  ------------------
 1366|    298|        case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|    298|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (1366:9): [True: 95, False: 34.0k]
  ------------------
 1367|    389|        case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|    389|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (1367:9): [True: 91, False: 34.0k]
  ------------------
 1368|    556|        case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|    556|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (1368:9): [True: 167, False: 33.9k]
  ------------------
 1369|    575|        case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|    575|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (1369:9): [True: 19, False: 34.1k]
  ------------------
 1370|       |        /* CCITT* */
 1371|    575|        case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|    575|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1371:9): [True: 0, False: 34.1k]
  ------------------
 1372|    575|        case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|    575|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1372:9): [True: 0, False: 34.1k]
  ------------------
 1373|    577|        case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|    577|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1373:9): [True: 2, False: 34.1k]
  ------------------
 1374|    607|        case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|    607|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1374:9): [True: 30, False: 34.1k]
  ------------------
 1375|    616|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|    616|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1375:9): [True: 9, False: 34.1k]
  ------------------
 1376|       |        /* LERC */
 1377|    616|        case TIFFTAG_LERC_PARAMETERS:
  ------------------
  |  |  502|    616|#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */
  ------------------
  |  Branch (1377:9): [True: 0, False: 34.1k]
  ------------------
 1378|    616|            break;
 1379|  33.5k|        default:
  ------------------
  |  Branch (1379:9): [True: 33.5k, False: 616]
  ------------------
 1380|  33.5k|            return 1;
 1381|  34.1k|    }
 1382|    616|    if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression))
  ------------------
  |  Branch (1382:9): [True: 6, False: 610]
  ------------------
 1383|      6|    {
 1384|      6|        return 0;
 1385|      6|    }
 1386|       |    /* Check if codec specific tags are allowed for the current
 1387|       |     * compression scheme (codec) */
 1388|    610|    switch (tif->tif_dir.td_compression)
 1389|    610|    {
 1390|     26|        case COMPRESSION_LZW:
  ------------------
  |  |  188|     26|#define COMPRESSION_LZW 5             /* Lempel-Ziv  & Welch */
  ------------------
  |  Branch (1390:9): [True: 26, False: 584]
  ------------------
 1391|     26|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|     26|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1391:17): [True: 1, False: 25]
  ------------------
 1392|      1|                return 1;
 1393|     25|            break;
 1394|     25|        case COMPRESSION_PACKBITS:
  ------------------
  |  |  195|      0|#define COMPRESSION_PACKBITS 32773    /* Macintosh RLE */
  ------------------
  |  Branch (1394:9): [True: 0, False: 610]
  ------------------
 1395|       |            /* No codec-specific tags */
 1396|      0|            break;
 1397|      0|        case COMPRESSION_THUNDERSCAN:
  ------------------
  |  |  196|      0|#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */
  ------------------
  |  Branch (1397:9): [True: 0, False: 610]
  ------------------
 1398|       |            /* No codec-specific tags */
 1399|      0|            break;
 1400|      0|        case COMPRESSION_NEXT:
  ------------------
  |  |  193|      0|#define COMPRESSION_NEXT 32766        /* NeXT 2-bit RLE */
  ------------------
  |  Branch (1400:9): [True: 0, False: 610]
  ------------------
 1401|       |            /* No codec-specific tags */
 1402|      0|            break;
 1403|    147|        case COMPRESSION_JPEG:
  ------------------
  |  |  190|    147|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
  |  Branch (1403:9): [True: 147, False: 463]
  ------------------
 1404|    147|            if (tag == TIFFTAG_JPEGTABLES)
  ------------------
  |  |  346|    147|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (1404:17): [True: 3, False: 144]
  ------------------
 1405|      3|                return 1;
 1406|    144|            break;
 1407|    377|        case COMPRESSION_OJPEG:
  ------------------
  |  |  189|    377|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (1407:9): [True: 377, False: 233]
  ------------------
 1408|    377|            switch (tag)
 1409|    377|            {
 1410|     12|                case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|     12|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (1410:17): [True: 12, False: 365]
  ------------------
 1411|     38|                case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|     38|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (1411:17): [True: 26, False: 351]
  ------------------
 1412|    138|                case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|    138|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (1412:17): [True: 100, False: 277]
  ------------------
 1413|    230|                case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|    230|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (1413:17): [True: 92, False: 285]
  ------------------
 1414|    317|                case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|    317|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (1414:17): [True: 87, False: 290]
  ------------------
 1415|    364|                case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|    364|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (1415:17): [True: 47, False: 330]
  ------------------
 1416|    365|                case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|    365|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (1416:17): [True: 1, False: 376]
  ------------------
 1417|    365|                    return 1;
 1418|     12|                default:
  ------------------
  |  Branch (1418:17): [True: 12, False: 365]
  ------------------
 1419|     12|                    break;
 1420|    377|            }
 1421|     12|            break;
 1422|     17|        case COMPRESSION_CCITTRLE:
  ------------------
  |  |  183|     17|#define COMPRESSION_CCITTRLE 2        /* CCITT modified Huffman RLE */
  ------------------
  |  Branch (1422:9): [True: 17, False: 593]
  ------------------
 1423|     17|        case COMPRESSION_CCITTRLEW:
  ------------------
  |  |  194|     17|#define COMPRESSION_CCITTRLEW 32771   /* #1 w/ word alignment */
  ------------------
  |  Branch (1423:9): [True: 0, False: 610]
  ------------------
 1424|     34|        case COMPRESSION_CCITTFAX3:
  ------------------
  |  |  184|     34|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1424:9): [True: 17, False: 593]
  ------------------
 1425|     34|        case COMPRESSION_CCITTFAX4:
  ------------------
  |  |  186|     34|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1425:9): [True: 0, False: 610]
  ------------------
 1426|     34|            switch (tag)
 1427|     34|            {
 1428|      0|                case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|      0|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1428:17): [True: 0, False: 34]
  ------------------
 1429|      0|                case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|      0|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1429:17): [True: 0, False: 34]
  ------------------
 1430|      1|                case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|      1|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1430:17): [True: 1, False: 33]
  ------------------
 1431|      1|                    return 1;
 1432|     17|                case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|     17|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1432:17): [True: 17, False: 17]
  ------------------
 1433|     17|                    if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
  ------------------
  |  |  184|     17|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1433:25): [True: 13, False: 4]
  ------------------
 1434|     13|                        return 1;
 1435|      4|                    break;
 1436|      4|                case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|      0|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1436:17): [True: 0, False: 34]
  ------------------
 1437|      0|                    if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
  ------------------
  |  |  186|      0|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1437:25): [True: 0, False: 0]
  ------------------
 1438|      0|                        return 1;
 1439|      0|                    break;
 1440|     16|                default:
  ------------------
  |  Branch (1440:17): [True: 16, False: 18]
  ------------------
 1441|     16|                    break;
 1442|     34|            }
 1443|     20|            break;
 1444|     20|        case COMPRESSION_JBIG:
  ------------------
  |  |  209|      0|#define COMPRESSION_JBIG 34661     /* ISO JBIG */
  ------------------
  |  Branch (1444:9): [True: 0, False: 610]
  ------------------
 1445|       |            /* No codec-specific tags */
 1446|      0|            break;
 1447|      0|        case COMPRESSION_DEFLATE:
  ------------------
  |  |  205|      0|#define COMPRESSION_DEFLATE 32946   /* Deflate compression, legacy tag */
  ------------------
  |  Branch (1447:9): [True: 0, False: 610]
  ------------------
 1448|      0|        case COMPRESSION_ADOBE_DEFLATE:
  ------------------
  |  |  206|      0|#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, as recognized by Adobe */
  ------------------
  |  Branch (1448:9): [True: 0, False: 610]
  ------------------
 1449|      0|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1449:17): [True: 0, False: 0]
  ------------------
 1450|      0|                return 1;
 1451|      0|            break;
 1452|      0|        case COMPRESSION_PIXARLOG:
  ------------------
  |  |  204|      0|#define COMPRESSION_PIXARLOG 32909  /* Pixar companded 11bit ZIP */
  ------------------
  |  Branch (1452:9): [True: 0, False: 610]
  ------------------
 1453|      0|            if (tag == TIFFTAG_PREDICTOR)
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1453:17): [True: 0, False: 0]
  ------------------
 1454|      0|                return 1;
 1455|      0|            break;
 1456|      0|        case COMPRESSION_SGILOG:
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (1456:9): [True: 0, False: 610]
  ------------------
 1457|      0|        case COMPRESSION_SGILOG24:
  ------------------
  |  |  211|      0|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (1457:9): [True: 0, False: 610]
  ------------------
 1458|       |            /* No codec-specific tags */
 1459|      0|            break;
 1460|      0|        case COMPRESSION_LZMA:
  ------------------
  |  |  215|      0|#define COMPRESSION_LZMA 34925             /* LZMA2 */
  ------------------
  |  Branch (1460:9): [True: 0, False: 610]
  ------------------
 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: 610]
  ------------------
 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: 610]
  ------------------
 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|     26|        default:
  ------------------
  |  Branch (1472:9): [True: 26, False: 584]
  ------------------
 1473|     26|            break;
 1474|    610|    }
 1475|    227|    return 0;
 1476|    610|}
tif_dirinfo.c:tagCompare:
  601|  48.6M|{
  602|  48.6M|    const TIFFField *ta = *(const TIFFField **)a;
  603|  48.6M|    const TIFFField *tb = *(const TIFFField **)b;
  604|       |    /* NB: be careful of return values for 16-bit platforms */
  605|  48.6M|    if (ta->field_tag != tb->field_tag)
  ------------------
  |  Branch (605:9): [True: 48.6M, False: 20.1k]
  ------------------
  606|  48.6M|        return (int)ta->field_tag - (int)tb->field_tag;
  607|  20.1k|    else
  608|  20.1k|        return (ta->field_type == TIFF_ANY)
  ------------------
  |  |  341|  20.1k|#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  ------------------
  |  Branch (608:16): [True: 20.1k, False: 0]
  ------------------
  609|  20.1k|                   ? 0
  610|  20.1k|                   : ((int)tb->field_type - (int)ta->field_type);
  611|  48.6M|}

TIFFReadDirectory:
 4336|    996|{
 4337|    996|    static const char module[] = "TIFFReadDirectory";
 4338|    996|    TIFFDirEntry *dir;
 4339|    996|    uint16_t dircount;
 4340|    996|    TIFFDirEntry *dp;
 4341|    996|    uint16_t di;
 4342|    996|    const TIFFField *fip;
 4343|    996|    uint32_t fii = FAILED_FII;
  ------------------
  |  |   44|    996|#define FAILED_FII ((uint32_t)-1)
  ------------------
 4344|    996|    toff_t nextdiroff;
 4345|    996|    int bitspersample_read = FALSE;
  ------------------
  |  |   72|    996|#define FALSE 0
  ------------------
 4346|    996|    int color_channels;
 4347|       |
 4348|    996|    if (tif->tif_nextdiroff == 0)
  ------------------
  |  Branch (4348:9): [True: 33, False: 963]
  ------------------
 4349|     33|    {
 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|     33|        tif->tif_diroff = tif->tif_nextdiroff;
 4354|     33|        return 0;
 4355|     33|    }
 4356|       |
 4357|    963|    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|    963|    if (!_TIFFCheckDirNumberAndOffset(tif,
  ------------------
  |  Branch (4361:9): [True: 2, False: 961]
  ------------------
 4362|    963|                                      tif->tif_curdir ==
  ------------------
  |  Branch (4362:39): [True: 398, False: 565]
  ------------------
 4363|    963|                                              TIFF_NON_EXISTENT_DIR_NUMBER
  ------------------
  |  |   65|    963|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
 4364|    963|                                          ? 0
 4365|    963|                                          : tif->tif_curdir + 1,
 4366|    963|                                      nextdiroff))
 4367|      2|    {
 4368|      2|        return 0; /* bad offset (IFD looping or more than TIFF_MAX_DIR_COUNT
 4369|       |                     IFDs) */
 4370|      2|    }
 4371|    961|    dircount = TIFFFetchDirectory(tif, nextdiroff, &dir, &tif->tif_nextdiroff);
 4372|    961|    if (!dircount)
  ------------------
  |  Branch (4372:9): [True: 271, False: 690]
  ------------------
 4373|    271|    {
 4374|    271|        TIFFErrorExtR(tif, module,
 4375|    271|                      "Failed to read directory at offset %" PRIu64,
 4376|    271|                      nextdiroff);
 4377|    271|        return 0;
 4378|    271|    }
 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|    690|    if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
  ------------------
  |  |   65|    690|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  |  Branch (4382:9): [True: 398, False: 292]
  ------------------
 4383|    398|        tif->tif_curdir = 0;
 4384|    292|    else
 4385|    292|        tif->tif_curdir++;
 4386|       |
 4387|    690|    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|    690|    {
 4394|    690|        TIFFDirEntry *ma;
 4395|    690|        uint16_t mb;
 4396|  81.1k|        for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
  ------------------
  |  Branch (4396:32): [True: 80.4k, False: 690]
  ------------------
 4397|  80.4k|        {
 4398|  80.4k|            TIFFDirEntry *na;
 4399|  80.4k|            uint16_t nb;
 4400|  30.3M|            for (na = ma + 1, nb = (uint16_t)(mb + 1); nb < dircount;
  ------------------
  |  Branch (4400:56): [True: 30.3M, False: 80.4k]
  ------------------
 4401|  30.3M|                 na++, nb++)
 4402|  30.3M|            {
 4403|  30.3M|                if (ma->tdir_tag == na->tdir_tag)
  ------------------
  |  Branch (4403:21): [True: 6.96M, False: 23.3M]
  ------------------
 4404|  6.96M|                {
 4405|  6.96M|                    na->tdir_ignore = TRUE;
  ------------------
  |  |   71|  6.96M|#define TRUE 1
  ------------------
 4406|  6.96M|                }
 4407|  30.3M|            }
 4408|  80.4k|        }
 4409|    690|    }
 4410|       |
 4411|    690|    tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */
  ------------------
  |  |  125|    690|#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
  ------------------
 4412|    690|    tif->tif_flags &= ~TIFF_BUF4WRITE;   /* reset before new dir */
  ------------------
  |  |  141|    690|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 4413|    690|    tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
  ------------------
  |  |  153|    690|    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|    690|    tif->tif_flags &= ~TIFF_LAZYSTRILELOAD_DONE;
  ------------------
  |  |  149|    690|    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|    690|    TIFFFreeDirectory(tif);
 4425|    690|    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|    690|    tif->tif_dir.td_iswrittentofile = TRUE;
  ------------------
  |  |   71|    690|#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|    690|    tif->tif_dir.td_dirdatasize_offsets =
 4435|    690|        (TIFFEntryOffsetAndLength *)_TIFFmallocExt(
 4436|    690|            tif,
 4437|    690|            (tmsize_t)((size_t)dircount * sizeof(TIFFEntryOffsetAndLength)));
 4438|    690|    if (tif->tif_dir.td_dirdatasize_offsets == NULL)
  ------------------
  |  Branch (4438:9): [True: 0, False: 690]
  ------------------
 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|    690|    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  ------------------
  |  |  264|    690|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
                  TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  ------------------
  |  |  265|    690|#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|    690|    dp =
 4472|    690|        TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_SAMPLESPERPIXEL);
  ------------------
  |  |  257|    690|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
 4473|    690|    if (dp)
  ------------------
  |  Branch (4473:9): [True: 583, False: 107]
  ------------------
 4474|    583|    {
 4475|    583|        if (!TIFFFetchNormalTag(tif, dp, 0))
  ------------------
  |  Branch (4475:13): [True: 1, False: 582]
  ------------------
 4476|      1|            goto bad;
 4477|    582|        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|    582|#define TRUE 1
  ------------------
 4478|    582|    }
 4479|    689|    dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_COMPRESSION);
  ------------------
  |  |  181|    689|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
 4480|    689|    if (dp)
  ------------------
  |  Branch (4480:9): [True: 657, False: 32]
  ------------------
 4481|    657|    {
 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|    657|        uint16_t value;
 4489|    657|        enum TIFFReadDirEntryErr err;
 4490|    657|        err = TIFFReadDirEntryShort(tif, dp, &value);
 4491|    657|        if (err == TIFFReadDirEntryErrCount)
  ------------------
  |  Branch (4491:13): [True: 4, False: 653]
  ------------------
 4492|      4|            err = TIFFReadDirEntryPersampleShort(tif, dp, &value);
 4493|    657|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4493:13): [True: 3, False: 654]
  ------------------
 4494|      3|        {
 4495|      3|            TIFFReadDirEntryOutputErr(tif, err, module, "Compression", 0);
 4496|      3|            goto bad;
 4497|      3|        }
 4498|    654|        if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, value))
  ------------------
  |  |  181|    654|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  |  Branch (4498:13): [True: 0, False: 654]
  ------------------
 4499|      0|            goto bad;
 4500|    654|        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|    654|#define TRUE 1
  ------------------
 4501|    654|    }
 4502|     32|    else
 4503|     32|    {
 4504|     32|        if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE))
  ------------------
  |  |  181|     32|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
                      if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE))
  ------------------
  |  |  182|     32|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (4504:13): [True: 0, False: 32]
  ------------------
 4505|      0|            goto bad;
 4506|     32|    }
 4507|       |    /*
 4508|       |     * First real pass over the directory.
 4509|       |     */
 4510|  74.1k|    for (di = 0, dp = dir; di < dircount; di++, dp++)
  ------------------
  |  Branch (4510:28): [True: 73.4k, False: 674]
  ------------------
 4511|  73.4k|    {
 4512|  73.4k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4512:13): [True: 37.6k, False: 35.8k]
  ------------------
 4513|  37.6k|        {
 4514|  37.6k|            TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 4515|  37.6k|            if (fii == FAILED_FII)
  ------------------
  |  |   44|  37.6k|#define FAILED_FII ((uint32_t)-1)
  ------------------
  |  Branch (4515:17): [True: 30.3k, False: 7.30k]
  ------------------
 4516|  30.3k|            {
 4517|  30.3k|                if (tif->tif_warn_about_unknown_tags)
  ------------------
  |  Branch (4517:21): [True: 0, False: 30.3k]
  ------------------
 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|  30.3k|                const TIFFField *fld = _TIFFCreateAnonField(
 4527|  30.3k|                    tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
 4528|  30.3k|                if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
  ------------------
  |  Branch (4528:21): [True: 0, False: 30.3k]
  |  Branch (4528:36): [True: 0, False: 30.3k]
  ------------------
 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|  30.3k|                else
 4538|  30.3k|                {
 4539|  30.3k|                    TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 4540|  30.3k|                    assert(fii != FAILED_FII);
  ------------------
  |  Branch (4540:21): [True: 0, False: 30.3k]
  |  Branch (4540:21): [True: 30.3k, False: 0]
  ------------------
 4541|  30.3k|                }
 4542|  30.3k|            }
 4543|  37.6k|        }
 4544|  73.4k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4544:13): [True: 37.6k, False: 35.8k]
  ------------------
 4545|  37.6k|        {
 4546|  37.6k|            fip = tif->tif_fields[fii];
 4547|  37.6k|            if (fip->field_bit == FIELD_IGNORE)
  ------------------
  |  |  190|  37.6k|#define FIELD_IGNORE 0
  ------------------
  |  Branch (4547:17): [True: 295, False: 37.3k]
  ------------------
 4548|    295|                dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|    295|#define TRUE 1
  ------------------
 4549|  37.3k|            else
 4550|  37.3k|            {
 4551|  37.3k|                switch (dp->tdir_tag)
 4552|  37.3k|                {
 4553|    641|                    case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|    641|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (4553:21): [True: 641, False: 36.7k]
  ------------------
 4554|    934|                    case TIFFTAG_STRIPBYTECOUNTS:
  ------------------
  |  |  259|    934|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
  |  Branch (4554:21): [True: 293, False: 37.0k]
  ------------------
 4555|    935|                    case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|    935|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (4555:21): [True: 1, False: 37.3k]
  ------------------
 4556|    935|                    case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|    935|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (4556:21): [True: 0, False: 37.3k]
  ------------------
 4557|    935|                        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|    935|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|    935|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|    935|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 4558|    935|                        break;
 4559|    679|                    case TIFFTAG_IMAGEWIDTH:
  ------------------
  |  |  178|    679|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  |  Branch (4559:21): [True: 679, False: 36.6k]
  ------------------
 4560|  1.34k|                    case TIFFTAG_IMAGELENGTH:
  ------------------
  |  |  179|  1.34k|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  |  Branch (4560:21): [True: 668, False: 36.6k]
  ------------------
 4561|  1.34k|                    case TIFFTAG_IMAGEDEPTH:
  ------------------
  |  |  407|  1.34k|#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
  ------------------
  |  Branch (4561:21): [True: 0, False: 37.3k]
  ------------------
 4562|  1.35k|                    case TIFFTAG_TILELENGTH:
  ------------------
  |  |  312|  1.35k|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  |  Branch (4562:21): [True: 3, False: 37.3k]
  ------------------
 4563|  1.42k|                    case TIFFTAG_TILEWIDTH:
  ------------------
  |  |  311|  1.42k|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  |  Branch (4563:21): [True: 71, False: 37.2k]
  ------------------
 4564|  1.42k|                    case TIFFTAG_TILEDEPTH:
  ------------------
  |  |  408|  1.42k|#define TIFFTAG_TILEDEPTH 32998  /* z depth/data tile */
  ------------------
  |  Branch (4564:21): [True: 0, False: 37.3k]
  ------------------
 4565|  1.51k|                    case TIFFTAG_PLANARCONFIG:
  ------------------
  |  |  264|  1.51k|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  |  Branch (4565:21): [True: 98, False: 37.2k]
  ------------------
 4566|  1.94k|                    case TIFFTAG_ROWSPERSTRIP:
  ------------------
  |  |  258|  1.94k|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
  |  Branch (4566:21): [True: 427, False: 36.9k]
  ------------------
 4567|  2.28k|                    case TIFFTAG_EXTRASAMPLES:
  ------------------
  |  |  329|  2.28k|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  |  Branch (4567:21): [True: 338, False: 37.0k]
  ------------------
 4568|  2.28k|                        if (!TIFFFetchNormalTag(tif, dp, 0))
  ------------------
  |  Branch (4568:29): [True: 12, False: 2.27k]
  ------------------
 4569|     12|                            goto bad;
 4570|  2.27k|                        dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|  2.27k|#define TRUE 1
  ------------------
 4571|  2.27k|                        break;
 4572|  34.1k|                    default:
  ------------------
  |  Branch (4572:21): [True: 34.1k, False: 3.21k]
  ------------------
 4573|  34.1k|                        if (!_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag))
  ------------------
  |  Branch (4573:29): [True: 233, False: 33.8k]
  ------------------
 4574|    233|                            dp->tdir_ignore = TRUE;
  ------------------
  |  |   71|    233|#define TRUE 1
  ------------------
 4575|  34.1k|                        break;
 4576|  37.3k|                }
 4577|  37.3k|            }
 4578|  37.6k|        }
 4579|  73.4k|    }
 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|    674|    if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
  ------------------
  |  |  189|    674|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (4588:9): [True: 138, False: 536]
  ------------------
 4589|    138|        (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE))
  ------------------
  |  |  266|    138|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (4589:9): [True: 68, False: 70]
  ------------------
 4590|     68|    {
 4591|     68|        if (!_TIFFFillStriles(tif))
  ------------------
  |  Branch (4591:13): [True: 0, False: 68]
  ------------------
 4592|      0|            goto bad;
 4593|     68|        dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
 4594|     68|                                        TIFFTAG_STRIPOFFSETS);
  ------------------
  |  |  247|     68|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
 4595|     68|        if ((dp != 0) && (dp->tdir_count == 1))
  ------------------
  |  Branch (4595:13): [True: 68, False: 0]
  |  Branch (4595:26): [True: 1, False: 67]
  ------------------
 4596|      1|        {
 4597|      1|            dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
 4598|      1|                                            TIFFTAG_STRIPBYTECOUNTS);
  ------------------
  |  |  259|      1|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
 4599|      1|            if ((dp != 0) && (dp->tdir_count == 1))
  ------------------
  |  Branch (4599:17): [True: 1, False: 0]
  |  Branch (4599:30): [True: 1, False: 0]
  ------------------
 4600|      1|            {
 4601|      1|                tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
  ------------------
  |  |  265|      1|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
 4602|      1|                TIFFWarningExtR(tif, module,
 4603|      1|                                "Planarconfig tag value assumed incorrect, "
 4604|      1|                                "assuming data is contig instead of chunky");
 4605|      1|            }
 4606|      1|        }
 4607|     68|    }
 4608|       |    /*
 4609|       |     * Allocate directory structure and setup defaults.
 4610|       |     */
 4611|    674|    if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
  ------------------
  |  |  248|    674|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    674|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    674|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4611:9): [True: 2, False: 672]
  ------------------
 4612|      2|    {
 4613|      2|        MissingRequired(tif, "ImageLength");
 4614|      2|        goto bad;
 4615|      2|    }
 4616|       |
 4617|       |    /*
 4618|       |     * Second pass: extract other information.
 4619|       |     */
 4620|  69.4k|    for (di = 0, dp = dir; di < dircount; di++, dp++)
  ------------------
  |  Branch (4620:28): [True: 68.7k, False: 666]
  ------------------
 4621|  68.7k|    {
 4622|  68.7k|        if (!dp->tdir_ignore)
  ------------------
  |  Branch (4622:13): [True: 32.0k, False: 36.6k]
  ------------------
 4623|  32.0k|        {
 4624|  32.0k|            switch (dp->tdir_tag)
 4625|  32.0k|            {
 4626|      2|                case TIFFTAG_MINSAMPLEVALUE:
  ------------------
  |  |  260|      2|#define TIFFTAG_MINSAMPLEVALUE 280         /* +minimum sample value */
  ------------------
  |  Branch (4626:17): [True: 2, False: 32.0k]
  ------------------
 4627|      2|                case TIFFTAG_MAXSAMPLEVALUE:
  ------------------
  |  |  261|      2|#define TIFFTAG_MAXSAMPLEVALUE 281         /* +maximum sample value */
  ------------------
  |  Branch (4627:17): [True: 0, False: 32.0k]
  ------------------
 4628|    504|                case TIFFTAG_BITSPERSAMPLE:
  ------------------
  |  |  180|    504|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4628:17): [True: 502, False: 31.5k]
  ------------------
 4629|    504|                case TIFFTAG_DATATYPE:
  ------------------
  |  |  406|    504|#define TIFFTAG_DATATYPE 32996   /* $use SampleFormat */
  ------------------
  |  Branch (4629:17): [True: 0, False: 32.0k]
  ------------------
 4630|    505|                case TIFFTAG_SAMPLEFORMAT:
  ------------------
  |  |  333|    505|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
  |  Branch (4630:17): [True: 1, False: 32.0k]
  ------------------
 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|    505|                    {
 4642|    505|                        uint16_t value;
 4643|    505|                        enum TIFFReadDirEntryErr err;
 4644|    505|                        err = TIFFReadDirEntryShort(tif, dp, &value);
 4645|    505|                        if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4645:29): [True: 0, False: 505]
  ------------------
 4646|      0|                            goto bad;
 4647|    505|                        if (err == TIFFReadDirEntryErrCount)
  ------------------
  |  Branch (4647:29): [True: 3, False: 502]
  ------------------
 4648|      3|                            err =
 4649|      3|                                TIFFReadDirEntryPersampleShort(tif, dp, &value);
 4650|    505|                        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4650:29): [True: 3, False: 502]
  ------------------
 4651|      3|                        {
 4652|      3|                            fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4653|      3|                            TIFFReadDirEntryOutputErr(
 4654|      3|                                tif, err, module,
 4655|      3|                                fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (4655:33): [True: 3, False: 0]
  ------------------
 4656|      3|                            goto bad;
 4657|      3|                        }
 4658|    502|                        if (!TIFFSetField(tif, dp->tdir_tag, value))
  ------------------
  |  Branch (4658:29): [True: 0, False: 502]
  ------------------
 4659|      0|                            goto bad;
 4660|    502|                        if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE)
  ------------------
  |  |  180|    502|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4660:29): [True: 501, False: 1]
  ------------------
 4661|    501|                            bitspersample_read = TRUE;
  ------------------
  |  |   71|    501|#define TRUE 1
  ------------------
 4662|    502|                    }
 4663|      0|                    break;
 4664|      8|                case TIFFTAG_SMINSAMPLEVALUE:
  ------------------
  |  |  340|      8|#define TIFFTAG_SMINSAMPLEVALUE 340        /* !variable MinSampleValue */
  ------------------
  |  Branch (4664:17): [True: 8, False: 32.0k]
  ------------------
 4665|     10|                case TIFFTAG_SMAXSAMPLEVALUE:
  ------------------
  |  |  341|     10|#define TIFFTAG_SMAXSAMPLEVALUE 341        /* !variable MaxSampleValue */
  ------------------
  |  Branch (4665:17): [True: 2, False: 32.0k]
  ------------------
 4666|     10|                {
 4667|       |
 4668|     10|                    double *data = NULL;
 4669|     10|                    enum TIFFReadDirEntryErr err;
 4670|     10|                    uint32_t saved_flags;
 4671|     10|                    int m;
 4672|     10|                    if (dp->tdir_count !=
  ------------------
  |  Branch (4672:25): [True: 3, False: 7]
  ------------------
 4673|     10|                        (uint64_t)tif->tif_dir.td_samplesperpixel)
 4674|      3|                        err = TIFFReadDirEntryErrCount;
 4675|      7|                    else
 4676|      7|                        err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 4677|     10|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4677:25): [True: 0, False: 10]
  ------------------
 4678|      0|                        goto bad;
 4679|     10|                    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4679:25): [True: 3, False: 7]
  ------------------
 4680|      3|                    {
 4681|      3|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4682|      3|                        TIFFReadDirEntryOutputErr(
 4683|      3|                            tif, err, module,
 4684|      3|                            fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (4684:29): [True: 3, False: 0]
  ------------------
 4685|      3|                        goto bad;
 4686|      3|                    }
 4687|      7|                    saved_flags = tif->tif_flags;
 4688|      7|                    tif->tif_flags |= TIFF_PERSAMPLE;
  ------------------
  |  |  143|      7|#define TIFF_PERSAMPLE 0x400000U  /* get/set per sample tags as arrays */
  ------------------
 4689|      7|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 4690|      7|                    tif->tif_flags = saved_flags;
 4691|      7|                    _TIFFfreeExt(tif, data);
 4692|      7|                    if (!m)
  ------------------
  |  Branch (4692:25): [True: 0, False: 7]
  ------------------
 4693|      0|                        goto bad;
 4694|      7|                }
 4695|      7|                break;
 4696|    636|                case TIFFTAG_STRIPOFFSETS:
  ------------------
  |  |  247|    636|#define TIFFTAG_STRIPOFFSETS 273           /* offsets to data strips */
  ------------------
  |  Branch (4696:17): [True: 636, False: 31.4k]
  ------------------
 4697|    637|                case TIFFTAG_TILEOFFSETS:
  ------------------
  |  |  313|    637|#define TIFFTAG_TILEOFFSETS 324            /* !offsets to data tiles */
  ------------------
  |  Branch (4697:17): [True: 1, False: 32.0k]
  ------------------
 4698|    637|                {
 4699|    637|                    switch (dp->tdir_type)
 4700|    637|                    {
 4701|      3|                        case TIFF_SHORT:
  ------------------
  |  Branch (4701:25): [True: 3, False: 634]
  ------------------
 4702|    614|                        case TIFF_LONG:
  ------------------
  |  Branch (4702:25): [True: 611, False: 26]
  ------------------
 4703|    619|                        case TIFF_LONG8:
  ------------------
  |  Branch (4703:25): [True: 5, False: 632]
  ------------------
 4704|    619|                            break;
 4705|     18|                        default:
  ------------------
  |  Branch (4705:25): [True: 18, False: 619]
  ------------------
 4706|       |                            /* Warn except if directory typically created with
 4707|       |                             * TIFFDeferStrileArrayWriting() */
 4708|     18|                            if (!(tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (4708:35): [True: 0, False: 18]
  ------------------
 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|     18|                            {
 4712|     18|                                fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4713|     18|                                TIFFWarningExtR(
 4714|     18|                                    tif, module, "Invalid data type for tag %s",
 4715|     18|                                    fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4715:37): [True: 18, False: 0]
  ------------------
 4716|     18|                            }
 4717|     18|                            break;
 4718|    637|                    }
 4719|    637|                    _TIFFmemcpy(&(tif->tif_dir.td_stripoffset_entry), dp,
 4720|    637|                                sizeof(TIFFDirEntry));
 4721|    637|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4721:25): [True: 0, False: 637]
  ------------------
 4722|      0|                        goto bad;
 4723|    637|                }
 4724|    637|                break;
 4725|    637|                case TIFFTAG_STRIPBYTECOUNTS:
  ------------------
  |  |  259|    289|#define TIFFTAG_STRIPBYTECOUNTS 279        /* bytes counts for strips */
  ------------------
  |  Branch (4725:17): [True: 289, False: 31.7k]
  ------------------
 4726|    289|                case TIFFTAG_TILEBYTECOUNTS:
  ------------------
  |  |  314|    289|#define TIFFTAG_TILEBYTECOUNTS 325         /* !byte counts for tiles */
  ------------------
  |  Branch (4726:17): [True: 0, False: 32.0k]
  ------------------
 4727|    289|                {
 4728|    289|                    switch (dp->tdir_type)
 4729|    289|                    {
 4730|     66|                        case TIFF_SHORT:
  ------------------
  |  Branch (4730:25): [True: 66, False: 223]
  ------------------
 4731|    109|                        case TIFF_LONG:
  ------------------
  |  Branch (4731:25): [True: 43, False: 246]
  ------------------
 4732|    277|                        case TIFF_LONG8:
  ------------------
  |  Branch (4732:25): [True: 168, False: 121]
  ------------------
 4733|    277|                            break;
 4734|     12|                        default:
  ------------------
  |  Branch (4734:25): [True: 12, False: 277]
  ------------------
 4735|       |                            /* Warn except if directory typically created with
 4736|       |                             * TIFFDeferStrileArrayWriting() */
 4737|     12|                            if (!(tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (4737:35): [True: 0, False: 12]
  ------------------
 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|     12|                            {
 4741|     12|                                fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4742|     12|                                TIFFWarningExtR(
 4743|     12|                                    tif, module, "Invalid data type for tag %s",
 4744|     12|                                    fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4744:37): [True: 12, False: 0]
  ------------------
 4745|     12|                            }
 4746|     12|                            break;
 4747|    289|                    }
 4748|    289|                    _TIFFmemcpy(&(tif->tif_dir.td_stripbytecount_entry), dp,
 4749|    289|                                sizeof(TIFFDirEntry));
 4750|    289|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4750:25): [True: 0, False: 289]
  ------------------
 4751|      0|                        goto bad;
 4752|    289|                }
 4753|    289|                break;
 4754|    289|                case TIFFTAG_COLORMAP:
  ------------------
  |  |  309|      6|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (4754:17): [True: 6, False: 32.0k]
  ------------------
 4755|     30|                case TIFFTAG_TRANSFERFUNCTION:
  ------------------
  |  |  298|     30|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (4755:17): [True: 24, False: 32.0k]
  ------------------
 4756|     30|                {
 4757|     30|                    enum TIFFReadDirEntryErr err;
 4758|     30|                    uint32_t countpersample;
 4759|     30|                    uint32_t countrequired;
 4760|     30|                    uint32_t incrementpersample;
 4761|     30|                    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|     30|                    if (!bitspersample_read)
  ------------------
  |  Branch (4769:25): [True: 24, False: 6]
  ------------------
 4770|     24|                    {
 4771|     24|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4772|     24|                        TIFFWarningExtR(
 4773|     24|                            tif, module,
 4774|     24|                            "Ignoring %s since BitsPerSample tag not found",
 4775|     24|                            fip ? fip->field_name : "unknown tagname");
  ------------------
  |  Branch (4775:29): [True: 24, False: 0]
  ------------------
 4776|     24|                        continue;
 4777|     24|                    }
 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|      6|                    if (tif->tif_dir.td_bitspersample > 24)
  ------------------
  |  Branch (4781:25): [True: 0, False: 6]
  ------------------
 4782|      0|                    {
 4783|      0|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4784|      0|                        TIFFWarningExtR(
 4785|      0|                            tif, module,
 4786|      0|                            "Ignoring %s because BitsPerSample=%" PRIu16 ">24",
 4787|      0|                            fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (4787:29): [True: 0, False: 0]
  ------------------
 4788|      0|                            tif->tif_dir.td_bitspersample);
 4789|      0|                        continue;
 4790|      0|                    }
 4791|      6|                    countpersample = (1U << tif->tif_dir.td_bitspersample);
 4792|      6|                    if ((dp->tdir_tag == TIFFTAG_TRANSFERFUNCTION) &&
  ------------------
  |  |  298|      6|#define TIFFTAG_TRANSFERFUNCTION 301       /* !colorimetry info */
  ------------------
  |  Branch (4792:25): [True: 2, False: 4]
  ------------------
 4793|      2|                        (dp->tdir_count == (uint64_t)countpersample))
  ------------------
  |  Branch (4793:25): [True: 0, False: 2]
  ------------------
 4794|      0|                    {
 4795|      0|                        countrequired = countpersample;
 4796|      0|                        incrementpersample = 0;
 4797|      0|                    }
 4798|      6|                    else
 4799|      6|                    {
 4800|      6|                        countrequired = 3 * countpersample;
 4801|      6|                        incrementpersample = countpersample;
 4802|      6|                    }
 4803|      6|                    if (dp->tdir_count != (uint64_t)countrequired)
  ------------------
  |  Branch (4803:25): [True: 4, False: 2]
  ------------------
 4804|      4|                        err = TIFFReadDirEntryErrCount;
 4805|      2|                    else
 4806|      2|                        err = TIFFReadDirEntryShortArray(tif, dp, &value);
 4807|      6|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (4807:25): [True: 0, False: 6]
  ------------------
 4808|      0|                        goto bad;
 4809|      6|                    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (4809:25): [True: 4, False: 2]
  ------------------
 4810|      4|                    {
 4811|      4|                        fip = TIFFFieldWithTag(tif, dp->tdir_tag);
 4812|      4|                        TIFFReadDirEntryOutputErr(
 4813|      4|                            tif, err, module,
 4814|      4|                            fip ? fip->field_name : "unknown tagname", 1);
  ------------------
  |  Branch (4814:29): [True: 4, False: 0]
  ------------------
 4815|      4|                    }
 4816|      2|                    else
 4817|      2|                    {
 4818|      2|                        TIFFSetField(tif, dp->tdir_tag, value,
 4819|      2|                                     value + incrementpersample,
 4820|      2|                                     value + 2 * incrementpersample);
 4821|      2|                        _TIFFfreeExt(tif, value);
 4822|      2|                    }
 4823|      6|                }
 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: 32.0k]
  ------------------
 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|  30.6k|                default:
  ------------------
  |  Branch (4896:17): [True: 30.6k, False: 1.47k]
  ------------------
 4897|  30.6k|                    (void)TIFFFetchNormalTag(tif, dp, TRUE);
  ------------------
  |  |   71|  30.6k|#define TRUE 1
  ------------------
 4898|  30.6k|                    break;
 4899|  32.0k|            } /* -- switch (dp->tdir_tag) -- */
 4900|  32.0k|        } /* -- if (!dp->tdir_ignore) */
 4901|  68.7k|    } /* -- for-loop -- */
 4902|       |
 4903|       |    /* Evaluate final IFD data size. */
 4904|    666|    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|    666|    if (tif->tif_dir.td_compression == COMPRESSION_OJPEG)
  ------------------
  |  |  189|    666|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (4922:9): [True: 137, False: 529]
  ------------------
 4923|    137|    {
 4924|    137|        if (!TIFFFieldSet(tif, FIELD_PHOTOMETRIC))
  ------------------
  |  |  248|    137|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    137|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    137|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4924:13): [True: 94, False: 43]
  ------------------
 4925|     94|        {
 4926|     94|            TIFFWarningExtR(
 4927|     94|                tif, module,
 4928|     94|                "Photometric tag is missing, assuming data is YCbCr");
 4929|     94|            if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR))
  ------------------
  |  |  220|     94|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
                          if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR))
  ------------------
  |  |  227|     94|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4929:17): [True: 0, False: 94]
  ------------------
 4930|      0|                goto bad;
 4931|     94|        }
 4932|     43|        else if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|     43|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4932:18): [True: 0, False: 43]
  ------------------
 4933|      0|        {
 4934|      0|            tif->tif_dir.td_photometric = PHOTOMETRIC_YCBCR;
  ------------------
  |  |  227|      0|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
 4935|      0|            TIFFWarningExtR(tif, module,
 4936|      0|                            "Photometric tag value assumed incorrect, "
 4937|      0|                            "assuming data is YCbCr instead of RGB");
 4938|      0|        }
 4939|    137|        if (!TIFFFieldSet(tif, FIELD_BITSPERSAMPLE))
  ------------------
  |  |  248|    137|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    137|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    137|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4939:13): [True: 125, False: 12]
  ------------------
 4940|    125|        {
 4941|    125|            TIFFWarningExtR(
 4942|    125|                tif, module,
 4943|    125|                "BitsPerSample tag is missing, assuming 8 bits per sample");
 4944|    125|            if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8))
  ------------------
  |  |  180|    125|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  |  Branch (4944:17): [True: 0, False: 125]
  ------------------
 4945|      0|                goto bad;
 4946|    125|        }
 4947|    137|        if (!TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
  ------------------
  |  |  248|    137|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    137|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    137|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4947:13): [True: 69, False: 68]
  ------------------
 4948|     69|        {
 4949|     69|            if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|     69|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4949:17): [True: 0, False: 69]
  ------------------
 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|     69|            if (tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR)
  ------------------
  |  |  227|     69|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4957:17): [True: 49, False: 20]
  ------------------
 4958|     49|            {
 4959|     49|                TIFFWarningExtR(tif, module,
 4960|     49|                                "SamplesPerPixel tag is missing, "
 4961|     49|                                "applying correct SamplesPerPixel value of 3");
 4962|     49|                if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3))
  ------------------
  |  |  257|     49|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (4962:21): [True: 0, False: 49]
  ------------------
 4963|      0|                    goto bad;
 4964|     49|            }
 4965|     20|            else if ((tif->tif_dir.td_photometric == PHOTOMETRIC_MINISWHITE) ||
  ------------------
  |  |  221|     20|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (4965:22): [True: 0, False: 20]
  ------------------
 4966|     20|                     (tif->tif_dir.td_photometric == PHOTOMETRIC_MINISBLACK))
  ------------------
  |  |  222|     20|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (4966:22): [True: 0, False: 20]
  ------------------
 4967|      0|            {
 4968|       |                /*
 4969|       |                 * SamplesPerPixel tag is missing, but is not required
 4970|       |                 * by spec.  Assume correct SamplesPerPixel value of 1.
 4971|       |                 */
 4972|      0|                if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1))
  ------------------
  |  |  257|      0|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  |  Branch (4972:21): [True: 0, False: 0]
  ------------------
 4973|      0|                    goto bad;
 4974|      0|            }
 4975|     69|        }
 4976|    137|    }
 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|    666|    if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
  ------------------
  |  |  248|    666|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    666|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    666|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (4983:9): [True: 592, False: 74]
  ------------------
 4984|    592|    {
 4985|    592|        tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif);
 4986|    592|        tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth;
 4987|    592|        tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip;
 4988|    592|        tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth;
 4989|    592|        tif->tif_flags &= ~TIFF_ISTILED;
  ------------------
  |  |  129|    592|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 4990|    592|    }
 4991|     74|    else
 4992|     74|    {
 4993|     74|        tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif);
 4994|     74|        tif->tif_flags |= TIFF_ISTILED;
  ------------------
  |  |  129|     74|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
 4995|     74|    }
 4996|    666|    if (!tif->tif_dir.td_nstrips)
  ------------------
  |  Branch (4996:9): [True: 2, False: 664]
  ------------------
 4997|      2|    {
 4998|      2|        TIFFErrorExtR(tif, module, "Cannot handle zero number of %s",
 4999|      2|                      isTiled(tif) ? "tiles" : "strips");
  ------------------
  |  |  278|      2|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      2|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 5000|      2|        goto bad;
 5001|      2|    }
 5002|    664|    tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips;
 5003|    664|    if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    664|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5003:9): [True: 72, False: 592]
  ------------------
 5004|     72|        tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel;
 5005|    664|    if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS))
  ------------------
  |  |  248|    664|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    664|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    664|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5005:9): [True: 31, False: 633]
  ------------------
 5006|     31|    {
 5007|     31|#ifdef OJPEG_SUPPORT
 5008|     31|        if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
  ------------------
  |  |  189|     31|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (5008:13): [True: 27, False: 4]
  ------------------
 5009|     27|            (isTiled(tif) == 0) && (tif->tif_dir.td_nstrips == 1))
  ------------------
  |  |  278|     27|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     27|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (5009:13): [True: 27, False: 0]
  |  Branch (5009:36): [True: 27, False: 0]
  ------------------
 5010|     27|        {
 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|     27|            TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
  ------------------
  |  |  249|     27|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     27|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     27|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 5020|     27|        }
 5021|      4|        else
 5022|      4|#endif
 5023|      4|        {
 5024|      4|            MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets");
  ------------------
  |  |  278|      4|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      4|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 5025|      4|            goto bad;
 5026|      4|        }
 5027|     31|    }
 5028|       |
 5029|    660|    if (tif->tif_mode == O_RDWR &&
  ------------------
  |  Branch (5029:9): [True: 0, False: 660]
  ------------------
 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|    660|    else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD))
  ------------------
  |  |  147|    660|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (5042:14): [True: 660, False: 0]
  ------------------
 5043|    660|    {
 5044|    660|        if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0)
  ------------------
  |  Branch (5044:13): [True: 633, False: 27]
  ------------------
 5045|    633|        {
 5046|    633|            if (!TIFFFetchStripThing(tif, &(tif->tif_dir.td_stripoffset_entry),
  ------------------
  |  Branch (5046:17): [True: 8, False: 625]
  ------------------
 5047|    633|                                     tif->tif_dir.td_nstrips,
 5048|    633|                                     &tif->tif_dir.td_stripoffset_p))
 5049|      8|            {
 5050|      8|                goto bad;
 5051|      8|            }
 5052|    633|        }
 5053|    652|        if (tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0)
  ------------------
  |  Branch (5053:13): [True: 279, False: 373]
  ------------------
 5054|    279|        {
 5055|    279|            if (!TIFFFetchStripThing(
  ------------------
  |  Branch (5055:17): [True: 31, False: 248]
  ------------------
 5056|    279|                    tif, &(tif->tif_dir.td_stripbytecount_entry),
 5057|    279|                    tif->tif_dir.td_nstrips, &tif->tif_dir.td_stripbytecount_p))
 5058|     31|            {
 5059|     31|                goto bad;
 5060|     31|            }
 5061|    279|        }
 5062|    652|    }
 5063|       |
 5064|       |    /*
 5065|       |     * Make sure all non-color channels are extrasamples.
 5066|       |     * If it's not the case, define them as such.
 5067|       |     */
 5068|    621|    color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric);
 5069|    621|    if (color_channels &&
  ------------------
  |  Branch (5069:9): [True: 620, False: 1]
  ------------------
 5070|    620|        tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples >
  ------------------
  |  Branch (5070:9): [True: 131, False: 489]
  ------------------
 5071|    620|            color_channels)
 5072|    131|    {
 5073|    131|        uint16_t old_extrasamples;
 5074|    131|        uint16_t *new_sampleinfo;
 5075|       |
 5076|    131|        TIFFWarningExtR(
 5077|    131|            tif, module,
 5078|    131|            "Sum of Photometric type-related "
 5079|    131|            "color channels and ExtraSamples doesn't match SamplesPerPixel. "
 5080|    131|            "Defining non-color channels as ExtraSamples.");
 5081|       |
 5082|    131|        old_extrasamples = tif->tif_dir.td_extrasamples;
 5083|    131|        tif->tif_dir.td_extrasamples =
 5084|    131|            (uint16_t)(tif->tif_dir.td_samplesperpixel - color_channels);
 5085|       |
 5086|       |        // sampleinfo should contain information relative to these new extra
 5087|       |        // samples
 5088|    131|        new_sampleinfo = (uint16_t *)_TIFFcallocExt(
 5089|    131|            tif, tif->tif_dir.td_extrasamples, sizeof(uint16_t));
 5090|    131|        if (!new_sampleinfo)
  ------------------
  |  Branch (5090:13): [True: 0, False: 131]
  ------------------
 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|    131|        if (old_extrasamples > 0)
  ------------------
  |  Branch (5100:13): [True: 26, False: 105]
  ------------------
 5101|     26|            memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo,
 5102|     26|                   old_extrasamples * sizeof(uint16_t));
 5103|    131|        _TIFFsetShortArrayExt(tif, &tif->tif_dir.td_sampleinfo, new_sampleinfo,
 5104|    131|                              tif->tif_dir.td_extrasamples);
 5105|    131|        _TIFFfreeExt(tif, new_sampleinfo);
 5106|    131|    }
 5107|       |
 5108|       |    /*
 5109|       |     * Verify Palette image has a Colormap.
 5110|       |     */
 5111|    621|    if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE &&
  ------------------
  |  |  224|  1.24k|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (5111:9): [True: 70, False: 551]
  ------------------
 5112|     70|        !TIFFFieldSet(tif, FIELD_COLORMAP))
  ------------------
  |  |  248|     70|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|     70|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|     70|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5112:9): [True: 70, False: 0]
  ------------------
 5113|     70|    {
 5114|     70|        if (tif->tif_dir.td_bitspersample >= 8 &&
  ------------------
  |  Branch (5114:13): [True: 70, False: 0]
  ------------------
 5115|     70|            tif->tif_dir.td_samplesperpixel == 3)
  ------------------
  |  Branch (5115:13): [True: 0, False: 70]
  ------------------
 5116|      0|            tif->tif_dir.td_photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
 5117|     70|        else if (tif->tif_dir.td_bitspersample >= 8)
  ------------------
  |  Branch (5117:18): [True: 70, False: 0]
  ------------------
 5118|     70|            tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|     70|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
 5119|      0|        else
 5120|      0|        {
 5121|      0|            MissingRequired(tif, "Colormap");
 5122|      0|            goto bad;
 5123|      0|        }
 5124|     70|    }
 5125|       |    /*
 5126|       |     * OJPEG hack:
 5127|       |     * We do no further messing with strip/tile offsets/bytecounts in OJPEG
 5128|       |     * TIFFs
 5129|       |     */
 5130|    621|    if (tif->tif_dir.td_compression != COMPRESSION_OJPEG)
  ------------------
  |  |  189|    621|#define COMPRESSION_OJPEG 6           /* !6.0 JPEG */
  ------------------
  |  Branch (5130:9): [True: 489, False: 132]
  ------------------
 5131|    489|    {
 5132|       |        /*
 5133|       |         * Attempt to deal with a missing StripByteCounts tag.
 5134|       |         */
 5135|    489|        if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS))
  ------------------
  |  |  248|    489|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    489|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    489|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5135:13): [True: 338, False: 151]
  ------------------
 5136|    338|        {
 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|    338|            if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|    676|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5142:18): [True: 338, False: 0]
  ------------------
 5143|    338|                 tif->tif_dir.td_nstrips > 1) ||
  ------------------
  |  Branch (5143:18): [True: 0, False: 338]
  ------------------
 5144|    338|                (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE &&
  ------------------
  |  |  266|    676|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5144:18): [True: 0, False: 338]
  ------------------
 5145|      0|                 tif->tif_dir.td_nstrips !=
  ------------------
  |  Branch (5145:18): [True: 0, False: 0]
  ------------------
 5146|      0|                     (uint32_t)tif->tif_dir.td_samplesperpixel))
 5147|      0|            {
 5148|      0|                MissingRequired(tif, "StripByteCounts");
 5149|      0|                goto bad;
 5150|      0|            }
 5151|    338|            TIFFWarningExtR(
 5152|    338|                tif, module,
 5153|    338|                "TIFF directory is missing required "
 5154|    338|                "\"StripByteCounts\" field, calculating from imagelength");
 5155|    338|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5155:17): [True: 12, False: 326]
  ------------------
 5156|     12|                goto bad;
 5157|    338|        }
 5158|    151|        else if (tif->tif_dir.td_nstrips == 1 &&
  ------------------
  |  Branch (5158:18): [True: 129, False: 22]
  ------------------
 5159|    129|                 !(tif->tif_flags & TIFF_ISTILED) && ByteCountLooksBad(tif))
  ------------------
  |  |  129|    129|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
  |  Branch (5159:18): [True: 129, False: 0]
  |  Branch (5159:54): [True: 7, False: 122]
  ------------------
 5160|      7|        {
 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|      7|            TIFFWarningExtR(tif, module,
 5168|      7|                            "Bogus \"StripByteCounts\" field, ignoring and "
 5169|      7|                            "calculating from imagelength");
 5170|      7|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5170:17): [True: 6, False: 1]
  ------------------
 5171|      6|                goto bad;
 5172|      7|        }
 5173|    144|        else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
  ------------------
  |  |  147|    144|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (5173:18): [True: 144, False: 0]
  ------------------
 5174|    144|                 tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|    288|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5174:18): [True: 142, False: 2]
  ------------------
 5175|    142|                 tif->tif_dir.td_nstrips > 2 &&
  ------------------
  |  Branch (5175:18): [True: 20, False: 122]
  ------------------
 5176|     20|                 tif->tif_dir.td_compression == COMPRESSION_NONE &&
  ------------------
  |  |  182|    164|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5176:18): [True: 5, False: 15]
  ------------------
 5177|      5|                 TIFFGetStrileByteCount(tif, 0) !=
  ------------------
  |  Branch (5177:18): [True: 5, False: 0]
  ------------------
 5178|      5|                     TIFFGetStrileByteCount(tif, 1) &&
 5179|      5|                 TIFFGetStrileByteCount(tif, 0) != 0 &&
  ------------------
  |  Branch (5179:18): [True: 5, False: 0]
  ------------------
 5180|      5|                 TIFFGetStrileByteCount(tif, 1) != 0)
  ------------------
  |  Branch (5180:18): [True: 0, False: 5]
  ------------------
 5181|      0|        {
 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|      0|            TIFFWarningExtR(tif, module,
 5193|      0|                            "Wrong \"StripByteCounts\" field, ignoring and "
 5194|      0|                            "calculating from imagelength");
 5195|      0|            if (EstimateStripByteCounts(tif, dir, dircount) < 0)
  ------------------
  |  Branch (5195:17): [True: 0, False: 0]
  ------------------
 5196|      0|                goto bad;
 5197|      0|        }
 5198|    489|    }
 5199|    603|    if (dir)
  ------------------
  |  Branch (5199:9): [True: 603, False: 0]
  ------------------
 5200|    603|    {
 5201|    603|        _TIFFfreeExt(tif, dir);
 5202|    603|        dir = NULL;
 5203|    603|    }
 5204|    603|    if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE))
  ------------------
  |  |  248|    603|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    603|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    603|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5204:9): [True: 603, False: 0]
  ------------------
 5205|    603|    {
 5206|    603|        if (tif->tif_dir.td_bitspersample >= 16)
  ------------------
  |  Branch (5206:13): [True: 366, False: 237]
  ------------------
 5207|    366|            tif->tif_dir.td_maxsamplevalue = 0xFFFF;
 5208|    237|        else
 5209|    237|            tif->tif_dir.td_maxsamplevalue =
 5210|    237|                (uint16_t)((1 << tif->tif_dir.td_bitspersample) - 1);
 5211|    603|    }
 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|    603|    (*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|    603|    if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|    603|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5250:9): [True: 536, False: 67]
  ------------------
 5251|    536|        (tif->tif_dir.td_nstrips == 1) &&
  ------------------
  |  Branch (5251:9): [True: 499, False: 37]
  ------------------
 5252|    499|        (tif->tif_dir.td_compression == COMPRESSION_NONE) &&
  ------------------
  |  |  182|    499|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5252:9): [True: 10, False: 489]
  ------------------
 5253|     10|        ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  134|     10|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
                      ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  129|     10|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
                      ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
  ------------------
  |  |  134|     10|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  |  Branch (5253:9): [True: 10, False: 0]
  ------------------
 5254|     10|    {
 5255|     10|        ChopUpSingleUncompressedStrip(tif);
 5256|     10|    }
 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|    603|    if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|  1.20k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (5261:9): [True: 536, False: 67]
  ------------------
 5262|    536|        tif->tif_dir.td_compression == COMPRESSION_NONE &&
  ------------------
  |  |  182|  1.13k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5262:9): [True: 15, False: 521]
  ------------------
 5263|     15|        (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  134|     15|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
                      (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  129|     15|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  ------------------
                      (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
  ------------------
  |  |  134|    618|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  ------------------
  |  Branch (5263:9): [True: 11, False: 4]
  ------------------
 5264|     11|        TIFFStripSize64(tif) > 0x7FFFFFFFUL)
  ------------------
  |  Branch (5264:9): [True: 2, False: 9]
  ------------------
 5265|      2|    {
 5266|      2|        TryChopUpUncompressedBigTiff(tif);
 5267|      2|    }
 5268|       |
 5269|       |    /*
 5270|       |     * Clear the dirty directory flag.
 5271|       |     */
 5272|    603|    tif->tif_flags &= ~TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|    603|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 5273|    603|    tif->tif_flags &= ~TIFF_DIRTYSTRIP;
  ------------------
  |  |  142|    603|#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|    603|    tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 5279|    603|    if (!tif->tif_dir.td_scanlinesize)
  ------------------
  |  Branch (5279:9): [True: 5, False: 598]
  ------------------
 5280|      5|    {
 5281|      5|        TIFFErrorExtR(tif, module, "Cannot handle zero scanline size");
 5282|      5|        return (0);
 5283|      5|    }
 5284|       |
 5285|    598|    if (isTiled(tif))
  ------------------
  |  |  278|    598|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    598|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 70, False: 528]
  |  |  ------------------
  ------------------
 5286|     70|    {
 5287|     70|        tif->tif_dir.td_tilesize = TIFFTileSize(tif);
 5288|     70|        if (!tif->tif_dir.td_tilesize)
  ------------------
  |  Branch (5288:13): [True: 0, False: 70]
  ------------------
 5289|      0|        {
 5290|      0|            TIFFErrorExtR(tif, module, "Cannot handle zero tile size");
 5291|      0|            return (0);
 5292|      0|        }
 5293|     70|    }
 5294|    528|    else
 5295|    528|    {
 5296|    528|        if (!TIFFStripSize(tif))
  ------------------
  |  Branch (5296:13): [True: 0, False: 528]
  ------------------
 5297|      0|        {
 5298|      0|            TIFFErrorExtR(tif, module, "Cannot handle zero strip size");
 5299|      0|            return (0);
 5300|      0|        }
 5301|    528|    }
 5302|    598|    return (1);
 5303|     87|bad:
 5304|     87|    if (dir)
  ------------------
  |  Branch (5304:9): [True: 87, False: 0]
  ------------------
 5305|     87|        _TIFFfreeExt(tif, dir);
 5306|     87|    return (0);
 5307|    598|} /*-- TIFFReadDirectory() --*/
_TIFFCheckDirNumberAndOffset:
 5773|    963|{
 5774|    963|    if (diroff == 0) /* no more directories */
  ------------------
  |  Branch (5774:9): [True: 0, False: 963]
  ------------------
 5775|      0|        return 0;
 5776|       |
 5777|    963|    if (tif->tif_map_dir_offset_to_number == NULL)
  ------------------
  |  Branch (5777:9): [True: 398, False: 565]
  ------------------
 5778|    398|    {
 5779|    398|        tif->tif_map_dir_offset_to_number = TIFFHashSetNew(
 5780|    398|            hashFuncOffsetToNumber, equalFuncOffsetToNumber, free);
 5781|    398|        if (tif->tif_map_dir_offset_to_number == NULL)
  ------------------
  |  Branch (5781:13): [True: 0, False: 398]
  ------------------
 5782|      0|        {
 5783|      0|            TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5784|      0|                          "Not enough memory");
 5785|      0|            return 1;
 5786|      0|        }
 5787|    398|    }
 5788|       |
 5789|    963|    if (tif->tif_map_dir_number_to_offset == NULL)
  ------------------
  |  Branch (5789:9): [True: 398, False: 565]
  ------------------
 5790|    398|    {
 5791|       |        /* No free callback for this map, as it shares the same items as
 5792|       |         * tif->tif_map_dir_offset_to_number. */
 5793|    398|        tif->tif_map_dir_number_to_offset = TIFFHashSetNew(
 5794|    398|            hashFuncNumberToOffset, equalFuncNumberToOffset, NULL);
 5795|    398|        if (tif->tif_map_dir_number_to_offset == NULL)
  ------------------
  |  Branch (5795:13): [True: 0, False: 398]
  ------------------
 5796|      0|        {
 5797|      0|            TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
 5798|      0|                          "Not enough memory");
 5799|      0|            return 1;
 5800|      0|        }
 5801|    398|    }
 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|    963|    TIFFOffsetAndDirNumber entry;
 5809|    963|    entry.offset = diroff;
 5810|    963|    entry.dirNumber = dirn;
 5811|       |
 5812|    963|    TIFFOffsetAndDirNumber *foundEntry =
 5813|    963|        (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5814|    963|            tif->tif_map_dir_offset_to_number, &entry);
 5815|    963|    if (foundEntry)
  ------------------
  |  Branch (5815:9): [True: 2, False: 961]
  ------------------
 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|    961|    foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
 5835|    961|        tif->tif_map_dir_number_to_offset, &entry);
 5836|    961|    if (foundEntry)
  ------------------
  |  Branch (5836:9): [True: 0, False: 961]
  ------------------
 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|    961|    if (TIFFHashSetSize(tif->tif_map_dir_offset_to_number) >=
  ------------------
  |  Branch (5891:9): [True: 0, False: 961]
  ------------------
 5892|    961|        TIFF_MAX_DIR_COUNT)
  ------------------
  |  |  122|    961|#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|    961|    TIFFOffsetAndDirNumber *entryPtr =
 5901|    961|        (TIFFOffsetAndDirNumber *)malloc(sizeof(TIFFOffsetAndDirNumber));
 5902|    961|    if (entryPtr == NULL)
  ------------------
  |  Branch (5902:9): [True: 0, False: 961]
  ------------------
 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|    961|    *entryPtr = entry;
 5911|       |
 5912|    961|    if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr))
  ------------------
  |  Branch (5912:9): [True: 0, False: 961]
  ------------------
 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|    961|    if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr))
  ------------------
  |  Branch (5918:9): [True: 0, False: 961]
  ------------------
 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|    961|    return 1;
 5926|    961|} /* --- _TIFFCheckDirNumberAndOffset() ---*/
TIFFGetStrileOffset:
 8522|  4.53k|{
 8523|       |    return TIFFGetStrileOffsetWithErr(tif, strile, NULL);
 8524|  4.53k|}
TIFFGetStrileOffsetWithErr:
 8529|  94.3k|{
 8530|  94.3k|    TIFFDirectory *td = &tif->tif_dir;
 8531|  94.3k|    return _TIFFGetStrileOffsetOrByteCountValue(tif, strile,
 8532|  94.3k|                                                &(td->td_stripoffset_entry),
 8533|  94.3k|                                                &(td->td_stripoffset_p), pbErr);
 8534|  94.3k|}
TIFFGetStrileByteCount:
 8539|  6.07k|{
 8540|       |    return TIFFGetStrileByteCountWithErr(tif, strile, NULL);
 8541|  6.07k|}
TIFFGetStrileByteCountWithErr:
 8546|  60.5k|{
 8547|  60.5k|    TIFFDirectory *td = &tif->tif_dir;
 8548|  60.5k|    return _TIFFGetStrileOffsetOrByteCountValue(
 8549|  60.5k|        tif, strile, &(td->td_stripbytecount_entry), &(td->td_stripbytecount_p),
 8550|  60.5k|        pbErr);
 8551|  60.5k|}
_TIFFFillStriles:
 8553|     68|int _TIFFFillStriles(TIFF *tif) { return _TIFFFillStrilesInternal(tif, 1); }
tif_dirread.c:TIFFReadDirEntryShort:
  486|  3.25k|{
  487|  3.25k|    enum TIFFReadDirEntryErr err;
  488|  3.25k|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (488:9): [True: 678, False: 2.57k]
  ------------------
  489|    678|        return (TIFFReadDirEntryErrCount);
  490|  2.57k|    switch (direntry->tdir_type)
  491|  2.57k|    {
  492|      4|        case TIFF_BYTE:
  ------------------
  |  Branch (492:9): [True: 4, False: 2.57k]
  ------------------
  493|      4|        {
  494|      4|            uint8_t m;
  495|      4|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  496|      4|            *value = (uint16_t)m;
  497|      4|            return (TIFFReadDirEntryErrOk);
  498|      0|        }
  499|      3|        case TIFF_SBYTE:
  ------------------
  |  Branch (499:9): [True: 3, False: 2.57k]
  ------------------
  500|      3|        {
  501|      3|            int8_t m;
  502|      3|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  503|      3|            err = TIFFReadDirEntryCheckRangeShortSbyte(m);
  504|      3|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (504:17): [True: 0, False: 3]
  ------------------
  505|      0|                return (err);
  506|      3|            *value = (uint16_t)m;
  507|      3|            return (TIFFReadDirEntryErrOk);
  508|      3|        }
  509|  2.54k|        case TIFF_SHORT:
  ------------------
  |  Branch (509:9): [True: 2.54k, False: 36]
  ------------------
  510|  2.54k|            TIFFReadDirEntryCheckedShort(tif, direntry, value);
  511|  2.54k|            return (TIFFReadDirEntryErrOk);
  512|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (512:9): [True: 0, False: 2.57k]
  ------------------
  513|      0|        {
  514|      0|            int16_t m;
  515|      0|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  516|      0|            err = TIFFReadDirEntryCheckRangeShortSshort(m);
  517|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (517:17): [True: 0, False: 0]
  ------------------
  518|      0|                return (err);
  519|      0|            *value = (uint16_t)m;
  520|      0|            return (TIFFReadDirEntryErrOk);
  521|      0|        }
  522|     23|        case TIFF_LONG:
  ------------------
  |  Branch (522:9): [True: 23, False: 2.55k]
  ------------------
  523|     23|        {
  524|     23|            uint32_t m;
  525|     23|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  526|     23|            err = TIFFReadDirEntryCheckRangeShortLong(m);
  527|     23|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (527:17): [True: 4, False: 19]
  ------------------
  528|      4|                return (err);
  529|     19|            *value = (uint16_t)m;
  530|     19|            return (TIFFReadDirEntryErrOk);
  531|     23|        }
  532|      2|        case TIFF_SLONG:
  ------------------
  |  Branch (532:9): [True: 2, False: 2.57k]
  ------------------
  533|      2|        {
  534|      2|            int32_t m;
  535|      2|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  536|      2|            err = TIFFReadDirEntryCheckRangeShortSlong(m);
  537|      2|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (537:17): [True: 2, False: 0]
  ------------------
  538|      2|                return (err);
  539|      0|            *value = (uint16_t)m;
  540|      0|            return (TIFFReadDirEntryErrOk);
  541|      2|        }
  542|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (542:9): [True: 0, False: 2.57k]
  ------------------
  543|      0|        {
  544|      0|            uint64_t m;
  545|      0|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  546|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (546:17): [True: 0, False: 0]
  ------------------
  547|      0|                return (err);
  548|      0|            err = TIFFReadDirEntryCheckRangeShortLong8(m);
  549|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (549:17): [True: 0, False: 0]
  ------------------
  550|      0|                return (err);
  551|      0|            *value = (uint16_t)m;
  552|      0|            return (TIFFReadDirEntryErrOk);
  553|      0|        }
  554|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (554:9): [True: 0, False: 2.57k]
  ------------------
  555|      0|        {
  556|      0|            int64_t m;
  557|      0|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  558|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (558:17): [True: 0, False: 0]
  ------------------
  559|      0|                return (err);
  560|      0|            err = TIFFReadDirEntryCheckRangeShortSlong8(m);
  561|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (561:17): [True: 0, False: 0]
  ------------------
  562|      0|                return (err);
  563|      0|            *value = (uint16_t)m;
  564|      0|            return (TIFFReadDirEntryErrOk);
  565|      0|        }
  566|      4|        default:
  ------------------
  |  Branch (566:9): [True: 4, False: 2.57k]
  ------------------
  567|      4|            return (TIFFReadDirEntryErrType);
  568|  2.57k|    }
  569|  2.57k|} /*-- TIFFReadDirEntryShort() --*/
tif_dirread.c:TIFFReadDirEntryCheckedByte:
 3406|      6|{
 3407|      6|    (void)tif;
 3408|      6|    *value = *(uint8_t *)(&direntry->tdir_offset);
 3409|      6|}
tif_dirread.c:TIFFReadDirEntryCheckedSbyte:
 3413|     36|{
 3414|     36|    (void)tif;
 3415|     36|    *value = *(int8_t *)(&direntry->tdir_offset);
 3416|     36|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSbyte:
 3772|      3|{
 3773|      3|    if (value < 0)
  ------------------
  |  Branch (3773:9): [True: 0, False: 3]
  ------------------
 3774|      0|        return (TIFFReadDirEntryErrRange);
 3775|      3|    else
 3776|      3|        return (TIFFReadDirEntryErrOk);
 3777|      3|}
tif_dirread.c:TIFFReadDirEntryCheckedShort:
 3420|  4.33k|{
 3421|  4.33k|    *value = direntry->tdir_offset.toff_short;
 3422|       |    /* *value=*(uint16_t*)(&direntry->tdir_offset); */
 3423|  4.33k|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  4.33k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3423:9): [True: 0, False: 4.33k]
  ------------------
 3424|      0|        TIFFSwabShort(value);
 3425|  4.33k|}
tif_dirread.c:TIFFReadDirEntryCheckedSshort:
 3429|     17|{
 3430|     17|    *value = *(int16_t *)(&direntry->tdir_offset);
 3431|     17|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     17|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3431:9): [True: 0, False: 17]
  ------------------
 3432|      0|        TIFFSwabShort((uint16_t *)value);
 3433|     17|}
tif_dirread.c:TIFFReadDirEntryCheckedLong:
 3437|     87|{
 3438|     87|    *value = *(uint32_t *)(&direntry->tdir_offset);
 3439|     87|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     87|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3439:9): [True: 0, False: 87]
  ------------------
 3440|      0|        TIFFSwabLong(value);
 3441|     87|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortLong:
 3790|     37|{
 3791|     37|    if (value > 0xFFFF)
  ------------------
  |  Branch (3791:9): [True: 4, False: 33]
  ------------------
 3792|      4|        return (TIFFReadDirEntryErrRange);
 3793|     33|    else
 3794|     33|        return (TIFFReadDirEntryErrOk);
 3795|     37|}
tif_dirread.c:TIFFReadDirEntryCheckedSlong:
 3445|     10|{
 3446|     10|    *value = *(int32_t *)(&direntry->tdir_offset);
 3447|     10|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     10|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3447:9): [True: 0, False: 10]
  ------------------
 3448|      0|        TIFFSwabLong((uint32_t *)value);
 3449|     10|}
tif_dirread.c:TIFFReadDirEntryCheckRangeShortSlong:
 3799|      2|{
 3800|      2|    if ((value < 0) || (value > 0xFFFF))
  ------------------
  |  Branch (3800:9): [True: 0, False: 2]
  |  Branch (3800:24): [True: 2, False: 0]
  ------------------
 3801|      2|        return (TIFFReadDirEntryErrRange);
 3802|      0|    else
 3803|      0|        return (TIFFReadDirEntryErrOk);
 3804|      2|}
tif_dirread.c:TIFFReadDirEntryCheckedLong8:
 3453|      3|{
 3454|      3|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      3|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3454:9): [True: 3, False: 0]
  ------------------
 3455|      3|    {
 3456|      3|        enum TIFFReadDirEntryErr err;
 3457|      3|        uint32_t offset = direntry->tdir_offset.toff_long;
 3458|      3|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      3|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3458:13): [True: 0, False: 3]
  ------------------
 3459|      0|            TIFFSwabLong(&offset);
 3460|      3|        err = TIFFReadDirEntryData(tif, offset, 8, value);
 3461|      3|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3461:13): [True: 0, False: 3]
  ------------------
 3462|      0|            return (err);
 3463|      3|    }
 3464|      0|    else
 3465|      0|        *value = direntry->tdir_offset.toff_long8;
 3466|      3|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      3|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3466:9): [True: 0, False: 3]
  ------------------
 3467|      0|        TIFFSwabLong8(value);
 3468|      3|    return (TIFFReadDirEntryErrOk);
 3469|      3|}
tif_dirread.c:TIFFReadDirEntryData:
 3990|    180|{
 3991|    180|    assert(size > 0);
  ------------------
  |  Branch (3991:5): [True: 0, False: 180]
  |  Branch (3991:5): [True: 180, False: 0]
  ------------------
 3992|    180|    if (!isMapped(tif))
  ------------------
  |  |  279|    180|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|    180|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (3992:9): [True: 180, False: 0]
  ------------------
 3993|    180|    {
 3994|    180|        if (!SeekOK(tif, offset))
  ------------------
  |  |  303|    180|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (3994:13): [True: 3, False: 177]
  ------------------
 3995|      3|            return (TIFFReadDirEntryErrIo);
 3996|    177|        if (!ReadOK(tif, dest, size))
  ------------------
  |  |  300|    177|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    177|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (3996:13): [True: 0, False: 177]
  ------------------
 3997|      0|            return (TIFFReadDirEntryErrIo);
 3998|    177|    }
 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|    177|    return (TIFFReadDirEntryErrOk);
 4013|    180|}
tif_dirread.c:TIFFReadDirEntryCheckedSlong8:
 3473|      5|{
 3474|      5|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|      5|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3474:9): [True: 5, False: 0]
  ------------------
 3475|      5|    {
 3476|      5|        enum TIFFReadDirEntryErr err;
 3477|      5|        uint32_t offset = direntry->tdir_offset.toff_long;
 3478|      5|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      5|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3478:13): [True: 0, False: 5]
  ------------------
 3479|      0|            TIFFSwabLong(&offset);
 3480|      5|        err = TIFFReadDirEntryData(tif, offset, 8, value);
 3481|      5|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3481:13): [True: 0, False: 5]
  ------------------
 3482|      0|            return (err);
 3483|      5|    }
 3484|      0|    else
 3485|      0|        *value = *(int64_t *)(&direntry->tdir_offset);
 3486|      5|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      5|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3486:9): [True: 0, False: 5]
  ------------------
 3487|      0|        TIFFSwabLong8((uint64_t *)value);
 3488|      5|    return (TIFFReadDirEntryErrOk);
 3489|      5|}
tif_dirread.c:TIFFReadDirEntryPersampleShort:
 3348|      7|{
 3349|      7|    enum TIFFReadDirEntryErr err;
 3350|      7|    uint16_t *m;
 3351|      7|    uint16_t *na;
 3352|      7|    uint16_t nb;
 3353|      7|    if (direntry->tdir_count != (uint64_t)tif->tif_dir.td_samplesperpixel)
  ------------------
  |  Branch (3353:9): [True: 7, False: 0]
  ------------------
 3354|      7|    {
 3355|      7|        const TIFFField *fip = TIFFFieldWithTag(tif, direntry->tdir_tag);
 3356|      7|        if (direntry->tdir_count == 0)
  ------------------
  |  Branch (3356:13): [True: 0, False: 7]
  ------------------
 3357|      0|        {
 3358|      0|            return TIFFReadDirEntryErrCount;
 3359|      0|        }
 3360|      7|        else if (direntry->tdir_count <
  ------------------
  |  Branch (3360:18): [True: 0, False: 7]
  ------------------
 3361|      7|                 (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|      7|        else
 3372|      7|        {
 3373|      7|            TIFFWarningExtR(tif, "TIFFReadDirEntryPersampleShort",
 3374|      7|                            "Tag %s entry count is %" PRIu64
 3375|      7|                            " , whereas it should be SamplesPerPixel=%d. "
 3376|      7|                            "Ignoring extra entries",
 3377|      7|                            fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (3377:29): [True: 7, False: 0]
  ------------------
 3378|      7|                            direntry->tdir_count,
 3379|      7|                            tif->tif_dir.td_samplesperpixel);
 3380|      7|        }
 3381|      7|    }
 3382|      7|    err = TIFFReadDirEntryShortArray(tif, direntry, &m);
 3383|      7|    if (err != TIFFReadDirEntryErrOk || m == NULL)
  ------------------
  |  Branch (3383:9): [True: 6, False: 1]
  |  Branch (3383:41): [True: 0, False: 1]
  ------------------
 3384|      6|        return (err);
 3385|      1|    na = m;
 3386|      1|    nb = tif->tif_dir.td_samplesperpixel;
 3387|      1|    if (direntry->tdir_count < nb)
  ------------------
  |  Branch (3387:9): [True: 0, False: 1]
  ------------------
 3388|      0|        nb = (uint16_t)direntry->tdir_count;
 3389|      1|    *value = *na++;
 3390|      1|    nb--;
 3391|      1|    while (nb > 0)
  ------------------
  |  Branch (3391:12): [True: 0, False: 1]
  ------------------
 3392|      0|    {
 3393|      0|        if (*na++ != *value)
  ------------------
  |  Branch (3393:13): [True: 0, False: 0]
  ------------------
 3394|      0|        {
 3395|      0|            err = TIFFReadDirEntryErrPsdif;
 3396|      0|            break;
 3397|      0|        }
 3398|      0|        nb--;
 3399|      0|    }
 3400|      1|    _TIFFfreeExt(tif, m);
 3401|      1|    return (err);
 3402|      7|}
tif_dirread.c:TIFFReadDirEntryOutputErr:
 4018|  2.64k|{
 4019|  2.64k|    if (!recover)
  ------------------
  |  Branch (4019:9): [True: 60, False: 2.58k]
  ------------------
 4020|     60|    {
 4021|     60|        switch (err)
 4022|     60|        {
 4023|     14|            case TIFFReadDirEntryErrCount:
  ------------------
  |  Branch (4023:13): [True: 14, False: 46]
  ------------------
 4024|     14|                TIFFErrorExtR(tif, module, "Incorrect count for \"%s\"",
 4025|     14|                              tagname);
 4026|     14|                break;
 4027|      5|            case TIFFReadDirEntryErrType:
  ------------------
  |  Branch (4027:13): [True: 5, False: 55]
  ------------------
 4028|      5|                TIFFErrorExtR(tif, module, "Incompatible type for \"%s\"",
 4029|      5|                              tagname);
 4030|      5|                break;
 4031|     37|            case TIFFReadDirEntryErrIo:
  ------------------
  |  Branch (4031:13): [True: 37, False: 23]
  ------------------
 4032|     37|                TIFFErrorExtR(tif, module, "IO error during reading of \"%s\"",
 4033|     37|                              tagname);
 4034|     37|                break;
 4035|      1|            case TIFFReadDirEntryErrRange:
  ------------------
  |  Branch (4035:13): [True: 1, False: 59]
  ------------------
 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: 60]
  ------------------
 4040|      0|                TIFFErrorExtR(
 4041|      0|                    tif, module,
 4042|      0|                    "Cannot handle different values per sample for \"%s\"",
 4043|      0|                    tagname);
 4044|      0|                break;
 4045|      2|            case TIFFReadDirEntryErrSizesan:
  ------------------
  |  Branch (4045:13): [True: 2, False: 58]
  ------------------
 4046|      2|                TIFFErrorExtR(tif, module,
 4047|      2|                              "Sanity check on size of \"%s\" value failed",
 4048|      2|                              tagname);
 4049|      2|                break;
 4050|      1|            case TIFFReadDirEntryErrAlloc:
  ------------------
  |  Branch (4050:13): [True: 1, False: 59]
  ------------------
 4051|      1|                TIFFErrorExtR(tif, module, "Out of memory reading of \"%s\"",
 4052|      1|                              tagname);
 4053|      1|                break;
 4054|      0|            case TIFFReadDirEntryErrOk:
  ------------------
  |  Branch (4054:13): [True: 0, False: 60]
  ------------------
 4055|      0|            default:
  ------------------
  |  Branch (4055:13): [True: 0, False: 60]
  ------------------
 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|     60|        }
 4059|     60|    }
 4060|  2.58k|    else
 4061|  2.58k|    {
 4062|  2.58k|        switch (err)
 4063|  2.58k|        {
 4064|  1.11k|            case TIFFReadDirEntryErrCount:
  ------------------
  |  Branch (4064:13): [True: 1.11k, False: 1.46k]
  ------------------
 4065|  1.11k|                TIFFWarningExtR(tif, module,
 4066|  1.11k|                                "Incorrect count for \"%s\"; tag ignored",
 4067|  1.11k|                                tagname);
 4068|  1.11k|                break;
 4069|    127|            case TIFFReadDirEntryErrType:
  ------------------
  |  Branch (4069:13): [True: 127, False: 2.45k]
  ------------------
 4070|    127|                TIFFWarningExtR(tif, module,
 4071|    127|                                "Incompatible type for \"%s\"; tag ignored",
 4072|    127|                                tagname);
 4073|    127|                break;
 4074|    192|            case TIFFReadDirEntryErrIo:
  ------------------
  |  Branch (4074:13): [True: 192, False: 2.38k]
  ------------------
 4075|    192|                TIFFWarningExtR(
 4076|    192|                    tif, module,
 4077|    192|                    "IO error during reading of \"%s\"; tag ignored", tagname);
 4078|    192|                break;
 4079|    105|            case TIFFReadDirEntryErrRange:
  ------------------
  |  Branch (4079:13): [True: 105, False: 2.47k]
  ------------------
 4080|    105|                TIFFWarningExtR(tif, module,
 4081|    105|                                "Incorrect value for \"%s\"; tag ignored",
 4082|    105|                                tagname);
 4083|    105|                break;
 4084|      0|            case TIFFReadDirEntryErrPsdif:
  ------------------
  |  Branch (4084:13): [True: 0, False: 2.58k]
  ------------------
 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|    481|            case TIFFReadDirEntryErrSizesan:
  ------------------
  |  Branch (4090:13): [True: 481, False: 2.09k]
  ------------------
 4091|    481|                TIFFWarningExtR(
 4092|    481|                    tif, module,
 4093|    481|                    "Sanity check on size of \"%s\" value failed; tag ignored",
 4094|    481|                    tagname);
 4095|    481|                break;
 4096|    562|            case TIFFReadDirEntryErrAlloc:
  ------------------
  |  Branch (4096:13): [True: 562, False: 2.01k]
  ------------------
 4097|    562|                TIFFWarningExtR(tif, module,
 4098|    562|                                "Out of memory reading of \"%s\"; tag ignored",
 4099|    562|                                tagname);
 4100|    562|                break;
 4101|      0|            case TIFFReadDirEntryErrOk:
  ------------------
  |  Branch (4101:13): [True: 0, False: 2.58k]
  ------------------
 4102|      0|            default:
  ------------------
  |  Branch (4102:13): [True: 0, False: 2.58k]
  ------------------
 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|  2.58k|        }
 4106|  2.58k|    }
 4107|  2.64k|}
tif_dirread.c:EvaluateIFDdatasizeReading:
 4186|  4.13k|{
 4187|  4.13k|    const uint64_t data_width =
 4188|  4.13k|        (uint64_t)TIFFDataWidth((TIFFDataType)dp->tdir_type);
 4189|  4.13k|    if (data_width != 0 && dp->tdir_count > UINT64_MAX / data_width)
  ------------------
  |  Branch (4189:9): [True: 4.12k, False: 5]
  |  Branch (4189:28): [True: 0, False: 4.12k]
  ------------------
 4190|      0|    {
 4191|      0|        TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
 4192|      0|                      "Too large IFD data size");
 4193|      0|        return false;
 4194|      0|    }
 4195|  4.13k|    const uint64_t datalength = dp->tdir_count * data_width;
 4196|  4.13k|    if (datalength > ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
  ------------------
  |  |  140|  4.13k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4196:9): [True: 1.55k, False: 2.57k]
  |  Branch (4196:23): [True: 13, False: 4.11k]
  ------------------
 4197|  1.55k|    {
 4198|  1.55k|        if (tif->tif_dir.td_dirdatasize_read > UINT64_MAX - datalength)
  ------------------
  |  Branch (4198:13): [True: 0, False: 1.55k]
  ------------------
 4199|      0|        {
 4200|      0|            TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
 4201|      0|                          "Too large IFD data size");
 4202|      0|            return false;
 4203|      0|        }
 4204|  1.55k|        tif->tif_dir.td_dirdatasize_read += datalength;
 4205|  1.55k|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  1.55k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (4205:13): [True: 1.54k, False: 7]
  ------------------
 4206|  1.54k|        {
 4207|       |            /* The offset of TIFFDirEntry are not swapped when read in. That has
 4208|       |             * to be done when used. */
 4209|  1.54k|            uint32_t offset = dp->tdir_offset.toff_long;
 4210|  1.54k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.54k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (4210:17): [True: 1, False: 1.54k]
  ------------------
 4211|      1|                TIFFSwabLong(&offset);
 4212|  1.54k|            tif->tif_dir
 4213|  1.54k|                .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4214|  1.54k|                .offset = (uint64_t)offset;
 4215|  1.54k|        }
 4216|      7|        else
 4217|      7|        {
 4218|      7|            tif->tif_dir
 4219|      7|                .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4220|      7|                .offset = dp->tdir_offset.toff_long8;
 4221|      7|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      7|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (4221:17): [True: 0, False: 7]
  ------------------
 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|      7|        }
 4228|  1.55k|        tif->tif_dir
 4229|  1.55k|            .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
 4230|  1.55k|            .length = datalength;
 4231|  1.55k|        tif->tif_dir.td_dirdatasize_Noffsets++;
 4232|  1.55k|    }
 4233|  4.13k|    return true;
 4234|  4.13k|}
tif_dirread.c:TIFFReadDirEntryDoubleArray:
 3046|     22|{
 3047|     22|    enum TIFFReadDirEntryErr err;
 3048|     22|    uint32_t count;
 3049|     22|    void *origdata;
 3050|     22|    double *data;
 3051|     22|    switch (direntry->tdir_type)
 3052|     22|    {
 3053|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (3053:9): [True: 0, False: 22]
  ------------------
 3054|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (3054:9): [True: 0, False: 22]
  ------------------
 3055|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (3055:9): [True: 0, False: 22]
  ------------------
 3056|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (3056:9): [True: 0, False: 22]
  ------------------
 3057|      0|        case TIFF_LONG:
  ------------------
  |  Branch (3057:9): [True: 0, False: 22]
  ------------------
 3058|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (3058:9): [True: 0, False: 22]
  ------------------
 3059|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (3059:9): [True: 0, False: 22]
  ------------------
 3060|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (3060:9): [True: 0, False: 22]
  ------------------
 3061|      0|        case TIFF_RATIONAL:
  ------------------
  |  Branch (3061:9): [True: 0, False: 22]
  ------------------
 3062|      7|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (3062:9): [True: 7, False: 15]
  ------------------
 3063|      7|        case TIFF_FLOAT:
  ------------------
  |  Branch (3063:9): [True: 0, False: 22]
  ------------------
 3064|     22|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3064:9): [True: 15, False: 7]
  ------------------
 3065|     22|            break;
 3066|      0|        default:
  ------------------
  |  Branch (3066:9): [True: 0, False: 22]
  ------------------
 3067|      0|            return (TIFFReadDirEntryErrType);
 3068|     22|    }
 3069|     22|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 3070|     22|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (3070:9): [True: 10, False: 12]
  |  Branch (3070:43): [True: 5, False: 7]
  ------------------
 3071|     15|    {
 3072|     15|        *value = 0;
 3073|     15|        return (err);
 3074|     15|    }
 3075|      7|    switch (direntry->tdir_type)
 3076|      7|    {
 3077|      0|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3077:9): [True: 0, False: 7]
  ------------------
 3078|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3078:17): [True: 0, False: 0]
  ------------------
 3079|      0|                TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
 3080|      0|            TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
 3081|      0|            *value = (double *)origdata;
 3082|      0|            return (TIFFReadDirEntryErrOk);
 3083|      7|        default:
  ------------------
  |  Branch (3083:9): [True: 7, False: 0]
  ------------------
 3084|      7|            break;
 3085|      7|    }
 3086|      7|    data = (double *)_TIFFmallocExt(tif,
 3087|      7|                                    (tmsize_t)((size_t)count * sizeof(double)));
 3088|      7|    if (data == 0)
  ------------------
  |  Branch (3088:9): [True: 0, False: 7]
  ------------------
 3089|      0|    {
 3090|      0|        _TIFFfreeExt(tif, origdata);
 3091|      0|        return (TIFFReadDirEntryErrAlloc);
 3092|      0|    }
 3093|      7|    switch (direntry->tdir_type)
 3094|      7|    {
 3095|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (3095:9): [True: 0, False: 7]
  ------------------
 3096|      0|        {
 3097|      0|            uint8_t *ma;
 3098|      0|            double *mb;
 3099|      0|            uint32_t n;
 3100|      0|            ma = (uint8_t *)origdata;
 3101|      0|            mb = data;
 3102|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3102:25): [True: 0, False: 0]
  ------------------
 3103|      0|                *mb++ = (double)(*ma++);
 3104|      0|        }
 3105|      0|        break;
 3106|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (3106:9): [True: 0, False: 7]
  ------------------
 3107|      0|        {
 3108|      0|            int8_t *ma;
 3109|      0|            double *mb;
 3110|      0|            uint32_t n;
 3111|      0|            ma = (int8_t *)origdata;
 3112|      0|            mb = data;
 3113|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3113:25): [True: 0, False: 0]
  ------------------
 3114|      0|                *mb++ = (double)(*ma++);
 3115|      0|        }
 3116|      0|        break;
 3117|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (3117:9): [True: 0, False: 7]
  ------------------
 3118|      0|        {
 3119|      0|            uint16_t *ma;
 3120|      0|            double *mb;
 3121|      0|            uint32_t n;
 3122|      0|            ma = (uint16_t *)origdata;
 3123|      0|            mb = data;
 3124|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3124:25): [True: 0, False: 0]
  ------------------
 3125|      0|            {
 3126|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3126:21): [True: 0, False: 0]
  ------------------
 3127|      0|                    TIFFSwabShort(ma);
 3128|      0|                *mb++ = (double)(*ma++);
 3129|      0|            }
 3130|      0|        }
 3131|      0|        break;
 3132|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (3132:9): [True: 0, False: 7]
  ------------------
 3133|      0|        {
 3134|      0|            int16_t *ma;
 3135|      0|            double *mb;
 3136|      0|            uint32_t n;
 3137|      0|            ma = (int16_t *)origdata;
 3138|      0|            mb = data;
 3139|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3139:25): [True: 0, False: 0]
  ------------------
 3140|      0|            {
 3141|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3141:21): [True: 0, False: 0]
  ------------------
 3142|      0|                    TIFFSwabShort((uint16_t *)ma);
 3143|      0|                *mb++ = (double)(*ma++);
 3144|      0|            }
 3145|      0|        }
 3146|      0|        break;
 3147|      0|        case TIFF_LONG:
  ------------------
  |  Branch (3147:9): [True: 0, False: 7]
  ------------------
 3148|      0|        {
 3149|      0|            uint32_t *ma;
 3150|      0|            double *mb;
 3151|      0|            uint32_t n;
 3152|      0|            ma = (uint32_t *)origdata;
 3153|      0|            mb = data;
 3154|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3154:25): [True: 0, False: 0]
  ------------------
 3155|      0|            {
 3156|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3156:21): [True: 0, False: 0]
  ------------------
 3157|      0|                    TIFFSwabLong(ma);
 3158|      0|                *mb++ = (double)(*ma++);
 3159|      0|            }
 3160|      0|        }
 3161|      0|        break;
 3162|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (3162:9): [True: 0, False: 7]
  ------------------
 3163|      0|        {
 3164|      0|            int32_t *ma;
 3165|      0|            double *mb;
 3166|      0|            uint32_t n;
 3167|      0|            ma = (int32_t *)origdata;
 3168|      0|            mb = data;
 3169|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3169:25): [True: 0, False: 0]
  ------------------
 3170|      0|            {
 3171|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3171:21): [True: 0, False: 0]
  ------------------
 3172|      0|                    TIFFSwabLong((uint32_t *)ma);
 3173|      0|                *mb++ = (double)(*ma++);
 3174|      0|            }
 3175|      0|        }
 3176|      0|        break;
 3177|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (3177:9): [True: 0, False: 7]
  ------------------
 3178|      0|        {
 3179|      0|            uint64_t *ma;
 3180|      0|            double *mb;
 3181|      0|            uint32_t n;
 3182|      0|            ma = (uint64_t *)origdata;
 3183|      0|            mb = data;
 3184|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3184:25): [True: 0, False: 0]
  ------------------
 3185|      0|            {
 3186|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3186:21): [True: 0, False: 0]
  ------------------
 3187|      0|                    TIFFSwabLong8(ma);
 3188|      0|                *mb++ = (double)(*ma++);
 3189|      0|            }
 3190|      0|        }
 3191|      0|        break;
 3192|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (3192:9): [True: 0, False: 7]
  ------------------
 3193|      0|        {
 3194|      0|            int64_t *ma;
 3195|      0|            double *mb;
 3196|      0|            uint32_t n;
 3197|      0|            ma = (int64_t *)origdata;
 3198|      0|            mb = data;
 3199|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3199:25): [True: 0, False: 0]
  ------------------
 3200|      0|            {
 3201|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3201:21): [True: 0, False: 0]
  ------------------
 3202|      0|                    TIFFSwabLong8((uint64_t *)ma);
 3203|      0|                *mb++ = (double)(*ma++);
 3204|      0|            }
 3205|      0|        }
 3206|      0|        break;
 3207|      0|        case TIFF_RATIONAL:
  ------------------
  |  Branch (3207:9): [True: 0, False: 7]
  ------------------
 3208|      0|        {
 3209|      0|            uint32_t *ma;
 3210|      0|            uint32_t maa;
 3211|      0|            uint32_t mab;
 3212|      0|            double *mb;
 3213|      0|            uint32_t n;
 3214|      0|            ma = (uint32_t *)origdata;
 3215|      0|            mb = data;
 3216|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3216:25): [True: 0, False: 0]
  ------------------
 3217|      0|            {
 3218|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3218:21): [True: 0, False: 0]
  ------------------
 3219|      0|                    TIFFSwabLong(ma);
 3220|      0|                maa = *ma++;
 3221|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3221:21): [True: 0, False: 0]
  ------------------
 3222|      0|                    TIFFSwabLong(ma);
 3223|      0|                mab = *ma++;
 3224|      0|                if (mab == 0)
  ------------------
  |  Branch (3224:21): [True: 0, False: 0]
  ------------------
 3225|      0|                    *mb++ = 0.0;
 3226|      0|                else
 3227|      0|                    *mb++ = (double)maa / (double)mab;
 3228|      0|            }
 3229|      0|        }
 3230|      0|        break;
 3231|      7|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (3231:9): [True: 7, False: 0]
  ------------------
 3232|      7|        {
 3233|      7|            uint32_t *ma;
 3234|      7|            int32_t maa;
 3235|      7|            uint32_t mab;
 3236|      7|            double *mb;
 3237|      7|            uint32_t n;
 3238|      7|            ma = (uint32_t *)origdata;
 3239|      7|            mb = data;
 3240|     14|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3240:25): [True: 7, False: 7]
  ------------------
 3241|      7|            {
 3242|      7|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      7|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3242:21): [True: 0, False: 7]
  ------------------
 3243|      0|                    TIFFSwabLong(ma);
 3244|      7|                maa = *(int32_t *)ma;
 3245|      7|                ma++;
 3246|      7|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      7|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3246:21): [True: 0, False: 7]
  ------------------
 3247|      0|                    TIFFSwabLong(ma);
 3248|      7|                mab = *ma++;
 3249|      7|                if (mab == 0)
  ------------------
  |  Branch (3249:21): [True: 0, False: 7]
  ------------------
 3250|      0|                    *mb++ = 0.0;
 3251|      7|                else
 3252|      7|                    *mb++ = (double)maa / (double)mab;
 3253|      7|            }
 3254|      7|        }
 3255|      7|        break;
 3256|      0|        case TIFF_FLOAT:
  ------------------
  |  Branch (3256:9): [True: 0, False: 7]
  ------------------
 3257|      0|        {
 3258|      0|            float *ma;
 3259|      0|            double *mb;
 3260|      0|            uint32_t n;
 3261|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3261:17): [True: 0, False: 0]
  ------------------
 3262|      0|                TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 3263|      0|            TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata);
 3264|      0|            ma = (float *)origdata;
 3265|      0|            mb = data;
 3266|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3266:25): [True: 0, False: 0]
  ------------------
 3267|      0|                *mb++ = (double)(*ma++);
 3268|      0|        }
 3269|      0|        break;
 3270|      0|        default:
  ------------------
  |  Branch (3270:9): [True: 0, False: 7]
  ------------------
 3271|      0|            break;
 3272|      7|    }
 3273|      7|    _TIFFfreeExt(tif, origdata);
 3274|      7|    *value = data;
 3275|      7|    return (TIFFReadDirEntryErrOk);
 3276|      7|}
tif_dirread.c:TIFFReadDirEntryArray:
 1390|  3.53k|{
 1391|  3.53k|    return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, desttypesize,
 1392|  3.53k|                                          value, ~((uint64_t)0));
 1393|  3.53k|}
tif_dirread.c:TIFFReadDirEntryArrayWithLimit:
 1263|  4.77k|{
 1264|  4.77k|    int typesize;
 1265|  4.77k|    uint32_t datasize;
 1266|  4.77k|    void *data;
 1267|  4.77k|    uint64_t target_count64;
 1268|  4.77k|    int original_datasize_clamped;
 1269|  4.77k|    typesize = TIFFDataWidth((TIFFDataType)direntry->tdir_type);
 1270|       |
 1271|  4.77k|    target_count64 =
 1272|  4.77k|        (direntry->tdir_count > maxcount) ? maxcount : direntry->tdir_count;
  ------------------
  |  Branch (1272:9): [True: 209, False: 4.56k]
  ------------------
 1273|       |
 1274|  4.77k|    if ((target_count64 == 0) || (typesize == 0))
  ------------------
  |  Branch (1274:9): [True: 492, False: 4.27k]
  |  Branch (1274:34): [True: 0, False: 4.27k]
  ------------------
 1275|    492|    {
 1276|    492|        *value = 0;
 1277|    492|        return (TIFFReadDirEntryErrOk);
 1278|    492|    }
 1279|  4.27k|    (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|  4.27k|    original_datasize_clamped =
 1285|  4.27k|        ((direntry->tdir_count > 10) ? 10 : (int)direntry->tdir_count) *
  ------------------
  |  Branch (1285:10): [True: 1.63k, False: 2.64k]
  ------------------
 1286|  4.27k|        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|  4.27k|    if ((uint64_t)(MAX_SIZE_TAG_DATA / (unsigned int)typesize) < target_count64)
  ------------------
  |  | 1257|  4.27k|#define MAX_SIZE_TAG_DATA 2147483647U
  ------------------
  |  Branch (1293:9): [True: 481, False: 3.79k]
  ------------------
 1294|    481|        return (TIFFReadDirEntryErrSizesan);
 1295|  3.79k|    if ((uint64_t)(MAX_SIZE_TAG_DATA / desttypesize) < target_count64)
  ------------------
  |  | 1257|  3.79k|#define MAX_SIZE_TAG_DATA 2147483647U
  ------------------
  |  Branch (1295:9): [True: 2, False: 3.79k]
  ------------------
 1296|      2|        return (TIFFReadDirEntryErrSizesan);
 1297|       |
 1298|  3.79k|    *count = (uint32_t)target_count64;
 1299|  3.79k|    datasize = (uint32_t)(*count) * (unsigned int)typesize;
 1300|  3.79k|    assert((tmsize_t)datasize > 0);
  ------------------
  |  Branch (1300:5): [True: 0, False: 3.79k]
  |  Branch (1300:5): [True: 3.79k, False: 0]
  ------------------
 1301|       |
 1302|  3.79k|    if (datasize > 100 * 1024 * 1024)
  ------------------
  |  Branch (1302:9): [True: 563, False: 3.23k]
  ------------------
 1303|    563|    {
 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|    563|        const uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|    563|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 1308|    563|        if (datasize > filesize)
  ------------------
  |  Branch (1308:13): [True: 563, False: 0]
  ------------------
 1309|    563|        {
 1310|    563|            TIFFWarningExtR(tif, "ReadDirEntryArray",
 1311|    563|                            "Requested memory size for tag %d (0x%x) %" PRIu32
 1312|    563|                            " is greater than filesize %" PRIu64
 1313|    563|                            ". Memory not allocated, tag not read",
 1314|    563|                            direntry->tdir_tag, direntry->tdir_tag, datasize,
 1315|    563|                            filesize);
 1316|    563|            return (TIFFReadDirEntryErrAlloc);
 1317|    563|        }
 1318|    563|    }
 1319|       |
 1320|  3.23k|    if (isMapped(tif) && datasize > (uint64_t)tif->tif_size)
  ------------------
  |  |  279|  6.46k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  3.23k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 3.23k]
  |  |  ------------------
  ------------------
  |  Branch (1320:26): [True: 0, False: 0]
  ------------------
 1321|      0|        return TIFFReadDirEntryErrIo;
 1322|       |
 1323|  3.23k|    if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) ||
  ------------------
  |  |  279|  6.46k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  3.23k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
                  if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) ||
  ------------------
  |  |  140|  3.23k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1323:9): [True: 3.23k, False: 0]
  |  Branch (1323:29): [True: 8, False: 3.22k]
  |  Branch (1323:64): [True: 1, False: 7]
  ------------------
 1324|  3.23k|                           (!(tif->tif_flags & TIFF_BIGTIFF) && datasize > 4)))
  ------------------
  |  |  140|  3.23k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1324:29): [True: 3.22k, False: 7]
  |  Branch (1324:65): [True: 1.57k, False: 1.65k]
  ------------------
 1325|  1.57k|    {
 1326|  1.57k|        data = NULL;
 1327|  1.57k|    }
 1328|  1.65k|    else
 1329|  1.65k|    {
 1330|  1.65k|        data = _TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray");
 1331|  1.65k|        if (data == 0)
  ------------------
  |  Branch (1331:13): [True: 0, False: 1.65k]
  ------------------
 1332|      0|            return (TIFFReadDirEntryErrAlloc);
 1333|  1.65k|    }
 1334|  3.23k|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  3.23k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (1334:9): [True: 3.22k, False: 8]
  ------------------
 1335|  3.22k|    {
 1336|       |        /* Only the condition on original_datasize_clamped. The second
 1337|       |         * one is implied, but Coverity Scan cannot see it. */
 1338|  3.22k|        if (original_datasize_clamped <= 4 && datasize <= 4)
  ------------------
  |  Branch (1338:13): [True: 1.60k, False: 1.62k]
  |  Branch (1338:47): [True: 1.60k, False: 0]
  ------------------
 1339|  1.60k|            _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
 1340|  1.62k|        else
 1341|  1.62k|        {
 1342|  1.62k|            enum TIFFReadDirEntryErr err;
 1343|  1.62k|            uint32_t offset = direntry->tdir_offset.toff_long;
 1344|  1.62k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.62k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1344:17): [True: 2, False: 1.61k]
  ------------------
 1345|      2|                TIFFSwabLong(&offset);
 1346|  1.62k|            if (isMapped(tif))
  ------------------
  |  |  279|  1.62k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  1.62k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 1.62k]
  |  |  ------------------
  ------------------
 1347|      0|                err = TIFFReadDirEntryData(tif, (uint64_t)offset,
 1348|      0|                                           (tmsize_t)datasize, data);
 1349|  1.62k|            else
 1350|  1.62k|                err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
 1351|  1.62k|                                                     (tmsize_t)datasize, &data);
 1352|  1.62k|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1352:17): [True: 224, False: 1.39k]
  ------------------
 1353|    224|            {
 1354|    224|                _TIFFfreeExt(tif, data);
 1355|    224|                return (err);
 1356|    224|            }
 1357|  1.62k|        }
 1358|  3.22k|    }
 1359|      8|    else
 1360|      8|    {
 1361|       |        /* See above comment for the Classic TIFF case */
 1362|      8|        if (original_datasize_clamped <= 8 && datasize <= 8)
  ------------------
  |  Branch (1362:13): [True: 5, False: 3]
  |  Branch (1362:47): [True: 5, False: 0]
  ------------------
 1363|      5|            _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
 1364|      3|        else
 1365|      3|        {
 1366|      3|            enum TIFFReadDirEntryErr err;
 1367|      3|            uint64_t offset = direntry->tdir_offset.toff_long8;
 1368|      3|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      3|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1368:17): [True: 0, False: 3]
  ------------------
 1369|      0|                TIFFSwabLong8(&offset);
 1370|      3|            if (isMapped(tif))
  ------------------
  |  |  279|      3|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|      3|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 3]
  |  |  ------------------
  ------------------
 1371|      0|                err = TIFFReadDirEntryData(tif, (uint64_t)offset,
 1372|      0|                                           (tmsize_t)datasize, data);
 1373|      3|            else
 1374|      3|                err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
 1375|      3|                                                     (tmsize_t)datasize, &data);
 1376|      3|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1376:17): [True: 2, False: 1]
  ------------------
 1377|      2|            {
 1378|      2|                _TIFFfreeExt(tif, data);
 1379|      2|                return (err);
 1380|      2|            }
 1381|      3|        }
 1382|      8|    }
 1383|  3.00k|    *value = data;
 1384|  3.00k|    return (TIFFReadDirEntryErrOk);
 1385|  3.23k|}
tif_dirread.c:TIFFReadDirEntryDataAndRealloc:
 1199|  1.62k|{
 1200|  1.62k|#if SIZEOF_SIZE_T == 8
 1201|  1.62k|    tmsize_t threshold = INITIAL_THRESHOLD;
  ------------------
  |  | 1189|  1.62k|#define INITIAL_THRESHOLD (1024 * 1024)
  ------------------
 1202|  1.62k|#endif
 1203|  1.62k|    tmsize_t already_read = 0;
 1204|       |
 1205|  1.62k|    assert(!isMapped(tif));
  ------------------
  |  Branch (1205:5): [True: 0, False: 1.62k]
  |  Branch (1205:5): [True: 1.62k, False: 0]
  ------------------
 1206|       |
 1207|  1.62k|    if (!SeekOK(tif, offset))
  ------------------
  |  |  303|  1.62k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (1207:9): [True: 217, False: 1.40k]
  ------------------
 1208|    217|        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|  2.80k|    while (already_read < size)
  ------------------
  |  Branch (1216:12): [True: 1.40k, False: 1.39k]
  ------------------
 1217|  1.40k|    {
 1218|  1.40k|        void *new_dest;
 1219|  1.40k|        tmsize_t bytes_read;
 1220|  1.40k|        tmsize_t to_read = size - already_read;
 1221|  1.40k|#if SIZEOF_SIZE_T == 8
 1222|  1.40k|        if (to_read >= threshold && threshold < MAX_THRESHOLD)
  ------------------
  |  | 1192|      8|    (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|      8|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|      8|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  | 1190|      8|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  | 1193|      8|     INITIAL_THRESHOLD)
  |  |  ------------------
  |  |  |  | 1189|      8|#define INITIAL_THRESHOLD (1024 * 1024)
  |  |  ------------------
  ------------------
  |  Branch (1222:13): [True: 8, False: 1.39k]
  |  Branch (1222:37): [True: 8, False: 0]
  ------------------
 1223|      8|        {
 1224|      8|            to_read = threshold;
 1225|      8|            threshold *= THRESHOLD_MULTIPLIER;
  ------------------
  |  | 1190|      8|#define THRESHOLD_MULTIPLIER 10
  ------------------
 1226|      8|        }
 1227|  1.40k|#endif
 1228|       |
 1229|  1.40k|        new_dest =
 1230|  1.40k|            (uint8_t *)_TIFFreallocExt(tif, *pdest, already_read + to_read);
 1231|  1.40k|        if (new_dest == NULL)
  ------------------
  |  Branch (1231:13): [True: 0, False: 1.40k]
  ------------------
 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|  1.40k|        *pdest = new_dest;
 1242|       |
 1243|  1.40k|        bytes_read = TIFFReadFile(tif, (char *)*pdest + already_read, to_read);
  ------------------
  |  |  283|  1.40k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 1244|  1.40k|        if (bytes_read < 0)
  ------------------
  |  Branch (1244:13): [True: 0, False: 1.40k]
  ------------------
 1245|      0|            return TIFFReadDirEntryErrIo;
 1246|  1.40k|        already_read += bytes_read;
 1247|  1.40k|        if (bytes_read != to_read)
  ------------------
  |  Branch (1247:13): [True: 9, False: 1.39k]
  ------------------
 1248|      9|        {
 1249|      9|            return TIFFReadDirEntryErrIo;
 1250|      9|        }
 1251|  1.40k|    }
 1252|  1.39k|    return TIFFReadDirEntryErrOk;
 1253|  1.40k|}
tif_dirread.c:TIFFReadDirEntryShortArray:
 1767|  1.24k|{
 1768|  1.24k|    enum TIFFReadDirEntryErr err;
 1769|  1.24k|    uint32_t count;
 1770|  1.24k|    void *origdata;
 1771|  1.24k|    uint16_t *data;
 1772|  1.24k|    switch (direntry->tdir_type)
 1773|  1.24k|    {
 1774|     21|        case TIFF_BYTE:
  ------------------
  |  Branch (1774:9): [True: 21, False: 1.22k]
  ------------------
 1775|     21|        case TIFF_SBYTE:
  ------------------
  |  Branch (1775:9): [True: 0, False: 1.24k]
  ------------------
 1776|  1.22k|        case TIFF_SHORT:
  ------------------
  |  Branch (1776:9): [True: 1.20k, False: 37]
  ------------------
 1777|  1.22k|        case TIFF_SSHORT:
  ------------------
  |  Branch (1777:9): [True: 0, False: 1.24k]
  ------------------
 1778|  1.23k|        case TIFF_LONG:
  ------------------
  |  Branch (1778:9): [True: 14, False: 1.22k]
  ------------------
 1779|  1.23k|        case TIFF_SLONG:
  ------------------
  |  Branch (1779:9): [True: 0, False: 1.24k]
  ------------------
 1780|  1.23k|        case TIFF_LONG8:
  ------------------
  |  Branch (1780:9): [True: 0, False: 1.24k]
  ------------------
 1781|  1.23k|        case TIFF_SLONG8:
  ------------------
  |  Branch (1781:9): [True: 0, False: 1.24k]
  ------------------
 1782|  1.23k|            break;
 1783|      2|        default:
  ------------------
  |  Branch (1783:9): [True: 2, False: 1.23k]
  ------------------
 1784|      2|            return (TIFFReadDirEntryErrType);
 1785|  1.24k|    }
 1786|  1.23k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
 1787|  1.23k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1787:9): [True: 391, False: 848]
  |  Branch (1787:43): [True: 7, False: 841]
  ------------------
 1788|    398|    {
 1789|    398|        *value = 0;
 1790|    398|        return (err);
 1791|    398|    }
 1792|    841|    switch (direntry->tdir_type)
 1793|    841|    {
 1794|    806|        case TIFF_SHORT:
  ------------------
  |  Branch (1794:9): [True: 806, False: 35]
  ------------------
 1795|    806|            *value = (uint16_t *)origdata;
 1796|    806|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    806|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1796:17): [True: 0, False: 806]
  ------------------
 1797|      0|                TIFFSwabArrayOfShort(*value, count);
 1798|    806|            return (TIFFReadDirEntryErrOk);
 1799|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (1799:9): [True: 0, False: 841]
  ------------------
 1800|      0|        {
 1801|      0|            int16_t *m;
 1802|      0|            uint32_t n;
 1803|      0|            m = (int16_t *)origdata;
 1804|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1804:25): [True: 0, False: 0]
  ------------------
 1805|      0|            {
 1806|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1806:21): [True: 0, False: 0]
  ------------------
 1807|      0|                    TIFFSwabShort((uint16_t *)m);
 1808|      0|                err = TIFFReadDirEntryCheckRangeShortSshort(*m);
 1809|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1809:21): [True: 0, False: 0]
  ------------------
 1810|      0|                {
 1811|      0|                    _TIFFfreeExt(tif, origdata);
 1812|      0|                    return (err);
 1813|      0|                }
 1814|      0|                m++;
 1815|      0|            }
 1816|      0|            *value = (uint16_t *)origdata;
 1817|      0|            return (TIFFReadDirEntryErrOk);
 1818|      0|        }
 1819|     35|        default:
  ------------------
  |  Branch (1819:9): [True: 35, False: 806]
  ------------------
 1820|     35|            break;
 1821|    841|    }
 1822|     35|    data = (uint16_t *)_TIFFCheckMalloc(tif, count, sizeof(uint16_t),
 1823|     35|                                        "TIFFReadDirEntryShortArray");
 1824|     35|    if (data == 0)
  ------------------
  |  Branch (1824:9): [True: 0, False: 35]
  ------------------
 1825|      0|    {
 1826|      0|        _TIFFfreeExt(tif, origdata);
 1827|      0|        return (TIFFReadDirEntryErrAlloc);
 1828|      0|    }
 1829|     35|    switch (direntry->tdir_type)
 1830|     35|    {
 1831|     21|        case TIFF_BYTE:
  ------------------
  |  Branch (1831:9): [True: 21, False: 14]
  ------------------
 1832|     21|        {
 1833|     21|            uint8_t *ma;
 1834|     21|            uint16_t *mb;
 1835|     21|            uint32_t n;
 1836|     21|            ma = (uint8_t *)origdata;
 1837|     21|            mb = data;
 1838|   196k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1838:25): [True: 196k, False: 21]
  ------------------
 1839|   196k|                *mb++ = (uint16_t)(*ma++);
 1840|     21|        }
 1841|     21|        break;
 1842|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (1842:9): [True: 0, False: 35]
  ------------------
 1843|      0|        {
 1844|      0|            int8_t *ma;
 1845|      0|            uint16_t *mb;
 1846|      0|            uint32_t n;
 1847|      0|            ma = (int8_t *)origdata;
 1848|      0|            mb = data;
 1849|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1849:25): [True: 0, False: 0]
  ------------------
 1850|      0|            {
 1851|      0|                err = TIFFReadDirEntryCheckRangeShortSbyte(*ma);
 1852|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1852:21): [True: 0, False: 0]
  ------------------
 1853|      0|                    break;
 1854|      0|                *mb++ = (uint16_t)(*ma++);
 1855|      0|            }
 1856|      0|        }
 1857|      0|        break;
 1858|     14|        case TIFF_LONG:
  ------------------
  |  Branch (1858:9): [True: 14, False: 21]
  ------------------
 1859|     14|        {
 1860|     14|            uint32_t *ma;
 1861|     14|            uint16_t *mb;
 1862|     14|            uint32_t n;
 1863|     14|            ma = (uint32_t *)origdata;
 1864|     14|            mb = data;
 1865|     28|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1865:25): [True: 14, False: 14]
  ------------------
 1866|     14|            {
 1867|     14|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     14|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1867:21): [True: 0, False: 14]
  ------------------
 1868|      0|                    TIFFSwabLong(ma);
 1869|     14|                err = TIFFReadDirEntryCheckRangeShortLong(*ma);
 1870|     14|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1870:21): [True: 0, False: 14]
  ------------------
 1871|      0|                    break;
 1872|     14|                *mb++ = (uint16_t)(*ma++);
 1873|     14|            }
 1874|     14|        }
 1875|     14|        break;
 1876|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (1876:9): [True: 0, False: 35]
  ------------------
 1877|      0|        {
 1878|      0|            int32_t *ma;
 1879|      0|            uint16_t *mb;
 1880|      0|            uint32_t n;
 1881|      0|            ma = (int32_t *)origdata;
 1882|      0|            mb = data;
 1883|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1883:25): [True: 0, False: 0]
  ------------------
 1884|      0|            {
 1885|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1885:21): [True: 0, False: 0]
  ------------------
 1886|      0|                    TIFFSwabLong((uint32_t *)ma);
 1887|      0|                err = TIFFReadDirEntryCheckRangeShortSlong(*ma);
 1888|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1888:21): [True: 0, False: 0]
  ------------------
 1889|      0|                    break;
 1890|      0|                *mb++ = (uint16_t)(*ma++);
 1891|      0|            }
 1892|      0|        }
 1893|      0|        break;
 1894|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (1894:9): [True: 0, False: 35]
  ------------------
 1895|      0|        {
 1896|      0|            uint64_t *ma;
 1897|      0|            uint16_t *mb;
 1898|      0|            uint32_t n;
 1899|      0|            ma = (uint64_t *)origdata;
 1900|      0|            mb = data;
 1901|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1901:25): [True: 0, False: 0]
  ------------------
 1902|      0|            {
 1903|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1903:21): [True: 0, False: 0]
  ------------------
 1904|      0|                    TIFFSwabLong8(ma);
 1905|      0|                err = TIFFReadDirEntryCheckRangeShortLong8(*ma);
 1906|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1906:21): [True: 0, False: 0]
  ------------------
 1907|      0|                    break;
 1908|      0|                *mb++ = (uint16_t)(*ma++);
 1909|      0|            }
 1910|      0|        }
 1911|      0|        break;
 1912|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (1912:9): [True: 0, False: 35]
  ------------------
 1913|      0|        {
 1914|      0|            int64_t *ma;
 1915|      0|            uint16_t *mb;
 1916|      0|            uint32_t n;
 1917|      0|            ma = (int64_t *)origdata;
 1918|      0|            mb = data;
 1919|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1919:25): [True: 0, False: 0]
  ------------------
 1920|      0|            {
 1921|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1921:21): [True: 0, False: 0]
  ------------------
 1922|      0|                    TIFFSwabLong8((uint64_t *)ma);
 1923|      0|                err = TIFFReadDirEntryCheckRangeShortSlong8(*ma);
 1924|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1924:21): [True: 0, False: 0]
  ------------------
 1925|      0|                    break;
 1926|      0|                *mb++ = (uint16_t)(*ma++);
 1927|      0|            }
 1928|      0|        }
 1929|      0|        break;
 1930|      0|        default:
  ------------------
  |  Branch (1930:9): [True: 0, False: 35]
  ------------------
 1931|      0|            break;
 1932|     35|    }
 1933|     35|    _TIFFfreeExt(tif, origdata);
 1934|     35|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1934:9): [True: 0, False: 35]
  ------------------
 1935|      0|    {
 1936|      0|        _TIFFfreeExt(tif, data);
 1937|      0|        return (err);
 1938|      0|    }
 1939|     35|    *value = data;
 1940|     35|    return (TIFFReadDirEntryErrOk);
 1941|     35|}
tif_dirread.c:CalcFinalIFDdatasizeReading:
 4260|    666|{
 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|    666|    if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (4264:9): [True: 666, False: 0]
  ------------------
 4265|    666|        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|    621|{
 4116|    621|    switch (photometric)
 4117|    621|    {
 4118|     70|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|     70|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (4118:9): [True: 70, False: 551]
  ------------------
 4119|    186|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    186|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (4119:9): [True: 116, False: 505]
  ------------------
 4120|    193|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    193|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (4120:9): [True: 7, False: 614]
  ------------------
 4121|    193|            return 1;
 4122|    411|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    411|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (4122:9): [True: 411, False: 210]
  ------------------
 4123|    411|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|    411|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (4123:9): [True: 0, False: 621]
  ------------------
 4124|    425|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|    425|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (4124:9): [True: 14, False: 607]
  ------------------
 4125|    426|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|    426|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (4125:9): [True: 1, False: 620]
  ------------------
 4126|    426|        case PHOTOMETRIC_ITULAB:
  ------------------
  |  |  230|    426|#define PHOTOMETRIC_ITULAB 10              /* ITU L*a*b* */
  ------------------
  |  Branch (4126:9): [True: 0, False: 621]
  ------------------
 4127|    426|        case PHOTOMETRIC_ICCLAB:
  ------------------
  |  |  229|    426|#define PHOTOMETRIC_ICCLAB 9               /* ICC L*a*b* [Adobe TIFF Technote 4] */
  ------------------
  |  Branch (4127:9): [True: 0, False: 621]
  ------------------
 4128|    426|            return 3;
 4129|      1|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      1|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (4129:9): [True: 1, False: 620]
  ------------------
 4130|      1|        case PHOTOMETRIC_MASK:
  ------------------
  |  |  225|      1|#define PHOTOMETRIC_MASK 4                 /* $holdout mask */
  ------------------
  |  Branch (4130:9): [True: 0, False: 621]
  ------------------
 4131|      1|            return 4;
 4132|      0|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|      0|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (4132:9): [True: 0, False: 621]
  ------------------
 4133|      0|        case PHOTOMETRIC_CFA:
  ------------------
  |  |  231|      0|#define PHOTOMETRIC_CFA 32803              /* color filter array */
  ------------------
  |  Branch (4133:9): [True: 0, False: 621]
  ------------------
 4134|      1|        default:
  ------------------
  |  Branch (4134:9): [True: 1, False: 620]
  ------------------
 4135|      1|            return 0;
 4136|    621|    }
 4137|    621|}
tif_dirread.c:ByteCountLooksBad:
 4140|    129|{
 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|    129|    uint64_t bytecount = TIFFGetStrileByteCount(tif, 0);
 4155|    129|    uint64_t offset = TIFFGetStrileOffset(tif, 0);
 4156|    129|    uint64_t filesize;
 4157|       |
 4158|    129|    if (offset == 0)
  ------------------
  |  Branch (4158:9): [True: 0, False: 129]
  ------------------
 4159|      0|        return 0;
 4160|    129|    if (bytecount == 0)
  ------------------
  |  Branch (4160:9): [True: 6, False: 123]
  ------------------
 4161|      6|        return 1;
 4162|    123|    if (tif->tif_dir.td_compression != COMPRESSION_NONE)
  ------------------
  |  |  182|    123|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (4162:9): [True: 121, False: 2]
  ------------------
 4163|    121|        return 0;
 4164|      2|    filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      2|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 4165|      2|    if (offset <= filesize && bytecount > filesize - offset)
  ------------------
  |  Branch (4165:9): [True: 1, False: 1]
  |  Branch (4165:31): [True: 1, False: 0]
  ------------------
 4166|      1|        return 1;
 4167|      1|    if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (4167:9): [True: 1, False: 0]
  ------------------
 4168|      1|    {
 4169|      1|        uint64_t scanlinesize = TIFFScanlineSize64(tif);
 4170|      1|        if (tif->tif_dir.td_imagelength > 0 &&
  ------------------
  |  Branch (4170:13): [True: 1, False: 0]
  ------------------
 4171|      1|            scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength)
  ------------------
  |  Branch (4171:13): [True: 0, False: 1]
  ------------------
 4172|      0|        {
 4173|      0|            return 1;
 4174|      0|        }
 4175|      1|        if (bytecount < scanlinesize * tif->tif_dir.td_imagelength)
  ------------------
  |  Branch (4175:13): [True: 0, False: 1]
  ------------------
 4176|      0|            return 1;
 4177|      1|    }
 4178|      1|    return 0;
 4179|      1|}
tif_dirread.c:TIFFReadDirectoryCheckOrder:
 5311|    690|{
 5312|    690|    static const char module[] = "TIFFReadDirectoryCheckOrder";
 5313|    690|    uint32_t m;
 5314|    690|    uint16_t n;
 5315|    690|    TIFFDirEntry *o;
 5316|    690|    m = 0;
 5317|  3.13k|    for (n = 0, o = dir; n < dircount; n++, o++)
  ------------------
  |  Branch (5317:26): [True: 3.13k, False: 0]
  ------------------
 5318|  3.13k|    {
 5319|  3.13k|        if (o->tdir_tag < m)
  ------------------
  |  Branch (5319:13): [True: 690, False: 2.44k]
  ------------------
 5320|    690|        {
 5321|    690|            TIFFWarningExtR(tif, module,
 5322|    690|                            "Invalid TIFF directory; tags are not sorted in "
 5323|    690|                            "ascending order");
 5324|    690|            break;
 5325|    690|        }
 5326|  2.44k|        m = o->tdir_tag + 1U;
 5327|  2.44k|    }
 5328|    690|}
tif_dirread.c:TIFFReadDirectoryFindEntry:
 5333|  1.44k|{
 5334|  1.44k|    TIFFDirEntry *m;
 5335|  1.44k|    uint16_t n;
 5336|  1.44k|    (void)tif;
 5337|  54.7k|    for (m = dir, n = 0; n < dircount; m++, n++)
  ------------------
  |  Branch (5337:26): [True: 54.6k, False: 139]
  ------------------
 5338|  54.6k|    {
 5339|  54.6k|        if (m->tdir_tag == tagid)
  ------------------
  |  Branch (5339:13): [True: 1.30k, False: 53.3k]
  ------------------
 5340|  1.30k|            return (m);
 5341|  54.6k|    }
 5342|    139|    return (0);
 5343|  1.44k|}
tif_dirread.c:TIFFReadDirectoryFindFieldInfo:
 5347|   101k|{
 5348|   101k|    int32_t ma, mb, mc;
 5349|   101k|    ma = -1;
 5350|   101k|    mc = (int32_t)tif->tif_nfields;
 5351|   788k|    while (1)
  ------------------
  |  Branch (5351:12): [True: 788k, Folded]
  ------------------
 5352|   788k|    {
 5353|   788k|        if (ma + 1 == mc)
  ------------------
  |  Branch (5353:13): [True: 30.3k, False: 757k]
  ------------------
 5354|  30.3k|        {
 5355|  30.3k|            *fii = FAILED_FII;
  ------------------
  |  |   44|  30.3k|#define FAILED_FII ((uint32_t)-1)
  ------------------
 5356|  30.3k|            return;
 5357|  30.3k|        }
 5358|   757k|        mb = (ma + mc) / 2;
 5359|   757k|        if (tif->tif_fields[mb]->field_tag == (uint32_t)tagid)
  ------------------
  |  Branch (5359:13): [True: 71.1k, False: 686k]
  ------------------
 5360|  71.1k|            break;
 5361|   686k|        if (tif->tif_fields[mb]->field_tag < (uint32_t)tagid)
  ------------------
  |  Branch (5361:13): [True: 352k, False: 334k]
  ------------------
 5362|   352k|            ma = mb;
 5363|   334k|        else
 5364|   334k|            mc = mb;
 5365|   686k|    }
 5366|  71.1k|    while (1)
  ------------------
  |  Branch (5366:12): [True: 71.1k, Folded]
  ------------------
 5367|  71.1k|    {
 5368|  71.1k|        if (mb == 0)
  ------------------
  |  Branch (5368:13): [True: 1.37k, False: 69.7k]
  ------------------
 5369|  1.37k|            break;
 5370|  69.7k|        if (tif->tif_fields[mb - 1]->field_tag != (uint32_t)tagid)
  ------------------
  |  Branch (5370:13): [True: 69.7k, False: 0]
  ------------------
 5371|  69.7k|            break;
 5372|      0|        mb--;
 5373|      0|    }
 5374|  71.1k|    *fii = (uint32_t)mb;
 5375|  71.1k|}
tif_dirread.c:EstimateStripByteCounts:
 5582|    345|{
 5583|    345|    static const char module[] = "EstimateStripByteCounts";
 5584|       |
 5585|    345|    TIFFDirEntry *dp;
 5586|    345|    TIFFDirectory *td = &tif->tif_dir;
 5587|    345|    uint32_t strip;
 5588|       |
 5589|       |    /* Do not try to load stripbytecount as we will compute it */
 5590|    345|    if (!_TIFFFillStrilesInternal(tif, 0))
  ------------------
  |  Branch (5590:9): [True: 0, False: 345]
  ------------------
 5591|      0|        return -1;
 5592|       |
 5593|    345|    const uint64_t allocsize = (uint64_t)td->td_nstrips * sizeof(uint64_t);
 5594|    345|    uint64_t filesize = 0;
 5595|    345|    if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (5595:9): [True: 0, False: 345]
  ------------------
 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|    345|    if (td->td_stripbytecount_p)
  ------------------
  |  Branch (5611:9): [True: 7, False: 338]
  ------------------
 5612|      7|        _TIFFfreeExt(tif, td->td_stripbytecount_p);
 5613|    345|    td->td_stripbytecount_p = (uint64_t *)_TIFFCheckMalloc(
 5614|    345|        tif, td->td_nstrips, sizeof(uint64_t), "for \"StripByteCounts\" array");
 5615|    345|    if (td->td_stripbytecount_p == NULL)
  ------------------
  |  Branch (5615:9): [True: 0, False: 345]
  ------------------
 5616|      0|        return -1;
 5617|       |
 5618|    345|    if (td->td_compression != COMPRESSION_NONE)
  ------------------
  |  |  182|    345|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (5618:9): [True: 336, False: 9]
  ------------------
 5619|    336|    {
 5620|    336|        uint64_t space;
 5621|    336|        uint16_t n;
 5622|    336|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    336|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (5622:13): [True: 336, False: 0]
  ------------------
 5623|    336|            space = sizeof(TIFFHeaderClassic) + 2 +
 5624|    336|                    (unsigned long)dircount * 12 + 4;
 5625|      0|        else
 5626|      0|            space =
 5627|      0|                sizeof(TIFFHeaderBig) + 8 + (unsigned long)dircount * 20 + 8;
 5628|       |        /* calculate amount of space used by indirect values */
 5629|  6.12k|        for (dp = dir, n = dircount; n > 0; n--, dp++)
  ------------------
  |  Branch (5629:38): [True: 5.80k, False: 318]
  ------------------
 5630|  5.80k|        {
 5631|  5.80k|            uint32_t typewidth;
 5632|  5.80k|            uint64_t datasize;
 5633|  5.80k|            typewidth = (uint32_t)TIFFDataWidth((TIFFDataType)dp->tdir_type);
 5634|  5.80k|            if (typewidth == 0)
  ------------------
  |  Branch (5634:17): [True: 18, False: 5.78k]
  ------------------
 5635|     18|            {
 5636|     18|                TIFFErrorExtR(
 5637|     18|                    tif, module,
 5638|     18|                    "Cannot determine size of unknown tag type %" PRIu16,
 5639|     18|                    dp->tdir_type);
 5640|     18|                return -1;
 5641|     18|            }
 5642|  5.78k|            if (dp->tdir_count > UINT64_MAX / typewidth)
  ------------------
  |  Branch (5642:17): [True: 0, False: 5.78k]
  ------------------
 5643|      0|                return -1;
 5644|  5.78k|            datasize = (uint64_t)typewidth * dp->tdir_count;
 5645|  5.78k|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  5.78k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (5645:17): [True: 5.78k, False: 0]
  ------------------
 5646|  5.78k|            {
 5647|  5.78k|                if (datasize <= 4)
  ------------------
  |  Branch (5647:21): [True: 4.10k, False: 1.67k]
  ------------------
 5648|  4.10k|                    datasize = 0;
 5649|  5.78k|            }
 5650|      0|            else
 5651|      0|            {
 5652|      0|                if (datasize <= 8)
  ------------------
  |  Branch (5652:21): [True: 0, False: 0]
  ------------------
 5653|      0|                    datasize = 0;
 5654|      0|            }
 5655|  5.78k|            if (space > UINT64_MAX - datasize)
  ------------------
  |  Branch (5655:17): [True: 0, False: 5.78k]
  ------------------
 5656|      0|                return -1;
 5657|  5.78k|            space += datasize;
 5658|  5.78k|        }
 5659|    318|        if (filesize == 0)
  ------------------
  |  Branch (5659:13): [True: 318, False: 0]
  ------------------
 5660|    318|            filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|    318|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 5661|    318|        if (filesize < space)
  ------------------
  |  Branch (5661:13): [True: 281, False: 37]
  ------------------
 5662|       |            /* we should perhaps return in error ? */
 5663|    281|            space = filesize;
 5664|     37|        else
 5665|     37|            space = filesize - space;
 5666|    318|        if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    318|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (5666:13): [True: 0, False: 318]
  ------------------
 5667|      0|            space /= td->td_samplesperpixel;
 5668|    636|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5668:25): [True: 318, False: 318]
  ------------------
 5669|    318|            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|    318|        strip--;
 5678|    318|        if (td->td_stripoffset_p[strip] >
  ------------------
  |  Branch (5678:13): [True: 0, False: 318]
  ------------------
 5679|    318|            UINT64_MAX - td->td_stripbytecount_p[strip])
 5680|      0|            return -1;
 5681|    318|        if (td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip] >
  ------------------
  |  Branch (5681:13): [True: 281, False: 37]
  ------------------
 5682|    318|            filesize)
 5683|    281|        {
 5684|    281|            if (td->td_stripoffset_p[strip] >= filesize)
  ------------------
  |  Branch (5684:17): [True: 3, False: 278]
  ------------------
 5685|      3|            {
 5686|       |                /* Not sure what we should in that case... */
 5687|      3|                td->td_stripbytecount_p[strip] = 0;
 5688|      3|            }
 5689|    278|            else
 5690|    278|            {
 5691|    278|                td->td_stripbytecount_p[strip] =
 5692|    278|                    filesize - td->td_stripoffset_p[strip];
 5693|    278|            }
 5694|    281|        }
 5695|    318|    }
 5696|      9|    else if (isTiled(tif))
  ------------------
  |  |  278|      9|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      9|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 9]
  |  |  ------------------
  ------------------
 5697|      0|    {
 5698|      0|        uint64_t bytespertile = TIFFTileSize64(tif);
 5699|       |
 5700|      0|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5700:25): [True: 0, False: 0]
  ------------------
 5701|      0|            td->td_stripbytecount_p[strip] = bytespertile;
 5702|      0|    }
 5703|      9|    else
 5704|      9|    {
 5705|      9|        uint64_t rowbytes = TIFFScanlineSize64(tif);
 5706|      9|        uint32_t rowsperstrip = td->td_imagelength / td->td_stripsperimage;
 5707|     18|        for (strip = 0; strip < td->td_nstrips; strip++)
  ------------------
  |  Branch (5707:25): [True: 9, False: 9]
  ------------------
 5708|      9|        {
 5709|      9|            if (rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes)
  ------------------
  |  Branch (5709:17): [True: 7, False: 2]
  |  Branch (5709:33): [True: 0, False: 7]
  ------------------
 5710|      0|                return -1;
 5711|      9|            td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip;
 5712|      9|        }
 5713|      9|    }
 5714|    327|    TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
  ------------------
  |  |  249|    327|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|    327|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|    327|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 5715|    327|    if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
  ------------------
  |  |  248|    327|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    327|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    327|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  |  Branch (5715:9): [True: 226, False: 101]
  ------------------
 5716|    226|        td->td_rowsperstrip = td->td_imagelength;
 5717|    327|    return 1;
 5718|    345|}
tif_dirread.c:MissingRequired:
 5721|      6|{
 5722|      6|    static const char module[] = "MissingRequired";
 5723|       |
 5724|      6|    TIFFErrorExtR(tif, module,
 5725|      6|                  "TIFF directory is missing required \"%s\" field", tagname);
 5726|      6|}
tif_dirread.c:hashFuncOffsetToNumber:
 5729|  2.88k|{
 5730|  2.88k|    const TIFFOffsetAndDirNumber *offsetAndDirNumber =
 5731|  2.88k|        (const TIFFOffsetAndDirNumber *)elt;
 5732|  2.88k|    const uint32_t hash = (uint32_t)(offsetAndDirNumber->offset >> 32) ^
 5733|  2.88k|                          ((uint32_t)offsetAndDirNumber->offset & 0xFFFFFFFFU);
 5734|  2.88k|    return hash;
 5735|  2.88k|}
tif_dirread.c:equalFuncOffsetToNumber:
 5738|     16|{
 5739|     16|    const TIFFOffsetAndDirNumber *offsetAndDirNumber1 =
 5740|     16|        (const TIFFOffsetAndDirNumber *)elt1;
 5741|     16|    const TIFFOffsetAndDirNumber *offsetAndDirNumber2 =
 5742|     16|        (const TIFFOffsetAndDirNumber *)elt2;
 5743|     16|    return offsetAndDirNumber1->offset == offsetAndDirNumber2->offset;
 5744|     16|}
tif_dirread.c:hashFuncNumberToOffset:
 5747|  2.88k|{
 5748|  2.88k|    const TIFFOffsetAndDirNumber *offsetAndDirNumber =
 5749|  2.88k|        (const TIFFOffsetAndDirNumber *)elt;
 5750|  2.88k|    return offsetAndDirNumber->dirNumber;
 5751|  2.88k|}
tif_dirread.c:TIFFFetchDirectory:
 6087|    961|{
 6088|    961|    static const char module[] = "TIFFFetchDirectory";
 6089|       |
 6090|    961|    void *origdir;
 6091|    961|    uint16_t dircount16;
 6092|    961|    uint32_t dirsize;
 6093|    961|    TIFFDirEntry *dir;
 6094|    961|    uint8_t *ma;
 6095|    961|    TIFFDirEntry *mb;
 6096|    961|    uint16_t n;
 6097|       |
 6098|    961|    assert(pdir);
  ------------------
  |  Branch (6098:5): [True: 0, False: 961]
  |  Branch (6098:5): [True: 961, False: 0]
  ------------------
 6099|       |
 6100|    961|    tif->tif_diroff = diroff;
 6101|    961|    if (nextdiroff)
  ------------------
  |  Branch (6101:9): [True: 961, False: 0]
  ------------------
 6102|    961|        *nextdiroff = 0;
 6103|    961|    if (!isMapped(tif))
  ------------------
  |  |  279|    961|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|    961|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (6103:9): [True: 961, False: 0]
  ------------------
 6104|    961|    {
 6105|    961|        if (!SeekOK(tif, tif->tif_diroff))
  ------------------
  |  |  303|    961|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (6105:13): [True: 237, False: 724]
  ------------------
 6106|    237|        {
 6107|    237|            TIFFErrorExtR(tif, module,
 6108|    237|                          "%s: Seek error accessing TIFF directory",
 6109|    237|                          tif->tif_name);
 6110|    237|            return 0;
 6111|    237|        }
 6112|    724|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    724|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6112:13): [True: 713, False: 11]
  ------------------
 6113|    713|        {
 6114|    713|            if (!ReadOK(tif, &dircount16, sizeof(uint16_t)))
  ------------------
  |  |  300|    713|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    713|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6114:17): [True: 0, False: 713]
  ------------------
 6115|      0|            {
 6116|      0|                TIFFErrorExtR(tif, module,
 6117|      0|                              "%s: Can not read TIFF directory count",
 6118|      0|                              tif->tif_name);
 6119|      0|                return 0;
 6120|      0|            }
 6121|    713|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    713|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6121:17): [True: 1, False: 712]
  ------------------
 6122|      1|                TIFFSwabShort(&dircount16);
 6123|    713|            if (dircount16 > 4096)
  ------------------
  |  Branch (6123:17): [True: 10, False: 703]
  ------------------
 6124|     10|            {
 6125|     10|                TIFFErrorExtR(tif, module,
 6126|     10|                              "Sanity check on directory count failed, this is "
 6127|     10|                              "probably not a valid IFD offset");
 6128|     10|                return 0;
 6129|     10|            }
 6130|    703|            dirsize = 12;
 6131|    703|        }
 6132|     11|        else
 6133|     11|        {
 6134|     11|            uint64_t dircount64;
 6135|     11|            if (!ReadOK(tif, &dircount64, sizeof(uint64_t)))
  ------------------
  |  |  300|     11|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|     11|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6135:17): [True: 0, False: 11]
  ------------------
 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|     11|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6142:17): [True: 0, False: 11]
  ------------------
 6143|      0|                TIFFSwabLong8(&dircount64);
 6144|     11|            if (dircount64 > 4096)
  ------------------
  |  Branch (6144:17): [True: 0, False: 11]
  ------------------
 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|     11|            dircount16 = (uint16_t)dircount64;
 6152|     11|            dirsize = 20;
 6153|     11|        }
 6154|    714|        origdir = _TIFFCheckMalloc(tif, dircount16, dirsize,
 6155|    714|                                   "to read TIFF directory");
 6156|    714|        if (origdir == NULL)
  ------------------
  |  Branch (6156:13): [True: 24, False: 690]
  ------------------
 6157|     24|            return 0;
 6158|    690|        if (!ReadOK(tif, origdir, (tmsize_t)dircount16 * dirsize))
  ------------------
  |  |  300|    690|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    690|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6158:13): [True: 0, False: 690]
  ------------------
 6159|      0|        {
 6160|      0|            TIFFErrorExtR(tif, module, "%.100s: Can not read TIFF directory",
 6161|      0|                          tif->tif_name);
 6162|      0|            _TIFFfreeExt(tif, origdir);
 6163|      0|            return 0;
 6164|      0|        }
 6165|       |        /*
 6166|       |         * Read offset to next directory for sequential scans if
 6167|       |         * needed.
 6168|       |         */
 6169|    690|        if (nextdiroff)
  ------------------
  |  Branch (6169:13): [True: 690, False: 0]
  ------------------
 6170|    690|        {
 6171|    690|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    690|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6171:17): [True: 679, False: 11]
  ------------------
 6172|    679|            {
 6173|    679|                uint32_t nextdiroff32;
 6174|    679|                if (!ReadOK(tif, &nextdiroff32, sizeof(uint32_t)))
  ------------------
  |  |  300|    679|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    679|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6174:21): [True: 0, False: 679]
  ------------------
 6175|      0|                    nextdiroff32 = 0;
 6176|    679|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    679|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6176:21): [True: 1, False: 678]
  ------------------
 6177|      1|                    TIFFSwabLong(&nextdiroff32);
 6178|    679|                *nextdiroff = nextdiroff32;
 6179|    679|            }
 6180|     11|            else
 6181|     11|            {
 6182|     11|                if (!ReadOK(tif, nextdiroff, sizeof(uint64_t)))
  ------------------
  |  |  300|     11|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|     11|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (6182:21): [True: 0, False: 11]
  ------------------
 6183|      0|                    *nextdiroff = 0;
 6184|     11|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6184:21): [True: 0, False: 11]
  ------------------
 6185|      0|                    TIFFSwabLong8(nextdiroff);
 6186|     11|            }
 6187|    690|        }
 6188|    690|    }
 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|    690|    dir = (TIFFDirEntry *)_TIFFCheckMalloc(
 6333|    690|        tif, dircount16, sizeof(TIFFDirEntry), "to read TIFF directory");
 6334|    690|    if (dir == 0)
  ------------------
  |  Branch (6334:9): [True: 0, False: 690]
  ------------------
 6335|      0|    {
 6336|      0|        _TIFFfreeExt(tif, origdir);
 6337|      0|        return 0;
 6338|      0|    }
 6339|    690|    ma = (uint8_t *)origdir;
 6340|    690|    mb = dir;
 6341|  81.1k|    for (n = 0; n < dircount16; n++)
  ------------------
  |  Branch (6341:17): [True: 80.4k, False: 690]
  ------------------
 6342|  80.4k|    {
 6343|  80.4k|        mb->tdir_ignore = FALSE;
  ------------------
  |  |   72|  80.4k|#define FALSE 0
  ------------------
 6344|  80.4k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  80.4k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6344:13): [True: 29, False: 80.4k]
  ------------------
 6345|     29|            TIFFSwabShort((uint16_t *)ma);
 6346|  80.4k|        mb->tdir_tag = *(uint16_t *)ma;
 6347|  80.4k|        ma += sizeof(uint16_t);
 6348|  80.4k|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  80.4k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6348:13): [True: 29, False: 80.4k]
  ------------------
 6349|     29|            TIFFSwabShort((uint16_t *)ma);
 6350|  80.4k|        mb->tdir_type = *(uint16_t *)ma;
 6351|  80.4k|        ma += sizeof(uint16_t);
 6352|  80.4k|        if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|  80.4k|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (6352:13): [True: 78.5k, False: 1.95k]
  ------------------
 6353|  78.5k|        {
 6354|  78.5k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  78.5k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6354:17): [True: 29, False: 78.4k]
  ------------------
 6355|     29|                TIFFSwabLong((uint32_t *)ma);
 6356|  78.5k|            mb->tdir_count = (uint64_t)(*(uint32_t *)ma);
 6357|  78.5k|            ma += sizeof(uint32_t);
 6358|  78.5k|            mb->tdir_offset.toff_long8 = 0;
 6359|  78.5k|            *(uint32_t *)(&mb->tdir_offset) = *(uint32_t *)ma;
 6360|  78.5k|            ma += sizeof(uint32_t);
 6361|  78.5k|        }
 6362|  1.95k|        else
 6363|  1.95k|        {
 6364|  1.95k|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  1.95k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (6364:17): [True: 0, False: 1.95k]
  ------------------
 6365|      0|                TIFFSwabLong8((uint64_t *)ma);
 6366|  1.95k|            mb->tdir_count = TIFFReadUInt64(ma);
 6367|  1.95k|            ma += sizeof(uint64_t);
 6368|  1.95k|            mb->tdir_offset.toff_long8 = TIFFReadUInt64(ma);
 6369|  1.95k|            ma += sizeof(uint64_t);
 6370|  1.95k|        }
 6371|  80.4k|        mb++;
 6372|  80.4k|    }
 6373|    690|    _TIFFfreeExt(tif, origdir);
 6374|    690|    *pdir = dir;
 6375|    690|    return dircount16;
 6376|    690|}
tif_dirread.c:TIFFReadUInt64:
  283|  3.91k|{
  284|  3.91k|    UInt64Aligned_t result;
  285|       |
  286|  3.91k|    result.c[0] = value[0];
  287|  3.91k|    result.c[1] = value[1];
  288|  3.91k|    result.c[2] = value[2];
  289|  3.91k|    result.c[3] = value[3];
  290|  3.91k|    result.c[4] = value[4];
  291|  3.91k|    result.c[5] = value[5];
  292|  3.91k|    result.c[6] = value[6];
  293|  3.91k|    result.c[7] = value[7];
  294|       |
  295|  3.91k|    return result.l;
  296|  3.91k|}
tif_dirread.c:TIFFFetchNormalTag:
 6382|  33.4k|{
 6383|  33.4k|    static const char module[] = "TIFFFetchNormalTag";
 6384|  33.4k|    enum TIFFReadDirEntryErr err;
 6385|  33.4k|    uint32_t fii;
 6386|  33.4k|    const TIFFField *fip = NULL;
 6387|  33.4k|    TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
 6388|  33.4k|    if (fii == FAILED_FII)
  ------------------
  |  |   44|  33.4k|#define FAILED_FII ((uint32_t)-1)
  ------------------
  |  Branch (6388:9): [True: 0, False: 33.4k]
  ------------------
 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|  33.4k|    fip = tif->tif_fields[fii];
 6395|  33.4k|    assert(fip != NULL); /* should not happen */
  ------------------
  |  Branch (6395:5): [True: 0, False: 33.4k]
  |  Branch (6395:5): [True: 33.4k, False: 0]
  ------------------
 6396|  33.4k|    assert(fip->set_get_field_type !=
  ------------------
  |  Branch (6396:5): [True: 0, False: 33.4k]
  |  Branch (6396:5): [True: 33.4k, False: 0]
  ------------------
 6397|  33.4k|           TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with
 6398|       |                                  this in specialized code */
 6399|  33.4k|    assert(fip->set_get_field_type !=
  ------------------
  |  Branch (6399:5): [True: 0, False: 33.4k]
  |  Branch (6399:5): [True: 33.4k, False: 0]
  ------------------
 6400|  33.4k|           TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only
 6401|       |                                the case for pseudo-tags */
 6402|  33.4k|    err = TIFFReadDirEntryErrOk;
 6403|  33.4k|    switch (fip->set_get_field_type)
 6404|  33.4k|    {
 6405|  24.8k|        case TIFF_SETGET_UNDEFINED:
  ------------------
  |  Branch (6405:9): [True: 24.8k, False: 8.62k]
  ------------------
 6406|  24.8k|            TIFFErrorExtR(
 6407|  24.8k|                tif, "TIFFFetchNormalTag",
 6408|  24.8k|                "Defined set_get_field_type of custom tag %u (%s) is "
 6409|  24.8k|                "TIFF_SETGET_UNDEFINED and thus tag is not read from file",
 6410|  24.8k|                fip->field_tag, fip->field_name);
 6411|  24.8k|            break;
 6412|    720|        case TIFF_SETGET_ASCII:
  ------------------
  |  Branch (6412:9): [True: 720, False: 32.7k]
  ------------------
 6413|    720|        {
 6414|    720|            uint8_t *data;
 6415|    720|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6415:13): [True: 0, False: 720]
  |  Branch (6415:13): [True: 720, False: 0]
  ------------------
 6416|    720|            err = TIFFReadDirEntryByteArray(tif, dp, &data);
 6417|    720|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6417:17): [True: 511, False: 209]
  ------------------
 6418|    511|            {
 6419|    511|                size_t mb = 0;
 6420|    511|                int n;
 6421|    511|                if (data != NULL)
  ------------------
  |  Branch (6421:21): [True: 508, False: 3]
  ------------------
 6422|    508|                {
 6423|    508|                    if (dp->tdir_count > 0 && data[dp->tdir_count - 1] == 0)
  ------------------
  |  Branch (6423:25): [True: 508, False: 0]
  |  Branch (6423:47): [True: 427, False: 81]
  ------------------
 6424|    427|                    {
 6425|       |                        /* optimization: if data is known to be 0 terminated, we
 6426|       |                         * can use strlen() */
 6427|    427|                        mb = strlen((const char *)data);
 6428|    427|                    }
 6429|     81|                    else
 6430|     81|                    {
 6431|       |                        /* general case. equivalent to non-portable */
 6432|       |                        /* mb = strnlen((const char*)data,
 6433|       |                         * (uint32_t)dp->tdir_count); */
 6434|     81|                        uint8_t *ma = data;
 6435|    188|                        while (mb < (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6435:32): [True: 158, False: 30]
  ------------------
 6436|    158|                        {
 6437|    158|                            if (*ma == 0)
  ------------------
  |  Branch (6437:33): [True: 51, False: 107]
  ------------------
 6438|     51|                                break;
 6439|    107|                            ma++;
 6440|    107|                            mb++;
 6441|    107|                        }
 6442|     81|                    }
 6443|    508|                }
 6444|    511|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6444:21): [True: 0, False: 511]
  ------------------
 6445|      0|                {
 6446|      0|                    if (data != NULL)
  ------------------
  |  Branch (6446:25): [True: 0, False: 0]
  ------------------
 6447|      0|                        _TIFFfreeExt(tif, data);
 6448|      0|                    return (0);
 6449|      0|                }
 6450|    511|                if (mb + 1 < (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6450:21): [True: 477, False: 34]
  ------------------
 6451|    477|                    TIFFWarningExtR(
 6452|    477|                        tif, module,
 6453|    477|                        "ASCII value for tag \"%s\" contains null byte in "
 6454|    477|                        "value; value incorrectly truncated during reading due "
 6455|    477|                        "to implementation limitations",
 6456|    477|                        fip->field_name);
 6457|     34|                else if (mb + 1 > (uint32_t)dp->tdir_count)
  ------------------
  |  Branch (6457:26): [True: 33, False: 1]
  ------------------
 6458|     33|                {
 6459|     33|                    TIFFWarningExtR(tif, module,
 6460|     33|                                    "ASCII value for tag \"%s\" does not end "
 6461|     33|                                    "in null byte. Forcing it to be null",
 6462|     33|                                    fip->field_name);
 6463|       |                    /* TIFFReadDirEntryArrayWithLimit() ensures this can't be
 6464|       |                     * larger than MAX_SIZE_TAG_DATA */
 6465|     33|                    assert((uint32_t)dp->tdir_count + 1 == dp->tdir_count + 1);
  ------------------
  |  Branch (6465:21): [True: 0, False: 33]
  |  Branch (6465:21): [True: 33, False: 0]
  ------------------
 6466|     33|                    uint8_t *o = (uint8_t *)_TIFFmallocExt(
 6467|     33|                        tif, (uint32_t)dp->tdir_count + 1);
 6468|     33|                    if (o == NULL)
  ------------------
  |  Branch (6468:25): [True: 0, False: 33]
  ------------------
 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|     33|                    if (dp->tdir_count > 0)
  ------------------
  |  Branch (6474:25): [True: 30, False: 3]
  ------------------
 6475|     30|                    {
 6476|     30|                        _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 6477|     30|                    }
 6478|     33|                    o[(uint32_t)dp->tdir_count] = 0;
 6479|     33|                    if (data != 0)
  ------------------
  |  Branch (6479:25): [True: 30, False: 3]
  ------------------
 6480|     30|                        _TIFFfreeExt(tif, data);
 6481|     33|                    data = o;
 6482|     33|                }
 6483|    511|                n = TIFFSetField(tif, dp->tdir_tag, data);
 6484|    511|                if (data != 0)
  ------------------
  |  Branch (6484:21): [True: 511, False: 0]
  ------------------
 6485|    511|                    _TIFFfreeExt(tif, data);
 6486|    511|                if (!n)
  ------------------
  |  Branch (6486:21): [True: 0, False: 511]
  ------------------
 6487|      0|                    return (0);
 6488|    511|            }
 6489|    720|        }
 6490|    720|        break;
 6491|    720|        case TIFF_SETGET_UINT8:
  ------------------
  |  Branch (6491:9): [True: 19, False: 33.4k]
  ------------------
 6492|     19|        {
 6493|     19|            uint8_t data = 0;
 6494|     19|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6494:13): [True: 0, False: 19]
  |  Branch (6494:13): [True: 19, False: 0]
  ------------------
 6495|     19|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6495:13): [True: 0, False: 19]
  |  Branch (6495:13): [True: 19, False: 0]
  ------------------
 6496|     19|            err = TIFFReadDirEntryByte(tif, dp, &data);
 6497|     19|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6497:17): [True: 7, False: 12]
  ------------------
 6498|      7|            {
 6499|      7|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6499:21): [True: 0, False: 7]
  ------------------
 6500|      0|                    return (0);
 6501|      7|            }
 6502|     19|        }
 6503|     19|        break;
 6504|     19|        case TIFF_SETGET_SINT8:
  ------------------
  |  Branch (6504:9): [True: 0, False: 33.4k]
  ------------------
 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|  2.09k|        case TIFF_SETGET_UINT16:
  ------------------
  |  Branch (6517:9): [True: 2.09k, False: 31.3k]
  ------------------
 6518|  2.09k|        {
 6519|  2.09k|            uint16_t data;
 6520|  2.09k|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6520:13): [True: 0, False: 2.09k]
  |  Branch (6520:13): [True: 2.09k, False: 0]
  ------------------
 6521|  2.09k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6521:13): [True: 0, False: 2.09k]
  |  Branch (6521:13): [True: 2.09k, False: 0]
  ------------------
 6522|  2.09k|            err = TIFFReadDirEntryShort(tif, dp, &data);
 6523|  2.09k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6523:17): [True: 1.41k, False: 681]
  ------------------
 6524|  1.41k|            {
 6525|  1.41k|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6525:21): [True: 60, False: 1.35k]
  ------------------
 6526|     60|                    return (0);
 6527|  1.41k|            }
 6528|  2.09k|        }
 6529|  2.03k|        break;
 6530|  2.03k|        case TIFF_SETGET_SINT16:
  ------------------
  |  Branch (6530:9): [True: 0, False: 33.4k]
  ------------------
 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|  1.99k|        case TIFF_SETGET_UINT32:
  ------------------
  |  Branch (6543:9): [True: 1.99k, False: 31.4k]
  ------------------
 6544|  1.99k|        {
 6545|  1.99k|            uint32_t data;
 6546|  1.99k|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6546:13): [True: 0, False: 1.99k]
  |  Branch (6546:13): [True: 1.99k, False: 0]
  ------------------
 6547|  1.99k|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6547:13): [True: 0, False: 1.99k]
  |  Branch (6547:13): [True: 1.99k, False: 0]
  ------------------
 6548|  1.99k|            err = TIFFReadDirEntryLong(tif, dp, &data);
 6549|  1.99k|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6549:17): [True: 1.89k, False: 103]
  ------------------
 6550|  1.89k|            {
 6551|  1.89k|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6551:21): [True: 0, False: 1.89k]
  ------------------
 6552|      0|                    return (0);
 6553|  1.89k|            }
 6554|  1.99k|        }
 6555|  1.99k|        break;
 6556|  1.99k|        case TIFF_SETGET_SINT32:
  ------------------
  |  Branch (6556:9): [True: 0, False: 33.4k]
  ------------------
 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|     38|        case TIFF_SETGET_UINT64:
  ------------------
  |  Branch (6569:9): [True: 38, False: 33.4k]
  ------------------
 6570|     38|        {
 6571|     38|            uint64_t data;
 6572|     38|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6572:13): [True: 0, False: 38]
  |  Branch (6572:13): [True: 38, False: 0]
  ------------------
 6573|     38|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6573:13): [True: 0, False: 38]
  |  Branch (6573:13): [True: 38, False: 0]
  ------------------
 6574|     38|            err = TIFFReadDirEntryLong8(tif, dp, &data);
 6575|     38|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6575:17): [True: 1, False: 37]
  ------------------
 6576|      1|            {
 6577|      1|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6577:21): [True: 0, False: 1]
  ------------------
 6578|      0|                    return 0;
 6579|      1|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6579:21): [True: 0, False: 1]
  ------------------
 6580|      0|                    return (0);
 6581|      1|            }
 6582|     38|        }
 6583|     38|        break;
 6584|     38|        case TIFF_SETGET_SINT64:
  ------------------
  |  Branch (6584:9): [True: 0, False: 33.4k]
  ------------------
 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|    462|        case TIFF_SETGET_FLOAT:
  ------------------
  |  Branch (6599:9): [True: 462, False: 33.0k]
  ------------------
 6600|    462|        {
 6601|    462|            float data;
 6602|    462|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6602:13): [True: 0, False: 462]
  |  Branch (6602:13): [True: 462, False: 0]
  ------------------
 6603|    462|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6603:13): [True: 0, False: 462]
  |  Branch (6603:13): [True: 462, False: 0]
  ------------------
 6604|    462|            err = TIFFReadDirEntryFloat(tif, dp, &data);
 6605|    462|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6605:17): [True: 178, False: 284]
  ------------------
 6606|    178|            {
 6607|    178|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6607:21): [True: 0, False: 178]
  ------------------
 6608|      0|                    return 0;
 6609|    178|                if (!TIFFSetField(tif, dp->tdir_tag, (double)data))
  ------------------
  |  Branch (6609:21): [True: 0, False: 178]
  ------------------
 6610|      0|                    return (0);
 6611|    178|            }
 6612|    462|        }
 6613|    462|        break;
 6614|    462|        case TIFF_SETGET_DOUBLE:
  ------------------
  |  Branch (6614:9): [True: 0, False: 33.4k]
  ------------------
 6615|      0|        {
 6616|      0|            double data;
 6617|      0|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6617:13): [True: 0, False: 0]
  |  Branch (6617:13): [True: 0, False: 0]
  ------------------
 6618|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6618:13): [True: 0, False: 0]
  |  Branch (6618:13): [True: 0, False: 0]
  ------------------
 6619|      0|            err = TIFFReadDirEntryDouble(tif, dp, &data);
 6620|      0|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6620:17): [True: 0, False: 0]
  ------------------
 6621|      0|            {
 6622|      0|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6622:21): [True: 0, False: 0]
  ------------------
 6623|      0|                    return 0;
 6624|      0|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6624:21): [True: 0, False: 0]
  ------------------
 6625|      0|                    return (0);
 6626|      0|            }
 6627|      0|        }
 6628|      0|        break;
 6629|      1|        case TIFF_SETGET_IFD8:
  ------------------
  |  Branch (6629:9): [True: 1, False: 33.4k]
  ------------------
 6630|      1|        {
 6631|      1|            uint64_t data;
 6632|      1|            assert(fip->field_readcount == 1);
  ------------------
  |  Branch (6632:13): [True: 0, False: 1]
  |  Branch (6632:13): [True: 1, False: 0]
  ------------------
 6633|      1|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6633:13): [True: 0, False: 1]
  |  Branch (6633:13): [True: 1, False: 0]
  ------------------
 6634|      1|            err = TIFFReadDirEntryIfd8(tif, dp, &data);
 6635|      1|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6635:17): [True: 1, False: 0]
  ------------------
 6636|      1|            {
 6637|      1|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6637:21): [True: 0, False: 1]
  ------------------
 6638|      0|                    return 0;
 6639|      1|                if (!TIFFSetField(tif, dp->tdir_tag, data))
  ------------------
  |  Branch (6639:21): [True: 0, False: 1]
  ------------------
 6640|      0|                    return (0);
 6641|      1|            }
 6642|      1|        }
 6643|      1|        break;
 6644|     44|        case TIFF_SETGET_UINT16_PAIR:
  ------------------
  |  Branch (6644:9): [True: 44, False: 33.4k]
  ------------------
 6645|     44|        {
 6646|     44|            uint16_t *data;
 6647|     44|            assert(fip->field_readcount == 2);
  ------------------
  |  Branch (6647:13): [True: 0, False: 44]
  |  Branch (6647:13): [True: 44, False: 0]
  ------------------
 6648|     44|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6648:13): [True: 0, False: 44]
  |  Branch (6648:13): [True: 44, False: 0]
  ------------------
 6649|     44|            if (dp->tdir_count != 2)
  ------------------
  |  Branch (6649:17): [True: 16, False: 28]
  ------------------
 6650|     16|            {
 6651|     16|                TIFFWarningExtR(tif, module,
 6652|     16|                                "incorrect count for field \"%s\", expected 2, "
 6653|     16|                                "got %" PRIu64,
 6654|     16|                                fip->field_name, dp->tdir_count);
 6655|     16|                return (0);
 6656|     16|            }
 6657|     28|            err = TIFFReadDirEntryShortArray(tif, dp, &data);
 6658|     28|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6658:17): [True: 28, False: 0]
  ------------------
 6659|     28|            {
 6660|     28|                int m;
 6661|     28|                assert(data); /* avoid CLang static Analyzer false positive */
  ------------------
  |  Branch (6661:17): [True: 0, False: 28]
  |  Branch (6661:17): [True: 28, False: 0]
  ------------------
 6662|     28|                m = TIFFSetField(tif, dp->tdir_tag, data[0], data[1]);
 6663|     28|                _TIFFfreeExt(tif, data);
 6664|     28|                if (!m)
  ------------------
  |  Branch (6664:21): [True: 0, False: 28]
  ------------------
 6665|      0|                    return (0);
 6666|     28|            }
 6667|     28|        }
 6668|     28|        break;
 6669|     28|        case TIFF_SETGET_C0_UINT8:
  ------------------
  |  Branch (6669:9): [True: 1, False: 33.4k]
  ------------------
 6670|      1|        {
 6671|      1|            uint8_t *data;
 6672|      1|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6672:13): [True: 0, False: 1]
  |  Branch (6672:13): [True: 1, False: 0]
  ------------------
 6673|      1|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6673:13): [True: 0, False: 1]
  |  Branch (6673:13): [True: 1, False: 0]
  ------------------
 6674|      1|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6674:17): [True: 1, False: 0]
  ------------------
 6675|      1|            {
 6676|      1|                TIFFWarningExtR(tif, module,
 6677|      1|                                "incorrect count for field \"%s\", expected "
 6678|      1|                                "%d, got %" PRIu64,
 6679|      1|                                fip->field_name, (int)fip->field_readcount,
 6680|      1|                                dp->tdir_count);
 6681|      1|                return (0);
 6682|      1|            }
 6683|      0|            else
 6684|      0|            {
 6685|      0|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 6686|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6686:21): [True: 0, False: 0]
  ------------------
 6687|      0|                {
 6688|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6688:25): [True: 0, False: 0]
  ------------------
 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|      0|                    int m;
 6695|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6696|      0|                    if (data != 0)
  ------------------
  |  Branch (6696:25): [True: 0, False: 0]
  ------------------
 6697|      0|                        _TIFFfreeExt(tif, data);
 6698|      0|                    if (!m)
  ------------------
  |  Branch (6698:25): [True: 0, False: 0]
  ------------------
 6699|      0|                        return (0);
 6700|      0|                }
 6701|      0|            }
 6702|      1|        }
 6703|      0|        break;
 6704|      0|        case TIFF_SETGET_C0_SINT8:
  ------------------
  |  Branch (6704:9): [True: 0, False: 33.4k]
  ------------------
 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|      1|        case TIFF_SETGET_C0_UINT16:
  ------------------
  |  Branch (6739:9): [True: 1, False: 33.4k]
  ------------------
 6740|      1|        {
 6741|      1|            uint16_t *data;
 6742|      1|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6742:13): [True: 0, False: 1]
  |  Branch (6742:13): [True: 1, False: 0]
  ------------------
 6743|      1|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6743:13): [True: 0, False: 1]
  |  Branch (6743:13): [True: 1, False: 0]
  ------------------
 6744|      1|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6744:17): [True: 1, False: 0]
  ------------------
 6745|      1|            {
 6746|      1|                TIFFWarningExtR(tif, module,
 6747|      1|                                "incorrect count for field \"%s\", expected "
 6748|      1|                                "%d, got %" PRIu64,
 6749|      1|                                fip->field_name, (int)fip->field_readcount,
 6750|      1|                                dp->tdir_count);
 6751|      1|                return (0);
 6752|      1|            }
 6753|      0|            else
 6754|      0|            {
 6755|      0|                err = TIFFReadDirEntryShortArray(tif, dp, &data);
 6756|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6756:21): [True: 0, False: 0]
  ------------------
 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|      0|            }
 6772|      1|        }
 6773|      0|        break;
 6774|      0|        case TIFF_SETGET_C0_SINT16:
  ------------------
  |  Branch (6774:9): [True: 0, False: 33.4k]
  ------------------
 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|      0|        case TIFF_SETGET_C0_UINT32:
  ------------------
  |  Branch (6809:9): [True: 0, False: 33.4k]
  ------------------
 6810|      0|        {
 6811|      0|            uint32_t *data;
 6812|      0|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6812:13): [True: 0, False: 0]
  |  Branch (6812:13): [True: 0, False: 0]
  ------------------
 6813|      0|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6813:13): [True: 0, False: 0]
  |  Branch (6813:13): [True: 0, False: 0]
  ------------------
 6814|      0|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6814:17): [True: 0, False: 0]
  ------------------
 6815|      0|            {
 6816|      0|                TIFFWarningExtR(tif, module,
 6817|      0|                                "incorrect count for field \"%s\", expected "
 6818|      0|                                "%d, got %" PRIu64,
 6819|      0|                                fip->field_name, (int)fip->field_readcount,
 6820|      0|                                dp->tdir_count);
 6821|      0|                return (0);
 6822|      0|            }
 6823|      0|            else
 6824|      0|            {
 6825|      0|                err = TIFFReadDirEntryLongArray(tif, dp, &data);
 6826|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6826:21): [True: 0, False: 0]
  ------------------
 6827|      0|                {
 6828|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6828:25): [True: 0, False: 0]
  ------------------
 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|      0|                    int m;
 6835|      0|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6836|      0|                    if (data != 0)
  ------------------
  |  Branch (6836:25): [True: 0, False: 0]
  ------------------
 6837|      0|                        _TIFFfreeExt(tif, data);
 6838|      0|                    if (!m)
  ------------------
  |  Branch (6838:25): [True: 0, False: 0]
  ------------------
 6839|      0|                        return (0);
 6840|      0|                }
 6841|      0|            }
 6842|      0|        }
 6843|      0|        break;
 6844|      0|        case TIFF_SETGET_C0_SINT32:
  ------------------
  |  Branch (6844:9): [True: 0, False: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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|     61|        case TIFF_SETGET_C0_FLOAT:
  ------------------
  |  Branch (6949:9): [True: 61, False: 33.4k]
  ------------------
 6950|     61|        {
 6951|     61|            float *data;
 6952|     61|            assert(fip->field_readcount >= 1);
  ------------------
  |  Branch (6952:13): [True: 0, False: 61]
  |  Branch (6952:13): [True: 61, False: 0]
  ------------------
 6953|     61|            assert(fip->field_passcount == 0);
  ------------------
  |  Branch (6953:13): [True: 0, False: 61]
  |  Branch (6953:13): [True: 61, False: 0]
  ------------------
 6954|     61|            if (dp->tdir_count != (uint64_t)fip->field_readcount)
  ------------------
  |  Branch (6954:17): [True: 50, False: 11]
  ------------------
 6955|     50|            {
 6956|     50|                TIFFWarningExtR(tif, module,
 6957|     50|                                "incorrect count for field \"%s\", expected "
 6958|     50|                                "%d, got %" PRIu64,
 6959|     50|                                fip->field_name, (int)fip->field_readcount,
 6960|     50|                                dp->tdir_count);
 6961|     50|                return (0);
 6962|     50|            }
 6963|     11|            else
 6964|     11|            {
 6965|     11|                err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 6966|     11|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (6966:21): [True: 9, False: 2]
  ------------------
 6967|      9|                {
 6968|      9|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (6968:25): [True: 0, False: 9]
  ------------------
 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|      9|                    int m;
 6975|      9|                    m = TIFFSetField(tif, dp->tdir_tag, data);
 6976|      9|                    if (data != 0)
  ------------------
  |  Branch (6976:25): [True: 9, False: 0]
  ------------------
 6977|      9|                        _TIFFfreeExt(tif, data);
 6978|      9|                    if (!m)
  ------------------
  |  Branch (6978:25): [True: 0, False: 9]
  ------------------
 6979|      0|                        return (0);
 6980|      9|                }
 6981|     11|            }
 6982|     61|        }
 6983|     11|        break;
 6984|       |        /*--: Rational2Double: Extend for Double Arrays and Rational-Arrays read
 6985|       |         * into Double-Arrays. */
 6986|     11|        case TIFF_SETGET_C0_DOUBLE:
  ------------------
  |  Branch (6986:9): [True: 0, False: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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|      6|        case TIFF_SETGET_C16_ASCII:
  ------------------
  |  Branch (7056:9): [True: 6, False: 33.4k]
  ------------------
 7057|      6|        {
 7058|      6|            uint8_t *data;
 7059|      6|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7059:13): [True: 0, False: 6]
  |  Branch (7059:13): [True: 6, False: 0]
  ------------------
 7060|      6|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7060:13): [True: 0, False: 6]
  |  Branch (7060:13): [True: 6, False: 0]
  ------------------
 7061|      6|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7061:17): [True: 1, False: 5]
  ------------------
 7062|      1|                err = TIFFReadDirEntryErrCount;
 7063|      5|            else
 7064|      5|            {
 7065|      5|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7066|      5|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7066:21): [True: 5, False: 0]
  ------------------
 7067|      5|                {
 7068|      5|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7068:25): [True: 0, False: 5]
  ------------------
 7069|      0|                    {
 7070|      0|                        if (data != 0)
  ------------------
  |  Branch (7070:29): [True: 0, False: 0]
  ------------------
 7071|      0|                            _TIFFfreeExt(tif, data);
 7072|      0|                        return 0;
 7073|      0|                    }
 7074|      5|                    int m;
 7075|      5|                    if (data != 0 && dp->tdir_count > 0 &&
  ------------------
  |  Branch (7075:25): [True: 5, False: 0]
  |  Branch (7075:38): [True: 5, False: 0]
  ------------------
 7076|      5|                        data[dp->tdir_count - 1] != '\0')
  ------------------
  |  Branch (7076:25): [True: 5, False: 0]
  ------------------
 7077|      5|                    {
 7078|      5|                        TIFFWarningExtR(tif, module,
 7079|      5|                                        "ASCII value for ASCII array tag "
 7080|      5|                                        "\"%s\" does not end in null "
 7081|      5|                                        "byte. Forcing it to be null",
 7082|      5|                                        fip->field_name);
 7083|       |                        /* Enlarge buffer and add terminating null. */
 7084|      5|                        uint8_t *o = (uint8_t *)_TIFFmallocExt(
 7085|      5|                            tif, (uint32_t)dp->tdir_count + 1);
 7086|      5|                        if (o == NULL)
  ------------------
  |  Branch (7086:29): [True: 0, False: 5]
  ------------------
 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|      5|                        if (dp->tdir_count > 0)
  ------------------
  |  Branch (7092:29): [True: 5, False: 0]
  ------------------
 7093|      5|                        {
 7094|      5|                            _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 7095|      5|                        }
 7096|      5|                        o[(uint32_t)dp->tdir_count] = 0;
 7097|      5|                        dp->tdir_count++; /* Increment for added null. */
 7098|      5|                        if (data != 0)
  ------------------
  |  Branch (7098:29): [True: 5, False: 0]
  ------------------
 7099|      5|                            _TIFFfreeExt(tif, data);
 7100|      5|                        data = o;
 7101|      5|                    }
 7102|      5|                    m = TIFFSetField(tif, dp->tdir_tag,
 7103|      5|                                     (uint16_t)(dp->tdir_count), data);
 7104|      5|                    if (data != 0)
  ------------------
  |  Branch (7104:25): [True: 5, False: 0]
  ------------------
 7105|      5|                        _TIFFfreeExt(tif, data);
 7106|      5|                    if (!m)
  ------------------
  |  Branch (7106:25): [True: 0, False: 5]
  ------------------
 7107|      0|                        return (0);
 7108|      5|                }
 7109|      5|            }
 7110|      6|        }
 7111|      6|        break;
 7112|      6|        case TIFF_SETGET_C16_UINT8:
  ------------------
  |  Branch (7112:9): [True: 5, False: 33.4k]
  ------------------
 7113|      5|        {
 7114|      5|            uint8_t *data;
 7115|      5|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7115:13): [True: 0, False: 5]
  |  Branch (7115:13): [True: 5, False: 0]
  ------------------
 7116|      5|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7116:13): [True: 0, False: 5]
  |  Branch (7116:13): [True: 5, False: 0]
  ------------------
 7117|      5|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7117:17): [True: 1, False: 4]
  ------------------
 7118|      1|                err = TIFFReadDirEntryErrCount;
 7119|      4|            else
 7120|      4|            {
 7121|      4|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7122|      4|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7122:21): [True: 0, False: 4]
  ------------------
 7123|      0|                {
 7124|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7124:25): [True: 0, False: 0]
  ------------------
 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|      0|                    int m;
 7131|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7132|      0|                                     (uint16_t)(dp->tdir_count), data);
 7133|      0|                    if (data != 0)
  ------------------
  |  Branch (7133:25): [True: 0, False: 0]
  ------------------
 7134|      0|                        _TIFFfreeExt(tif, data);
 7135|      0|                    if (!m)
  ------------------
  |  Branch (7135:25): [True: 0, False: 0]
  ------------------
 7136|      0|                        return (0);
 7137|      0|                }
 7138|      4|            }
 7139|      5|        }
 7140|      5|        break;
 7141|      5|        case TIFF_SETGET_C16_SINT8:
  ------------------
  |  Branch (7141:9): [True: 0, False: 33.4k]
  ------------------
 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|    338|        case TIFF_SETGET_C16_UINT16:
  ------------------
  |  Branch (7170:9): [True: 338, False: 33.1k]
  ------------------
 7171|    338|        {
 7172|    338|            uint16_t *data;
 7173|    338|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7173:13): [True: 0, False: 338]
  |  Branch (7173:13): [True: 338, False: 0]
  ------------------
 7174|    338|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7174:13): [True: 0, False: 338]
  |  Branch (7174:13): [True: 338, False: 0]
  ------------------
 7175|    338|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7175:17): [True: 0, False: 338]
  ------------------
 7176|      0|                err = TIFFReadDirEntryErrCount;
 7177|    338|            else
 7178|    338|            {
 7179|    338|                err = TIFFReadDirEntryShortArray(tif, dp, &data);
 7180|    338|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7180:21): [True: 338, False: 0]
  ------------------
 7181|    338|                {
 7182|    338|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7182:25): [True: 0, False: 338]
  ------------------
 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|    338|                    int m;
 7189|    338|                    m = TIFFSetField(tif, dp->tdir_tag,
 7190|    338|                                     (uint16_t)(dp->tdir_count), data);
 7191|    338|                    if (data != 0)
  ------------------
  |  Branch (7191:25): [True: 337, False: 1]
  ------------------
 7192|    337|                        _TIFFfreeExt(tif, data);
 7193|    338|                    if (!m)
  ------------------
  |  Branch (7193:25): [True: 1, False: 337]
  ------------------
 7194|      1|                        return (0);
 7195|    338|                }
 7196|    338|            }
 7197|    338|        }
 7198|    337|        break;
 7199|    337|        case TIFF_SETGET_C16_SINT16:
  ------------------
  |  Branch (7199:9): [True: 0, False: 33.4k]
  ------------------
 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|      2|        case TIFF_SETGET_C16_UINT32:
  ------------------
  |  Branch (7228:9): [True: 2, False: 33.4k]
  ------------------
 7229|      2|        {
 7230|      2|            uint32_t *data;
 7231|      2|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7231:13): [True: 0, False: 2]
  |  Branch (7231:13): [True: 2, False: 0]
  ------------------
 7232|      2|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7232:13): [True: 0, False: 2]
  |  Branch (7232:13): [True: 2, False: 0]
  ------------------
 7233|      2|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7233:17): [True: 2, False: 0]
  ------------------
 7234|      2|                err = TIFFReadDirEntryErrCount;
 7235|      0|            else
 7236|      0|            {
 7237|      0|                err = TIFFReadDirEntryLongArray(tif, dp, &data);
 7238|      0|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7238:21): [True: 0, False: 0]
  ------------------
 7239|      0|                {
 7240|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7240:25): [True: 0, False: 0]
  ------------------
 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|      0|                    int m;
 7247|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7248|      0|                                     (uint16_t)(dp->tdir_count), data);
 7249|      0|                    if (data != 0)
  ------------------
  |  Branch (7249:25): [True: 0, False: 0]
  ------------------
 7250|      0|                        _TIFFfreeExt(tif, data);
 7251|      0|                    if (!m)
  ------------------
  |  Branch (7251:25): [True: 0, False: 0]
  ------------------
 7252|      0|                        return (0);
 7253|      0|                }
 7254|      0|            }
 7255|      2|        }
 7256|      2|        break;
 7257|      2|        case TIFF_SETGET_C16_SINT32:
  ------------------
  |  Branch (7257:9): [True: 0, False: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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|      5|        case TIFF_SETGET_C16_FLOAT:
  ------------------
  |  Branch (7344:9): [True: 5, False: 33.4k]
  ------------------
 7345|      5|        {
 7346|      5|            float *data;
 7347|      5|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7347:13): [True: 0, False: 5]
  |  Branch (7347:13): [True: 5, False: 0]
  ------------------
 7348|      5|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7348:13): [True: 0, False: 5]
  |  Branch (7348:13): [True: 5, False: 0]
  ------------------
 7349|      5|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7349:17): [True: 1, False: 4]
  ------------------
 7350|      1|                err = TIFFReadDirEntryErrCount;
 7351|      4|            else
 7352|      4|            {
 7353|      4|                err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 7354|      4|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7354:21): [True: 4, False: 0]
  ------------------
 7355|      4|                {
 7356|      4|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7356:25): [True: 0, False: 4]
  ------------------
 7357|      0|                    {
 7358|      0|                        if (data != 0)
  ------------------
  |  Branch (7358:29): [True: 0, False: 0]
  ------------------
 7359|      0|                            _TIFFfreeExt(tif, data);
 7360|      0|                        return 0;
 7361|      0|                    }
 7362|      4|                    int m;
 7363|      4|                    m = TIFFSetField(tif, dp->tdir_tag,
 7364|      4|                                     (uint16_t)(dp->tdir_count), data);
 7365|      4|                    if (data != 0)
  ------------------
  |  Branch (7365:25): [True: 4, False: 0]
  ------------------
 7366|      4|                        _TIFFfreeExt(tif, data);
 7367|      4|                    if (!m)
  ------------------
  |  Branch (7367:25): [True: 0, False: 4]
  ------------------
 7368|      0|                        return (0);
 7369|      4|                }
 7370|      4|            }
 7371|      5|        }
 7372|      5|        break;
 7373|      5|        case TIFF_SETGET_C16_DOUBLE:
  ------------------
  |  Branch (7373:9): [True: 0, False: 33.4k]
  ------------------
 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|      1|        case TIFF_SETGET_C16_IFD8:
  ------------------
  |  Branch (7402:9): [True: 1, False: 33.4k]
  ------------------
 7403|      1|        {
 7404|      1|            uint64_t *data;
 7405|      1|            assert(fip->field_readcount == TIFF_VARIABLE);
  ------------------
  |  Branch (7405:13): [True: 0, False: 1]
  |  Branch (7405:13): [True: 1, False: 0]
  ------------------
 7406|      1|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7406:13): [True: 0, False: 1]
  |  Branch (7406:13): [True: 1, False: 0]
  ------------------
 7407|      1|            if (dp->tdir_count > 0xFFFF)
  ------------------
  |  Branch (7407:17): [True: 0, False: 1]
  ------------------
 7408|      0|                err = TIFFReadDirEntryErrCount;
 7409|      1|            else
 7410|      1|            {
 7411|      1|                err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
 7412|      1|                if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7412:21): [True: 0, False: 1]
  ------------------
 7413|      0|                {
 7414|      0|                    if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7414:25): [True: 0, False: 0]
  ------------------
 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|      0|                    int m;
 7421|      0|                    m = TIFFSetField(tif, dp->tdir_tag,
 7422|      0|                                     (uint16_t)(dp->tdir_count), data);
 7423|      0|                    if (data != 0)
  ------------------
  |  Branch (7423:25): [True: 0, False: 0]
  ------------------
 7424|      0|                        _TIFFfreeExt(tif, data);
 7425|      0|                    if (!m)
  ------------------
  |  Branch (7425:25): [True: 0, False: 0]
  ------------------
 7426|      0|                        return (0);
 7427|      0|                }
 7428|      1|            }
 7429|      1|        }
 7430|      1|        break;
 7431|     41|        case TIFF_SETGET_C32_ASCII:
  ------------------
  |  Branch (7431:9): [True: 41, False: 33.4k]
  ------------------
 7432|     41|        {
 7433|     41|            uint8_t *data;
 7434|     41|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7434:13): [True: 0, False: 41]
  |  Branch (7434:13): [True: 41, False: 0]
  ------------------
 7435|     41|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7435:13): [True: 0, False: 41]
  |  Branch (7435:13): [True: 41, False: 0]
  ------------------
 7436|     41|            err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7437|     41|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7437:17): [True: 15, False: 26]
  ------------------
 7438|     15|            {
 7439|     15|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7439:21): [True: 0, False: 15]
  ------------------
 7440|      0|                {
 7441|      0|                    if (data != 0)
  ------------------
  |  Branch (7441:25): [True: 0, False: 0]
  ------------------
 7442|      0|                        _TIFFfreeExt(tif, data);
 7443|      0|                    return 0;
 7444|      0|                }
 7445|     15|                int m;
 7446|     15|                if (data != 0 && dp->tdir_count > 0 &&
  ------------------
  |  Branch (7446:21): [True: 11, False: 4]
  |  Branch (7446:34): [True: 11, False: 0]
  ------------------
 7447|     11|                    data[dp->tdir_count - 1] != '\0')
  ------------------
  |  Branch (7447:21): [True: 10, False: 1]
  ------------------
 7448|     10|                {
 7449|     10|                    TIFFWarningExtR(
 7450|     10|                        tif, module,
 7451|     10|                        "ASCII value for ASCII array tag \"%s\" does not end "
 7452|     10|                        "in null byte. Forcing it to be null",
 7453|     10|                        fip->field_name);
 7454|       |                    /* Enlarge buffer and add terminating null. */
 7455|     10|                    uint8_t *o = (uint8_t *)_TIFFmallocExt(
 7456|     10|                        tif, (uint32_t)dp->tdir_count + 1);
 7457|     10|                    if (o == NULL)
  ------------------
  |  Branch (7457:25): [True: 0, False: 10]
  ------------------
 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|     10|                    if (dp->tdir_count > 0)
  ------------------
  |  Branch (7463:25): [True: 10, False: 0]
  ------------------
 7464|     10|                    {
 7465|     10|                        _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
 7466|     10|                    }
 7467|     10|                    o[(uint32_t)dp->tdir_count] = 0;
 7468|     10|                    dp->tdir_count++; /* Increment for added null. */
 7469|     10|                    if (data != 0)
  ------------------
  |  Branch (7469:25): [True: 10, False: 0]
  ------------------
 7470|     10|                        _TIFFfreeExt(tif, data);
 7471|     10|                    data = o;
 7472|     10|                }
 7473|     15|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7474|     15|                                 data);
 7475|     15|                if (data != 0)
  ------------------
  |  Branch (7475:21): [True: 11, False: 4]
  ------------------
 7476|     11|                    _TIFFfreeExt(tif, data);
 7477|     15|                if (!m)
  ------------------
  |  Branch (7477:21): [True: 0, False: 15]
  ------------------
 7478|      0|                    return (0);
 7479|     15|            }
 7480|     41|        }
 7481|     41|        break;
 7482|    873|        case TIFF_SETGET_C32_UINT8:
  ------------------
  |  Branch (7482:9): [True: 873, False: 32.6k]
  ------------------
 7483|    873|        {
 7484|    873|            uint8_t *data;
 7485|    873|            uint32_t count = 0;
 7486|    873|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7486:13): [True: 0, False: 873]
  |  Branch (7486:13): [True: 873, False: 0]
  ------------------
 7487|    873|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7487:13): [True: 0, False: 873]
  |  Branch (7487:13): [True: 873, False: 0]
  ------------------
 7488|    873|            if (fip->field_tag == TIFFTAG_RICHTIFFIPTC &&
  ------------------
  |  |  448|  1.74k|#define TIFFTAG_RICHTIFFIPTC 33723
  ------------------
  |  Branch (7488:17): [True: 2, False: 871]
  ------------------
 7489|      2|                dp->tdir_type == TIFF_LONG)
  ------------------
  |  Branch (7489:17): [True: 2, False: 0]
  ------------------
 7490|      2|            {
 7491|       |                /* Adobe's software (wrongly) writes RichTIFFIPTC tag with
 7492|       |                 * data type LONG instead of UNDEFINED. Work around this
 7493|       |                 * frequently found issue */
 7494|      2|                void *origdata;
 7495|      2|                err = TIFFReadDirEntryArray(tif, dp, &count, 4, &origdata);
 7496|      2|                if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (7496:21): [True: 0, False: 2]
  |  Branch (7496:55): [True: 2, False: 0]
  ------------------
 7497|      2|                {
 7498|      2|                    data = NULL;
 7499|      2|                }
 7500|      0|                else
 7501|      0|                {
 7502|      0|                    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (7502:25): [True: 0, False: 0]
  ------------------
 7503|      0|                        TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 7504|      0|                    data = (uint8_t *)origdata;
 7505|      0|                    count = (uint32_t)(count * 4);
 7506|      0|                }
 7507|      2|            }
 7508|    871|            else
 7509|    871|            {
 7510|    871|                err = TIFFReadDirEntryByteArray(tif, dp, &data);
 7511|    871|                count = (uint32_t)(dp->tdir_count);
 7512|    871|            }
 7513|    873|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7513:17): [True: 595, False: 278]
  ------------------
 7514|    595|            {
 7515|    595|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7515:21): [True: 0, False: 595]
  ------------------
 7516|      0|                {
 7517|      0|                    if (data != 0)
  ------------------
  |  Branch (7517:25): [True: 0, False: 0]
  ------------------
 7518|      0|                        _TIFFfreeExt(tif, data);
 7519|      0|                    return 0;
 7520|      0|                }
 7521|    595|                int m;
 7522|    595|                m = TIFFSetField(tif, dp->tdir_tag, count, data);
 7523|    595|                if (data != 0)
  ------------------
  |  Branch (7523:21): [True: 155, False: 440]
  ------------------
 7524|    155|                    _TIFFfreeExt(tif, data);
 7525|    595|                if (!m)
  ------------------
  |  Branch (7525:21): [True: 0, False: 595]
  ------------------
 7526|      0|                    return (0);
 7527|    595|            }
 7528|    873|        }
 7529|    873|        break;
 7530|    873|        case TIFF_SETGET_C32_SINT8:
  ------------------
  |  Branch (7530:9): [True: 148, False: 33.3k]
  ------------------
 7531|    148|        {
 7532|    148|            int8_t *data = NULL;
 7533|    148|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7533:13): [True: 0, False: 148]
  |  Branch (7533:13): [True: 148, False: 0]
  ------------------
 7534|    148|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7534:13): [True: 0, False: 148]
  |  Branch (7534:13): [True: 148, False: 0]
  ------------------
 7535|    148|            err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
 7536|    148|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7536:17): [True: 87, False: 61]
  ------------------
 7537|     87|            {
 7538|     87|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7538:21): [True: 0, False: 87]
  ------------------
 7539|      0|                {
 7540|      0|                    if (data != 0)
  ------------------
  |  Branch (7540:25): [True: 0, False: 0]
  ------------------
 7541|      0|                        _TIFFfreeExt(tif, data);
 7542|      0|                    return 0;
 7543|      0|                }
 7544|     87|                int m;
 7545|     87|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7546|     87|                                 data);
 7547|     87|                if (data != 0)
  ------------------
  |  Branch (7547:21): [True: 72, False: 15]
  ------------------
 7548|     72|                    _TIFFfreeExt(tif, data);
 7549|     87|                if (!m)
  ------------------
  |  Branch (7549:21): [True: 0, False: 87]
  ------------------
 7550|      0|                    return (0);
 7551|     87|            }
 7552|    148|        }
 7553|    148|        break;
 7554|    866|        case TIFF_SETGET_C32_UINT16:
  ------------------
  |  Branch (7554:9): [True: 866, False: 32.6k]
  ------------------
 7555|    866|        {
 7556|    866|            uint16_t *data;
 7557|    866|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7557:13): [True: 0, False: 866]
  |  Branch (7557:13): [True: 866, False: 0]
  ------------------
 7558|    866|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7558:13): [True: 0, False: 866]
  |  Branch (7558:13): [True: 866, False: 0]
  ------------------
 7559|    866|            err = TIFFReadDirEntryShortArray(tif, dp, &data);
 7560|    866|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7560:17): [True: 479, False: 387]
  ------------------
 7561|    479|            {
 7562|    479|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7562:21): [True: 0, False: 479]
  ------------------
 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|    479|                int m;
 7569|    479|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7570|    479|                                 data);
 7571|    479|                if (data != 0)
  ------------------
  |  Branch (7571:21): [True: 473, False: 6]
  ------------------
 7572|    473|                    _TIFFfreeExt(tif, data);
 7573|    479|                if (!m)
  ------------------
  |  Branch (7573:21): [True: 0, False: 479]
  ------------------
 7574|      0|                    return (0);
 7575|    479|            }
 7576|    866|        }
 7577|    866|        break;
 7578|    866|        case TIFF_SETGET_C32_SINT16:
  ------------------
  |  Branch (7578:9): [True: 13, False: 33.4k]
  ------------------
 7579|     13|        {
 7580|     13|            int16_t *data = NULL;
 7581|     13|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7581:13): [True: 0, False: 13]
  |  Branch (7581:13): [True: 13, False: 0]
  ------------------
 7582|     13|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7582:13): [True: 0, False: 13]
  |  Branch (7582:13): [True: 13, False: 0]
  ------------------
 7583|     13|            err = TIFFReadDirEntrySshortArray(tif, dp, &data);
 7584|     13|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7584:17): [True: 1, False: 12]
  ------------------
 7585|      1|            {
 7586|      1|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7586:21): [True: 0, False: 1]
  ------------------
 7587|      0|                {
 7588|      0|                    if (data != 0)
  ------------------
  |  Branch (7588:25): [True: 0, False: 0]
  ------------------
 7589|      0|                        _TIFFfreeExt(tif, data);
 7590|      0|                    return 0;
 7591|      0|                }
 7592|      1|                int m;
 7593|      1|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7594|      1|                                 data);
 7595|      1|                if (data != 0)
  ------------------
  |  Branch (7595:21): [True: 0, False: 1]
  ------------------
 7596|      0|                    _TIFFfreeExt(tif, data);
 7597|      1|                if (!m)
  ------------------
  |  Branch (7597:21): [True: 0, False: 1]
  ------------------
 7598|      0|                    return (0);
 7599|      1|            }
 7600|     13|        }
 7601|     13|        break;
 7602|    255|        case TIFF_SETGET_C32_UINT32:
  ------------------
  |  Branch (7602:9): [True: 255, False: 33.2k]
  ------------------
 7603|    255|        {
 7604|    255|            uint32_t *data;
 7605|    255|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7605:13): [True: 0, False: 255]
  |  Branch (7605:13): [True: 255, False: 0]
  ------------------
 7606|    255|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7606:13): [True: 0, False: 255]
  |  Branch (7606:13): [True: 255, False: 0]
  ------------------
 7607|    255|            err = TIFFReadDirEntryLongArray(tif, dp, &data);
 7608|    255|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7608:17): [True: 160, False: 95]
  ------------------
 7609|    160|            {
 7610|    160|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7610:21): [True: 0, False: 160]
  ------------------
 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|    160|                int m;
 7617|    160|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7618|    160|                                 data);
 7619|    160|                if (data != 0)
  ------------------
  |  Branch (7619:21): [True: 147, False: 13]
  ------------------
 7620|    147|                    _TIFFfreeExt(tif, data);
 7621|    160|                if (!m)
  ------------------
  |  Branch (7621:21): [True: 0, False: 160]
  ------------------
 7622|      0|                    return (0);
 7623|    160|            }
 7624|    255|        }
 7625|    255|        break;
 7626|    255|        case TIFF_SETGET_C32_SINT32:
  ------------------
  |  Branch (7626:9): [True: 17, False: 33.4k]
  ------------------
 7627|     17|        {
 7628|     17|            int32_t *data = NULL;
 7629|     17|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7629:13): [True: 0, False: 17]
  |  Branch (7629:13): [True: 17, False: 0]
  ------------------
 7630|     17|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7630:13): [True: 0, False: 17]
  |  Branch (7630:13): [True: 17, False: 0]
  ------------------
 7631|     17|            err = TIFFReadDirEntrySlongArray(tif, dp, &data);
 7632|     17|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7632:17): [True: 14, False: 3]
  ------------------
 7633|     14|            {
 7634|     14|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7634:21): [True: 0, False: 14]
  ------------------
 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|     14|                int m;
 7641|     14|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7642|     14|                                 data);
 7643|     14|                if (data != 0)
  ------------------
  |  Branch (7643:21): [True: 12, False: 2]
  ------------------
 7644|     12|                    _TIFFfreeExt(tif, data);
 7645|     14|                if (!m)
  ------------------
  |  Branch (7645:21): [True: 0, False: 14]
  ------------------
 7646|      0|                    return (0);
 7647|     14|            }
 7648|     17|        }
 7649|     17|        break;
 7650|    330|        case TIFF_SETGET_C32_UINT64:
  ------------------
  |  Branch (7650:9): [True: 330, False: 33.1k]
  ------------------
 7651|    330|        {
 7652|    330|            uint64_t *data;
 7653|    330|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7653:13): [True: 0, False: 330]
  |  Branch (7653:13): [True: 330, False: 0]
  ------------------
 7654|    330|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7654:13): [True: 0, False: 330]
  |  Branch (7654:13): [True: 330, False: 0]
  ------------------
 7655|    330|            err = TIFFReadDirEntryLong8Array(tif, dp, &data);
 7656|    330|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7656:17): [True: 249, False: 81]
  ------------------
 7657|    249|            {
 7658|    249|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7658:21): [True: 0, False: 249]
  ------------------
 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|    249|                int m;
 7665|    249|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7666|    249|                                 data);
 7667|    249|                if (data != 0)
  ------------------
  |  Branch (7667:21): [True: 247, False: 2]
  ------------------
 7668|    247|                    _TIFFfreeExt(tif, data);
 7669|    249|                if (!m)
  ------------------
  |  Branch (7669:21): [True: 100, False: 149]
  ------------------
 7670|    100|                    return (0);
 7671|    249|            }
 7672|    330|        }
 7673|    230|        break;
 7674|    230|        case TIFF_SETGET_C32_SINT64:
  ------------------
  |  Branch (7674:9): [True: 191, False: 33.2k]
  ------------------
 7675|    191|        {
 7676|    191|            int64_t *data = NULL;
 7677|    191|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7677:13): [True: 0, False: 191]
  |  Branch (7677:13): [True: 191, False: 0]
  ------------------
 7678|    191|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7678:13): [True: 0, False: 191]
  |  Branch (7678:13): [True: 191, False: 0]
  ------------------
 7679|    191|            err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
 7680|    191|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7680:17): [True: 0, False: 191]
  ------------------
 7681|      0|            {
 7682|      0|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7682:21): [True: 0, False: 0]
  ------------------
 7683|      0|                {
 7684|      0|                    if (data != 0)
  ------------------
  |  Branch (7684:25): [True: 0, False: 0]
  ------------------
 7685|      0|                        _TIFFfreeExt(tif, data);
 7686|      0|                    return 0;
 7687|      0|                }
 7688|      0|                int m;
 7689|      0|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7690|      0|                                 data);
 7691|      0|                if (data != 0)
  ------------------
  |  Branch (7691:21): [True: 0, False: 0]
  ------------------
 7692|      0|                    _TIFFfreeExt(tif, data);
 7693|      0|                if (!m)
  ------------------
  |  Branch (7693:21): [True: 0, False: 0]
  ------------------
 7694|      0|                    return (0);
 7695|      0|            }
 7696|    191|        }
 7697|    191|        break;
 7698|    191|        case TIFF_SETGET_C32_FLOAT:
  ------------------
  |  Branch (7698:9): [True: 62, False: 33.4k]
  ------------------
 7699|     62|        {
 7700|     62|            float *data;
 7701|     62|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7701:13): [True: 0, False: 62]
  |  Branch (7701:13): [True: 62, False: 0]
  ------------------
 7702|     62|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7702:13): [True: 0, False: 62]
  |  Branch (7702:13): [True: 62, False: 0]
  ------------------
 7703|     62|            err = TIFFReadDirEntryFloatArray(tif, dp, &data);
 7704|     62|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7704:17): [True: 28, False: 34]
  ------------------
 7705|     28|            {
 7706|     28|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7706:21): [True: 0, False: 28]
  ------------------
 7707|      0|                {
 7708|      0|                    if (data != 0)
  ------------------
  |  Branch (7708:25): [True: 0, False: 0]
  ------------------
 7709|      0|                        _TIFFfreeExt(tif, data);
 7710|      0|                    return 0;
 7711|      0|                }
 7712|     28|                int m;
 7713|     28|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7714|     28|                                 data);
 7715|     28|                if (data != 0)
  ------------------
  |  Branch (7715:21): [True: 28, False: 0]
  ------------------
 7716|     28|                    _TIFFfreeExt(tif, data);
 7717|     28|                if (!m)
  ------------------
  |  Branch (7717:21): [True: 0, False: 28]
  ------------------
 7718|      0|                    return (0);
 7719|     28|            }
 7720|     62|        }
 7721|     62|        break;
 7722|     62|        case TIFF_SETGET_C32_DOUBLE:
  ------------------
  |  Branch (7722:9): [True: 15, False: 33.4k]
  ------------------
 7723|     15|        {
 7724|     15|            double *data;
 7725|     15|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7725:13): [True: 0, False: 15]
  |  Branch (7725:13): [True: 15, False: 0]
  ------------------
 7726|     15|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7726:13): [True: 0, False: 15]
  |  Branch (7726:13): [True: 15, False: 0]
  ------------------
 7727|     15|            err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
 7728|     15|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7728:17): [True: 5, False: 10]
  ------------------
 7729|      5|            {
 7730|      5|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7730:21): [True: 0, False: 5]
  ------------------
 7731|      0|                {
 7732|      0|                    if (data != 0)
  ------------------
  |  Branch (7732:25): [True: 0, False: 0]
  ------------------
 7733|      0|                        _TIFFfreeExt(tif, data);
 7734|      0|                    return 0;
 7735|      0|                }
 7736|      5|                int m;
 7737|      5|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7738|      5|                                 data);
 7739|      5|                if (data != 0)
  ------------------
  |  Branch (7739:21): [True: 0, False: 5]
  ------------------
 7740|      0|                    _TIFFfreeExt(tif, data);
 7741|      5|                if (!m)
  ------------------
  |  Branch (7741:21): [True: 0, False: 5]
  ------------------
 7742|      0|                    return (0);
 7743|      5|            }
 7744|     15|        }
 7745|     15|        break;
 7746|     23|        case TIFF_SETGET_C32_IFD8:
  ------------------
  |  Branch (7746:9): [True: 23, False: 33.4k]
  ------------------
 7747|     23|        {
 7748|     23|            uint64_t *data;
 7749|     23|            assert(fip->field_readcount == TIFF_VARIABLE2);
  ------------------
  |  Branch (7749:13): [True: 0, False: 23]
  |  Branch (7749:13): [True: 23, False: 0]
  ------------------
 7750|     23|            assert(fip->field_passcount == 1);
  ------------------
  |  Branch (7750:13): [True: 0, False: 23]
  |  Branch (7750:13): [True: 23, False: 0]
  ------------------
 7751|     23|            err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
 7752|     23|            if (err == TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7752:17): [True: 4, False: 19]
  ------------------
 7753|      4|            {
 7754|      4|                if (!EvaluateIFDdatasizeReading(tif, dp))
  ------------------
  |  Branch (7754:21): [True: 0, False: 4]
  ------------------
 7755|      0|                {
 7756|      0|                    if (data != 0)
  ------------------
  |  Branch (7756:25): [True: 0, False: 0]
  ------------------
 7757|      0|                        _TIFFfreeExt(tif, data);
 7758|      0|                    return 0;
 7759|      0|                }
 7760|      4|                int m;
 7761|      4|                m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
 7762|      4|                                 data);
 7763|      4|                if (data != 0)
  ------------------
  |  Branch (7763:21): [True: 4, False: 0]
  ------------------
 7764|      4|                    _TIFFfreeExt(tif, data);
 7765|      4|                if (!m)
  ------------------
  |  Branch (7765:21): [True: 4, False: 0]
  ------------------
 7766|      4|                    return (0);
 7767|      4|            }
 7768|     23|        }
 7769|     19|        break;
 7770|     19|        case TIFF_SETGET_INT:
  ------------------
  |  Branch (7770:9): [True: 0, False: 33.4k]
  ------------------
 7771|      0|        case TIFF_SETGET_C0_ASCII:
  ------------------
  |  Branch (7771:9): [True: 0, False: 33.4k]
  ------------------
 7772|      0|        case TIFF_SETGET_OTHER:
  ------------------
  |  Branch (7772:9): [True: 0, False: 33.4k]
  ------------------
 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: 33.4k]
  ------------------
 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|  33.4k|    }
 7779|  33.2k|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7779:9): [True: 2.53k, False: 30.7k]
  ------------------
 7780|  2.53k|    {
 7781|  2.53k|        TIFFReadDirEntryOutputErr(tif, err, module, fip->field_name, recover);
 7782|  2.53k|        return (0);
 7783|  2.53k|    }
 7784|  30.7k|    return (1);
 7785|  33.2k|}
tif_dirread.c:TIFFReadDirEntryByteArray:
 1397|  1.64k|{
 1398|  1.64k|    enum TIFFReadDirEntryErr err;
 1399|  1.64k|    uint32_t count;
 1400|  1.64k|    void *origdata;
 1401|  1.64k|    uint8_t *data;
 1402|  1.64k|    switch (direntry->tdir_type)
 1403|  1.64k|    {
 1404|    568|        case TIFF_ASCII:
  ------------------
  |  Branch (1404:9): [True: 568, False: 1.07k]
  ------------------
 1405|    598|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1405:9): [True: 30, False: 1.61k]
  ------------------
 1406|  1.43k|        case TIFF_BYTE:
  ------------------
  |  Branch (1406:9): [True: 840, False: 801]
  ------------------
 1407|  1.43k|        case TIFF_SBYTE:
  ------------------
  |  Branch (1407:9): [True: 0, False: 1.64k]
  ------------------
 1408|  1.47k|        case TIFF_SHORT:
  ------------------
  |  Branch (1408:9): [True: 39, False: 1.60k]
  ------------------
 1409|  1.48k|        case TIFF_SSHORT:
  ------------------
  |  Branch (1409:9): [True: 3, False: 1.63k]
  ------------------
 1410|  1.48k|        case TIFF_LONG:
  ------------------
  |  Branch (1410:9): [True: 0, False: 1.64k]
  ------------------
 1411|  1.48k|        case TIFF_SLONG:
  ------------------
  |  Branch (1411:9): [True: 0, False: 1.64k]
  ------------------
 1412|  1.55k|        case TIFF_LONG8:
  ------------------
  |  Branch (1412:9): [True: 70, False: 1.57k]
  ------------------
 1413|  1.55k|        case TIFF_SLONG8:
  ------------------
  |  Branch (1413:9): [True: 0, False: 1.64k]
  ------------------
 1414|  1.55k|            break;
 1415|     91|        default:
  ------------------
  |  Branch (1415:9): [True: 91, False: 1.55k]
  ------------------
 1416|     91|            return (TIFFReadDirEntryErrType);
 1417|  1.64k|    }
 1418|  1.55k|    err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
 1419|  1.55k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1419:9): [True: 342, False: 1.20k]
  |  Branch (1419:43): [True: 445, False: 763]
  ------------------
 1420|    787|    {
 1421|    787|        *value = 0;
 1422|    787|        return (err);
 1423|    787|    }
 1424|    763|    switch (direntry->tdir_type)
 1425|    763|    {
 1426|    501|        case TIFF_ASCII:
  ------------------
  |  Branch (1426:9): [True: 501, False: 262]
  ------------------
 1427|    505|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1427:9): [True: 4, False: 759]
  ------------------
 1428|    654|        case TIFF_BYTE:
  ------------------
  |  Branch (1428:9): [True: 149, False: 614]
  ------------------
 1429|    654|            *value = (uint8_t *)origdata;
 1430|    654|            return (TIFFReadDirEntryErrOk);
 1431|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (1431:9): [True: 0, False: 763]
  ------------------
 1432|      0|        {
 1433|      0|            int8_t *m;
 1434|      0|            uint32_t n;
 1435|      0|            m = (int8_t *)origdata;
 1436|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1436:25): [True: 0, False: 0]
  ------------------
 1437|      0|            {
 1438|      0|                err = TIFFReadDirEntryCheckRangeByteSbyte(*m);
 1439|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1439:21): [True: 0, False: 0]
  ------------------
 1440|      0|                {
 1441|      0|                    _TIFFfreeExt(tif, origdata);
 1442|      0|                    return (err);
 1443|      0|                }
 1444|      0|                m++;
 1445|      0|            }
 1446|      0|            *value = (uint8_t *)origdata;
 1447|      0|            return (TIFFReadDirEntryErrOk);
 1448|      0|        }
 1449|    109|        default:
  ------------------
  |  Branch (1449:9): [True: 109, False: 654]
  ------------------
 1450|    109|            break;
 1451|    763|    }
 1452|    109|    data = (uint8_t *)_TIFFmallocExt(tif, count);
 1453|    109|    if (data == 0)
  ------------------
  |  Branch (1453:9): [True: 0, False: 109]
  ------------------
 1454|      0|    {
 1455|      0|        _TIFFfreeExt(tif, origdata);
 1456|      0|        return (TIFFReadDirEntryErrAlloc);
 1457|      0|    }
 1458|    109|    switch (direntry->tdir_type)
 1459|    109|    {
 1460|     36|        case TIFF_SHORT:
  ------------------
  |  Branch (1460:9): [True: 36, False: 73]
  ------------------
 1461|     36|        {
 1462|     36|            uint16_t *ma;
 1463|     36|            uint8_t *mb;
 1464|     36|            uint32_t n;
 1465|     36|            ma = (uint16_t *)origdata;
 1466|     36|            mb = data;
 1467|     71|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1467:25): [True: 48, False: 23]
  ------------------
 1468|     48|            {
 1469|     48|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     48|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1469:21): [True: 0, False: 48]
  ------------------
 1470|      0|                    TIFFSwabShort(ma);
 1471|     48|                err = TIFFReadDirEntryCheckRangeByteShort(*ma);
 1472|     48|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1472:21): [True: 13, False: 35]
  ------------------
 1473|     13|                    break;
 1474|     35|                *mb++ = (uint8_t)(*ma++);
 1475|     35|            }
 1476|     36|        }
 1477|     36|        break;
 1478|      3|        case TIFF_SSHORT:
  ------------------
  |  Branch (1478:9): [True: 3, False: 106]
  ------------------
 1479|      3|        {
 1480|      3|            int16_t *ma;
 1481|      3|            uint8_t *mb;
 1482|      3|            uint32_t n;
 1483|      3|            ma = (int16_t *)origdata;
 1484|      3|            mb = data;
 1485|    929|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1485:25): [True: 929, False: 0]
  ------------------
 1486|    929|            {
 1487|    929|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    929|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1487:21): [True: 927, False: 2]
  ------------------
 1488|    927|                    TIFFSwabShort((uint16_t *)ma);
 1489|    929|                err = TIFFReadDirEntryCheckRangeByteSshort(*ma);
 1490|    929|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1490:21): [True: 3, False: 926]
  ------------------
 1491|      3|                    break;
 1492|    926|                *mb++ = (uint8_t)(*ma++);
 1493|    926|            }
 1494|      3|        }
 1495|      3|        break;
 1496|      0|        case TIFF_LONG:
  ------------------
  |  Branch (1496:9): [True: 0, False: 109]
  ------------------
 1497|      0|        {
 1498|      0|            uint32_t *ma;
 1499|      0|            uint8_t *mb;
 1500|      0|            uint32_t n;
 1501|      0|            ma = (uint32_t *)origdata;
 1502|      0|            mb = data;
 1503|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1503:25): [True: 0, False: 0]
  ------------------
 1504|      0|            {
 1505|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1505:21): [True: 0, False: 0]
  ------------------
 1506|      0|                    TIFFSwabLong(ma);
 1507|      0|                err = TIFFReadDirEntryCheckRangeByteLong(*ma);
 1508|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1508:21): [True: 0, False: 0]
  ------------------
 1509|      0|                    break;
 1510|      0|                *mb++ = (uint8_t)(*ma++);
 1511|      0|            }
 1512|      0|        }
 1513|      0|        break;
 1514|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (1514:9): [True: 0, False: 109]
  ------------------
 1515|      0|        {
 1516|      0|            int32_t *ma;
 1517|      0|            uint8_t *mb;
 1518|      0|            uint32_t n;
 1519|      0|            ma = (int32_t *)origdata;
 1520|      0|            mb = data;
 1521|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1521:25): [True: 0, False: 0]
  ------------------
 1522|      0|            {
 1523|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1523:21): [True: 0, False: 0]
  ------------------
 1524|      0|                    TIFFSwabLong((uint32_t *)ma);
 1525|      0|                err = TIFFReadDirEntryCheckRangeByteSlong(*ma);
 1526|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1526:21): [True: 0, False: 0]
  ------------------
 1527|      0|                    break;
 1528|      0|                *mb++ = (uint8_t)(*ma++);
 1529|      0|            }
 1530|      0|        }
 1531|      0|        break;
 1532|     70|        case TIFF_LONG8:
  ------------------
  |  Branch (1532:9): [True: 70, False: 39]
  ------------------
 1533|     70|        {
 1534|     70|            uint64_t *ma;
 1535|     70|            uint8_t *mb;
 1536|     70|            uint32_t n;
 1537|     70|            ma = (uint64_t *)origdata;
 1538|     70|            mb = data;
 1539|     94|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1539:25): [True: 92, False: 2]
  ------------------
 1540|     92|            {
 1541|     92|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     92|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1541:21): [True: 0, False: 92]
  ------------------
 1542|      0|                    TIFFSwabLong8(ma);
 1543|     92|                err = TIFFReadDirEntryCheckRangeByteLong8(*ma);
 1544|     92|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1544:21): [True: 68, False: 24]
  ------------------
 1545|     68|                    break;
 1546|     24|                *mb++ = (uint8_t)(*ma++);
 1547|     24|            }
 1548|     70|        }
 1549|     70|        break;
 1550|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (1550:9): [True: 0, False: 109]
  ------------------
 1551|      0|        {
 1552|      0|            int64_t *ma;
 1553|      0|            uint8_t *mb;
 1554|      0|            uint32_t n;
 1555|      0|            ma = (int64_t *)origdata;
 1556|      0|            mb = data;
 1557|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (1557:25): [True: 0, False: 0]
  ------------------
 1558|      0|            {
 1559|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1559:21): [True: 0, False: 0]
  ------------------
 1560|      0|                    TIFFSwabLong8((uint64_t *)ma);
 1561|      0|                err = TIFFReadDirEntryCheckRangeByteSlong8(*ma);
 1562|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1562:21): [True: 0, False: 0]
  ------------------
 1563|      0|                    break;
 1564|      0|                *mb++ = (uint8_t)(*ma++);
 1565|      0|            }
 1566|      0|        }
 1567|      0|        break;
 1568|      0|        default:
  ------------------
  |  Branch (1568:9): [True: 0, False: 109]
  ------------------
 1569|      0|            break;
 1570|    109|    }
 1571|    109|    _TIFFfreeExt(tif, origdata);
 1572|    109|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1572:9): [True: 84, False: 25]
  ------------------
 1573|     84|    {
 1574|     84|        _TIFFfreeExt(tif, data);
 1575|     84|        return (err);
 1576|     84|    }
 1577|     25|    *value = data;
 1578|     25|    return (TIFFReadDirEntryErrOk);
 1579|    109|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteShort:
 3655|     55|{
 3656|     55|    if (value > 0xFF)
  ------------------
  |  Branch (3656:9): [True: 13, False: 42]
  ------------------
 3657|     13|        return (TIFFReadDirEntryErrRange);
 3658|     42|    else
 3659|     42|        return (TIFFReadDirEntryErrOk);
 3660|     55|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSshort:
 3664|    933|{
 3665|    933|    if ((value < 0) || (value > 0xFF))
  ------------------
  |  Branch (3665:9): [True: 4, False: 929]
  |  Branch (3665:24): [True: 3, False: 926]
  ------------------
 3666|      7|        return (TIFFReadDirEntryErrRange);
 3667|    926|    else
 3668|    926|        return (TIFFReadDirEntryErrOk);
 3669|    933|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteSlong:
 3682|      4|{
 3683|      4|    if ((value < 0) || (value > 0xFF))
  ------------------
  |  Branch (3683:9): [True: 4, False: 0]
  |  Branch (3683:24): [True: 0, False: 0]
  ------------------
 3684|      4|        return (TIFFReadDirEntryErrRange);
 3685|      0|    else
 3686|      0|        return (TIFFReadDirEntryErrOk);
 3687|      4|}
tif_dirread.c:TIFFReadDirEntryCheckRangeByteLong8:
 3691|     92|{
 3692|     92|    if (value > 0xFF)
  ------------------
  |  Branch (3692:9): [True: 68, False: 24]
  ------------------
 3693|     68|        return (TIFFReadDirEntryErrRange);
 3694|     24|    else
 3695|     24|        return (TIFFReadDirEntryErrOk);
 3696|     92|}
tif_dirread.c:TIFFReadDirEntryByte:
  300|     19|{
  301|     19|    enum TIFFReadDirEntryErr err;
  302|     19|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (302:9): [True: 4, False: 15]
  ------------------
  303|      4|        return (TIFFReadDirEntryErrCount);
  304|     15|    switch (direntry->tdir_type)
  305|     15|    {
  306|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (306:9): [True: 0, False: 15]
  ------------------
  307|      0|        case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with
  ------------------
  |  Branch (307:9): [True: 0, False: 15]
  ------------------
  308|       |                                field_readcount==1 */
  309|      0|            TIFFReadDirEntryCheckedByte(tif, direntry, value);
  310|      0|            return (TIFFReadDirEntryErrOk);
  311|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (311:9): [True: 0, False: 15]
  ------------------
  312|      0|        {
  313|      0|            int8_t m;
  314|      0|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  315|      0|            err = TIFFReadDirEntryCheckRangeByteSbyte(m);
  316|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (316:17): [True: 0, False: 0]
  ------------------
  317|      0|                return (err);
  318|      0|            *value = (uint8_t)m;
  319|      0|            return (TIFFReadDirEntryErrOk);
  320|      0|        }
  321|      7|        case TIFF_SHORT:
  ------------------
  |  Branch (321:9): [True: 7, False: 8]
  ------------------
  322|      7|        {
  323|      7|            uint16_t m;
  324|      7|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  325|      7|            err = TIFFReadDirEntryCheckRangeByteShort(m);
  326|      7|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (326:17): [True: 0, False: 7]
  ------------------
  327|      0|                return (err);
  328|      7|            *value = (uint8_t)m;
  329|      7|            return (TIFFReadDirEntryErrOk);
  330|      7|        }
  331|      4|        case TIFF_SSHORT:
  ------------------
  |  Branch (331:9): [True: 4, False: 11]
  ------------------
  332|      4|        {
  333|      4|            int16_t m;
  334|      4|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  335|      4|            err = TIFFReadDirEntryCheckRangeByteSshort(m);
  336|      4|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (336:17): [True: 4, False: 0]
  ------------------
  337|      4|                return (err);
  338|      0|            *value = (uint8_t)m;
  339|      0|            return (TIFFReadDirEntryErrOk);
  340|      4|        }
  341|      0|        case TIFF_LONG:
  ------------------
  |  Branch (341:9): [True: 0, False: 15]
  ------------------
  342|      0|        {
  343|      0|            uint32_t m;
  344|      0|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  345|      0|            err = TIFFReadDirEntryCheckRangeByteLong(m);
  346|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (346:17): [True: 0, False: 0]
  ------------------
  347|      0|                return (err);
  348|      0|            *value = (uint8_t)m;
  349|      0|            return (TIFFReadDirEntryErrOk);
  350|      0|        }
  351|      4|        case TIFF_SLONG:
  ------------------
  |  Branch (351:9): [True: 4, False: 11]
  ------------------
  352|      4|        {
  353|      4|            int32_t m;
  354|      4|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  355|      4|            err = TIFFReadDirEntryCheckRangeByteSlong(m);
  356|      4|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (356:17): [True: 4, False: 0]
  ------------------
  357|      4|                return (err);
  358|      0|            *value = (uint8_t)m;
  359|      0|            return (TIFFReadDirEntryErrOk);
  360|      4|        }
  361|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (361:9): [True: 0, False: 15]
  ------------------
  362|      0|        {
  363|      0|            uint64_t m;
  364|      0|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  365|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (365:17): [True: 0, False: 0]
  ------------------
  366|      0|                return (err);
  367|      0|            err = TIFFReadDirEntryCheckRangeByteLong8(m);
  368|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (368:17): [True: 0, False: 0]
  ------------------
  369|      0|                return (err);
  370|      0|            *value = (uint8_t)m;
  371|      0|            return (TIFFReadDirEntryErrOk);
  372|      0|        }
  373|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (373:9): [True: 0, False: 15]
  ------------------
  374|      0|        {
  375|      0|            int64_t m;
  376|      0|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  377|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (377:17): [True: 0, False: 0]
  ------------------
  378|      0|                return (err);
  379|      0|            err = TIFFReadDirEntryCheckRangeByteSlong8(m);
  380|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (380:17): [True: 0, False: 0]
  ------------------
  381|      0|                return (err);
  382|      0|            *value = (uint8_t)m;
  383|      0|            return (TIFFReadDirEntryErrOk);
  384|      0|        }
  385|      0|        default:
  ------------------
  |  Branch (385:9): [True: 0, False: 15]
  ------------------
  386|      0|            return (TIFFReadDirEntryErrType);
  387|     15|    }
  388|     15|}
tif_dirread.c:TIFFReadDirEntryLong:
  657|  1.99k|{
  658|  1.99k|    enum TIFFReadDirEntryErr err;
  659|  1.99k|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (659:9): [True: 95, False: 1.90k]
  ------------------
  660|     95|        return (TIFFReadDirEntryErrCount);
  661|  1.90k|    switch (direntry->tdir_type)
  662|  1.90k|    {
  663|      2|        case TIFF_BYTE:
  ------------------
  |  Branch (663:9): [True: 2, False: 1.90k]
  ------------------
  664|      2|        {
  665|      2|            uint8_t m;
  666|      2|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  667|      2|            *value = (uint32_t)m;
  668|      2|            return (TIFFReadDirEntryErrOk);
  669|      0|        }
  670|     33|        case TIFF_SBYTE:
  ------------------
  |  Branch (670:9): [True: 33, False: 1.86k]
  ------------------
  671|     33|        {
  672|     33|            int8_t m;
  673|     33|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  674|     33|            err = TIFFReadDirEntryCheckRangeLongSbyte(m);
  675|     33|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (675:17): [True: 0, False: 33]
  ------------------
  676|      0|                return (err);
  677|     33|            *value = (uint32_t)m;
  678|     33|            return (TIFFReadDirEntryErrOk);
  679|     33|        }
  680|  1.78k|        case TIFF_SHORT:
  ------------------
  |  Branch (680:9): [True: 1.78k, False: 116]
  ------------------
  681|  1.78k|        {
  682|  1.78k|            uint16_t m;
  683|  1.78k|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  684|  1.78k|            *value = (uint32_t)m;
  685|  1.78k|            return (TIFFReadDirEntryErrOk);
  686|     33|        }
  687|     13|        case TIFF_SSHORT:
  ------------------
  |  Branch (687:9): [True: 13, False: 1.88k]
  ------------------
  688|     13|        {
  689|     13|            int16_t m;
  690|     13|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  691|     13|            err = TIFFReadDirEntryCheckRangeLongSshort(m);
  692|     13|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (692:17): [True: 7, False: 6]
  ------------------
  693|      7|                return (err);
  694|      6|            *value = (uint32_t)m;
  695|      6|            return (TIFFReadDirEntryErrOk);
  696|     13|        }
  697|     61|        case TIFF_LONG:
  ------------------
  |  Branch (697:9): [True: 61, False: 1.84k]
  ------------------
  698|     63|        case TIFF_IFD:
  ------------------
  |  Branch (698:9): [True: 2, False: 1.90k]
  ------------------
  699|     63|            TIFFReadDirEntryCheckedLong(tif, direntry, value);
  700|     63|            return (TIFFReadDirEntryErrOk);
  701|      4|        case TIFF_SLONG:
  ------------------
  |  Branch (701:9): [True: 4, False: 1.89k]
  ------------------
  702|      4|        {
  703|      4|            int32_t m;
  704|      4|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  705|      4|            err = TIFFReadDirEntryCheckRangeLongSlong(m);
  706|      4|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (706:17): [True: 0, False: 4]
  ------------------
  707|      0|                return (err);
  708|      4|            *value = (uint32_t)m;
  709|      4|            return (TIFFReadDirEntryErrOk);
  710|      4|        }
  711|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (711:9): [True: 0, False: 1.90k]
  ------------------
  712|      0|        case TIFF_IFD8:
  ------------------
  |  Branch (712:9): [True: 0, False: 1.90k]
  ------------------
  713|      0|        {
  714|      0|            uint64_t m;
  715|      0|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
  716|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (716:17): [True: 0, False: 0]
  ------------------
  717|      0|                return (err);
  718|      0|            err = TIFFReadDirEntryCheckRangeLongLong8(m);
  719|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (719:17): [True: 0, False: 0]
  ------------------
  720|      0|                return (err);
  721|      0|            *value = (uint32_t)m;
  722|      0|            return (TIFFReadDirEntryErrOk);
  723|      0|        }
  724|      1|        case TIFF_SLONG8:
  ------------------
  |  Branch (724:9): [True: 1, False: 1.90k]
  ------------------
  725|      1|        {
  726|      1|            int64_t m;
  727|      1|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  728|      1|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (728:17): [True: 0, False: 1]
  ------------------
  729|      0|                return (err);
  730|      1|            err = TIFFReadDirEntryCheckRangeLongSlong8(m);
  731|      1|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (731:17): [True: 1, False: 0]
  ------------------
  732|      1|                return (err);
  733|      0|            *value = (uint32_t)m;
  734|      0|            return (TIFFReadDirEntryErrOk);
  735|      1|        }
  736|      0|        default:
  ------------------
  |  Branch (736:9): [True: 0, False: 1.90k]
  ------------------
  737|      0|            return (TIFFReadDirEntryErrType);
  738|  1.90k|    }
  739|  1.90k|} /*-- TIFFReadDirEntryLong() --*/
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSbyte:
 3871|     33|{
 3872|     33|    if (value < 0)
  ------------------
  |  Branch (3872:9): [True: 0, False: 33]
  ------------------
 3873|      0|        return (TIFFReadDirEntryErrRange);
 3874|     33|    else
 3875|     33|        return (TIFFReadDirEntryErrOk);
 3876|     33|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSshort:
 3880|     13|{
 3881|     13|    if (value < 0)
  ------------------
  |  Branch (3881:9): [True: 7, False: 6]
  ------------------
 3882|      7|        return (TIFFReadDirEntryErrRange);
 3883|      6|    else
 3884|      6|        return (TIFFReadDirEntryErrOk);
 3885|     13|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSlong:
 3889|      4|{
 3890|      4|    if (value < 0)
  ------------------
  |  Branch (3890:9): [True: 0, False: 4]
  ------------------
 3891|      0|        return (TIFFReadDirEntryErrRange);
 3892|      4|    else
 3893|      4|        return (TIFFReadDirEntryErrOk);
 3894|      4|}
tif_dirread.c:TIFFReadDirEntryCheckRangeLongSlong8:
 3907|      1|{
 3908|      1|    if ((value < 0) || (value > (int64_t)UINT32_MAX))
  ------------------
  |  Branch (3908:9): [True: 0, False: 1]
  |  Branch (3908:24): [True: 1, False: 0]
  ------------------
 3909|      1|        return (TIFFReadDirEntryErrRange);
 3910|      0|    else
 3911|      0|        return (TIFFReadDirEntryErrOk);
 3912|      1|}
tif_dirread.c:TIFFReadDirEntryLong8:
  821|     38|{
  822|     38|    enum TIFFReadDirEntryErr err;
  823|     38|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (823:9): [True: 37, False: 1]
  ------------------
  824|     37|        return (TIFFReadDirEntryErrCount);
  825|      1|    switch (direntry->tdir_type)
  826|      1|    {
  827|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (827:9): [True: 0, False: 1]
  ------------------
  828|      0|        {
  829|      0|            uint8_t m;
  830|      0|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  831|      0|            *value = (uint64_t)m;
  832|      0|            return (TIFFReadDirEntryErrOk);
  833|      0|        }
  834|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (834:9): [True: 0, False: 1]
  ------------------
  835|      0|        {
  836|      0|            int8_t m;
  837|      0|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  838|      0|            err = TIFFReadDirEntryCheckRangeLong8Sbyte(m);
  839|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (839:17): [True: 0, False: 0]
  ------------------
  840|      0|                return (err);
  841|      0|            *value = (uint64_t)m;
  842|      0|            return (TIFFReadDirEntryErrOk);
  843|      0|        }
  844|      1|        case TIFF_SHORT:
  ------------------
  |  Branch (844:9): [True: 1, False: 0]
  ------------------
  845|      1|        {
  846|      1|            uint16_t m;
  847|      1|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  848|      1|            *value = (uint64_t)m;
  849|      1|            return (TIFFReadDirEntryErrOk);
  850|      0|        }
  851|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (851:9): [True: 0, False: 1]
  ------------------
  852|      0|        {
  853|      0|            int16_t m;
  854|      0|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
  855|      0|            err = TIFFReadDirEntryCheckRangeLong8Sshort(m);
  856|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (856:17): [True: 0, False: 0]
  ------------------
  857|      0|                return (err);
  858|      0|            *value = (uint64_t)m;
  859|      0|            return (TIFFReadDirEntryErrOk);
  860|      0|        }
  861|      0|        case TIFF_LONG:
  ------------------
  |  Branch (861:9): [True: 0, False: 1]
  ------------------
  862|      0|        case TIFF_IFD:
  ------------------
  |  Branch (862:9): [True: 0, False: 1]
  ------------------
  863|      0|        {
  864|      0|            uint32_t m;
  865|      0|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
  866|      0|            *value = (uint64_t)m;
  867|      0|            return (TIFFReadDirEntryErrOk);
  868|      0|        }
  869|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (869:9): [True: 0, False: 1]
  ------------------
  870|      0|        {
  871|      0|            int32_t m;
  872|      0|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
  873|      0|            err = TIFFReadDirEntryCheckRangeLong8Slong(m);
  874|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (874:17): [True: 0, False: 0]
  ------------------
  875|      0|                return (err);
  876|      0|            *value = (uint64_t)m;
  877|      0|            return (TIFFReadDirEntryErrOk);
  878|      0|        }
  879|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (879:9): [True: 0, False: 1]
  ------------------
  880|      0|        case TIFF_IFD8:
  ------------------
  |  Branch (880:9): [True: 0, False: 1]
  ------------------
  881|      0|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
  882|      0|            return (err);
  883|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (883:9): [True: 0, False: 1]
  ------------------
  884|      0|        {
  885|      0|            int64_t m;
  886|      0|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
  887|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (887:17): [True: 0, False: 0]
  ------------------
  888|      0|                return (err);
  889|      0|            err = TIFFReadDirEntryCheckRangeLong8Slong8(m);
  890|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (890:17): [True: 0, False: 0]
  ------------------
  891|      0|                return (err);
  892|      0|            *value = (uint64_t)m;
  893|      0|            return (TIFFReadDirEntryErrOk);
  894|      0|        }
  895|      0|        default:
  ------------------
  |  Branch (895:9): [True: 0, False: 1]
  ------------------
  896|      0|            return (TIFFReadDirEntryErrType);
  897|      1|    }
  898|      1|} /*-- TIFFReadDirEntryLong8() --*/
tif_dirread.c:TIFFReadDirEntryCheckRangeLong8Sshort:
 3954|      6|{
 3955|      6|    if (value < 0)
  ------------------
  |  Branch (3955:9): [True: 0, False: 6]
  ------------------
 3956|      0|        return (TIFFReadDirEntryErrRange);
 3957|      6|    else
 3958|      6|        return (TIFFReadDirEntryErrOk);
 3959|      6|}
tif_dirread.c:TIFFReadDirEntryFloat:
  972|    462|{
  973|    462|    enum TIFFReadDirEntryErr err;
  974|    462|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (974:9): [True: 255, False: 207]
  ------------------
  975|    255|        return (TIFFReadDirEntryErrCount);
  976|    207|    switch (direntry->tdir_type)
  977|    207|    {
  978|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (978:9): [True: 0, False: 207]
  ------------------
  979|      0|        {
  980|      0|            uint8_t m;
  981|      0|            TIFFReadDirEntryCheckedByte(tif, direntry, &m);
  982|      0|            *value = (float)m;
  983|      0|            return (TIFFReadDirEntryErrOk);
  984|      0|        }
  985|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (985:9): [True: 0, False: 207]
  ------------------
  986|      0|        {
  987|      0|            int8_t m;
  988|      0|            TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
  989|      0|            *value = (float)m;
  990|      0|            return (TIFFReadDirEntryErrOk);
  991|      0|        }
  992|      2|        case TIFF_SHORT:
  ------------------
  |  Branch (992:9): [True: 2, False: 205]
  ------------------
  993|      2|        {
  994|      2|            uint16_t m;
  995|      2|            TIFFReadDirEntryCheckedShort(tif, direntry, &m);
  996|      2|            *value = (float)m;
  997|      2|            return (TIFFReadDirEntryErrOk);
  998|      0|        }
  999|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (999:9): [True: 0, False: 207]
  ------------------
 1000|      0|        {
 1001|      0|            int16_t m;
 1002|      0|            TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
 1003|      0|            *value = (float)m;
 1004|      0|            return (TIFFReadDirEntryErrOk);
 1005|      0|        }
 1006|      0|        case TIFF_LONG:
  ------------------
  |  Branch (1006:9): [True: 0, False: 207]
  ------------------
 1007|      0|        {
 1008|      0|            uint32_t m;
 1009|      0|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
 1010|      0|            *value = (float)m;
 1011|      0|            return (TIFFReadDirEntryErrOk);
 1012|      0|        }
 1013|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (1013:9): [True: 0, False: 207]
  ------------------
 1014|      0|        {
 1015|      0|            int32_t m;
 1016|      0|            TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
 1017|      0|            *value = (float)m;
 1018|      0|            return (TIFFReadDirEntryErrOk);
 1019|      0|        }
 1020|      3|        case TIFF_LONG8:
  ------------------
  |  Branch (1020:9): [True: 3, False: 204]
  ------------------
 1021|      3|        {
 1022|      3|            uint64_t m;
 1023|      3|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
 1024|      3|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1024:17): [True: 0, False: 3]
  ------------------
 1025|      0|                return (err);
 1026|      3|            *value = (float)m;
 1027|      3|            return (TIFFReadDirEntryErrOk);
 1028|      3|        }
 1029|      4|        case TIFF_SLONG8:
  ------------------
  |  Branch (1029:9): [True: 4, False: 203]
  ------------------
 1030|      4|        {
 1031|      4|            int64_t m;
 1032|      4|            err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
 1033|      4|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1033:17): [True: 0, False: 4]
  ------------------
 1034|      0|                return (err);
 1035|      4|            *value = (float)m;
 1036|      4|            return (TIFFReadDirEntryErrOk);
 1037|      4|        }
 1038|    172|        case TIFF_RATIONAL:
  ------------------
  |  Branch (1038:9): [True: 172, False: 35]
  ------------------
 1039|    172|        {
 1040|    172|            double m;
 1041|    172|            err = TIFFReadDirEntryCheckedRational(tif, direntry, &m);
 1042|    172|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1042:17): [True: 3, False: 169]
  ------------------
 1043|      3|                return (err);
 1044|    169|            *value = (float)m;
 1045|    169|            return (TIFFReadDirEntryErrOk);
 1046|    172|        }
 1047|      0|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (1047:9): [True: 0, False: 207]
  ------------------
 1048|      0|        {
 1049|      0|            double m;
 1050|      0|            err = TIFFReadDirEntryCheckedSrational(tif, direntry, &m);
 1051|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1051:17): [True: 0, False: 0]
  ------------------
 1052|      0|                return (err);
 1053|      0|            *value = (float)m;
 1054|      0|            return (TIFFReadDirEntryErrOk);
 1055|      0|        }
 1056|      0|        case TIFF_FLOAT:
  ------------------
  |  Branch (1056:9): [True: 0, False: 207]
  ------------------
 1057|      0|            TIFFReadDirEntryCheckedFloat(tif, direntry, value);
 1058|      0|            return (TIFFReadDirEntryErrOk);
 1059|      0|        case TIFF_DOUBLE:
  ------------------
  |  Branch (1059:9): [True: 0, False: 207]
  ------------------
 1060|      0|        {
 1061|      0|            double m;
 1062|      0|            err = TIFFReadDirEntryCheckedDouble(tif, direntry, &m);
 1063|      0|            if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (1063:17): [True: 0, False: 0]
  ------------------
 1064|      0|                return (err);
 1065|      0|            if ((m > (double)FLT_MAX) || (m < -(double)FLT_MAX))
  ------------------
  |  Branch (1065:17): [True: 0, False: 0]
  |  Branch (1065:42): [True: 0, False: 0]
  ------------------
 1066|      0|                return (TIFFReadDirEntryErrRange);
 1067|      0|            *value = (float)m;
 1068|      0|            return (TIFFReadDirEntryErrOk);
 1069|      0|        }
 1070|     26|        default:
  ------------------
  |  Branch (1070:9): [True: 26, False: 181]
  ------------------
 1071|     26|            return (TIFFReadDirEntryErrType);
 1072|    207|    }
 1073|    207|}
tif_dirread.c:TIFFReadDirEntryCheckedRational:
 3494|    172|{
 3495|    172|    UInt64Aligned_t m;
 3496|       |
 3497|    172|    assert(sizeof(double) == 8);
  ------------------
  |  Branch (3497:5): [True: 0, Folded]
  |  Branch (3497:5): [True: 172, Folded]
  ------------------
 3498|    172|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (3498:5): [True: 0, Folded]
  |  Branch (3498:5): [True: 172, Folded]
  ------------------
 3499|    172|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (3499:5): [True: 0, Folded]
  |  Branch (3499:5): [True: 172, Folded]
  ------------------
 3500|    172|    if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    172|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (3500:9): [True: 172, False: 0]
  ------------------
 3501|    172|    {
 3502|    172|        enum TIFFReadDirEntryErr err;
 3503|    172|        uint32_t offset = direntry->tdir_offset.toff_long;
 3504|    172|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    172|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3504:13): [True: 0, False: 172]
  ------------------
 3505|      0|            TIFFSwabLong(&offset);
 3506|    172|        err = TIFFReadDirEntryData(tif, offset, 8, m.i);
 3507|    172|        if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (3507:13): [True: 3, False: 169]
  ------------------
 3508|      3|            return (err);
 3509|    172|    }
 3510|      0|    else
 3511|      0|        m.l = direntry->tdir_offset.toff_long8;
 3512|    169|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    169|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3512:9): [True: 0, False: 169]
  ------------------
 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|    169|    if (m.i[0] == 0 || m.i[1] == 0)
  ------------------
  |  Branch (3517:9): [True: 0, False: 169]
  |  Branch (3517:24): [True: 17, False: 152]
  ------------------
 3518|     17|        *value = 0.0;
 3519|    152|    else
 3520|    152|        *value = (double)m.i[0] / (double)m.i[1];
 3521|    169|    return (TIFFReadDirEntryErrOk);
 3522|    172|}
tif_dirread.c:TIFFReadDirEntryIfd8:
 1166|      1|{
 1167|      1|    enum TIFFReadDirEntryErr err;
 1168|      1|    if (direntry->tdir_count != 1)
  ------------------
  |  Branch (1168:9): [True: 0, False: 1]
  ------------------
 1169|      0|        return (TIFFReadDirEntryErrCount);
 1170|      1|    switch (direntry->tdir_type)
 1171|      1|    {
 1172|      1|        case TIFF_LONG:
  ------------------
  |  Branch (1172:9): [True: 1, False: 0]
  ------------------
 1173|      1|        case TIFF_IFD:
  ------------------
  |  Branch (1173:9): [True: 0, False: 1]
  ------------------
 1174|      1|        {
 1175|      1|            uint32_t m;
 1176|      1|            TIFFReadDirEntryCheckedLong(tif, direntry, &m);
 1177|      1|            *value = (uint64_t)m;
 1178|      1|            return (TIFFReadDirEntryErrOk);
 1179|      1|        }
 1180|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (1180:9): [True: 0, False: 1]
  ------------------
 1181|      0|        case TIFF_IFD8:
  ------------------
  |  Branch (1181:9): [True: 0, False: 1]
  ------------------
 1182|      0|            err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
 1183|      0|            return (err);
 1184|      0|        default:
  ------------------
  |  Branch (1184:9): [True: 0, False: 1]
  ------------------
 1185|      0|            return (TIFFReadDirEntryErrType);
 1186|      1|    }
 1187|      1|}
tif_dirread.c:TIFFReadDirEntrySbyteArray:
 1583|    148|{
 1584|    148|    enum TIFFReadDirEntryErr err;
 1585|    148|    uint32_t count;
 1586|    148|    void *origdata;
 1587|    148|    int8_t *data;
 1588|    148|    switch (direntry->tdir_type)
 1589|    148|    {
 1590|      0|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1590:9): [True: 0, False: 148]
  ------------------
 1591|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1591:9): [True: 0, False: 148]
  ------------------
 1592|    148|        case TIFF_SBYTE:
  ------------------
  |  Branch (1592:9): [True: 148, False: 0]
  ------------------
 1593|    148|        case TIFF_SHORT:
  ------------------
  |  Branch (1593:9): [True: 0, False: 148]
  ------------------
 1594|    148|        case TIFF_SSHORT:
  ------------------
  |  Branch (1594:9): [True: 0, False: 148]
  ------------------
 1595|    148|        case TIFF_LONG:
  ------------------
  |  Branch (1595:9): [True: 0, False: 148]
  ------------------
 1596|    148|        case TIFF_SLONG:
  ------------------
  |  Branch (1596:9): [True: 0, False: 148]
  ------------------
 1597|    148|        case TIFF_LONG8:
  ------------------
  |  Branch (1597:9): [True: 0, False: 148]
  ------------------
 1598|    148|        case TIFF_SLONG8:
  ------------------
  |  Branch (1598:9): [True: 0, False: 148]
  ------------------
 1599|    148|            break;
 1600|      0|        default:
  ------------------
  |  Branch (1600:9): [True: 0, False: 148]
  ------------------
 1601|      0|            return (TIFFReadDirEntryErrType);
 1602|    148|    }
 1603|    148|    err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
 1604|    148|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1604:9): [True: 61, False: 87]
  |  Branch (1604:43): [True: 15, False: 72]
  ------------------
 1605|     76|    {
 1606|     76|        *value = 0;
 1607|     76|        return (err);
 1608|     76|    }
 1609|     72|    switch (direntry->tdir_type)
 1610|     72|    {
 1611|      0|        case TIFF_UNDEFINED:
  ------------------
  |  Branch (1611:9): [True: 0, False: 72]
  ------------------
 1612|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1612:9): [True: 0, False: 72]
  ------------------
 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|     72|        case TIFF_SBYTE:
  ------------------
  |  Branch (1630:9): [True: 72, False: 0]
  ------------------
 1631|     72|            *value = (int8_t *)origdata;
 1632|     72|            return (TIFFReadDirEntryErrOk);
 1633|      0|        default:
  ------------------
  |  Branch (1633:9): [True: 0, False: 72]
  ------------------
 1634|      0|            break;
 1635|     72|    }
 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|     13|{
 1946|     13|    enum TIFFReadDirEntryErr err;
 1947|     13|    uint32_t count;
 1948|     13|    void *origdata;
 1949|     13|    int16_t *data;
 1950|     13|    switch (direntry->tdir_type)
 1951|     13|    {
 1952|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (1952:9): [True: 0, False: 13]
  ------------------
 1953|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (1953:9): [True: 0, False: 13]
  ------------------
 1954|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1954:9): [True: 0, False: 13]
  ------------------
 1955|     13|        case TIFF_SSHORT:
  ------------------
  |  Branch (1955:9): [True: 13, False: 0]
  ------------------
 1956|     13|        case TIFF_LONG:
  ------------------
  |  Branch (1956:9): [True: 0, False: 13]
  ------------------
 1957|     13|        case TIFF_SLONG:
  ------------------
  |  Branch (1957:9): [True: 0, False: 13]
  ------------------
 1958|     13|        case TIFF_LONG8:
  ------------------
  |  Branch (1958:9): [True: 0, False: 13]
  ------------------
 1959|     13|        case TIFF_SLONG8:
  ------------------
  |  Branch (1959:9): [True: 0, False: 13]
  ------------------
 1960|     13|            break;
 1961|      0|        default:
  ------------------
  |  Branch (1961:9): [True: 0, False: 13]
  ------------------
 1962|      0|            return (TIFFReadDirEntryErrType);
 1963|     13|    }
 1964|     13|    err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
 1965|     13|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (1965:9): [True: 12, False: 1]
  |  Branch (1965:43): [True: 1, False: 0]
  ------------------
 1966|     13|    {
 1967|     13|        *value = 0;
 1968|     13|        return (err);
 1969|     13|    }
 1970|      0|    switch (direntry->tdir_type)
 1971|      0|    {
 1972|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (1972:9): [True: 0, False: 0]
  ------------------
 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|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (1992:9): [True: 0, False: 0]
  ------------------
 1993|      0|            *value = (int16_t *)origdata;
 1994|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1994:17): [True: 0, False: 0]
  ------------------
 1995|      0|                TIFFSwabArrayOfShort((uint16_t *)(*value), count);
 1996|      0|            return (TIFFReadDirEntryErrOk);
 1997|      0|        default:
  ------------------
  |  Branch (1997:9): [True: 0, False: 0]
  ------------------
 1998|      0|            break;
 1999|      0|    }
 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|    255|{
 2119|    255|    enum TIFFReadDirEntryErr err;
 2120|    255|    uint32_t count;
 2121|    255|    void *origdata;
 2122|    255|    uint32_t *data;
 2123|    255|    switch (direntry->tdir_type)
 2124|    255|    {
 2125|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2125:9): [True: 0, False: 255]
  ------------------
 2126|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2126:9): [True: 0, False: 255]
  ------------------
 2127|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2127:9): [True: 0, False: 255]
  ------------------
 2128|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2128:9): [True: 0, False: 255]
  ------------------
 2129|    255|        case TIFF_LONG:
  ------------------
  |  Branch (2129:9): [True: 255, False: 0]
  ------------------
 2130|    255|        case TIFF_SLONG:
  ------------------
  |  Branch (2130:9): [True: 0, False: 255]
  ------------------
 2131|    255|        case TIFF_LONG8:
  ------------------
  |  Branch (2131:9): [True: 0, False: 255]
  ------------------
 2132|    255|        case TIFF_SLONG8:
  ------------------
  |  Branch (2132:9): [True: 0, False: 255]
  ------------------
 2133|    255|        case TIFF_IFD:
  ------------------
  |  Branch (2133:9): [True: 0, False: 255]
  ------------------
 2134|    255|        case TIFF_IFD8:
  ------------------
  |  Branch (2134:9): [True: 0, False: 255]
  ------------------
 2135|    255|            break;
 2136|      0|        default:
  ------------------
  |  Branch (2136:9): [True: 0, False: 255]
  ------------------
 2137|      0|            return (TIFFReadDirEntryErrType);
 2138|    255|    }
 2139|    255|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2140|    255|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2140:9): [True: 95, False: 160]
  |  Branch (2140:43): [True: 13, False: 147]
  ------------------
 2141|    108|    {
 2142|    108|        *value = 0;
 2143|    108|        return (err);
 2144|    108|    }
 2145|    147|    switch (direntry->tdir_type)
 2146|    147|    {
 2147|    147|        case TIFF_LONG:
  ------------------
  |  Branch (2147:9): [True: 147, False: 0]
  ------------------
 2148|    147|        case TIFF_IFD:
  ------------------
  |  Branch (2148:9): [True: 0, False: 147]
  ------------------
 2149|    147|            *value = (uint32_t *)origdata;
 2150|    147|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    147|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2150:17): [True: 0, False: 147]
  ------------------
 2151|      0|                TIFFSwabArrayOfLong(*value, count);
 2152|    147|            return (TIFFReadDirEntryErrOk);
 2153|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2153:9): [True: 0, False: 147]
  ------------------
 2154|      0|        {
 2155|      0|            int32_t *m;
 2156|      0|            uint32_t n;
 2157|      0|            m = (int32_t *)origdata;
 2158|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2158:25): [True: 0, False: 0]
  ------------------
 2159|      0|            {
 2160|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2160:21): [True: 0, False: 0]
  ------------------
 2161|      0|                    TIFFSwabLong((uint32_t *)m);
 2162|      0|                err = TIFFReadDirEntryCheckRangeLongSlong(*m);
 2163|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2163:21): [True: 0, False: 0]
  ------------------
 2164|      0|                {
 2165|      0|                    _TIFFfreeExt(tif, origdata);
 2166|      0|                    return (err);
 2167|      0|                }
 2168|      0|                m++;
 2169|      0|            }
 2170|      0|            *value = (uint32_t *)origdata;
 2171|      0|            return (TIFFReadDirEntryErrOk);
 2172|      0|        }
 2173|      0|        default:
  ------------------
  |  Branch (2173:9): [True: 0, False: 147]
  ------------------
 2174|      0|            break;
 2175|    147|    }
 2176|      0|    data = (uint32_t *)_TIFFCheckMalloc(tif, count, sizeof(uint32_t),
 2177|      0|                                        "TIFFReadDirEntryLongArray");
 2178|      0|    if (data == 0)
  ------------------
  |  Branch (2178:9): [True: 0, False: 0]
  ------------------
 2179|      0|    {
 2180|      0|        _TIFFfreeExt(tif, origdata);
 2181|      0|        return (TIFFReadDirEntryErrAlloc);
 2182|      0|    }
 2183|      0|    switch (direntry->tdir_type)
 2184|      0|    {
 2185|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2185:9): [True: 0, False: 0]
  ------------------
 2186|      0|        {
 2187|      0|            uint8_t *ma;
 2188|      0|            uint32_t *mb;
 2189|      0|            uint32_t n;
 2190|      0|            ma = (uint8_t *)origdata;
 2191|      0|            mb = data;
 2192|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2192:25): [True: 0, False: 0]
  ------------------
 2193|      0|                *mb++ = (uint32_t)(*ma++);
 2194|      0|        }
 2195|      0|        break;
 2196|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2196:9): [True: 0, False: 0]
  ------------------
 2197|      0|        {
 2198|      0|            int8_t *ma;
 2199|      0|            uint32_t *mb;
 2200|      0|            uint32_t n;
 2201|      0|            ma = (int8_t *)origdata;
 2202|      0|            mb = data;
 2203|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2203:25): [True: 0, False: 0]
  ------------------
 2204|      0|            {
 2205|      0|                err = TIFFReadDirEntryCheckRangeLongSbyte(*ma);
 2206|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2206:21): [True: 0, False: 0]
  ------------------
 2207|      0|                    break;
 2208|      0|                *mb++ = (uint32_t)(*ma++);
 2209|      0|            }
 2210|      0|        }
 2211|      0|        break;
 2212|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2212:9): [True: 0, False: 0]
  ------------------
 2213|      0|        {
 2214|      0|            uint16_t *ma;
 2215|      0|            uint32_t *mb;
 2216|      0|            uint32_t n;
 2217|      0|            ma = (uint16_t *)origdata;
 2218|      0|            mb = data;
 2219|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2219:25): [True: 0, False: 0]
  ------------------
 2220|      0|            {
 2221|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2221:21): [True: 0, False: 0]
  ------------------
 2222|      0|                    TIFFSwabShort(ma);
 2223|      0|                *mb++ = (uint32_t)(*ma++);
 2224|      0|            }
 2225|      0|        }
 2226|      0|        break;
 2227|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2227:9): [True: 0, False: 0]
  ------------------
 2228|      0|        {
 2229|      0|            int16_t *ma;
 2230|      0|            uint32_t *mb;
 2231|      0|            uint32_t n;
 2232|      0|            ma = (int16_t *)origdata;
 2233|      0|            mb = data;
 2234|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2234:25): [True: 0, False: 0]
  ------------------
 2235|      0|            {
 2236|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2236:21): [True: 0, False: 0]
  ------------------
 2237|      0|                    TIFFSwabShort((uint16_t *)ma);
 2238|      0|                err = TIFFReadDirEntryCheckRangeLongSshort(*ma);
 2239|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2239:21): [True: 0, False: 0]
  ------------------
 2240|      0|                    break;
 2241|      0|                *mb++ = (uint32_t)(*ma++);
 2242|      0|            }
 2243|      0|        }
 2244|      0|        break;
 2245|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2245:9): [True: 0, False: 0]
  ------------------
 2246|      0|        case TIFF_IFD8:
  ------------------
  |  Branch (2246:9): [True: 0, False: 0]
  ------------------
 2247|      0|        {
 2248|      0|            uint64_t *ma;
 2249|      0|            uint32_t *mb;
 2250|      0|            uint32_t n;
 2251|      0|            ma = (uint64_t *)origdata;
 2252|      0|            mb = data;
 2253|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2253:25): [True: 0, False: 0]
  ------------------
 2254|      0|            {
 2255|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2255:21): [True: 0, False: 0]
  ------------------
 2256|      0|                    TIFFSwabLong8(ma);
 2257|      0|                err = TIFFReadDirEntryCheckRangeLongLong8(*ma);
 2258|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2258:21): [True: 0, False: 0]
  ------------------
 2259|      0|                    break;
 2260|      0|                *mb++ = (uint32_t)(*ma++);
 2261|      0|            }
 2262|      0|        }
 2263|      0|        break;
 2264|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2264:9): [True: 0, False: 0]
  ------------------
 2265|      0|        {
 2266|      0|            int64_t *ma;
 2267|      0|            uint32_t *mb;
 2268|      0|            uint32_t n;
 2269|      0|            ma = (int64_t *)origdata;
 2270|      0|            mb = data;
 2271|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2271:25): [True: 0, False: 0]
  ------------------
 2272|      0|            {
 2273|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2273:21): [True: 0, False: 0]
  ------------------
 2274|      0|                    TIFFSwabLong8((uint64_t *)ma);
 2275|      0|                err = TIFFReadDirEntryCheckRangeLongSlong8(*ma);
 2276|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2276:21): [True: 0, False: 0]
  ------------------
 2277|      0|                    break;
 2278|      0|                *mb++ = (uint32_t)(*ma++);
 2279|      0|            }
 2280|      0|        }
 2281|      0|        break;
 2282|      0|        default:
  ------------------
  |  Branch (2282:9): [True: 0, False: 0]
  ------------------
 2283|      0|            break;
 2284|      0|    }
 2285|      0|    _TIFFfreeExt(tif, origdata);
 2286|      0|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2286:9): [True: 0, False: 0]
  ------------------
 2287|      0|    {
 2288|      0|        _TIFFfreeExt(tif, data);
 2289|      0|        return (err);
 2290|      0|    }
 2291|      0|    *value = data;
 2292|      0|    return (TIFFReadDirEntryErrOk);
 2293|      0|}
tif_dirread.c:TIFFReadDirEntrySlongArray:
 2297|     17|{
 2298|     17|    enum TIFFReadDirEntryErr err;
 2299|     17|    uint32_t count;
 2300|     17|    void *origdata;
 2301|     17|    int32_t *data;
 2302|     17|    switch (direntry->tdir_type)
 2303|     17|    {
 2304|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2304:9): [True: 0, False: 17]
  ------------------
 2305|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2305:9): [True: 0, False: 17]
  ------------------
 2306|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2306:9): [True: 0, False: 17]
  ------------------
 2307|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2307:9): [True: 0, False: 17]
  ------------------
 2308|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2308:9): [True: 0, False: 17]
  ------------------
 2309|     17|        case TIFF_SLONG:
  ------------------
  |  Branch (2309:9): [True: 17, False: 0]
  ------------------
 2310|     17|        case TIFF_LONG8:
  ------------------
  |  Branch (2310:9): [True: 0, False: 17]
  ------------------
 2311|     17|        case TIFF_SLONG8:
  ------------------
  |  Branch (2311:9): [True: 0, False: 17]
  ------------------
 2312|     17|            break;
 2313|      0|        default:
  ------------------
  |  Branch (2313:9): [True: 0, False: 17]
  ------------------
 2314|      0|            return (TIFFReadDirEntryErrType);
 2315|     17|    }
 2316|     17|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2317|     17|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2317:9): [True: 3, False: 14]
  |  Branch (2317:43): [True: 2, False: 12]
  ------------------
 2318|      5|    {
 2319|      5|        *value = 0;
 2320|      5|        return (err);
 2321|      5|    }
 2322|     12|    switch (direntry->tdir_type)
 2323|     12|    {
 2324|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2324:9): [True: 0, False: 12]
  ------------------
 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|     12|        case TIFF_SLONG:
  ------------------
  |  Branch (2344:9): [True: 12, False: 0]
  ------------------
 2345|     12|            *value = (int32_t *)origdata;
 2346|     12|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     12|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2346:17): [True: 0, False: 12]
  ------------------
 2347|      0|                TIFFSwabArrayOfLong((uint32_t *)(*value), count);
 2348|     12|            return (TIFFReadDirEntryErrOk);
 2349|      0|        default:
  ------------------
  |  Branch (2349:9): [True: 0, False: 12]
  ------------------
 2350|      0|            break;
 2351|     12|    }
 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|    330|{
 2643|    330|    return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value,
 2644|    330|                                               ~((uint64_t)0));
 2645|    330|}
tif_dirread.c:TIFFReadDirEntryLong8ArrayWithLimit:
 2465|  1.24k|{
 2466|  1.24k|    enum TIFFReadDirEntryErr err;
 2467|  1.24k|    uint32_t count;
 2468|  1.24k|    void *origdata;
 2469|  1.24k|    uint64_t *data;
 2470|  1.24k|    switch (direntry->tdir_type)
 2471|  1.24k|    {
 2472|     12|        case TIFF_BYTE:
  ------------------
  |  Branch (2472:9): [True: 12, False: 1.23k]
  ------------------
 2473|     15|        case TIFF_SBYTE:
  ------------------
  |  Branch (2473:9): [True: 3, False: 1.23k]
  ------------------
 2474|    354|        case TIFF_SHORT:
  ------------------
  |  Branch (2474:9): [True: 339, False: 903]
  ------------------
 2475|    360|        case TIFF_SSHORT:
  ------------------
  |  Branch (2475:9): [True: 6, False: 1.23k]
  ------------------
 2476|  1.00k|        case TIFF_LONG:
  ------------------
  |  Branch (2476:9): [True: 649, False: 593]
  ------------------
 2477|  1.00k|        case TIFF_SLONG:
  ------------------
  |  Branch (2477:9): [True: 0, False: 1.24k]
  ------------------
 2478|  1.23k|        case TIFF_LONG8:
  ------------------
  |  Branch (2478:9): [True: 224, False: 1.01k]
  ------------------
 2479|  1.23k|        case TIFF_SLONG8:
  ------------------
  |  Branch (2479:9): [True: 0, False: 1.24k]
  ------------------
 2480|  1.23k|        case TIFF_IFD:
  ------------------
  |  Branch (2480:9): [True: 0, False: 1.24k]
  ------------------
 2481|  1.23k|        case TIFF_IFD8:
  ------------------
  |  Branch (2481:9): [True: 3, False: 1.23k]
  ------------------
 2482|  1.23k|            break;
 2483|      6|        default:
  ------------------
  |  Branch (2483:9): [True: 6, False: 1.23k]
  ------------------
 2484|      6|            return (TIFFReadDirEntryErrType);
 2485|  1.24k|    }
 2486|  1.23k|    err = TIFFReadDirEntryArrayWithLimit(tif, direntry, &count, 8, &origdata,
 2487|  1.23k|                                         maxcount);
 2488|  1.23k|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2488:9): [True: 114, False: 1.12k]
  |  Branch (2488:43): [True: 2, False: 1.12k]
  ------------------
 2489|    116|    {
 2490|    116|        *value = 0;
 2491|    116|        return (err);
 2492|    116|    }
 2493|  1.12k|    switch (direntry->tdir_type)
 2494|  1.12k|    {
 2495|    181|        case TIFF_LONG8:
  ------------------
  |  Branch (2495:9): [True: 181, False: 939]
  ------------------
 2496|    184|        case TIFF_IFD8:
  ------------------
  |  Branch (2496:9): [True: 3, False: 1.11k]
  ------------------
 2497|    184|            *value = (uint64_t *)origdata;
 2498|    184|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    184|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2498:17): [True: 0, False: 184]
  ------------------
 2499|      0|                TIFFSwabArrayOfLong8(*value, count);
 2500|    184|            return (TIFFReadDirEntryErrOk);
 2501|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2501:9): [True: 0, False: 1.12k]
  ------------------
 2502|      0|        {
 2503|      0|            int64_t *m;
 2504|      0|            uint32_t n;
 2505|      0|            m = (int64_t *)origdata;
 2506|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2506:25): [True: 0, False: 0]
  ------------------
 2507|      0|            {
 2508|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2508:21): [True: 0, False: 0]
  ------------------
 2509|      0|                    TIFFSwabLong8((uint64_t *)m);
 2510|      0|                err = TIFFReadDirEntryCheckRangeLong8Slong8(*m);
 2511|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2511:21): [True: 0, False: 0]
  ------------------
 2512|      0|                {
 2513|      0|                    _TIFFfreeExt(tif, origdata);
 2514|      0|                    return (err);
 2515|      0|                }
 2516|      0|                m++;
 2517|      0|            }
 2518|      0|            *value = (uint64_t *)origdata;
 2519|      0|            return (TIFFReadDirEntryErrOk);
 2520|      0|        }
 2521|    936|        default:
  ------------------
  |  Branch (2521:9): [True: 936, False: 184]
  ------------------
 2522|    936|            break;
 2523|  1.12k|    }
 2524|    936|    data = (uint64_t *)_TIFFCheckMalloc(tif, count, sizeof(uint64_t),
 2525|    936|                                        "TIFFReadDirEntryLong8ArrayWithLimit");
 2526|    936|    if (data == 0)
  ------------------
  |  Branch (2526:9): [True: 0, False: 936]
  ------------------
 2527|      0|    {
 2528|      0|        _TIFFfreeExt(tif, origdata);
 2529|      0|        return (TIFFReadDirEntryErrAlloc);
 2530|      0|    }
 2531|    936|    switch (direntry->tdir_type)
 2532|    936|    {
 2533|     12|        case TIFF_BYTE:
  ------------------
  |  Branch (2533:9): [True: 12, False: 924]
  ------------------
 2534|     12|        {
 2535|     12|            uint8_t *ma;
 2536|     12|            uint64_t *mb;
 2537|     12|            uint32_t n;
 2538|     12|            ma = (uint8_t *)origdata;
 2539|     12|            mb = data;
 2540|  6.10k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2540:25): [True: 6.09k, False: 12]
  ------------------
 2541|  6.09k|                *mb++ = (uint64_t)(*ma++);
 2542|     12|        }
 2543|     12|        break;
 2544|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2544:9): [True: 0, False: 936]
  ------------------
 2545|      0|        {
 2546|      0|            int8_t *ma;
 2547|      0|            uint64_t *mb;
 2548|      0|            uint32_t n;
 2549|      0|            ma = (int8_t *)origdata;
 2550|      0|            mb = data;
 2551|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2551:25): [True: 0, False: 0]
  ------------------
 2552|      0|            {
 2553|      0|                err = TIFFReadDirEntryCheckRangeLong8Sbyte(*ma);
 2554|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2554:21): [True: 0, False: 0]
  ------------------
 2555|      0|                    break;
 2556|      0|                *mb++ = (uint64_t)(*ma++);
 2557|      0|            }
 2558|      0|        }
 2559|      0|        break;
 2560|    275|        case TIFF_SHORT:
  ------------------
  |  Branch (2560:9): [True: 275, False: 661]
  ------------------
 2561|    275|        {
 2562|    275|            uint16_t *ma;
 2563|    275|            uint64_t *mb;
 2564|    275|            uint32_t n;
 2565|    275|            ma = (uint16_t *)origdata;
 2566|    275|            mb = data;
 2567|  71.9k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2567:25): [True: 71.7k, False: 275]
  ------------------
 2568|  71.7k|            {
 2569|  71.7k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  71.7k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2569:21): [True: 0, False: 71.7k]
  ------------------
 2570|      0|                    TIFFSwabShort(ma);
 2571|  71.7k|                *mb++ = (uint64_t)(*ma++);
 2572|  71.7k|            }
 2573|    275|        }
 2574|    275|        break;
 2575|      6|        case TIFF_SSHORT:
  ------------------
  |  Branch (2575:9): [True: 6, False: 930]
  ------------------
 2576|      6|        {
 2577|      6|            int16_t *ma;
 2578|      6|            uint64_t *mb;
 2579|      6|            uint32_t n;
 2580|      6|            ma = (int16_t *)origdata;
 2581|      6|            mb = data;
 2582|     12|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2582:25): [True: 6, False: 6]
  ------------------
 2583|      6|            {
 2584|      6|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      6|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2584:21): [True: 0, False: 6]
  ------------------
 2585|      0|                    TIFFSwabShort((uint16_t *)ma);
 2586|      6|                err = TIFFReadDirEntryCheckRangeLong8Sshort(*ma);
 2587|      6|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2587:21): [True: 0, False: 6]
  ------------------
 2588|      0|                    break;
 2589|      6|                *mb++ = (uint64_t)(*ma++);
 2590|      6|            }
 2591|      6|        }
 2592|      6|        break;
 2593|    643|        case TIFF_LONG:
  ------------------
  |  Branch (2593:9): [True: 643, False: 293]
  ------------------
 2594|    643|        case TIFF_IFD:
  ------------------
  |  Branch (2594:9): [True: 0, False: 936]
  ------------------
 2595|    643|        {
 2596|    643|            uint32_t *ma;
 2597|    643|            uint64_t *mb;
 2598|    643|            uint32_t n;
 2599|    643|            ma = (uint32_t *)origdata;
 2600|    643|            mb = data;
 2601|  3.79k|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2601:25): [True: 3.15k, False: 643]
  ------------------
 2602|  3.15k|            {
 2603|  3.15k|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|  3.15k|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2603:21): [True: 0, False: 3.15k]
  ------------------
 2604|      0|                    TIFFSwabLong(ma);
 2605|  3.15k|                *mb++ = (uint64_t)(*ma++);
 2606|  3.15k|            }
 2607|    643|        }
 2608|    643|        break;
 2609|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2609:9): [True: 0, False: 936]
  ------------------
 2610|      0|        {
 2611|      0|            int32_t *ma;
 2612|      0|            uint64_t *mb;
 2613|      0|            uint32_t n;
 2614|      0|            ma = (int32_t *)origdata;
 2615|      0|            mb = data;
 2616|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2616:25): [True: 0, False: 0]
  ------------------
 2617|      0|            {
 2618|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2618:21): [True: 0, False: 0]
  ------------------
 2619|      0|                    TIFFSwabLong((uint32_t *)ma);
 2620|      0|                err = TIFFReadDirEntryCheckRangeLong8Slong(*ma);
 2621|      0|                if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2621:21): [True: 0, False: 0]
  ------------------
 2622|      0|                    break;
 2623|      0|                *mb++ = (uint64_t)(*ma++);
 2624|      0|            }
 2625|      0|        }
 2626|      0|        break;
 2627|      0|        default:
  ------------------
  |  Branch (2627:9): [True: 0, False: 936]
  ------------------
 2628|      0|            break;
 2629|    936|    }
 2630|    936|    _TIFFfreeExt(tif, origdata);
 2631|    936|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (2631:9): [True: 0, False: 936]
  ------------------
 2632|      0|    {
 2633|      0|        _TIFFfreeExt(tif, data);
 2634|      0|        return (err);
 2635|      0|    }
 2636|    936|    *value = data;
 2637|    936|    return (TIFFReadDirEntryErrOk);
 2638|    936|}
tif_dirread.c:TIFFReadDirEntrySlong8Array:
 2649|    191|{
 2650|    191|    enum TIFFReadDirEntryErr err;
 2651|    191|    uint32_t count;
 2652|    191|    void *origdata;
 2653|    191|    int64_t *data;
 2654|    191|    switch (direntry->tdir_type)
 2655|    191|    {
 2656|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2656:9): [True: 0, False: 191]
  ------------------
 2657|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2657:9): [True: 0, False: 191]
  ------------------
 2658|      0|        case TIFF_SHORT:
  ------------------
  |  Branch (2658:9): [True: 0, False: 191]
  ------------------
 2659|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2659:9): [True: 0, False: 191]
  ------------------
 2660|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2660:9): [True: 0, False: 191]
  ------------------
 2661|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2661:9): [True: 0, False: 191]
  ------------------
 2662|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2662:9): [True: 0, False: 191]
  ------------------
 2663|    191|        case TIFF_SLONG8:
  ------------------
  |  Branch (2663:9): [True: 191, False: 0]
  ------------------
 2664|    191|            break;
 2665|      0|        default:
  ------------------
  |  Branch (2665:9): [True: 0, False: 191]
  ------------------
 2666|      0|            return (TIFFReadDirEntryErrType);
 2667|    191|    }
 2668|    191|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 2669|    191|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2669:9): [True: 191, False: 0]
  |  Branch (2669:43): [True: 0, False: 0]
  ------------------
 2670|    191|    {
 2671|    191|        *value = 0;
 2672|    191|        return (err);
 2673|    191|    }
 2674|      0|    switch (direntry->tdir_type)
 2675|      0|    {
 2676|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2676:9): [True: 0, False: 0]
  ------------------
 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|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2696:9): [True: 0, False: 0]
  ------------------
 2697|      0|            *value = (int64_t *)origdata;
 2698|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2698:17): [True: 0, False: 0]
  ------------------
 2699|      0|                TIFFSwabArrayOfLong8((uint64_t *)(*value), count);
 2700|      0|            return (TIFFReadDirEntryErrOk);
 2701|      0|        default:
  ------------------
  |  Branch (2701:9): [True: 0, False: 0]
  ------------------
 2702|      0|            break;
 2703|      0|    }
 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|     77|{
 2806|     77|    enum TIFFReadDirEntryErr err;
 2807|     77|    uint32_t count;
 2808|     77|    void *origdata;
 2809|     77|    float *data;
 2810|     77|    switch (direntry->tdir_type)
 2811|     77|    {
 2812|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2812:9): [True: 0, False: 77]
  ------------------
 2813|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2813:9): [True: 0, False: 77]
  ------------------
 2814|     11|        case TIFF_SHORT:
  ------------------
  |  Branch (2814:9): [True: 11, False: 66]
  ------------------
 2815|     11|        case TIFF_SSHORT:
  ------------------
  |  Branch (2815:9): [True: 0, False: 77]
  ------------------
 2816|     11|        case TIFF_LONG:
  ------------------
  |  Branch (2816:9): [True: 0, False: 77]
  ------------------
 2817|     11|        case TIFF_SLONG:
  ------------------
  |  Branch (2817:9): [True: 0, False: 77]
  ------------------
 2818|     11|        case TIFF_LONG8:
  ------------------
  |  Branch (2818:9): [True: 0, False: 77]
  ------------------
 2819|     11|        case TIFF_SLONG8:
  ------------------
  |  Branch (2819:9): [True: 0, False: 77]
  ------------------
 2820|     67|        case TIFF_RATIONAL:
  ------------------
  |  Branch (2820:9): [True: 56, False: 21]
  ------------------
 2821|     72|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (2821:9): [True: 5, False: 72]
  ------------------
 2822|     73|        case TIFF_FLOAT:
  ------------------
  |  Branch (2822:9): [True: 1, False: 76]
  ------------------
 2823|     75|        case TIFF_DOUBLE:
  ------------------
  |  Branch (2823:9): [True: 2, False: 75]
  ------------------
 2824|     75|            break;
 2825|      2|        default:
  ------------------
  |  Branch (2825:9): [True: 2, False: 75]
  ------------------
 2826|      2|            return (TIFFReadDirEntryErrType);
 2827|     77|    }
 2828|     75|    err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
 2829|     75|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (2829:9): [True: 34, False: 41]
  |  Branch (2829:43): [True: 0, False: 41]
  ------------------
 2830|     34|    {
 2831|     34|        *value = 0;
 2832|     34|        return (err);
 2833|     34|    }
 2834|     41|    switch (direntry->tdir_type)
 2835|     41|    {
 2836|      0|        case TIFF_FLOAT:
  ------------------
  |  Branch (2836:9): [True: 0, False: 41]
  ------------------
 2837|      0|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2837:17): [True: 0, False: 0]
  ------------------
 2838|      0|                TIFFSwabArrayOfLong((uint32_t *)origdata, count);
 2839|      0|            TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata);
 2840|      0|            *value = (float *)origdata;
 2841|      0|            return (TIFFReadDirEntryErrOk);
 2842|     41|        default:
  ------------------
  |  Branch (2842:9): [True: 41, False: 0]
  ------------------
 2843|     41|            break;
 2844|     41|    }
 2845|     41|    data = (float *)_TIFFCheckMalloc(tif, count, sizeof(float),
 2846|     41|                                     "TIFFReadDirEntryFloatArray");
 2847|     41|    if (data == 0)
  ------------------
  |  Branch (2847:9): [True: 0, False: 41]
  ------------------
 2848|      0|    {
 2849|      0|        _TIFFfreeExt(tif, origdata);
 2850|      0|        return (TIFFReadDirEntryErrAlloc);
 2851|      0|    }
 2852|     41|    switch (direntry->tdir_type)
 2853|     41|    {
 2854|      0|        case TIFF_BYTE:
  ------------------
  |  Branch (2854:9): [True: 0, False: 41]
  ------------------
 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|      0|        case TIFF_SBYTE:
  ------------------
  |  Branch (2865:9): [True: 0, False: 41]
  ------------------
 2866|      0|        {
 2867|      0|            int8_t *ma;
 2868|      0|            float *mb;
 2869|      0|            uint32_t n;
 2870|      0|            ma = (int8_t *)origdata;
 2871|      0|            mb = data;
 2872|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2872:25): [True: 0, False: 0]
  ------------------
 2873|      0|                *mb++ = (float)(*ma++);
 2874|      0|        }
 2875|      0|        break;
 2876|     11|        case TIFF_SHORT:
  ------------------
  |  Branch (2876:9): [True: 11, False: 30]
  ------------------
 2877|     11|        {
 2878|     11|            uint16_t *ma;
 2879|     11|            float *mb;
 2880|     11|            uint32_t n;
 2881|     11|            ma = (uint16_t *)origdata;
 2882|     11|            mb = data;
 2883|     36|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2883:25): [True: 25, False: 11]
  ------------------
 2884|     25|            {
 2885|     25|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     25|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2885:21): [True: 0, False: 25]
  ------------------
 2886|      0|                    TIFFSwabShort(ma);
 2887|     25|                *mb++ = (float)(*ma++);
 2888|     25|            }
 2889|     11|        }
 2890|     11|        break;
 2891|      0|        case TIFF_SSHORT:
  ------------------
  |  Branch (2891:9): [True: 0, False: 41]
  ------------------
 2892|      0|        {
 2893|      0|            int16_t *ma;
 2894|      0|            float *mb;
 2895|      0|            uint32_t n;
 2896|      0|            ma = (int16_t *)origdata;
 2897|      0|            mb = data;
 2898|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2898:25): [True: 0, False: 0]
  ------------------
 2899|      0|            {
 2900|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2900:21): [True: 0, False: 0]
  ------------------
 2901|      0|                    TIFFSwabShort((uint16_t *)ma);
 2902|      0|                *mb++ = (float)(*ma++);
 2903|      0|            }
 2904|      0|        }
 2905|      0|        break;
 2906|      0|        case TIFF_LONG:
  ------------------
  |  Branch (2906:9): [True: 0, False: 41]
  ------------------
 2907|      0|        {
 2908|      0|            uint32_t *ma;
 2909|      0|            float *mb;
 2910|      0|            uint32_t n;
 2911|      0|            ma = (uint32_t *)origdata;
 2912|      0|            mb = data;
 2913|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2913:25): [True: 0, False: 0]
  ------------------
 2914|      0|            {
 2915|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2915:21): [True: 0, False: 0]
  ------------------
 2916|      0|                    TIFFSwabLong(ma);
 2917|      0|                *mb++ = (float)(*ma++);
 2918|      0|            }
 2919|      0|        }
 2920|      0|        break;
 2921|      0|        case TIFF_SLONG:
  ------------------
  |  Branch (2921:9): [True: 0, False: 41]
  ------------------
 2922|      0|        {
 2923|      0|            int32_t *ma;
 2924|      0|            float *mb;
 2925|      0|            uint32_t n;
 2926|      0|            ma = (int32_t *)origdata;
 2927|      0|            mb = data;
 2928|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2928:25): [True: 0, False: 0]
  ------------------
 2929|      0|            {
 2930|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2930:21): [True: 0, False: 0]
  ------------------
 2931|      0|                    TIFFSwabLong((uint32_t *)ma);
 2932|      0|                *mb++ = (float)(*ma++);
 2933|      0|            }
 2934|      0|        }
 2935|      0|        break;
 2936|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (2936:9): [True: 0, False: 41]
  ------------------
 2937|      0|        {
 2938|      0|            uint64_t *ma;
 2939|      0|            float *mb;
 2940|      0|            uint32_t n;
 2941|      0|            ma = (uint64_t *)origdata;
 2942|      0|            mb = data;
 2943|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2943:25): [True: 0, False: 0]
  ------------------
 2944|      0|            {
 2945|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2945:21): [True: 0, False: 0]
  ------------------
 2946|      0|                    TIFFSwabLong8(ma);
 2947|      0|                *mb++ = (float)(*ma++);
 2948|      0|            }
 2949|      0|        }
 2950|      0|        break;
 2951|      0|        case TIFF_SLONG8:
  ------------------
  |  Branch (2951:9): [True: 0, False: 41]
  ------------------
 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|     28|        case TIFF_RATIONAL:
  ------------------
  |  Branch (2966:9): [True: 28, False: 13]
  ------------------
 2967|     28|        {
 2968|     28|            uint32_t *ma;
 2969|     28|            uint32_t maa;
 2970|     28|            uint32_t mab;
 2971|     28|            float *mb;
 2972|     28|            uint32_t n;
 2973|     28|            ma = (uint32_t *)origdata;
 2974|     28|            mb = data;
 2975|     58|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2975:25): [True: 30, False: 28]
  ------------------
 2976|     30|            {
 2977|     30|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     30|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2977:21): [True: 0, False: 30]
  ------------------
 2978|      0|                    TIFFSwabLong(ma);
 2979|     30|                maa = *ma++;
 2980|     30|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     30|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (2980:21): [True: 0, False: 30]
  ------------------
 2981|      0|                    TIFFSwabLong(ma);
 2982|     30|                mab = *ma++;
 2983|     30|                if (mab == 0)
  ------------------
  |  Branch (2983:21): [True: 2, False: 28]
  ------------------
 2984|      2|                    *mb++ = 0.0;
 2985|     28|                else
 2986|     28|                    *mb++ = (float)maa / (float)mab;
 2987|     30|            }
 2988|     28|        }
 2989|     28|        break;
 2990|      0|        case TIFF_SRATIONAL:
  ------------------
  |  Branch (2990:9): [True: 0, False: 41]
  ------------------
 2991|      0|        {
 2992|      0|            uint32_t *ma;
 2993|      0|            int32_t maa;
 2994|      0|            uint32_t mab;
 2995|      0|            float *mb;
 2996|      0|            uint32_t n;
 2997|      0|            ma = (uint32_t *)origdata;
 2998|      0|            mb = data;
 2999|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (2999:25): [True: 0, False: 0]
  ------------------
 3000|      0|            {
 3001|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3001:21): [True: 0, False: 0]
  ------------------
 3002|      0|                    TIFFSwabLong(ma);
 3003|      0|                maa = *(int32_t *)ma;
 3004|      0|                ma++;
 3005|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3005:21): [True: 0, False: 0]
  ------------------
 3006|      0|                    TIFFSwabLong(ma);
 3007|      0|                mab = *ma++;
 3008|      0|                if (mab == 0)
  ------------------
  |  Branch (3008:21): [True: 0, False: 0]
  ------------------
 3009|      0|                    *mb++ = 0.0;
 3010|      0|                else
 3011|      0|                    *mb++ = (float)maa / (float)mab;
 3012|      0|            }
 3013|      0|        }
 3014|      0|        break;
 3015|      2|        case TIFF_DOUBLE:
  ------------------
  |  Branch (3015:9): [True: 2, False: 39]
  ------------------
 3016|      2|        {
 3017|      2|            double *ma;
 3018|      2|            float *mb;
 3019|      2|            uint32_t n;
 3020|      2|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      2|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3020:17): [True: 0, False: 2]
  ------------------
 3021|      0|                TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
 3022|      2|            TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
 3023|      2|            ma = (double *)origdata;
 3024|      2|            mb = data;
 3025|     14|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3025:25): [True: 12, False: 2]
  ------------------
 3026|     12|            {
 3027|     12|                double val = *ma++;
 3028|     12|                if (val > (double)FLT_MAX)
  ------------------
  |  Branch (3028:21): [True: 7, False: 5]
  ------------------
 3029|      7|                    val = (double)FLT_MAX;
 3030|      5|                else if (val < -(double)FLT_MAX)
  ------------------
  |  Branch (3030:26): [True: 1, False: 4]
  ------------------
 3031|      1|                    val = -(double)FLT_MAX;
 3032|     12|                *mb++ = (float)val;
 3033|     12|            }
 3034|      2|        }
 3035|      2|        break;
 3036|      0|        default:
  ------------------
  |  Branch (3036:9): [True: 0, False: 41]
  ------------------
 3037|      0|            break;
 3038|     41|    }
 3039|     41|    _TIFFfreeExt(tif, origdata);
 3040|     41|    *value = data;
 3041|     41|    return (TIFFReadDirEntryErrOk);
 3042|     41|}
tif_dirread.c:TIFFReadDirEntryIfd8Array:
 3280|     24|{
 3281|     24|    enum TIFFReadDirEntryErr err;
 3282|     24|    uint32_t count;
 3283|     24|    void *origdata;
 3284|     24|    uint64_t *data;
 3285|     24|    switch (direntry->tdir_type)
 3286|     24|    {
 3287|      0|        case TIFF_LONG:
  ------------------
  |  Branch (3287:9): [True: 0, False: 24]
  ------------------
 3288|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (3288:9): [True: 0, False: 24]
  ------------------
 3289|      3|        case TIFF_IFD:
  ------------------
  |  Branch (3289:9): [True: 3, False: 21]
  ------------------
 3290|     23|        case TIFF_IFD8:
  ------------------
  |  Branch (3290:9): [True: 20, False: 4]
  ------------------
 3291|     23|            break;
 3292|      1|        default:
  ------------------
  |  Branch (3292:9): [True: 1, False: 23]
  ------------------
 3293|      1|            return (TIFFReadDirEntryErrType);
 3294|     24|    }
 3295|     23|    err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
 3296|     23|    if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
  ------------------
  |  Branch (3296:9): [True: 19, False: 4]
  |  Branch (3296:43): [True: 0, False: 4]
  ------------------
 3297|     19|    {
 3298|     19|        *value = 0;
 3299|     19|        return (err);
 3300|     19|    }
 3301|      4|    switch (direntry->tdir_type)
 3302|      4|    {
 3303|      0|        case TIFF_LONG8:
  ------------------
  |  Branch (3303:9): [True: 0, False: 4]
  ------------------
 3304|      4|        case TIFF_IFD8:
  ------------------
  |  Branch (3304:9): [True: 4, False: 0]
  ------------------
 3305|      4|            *value = (uint64_t *)origdata;
 3306|      4|            if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      4|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3306:17): [True: 0, False: 4]
  ------------------
 3307|      0|                TIFFSwabArrayOfLong8(*value, count);
 3308|      4|            return (TIFFReadDirEntryErrOk);
 3309|      0|        default:
  ------------------
  |  Branch (3309:9): [True: 0, False: 4]
  ------------------
 3310|      0|            break;
 3311|      4|    }
 3312|      0|    data = (uint64_t *)_TIFFCheckMalloc(tif, count, sizeof(uint64_t),
 3313|      0|                                        "TIFFReadDirEntryIfd8Array");
 3314|      0|    if (data == 0)
  ------------------
  |  Branch (3314:9): [True: 0, False: 0]
  ------------------
 3315|      0|    {
 3316|      0|        _TIFFfreeExt(tif, origdata);
 3317|      0|        return (TIFFReadDirEntryErrAlloc);
 3318|      0|    }
 3319|      0|    switch (direntry->tdir_type)
 3320|      0|    {
 3321|      0|        case TIFF_LONG:
  ------------------
  |  Branch (3321:9): [True: 0, False: 0]
  ------------------
 3322|      0|        case TIFF_IFD:
  ------------------
  |  Branch (3322:9): [True: 0, False: 0]
  ------------------
 3323|      0|        {
 3324|      0|            uint32_t *ma;
 3325|      0|            uint64_t *mb;
 3326|      0|            uint32_t n;
 3327|      0|            ma = (uint32_t *)origdata;
 3328|      0|            mb = data;
 3329|      0|            for (n = 0; n < count; n++)
  ------------------
  |  Branch (3329:25): [True: 0, False: 0]
  ------------------
 3330|      0|            {
 3331|      0|                if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (3331:21): [True: 0, False: 0]
  ------------------
 3332|      0|                    TIFFSwabLong(ma);
 3333|      0|                *mb++ = (uint64_t)(*ma++);
 3334|      0|            }
 3335|      0|        }
 3336|      0|        break;
 3337|      0|        default:
  ------------------
  |  Branch (3337:9): [True: 0, False: 0]
  ------------------
 3338|      0|            break;
 3339|      0|    }
 3340|      0|    _TIFFfreeExt(tif, origdata);
 3341|      0|    *value = data;
 3342|      0|    return (TIFFReadDirEntryErrOk);
 3343|      0|}
tif_dirread.c:TIFFFetchStripThing:
 7793|    912|{
 7794|    912|    static const char module[] = "TIFFFetchStripThing";
 7795|    912|    enum TIFFReadDirEntryErr err;
 7796|    912|    uint64_t *data;
 7797|    912|    err = TIFFReadDirEntryLong8ArrayWithLimit(tif, dir, &data, nstrips);
 7798|    912|    if (err != TIFFReadDirEntryErrOk)
  ------------------
  |  Branch (7798:9): [True: 39, False: 873]
  ------------------
 7799|     39|    {
 7800|     39|        const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
 7801|     39|        TIFFReadDirEntryOutputErr(tif, err, module,
 7802|     39|                                  fip ? fip->field_name : "unknown tagname", 0);
  ------------------
  |  Branch (7802:35): [True: 39, False: 0]
  ------------------
 7803|     39|        return (0);
 7804|     39|    }
 7805|    873|    if (dir->tdir_count < (uint64_t)nstrips)
  ------------------
  |  Branch (7805:9): [True: 53, False: 820]
  ------------------
 7806|     53|    {
 7807|     53|        uint64_t *resizeddata;
 7808|     53|        const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
 7809|     53|        const char *pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT");
 7810|     53|        uint32_t max_nstrips = 1000000;
 7811|     53|        if (pszMax)
  ------------------
  |  Branch (7811:13): [True: 0, False: 53]
  ------------------
 7812|      0|            max_nstrips = (uint32_t)atoi(pszMax);
 7813|     53|        TIFFReadDirEntryOutputErr(tif, TIFFReadDirEntryErrCount, module,
 7814|     53|                                  fip ? fip->field_name : "unknown tagname",
  ------------------
  |  Branch (7814:35): [True: 53, False: 0]
  ------------------
 7815|     53|                                  (nstrips <= max_nstrips));
 7816|       |
 7817|     53|        if (nstrips > max_nstrips)
  ------------------
  |  Branch (7817:13): [True: 0, False: 53]
  ------------------
 7818|      0|        {
 7819|      0|            _TIFFfreeExt(tif, data);
 7820|      0|            return (0);
 7821|      0|        }
 7822|       |
 7823|     53|        const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t);
 7824|     53|        if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (7824:13): [True: 0, False: 53]
  ------------------
 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|     53|        resizeddata = (uint64_t *)_TIFFCheckMalloc(
 7843|     53|            tif, nstrips, sizeof(uint64_t), "for strip array");
 7844|     53|        if (resizeddata == 0)
  ------------------
  |  Branch (7844:13): [True: 0, False: 53]
  ------------------
 7845|      0|        {
 7846|      0|            _TIFFfreeExt(tif, data);
 7847|      0|            return (0);
 7848|      0|        }
 7849|     53|        if (dir->tdir_count)
  ------------------
  |  Branch (7849:13): [True: 53, False: 0]
  ------------------
 7850|     53|            _TIFFmemcpy(resizeddata, data,
 7851|     53|                        (tmsize_t)((size_t)dir->tdir_count * sizeof(uint64_t)));
 7852|     53|        _TIFFmemset(resizeddata + (uint32_t)dir->tdir_count, 0,
 7853|     53|                    (tmsize_t)((size_t)(nstrips - (uint32_t)dir->tdir_count) *
 7854|     53|                               sizeof(uint64_t)));
 7855|     53|        _TIFFfreeExt(tif, data);
 7856|     53|        data = resizeddata;
 7857|     53|    }
 7858|    873|    *lpp = data;
 7859|    873|    return (1);
 7860|    873|}
tif_dirread.c:ChopUpSingleUncompressedStrip:
 8017|     10|{
 8018|     10|    TIFFDirectory *td = &tif->tif_dir;
 8019|     10|    uint64_t bytecount;
 8020|     10|    uint64_t offset;
 8021|     10|    uint32_t rowblock;
 8022|     10|    uint64_t rowblockbytes;
 8023|     10|    uint64_t stripbytes;
 8024|     10|    uint32_t nstrips;
 8025|     10|    uint32_t rowsperstrip;
 8026|       |
 8027|     10|    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|     10|    if (bytecount == 0 && tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (8031:9): [True: 3, False: 7]
  |  Branch (8031:27): [True: 0, False: 3]
  ------------------
 8032|      0|        return;
 8033|     10|    offset = TIFFGetStrileOffset(tif, 0);
 8034|     10|    assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
  ------------------
  |  Branch (8034:5): [True: 0, False: 10]
  |  Branch (8034:5): [True: 10, False: 0]
  ------------------
 8035|     10|    if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|     10|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
                  if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  281|      4|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|      4|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (8035:9): [True: 4, False: 6]
  |  Branch (8035:54): [True: 4, False: 0]
  ------------------
 8036|      4|        rowblock = td->td_ycbcrsubsampling[1];
 8037|      6|    else
 8038|      6|        rowblock = 1;
 8039|     10|    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|     10|    if (rowblockbytes > STRIP_SIZE_DEFAULT)
  ------------------
  |  |  119|     10|#define STRIP_SIZE_DEFAULT 8192
  ------------------
  |  Branch (8044:9): [True: 3, False: 7]
  ------------------
 8045|      3|    {
 8046|      3|        stripbytes = rowblockbytes;
 8047|      3|        rowsperstrip = rowblock;
 8048|      3|    }
 8049|      7|    else if (rowblockbytes > 0)
  ------------------
  |  Branch (8049:14): [True: 5, False: 2]
  ------------------
 8050|      5|    {
 8051|      5|        uint32_t rowblocksperstrip;
 8052|      5|        rowblocksperstrip = (uint32_t)(STRIP_SIZE_DEFAULT / rowblockbytes);
  ------------------
  |  |  119|      5|#define STRIP_SIZE_DEFAULT 8192
  ------------------
 8053|      5|        rowsperstrip = rowblocksperstrip * rowblock;
 8054|      5|        stripbytes = rowblocksperstrip * rowblockbytes;
 8055|      5|    }
 8056|      2|    else
 8057|      2|        return;
 8058|       |
 8059|       |    /*
 8060|       |     * never increase the number of rows per strip
 8061|       |     */
 8062|      8|    if (rowsperstrip >= td->td_rowsperstrip || rowsperstrip == 0)
  ------------------
  |  Branch (8062:9): [True: 5, False: 3]
  |  Branch (8062:48): [True: 0, False: 3]
  ------------------
 8063|      5|        return;
 8064|      3|    nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  312|      3|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 3, False: 0]
  |  |  ------------------
  |  |  313|      3|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|      3|         : 0U)
  ------------------
 8065|      3|    if (nstrips == 0)
  ------------------
  |  Branch (8065:9): [True: 0, False: 3]
  ------------------
 8066|      0|        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|      3|    if (tif->tif_mode == O_RDONLY && nstrips > 1000000 &&
  ------------------
  |  Branch (8070:9): [True: 3, False: 0]
  |  Branch (8070:38): [True: 1, False: 2]
  ------------------
 8071|      1|        (offset >= TIFFGetFileSize(tif) ||
  ------------------
  |  |  289|      2|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
  |  Branch (8071:10): [True: 1, False: 0]
  ------------------
 8072|      0|         stripbytes > (TIFFGetFileSize(tif) - offset) / (nstrips - 1)))
  ------------------
  |  |  289|      0|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
  |  Branch (8072:10): [True: 0, False: 0]
  ------------------
 8073|      1|    {
 8074|      1|        return;
 8075|      1|    }
 8076|       |
 8077|      2|    allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
 8078|      2|}
tif_dirread.c:allocChoppedUpStripArrays:
 7922|      2|{
 7923|      2|    TIFFDirectory *td = &tif->tif_dir;
 7924|      2|    uint64_t bytecount;
 7925|      2|    uint64_t offset;
 7926|      2|    uint64_t last_offset;
 7927|      2|    uint64_t last_bytecount;
 7928|      2|    uint32_t i;
 7929|      2|    uint64_t *newcounts;
 7930|      2|    uint64_t *newoffsets;
 7931|       |
 7932|      2|    offset = TIFFGetStrileOffset(tif, 0);
 7933|      2|    last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
 7934|      2|    last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
 7935|      2|    if (last_offset > UINT64_MAX - last_bytecount ||
  ------------------
  |  Branch (7935:9): [True: 0, False: 2]
  ------------------
 7936|      2|        last_offset + last_bytecount < offset)
  ------------------
  |  Branch (7936:9): [True: 0, False: 2]
  ------------------
 7937|      0|    {
 7938|      0|        return;
 7939|      0|    }
 7940|      2|    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|      2|    const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t) * 2;
 7947|      2|    if (allocsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (7947:9): [True: 0, False: 2]
  ------------------
 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|      2|    newcounts =
 7963|      2|        (uint64_t *)_TIFFCheckMalloc(tif, nstrips, sizeof(uint64_t),
 7964|      2|                                     "for chopped \"StripByteCounts\" array");
 7965|      2|    newoffsets = (uint64_t *)_TIFFCheckMalloc(
 7966|      2|        tif, nstrips, sizeof(uint64_t), "for chopped \"StripOffsets\" array");
 7967|      2|    if (newcounts == NULL || newoffsets == NULL)
  ------------------
  |  Branch (7967:9): [True: 0, False: 2]
  |  Branch (7967:30): [True: 0, False: 2]
  ------------------
 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|     38|    for (i = 0; i < nstrips; i++)
  ------------------
  |  Branch (7984:17): [True: 36, False: 2]
  ------------------
 7985|     36|    {
 7986|     36|        if (stripbytes > bytecount)
  ------------------
  |  Branch (7986:13): [True: 1, False: 35]
  ------------------
 7987|      1|            stripbytes = bytecount;
 7988|     36|        newcounts[i] = stripbytes;
 7989|     36|        newoffsets[i] = stripbytes ? offset : 0;
  ------------------
  |  Branch (7989:25): [True: 36, False: 0]
  ------------------
 7990|     36|        offset += stripbytes;
 7991|     36|        bytecount -= stripbytes;
 7992|     36|    }
 7993|       |
 7994|       |    /*
 7995|       |     * Replace old single strip info with multi-strip info.
 7996|       |     */
 7997|      2|    td->td_stripsperimage = td->td_nstrips = nstrips;
 7998|      2|    TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
  ------------------
  |  |  258|      2|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 7999|       |
 8000|      2|    _TIFFfreeExt(tif, td->td_stripbytecount_p);
 8001|      2|    _TIFFfreeExt(tif, td->td_stripoffset_p);
 8002|      2|    td->td_stripbytecount_p = newcounts;
 8003|      2|    td->td_stripoffset_p = newoffsets;
 8004|       |#ifdef STRIPBYTECOUNTSORTED_UNUSED
 8005|       |    td->td_stripbytecountsorted = 1;
 8006|       |#endif
 8007|      2|    tif->tif_flags |= TIFF_CHOPPEDUPARRAYS;
  ------------------
  |  |  153|      2|    0x4000000U /* set when allocChoppedUpStripArrays() has modified strip      \
  ------------------
 8008|      2|}
tif_dirread.c:TryChopUpUncompressedBigTiff:
 8087|      2|{
 8088|      2|    TIFFDirectory *td = &tif->tif_dir;
 8089|      2|    uint32_t rowblock;
 8090|      2|    uint64_t rowblockbytes;
 8091|      2|    uint32_t i;
 8092|      2|    uint64_t stripsize;
 8093|      2|    uint32_t rowblocksperstrip;
 8094|      2|    uint32_t rowsperstrip;
 8095|      2|    uint64_t stripbytes;
 8096|      2|    uint32_t nstrips;
 8097|       |
 8098|      2|    stripsize = TIFFStripSize64(tif);
 8099|       |
 8100|      2|    assert(tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG);
  ------------------
  |  Branch (8100:5): [True: 0, False: 2]
  |  Branch (8100:5): [True: 2, False: 0]
  ------------------
 8101|      2|    assert(tif->tif_dir.td_compression == COMPRESSION_NONE);
  ------------------
  |  Branch (8101:5): [True: 0, False: 2]
  |  Branch (8101:5): [True: 2, False: 0]
  ------------------
 8102|      2|    assert((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) ==
  ------------------
  |  Branch (8102:5): [True: 0, False: 2]
  |  Branch (8102:5): [True: 2, False: 0]
  ------------------
 8103|      2|           TIFF_STRIPCHOP);
 8104|      2|    assert(stripsize > 0x7FFFFFFFUL);
  ------------------
  |  Branch (8104:5): [True: 0, False: 2]
  |  Branch (8104:5): [True: 2, 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|      2|    if (TIFFGetStrileByteCount(tif, 0) == 0 && tif->tif_mode != O_RDONLY)
  ------------------
  |  Branch (8109:9): [True: 0, False: 2]
  |  Branch (8109:48): [True: 0, False: 0]
  ------------------
 8110|      0|        return;
 8111|       |
 8112|      2|    if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|      2|#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: 2]
  |  Branch (8112:54): [True: 0, False: 0]
  ------------------
 8113|      0|        rowblock = td->td_ycbcrsubsampling[1];
 8114|      2|    else
 8115|      2|        rowblock = 1;
 8116|      2|    rowblockbytes = TIFFVStripSize64(tif, rowblock);
 8117|      2|    if (rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL)
  ------------------
  |  Branch (8117:9): [True: 0, False: 2]
  |  Branch (8117:31): [True: 1, False: 1]
  ------------------
 8118|      1|    {
 8119|       |        /* In case of file with gigantic width */
 8120|      1|        return;
 8121|      1|    }
 8122|       |
 8123|       |    /* Check that the strips are contiguous and of the expected size */
 8124|      2|    for (i = 0; i < td->td_nstrips; i++)
  ------------------
  |  Branch (8124:17): [True: 1, False: 1]
  ------------------
 8125|      1|    {
 8126|      1|        if (i == td->td_nstrips - 1)
  ------------------
  |  Branch (8126:13): [True: 1, False: 0]
  ------------------
 8127|      1|        {
 8128|      1|            if (TIFFGetStrileByteCount(tif, i) <
  ------------------
  |  Branch (8128:17): [True: 0, False: 1]
  ------------------
 8129|      1|                TIFFVStripSize64(tif,
 8130|      1|                                 td->td_imagelength - i * td->td_rowsperstrip))
 8131|      0|            {
 8132|      0|                return;
 8133|      0|            }
 8134|      1|        }
 8135|      0|        else
 8136|      0|        {
 8137|      0|            if (TIFFGetStrileByteCount(tif, i) != stripsize)
  ------------------
  |  Branch (8137:17): [True: 0, False: 0]
  ------------------
 8138|      0|            {
 8139|      0|                return;
 8140|      0|            }
 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|      1|    }
 8149|       |
 8150|       |    /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */
 8151|      1|    rowblocksperstrip = (uint32_t)(512 * 1024 * 1024 / rowblockbytes);
 8152|      1|    if (rowblocksperstrip == 0)
  ------------------
  |  Branch (8152:9): [True: 0, False: 1]
  ------------------
 8153|      0|        rowblocksperstrip = 1;
 8154|      1|    rowsperstrip = rowblocksperstrip * rowblock;
 8155|      1|    stripbytes = rowblocksperstrip * rowblockbytes;
 8156|      1|    assert(stripbytes <= 0x7FFFFFFFUL);
  ------------------
  |  Branch (8156:5): [True: 0, False: 1]
  |  Branch (8156:5): [True: 1, False: 0]
  ------------------
 8157|       |
 8158|      1|    if (rowsperstrip == 0)
  ------------------
  |  Branch (8158:9): [True: 0, False: 1]
  ------------------
 8159|      0|        return;
 8160|      1|    nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  312|      1|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  313|      1|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|      1|         : 0U)
  ------------------
 8161|      1|    if (nstrips == 0)
  ------------------
  |  Branch (8161:9): [True: 0, False: 1]
  ------------------
 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|      1|    if (tif->tif_mode == O_RDONLY && nstrips > 1000000)
  ------------------
  |  Branch (8166:9): [True: 1, False: 0]
  |  Branch (8166:38): [True: 1, False: 0]
  ------------------
 8167|      1|    {
 8168|      1|        uint64_t last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
 8169|      1|        uint64_t filesize = TIFFGetFileSize(tif);
  ------------------
  |  |  289|      1|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 8170|      1|        uint64_t last_bytecount =
 8171|      1|            TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
 8172|      1|        if (last_offset > filesize || last_bytecount > filesize - last_offset)
  ------------------
  |  Branch (8172:13): [True: 1, False: 0]
  |  Branch (8172:39): [True: 0, False: 0]
  ------------------
 8173|      1|        {
 8174|      1|            return;
 8175|      1|        }
 8176|      1|    }
 8177|       |
 8178|      0|    allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
 8179|      0|}
tif_dirread.c:_TIFFGetStrileOffsetOrByteCountValue:
 8456|   154k|{
 8457|   154k|    TIFFDirectory *td = &tif->tif_dir;
 8458|   154k|    if (pbErr)
  ------------------
  |  Branch (8458:9): [True: 144k, False: 10.6k]
  ------------------
 8459|   144k|        *pbErr = 0;
 8460|       |
 8461|   154k|    if (strile >= td->td_nstrips)
  ------------------
  |  Branch (8461:9): [True: 0, False: 154k]
  ------------------
 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|   154k|    if ((td->td_stripoffset_entry.tdir_count <= 4) !=
  ------------------
  |  Branch (8472:9): [True: 33, False: 154k]
  ------------------
 8473|   154k|        (td->td_stripbytecount_entry.tdir_count <= 4))
 8474|     33|    {
 8475|     33|        TIFFErrorExtR(tif, "_TIFFGetStrileOffsetOrByteCountValue",
 8476|     33|                      "Inconsistent directory count between StripOffsets and "
 8477|     33|                      "StripByteCounts");
 8478|     33|        if (pbErr)
  ------------------
  |  Branch (8478:13): [True: 25, False: 8]
  ------------------
 8479|     25|            *pbErr = 1;
 8480|     33|        return 0;
 8481|     33|    }
 8482|       |
 8483|   154k|    if ((tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
  ------------------
  |  |  147|   154k|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (8483:9): [True: 0, False: 154k]
  ------------------
 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|   154k|    if (*parray == NULL)
  ------------------
  |  Branch (8510:9): [True: 77, False: 154k]
  ------------------
 8511|     77|    {
 8512|     77|        if (pbErr)
  ------------------
  |  Branch (8512:13): [True: 77, False: 0]
  ------------------
 8513|     77|            *pbErr = 1;
 8514|     77|        return 0;
 8515|     77|    }
 8516|   154k|    return (*parray)[strile];
 8517|   154k|}
tif_dirread.c:_TIFFFillStrilesInternal:
 8556|    413|{
 8557|    413|    TIFFDirectory *td = &tif->tif_dir;
 8558|    413|    int return_value = 1;
 8559|       |
 8560|       |    /* Do not do anything if TIFF_DEFERSTRILELOAD is not set */
 8561|    413|    if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) ||
  ------------------
  |  |  147|    413|    0x1000000U /* defer strip/tile offset/bytecount array loading. */
  ------------------
  |  Branch (8561:9): [True: 413, 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|    413|        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|    690|{
  127|    690|    (void)scheme;
  128|    690|    tif->tif_fixuptags = DumpFixupTags;
  129|    690|    tif->tif_decoderow = DumpModeDecode;
  130|    690|    tif->tif_decodestrip = DumpModeDecode;
  131|    690|    tif->tif_decodetile = DumpModeDecode;
  132|    690|    tif->tif_encoderow = DumpModeEncode;
  133|    690|    tif->tif_encodestrip = DumpModeEncode;
  134|    690|    tif->tif_encodetile = DumpModeEncode;
  135|    690|    tif->tif_seek = DumpModeSeek;
  136|    690|    return (1);
  137|    690|}
tif_dumpmode.c:DumpFixupTags:
   33|     17|{
   34|     17|    (void)tif;
   35|     17|    return (1);
   36|     17|}
tif_dumpmode.c:DumpModeDecode:
   74|      8|{
   75|      8|    static const char module[] = "DumpModeDecode";
   76|      8|    (void)s;
   77|      8|    if (tif->tif_rawcc < cc)
  ------------------
  |  Branch (77:9): [True: 8, False: 0]
  ------------------
   78|      8|    {
   79|      8|        TIFFErrorExtR(tif, module,
   80|      8|                      "Not enough data for scanline %" PRIu32
   81|      8|                      ", expected a request for at most %" TIFF_SSIZE_FORMAT
   82|      8|                      " bytes, got a request for %" TIFF_SSIZE_FORMAT " bytes",
   83|      8|                      tif->tif_dir.td_row, tif->tif_rawcc, cc);
   84|      8|        return (0);
   85|      8|    }
   86|       |    /*
   87|       |     * Avoid copy if client has setup raw
   88|       |     * data buffer to avoid extra copy.
   89|       |     */
   90|      0|    if (tif->tif_rawcp != buf)
  ------------------
  |  Branch (90:9): [True: 0, False: 0]
  ------------------
   91|      0|        _TIFFmemcpy(buf, tif->tif_rawcp, cc);
   92|      0|    tif->tif_rawcp += cc;
   93|      0|    tif->tif_rawcc -= cc;
   94|      0|    return (1);
   95|      8|}

TIFFSetErrorHandler:
   33|    402|{
   34|    402|    TIFFErrorHandler prev = _TIFFerrorHandler;
   35|    402|    _TIFFerrorHandler = handler;
   36|    402|    return (prev);
   37|    402|}
TIFFErrorExtR:
  108|  66.8k|{
  109|  66.8k|    va_list ap;
  110|  66.8k|    if (tif && tif->tif_errorhandler)
  ------------------
  |  Branch (110:9): [True: 66.8k, False: 0]
  |  Branch (110:16): [True: 0, False: 66.8k]
  ------------------
  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|  66.8k|    if (_TIFFerrorHandler)
  ------------------
  |  Branch (119:9): [True: 66.8k, False: 0]
  ------------------
  120|  66.8k|    {
  121|  66.8k|        va_start(ap, fmt);
  122|  66.8k|        (*_TIFFerrorHandler)(module, fmt, ap);
  123|  66.8k|        va_end(ap);
  124|  66.8k|    }
  125|  66.8k|    if (_TIFFerrorHandlerExt)
  ------------------
  |  Branch (125:9): [True: 0, False: 66.8k]
  ------------------
  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|  66.8k|}

_TIFFFax3fillruns:
  464|  35.9k|{
  465|  35.9k|    static const unsigned char _fillmasks[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
  466|  35.9k|                                               0xf8, 0xfc, 0xfe, 0xff};
  467|  35.9k|    unsigned char *cp;
  468|  35.9k|    uint32_t x, bx, run;
  469|  35.9k|    int32_t n, nw;
  470|  35.9k|    int64_t *lp;
  471|       |
  472|  35.9k|    if ((erun - runs) & 1)
  ------------------
  |  Branch (472:9): [True: 34.6k, False: 1.32k]
  ------------------
  473|  34.6k|        *erun++ = 0;
  474|  35.9k|    x = 0;
  475|  85.5k|    for (; runs < erun; runs += 2)
  ------------------
  |  Branch (475:12): [True: 49.5k, False: 35.9k]
  ------------------
  476|  49.5k|    {
  477|  49.5k|        run = runs[0];
  478|  49.5k|        if (x + run > lastx || run > lastx)
  ------------------
  |  Branch (478:13): [True: 3.33k, False: 46.2k]
  |  Branch (478:32): [True: 0, False: 46.2k]
  ------------------
  479|  3.33k|            run = runs[0] = (uint32_t)(lastx - x);
  480|  49.5k|        if (run)
  ------------------
  |  Branch (480:13): [True: 46.1k, False: 3.48k]
  ------------------
  481|  46.1k|        {
  482|  46.1k|            cp = buf + (x >> 3);
  483|  46.1k|            bx = x & 7;
  484|  46.1k|            if (run > 8 - bx)
  ------------------
  |  Branch (484:17): [True: 38.8k, False: 7.26k]
  ------------------
  485|  38.8k|            {
  486|  38.8k|                if (bx)
  ------------------
  |  Branch (486:21): [True: 6.10k, False: 32.7k]
  ------------------
  487|  6.10k|                { /* align to byte boundary */
  488|  6.10k|                    *cp++ &= (unsigned char)(0xff << (8 - bx));
  489|  6.10k|                    run -= 8 - bx;
  490|  6.10k|                }
  491|  38.8k|                if ((n = (int32_t)(run >> 3)) != 0)
  ------------------
  |  Branch (491:21): [True: 37.4k, False: 1.44k]
  ------------------
  492|  37.4k|                { /* multiple bytes to fill */
  493|  37.4k|                    if (((size_t)n / sizeof(int64_t)) > 1)
  ------------------
  |  Branch (493:25): [True: 4.28k, False: 33.1k]
  ------------------
  494|  4.28k|                    {
  495|       |                        /*
  496|       |                         * Align to int64_tword boundary and fill.
  497|       |                         */
  498|  19.2k|                        for (; n && !isAligned(cp, int64_t); n--)
  ------------------
  |  |  112|  19.2k|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (498:32): [True: 19.2k, False: 0]
  |  Branch (498:37): [True: 15.0k, False: 4.28k]
  ------------------
  499|  15.0k|                            *cp++ = 0x00;
  500|  4.28k|                        lp = (int64_t *)cp;
  501|  4.28k|                        nw = (int32_t)((size_t)n / sizeof(int64_t));
  502|  4.28k|                        n -= (int32_t)((size_t)nw * sizeof(int64_t));
  503|  4.28k|                        do
  504|   119k|                        {
  505|   119k|                            *lp++ = 0L;
  506|   119k|                        } while (--nw);
  ------------------
  |  Branch (506:34): [True: 115k, False: 4.28k]
  ------------------
  507|  4.28k|                        cp = (unsigned char *)lp;
  508|  4.28k|                    }
  509|  37.4k|                    ZERO(n, cp);
  ------------------
  |  |  452|   168k|    for (int32_t izero = 0; izero < (n); ++izero)                              \
  |  |  ------------------
  |  |  |  Branch (452:29): [True: 131k, False: 37.4k]
  |  |  ------------------
  |  |  453|   131k|    {                                                                          \
  |  |  454|   131k|        (cp)[izero] = 0;                                                       \
  |  |  455|   131k|    }                                                                          \
  |  |  456|  37.4k|    (cp) += (n);
  ------------------
  510|  37.4k|                    run &= 7;
  511|  37.4k|                }
  512|  38.8k|                if (run)
  ------------------
  |  Branch (512:21): [True: 12.2k, False: 26.5k]
  ------------------
  513|  12.2k|                    cp[0] &= (unsigned char)(0xff >> run);
  514|  38.8k|            }
  515|  7.26k|            else
  516|  7.26k|                cp[0] &= (unsigned char)~(_fillmasks[run] >> bx);
  517|  46.1k|            x += runs[0];
  518|  46.1k|        }
  519|  49.5k|        run = runs[1];
  520|  49.5k|        if (x + run > lastx || run > lastx)
  ------------------
  |  Branch (520:13): [True: 0, False: 49.5k]
  |  Branch (520:32): [True: 0, False: 49.5k]
  ------------------
  521|      0|            run = runs[1] = lastx - x;
  522|  49.5k|        if (run)
  ------------------
  |  Branch (522:13): [True: 9.03k, False: 40.5k]
  ------------------
  523|  9.03k|        {
  524|  9.03k|            cp = buf + (x >> 3);
  525|  9.03k|            bx = x & 7;
  526|  9.03k|            if (run > 8 - bx)
  ------------------
  |  Branch (526:17): [True: 4.11k, False: 4.91k]
  ------------------
  527|  4.11k|            {
  528|  4.11k|                if (bx)
  ------------------
  |  Branch (528:21): [True: 3.88k, False: 231]
  ------------------
  529|  3.88k|                { /* align to byte boundary */
  530|  3.88k|                    *cp++ |= (unsigned char)(0xff >> bx);
  531|  3.88k|                    run -= 8 - bx;
  532|  3.88k|                }
  533|  4.11k|                if ((n = (int32_t)(run >> 3)) != 0)
  ------------------
  |  Branch (533:21): [True: 1.78k, False: 2.33k]
  ------------------
  534|  1.78k|                { /* multiple bytes to fill */
  535|  1.78k|                    if (((size_t)n / sizeof(int64_t)) > 1)
  ------------------
  |  Branch (535:25): [True: 120, False: 1.66k]
  ------------------
  536|    120|                    {
  537|       |                        /*
  538|       |                         * Align to int64_t boundary and fill.
  539|       |                         */
  540|    512|                        for (; n && !isAligned(cp, int64_t); n--)
  ------------------
  |  |  112|    512|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (540:32): [True: 512, False: 0]
  |  Branch (540:37): [True: 392, False: 120]
  ------------------
  541|    392|                            *cp++ = 0xff;
  542|    120|                        lp = (int64_t *)cp;
  543|    120|                        nw = (int32_t)((size_t)n / sizeof(int64_t));
  544|    120|                        n -= (int32_t)((size_t)nw * sizeof(int64_t));
  545|    120|                        do
  546|  3.10k|                        {
  547|  3.10k|                            *lp++ = -1L;
  548|  3.10k|                        } while (--nw);
  ------------------
  |  Branch (548:34): [True: 2.98k, False: 120]
  ------------------
  549|    120|                        cp = (unsigned char *)lp;
  550|    120|                    }
  551|  1.78k|                    FILL(n, cp);
  ------------------
  |  |  445|  4.87k|    for (int32_t ifill = 0; ifill < (n); ++ifill)                              \
  |  |  ------------------
  |  |  |  Branch (445:29): [True: 3.08k, False: 1.78k]
  |  |  ------------------
  |  |  446|  3.08k|    {                                                                          \
  |  |  447|  3.08k|        (cp)[ifill] = 0xff;                                                    \
  |  |  448|  3.08k|    }                                                                          \
  |  |  449|  1.78k|    (cp) += (n);
  ------------------
  552|  1.78k|                    run &= 7;
  553|  1.78k|                }
  554|       |                /* Explicit 0xff masking to make icc -check=conversions happy */
  555|  4.11k|                if (run)
  ------------------
  |  Branch (555:21): [True: 3.00k, False: 1.10k]
  ------------------
  556|  3.00k|                    cp[0] = (unsigned char)((cp[0] | (0xff00 >> run)) & 0xff);
  557|  4.11k|            }
  558|  4.91k|            else
  559|  4.91k|                cp[0] |= (unsigned char)(_fillmasks[run] >> bx);
  560|  9.03k|            x += runs[1];
  561|  9.03k|        }
  562|  49.5k|    }
  563|       |    assert(x == lastx);
  ------------------
  |  Branch (563:5): [True: 0, False: 35.9k]
  |  Branch (563:5): [True: 35.9k, False: 0]
  ------------------
  564|  35.9k|}
TIFFInitCCITTFax3:
 1607|     17|{
 1608|     17|    (void)scheme;
 1609|     17|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1609:9): [True: 17, False: 0]
  ------------------
 1610|     17|    {
 1611|       |        /*
 1612|       |         * Merge codec-specific tag information.
 1613|       |         */
 1614|     17|        if (!_TIFFMergeFields(tif, fax3Fields, TIFFArrayCount(fax3Fields)))
  ------------------
  |  |  339|     17|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1614:13): [True: 0, False: 17]
  ------------------
 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|     17|        return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
  ------------------
  |  |  697|     17|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
                      return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
  ------------------
  |  |  703|     17|#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */
  |  |  ------------------
  |  |  |  |  699|     17|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  |  |  ------------------
  ------------------
 1625|     17|    }
 1626|      0|    else
 1627|      0|        return 01;
 1628|     17|}
TIFFInitCCITTRLE:
 1871|      4|{
 1872|      4|    (void)scheme;
 1873|      4|    if (InitCCITTFax3(tif))
  ------------------
  |  Branch (1873:9): [True: 4, False: 0]
  ------------------
 1874|      4|    { /* reuse G3 support */
 1875|      4|        tif->tif_decoderow = Fax3DecodeRLE;
 1876|      4|        tif->tif_decodestrip = Fax3DecodeRLE;
 1877|      4|        tif->tif_decodetile = Fax3DecodeRLE;
 1878|      4|        tif->tif_getmaxcompressionratio = Fax3RLEGetMaxCompressionRatio;
 1879|       |        /*
 1880|       |         * Suppress RTC+EOLs when encoding and byte-align data.
 1881|       |         */
 1882|      4|        return TIFFSetField(tif, TIFFTAG_FAXMODE,
  ------------------
  |  |  697|      4|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
 1883|      4|                            FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  699|      4|#define FAXMODE_NORTC 0x0001         /* no RTC at end of data */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  700|      4|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  ------------------
                                          FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
  ------------------
  |  |  701|      4|#define FAXMODE_BYTEALIGN 0x0004     /* byte align row */
  ------------------
 1884|      4|    }
 1885|      0|    else
 1886|      0|        return (0);
 1887|      4|}
tif_fax3.c:InitCCITTFax3:
 1538|     21|{
 1539|     21|    static const char module[] = "InitCCITTFax3";
 1540|     21|    Fax3BaseState *sp;
 1541|       |
 1542|       |    /*
 1543|       |     * Merge codec-specific tag information.
 1544|       |     */
 1545|     21|    if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields)))
  ------------------
  |  |  339|     21|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1545:9): [True: 0, False: 21]
  ------------------
 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|     21|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(Fax3CodecState));
 1556|       |
 1557|     21|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1557:9): [True: 0, False: 21]
  ------------------
 1558|      0|    {
 1559|      0|        TIFFErrorExtR(tif, module, "No space for state block");
 1560|      0|        return (0);
 1561|      0|    }
 1562|     21|    _TIFFmemset(tif->tif_data, 0, sizeof(Fax3CodecState));
 1563|       |
 1564|     21|    sp = Fax3State(tif);
  ------------------
  |  |   72|     21|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1565|     21|    sp->rw_mode = tif->tif_mode;
 1566|       |
 1567|       |    /*
 1568|       |     * Override parent get/set field methods.
 1569|       |     */
 1570|     21|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1571|     21|    tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */
 1572|     21|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1573|     21|    tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */
 1574|     21|    sp->printdir = tif->tif_tagmethods.printdir;
 1575|     21|    tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */
 1576|     21|    sp->groupoptions = 0;
 1577|       |
 1578|     21|    if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */
  ------------------
  |  Branch (1578:9): [True: 21, False: 0]
  ------------------
 1579|     21|        tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */
  ------------------
  |  |  127|     21|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 1580|     21|    DecoderState(tif)->runs = NULL;
  ------------------
  |  |  108|     21|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     21|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1581|     21|    TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
  ------------------
  |  |  713|     21|#define TIFFTAG_FAXFILLFUNC 65540     /* G3/G4 fill function */
  ------------------
 1582|     21|    EncoderState(tif)->refline = NULL;
  ------------------
  |  |  109|     21|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     21|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |    /*
 1585|       |     * Install codec methods.
 1586|       |     */
 1587|     21|    tif->tif_fixuptags = Fax3FixupTags;
 1588|     21|    tif->tif_setupdecode = Fax3SetupState;
 1589|     21|    tif->tif_predecode = Fax3PreDecode;
 1590|     21|    tif->tif_decoderow = Fax3Decode1D;
 1591|     21|    tif->tif_decodestrip = Fax3Decode1D;
 1592|     21|    tif->tif_decodetile = Fax3Decode1D;
 1593|     21|    tif->tif_setupencode = Fax3SetupState;
 1594|     21|    tif->tif_preencode = Fax3PreEncode;
 1595|     21|    tif->tif_postencode = Fax3PostEncode;
 1596|     21|    tif->tif_encoderow = Fax3Encode;
 1597|     21|    tif->tif_encodestrip = Fax3Encode;
 1598|     21|    tif->tif_encodetile = Fax3Encode;
 1599|     21|    tif->tif_close = Fax3Close;
 1600|     21|    tif->tif_cleanup = Fax3Cleanup;
 1601|     21|    tif->tif_getmaxcompressionratio = Fax3GetMaxCompressionRatio;
 1602|       |
 1603|     21|    return (1);
 1604|     21|}
tif_fax3.c:Fax3VGetField:
 1424|    108|{
 1425|    108|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|    108|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1426|       |
 1427|    108|    assert(sp != 0);
  ------------------
  |  Branch (1427:5): [True: 0, False: 108]
  |  Branch (1427:5): [True: 108, False: 0]
  ------------------
 1428|       |
 1429|    108|    switch (tag)
 1430|    108|    {
 1431|      0|        case TIFFTAG_FAXMODE:
  ------------------
  |  |  697|      0|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
  |  Branch (1431:9): [True: 0, False: 108]
  ------------------
 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: 108]
  ------------------
 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: 108]
  ------------------
 1438|      0|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|      0|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1438:9): [True: 0, False: 108]
  ------------------
 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: 108]
  ------------------
 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: 108]
  ------------------
 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: 108]
  ------------------
 1448|      0|            *va_arg(ap, uint32_t *) = sp->badfaxrun;
 1449|      0|            break;
 1450|    108|        default:
  ------------------
  |  Branch (1450:9): [True: 108, False: 0]
  ------------------
 1451|    108|            return (*sp->vgetparent)(tif, tag, ap);
 1452|    108|    }
 1453|      0|    return (1);
 1454|    108|}
tif_fax3.c:Fax3VSetField:
 1376|    214|{
 1377|    214|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|    214|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
 1378|    214|    const TIFFField *fip;
 1379|       |
 1380|    214|    assert(sp != 0);
  ------------------
  |  Branch (1380:5): [True: 0, False: 214]
  |  Branch (1380:5): [True: 214, False: 0]
  ------------------
 1381|    214|    assert(sp->vsetparent != 0);
  ------------------
  |  Branch (1381:5): [True: 0, False: 214]
  |  Branch (1381:5): [True: 214, False: 0]
  ------------------
 1382|       |
 1383|    214|    switch (tag)
 1384|    214|    {
 1385|     21|        case TIFFTAG_FAXMODE:
  ------------------
  |  |  697|     21|#define TIFFTAG_FAXMODE 65536        /* Group 3/4 format control */
  ------------------
  |  Branch (1385:9): [True: 21, False: 193]
  ------------------
 1386|     21|            sp->mode = (int)va_arg(ap, int);
 1387|     21|            return 1; /* NB: pseudo tag */
 1388|     21|        case TIFFTAG_FAXFILLFUNC:
  ------------------
  |  |  713|     21|#define TIFFTAG_FAXFILLFUNC 65540     /* G3/G4 fill function */
  ------------------
  |  Branch (1388:9): [True: 21, False: 193]
  ------------------
 1389|     21|            DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
  ------------------
  |  |  108|     21|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     21|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1390|     21|            return 1; /* NB: pseudo tag */
 1391|     12|        case TIFFTAG_GROUP3OPTIONS:
  ------------------
  |  |  279|     12|#define TIFFTAG_GROUP3OPTIONS 292          /* 32 flag bits */
  ------------------
  |  Branch (1391:9): [True: 12, False: 202]
  ------------------
 1392|       |            /* XXX: avoid reading options if compression mismatches. */
 1393|     12|            if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
  ------------------
  |  |  184|     12|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (1393:17): [True: 12, False: 0]
  ------------------
 1394|     12|                sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
 1395|     12|            break;
 1396|      0|        case TIFFTAG_GROUP4OPTIONS:
  ------------------
  |  |  284|      0|#define TIFFTAG_GROUP4OPTIONS 293          /* 32 flag bits */
  ------------------
  |  Branch (1396:9): [True: 0, False: 214]
  ------------------
 1397|       |            /* XXX: avoid reading options if compression mismatches. */
 1398|      0|            if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
  ------------------
  |  |  186|      0|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (1398:17): [True: 0, False: 0]
  ------------------
 1399|      0|                sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
 1400|      0|            break;
 1401|      0|        case TIFFTAG_BADFAXLINES:
  ------------------
  |  |  315|      0|#define TIFFTAG_BADFAXLINES 326            /* lines w/ wrong pixel count */
  ------------------
  |  Branch (1401:9): [True: 0, False: 214]
  ------------------
 1402|      0|            sp->badfaxlines = (uint32_t)va_arg(ap, uint32_t);
 1403|      0|            break;
 1404|      0|        case TIFFTAG_CLEANFAXDATA:
  ------------------
  |  |  316|      0|#define TIFFTAG_CLEANFAXDATA 327           /* regenerated line info */
  ------------------
  |  Branch (1404:9): [True: 0, False: 214]
  ------------------
 1405|      0|            sp->cleanfaxdata = (uint16_t)va_arg(ap, uint16_vap);
 1406|      0|            break;
 1407|      0|        case TIFFTAG_CONSECUTIVEBADFAXLINES:
  ------------------
  |  |  320|      0|#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
  ------------------
  |  Branch (1407:9): [True: 0, False: 214]
  ------------------
 1408|      0|            sp->badfaxrun = (uint32_t)va_arg(ap, uint32_t);
 1409|      0|            break;
 1410|    160|        default:
  ------------------
  |  Branch (1410:9): [True: 160, False: 54]
  ------------------
 1411|    160|            return (*sp->vsetparent)(tif, tag, ap);
 1412|    214|    }
 1413|       |
 1414|     12|    if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
  ------------------
  |  Branch (1414:9): [True: 12, False: 0]
  ------------------
 1415|     12|        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|     12|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|     12|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|     12|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1416|      0|    else
 1417|      0|        return 0;
 1418|       |
 1419|     12|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|     12|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1420|     12|    return 1;
 1421|     12|}
tif_fax3.c:Fax3FixupTags:
  569|     12|{
  570|     12|    (void)tif;
  571|     12|    return (1);
  572|     12|}
tif_fax3.c:Fax3SetupState:
  582|     12|{
  583|     12|    static const char module[] = "Fax3SetupState";
  584|     12|    TIFFDirectory *td = &tif->tif_dir;
  585|     12|    Fax3BaseState *sp = Fax3State(tif);
  ------------------
  |  |   72|     12|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
  586|     12|    int needsRefLine;
  587|     12|    Fax3CodecState *dsp = (Fax3CodecState *)Fax3State(tif);
  ------------------
  |  |   72|     12|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  ------------------
  588|     12|    tmsize_t rowbytes;
  589|     12|    uint32_t rowpixels;
  590|       |
  591|     12|    if (td->td_bitspersample != 1)
  ------------------
  |  Branch (591:9): [True: 0, False: 12]
  ------------------
  592|      0|    {
  593|      0|        TIFFErrorExtR(tif, module,
  594|      0|                      "Bits/sample must be 1 for Group 3/4 encoding/decoding");
  595|      0|        return (0);
  596|      0|    }
  597|     12|    if (td->td_samplesperpixel != 1 &&
  ------------------
  |  Branch (597:9): [True: 0, False: 12]
  ------------------
  598|      0|        td->td_planarconfig != PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|      0|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (598:9): [True: 0, False: 0]
  ------------------
  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|     12|    if (isTiled(tif))
  ------------------
  |  |  278|     12|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     12|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 12]
  |  |  ------------------
  ------------------
  610|      0|    {
  611|      0|        rowbytes = TIFFTileRowSize(tif);
  612|      0|        rowpixels = td->td_tilewidth;
  613|      0|    }
  614|     12|    else
  615|     12|    {
  616|     12|        rowbytes = TIFFScanlineSize(tif);
  617|     12|        rowpixels = td->td_imagewidth;
  618|     12|    }
  619|     12|    if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8)
  ------------------
  |  Branch (619:9): [True: 0, False: 12]
  ------------------
  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|     12|    sp->rowbytes = rowbytes;
  628|     12|    sp->rowpixels = rowpixels;
  629|       |    /*
  630|       |     * Allocate any additional space required for decoding/encoding.
  631|       |     */
  632|     12|    needsRefLine = ((sp->groupoptions & GROUP3OPT_2DENCODING) ||
  ------------------
  |  |  281|     12|#define GROUP3OPT_2DENCODING 0x1           /* 2-dimensional coding */
  ------------------
  |  Branch (632:21): [True: 6, False: 6]
  ------------------
  633|      6|                    td->td_compression == COMPRESSION_CCITTFAX4);
  ------------------
  |  |  186|      6|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (633:21): [True: 0, False: 6]
  ------------------
  634|       |
  635|       |    /*
  636|       |      Assure that allocation computations do not overflow.
  637|       |
  638|       |      TIFFroundup and TIFFSafeMultiply return zero on integer overflow
  639|       |    */
  640|     12|    if (dsp->runs != NULL)
  ------------------
  |  Branch (640:9): [True: 0, False: 12]
  ------------------
  641|      0|    {
  642|      0|        _TIFFfreeExt(tif, dsp->runs);
  643|      0|        dsp->runs = (uint32_t *)NULL;
  644|      0|    }
  645|     12|    dsp->nruns = TIFFroundup_32(rowpixels + 1, 32);
  ------------------
  |  |  322|     12|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|     12|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  313|     12|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|     12|         : 0U)
  |  |  ------------------
  ------------------
  646|     12|    if (needsRefLine)
  ------------------
  |  Branch (646:9): [True: 6, False: 6]
  ------------------
  647|      6|    {
  648|      6|        dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2);
  ------------------
  |  |  332|      6|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 6, Folded]
  |  |  |  Branch (332:27): [True: 6, False: 0]
  |  |  ------------------
  |  |  333|      6|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|      6|         : (t)0)
  ------------------
  649|      6|    }
  650|     12|    if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0))
  ------------------
  |  |  332|     12|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 12, Folded]
  |  |  |  Branch (332:27): [True: 12, False: 0]
  |  |  ------------------
  |  |  333|     12|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     12|         : (t)0)
  ------------------
  |  Branch (650:9): [True: 0, False: 12]
  |  Branch (650:30): [True: 0, False: 12]
  ------------------
  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|     12|    dsp->runs = (uint32_t *)_TIFFCheckMalloc(
  658|     12|        tif, TIFFSafeMultiply(uint32_t, dsp->nruns, 2), sizeof(uint32_t),
  ------------------
  |  |  332|     12|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 12, Folded]
  |  |  |  Branch (332:27): [True: 12, False: 0]
  |  |  ------------------
  |  |  333|     12|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     12|         : (t)0)
  ------------------
  659|     12|        "for Group 3/4 run arrays");
  660|     12|    if (dsp->runs == NULL)
  ------------------
  |  Branch (660:9): [True: 0, False: 12]
  ------------------
  661|      0|        return (0);
  662|     12|    memset(dsp->runs, 0,
  663|     12|           TIFFSafeMultiply(uint32_t, dsp->nruns, 2) * sizeof(uint32_t));
  ------------------
  |  |  332|     12|    ((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
  |  |  ------------------
  |  |  |  Branch (332:7): [True: 12, Folded]
  |  |  |  Branch (332:27): [True: 12, False: 0]
  |  |  ------------------
  |  |  333|     12|         ? (t)(((t)(v)) * ((t)(m)))                                            \
  |  |  334|     12|         : (t)0)
  ------------------
  664|     12|    dsp->curruns = dsp->runs;
  665|     12|    if (needsRefLine)
  ------------------
  |  Branch (665:9): [True: 6, False: 6]
  ------------------
  666|      6|        dsp->refruns = dsp->runs + dsp->nruns;
  667|      6|    else
  668|      6|        dsp->refruns = NULL;
  669|     12|    if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp))
  ------------------
  |  |  184|     24|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
                  if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp))
  ------------------
  |  |  111|     11|#define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING)
  |  |  ------------------
  |  |  |  |  281|     11|#define GROUP3OPT_2DENCODING 0x1           /* 2-dimensional coding */
  |  |  ------------------
  |  |  |  Branch (111:26): [True: 6, False: 5]
  |  |  ------------------
  ------------------
  |  Branch (669:9): [True: 11, False: 1]
  ------------------
  670|      6|    { /* NB: default is 1D routine */
  671|      6|        tif->tif_decoderow = Fax3Decode2D;
  672|      6|        tif->tif_decodestrip = Fax3Decode2D;
  673|      6|        tif->tif_decodetile = Fax3Decode2D;
  674|      6|    }
  675|       |
  676|     12|    if (needsRefLine)
  ------------------
  |  Branch (676:9): [True: 6, False: 6]
  ------------------
  677|      6|    { /* 2d encoding */
  678|      6|        Fax3CodecState *esp = EncoderState(tif);
  ------------------
  |  |  109|      6|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|      6|#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|      6|        if (esp->refline != NULL)
  ------------------
  |  Branch (686:13): [True: 0, False: 6]
  ------------------
  687|      0|        {
  688|      0|            _TIFFfreeExt(tif, esp->refline);
  689|      0|        }
  690|      6|        esp->refline = (unsigned char *)_TIFFmallocExt(tif, rowbytes);
  691|      6|        if (esp->refline == NULL)
  ------------------
  |  Branch (691:13): [True: 0, False: 6]
  ------------------
  692|      0|        {
  693|      0|            TIFFErrorExtR(tif, module, "No space for Group 3/4 reference line");
  694|      0|            return (0);
  695|      0|        }
  696|      6|    }
  697|      6|    else /* 1d encoding */
  698|      6|        EncoderState(tif)->refline = NULL;
  ------------------
  |  |  109|      6|#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|      6|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  699|       |
  700|     12|    return (1);
  701|     12|}
tif_fax3.c:Fax3Decode2D:
  385|     12|{
  386|     12|    DECLARE_STATE_2D(tif, sp, "Fax3Decode2D");
  ------------------
  |  |  139|     12|    DECLARE_STATE(tif, sp, mod);                                               \
  |  |  ------------------
  |  |  |  |  123|     12|    static const char module[] = mod;                                          \
  |  |  |  |  124|     12|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  108|     12|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   72|     12|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  125|     12|    int a0;                                   /* reference element */          \
  |  |  |  |  126|     12|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  |  |  127|     12|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  |  |  128|     12|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  |  |  129|     12|    int RunLength;                            /* length of current run */      \
  |  |  |  |  130|     12|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  |  |  131|     12|    unsigned char *ep;                        /* end of input data */          \
  |  |  |  |  132|     12|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  |  |  133|     12|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  |  |  134|     12|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  |  |  135|     12|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  |  |  136|     12|    const TIFFFaxTabEnt *TabEnt
  |  |  ------------------
  |  |  140|     12|    int b1; /* next change on prev line */                                     \
  |  |  141|     12|    uint32_t                                                                   \
  |  |  142|     12|        *pb /* next run in reference line */ /*                                \
  ------------------
  387|     12|    int is1D; /* current line is 1d/2d-encoded */
  388|     12|    (void)s;
  389|     12|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (389:9): [True: 0, False: 12]
  ------------------
  390|      0|    {
  391|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  392|      0|        return (-1);
  393|      0|    }
  394|     12|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (394:9): [True: 0, False: 12]
  ------------------
  395|      0|        return (-1);
  396|     18|RETRY_WITHOUT_EOL_2D:
  397|     18|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|     18|    do                                                                         \
  |  |  148|     18|    {                                                                          \
  |  |  149|     18|        BitAcc = sp->data;                                                     \
  |  |  150|     18|        BitsAvail = sp->bit;                                                   \
  |  |  151|     18|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|     18|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|     18|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|     18|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 18]
  |  |  ------------------
  ------------------
  398|  10.4k|    while (occ > 0)
  ------------------
  |  Branch (398:12): [True: 10.4k, False: 7]
  ------------------
  399|  10.4k|    {
  400|  10.4k|        a0 = 0;
  401|  10.4k|        RunLength = 0;
  402|  10.4k|        pa = thisrun = sp->curruns;
  403|       |#ifdef FAX3_DEBUG
  404|       |        printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d EOLcnt = %d", BitAcc,
  405|       |               BitsAvail, EOLcnt);
  406|       |#endif
  407|  10.4k|        SYNC_EOL(EOF2D, RETRY_WITHOUT_EOL_2D);
  ------------------
  |  |  293|  10.4k|    do                                                                         \
  |  |  294|  10.4k|    {                                                                          \
  |  |  295|  10.4k|        if (!(sp->b.mode & FAXMODE_NOEOL)) /* skip EOL, if not present */      \
  |  |  ------------------
  |  |  |  |  700|  10.4k|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  |  Branch (295:13): [True: 879, False: 9.54k]
  |  |  ------------------
  |  |  296|  10.4k|        {                                                                      \
  |  |  297|    879|            if (EOLcnt == 0)                                                   \
  |  |  ------------------
  |  |  |  Branch (297:17): [True: 441, False: 438]
  |  |  ------------------
  |  |  298|    879|            {                                                                  \
  |  |  299|    441|                for (;;)                                                       \
  |  |  300|   472k|                {                                                              \
  |  |  301|   472k|                    NeedBits16(11, eoflab);                                    \
  |  |  ------------------
  |  |  |  |  164|   472k|    do                                                                         \
  |  |  |  |  165|   472k|    {                                                                          \
  |  |  |  |  166|   472k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:13): [True: 59.3k, False: 413k]
  |  |  |  |  ------------------
  |  |  |  |  167|   472k|        {                                                                      \
  |  |  |  |  168|  59.3k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  59.3k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 18, False: 59.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  169|  59.3k|            {                                                                  \
  |  |  |  |  170|     18|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (170:21): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  171|     18|                    goto eoflab;                                               \
  |  |  |  |  172|     18|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  173|     18|            }                                                                  \
  |  |  |  |  174|  59.3k|            else                                                               \
  |  |  |  |  175|  59.3k|            {                                                                  \
  |  |  |  |  176|  59.3k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  177|  59.3k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:21): [True: 68, False: 59.2k]
  |  |  |  |  ------------------
  |  |  |  |  178|  59.3k|                {                                                              \
  |  |  |  |  179|     68|                    if (EndOfData())                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|     68|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 68]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  180|     68|                    {                                                          \
  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  184|     68|                    else                                                       \
  |  |  |  |  185|     68|                    {                                                          \
  |  |  |  |  186|     68|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  187|     68|                        BitsAvail += 8;                                        \
  |  |  |  |  188|     68|                    }                                                          \
  |  |  |  |  189|     68|                }                                                              \
  |  |  |  |  190|  59.3k|            }                                                                  \
  |  |  |  |  191|  59.3k|        }                                                                      \
  |  |  |  |  192|   472k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:14): [Folded, False: 472k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  302|   472k|                    if (GetBits(11) == 0)                                      \
  |  |  ------------------
  |  |  |  |  194|   472k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (302:25): [True: 441, False: 472k]
  |  |  ------------------
  |  |  303|   472k|                        break; /* EOL found */                                 \
  |  |  304|   472k|                    ClrBits(1);                                                \
  |  |  ------------------
  |  |  |  |  196|   472k|    do                                                                         \
  |  |  |  |  197|   472k|    {                                                                          \
  |  |  |  |  198|   472k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|   472k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|   472k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 472k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  305|   472k|                }                                                              \
  |  |  306|    441|            }                                                                  \
  |  |  307|    879|            /* Now move after EOL or detect missing EOL. */                    \
  |  |  308|    879|            for (;;)                                                           \
  |  |  309|  2.62k|            {                                                                  \
  |  |  310|  2.62k|                NeedBits8(8, noEOLFound);                                      \
  |  |  ------------------
  |  |  |  |  144|  2.62k|    do                                                                         \
  |  |  |  |  145|  2.62k|    {                                                                          \
  |  |  |  |  146|  2.62k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 1.84k, False: 781]
  |  |  |  |  ------------------
  |  |  |  |  147|  2.62k|        {                                                                      \
  |  |  |  |  148|  1.84k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  1.84k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 12, False: 1.83k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  1.84k|            {                                                                  \
  |  |  |  |  150|     12|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 6, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  151|     12|                    goto eoflab;                                               \
  |  |  |  |  152|     12|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      6|            }                                                                  \
  |  |  |  |  154|  1.84k|            else                                                               \
  |  |  |  |  155|  1.84k|            {                                                                  \
  |  |  |  |  156|  1.83k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  1.83k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  1.83k|            }                                                                  \
  |  |  |  |  159|  1.84k|        }                                                                      \
  |  |  |  |  160|  2.62k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 2.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  311|  2.62k|                if (GetBits(8))                                                \
  |  |  ------------------
  |  |  |  |  194|  2.61k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 873, False: 1.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  312|  2.61k|                    break;                                                     \
  |  |  313|  2.61k|                ClrBits(8);                                                    \
  |  |  ------------------
  |  |  |  |  196|  1.74k|    do                                                                         \
  |  |  |  |  197|  1.74k|    {                                                                          \
  |  |  |  |  198|  1.74k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  1.74k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  1.74k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 1.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  314|  1.74k|            }                                                                  \
  |  |  315|  4.31k|            while (GetBits(1) == 0)                                            \
  |  |  ------------------
  |  |  |  |  194|  4.31k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (315:20): [True: 3.43k, False: 873]
  |  |  ------------------
  |  |  316|  3.43k|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|  4.31k|    do                                                                         \
  |  |  |  |  197|  4.31k|    {                                                                          \
  |  |  |  |  198|  3.43k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  3.43k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  3.43k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 3.43k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  317|    873|            ClrBits(1); /* EOL bit */                                          \
  |  |  ------------------
  |  |  |  |  196|    873|    do                                                                         \
  |  |  |  |  197|    873|    {                                                                          \
  |  |  |  |  198|    873|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|    873|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|    873|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 873]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  318|    873|            EOLcnt = 0; /* reset EOL counter/flag */                           \
  |  |  319|    873|            break;      /* existing EOL skipped, leave macro */                \
  |  |  320|    879|        noEOLFound:                                                            \
  |  |  321|      6|            sp->b.mode |= FAXMODE_NOEOL;                                       \
  |  |  ------------------
  |  |  |  |  700|      6|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  322|      6|            tryG3WithoutEOL(a0);                                               \
  |  |  ------------------
  |  |  |  |  289|      6|    do                                                                         \
  |  |  |  |  290|      6|    {                                                                          \
  |  |  |  |  291|      6|        Fax3TryG3WithoutEOL(module, tif, (uint32_t)sp->line, (uint32_t)(a0));  \
  |  |  |  |  292|      6|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:14): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  323|      6|            goto retrywithouteol;                                              \
  |  |  324|    879|        }                                                                      \
  |  |  325|  10.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (325:14): [Folded, False: 9.54k]
  |  |  ------------------
  ------------------
  408|  10.4k|        NeedBits8(1, EOF2D);
  ------------------
  |  |  144|  10.4k|    do                                                                         \
  |  |  145|  10.4k|    {                                                                          \
  |  |  146|  10.4k|        if (BitsAvail < (n))                                                   \
  |  |  ------------------
  |  |  |  Branch (146:13): [True: 570, False: 9.85k]
  |  |  ------------------
  |  |  147|  10.4k|        {                                                                      \
  |  |  148|    570|            if (EndOfData())                                                   \
  |  |  ------------------
  |  |  |  |  117|    570|#define EndOfData() (cp >= ep)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (117:21): [True: 0, False: 570]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  149|    570|            {                                                                  \
  |  |  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|    570|            else                                                               \
  |  |  155|    570|            {                                                                  \
  |  |  156|    570|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  157|    570|                BitsAvail += 8;                                                \
  |  |  158|    570|            }                                                                  \
  |  |  159|    570|        }                                                                      \
  |  |  160|  10.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (160:14): [Folded, False: 10.4k]
  |  |  ------------------
  ------------------
  409|  10.4k|        is1D = GetBits(1); /* 1D/2D-encoding tag bit */
  ------------------
  |  |  194|  10.4k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  ------------------
  410|  10.4k|        ClrBits(1);
  ------------------
  |  |  196|  10.4k|    do                                                                         \
  |  |  197|  10.4k|    {                                                                          \
  |  |  198|  10.4k|        BitsAvail -= (n);                                                      \
  |  |  199|  10.4k|        BitAcc >>= (n);                                                        \
  |  |  200|  10.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 10.4k]
  |  |  ------------------
  ------------------
  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|  10.4k|        pb = sp->refruns;
  417|  10.4k|        b1 = (int)*pb++;
  418|  10.4k|        if (is1D)
  ------------------
  |  Branch (418:13): [True: 2.71k, False: 7.70k]
  ------------------
  419|  2.71k|            EXPAND1D(EOF2Da);
  ------------------
  |  |  371|  2.71k|    do                                                                         \
  |  |  372|  2.71k|    {                                                                          \
  |  |  373|  2.71k|        for (;;)                                                               \
  |  |  374|  4.43k|        {                                                                      \
  |  |  375|  4.43k|            for (;;)                                                           \
  |  |  376|  46.5k|            {                                                                  \
  |  |  377|  46.5k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  46.5k|    do                                                                         \
  |  |  |  |  255|  46.5k|    {                                                                          \
  |  |  |  |  256|  46.5k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  46.5k|    do                                                                         \
  |  |  |  |  |  |  165|  46.5k|    {                                                                          \
  |  |  |  |  |  |  166|  46.5k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 45.0k, False: 1.51k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  46.5k|        {                                                                      \
  |  |  |  |  |  |  168|  45.0k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  45.0k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 45.0k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  45.0k|            {                                                                  \
  |  |  |  |  |  |  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|  45.0k|            else                                                               \
  |  |  |  |  |  |  175|  45.0k|            {                                                                  \
  |  |  |  |  |  |  176|  45.0k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  45.0k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 543, False: 44.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  45.0k|                {                                                              \
  |  |  |  |  |  |  179|    543|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    543|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 543]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|    543|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|    543|                    else                                                       \
  |  |  |  |  |  |  185|    543|                    {                                                          \
  |  |  |  |  |  |  186|    543|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|    543|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|    543|                    }                                                          \
  |  |  |  |  |  |  189|    543|                }                                                              \
  |  |  |  |  |  |  190|  45.0k|            }                                                                  \
  |  |  |  |  |  |  191|  45.0k|        }                                                                      \
  |  |  |  |  |  |  192|  46.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 46.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  46.5k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  46.5k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  46.5k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  46.5k|    do                                                                         \
  |  |  |  |  |  |  197|  46.5k|    {                                                                          \
  |  |  |  |  |  |  198|  46.5k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  46.5k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  46.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 46.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  46.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 46.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|  46.5k|                switch (TabEnt->State)                                         \
  |  |  379|  46.5k|                {                                                              \
  |  |  380|    251|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    251|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 251, False: 46.2k]
  |  |  ------------------
  |  |  381|    251|                        EOLcnt = 1;                                            \
  |  |  382|    251|                        goto done1d;                                           \
  |  |  383|  4.11k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  4.11k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 4.11k, False: 42.4k]
  |  |  ------------------
  |  |  384|  4.11k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  4.11k|    do                                                                         \
  |  |  |  |  267|  4.11k|    {                                                                          \
  |  |  |  |  268|  4.11k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 4.11k]
  |  |  |  |  ------------------
  |  |  |  |  269|  4.11k|        {                                                                      \
  |  |  |  |  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.11k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  4.11k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  4.11k|        RunLength = 0;                                                         \
  |  |  |  |  279|  4.11k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 4.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  4.11k|                        goto doneWhite1d;                                      \
  |  |  386|  42.0k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|  42.0k|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 42.0k, False: 4.51k]
  |  |  ------------------
  |  |  387|  42.0k|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|  42.0k|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 78, False: 46.4k]
  |  |  ------------------
  |  |  388|  42.0k|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|  42.0k|                        RunLength =                                            \
  |  |  390|  42.0k|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|  42.0k|                        break;                                                 \
  |  |  392|  42.0k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 74, False: 46.4k]
  |  |  ------------------
  |  |  393|     74|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|     74|    do                                                                         \
  |  |  |  |  221|     74|    {                                                                          \
  |  |  |  |  222|     74|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     74|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     74|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|     74|                        goto done1d;                                           \
  |  |  395|  46.5k|                }                                                              \
  |  |  396|  46.5k|            }                                                                  \
  |  |  397|  4.43k|        doneWhite1d:                                                           \
  |  |  398|  4.11k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 1.87k, False: 2.23k]
  |  |  ------------------
  |  |  399|  4.11k|                goto done1d;                                                   \
  |  |  400|  4.11k|            for (;;)                                                           \
  |  |  401|  2.32k|            {                                                                  \
  |  |  402|  2.32k|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  2.32k|    do                                                                         \
  |  |  |  |  255|  2.32k|    {                                                                          \
  |  |  |  |  256|  2.32k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  2.32k|    do                                                                         \
  |  |  |  |  |  |  165|  2.32k|    {                                                                          \
  |  |  |  |  |  |  166|  2.32k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 1.41k, False: 907]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  2.32k|        {                                                                      \
  |  |  |  |  |  |  168|  1.41k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  1.41k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 1.41k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.41k|            {                                                                  \
  |  |  |  |  |  |  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|  1.41k|            else                                                               \
  |  |  |  |  |  |  175|  1.41k|            {                                                                  \
  |  |  |  |  |  |  176|  1.41k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  1.41k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 6, False: 1.41k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  1.41k|                {                                                              \
  |  |  |  |  |  |  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|  1.41k|            }                                                                  \
  |  |  |  |  |  |  191|  1.41k|        }                                                                      \
  |  |  |  |  |  |  192|  2.32k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 2.32k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  2.32k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  2.32k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  2.32k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  2.32k|    do                                                                         \
  |  |  |  |  |  |  197|  2.32k|    {                                                                          \
  |  |  |  |  |  |  198|  2.32k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  2.32k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  2.32k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 2.32k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  2.32k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 2.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|  2.32k|                switch (TabEnt->State)                                         \
  |  |  404|  2.32k|                {                                                              \
  |  |  405|    201|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    201|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 201, False: 2.12k]
  |  |  ------------------
  |  |  406|    201|                        EOLcnt = 1;                                            \
  |  |  407|    201|                        goto done1d;                                           \
  |  |  408|  2.00k|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|  2.00k|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 2.00k, False: 318]
  |  |  ------------------
  |  |  409|  2.00k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  2.00k|    do                                                                         \
  |  |  |  |  267|  2.00k|    {                                                                          \
  |  |  |  |  268|  2.00k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 2.00k]
  |  |  |  |  ------------------
  |  |  |  |  269|  2.00k|        {                                                                      \
  |  |  |  |  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.00k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  2.00k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  2.00k|        RunLength = 0;                                                         \
  |  |  |  |  279|  2.00k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 2.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|  2.00k|                        goto doneBlack1d;                                      \
  |  |  411|  2.00k|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 0, False: 2.32k]
  |  |  ------------------
  |  |  412|     90|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|     90|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 90, False: 2.23k]
  |  |  ------------------
  |  |  413|     90|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|     90|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|     90|                        break;                                                 \
  |  |  416|     27|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 27, False: 2.29k]
  |  |  ------------------
  |  |  417|     27|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|     27|    do                                                                         \
  |  |  |  |  221|     27|    {                                                                          \
  |  |  |  |  222|     27|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     27|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     27|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|     27|                        goto done1d;                                           \
  |  |  419|  2.32k|                }                                                              \
  |  |  420|  2.32k|            }                                                                  \
  |  |  421|  2.23k|        doneBlack1d:                                                           \
  |  |  422|  2.00k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 285, False: 1.72k]
  |  |  ------------------
  |  |  423|  2.00k|                goto done1d;                                                   \
  |  |  424|  2.00k|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 1.72k]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|  1.72k|                pa -= 2;                                                       \
  |  |  426|  1.72k|        }                                                                      \
  |  |  427|  2.71k|    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.71k|    done1d:                                                                    \
  |  |  432|  2.71k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  2.71k|    do                                                                         \
  |  |  |  |  334|  2.71k|    {                                                                          \
  |  |  |  |  335|  2.71k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 71, False: 2.64k]
  |  |  |  |  ------------------
  |  |  |  |  336|  2.71k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     71|    do                                                                         \
  |  |  |  |  |  |  267|     71|    {                                                                          \
  |  |  |  |  |  |  268|     71|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 71]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     71|        {                                                                      \
  |  |  |  |  |  |  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|     71|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     71|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     71|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     71|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 71]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  2.71k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 2.62k, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  338|  2.71k|        {                                                                      \
  |  |  |  |  339|  2.62k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  2.62k|    do                                                                         \
  |  |  |  |  |  |  254|  2.62k|    {                                                                          \
  |  |  |  |  |  |  255|  2.62k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  2.62k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  2.62k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  2.62k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 2.62k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  4.76k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 2.14k, False: 2.62k]
  |  |  |  |  |  Branch (340:39): [True: 2.14k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  2.62k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  2.62k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 2.62k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  2.62k|            {                                                                  \
  |  |  |  |  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: 476, False: 2.14k]
  |  |  |  |  ------------------
  |  |  |  |  347|  2.62k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|    476|    do                                                                         \
  |  |  |  |  |  |  267|    476|    {                                                                          \
  |  |  |  |  |  |  268|    476|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 476]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|    476|        {                                                                      \
  |  |  |  |  |  |  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|    476|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|    476|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|    476|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|    476|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 476]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  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.62k|            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.62k|        }                                                                      \
  |  |  |  |  356|  2.71k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 2.71k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  2.71k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 2.71k]
  |  |  ------------------
  ------------------
  420|  7.70k|        else
  421|  7.70k|            EXPAND2D(EOF2Da);
  ------------------
  |  |  463|  7.70k|    do                                                                         \
  |  |  464|  7.70k|    {                                                                          \
  |  |  465|  16.7k|        while (a0 < (int)lastx)                                                \
  |  |  ------------------
  |  |  |  Branch (465:16): [True: 12.7k, False: 4.01k]
  |  |  ------------------
  |  |  466|  12.7k|        {                                                                      \
  |  |  467|  12.7k|            if (pa >= thisrun + sp->nruns)                                     \
  |  |  ------------------
  |  |  |  Branch (467:17): [True: 0, False: 12.7k]
  |  |  ------------------
  |  |  468|  12.7k|            {                                                                  \
  |  |  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|  12.7k|            LOOKUP8(7, TIFFFaxMainTable, eof2d);                               \
  |  |  ------------------
  |  |  |  |  247|  12.7k|    do                                                                         \
  |  |  |  |  248|  12.7k|    {                                                                          \
  |  |  |  |  249|  12.7k|        NeedBits8(wid, eoflab);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|  12.7k|    do                                                                         \
  |  |  |  |  |  |  145|  12.7k|    {                                                                          \
  |  |  |  |  |  |  146|  12.7k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:13): [True: 5.72k, False: 7.05k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  12.7k|        {                                                                      \
  |  |  |  |  |  |  148|  5.72k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  5.72k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 5.72k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  5.72k|            {                                                                  \
  |  |  |  |  |  |  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|  5.72k|            else                                                               \
  |  |  |  |  |  |  155|  5.72k|            {                                                                  \
  |  |  |  |  |  |  156|  5.72k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  157|  5.72k|                BitsAvail += 8;                                                \
  |  |  |  |  |  |  158|  5.72k|            }                                                                  \
  |  |  |  |  |  |  159|  5.72k|        }                                                                      \
  |  |  |  |  |  |  160|  12.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (160:14): [Folded, False: 12.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  250|  12.7k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  12.7k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  251|  12.7k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  12.7k|    do                                                                         \
  |  |  |  |  |  |  197|  12.7k|    {                                                                          \
  |  |  |  |  |  |  198|  12.7k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  12.7k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  12.7k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 12.7k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  252|  12.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (252:14): [Folded, False: 12.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  477|  12.7k|            switch (TabEnt->State)                                             \
  |  |  478|  12.7k|            {                                                                  \
  |  |  479|    467|                case S_Pass:                                                   \
  |  |  ------------------
  |  |  |  |   71|    467|#define S_Pass 1
  |  |  ------------------
  |  |  |  Branch (479:17): [True: 467, False: 12.3k]
  |  |  ------------------
  |  |  480|    467|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|    467|    do                                                                         \
  |  |  |  |  441|    467|    {                                                                          \
  |  |  |  |  442|    467|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 109, False: 358]
  |  |  |  |  ------------------
  |  |  |  |  443|    467|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 24, False: 109]
  |  |  |  |  |  Branch (443:32): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|    109|            {                                                                  \
  |  |  |  |  445|     24|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  446|     24|                {                                                              \
  |  |  |  |  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|     24|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|     24|                pb += 2;                                                       \
  |  |  |  |  456|     24|            }                                                                  \
  |  |  |  |  457|    467|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 467]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  481|    467|                    if (pb + 1 >= sp->refruns + sp->nruns)                     \
  |  |  ------------------
  |  |  |  Branch (481:25): [True: 0, False: 467]
  |  |  ------------------
  |  |  482|    467|                    {                                                          \
  |  |  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|    467|                    b1 = b1 + (int)*pb++;                                      \
  |  |  492|    467|                    RunLength =                                                \
  |  |  493|    467|                        (int)((uint32_t)RunLength + (uint32_t)(b1 - a0));      \
  |  |  494|    467|                    a0 = b1;                                                   \
  |  |  495|    467|                    b1 = b1 + (int)*pb++;                                      \
  |  |  496|    467|                    break;                                                     \
  |  |  497|  1.34k|                case S_Horiz:                                                  \
  |  |  ------------------
  |  |  |  |   72|  1.34k|#define S_Horiz 2
  |  |  ------------------
  |  |  |  Branch (497:17): [True: 1.34k, False: 11.4k]
  |  |  ------------------
  |  |  498|  1.34k|                    if ((pa - thisrun) & 1)                                    \
  |  |  ------------------
  |  |  |  Branch (498:25): [True: 724, False: 617]
  |  |  ------------------
  |  |  499|  1.34k|                    {                                                          \
  |  |  500|    724|                        for (;;)                                               \
  |  |  501|    746|                        { /* black first */                                    \
  |  |  502|    746|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|    746|    do                                                                         \
  |  |  |  |  255|    746|    {                                                                          \
  |  |  |  |  256|    746|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    746|    do                                                                         \
  |  |  |  |  |  |  165|    746|    {                                                                          \
  |  |  |  |  |  |  166|    746|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 740, False: 6]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    746|        {                                                                      \
  |  |  |  |  |  |  168|    740|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    740|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 740]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    740|            {                                                                  \
  |  |  |  |  |  |  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|    740|            else                                                               \
  |  |  |  |  |  |  175|    740|            {                                                                  \
  |  |  |  |  |  |  176|    740|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    740|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 12, False: 728]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    740|                {                                                              \
  |  |  |  |  |  |  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|    740|            }                                                                  \
  |  |  |  |  |  |  191|    740|        }                                                                      \
  |  |  |  |  |  |  192|    746|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 746]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    746|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    746|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    746|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    746|    do                                                                         \
  |  |  |  |  |  |  197|    746|    {                                                                          \
  |  |  |  |  |  |  198|    746|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    746|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    746|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 746]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    746|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 746]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  503|    746|                            switch (TabEnt->State)                             \
  |  |  504|    746|                            {                                                  \
  |  |  505|    699|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|    699|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (505:33): [True: 699, False: 47]
  |  |  ------------------
  |  |  506|    699|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    699|    do                                                                         \
  |  |  |  |  267|    699|    {                                                                          \
  |  |  |  |  268|    699|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 699]
  |  |  |  |  ------------------
  |  |  |  |  269|    699|        {                                                                      \
  |  |  |  |  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|    699|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    699|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    699|        RunLength = 0;                                                         \
  |  |  |  |  279|    699|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 699]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  507|    699|                                    goto doneWhite2da;                         \
  |  |  508|    699|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (508:33): [True: 0, False: 746]
  |  |  ------------------
  |  |  509|     22|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|     22|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (509:33): [True: 22, False: 724]
  |  |  ------------------
  |  |  510|     22|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  511|     22|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  512|     22|                                                      TabEnt->Param);          \
  |  |  513|     22|                                    break;                                     \
  |  |  514|     25|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (514:33): [True: 25, False: 721]
  |  |  ------------------
  |  |  515|     25|                                    goto badBlack2d;                           \
  |  |  516|    746|                            }                                                  \
  |  |  517|    746|                        }                                                      \
  |  |  518|    724|                    doneWhite2da:;                                             \
  |  |  519|    699|                        for (;;)                                               \
  |  |  520|  38.9k|                        { /* then white */                                     \
  |  |  521|  38.9k|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|  38.9k|    do                                                                         \
  |  |  |  |  255|  38.9k|    {                                                                          \
  |  |  |  |  256|  38.9k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  38.9k|    do                                                                         \
  |  |  |  |  |  |  165|  38.9k|    {                                                                          \
  |  |  |  |  |  |  166|  38.9k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 38.2k, False: 669]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  38.9k|        {                                                                      \
  |  |  |  |  |  |  168|  38.2k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  38.2k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 38.2k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  38.2k|            {                                                                  \
  |  |  |  |  |  |  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|  38.2k|            else                                                               \
  |  |  |  |  |  |  175|  38.2k|            {                                                                  \
  |  |  |  |  |  |  176|  38.2k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  38.2k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 38.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  38.2k|                {                                                              \
  |  |  |  |  |  |  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|  38.2k|            }                                                                  \
  |  |  |  |  |  |  191|  38.2k|        }                                                                      \
  |  |  |  |  |  |  192|  38.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 38.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  38.9k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  38.9k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  38.9k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  38.9k|    do                                                                         \
  |  |  |  |  |  |  197|  38.9k|    {                                                                          \
  |  |  |  |  |  |  198|  38.9k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  38.9k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  38.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 38.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  38.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 38.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  522|  38.9k|                            switch (TabEnt->State)                             \
  |  |  523|  38.9k|                            {                                                  \
  |  |  524|    677|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|    677|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (524:33): [True: 677, False: 38.2k]
  |  |  ------------------
  |  |  525|    677|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    677|    do                                                                         \
  |  |  |  |  267|    677|    {                                                                          \
  |  |  |  |  268|    677|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 677]
  |  |  |  |  ------------------
  |  |  |  |  269|    677|        {                                                                      \
  |  |  |  |  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|    677|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    677|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    677|        RunLength = 0;                                                         \
  |  |  |  |  279|    677|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 677]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  526|    677|                                    goto doneBlack2da;                         \
  |  |  527|  38.2k|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|  38.2k|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (527:33): [True: 38.2k, False: 699]
  |  |  ------------------
  |  |  528|  38.2k|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|  38.2k|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (528:33): [True: 0, False: 38.9k]
  |  |  ------------------
  |  |  529|  38.2k|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  530|  38.2k|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  531|  38.2k|                                                      TabEnt->Param);          \
  |  |  532|  38.2k|                                    break;                                     \
  |  |  533|  38.2k|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (533:33): [True: 22, False: 38.9k]
  |  |  ------------------
  |  |  534|     22|                                    goto badWhite2d;                           \
  |  |  535|  38.9k|                            }                                                  \
  |  |  536|  38.9k|                        }                                                      \
  |  |  537|    699|                    doneBlack2da:;                                             \
  |  |  538|    677|                    }                                                          \
  |  |  539|  1.34k|                    else                                                       \
  |  |  540|  1.34k|                    {                                                          \
  |  |  541|    617|                        for (;;)                                               \
  |  |  542|    704|                        { /* white first */                                    \
  |  |  543|    704|                            LOOKUP16(12, TIFFFaxWhiteTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|    704|    do                                                                         \
  |  |  |  |  255|    704|    {                                                                          \
  |  |  |  |  256|    704|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    704|    do                                                                         \
  |  |  |  |  |  |  165|    704|    {                                                                          \
  |  |  |  |  |  |  166|    704|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 665, False: 39]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    704|        {                                                                      \
  |  |  |  |  |  |  168|    665|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    665|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 665]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    665|            {                                                                  \
  |  |  |  |  |  |  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|    665|            else                                                               \
  |  |  |  |  |  |  175|    665|            {                                                                  \
  |  |  |  |  |  |  176|    665|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    665|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 0, False: 665]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    665|                {                                                              \
  |  |  |  |  |  |  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|    665|            }                                                                  \
  |  |  |  |  |  |  191|    665|        }                                                                      \
  |  |  |  |  |  |  192|    704|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 704]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    704|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    704|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    704|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    704|    do                                                                         \
  |  |  |  |  |  |  197|    704|    {                                                                          \
  |  |  |  |  |  |  198|    704|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    704|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    704|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 704]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    704|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 704]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  544|    704|                            switch (TabEnt->State)                             \
  |  |  545|    704|                            {                                                  \
  |  |  546|    482|                                case S_TermW:                                  \
  |  |  ------------------
  |  |  |  |   77|    482|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (546:33): [True: 482, False: 222]
  |  |  ------------------
  |  |  547|    482|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    482|    do                                                                         \
  |  |  |  |  267|    482|    {                                                                          \
  |  |  |  |  268|    482|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 482]
  |  |  |  |  ------------------
  |  |  |  |  269|    482|        {                                                                      \
  |  |  |  |  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|    482|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    482|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    482|        RunLength = 0;                                                         \
  |  |  |  |  279|    482|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 482]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  548|    482|                                    goto doneWhite2db;                         \
  |  |  549|    482|                                case S_MakeUpW:                                \
  |  |  ------------------
  |  |  |  |   79|     63|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (549:33): [True: 63, False: 641]
  |  |  ------------------
  |  |  550|     87|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|     87|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (550:33): [True: 24, False: 680]
  |  |  ------------------
  |  |  551|     87|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  552|     87|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  553|     87|                                                      TabEnt->Param);          \
  |  |  554|     87|                                    break;                                     \
  |  |  555|    135|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (555:33): [True: 135, False: 569]
  |  |  ------------------
  |  |  556|    135|                                    goto badWhite2d;                           \
  |  |  557|    704|                            }                                                  \
  |  |  558|    704|                        }                                                      \
  |  |  559|    617|                    doneWhite2db:;                                             \
  |  |  560|    482|                        for (;;)                                               \
  |  |  561|    483|                        { /* then black */                                     \
  |  |  562|    483|                            LOOKUP16(13, TIFFFaxBlackTable, eof2d);            \
  |  |  ------------------
  |  |  |  |  254|    483|    do                                                                         \
  |  |  |  |  255|    483|    {                                                                          \
  |  |  |  |  256|    483|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|    483|    do                                                                         \
  |  |  |  |  |  |  165|    483|    {                                                                          \
  |  |  |  |  |  |  166|    483|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 288, False: 195]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    483|        {                                                                      \
  |  |  |  |  |  |  168|    288|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    288|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 288]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|    288|            {                                                                  \
  |  |  |  |  |  |  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|    288|            else                                                               \
  |  |  |  |  |  |  175|    288|            {                                                                  \
  |  |  |  |  |  |  176|    288|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|    288|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 1, False: 287]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|    288|                {                                                              \
  |  |  |  |  |  |  179|      1|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      1|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 1]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      1|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      1|                    else                                                       \
  |  |  |  |  |  |  185|      1|                    {                                                          \
  |  |  |  |  |  |  186|      1|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      1|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      1|                    }                                                          \
  |  |  |  |  |  |  189|      1|                }                                                              \
  |  |  |  |  |  |  190|    288|            }                                                                  \
  |  |  |  |  |  |  191|    288|        }                                                                      \
  |  |  |  |  |  |  192|    483|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 483]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|    483|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|    483|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|    483|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|    483|    do                                                                         \
  |  |  |  |  |  |  197|    483|    {                                                                          \
  |  |  |  |  |  |  198|    483|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|    483|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|    483|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 483]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|    483|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 483]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  563|    483|                            switch (TabEnt->State)                             \
  |  |  564|    483|                            {                                                  \
  |  |  565|    335|                                case S_TermB:                                  \
  |  |  ------------------
  |  |  |  |   78|    335|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (565:33): [True: 335, False: 148]
  |  |  ------------------
  |  |  566|    335|                                    SETVALUE(TabEnt->Param);                   \
  |  |  ------------------
  |  |  |  |  266|    335|    do                                                                         \
  |  |  |  |  267|    335|    {                                                                          \
  |  |  |  |  268|    335|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 335]
  |  |  |  |  ------------------
  |  |  |  |  269|    335|        {                                                                      \
  |  |  |  |  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|    335|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    335|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    335|        RunLength = 0;                                                         \
  |  |  |  |  279|    335|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 335]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  567|    335|                                    goto doneBlack2db;                         \
  |  |  568|    335|                                case S_MakeUpB:                                \
  |  |  ------------------
  |  |  |  |   80|      0|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (568:33): [True: 0, False: 483]
  |  |  ------------------
  |  |  569|      1|                                case S_MakeUp:                                 \
  |  |  ------------------
  |  |  |  |   81|      1|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (569:33): [True: 1, False: 482]
  |  |  ------------------
  |  |  570|      1|                                    a0 = (int)((uint32_t)a0 + TabEnt->Param);  \
  |  |  571|      1|                                    RunLength = (int)((uint32_t)RunLength +    \
  |  |  572|      1|                                                      TabEnt->Param);          \
  |  |  573|      1|                                    break;                                     \
  |  |  574|    147|                                default:                                       \
  |  |  ------------------
  |  |  |  Branch (574:33): [True: 147, False: 336]
  |  |  ------------------
  |  |  575|    147|                                    goto badBlack2d;                           \
  |  |  576|    483|                            }                                                  \
  |  |  577|    483|                        }                                                      \
  |  |  578|    482|                    doneBlack2db:;                                             \
  |  |  579|    335|                    }                                                          \
  |  |  580|  1.34k|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|  1.01k|    do                                                                         \
  |  |  |  |  441|  1.01k|    {                                                                          \
  |  |  |  |  442|  1.01k|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 1.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  443|  1.78k|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 1.43k, False: 350]
  |  |  |  |  |  Branch (443:32): [True: 772, False: 662]
  |  |  |  |  ------------------
  |  |  |  |  444|  1.01k|            {                                                                  \
  |  |  |  |  445|    772|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 772]
  |  |  |  |  ------------------
  |  |  |  |  446|    772|                {                                                              \
  |  |  |  |  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|    772|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|    772|                pb += 2;                                                       \
  |  |  |  |  456|    772|            }                                                                  \
  |  |  |  |  457|  1.01k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 1.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  581|  1.01k|                    break;                                                     \
  |  |  582|  3.86k|                case S_V0:                                                     \
  |  |  ------------------
  |  |  |  |   73|  3.86k|#define S_V0 3
  |  |  ------------------
  |  |  |  Branch (582:17): [True: 3.86k, False: 8.91k]
  |  |  ------------------
  |  |  583|  3.86k|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|  3.86k|    do                                                                         \
  |  |  |  |  441|  3.86k|    {                                                                          \
  |  |  |  |  442|  3.86k|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 2.34k, False: 1.51k]
  |  |  |  |  ------------------
  |  |  |  |  443|  3.86k|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 562, False: 2.34k]
  |  |  |  |  |  Branch (443:32): [True: 562, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|  2.34k|            {                                                                  \
  |  |  |  |  445|    562|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 562]
  |  |  |  |  ------------------
  |  |  |  |  446|    562|                {                                                              \
  |  |  |  |  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|    562|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|    562|                pb += 2;                                                       \
  |  |  |  |  456|    562|            }                                                                  \
  |  |  |  |  457|  3.86k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 3.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  584|  3.86k|                    SETVALUE(b1 - a0);                                         \
  |  |  ------------------
  |  |  |  |  266|  3.86k|    do                                                                         \
  |  |  |  |  267|  3.86k|    {                                                                          \
  |  |  |  |  268|  3.86k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 3.86k]
  |  |  |  |  ------------------
  |  |  |  |  269|  3.86k|        {                                                                      \
  |  |  |  |  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.86k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  3.86k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  3.86k|        RunLength = 0;                                                         \
  |  |  |  |  279|  3.86k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 3.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  585|  3.86k|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (585:25): [True: 0, False: 3.86k]
  |  |  ------------------
  |  |  586|  3.86k|                    {                                                          \
  |  |  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|  3.86k|                    b1 = b1 + (int)*pb++;                                      \
  |  |  596|  3.86k|                    break;                                                     \
  |  |  597|  3.86k|                case S_VR:                                                     \
  |  |  ------------------
  |  |  |  |   74|  1.96k|#define S_VR 4
  |  |  ------------------
  |  |  |  Branch (597:17): [True: 1.96k, False: 10.8k]
  |  |  ------------------
  |  |  598|  1.96k|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|  1.96k|    do                                                                         \
  |  |  |  |  441|  1.96k|    {                                                                          \
  |  |  |  |  442|  1.96k|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 427, False: 1.53k]
  |  |  |  |  ------------------
  |  |  |  |  443|  1.96k|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 172, False: 427]
  |  |  |  |  |  Branch (443:32): [True: 172, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|    427|            {                                                                  \
  |  |  |  |  445|    172|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 172]
  |  |  |  |  ------------------
  |  |  |  |  446|    172|                {                                                              \
  |  |  |  |  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|    172|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|    172|                pb += 2;                                                       \
  |  |  |  |  456|    172|            }                                                                  \
  |  |  |  |  457|  1.96k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 1.96k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  599|  1.96k|                    SETVALUE((int)((uint32_t)(b1 - a0) + TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|  1.96k|    do                                                                         \
  |  |  |  |  267|  1.96k|    {                                                                          \
  |  |  |  |  268|  1.96k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.96k]
  |  |  |  |  ------------------
  |  |  |  |  269|  1.96k|        {                                                                      \
  |  |  |  |  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.96k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  1.96k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  1.96k|        RunLength = 0;                                                         \
  |  |  |  |  279|  1.96k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 1.96k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  600|  1.96k|                    if (pb >= sp->refruns + sp->nruns)                         \
  |  |  ------------------
  |  |  |  Branch (600:25): [True: 0, False: 1.96k]
  |  |  ------------------
  |  |  601|  1.96k|                    {                                                          \
  |  |  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|  1.96k|                    b1 = b1 + (int)*pb++;                                      \
  |  |  611|  1.96k|                    break;                                                     \
  |  |  612|  1.96k|                case S_VL:                                                     \
  |  |  ------------------
  |  |  |  |   75|  1.80k|#define S_VL 5
  |  |  ------------------
  |  |  |  Branch (612:17): [True: 1.80k, False: 10.9k]
  |  |  ------------------
  |  |  613|  1.80k|                    CHECK_b1;                                                  \
  |  |  ------------------
  |  |  |  |  440|  1.80k|    do                                                                         \
  |  |  |  |  441|  1.80k|    {                                                                          \
  |  |  |  |  442|  1.80k|        if (pa != thisrun)                                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (442:13): [True: 545, False: 1.26k]
  |  |  |  |  ------------------
  |  |  |  |  443|  1.80k|            while (b1 <= a0 && b1 < (int)lastx)                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (443:20): [True: 322, False: 545]
  |  |  |  |  |  Branch (443:32): [True: 322, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  444|    545|            {                                                                  \
  |  |  |  |  445|    322|                if (pb + 1 >= sp->refruns + sp->nruns)                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (445:21): [True: 0, False: 322]
  |  |  |  |  ------------------
  |  |  |  |  446|    322|                {                                                              \
  |  |  |  |  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|    322|                b1 += (int)(pb[0] + pb[1]);                                    \
  |  |  |  |  455|    322|                pb += 2;                                                       \
  |  |  |  |  456|    322|            }                                                                  \
  |  |  |  |  457|  1.80k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (457:14): [Folded, False: 1.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  614|  1.80k|                    if (b1 < (int)((uint32_t)a0 + TabEnt->Param))              \
  |  |  ------------------
  |  |  |  Branch (614:25): [True: 23, False: 1.78k]
  |  |  ------------------
  |  |  615|  1.80k|                    {                                                          \
  |  |  616|     23|                        unexpected("VL", a0);                                  \
  |  |  ------------------
  |  |  |  |  220|     23|    do                                                                         \
  |  |  |  |  221|     23|    {                                                                          \
  |  |  |  |  222|     23|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|     23|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|     23|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  617|     23|                        goto eol2d;                                            \
  |  |  618|     23|                    }                                                          \
  |  |  619|  1.80k|                    SETVALUE((int)((uint32_t)(b1 - a0) - TabEnt->Param));      \
  |  |  ------------------
  |  |  |  |  266|  1.78k|    do                                                                         \
  |  |  |  |  267|  1.78k|    {                                                                          \
  |  |  |  |  268|  1.78k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.78k]
  |  |  |  |  ------------------
  |  |  |  |  269|  1.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|  1.78k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  1.78k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  1.78k|        RunLength = 0;                                                         \
  |  |  |  |  279|  1.78k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 1.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  620|  1.78k|                    b1 = b1 - (int)*--pb;                                      \
  |  |  621|  1.78k|                    break;                                                     \
  |  |  622|  1.78k|                case S_Ext:                                                    \
  |  |  ------------------
  |  |  |  |   76|    290|#define S_Ext 6
  |  |  ------------------
  |  |  |  Branch (622:17): [True: 290, False: 12.4k]
  |  |  ------------------
  |  |  623|    290|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  624|    290|                    extension(a0);                                             \
  |  |  ------------------
  |  |  |  |  238|    290|    Fax3Extension(module, tif, (uint32_t)sp->line, (uint32_t)(a0))
  |  |  ------------------
  |  |  625|    290|                    goto eol2d;                                                \
  |  |  626|  3.04k|                case S_EOL:                                                    \
  |  |  ------------------
  |  |  |  |   82|  3.04k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (626:17): [True: 3.04k, False: 9.72k]
  |  |  ------------------
  |  |  627|  3.04k|                    *pa++ = (uint32_t)((int)lastx - a0);                       \
  |  |  628|  3.04k|                    NeedBits8(4, eof2d);                                       \
  |  |  ------------------
  |  |  |  |  144|  3.04k|    do                                                                         \
  |  |  |  |  145|  3.04k|    {                                                                          \
  |  |  |  |  146|  3.04k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 1.78k, False: 1.26k]
  |  |  |  |  ------------------
  |  |  |  |  147|  3.04k|        {                                                                      \
  |  |  |  |  148|  1.78k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  1.78k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 5, False: 1.77k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  1.78k|            {                                                                  \
  |  |  |  |  150|      5|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  151|      5|                    goto eoflab;                                               \
  |  |  |  |  152|      5|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      0|            }                                                                  \
  |  |  |  |  154|  1.78k|            else                                                               \
  |  |  |  |  155|  1.78k|            {                                                                  \
  |  |  |  |  156|  1.77k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  1.77k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  1.77k|            }                                                                  \
  |  |  |  |  159|  1.78k|        }                                                                      \
  |  |  |  |  160|  3.04k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 3.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  629|  3.04k|                    if (GetBits(4))                                            \
  |  |  ------------------
  |  |  |  |  194|  3.04k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 672, False: 2.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  630|  3.04k|                        unexpected("EOL", a0);                                 \
  |  |  ------------------
  |  |  |  |  220|    672|    do                                                                         \
  |  |  |  |  221|    672|    {                                                                          \
  |  |  |  |  222|    672|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    672|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    672|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 672]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  631|  3.04k|                    ClrBits(4);                                                \
  |  |  ------------------
  |  |  |  |  196|  3.04k|    do                                                                         \
  |  |  |  |  197|  3.04k|    {                                                                          \
  |  |  |  |  198|  3.04k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  3.04k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  3.04k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 3.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  632|  3.04k|                    EOLcnt = 1;                                                \
  |  |  633|  3.04k|                    goto eol2d;                                                \
  |  |  634|  3.04k|                default:                                                       \
  |  |  ------------------
  |  |  |  Branch (634:17): [True: 0, False: 12.7k]
  |  |  ------------------
  |  |  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|    172|                badBlack2d:                                                    \
  |  |  639|    172|                    unexpected("BlackTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|    172|    do                                                                         \
  |  |  |  |  221|    172|    {                                                                          \
  |  |  |  |  222|    172|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    172|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    172|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 172]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  640|    172|                    goto eol2d;                                                \
  |  |  641|    157|                badWhite2d:                                                    \
  |  |  642|    157|                    unexpected("WhiteTable", a0);                              \
  |  |  ------------------
  |  |  |  |  220|    157|    do                                                                         \
  |  |  |  |  221|    157|    {                                                                          \
  |  |  |  |  222|    157|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    157|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    157|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 157]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  643|    157|                    goto eol2d;                                                \
  |  |  644|      5|                eof2d:                                                         \
  |  |  645|      5|                    prematureEOF(a0);                                          \
  |  |  ------------------
  |  |  |  |  271|      5|    do                                                                         \
  |  |  |  |  272|      5|    {                                                                          \
  |  |  |  |  273|      5|        Fax3PrematureEOF(module, tif, (uint32_t)sp->line, (uint32_t)(a0));     \
  |  |  |  |  274|      5|        ++sp->eofReachedCount;                                                 \
  |  |  |  |  275|      5|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (275:14): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  646|      5|                    CLEANUP_RUNS();                                            \
  |  |  ------------------
  |  |  |  |  333|      5|    do                                                                         \
  |  |  |  |  334|      5|    {                                                                          \
  |  |  |  |  335|      5|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  336|      5|            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|      5|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  338|      5|        {                                                                      \
  |  |  |  |  339|      5|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|      5|    do                                                                         \
  |  |  |  |  |  |  254|      5|    {                                                                          \
  |  |  |  |  |  |  255|      5|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|      5|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|      5|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|      5|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|      5|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 0, False: 5]
  |  |  |  |  |  Branch (340:39): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|      5|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|      5|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|      5|            {                                                                  \
  |  |  |  |  344|      5|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  345|      5|                    a0 = 0;                                                    \
  |  |  |  |  346|      5|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  347|      5|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      5|    do                                                                         \
  |  |  |  |  |  |  267|      5|    {                                                                          \
  |  |  |  |  |  |  268|      5|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      5|        {                                                                      \
  |  |  |  |  |  |  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|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      5|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      5|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      5|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|      5|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      5|    do                                                                         \
  |  |  |  |  |  |  267|      5|    {                                                                          \
  |  |  |  |  |  |  268|      5|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      5|        {                                                                      \
  |  |  |  |  |  |  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|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|      5|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|      5|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|      5|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|      5|            }                                                                  \
  |  |  |  |  350|      5|            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|      5|        }                                                                      \
  |  |  |  |  356|      5|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  647|      5|                    goto eoflab;                                               \
  |  |  648|  12.7k|            }                                                                  \
  |  |  649|  12.7k|        }                                                                      \
  |  |  650|  7.70k|        if (RunLength)                                                         \
  |  |  ------------------
  |  |  |  Branch (650:13): [True: 273, False: 3.74k]
  |  |  ------------------
  |  |  651|  4.01k|        {                                                                      \
  |  |  652|    273|            if (RunLength + a0 < lastx)                                        \
  |  |  ------------------
  |  |  |  Branch (652:17): [True: 0, False: 273]
  |  |  ------------------
  |  |  653|    273|            {                                                                  \
  |  |  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|    273|            SETVALUE(0);                                                       \
  |  |  ------------------
  |  |  |  |  266|    273|    do                                                                         \
  |  |  |  |  267|    273|    {                                                                          \
  |  |  |  |  268|    273|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 273]
  |  |  |  |  ------------------
  |  |  |  |  269|    273|        {                                                                      \
  |  |  |  |  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|    273|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|    273|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|    273|        RunLength = 0;                                                         \
  |  |  |  |  279|    273|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 273]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  661|    273|        }                                                                      \
  |  |  662|  7.70k|    eol2d:                                                                     \
  |  |  663|  7.70k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  7.70k|    do                                                                         \
  |  |  |  |  334|  7.70k|    {                                                                          \
  |  |  |  |  335|  7.70k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 40, False: 7.66k]
  |  |  |  |  ------------------
  |  |  |  |  336|  7.70k|            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|  7.70k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 5.41k, False: 2.28k]
  |  |  |  |  ------------------
  |  |  |  |  338|  7.70k|        {                                                                      \
  |  |  |  |  339|  5.41k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  5.41k|    do                                                                         \
  |  |  |  |  |  |  254|  5.41k|    {                                                                          \
  |  |  |  |  |  |  255|  5.41k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  5.41k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  5.41k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  5.41k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 5.41k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  7.75k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 2.34k, False: 5.41k]
  |  |  |  |  |  Branch (340:39): [True: 2.34k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  5.41k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  5.41k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 5.40k, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  343|  5.41k|            {                                                                  \
  |  |  |  |  344|  5.40k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 5.40k]
  |  |  |  |  ------------------
  |  |  |  |  345|  5.40k|                    a0 = 0;                                                    \
  |  |  |  |  346|  5.40k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 3.68k, False: 1.71k]
  |  |  |  |  ------------------
  |  |  |  |  347|  5.40k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  3.68k|    do                                                                         \
  |  |  |  |  |  |  267|  3.68k|    {                                                                          \
  |  |  |  |  |  |  268|  3.68k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 3.68k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  3.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|  3.68k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  3.68k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  3.68k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  3.68k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 3.68k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  5.40k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  5.40k|    do                                                                         \
  |  |  |  |  |  |  267|  5.40k|    {                                                                          \
  |  |  |  |  |  |  268|  5.40k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 5.40k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  5.40k|        {                                                                      \
  |  |  |  |  |  |  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.40k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  5.40k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  5.40k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  5.40k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 5.40k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  5.40k|            }                                                                  \
  |  |  |  |  350|  5.41k|            else if (a0 > (int)lastx)                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:22): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  351|     18|            {                                                                  \
  |  |  |  |  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|  5.41k|        }                                                                      \
  |  |  |  |  356|  7.70k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 7.70k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  664|  7.70k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (664:14): [Folded, False: 7.70k]
  |  |  ------------------
  ------------------
  422|  10.4k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  423|  10.4k|        if (pa < thisrun + sp->nruns)
  ------------------
  |  Branch (423:13): [True: 10.4k, False: 0]
  ------------------
  424|  10.4k|        {
  425|  10.4k|            SETVALUE(0); /* imaginary change for reference */
  ------------------
  |  |  266|  10.4k|    do                                                                         \
  |  |  267|  10.4k|    {                                                                          \
  |  |  268|  10.4k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  ------------------
  |  |  |  Branch (268:13): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |  269|  10.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|  10.4k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  277|  10.4k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  278|  10.4k|        RunLength = 0;                                                         \
  |  |  279|  10.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (279:14): [Folded, False: 10.4k]
  |  |  ------------------
  ------------------
  426|  10.4k|        }
  427|  10.4k|        SWAP(uint32_t *, sp->curruns, sp->refruns);
  ------------------
  |  |  375|  10.4k|    {                                                                          \
  |  |  376|  10.4k|        t x;                                                                   \
  |  |  377|  10.4k|        x = (a);                                                               \
  |  |  378|  10.4k|        (a) = (b);                                                             \
  |  |  379|  10.4k|        (b) = x;                                                               \
  |  |  380|  10.4k|    }
  ------------------
  428|  10.4k|        buf += sp->b.rowbytes;
  429|  10.4k|        occ -= sp->b.rowbytes;
  430|  10.4k|        sp->line++;
  431|  10.4k|        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|      5|    EOF2Da: /* premature EOF */
  435|      5|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  436|      5|        UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      5|    do                                                                         \
  |  |  160|      5|    {                                                                          \
  |  |  161|      5|        sp->bit = BitsAvail;                                                   \
  |  |  162|      5|        sp->data = BitAcc;                                                     \
  |  |  163|      5|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      5|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      5|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      5|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 5]
  |  |  ------------------
  ------------------
  437|      5|        return (-1);
  438|      0|    }
  439|      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]
  |  |  ------------------
  ------------------
  440|      7|    return (1);
  441|     18|}
tif_fax3.c:CheckReachedCounters:
  296|    231|{
  297|    231|    if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|    231|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (297:9): [True: 0, False: 231]
  ------------------
  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|    231|    if (sp->eolReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|    231|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (305:9): [True: 0, False: 231]
  ------------------
  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|    231|    if (sp->unexpectedReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
  ------------------
  |  |   49|    231|#define EOF_REACHED_COUNT_THRESHOLD 8192
  ------------------
  |  Branch (313:9): [True: 0, False: 231]
  ------------------
  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|    231|    return (0);
  323|    231|}
tif_fax3.c:Fax3TryG3WithoutEOL:
  279|     11|{
  280|     11|    TIFFWarningExtR(
  281|     11|        tif, module,
  282|     11|        "Try to decode (read) fax Group 3 data without EOL at line %" PRIu32
  283|     11|        " of %s %" PRIu32 " (x %" PRIu32 "). Please check result",
  284|     11|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|     11|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     11|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 11]
  |  |  ------------------
  ------------------
  285|     11|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|     11|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|     11|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 11]
  |  |  ------------------
  ------------------
  286|     11|        a0);
  287|     11|}
tif_fax3.c:Fax3Unexpected:
  211|  21.6k|{
  212|  21.6k|    TIFFErrorExtR(
  213|  21.6k|        tif, module,
  214|  21.6k|        "Bad code word at line %" PRIu32 " of %s %" PRIu32 " (x %" PRIu32 ")",
  215|  21.6k|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|  21.6k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  21.6k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 21.6k]
  |  |  ------------------
  ------------------
  216|  21.6k|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|  21.6k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  21.6k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 21.6k]
  |  |  ------------------
  ------------------
  217|  21.6k|        a0);
  218|  21.6k|}
tif_fax3.c:Fax3PrematureEOF:
  262|      5|{
  263|      5|    TIFFWarningExtR(
  264|      5|        tif, module,
  265|      5|        "Premature EOF at line %" PRIu32 " of %s %" PRIu32 " (x %" PRIu32 ")",
  266|      5|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  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: 0, False: 5]
  |  |  ------------------
  ------------------
  267|      5|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  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: 0, False: 5]
  |  |  ------------------
  ------------------
  268|      5|        a0);
  269|      5|}
tif_fax3.c:Fax3BadLength:
  242|  33.4k|{
  243|  33.4k|    TIFFWarningExtR(
  244|  33.4k|        tif, module,
  245|  33.4k|        "%s at line %" PRIu32 " of %s %" PRIu32 " (got %" PRIu32
  246|  33.4k|        ", expected %" PRIu32 ")",
  247|  33.4k|        a0 < lastx ? "Premature EOL" : "Line length mismatch", line,
  ------------------
  |  Branch (247:9): [True: 27.3k, False: 6.06k]
  ------------------
  248|  33.4k|        isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|  33.4k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  33.4k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 33.4k]
  |  |  ------------------
  ------------------
  249|  33.4k|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip), a0,
  ------------------
  |  |  278|  33.4k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  33.4k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 33.4k]
  |  |  ------------------
  ------------------
  250|  33.4k|        lastx);
  251|  33.4k|}
tif_fax3.c:Fax3Extension:
  228|    290|{
  229|    290|    TIFFErrorExtR(
  230|    290|        tif, module,
  231|    290|        "Uncompressed data (not supported) at line %" PRIu32 " of %s %" PRIu32
  232|    290|        " (x %" PRIu32 ")",
  233|    290|        line, isTiled(tif) ? "tile" : "strip",
  ------------------
  |  |  278|    290|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    290|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 290]
  |  |  ------------------
  ------------------
  234|    290|        (isTiled(tif) ? tif->tif_dir.td_curtile : tif->tif_dir.td_curstrip),
  ------------------
  |  |  278|    290|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|    290|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 290]
  |  |  ------------------
  ------------------
  235|    290|        a0);
  236|    290|}
tif_fax3.c:Fax3PreDecode:
  172|    231|{
  173|    231|    Fax3CodecState *sp = DecoderState(tif);
  ------------------
  |  |  108|    231|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|    231|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  174|       |
  175|    231|    (void)s;
  176|    231|    assert(sp != NULL);
  ------------------
  |  Branch (176:5): [True: 0, False: 231]
  |  Branch (176:5): [True: 231, False: 0]
  ------------------
  177|    231|    sp->bit = 0; /* force initial read */
  178|    231|    sp->data = 0;
  179|    231|    sp->EOLcnt = 0; /* force initial scan for EOL */
  180|    231|    sp->eofReachedCount = 0;
  181|    231|    sp->eolReachedCount = 0;
  182|    231|    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|    231|    sp->bitmap =
  191|    231|        TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB);
  ------------------
  |  |  242|    231|#define FILLORDER_LSB2MSB 2                /* least significant -> most */
  ------------------
  192|    231|    sp->curruns = sp->runs;
  193|    231|    if (sp->refruns)
  ------------------
  |  Branch (193:9): [True: 12, False: 219]
  ------------------
  194|     12|    { /* init reference line to white */
  195|     12|        sp->refruns = sp->runs + sp->nruns;
  196|     12|        sp->refruns[0] = (uint32_t)sp->b.rowpixels;
  197|     12|        sp->refruns[1] = 0;
  198|     12|    }
  199|    231|    sp->line = 0;
  200|    231|    return (1);
  201|    231|}
tif_fax3.c:Fax3Decode1D:
  333|      5|{
  334|      5|    DECLARE_STATE(tif, sp, "Fax3Decode1D");
  ------------------
  |  |  123|      5|    static const char module[] = mod;                                          \
  |  |  124|      5|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  ------------------
  |  |  |  |  108|      5|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|      5|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  125|      5|    int a0;                                   /* reference element */          \
  |  |  126|      5|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  127|      5|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  128|      5|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  129|      5|    int RunLength;                            /* length of current run */      \
  |  |  130|      5|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  131|      5|    unsigned char *ep;                        /* end of input data */          \
  |  |  132|      5|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  133|      5|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  134|      5|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  135|      5|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  136|      5|    const TIFFFaxTabEnt *TabEnt
  ------------------
  335|      5|    (void)s;
  336|      5|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (336:9): [True: 0, False: 5]
  ------------------
  337|      0|    {
  338|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  339|      0|        return (-1);
  340|      0|    }
  341|      5|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (341:9): [True: 0, False: 5]
  ------------------
  342|      0|        return (-1);
  343|     10|RETRY_WITHOUT_EOL_1D:
  344|     10|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|     10|    do                                                                         \
  |  |  148|     10|    {                                                                          \
  |  |  149|     10|        BitAcc = sp->data;                                                     \
  |  |  150|     10|        BitsAvail = sp->bit;                                                   \
  |  |  151|     10|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|     10|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|     10|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|     10|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 10]
  |  |  ------------------
  ------------------
  345|     10|    thisrun = sp->curruns;
  346|  6.05k|    while (occ > 0)
  ------------------
  |  Branch (346:12): [True: 6.05k, False: 5]
  ------------------
  347|  6.05k|    {
  348|  6.05k|        a0 = 0;
  349|  6.05k|        RunLength = 0;
  350|  6.05k|        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|  6.05k|        SYNC_EOL(EOF1D, RETRY_WITHOUT_EOL_1D);
  ------------------
  |  |  293|  6.05k|    do                                                                         \
  |  |  294|  6.05k|    {                                                                          \
  |  |  295|  6.05k|        if (!(sp->b.mode & FAXMODE_NOEOL)) /* skip EOL, if not present */      \
  |  |  ------------------
  |  |  |  |  700|  6.05k|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  |  Branch (295:13): [True: 3.10k, False: 2.94k]
  |  |  ------------------
  |  |  296|  6.05k|        {                                                                      \
  |  |  297|  3.10k|            if (EOLcnt == 0)                                                   \
  |  |  ------------------
  |  |  |  Branch (297:17): [True: 945, False: 2.15k]
  |  |  ------------------
  |  |  298|  3.10k|            {                                                                  \
  |  |  299|    945|                for (;;)                                                       \
  |  |  300|   369k|                {                                                              \
  |  |  301|   369k|                    NeedBits16(11, eoflab);                                    \
  |  |  ------------------
  |  |  |  |  164|   369k|    do                                                                         \
  |  |  |  |  165|   369k|    {                                                                          \
  |  |  |  |  166|   369k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:13): [True: 46.5k, False: 323k]
  |  |  |  |  ------------------
  |  |  |  |  167|   369k|        {                                                                      \
  |  |  |  |  168|  46.5k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  46.5k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 46.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  169|  46.5k|            {                                                                  \
  |  |  |  |  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.5k|            else                                                               \
  |  |  |  |  175|  46.5k|            {                                                                  \
  |  |  |  |  176|  46.5k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  177|  46.5k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:21): [True: 12, False: 46.5k]
  |  |  |  |  ------------------
  |  |  |  |  178|  46.5k|                {                                                              \
  |  |  |  |  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|  46.5k|            }                                                                  \
  |  |  |  |  191|  46.5k|        }                                                                      \
  |  |  |  |  192|   369k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:14): [Folded, False: 369k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  302|   369k|                    if (GetBits(11) == 0)                                      \
  |  |  ------------------
  |  |  |  |  194|   369k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (302:25): [True: 945, False: 369k]
  |  |  ------------------
  |  |  303|   369k|                        break; /* EOL found */                                 \
  |  |  304|   369k|                    ClrBits(1);                                                \
  |  |  ------------------
  |  |  |  |  196|   369k|    do                                                                         \
  |  |  |  |  197|   369k|    {                                                                          \
  |  |  |  |  198|   369k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|   369k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|   369k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 369k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  305|   369k|                }                                                              \
  |  |  306|    945|            }                                                                  \
  |  |  307|  3.10k|            /* Now move after EOL or detect missing EOL. */                    \
  |  |  308|  3.10k|            for (;;)                                                           \
  |  |  309|  9.72k|            {                                                                  \
  |  |  310|  9.72k|                NeedBits8(8, noEOLFound);                                      \
  |  |  ------------------
  |  |  |  |  144|  9.72k|    do                                                                         \
  |  |  |  |  145|  9.72k|    {                                                                          \
  |  |  |  |  146|  9.72k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:13): [True: 7.94k, False: 1.78k]
  |  |  |  |  ------------------
  |  |  |  |  147|  9.72k|        {                                                                      \
  |  |  |  |  148|  7.94k|            if (EndOfData())                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|  7.94k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (117:21): [True: 9, False: 7.93k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  149|  7.94k|            {                                                                  \
  |  |  |  |  150|      9|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:21): [True: 5, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  151|      9|                    goto eoflab;                                               \
  |  |  |  |  152|      9|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  153|      4|            }                                                                  \
  |  |  |  |  154|  7.94k|            else                                                               \
  |  |  |  |  155|  7.94k|            {                                                                  \
  |  |  |  |  156|  7.93k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  157|  7.93k|                BitsAvail += 8;                                                \
  |  |  |  |  158|  7.93k|            }                                                                  \
  |  |  |  |  159|  7.94k|        }                                                                      \
  |  |  |  |  160|  9.72k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (160:14): [Folded, False: 9.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  311|  9.72k|                if (GetBits(8))                                                \
  |  |  ------------------
  |  |  |  |  194|  9.72k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (194:20): [True: 3.09k, False: 6.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  312|  9.72k|                    break;                                                     \
  |  |  313|  9.72k|                ClrBits(8);                                                    \
  |  |  ------------------
  |  |  |  |  196|  6.62k|    do                                                                         \
  |  |  |  |  197|  6.62k|    {                                                                          \
  |  |  |  |  198|  6.62k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  6.62k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  6.62k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 6.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  314|  6.62k|            }                                                                  \
  |  |  315|  13.8k|            while (GetBits(1) == 0)                                            \
  |  |  ------------------
  |  |  |  |  194|  13.8k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  ------------------
  |  |  |  Branch (315:20): [True: 10.7k, False: 3.09k]
  |  |  ------------------
  |  |  316|  10.7k|                ClrBits(1);                                                    \
  |  |  ------------------
  |  |  |  |  196|  13.8k|    do                                                                         \
  |  |  |  |  197|  13.8k|    {                                                                          \
  |  |  |  |  198|  10.7k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  10.7k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  10.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 10.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  317|  3.09k|            ClrBits(1); /* EOL bit */                                          \
  |  |  ------------------
  |  |  |  |  196|  3.09k|    do                                                                         \
  |  |  |  |  197|  3.09k|    {                                                                          \
  |  |  |  |  198|  3.09k|        BitsAvail -= (n);                                                      \
  |  |  |  |  199|  3.09k|        BitAcc >>= (n);                                                        \
  |  |  |  |  200|  3.09k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:14): [Folded, False: 3.09k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  318|  3.09k|            EOLcnt = 0; /* reset EOL counter/flag */                           \
  |  |  319|  3.09k|            break;      /* existing EOL skipped, leave macro */                \
  |  |  320|  3.10k|        noEOLFound:                                                            \
  |  |  321|      5|            sp->b.mode |= FAXMODE_NOEOL;                                       \
  |  |  ------------------
  |  |  |  |  700|      5|#define FAXMODE_NOEOL 0x0002         /* no EOL code at end of row */
  |  |  ------------------
  |  |  322|      5|            tryG3WithoutEOL(a0);                                               \
  |  |  ------------------
  |  |  |  |  289|      5|    do                                                                         \
  |  |  |  |  290|      5|    {                                                                          \
  |  |  |  |  291|      5|        Fax3TryG3WithoutEOL(module, tif, (uint32_t)sp->line, (uint32_t)(a0));  \
  |  |  |  |  292|      5|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:14): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  323|      5|            goto retrywithouteol;                                              \
  |  |  324|  3.10k|        }                                                                      \
  |  |  325|  6.05k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (325:14): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
  357|  6.04k|        EXPAND1D(EOF1Da);
  ------------------
  |  |  371|  6.04k|    do                                                                         \
  |  |  372|  6.04k|    {                                                                          \
  |  |  373|  6.04k|        for (;;)                                                               \
  |  |  374|  8.85k|        {                                                                      \
  |  |  375|  8.85k|            for (;;)                                                           \
  |  |  376|  55.9k|            {                                                                  \
  |  |  377|  55.9k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  55.9k|    do                                                                         \
  |  |  |  |  255|  55.9k|    {                                                                          \
  |  |  |  |  256|  55.9k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  55.9k|    do                                                                         \
  |  |  |  |  |  |  165|  55.9k|    {                                                                          \
  |  |  |  |  |  |  166|  55.9k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 50.9k, False: 5.03k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  55.9k|        {                                                                      \
  |  |  |  |  |  |  168|  50.9k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  50.9k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 50.9k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  50.9k|            {                                                                  \
  |  |  |  |  |  |  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|  50.9k|            else                                                               \
  |  |  |  |  |  |  175|  50.9k|            {                                                                  \
  |  |  |  |  |  |  176|  50.9k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  50.9k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 464, False: 50.4k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  50.9k|                {                                                              \
  |  |  |  |  |  |  179|    464|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    464|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 464]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|    464|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|    464|                    else                                                       \
  |  |  |  |  |  |  185|    464|                    {                                                          \
  |  |  |  |  |  |  186|    464|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|    464|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|    464|                    }                                                          \
  |  |  |  |  |  |  189|    464|                }                                                              \
  |  |  |  |  |  |  190|  50.9k|            }                                                                  \
  |  |  |  |  |  |  191|  50.9k|        }                                                                      \
  |  |  |  |  |  |  192|  55.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 55.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  55.9k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  55.9k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  55.9k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  55.9k|    do                                                                         \
  |  |  |  |  |  |  197|  55.9k|    {                                                                          \
  |  |  |  |  |  |  198|  55.9k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  55.9k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  55.9k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 55.9k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  55.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 55.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|  55.9k|                switch (TabEnt->State)                                         \
  |  |  379|  55.9k|                {                                                              \
  |  |  380|  1.42k|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|  1.42k|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 1.42k, False: 54.5k]
  |  |  ------------------
  |  |  381|  1.42k|                        EOLcnt = 1;                                            \
  |  |  382|  1.42k|                        goto done1d;                                           \
  |  |  383|  4.29k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  4.29k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 4.29k, False: 51.6k]
  |  |  ------------------
  |  |  384|  4.29k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  4.29k|    do                                                                         \
  |  |  |  |  267|  4.29k|    {                                                                          \
  |  |  |  |  268|  4.29k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 4.29k]
  |  |  |  |  ------------------
  |  |  |  |  269|  4.29k|        {                                                                      \
  |  |  |  |  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.29k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  4.29k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  4.29k|        RunLength = 0;                                                         \
  |  |  |  |  279|  4.29k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 4.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  4.29k|                        goto doneWhite1d;                                      \
  |  |  386|  46.9k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|  46.9k|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 46.9k, False: 9.03k]
  |  |  ------------------
  |  |  387|  47.1k|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|  47.1k|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 180, False: 55.8k]
  |  |  ------------------
  |  |  388|  47.1k|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|  47.1k|                        RunLength =                                            \
  |  |  390|  47.1k|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|  47.1k|                        break;                                                 \
  |  |  392|  46.9k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 3.12k, False: 52.8k]
  |  |  ------------------
  |  |  393|  3.12k|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|  3.12k|    do                                                                         \
  |  |  |  |  221|  3.12k|    {                                                                          \
  |  |  |  |  222|  3.12k|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|  3.12k|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|  3.12k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 3.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|  3.12k|                        goto done1d;                                           \
  |  |  395|  55.9k|                }                                                              \
  |  |  396|  55.9k|            }                                                                  \
  |  |  397|  8.85k|        doneWhite1d:                                                           \
  |  |  398|  4.29k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 398, False: 3.89k]
  |  |  ------------------
  |  |  399|  4.29k|                goto done1d;                                                   \
  |  |  400|  4.29k|            for (;;)                                                           \
  |  |  401|  4.07k|            {                                                                  \
  |  |  402|  4.07k|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  4.07k|    do                                                                         \
  |  |  |  |  255|  4.07k|    {                                                                          \
  |  |  |  |  256|  4.07k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  4.07k|    do                                                                         \
  |  |  |  |  |  |  165|  4.07k|    {                                                                          \
  |  |  |  |  |  |  166|  4.07k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 3.00k, False: 1.06k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  4.07k|        {                                                                      \
  |  |  |  |  |  |  168|  3.00k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  3.00k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 4, False: 3.00k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  3.00k|            {                                                                  \
  |  |  |  |  |  |  170|      4|                if (BitsAvail == 0) /* no valid bits */                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:21): [True: 0, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      4|                    goto eoflab;                                               \
  |  |  |  |  |  |  172|      4|                BitsAvail = (n); /* pad with zeros */                          \
  |  |  |  |  |  |  173|      4|            }                                                                  \
  |  |  |  |  |  |  174|  3.00k|            else                                                               \
  |  |  |  |  |  |  175|  3.00k|            {                                                                  \
  |  |  |  |  |  |  176|  3.00k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  3.00k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 264, False: 2.73k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  3.00k|                {                                                              \
  |  |  |  |  |  |  179|    264|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|    264|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 264]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|    264|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|    264|                    else                                                       \
  |  |  |  |  |  |  185|    264|                    {                                                          \
  |  |  |  |  |  |  186|    264|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|    264|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|    264|                    }                                                          \
  |  |  |  |  |  |  189|    264|                }                                                              \
  |  |  |  |  |  |  190|  3.00k|            }                                                                  \
  |  |  |  |  |  |  191|  3.00k|        }                                                                      \
  |  |  |  |  |  |  192|  4.07k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 4.07k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  4.07k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  4.07k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  4.07k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  4.07k|    do                                                                         \
  |  |  |  |  |  |  197|  4.07k|    {                                                                          \
  |  |  |  |  |  |  198|  4.07k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  4.07k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  4.07k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 4.07k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  4.07k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 4.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|  4.07k|                switch (TabEnt->State)                                         \
  |  |  404|  4.07k|                {                                                              \
  |  |  405|    740|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    740|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 740, False: 3.33k]
  |  |  ------------------
  |  |  406|    740|                        EOLcnt = 1;                                            \
  |  |  407|    740|                        goto done1d;                                           \
  |  |  408|  2.96k|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|  2.96k|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 2.96k, False: 1.10k]
  |  |  ------------------
  |  |  409|  2.96k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  2.96k|    do                                                                         \
  |  |  |  |  267|  2.96k|    {                                                                          \
  |  |  |  |  268|  2.96k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 2.96k]
  |  |  |  |  ------------------
  |  |  |  |  269|  2.96k|        {                                                                      \
  |  |  |  |  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.96k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  2.96k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  2.96k|        RunLength = 0;                                                         \
  |  |  |  |  279|  2.96k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 2.96k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|  2.96k|                        goto doneBlack1d;                                      \
  |  |  411|  2.96k|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|     14|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 14, False: 4.05k]
  |  |  ------------------
  |  |  412|    173|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|    173|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 159, False: 3.91k]
  |  |  ------------------
  |  |  413|    173|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|    173|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|    173|                        break;                                                 \
  |  |  416|    190|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 190, False: 3.88k]
  |  |  ------------------
  |  |  417|    190|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|    190|    do                                                                         \
  |  |  |  |  221|    190|    {                                                                          \
  |  |  |  |  222|    190|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|    190|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|    190|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|    190|                        goto done1d;                                           \
  |  |  419|  4.07k|                }                                                              \
  |  |  420|  4.07k|            }                                                                  \
  |  |  421|  3.89k|        doneBlack1d:                                                           \
  |  |  422|  2.96k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 162, False: 2.80k]
  |  |  ------------------
  |  |  423|  2.96k|                goto done1d;                                                   \
  |  |  424|  2.96k|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 2.80k]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|  2.80k|                pa -= 2;                                                       \
  |  |  426|  2.80k|        }                                                                      \
  |  |  427|  6.04k|    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|  6.04k|    done1d:                                                                    \
  |  |  432|  6.04k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  6.04k|    do                                                                         \
  |  |  |  |  334|  6.04k|    {                                                                          \
  |  |  |  |  335|  6.04k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 85, False: 5.96k]
  |  |  |  |  ------------------
  |  |  |  |  336|  6.04k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     85|    do                                                                         \
  |  |  |  |  |  |  267|     85|    {                                                                          \
  |  |  |  |  |  |  268|     85|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 85]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     85|        {                                                                      \
  |  |  |  |  |  |  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|     85|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     85|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     85|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     85|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 85]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  6.04k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 6.01k, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  338|  6.04k|        {                                                                      \
  |  |  |  |  339|  6.01k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  6.01k|    do                                                                         \
  |  |  |  |  |  |  254|  6.01k|    {                                                                          \
  |  |  |  |  |  |  255|  6.01k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  6.01k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  6.01k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  6.01k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 6.01k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  6.57k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 560, False: 6.01k]
  |  |  |  |  |  Branch (340:39): [True: 560, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  6.01k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  6.01k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 6.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  6.01k|            {                                                                  \
  |  |  |  |  344|  6.01k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 6.01k]
  |  |  |  |  ------------------
  |  |  |  |  345|  6.01k|                    a0 = 0;                                                    \
  |  |  |  |  346|  6.01k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 1.11k, False: 4.90k]
  |  |  |  |  ------------------
  |  |  |  |  347|  6.01k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  1.11k|    do                                                                         \
  |  |  |  |  |  |  267|  1.11k|    {                                                                          \
  |  |  |  |  |  |  268|  1.11k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.11k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  1.11k|        {                                                                      \
  |  |  |  |  |  |  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.11k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  1.11k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  1.11k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  1.11k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 1.11k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  6.01k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  6.01k|    do                                                                         \
  |  |  |  |  |  |  267|  6.01k|    {                                                                          \
  |  |  |  |  |  |  268|  6.01k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 6.01k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  6.01k|        {                                                                      \
  |  |  |  |  |  |  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|  6.01k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  6.01k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  6.01k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  6.01k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 6.01k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  6.01k|            }                                                                  \
  |  |  |  |  350|  6.01k|            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|  6.01k|        }                                                                      \
  |  |  |  |  356|  6.04k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 6.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  6.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 6.04k]
  |  |  ------------------
  ------------------
  358|  6.04k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
  359|  6.04k|        buf += sp->b.rowbytes;
  360|  6.04k|        occ -= sp->b.rowbytes;
  361|  6.04k|        sp->line++;
  362|  6.04k|        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|      5|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|      5|    do                                                                         \
  |  |  160|      5|    {                                                                          \
  |  |  161|      5|        sp->bit = BitsAvail;                                                   \
  |  |  162|      5|        sp->data = BitAcc;                                                     \
  |  |  163|      5|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|      5|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|      5|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|      5|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 5]
  |  |  ------------------
  ------------------
  371|      5|    return (1);
  372|     10|}
tif_fax3.c:Fax3Cleanup:
 1329|     21|{
 1330|     21|    Fax3CodecState *sp = DecoderState(tif);
  ------------------
  |  |  108|     21|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  ------------------
  |  |  |  |   72|     21|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1331|       |
 1332|     21|    assert(sp != 0);
  ------------------
  |  Branch (1332:5): [True: 0, False: 21]
  |  Branch (1332:5): [True: 21, False: 0]
  ------------------
 1333|       |
 1334|     21|    tif->tif_tagmethods.vgetfield = sp->b.vgetparent;
 1335|     21|    tif->tif_tagmethods.vsetfield = sp->b.vsetparent;
 1336|     21|    tif->tif_tagmethods.printdir = sp->b.printdir;
 1337|       |
 1338|     21|    if (sp->runs)
  ------------------
  |  Branch (1338:9): [True: 12, False: 9]
  ------------------
 1339|     12|        _TIFFfreeExt(tif, sp->runs);
 1340|     21|    if (sp->refline)
  ------------------
  |  Branch (1340:9): [True: 6, False: 15]
  ------------------
 1341|      6|        _TIFFfreeExt(tif, sp->refline);
 1342|       |
 1343|     21|    _TIFFfreeExt(tif, tif->tif_data);
 1344|     21|    tif->tif_data = NULL;
 1345|       |
 1346|     21|    _TIFFSetDefaultCompressionState(tif);
 1347|     21|}
tif_fax3.c:Fax3DecodeRLE:
 1802|    214|{
 1803|    214|    DECLARE_STATE(tif, sp, "Fax3DecodeRLE");
  ------------------
  |  |  123|    214|    static const char module[] = mod;                                          \
  |  |  124|    214|    Fax3CodecState *sp = DecoderState(tif);                                    \
  |  |  ------------------
  |  |  |  |  108|    214|#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|    214|#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  125|    214|    int a0;                                   /* reference element */          \
  |  |  126|    214|    int lastx = (int)sp->b.rowpixels;         /* last element in row */        \
  |  |  127|    214|    uint32_t BitAcc;                          /* bit accumulator */            \
  |  |  128|    214|    int BitsAvail;                            /* # valid bits in BitAcc */     \
  |  |  129|    214|    int RunLength;                            /* length of current run */      \
  |  |  130|    214|    unsigned char *cp;                        /* next byte of input data */    \
  |  |  131|    214|    unsigned char *ep;                        /* end of input data */          \
  |  |  132|    214|    uint32_t *pa;                             /* place to stuff next run */    \
  |  |  133|    214|    uint32_t *thisrun;                        /* current row's run array */    \
  |  |  134|    214|    int EOLcnt;                               /* # EOL codes recognized */     \
  |  |  135|    214|    const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */    \
  |  |  136|    214|    const TIFFFaxTabEnt *TabEnt
  ------------------
 1804|    214|    int mode = sp->b.mode;
 1805|    214|    (void)s;
 1806|    214|    if (occ % sp->b.rowbytes)
  ------------------
  |  Branch (1806:9): [True: 0, False: 214]
  ------------------
 1807|      0|    {
 1808|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
 1809|      0|        return (-1);
 1810|      0|    }
 1811|    214|    if (CheckReachedCounters(tif, module, sp))
  ------------------
  |  Branch (1811:9): [True: 0, False: 214]
  ------------------
 1812|      0|        return (-1);
 1813|    214|    CACHE_STATE(tif, sp);
  ------------------
  |  |  147|    214|    do                                                                         \
  |  |  148|    214|    {                                                                          \
  |  |  149|    214|        BitAcc = sp->data;                                                     \
  |  |  150|    214|        BitsAvail = sp->bit;                                                   \
  |  |  151|    214|        EOLcnt = sp->EOLcnt;                                                   \
  |  |  152|    214|        cp = (unsigned char *)tif->tif_rawcp;                                  \
  |  |  153|    214|        ep = cp + tif->tif_rawcc;                                              \
  |  |  154|    214|    } while (0)
  |  |  ------------------
  |  |  |  Branch (154:14): [Folded, False: 214]
  |  |  ------------------
  ------------------
 1814|    214|    thisrun = sp->curruns;
 1815|  19.6k|    while (occ > 0)
  ------------------
  |  Branch (1815:12): [True: 19.4k, False: 214]
  ------------------
 1816|  19.4k|    {
 1817|  19.4k|        a0 = 0;
 1818|  19.4k|        RunLength = 0;
 1819|  19.4k|        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|  19.4k|        EXPAND1D(EOFRLE);
  ------------------
  |  |  371|  19.4k|    do                                                                         \
  |  |  372|  19.4k|    {                                                                          \
  |  |  373|  19.4k|        for (;;)                                                               \
  |  |  374|  20.7k|        {                                                                      \
  |  |  375|  20.7k|            for (;;)                                                           \
  |  |  376|  21.2k|            {                                                                  \
  |  |  377|  21.2k|                LOOKUP16(12, TIFFFaxWhiteTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  21.2k|    do                                                                         \
  |  |  |  |  255|  21.2k|    {                                                                          \
  |  |  |  |  256|  21.2k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  21.2k|    do                                                                         \
  |  |  |  |  |  |  165|  21.2k|    {                                                                          \
  |  |  |  |  |  |  166|  21.2k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 3.11k, False: 18.1k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  21.2k|        {                                                                      \
  |  |  |  |  |  |  168|  3.11k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  3.11k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 3.11k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  3.11k|            {                                                                  \
  |  |  |  |  |  |  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|  3.11k|            else                                                               \
  |  |  |  |  |  |  175|  3.11k|            {                                                                  \
  |  |  |  |  |  |  176|  3.11k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  3.11k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 1.32k, False: 1.79k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  3.11k|                {                                                              \
  |  |  |  |  |  |  179|  1.32k|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  1.32k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 1.32k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|  1.32k|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|  1.32k|                    else                                                       \
  |  |  |  |  |  |  185|  1.32k|                    {                                                          \
  |  |  |  |  |  |  186|  1.32k|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|  1.32k|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|  1.32k|                    }                                                          \
  |  |  |  |  |  |  189|  1.32k|                }                                                              \
  |  |  |  |  |  |  190|  3.11k|            }                                                                  \
  |  |  |  |  |  |  191|  3.11k|        }                                                                      \
  |  |  |  |  |  |  192|  21.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 21.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  21.2k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  21.2k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  21.2k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  21.2k|    do                                                                         \
  |  |  |  |  |  |  197|  21.2k|    {                                                                          \
  |  |  |  |  |  |  198|  21.2k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  21.2k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  21.2k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 21.2k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  21.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 21.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  378|  21.2k|                switch (TabEnt->State)                                         \
  |  |  379|  21.2k|                {                                                              \
  |  |  380|    496|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    496|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 496, False: 20.7k]
  |  |  ------------------
  |  |  381|    496|                        EOLcnt = 1;                                            \
  |  |  382|    496|                        goto done1d;                                           \
  |  |  383|  3.06k|                    case S_TermW:                                              \
  |  |  ------------------
  |  |  |  |   77|  3.06k|#define S_TermW 7
  |  |  ------------------
  |  |  |  Branch (383:21): [True: 3.06k, False: 18.1k]
  |  |  ------------------
  |  |  384|  3.06k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  3.06k|    do                                                                         \
  |  |  |  |  267|  3.06k|    {                                                                          \
  |  |  |  |  268|  3.06k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 3.06k]
  |  |  |  |  ------------------
  |  |  |  |  269|  3.06k|        {                                                                      \
  |  |  |  |  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.06k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  3.06k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  3.06k|        RunLength = 0;                                                         \
  |  |  |  |  279|  3.06k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 3.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  385|  3.06k|                        goto doneWhite1d;                                      \
  |  |  386|  3.06k|                    case S_MakeUpW:                                            \
  |  |  ------------------
  |  |  |  |   79|    272|#define S_MakeUpW 9
  |  |  ------------------
  |  |  |  Branch (386:21): [True: 272, False: 20.9k]
  |  |  ------------------
  |  |  387|    434|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|    434|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 162, False: 21.0k]
  |  |  ------------------
  |  |  388|    434|                        a0 = (int)((uint32_t)a0 + TabEnt->Param);              \
  |  |  389|    434|                        RunLength =                                            \
  |  |  390|    434|                            (int)((uint32_t)RunLength + TabEnt->Param);        \
  |  |  391|    434|                        break;                                                 \
  |  |  392|  17.2k|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (392:21): [True: 17.2k, False: 3.99k]
  |  |  ------------------
  |  |  393|  17.2k|                        unexpected("WhiteTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|  17.2k|    do                                                                         \
  |  |  |  |  221|  17.2k|    {                                                                          \
  |  |  |  |  222|  17.2k|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|  17.2k|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|  17.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 17.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  394|  17.2k|                        goto done1d;                                           \
  |  |  395|  21.2k|                }                                                              \
  |  |  396|  21.2k|            }                                                                  \
  |  |  397|  20.7k|        doneWhite1d:                                                           \
  |  |  398|  3.06k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (398:17): [True: 1.11k, False: 1.94k]
  |  |  ------------------
  |  |  399|  3.06k|                goto done1d;                                                   \
  |  |  400|  3.06k|            for (;;)                                                           \
  |  |  401|  1.95k|            {                                                                  \
  |  |  402|  1.95k|                LOOKUP16(13, TIFFFaxBlackTable, eof1d);                        \
  |  |  ------------------
  |  |  |  |  254|  1.95k|    do                                                                         \
  |  |  |  |  255|  1.95k|    {                                                                          \
  |  |  |  |  256|  1.95k|        NeedBits16(wid, eoflab);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|  1.95k|    do                                                                         \
  |  |  |  |  |  |  165|  1.95k|    {                                                                          \
  |  |  |  |  |  |  166|  1.95k|        if (BitsAvail < (n))                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (166:13): [True: 1.55k, False: 406]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  1.95k|        {                                                                      \
  |  |  |  |  |  |  168|  1.55k|            if (EndOfData())                                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|  1.55k|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 1.55k]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.55k|            {                                                                  \
  |  |  |  |  |  |  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|  1.55k|            else                                                               \
  |  |  |  |  |  |  175|  1.55k|            {                                                                  \
  |  |  |  |  |  |  176|  1.55k|                BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;              \
  |  |  |  |  |  |  177|  1.55k|                if ((BitsAvail += 8) < (n))                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:21): [True: 4, False: 1.54k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|  1.55k|                {                                                              \
  |  |  |  |  |  |  179|      4|                    if (EndOfData())                                           \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  117|      4|#define EndOfData() (cp >= ep)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (117:21): [True: 0, False: 4]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      4|                    {                                                          \
  |  |  |  |  |  |  181|      0|                        /* NB: we know BitsAvail is non-zero here */           \
  |  |  |  |  |  |  182|      0|                        BitsAvail = (n); /* pad with zeros */                  \
  |  |  |  |  |  |  183|      0|                    }                                                          \
  |  |  |  |  |  |  184|      4|                    else                                                       \
  |  |  |  |  |  |  185|      4|                    {                                                          \
  |  |  |  |  |  |  186|      4|                        BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail;      \
  |  |  |  |  |  |  187|      4|                        BitsAvail += 8;                                        \
  |  |  |  |  |  |  188|      4|                    }                                                          \
  |  |  |  |  |  |  189|      4|                }                                                              \
  |  |  |  |  |  |  190|  1.55k|            }                                                                  \
  |  |  |  |  |  |  191|  1.55k|        }                                                                      \
  |  |  |  |  |  |  192|  1.95k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (192:14): [Folded, False: 1.95k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  257|  1.95k|        TabEnt = tab + GetBits(wid);                                           \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|  1.95k|#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
  |  |  |  |  ------------------
  |  |  |  |  258|  1.95k|        ClrBits(TabEnt->Width);                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|  1.95k|    do                                                                         \
  |  |  |  |  |  |  197|  1.95k|    {                                                                          \
  |  |  |  |  |  |  198|  1.95k|        BitsAvail -= (n);                                                      \
  |  |  |  |  |  |  199|  1.95k|        BitAcc >>= (n);                                                        \
  |  |  |  |  |  |  200|  1.95k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (200:14): [Folded, False: 1.95k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  259|  1.95k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (259:14): [Folded, False: 1.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  403|  1.95k|                switch (TabEnt->State)                                         \
  |  |  404|  1.95k|                {                                                              \
  |  |  405|    118|                    case S_EOL:                                                \
  |  |  ------------------
  |  |  |  |   82|    118|#define S_EOL 12
  |  |  ------------------
  |  |  |  Branch (405:21): [True: 118, False: 1.84k]
  |  |  ------------------
  |  |  406|    118|                        EOLcnt = 1;                                            \
  |  |  407|    118|                        goto done1d;                                           \
  |  |  408|  1.82k|                    case S_TermB:                                              \
  |  |  ------------------
  |  |  |  |   78|  1.82k|#define S_TermB 8
  |  |  ------------------
  |  |  |  Branch (408:21): [True: 1.82k, False: 136]
  |  |  ------------------
  |  |  409|  1.82k|                        SETVALUE(TabEnt->Param);                               \
  |  |  ------------------
  |  |  |  |  266|  1.82k|    do                                                                         \
  |  |  |  |  267|  1.82k|    {                                                                          \
  |  |  |  |  268|  1.82k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (268:13): [True: 0, False: 1.82k]
  |  |  |  |  ------------------
  |  |  |  |  269|  1.82k|        {                                                                      \
  |  |  |  |  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.82k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  277|  1.82k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  278|  1.82k|        RunLength = 0;                                                         \
  |  |  |  |  279|  1.82k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:14): [Folded, False: 1.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|  1.82k|                        goto doneBlack1d;                                      \
  |  |  411|  1.82k|                    case S_MakeUpB:                                            \
  |  |  ------------------
  |  |  |  |   80|      6|#define S_MakeUpB 10
  |  |  ------------------
  |  |  |  Branch (411:21): [True: 6, False: 1.95k]
  |  |  ------------------
  |  |  412|     10|                    case S_MakeUp:                                             \
  |  |  ------------------
  |  |  |  |   81|     10|#define S_MakeUp 11
  |  |  ------------------
  |  |  |  Branch (412:21): [True: 4, False: 1.95k]
  |  |  ------------------
  |  |  413|     10|                        a0 += (int)TabEnt->Param;                              \
  |  |  414|     10|                        RunLength += (int)TabEnt->Param;                       \
  |  |  415|     10|                        break;                                                 \
  |  |  416|      8|                    default:                                                   \
  |  |  ------------------
  |  |  |  Branch (416:21): [True: 8, False: 1.95k]
  |  |  ------------------
  |  |  417|      8|                        unexpected("BlackTable", a0);                          \
  |  |  ------------------
  |  |  |  |  220|      8|    do                                                                         \
  |  |  |  |  221|      8|    {                                                                          \
  |  |  |  |  222|      8|        Fax3Unexpected(module, tif, (uint32_t)sp->line, (uint32_t)(a0));       \
  |  |  |  |  223|      8|        ++sp->unexpectedReachedCount;                                          \
  |  |  |  |  224|      8|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (224:14): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  418|      8|                        goto done1d;                                           \
  |  |  419|  1.95k|                }                                                              \
  |  |  420|  1.95k|            }                                                                  \
  |  |  421|  1.94k|        doneBlack1d:                                                           \
  |  |  422|  1.82k|            if (a0 >= (int)lastx)                                              \
  |  |  ------------------
  |  |  |  Branch (422:17): [True: 504, False: 1.31k]
  |  |  ------------------
  |  |  423|  1.82k|                goto done1d;                                                   \
  |  |  424|  1.82k|            if (*(pa - 1) == 0 && *(pa - 2) == 0)                              \
  |  |  ------------------
  |  |  |  Branch (424:17): [True: 0, False: 1.31k]
  |  |  |  Branch (424:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  425|  1.31k|                pa -= 2;                                                       \
  |  |  426|  1.31k|        }                                                                      \
  |  |  427|  19.4k|    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|  19.4k|    done1d:                                                                    \
  |  |  432|  19.4k|        CLEANUP_RUNS();                                                        \
  |  |  ------------------
  |  |  |  |  333|  19.4k|    do                                                                         \
  |  |  |  |  334|  19.4k|    {                                                                          \
  |  |  |  |  335|  19.4k|        if (RunLength)                                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (335:13): [True: 66, False: 19.4k]
  |  |  |  |  ------------------
  |  |  |  |  336|  19.4k|            SETVALUE(0);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|     66|    do                                                                         \
  |  |  |  |  |  |  267|     66|    {                                                                          \
  |  |  |  |  |  |  268|     66|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 66]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|     66|        {                                                                      \
  |  |  |  |  |  |  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|     66|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|     66|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|     66|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|     66|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 66]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  337|  19.4k|        if (a0 != (int)lastx)                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (337:13): [True: 19.3k, False: 104]
  |  |  |  |  ------------------
  |  |  |  |  338|  19.4k|        {                                                                      \
  |  |  |  |  339|  19.3k|            badlength(a0, lastx);                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  253|  19.3k|    do                                                                         \
  |  |  |  |  |  |  254|  19.3k|    {                                                                          \
  |  |  |  |  |  |  255|  19.3k|        Fax3BadLength(module, tif, (uint32_t)sp->line, (uint32_t)(a0),         \
  |  |  |  |  |  |  256|  19.3k|                      (uint32_t)(lastx));                                      \
  |  |  |  |  |  |  257|  19.3k|        ++sp->eolReachedCount;                                                 \
  |  |  |  |  |  |  258|  19.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (258:14): [Folded, False: 19.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  340|  20.9k|            while (a0 > (int)lastx && pa > thisrun)                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (340:20): [True: 1.57k, False: 19.3k]
  |  |  |  |  |  Branch (340:39): [True: 1.57k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  341|  19.3k|                a0 -= (int)*--pa;                                              \
  |  |  |  |  342|  19.3k|            if (a0 < (int)lastx)                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (342:17): [True: 19.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  343|  19.3k|            {                                                                  \
  |  |  |  |  344|  19.3k|                if (a0 < 0)                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (344:21): [True: 0, False: 19.3k]
  |  |  |  |  ------------------
  |  |  |  |  345|  19.3k|                    a0 = 0;                                                    \
  |  |  |  |  346|  19.3k|                if ((pa - thisrun) & 1)                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (346:21): [True: 578, False: 18.7k]
  |  |  |  |  ------------------
  |  |  |  |  347|  19.3k|                    SETVALUE(0);                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|    578|    do                                                                         \
  |  |  |  |  |  |  267|    578|    {                                                                          \
  |  |  |  |  |  |  268|    578|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 578]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|    578|        {                                                                      \
  |  |  |  |  |  |  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|    578|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|    578|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|    578|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|    578|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 578]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  348|  19.3k|                SETVALUE((uint32_t)((int)lastx - a0));                         \
  |  |  |  |  ------------------
  |  |  |  |  |  |  266|  19.3k|    do                                                                         \
  |  |  |  |  |  |  267|  19.3k|    {                                                                          \
  |  |  |  |  |  |  268|  19.3k|        if (pa >= thisrun + sp->nruns)                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (268:13): [True: 0, False: 19.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|  19.3k|        {                                                                      \
  |  |  |  |  |  |  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|  19.3k|        *pa++ = (uint32_t)((uint32_t)RunLength + (uint32_t)(x));               \
  |  |  |  |  |  |  277|  19.3k|        a0 += (int)(uint32_t)(x);                                              \
  |  |  |  |  |  |  278|  19.3k|        RunLength = 0;                                                         \
  |  |  |  |  |  |  279|  19.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (279:14): [Folded, False: 19.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  349|  19.3k|            }                                                                  \
  |  |  |  |  350|  19.3k|            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|  19.3k|        }                                                                      \
  |  |  |  |  356|  19.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (356:14): [Folded, False: 19.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  433|  19.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (433:14): [Folded, False: 19.4k]
  |  |  ------------------
  ------------------
 1826|  19.4k|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1827|       |        /*
 1828|       |         * Cleanup at the end of the row.
 1829|       |         */
 1830|  19.4k|        if (mode & FAXMODE_BYTEALIGN)
  ------------------
  |  |  701|  19.4k|#define FAXMODE_BYTEALIGN 0x0004     /* byte align row */
  ------------------
  |  Branch (1830:13): [True: 19.4k, False: 0]
  ------------------
 1831|  19.4k|        {
 1832|  19.4k|            int n = BitsAvail - (BitsAvail & ~7);
 1833|  19.4k|            ClrBits(n);
  ------------------
  |  |  196|  19.4k|    do                                                                         \
  |  |  197|  19.4k|    {                                                                          \
  |  |  198|  19.4k|        BitsAvail -= (n);                                                      \
  |  |  199|  19.4k|        BitAcc >>= (n);                                                        \
  |  |  200|  19.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 19.4k]
  |  |  ------------------
  ------------------
 1834|  19.4k|        }
 1835|      0|        else if (mode & FAXMODE_WORDALIGN)
  ------------------
  |  |  702|      0|#define FAXMODE_WORDALIGN 0x0008     /* word align row */
  ------------------
  |  Branch (1835:18): [True: 0, False: 0]
  ------------------
 1836|      0|        {
 1837|      0|            int n = BitsAvail - (BitsAvail & ~15);
 1838|      0|            ClrBits(n);
  ------------------
  |  |  196|      0|    do                                                                         \
  |  |  197|      0|    {                                                                          \
  |  |  198|      0|        BitsAvail -= (n);                                                      \
  |  |  199|      0|        BitAcc >>= (n);                                                        \
  |  |  200|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (200:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1839|      0|            if (BitsAvail == 0 && !isAligned(cp, uint16_t))
  ------------------
  |  |  112|      0|#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
  ------------------
  |  Branch (1839:17): [True: 0, False: 0]
  |  Branch (1839:35): [True: 0, False: 0]
  ------------------
 1840|      0|                cp++;
 1841|      0|        }
 1842|  19.4k|        buf += sp->b.rowbytes;
 1843|  19.4k|        occ -= sp->b.rowbytes;
 1844|  19.4k|        sp->line++;
 1845|  19.4k|        continue;
 1846|      0|    EOFRLE: /* premature EOF */
 1847|      0|        (*sp->fill)(buf, thisrun, pa, (uint32_t)lastx);
 1848|      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]
  |  |  ------------------
  ------------------
 1849|      0|        return (-1);
 1850|  19.4k|    }
 1851|    214|    UNCACHE_STATE(tif, sp);
  ------------------
  |  |  159|    214|    do                                                                         \
  |  |  160|    214|    {                                                                          \
  |  |  161|    214|        sp->bit = BitsAvail;                                                   \
  |  |  162|    214|        sp->data = BitAcc;                                                     \
  |  |  163|    214|        sp->EOLcnt = EOLcnt;                                                   \
  |  |  164|    214|        tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp);          \
  |  |  165|    214|        tif->tif_rawcp = (uint8_t *)cp;                                        \
  |  |  166|    214|    } while (0)
  |  |  ------------------
  |  |  |  Branch (166:14): [Folded, False: 214]
  |  |  ------------------
  ------------------
 1852|    214|    return (1);
 1853|    214|}

TIFFRGBAImageOK:
   85|    593|{
   86|    593|    TIFFDirectory *td = &tif->tif_dir;
   87|    593|    uint16_t photometric;
   88|    593|    int colorchannels;
   89|       |
   90|    593|    if (!tif->tif_decodestatus)
  ------------------
  |  Branch (90:9): [True: 0, False: 593]
  ------------------
   91|      0|    {
   92|      0|        snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
   93|      0|                 "Sorry, requested compression method is not configured");
   94|      0|        return (0);
   95|      0|    }
   96|    593|    switch (td->td_bitspersample)
   97|    593|    {
   98|     24|        case 1:
  ------------------
  |  Branch (98:9): [True: 24, False: 569]
  ------------------
   99|     33|        case 2:
  ------------------
  |  Branch (99:9): [True: 9, False: 584]
  ------------------
  100|     34|        case 4:
  ------------------
  |  Branch (100:9): [True: 1, False: 592]
  ------------------
  101|    219|        case 8:
  ------------------
  |  Branch (101:9): [True: 185, False: 408]
  ------------------
  102|    561|        case 16:
  ------------------
  |  Branch (102:9): [True: 342, False: 251]
  ------------------
  103|    561|            break;
  104|     32|        default:
  ------------------
  |  Branch (104:9): [True: 32, False: 561]
  ------------------
  105|     32|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|     32|#define EMSG_BUF_SIZE 1024
  ------------------
  106|     32|                     "Sorry, can not handle images with %" PRIu16
  107|     32|                     "-bit samples",
  108|     32|                     td->td_bitspersample);
  109|     32|            return (0);
  110|    593|    }
  111|    561|    if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
  ------------------
  |  |  336|    561|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (111:9): [True: 0, False: 561]
  ------------------
  112|      0|    {
  113|      0|        snprintf(
  114|      0|            emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  115|      0|            "Sorry, can not handle images with IEEE floating-point samples");
  116|      0|        return (0);
  117|      0|    }
  118|    561|    colorchannels = td->td_samplesperpixel - td->td_extrasamples;
  119|    561|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric))
  ------------------
  |  |  220|    561|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (119:9): [True: 99, False: 462]
  ------------------
  120|     99|    {
  121|     99|        switch (colorchannels)
  122|     99|        {
  123|     99|            case 1:
  ------------------
  |  Branch (123:13): [True: 99, False: 0]
  ------------------
  124|     99|                photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|     99|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  125|     99|                break;
  126|      0|            case 3:
  ------------------
  |  Branch (126:13): [True: 0, False: 99]
  ------------------
  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: 99]
  ------------------
  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|     99|        }
  134|     99|    }
  135|    561|    switch (photometric)
  136|    561|    {
  137|      0|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      0|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (137:9): [True: 0, False: 561]
  ------------------
  138|    172|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    172|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (138:9): [True: 172, False: 389]
  ------------------
  139|    172|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|    172|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (139:9): [True: 0, False: 561]
  ------------------
  140|    172|            if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|    344|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (140:17): [True: 164, False: 8]
  ------------------
  141|    164|                td->td_samplesperpixel != 1 && td->td_bitspersample < 8)
  ------------------
  |  Branch (141:17): [True: 113, False: 51]
  |  Branch (141:48): [True: 1, False: 112]
  ------------------
  142|      1|            {
  143|      1|                snprintf(
  144|      1|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      1|#define EMSG_BUF_SIZE 1024
  ------------------
  145|      1|                    "Sorry, can not handle contiguous data with %s=%" PRIu16
  146|      1|                    ", "
  147|      1|                    "and %s=%" PRIu16 " and Bits/Sample=%" PRIu16 "",
  148|      1|                    photoTag, photometric, "Samples/pixel",
  149|      1|                    td->td_samplesperpixel, td->td_bitspersample);
  150|      1|                return (0);
  151|      1|            }
  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|    171|            break;
  158|    373|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    373|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (158:9): [True: 373, False: 188]
  ------------------
  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|    373|            break;
  166|      0|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (166:9): [True: 0, False: 561]
  ------------------
  167|      0|            if (colorchannels < 3)
  ------------------
  |  Branch (167:17): [True: 0, False: 0]
  ------------------
  168|      0|            {
  169|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  170|      0|                         "Sorry, can not handle RGB image with %s=%d",
  171|      0|                         "Color channels", colorchannels);
  172|      0|                return (0);
  173|      0|            }
  174|      0|            break;
  175|      1|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      1|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (175:9): [True: 1, False: 560]
  ------------------
  176|      1|        {
  177|      1|            uint16_t inkset;
  178|      1|            TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
  ------------------
  |  |  322|      1|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  179|      1|            if (inkset != INKSET_CMYK)
  ------------------
  |  |  323|      1|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  |  Branch (179:17): [True: 0, False: 1]
  ------------------
  180|      0|            {
  181|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  182|      0|                         "Sorry, can not handle separated image with %s=%d",
  183|      0|                         "InkSet", inkset);
  184|      0|                return 0;
  185|      0|            }
  186|      1|            if (td->td_samplesperpixel < 4)
  ------------------
  |  Branch (186:17): [True: 0, False: 1]
  ------------------
  187|      0|            {
  188|      0|                snprintf(
  189|      0|                    emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  190|      0|                    "Sorry, can not handle separated image with %s=%" PRIu16,
  191|      0|                    "Samples/pixel", td->td_samplesperpixel);
  192|      0|                return 0;
  193|      0|            }
  194|      1|            break;
  195|      1|        }
  196|      1|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|      0|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (196:9): [True: 0, False: 561]
  ------------------
  197|      0|            if (td->td_compression != COMPRESSION_SGILOG)
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (197:17): [True: 0, False: 0]
  ------------------
  198|      0|            {
  199|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  200|      0|                         "Sorry, LogL data must have %s=%d", "Compression",
  201|      0|                         COMPRESSION_SGILOG);
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  202|      0|                return (0);
  203|      0|            }
  204|      0|            break;
  205|      1|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|      1|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (205:9): [True: 1, False: 560]
  ------------------
  206|      1|            if (td->td_compression != COMPRESSION_SGILOG &&
  ------------------
  |  |  210|      2|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (206:17): [True: 1, False: 0]
  ------------------
  207|      1|                td->td_compression != COMPRESSION_SGILOG24)
  ------------------
  |  |  211|      1|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (207:17): [True: 0, False: 1]
  ------------------
  208|      0|            {
  209|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  210|      0|                         "Sorry, LogLuv data must have %s=%d or %d",
  211|      0|                         "Compression", COMPRESSION_SGILOG,
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  212|      0|                         COMPRESSION_SGILOG24);
  ------------------
  |  |  211|      0|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  213|      0|                return (0);
  214|      0|            }
  215|      1|            if (td->td_planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|      1|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (215:17): [True: 0, False: 1]
  ------------------
  216|      0|            {
  217|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  218|      0|                         "Sorry, can not handle LogLuv images with %s=%" PRIu16,
  219|      0|                         "Planarconfiguration", td->td_planarconfig);
  220|      0|                return (0);
  221|      0|            }
  222|      1|            if (td->td_samplesperpixel != 3 || colorchannels != 3)
  ------------------
  |  Branch (222:17): [True: 0, False: 1]
  |  Branch (222:48): [True: 0, False: 1]
  ------------------
  223|      0|            {
  224|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  225|      0|                         "Sorry, can not handle image with %s=%" PRIu16
  226|      0|                         ", %s=%d",
  227|      0|                         "Samples/pixel", td->td_samplesperpixel,
  228|      0|                         "colorchannels", colorchannels);
  229|      0|                return 0;
  230|      0|            }
  231|      1|            break;
  232|     13|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|     13|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (232:9): [True: 13, False: 548]
  ------------------
  233|     13|            if (td->td_samplesperpixel != 3 || colorchannels != 3 ||
  ------------------
  |  Branch (233:17): [True: 0, False: 13]
  |  Branch (233:48): [True: 0, False: 13]
  ------------------
  234|     13|                (td->td_bitspersample != 8 && td->td_bitspersample != 16))
  ------------------
  |  Branch (234:18): [True: 0, False: 13]
  |  Branch (234:47): [True: 0, False: 0]
  ------------------
  235|      0|            {
  236|      0|                snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      0|#define EMSG_BUF_SIZE 1024
  ------------------
  237|      0|                         "Sorry, can not handle image with %s=%" PRIu16
  238|      0|                         ", %s=%d and %s=%" PRIu16,
  239|      0|                         "Samples/pixel", td->td_samplesperpixel,
  240|      0|                         "colorchannels", colorchannels, "Bits/sample",
  241|      0|                         td->td_bitspersample);
  242|      0|                return 0;
  243|      0|            }
  244|     13|            break;
  245|     13|        default:
  ------------------
  |  Branch (245:9): [True: 1, False: 560]
  ------------------
  246|      1|            snprintf(emsg, EMSG_BUF_SIZE,
  ------------------
  |  |   53|      1|#define EMSG_BUF_SIZE 1024
  ------------------
  247|      1|                     "Sorry, can not handle image with %s=%" PRIu16, photoTag,
  248|      1|                     photometric);
  249|      1|            return (0);
  250|    561|    }
  251|    559|    return (1);
  252|    561|}
TIFFRGBAImageEnd:
  255|    559|{
  256|    559|    if (img->Map)
  ------------------
  |  Branch (256:9): [True: 0, False: 559]
  ------------------
  257|      0|    {
  258|      0|        _TIFFfreeExt(img->tif, img->Map);
  259|      0|        img->Map = NULL;
  260|      0|    }
  261|    559|    if (img->BWmap)
  ------------------
  |  Branch (261:9): [True: 163, False: 396]
  ------------------
  262|    163|    {
  263|    163|        _TIFFfreeExt(img->tif, img->BWmap);
  264|    163|        img->BWmap = NULL;
  265|    163|    }
  266|    559|    if (img->PALmap)
  ------------------
  |  Branch (266:9): [True: 0, False: 559]
  ------------------
  267|      0|    {
  268|      0|        _TIFFfreeExt(img->tif, img->PALmap);
  269|      0|        img->PALmap = NULL;
  270|      0|    }
  271|    559|    if (img->ycbcr)
  ------------------
  |  Branch (271:9): [True: 81, False: 478]
  ------------------
  272|     81|    {
  273|     81|        _TIFFfreeExt(img->tif, img->ycbcr);
  274|     81|        img->ycbcr = NULL;
  275|     81|    }
  276|    559|    if (img->cielab)
  ------------------
  |  Branch (276:9): [True: 0, False: 559]
  ------------------
  277|      0|    {
  278|      0|        _TIFFfreeExt(img->tif, img->cielab);
  279|      0|        img->cielab = NULL;
  280|      0|    }
  281|    559|    if (img->UaToAa)
  ------------------
  |  Branch (281:9): [True: 7, False: 552]
  ------------------
  282|      7|    {
  283|      7|        _TIFFfreeExt(img->tif, img->UaToAa);
  284|      7|        img->UaToAa = NULL;
  285|      7|    }
  286|    559|    if (img->Bitdepth16To8)
  ------------------
  |  Branch (286:9): [True: 272, False: 287]
  ------------------
  287|    272|    {
  288|    272|        _TIFFfreeExt(img->tif, img->Bitdepth16To8);
  289|    272|        img->Bitdepth16To8 = NULL;
  290|    272|    }
  291|       |
  292|    559|    if (img->redcmap)
  ------------------
  |  Branch (292:9): [True: 0, False: 559]
  ------------------
  293|      0|    {
  294|      0|        _TIFFfreeExt(img->tif, img->redcmap);
  295|      0|        _TIFFfreeExt(img->tif, img->greencmap);
  296|      0|        _TIFFfreeExt(img->tif, img->bluecmap);
  297|       |        img->redcmap = img->greencmap = img->bluecmap = NULL;
  298|      0|    }
  299|    559|}
TIFFRGBAImageBegin:
  313|    593|{
  314|    593|    uint16_t *sampleinfo;
  315|    593|    uint16_t extrasamples;
  316|    593|    uint16_t planarconfig;
  317|    593|    uint16_t compress;
  318|    593|    int colorchannels;
  319|    593|    uint16_t *red_orig, *green_orig, *blue_orig;
  320|    593|    uint32_t n_color;
  321|       |
  322|    593|    if (!TIFFRGBAImageOK(tif, emsg))
  ------------------
  |  Branch (322:9): [True: 34, False: 559]
  ------------------
  323|     34|        return 0;
  324|       |
  325|       |    /* Initialize to normal values */
  326|    559|    img->row_offset = 0;
  327|    559|    img->col_offset = 0;
  328|    559|    img->redcmap = NULL;
  329|    559|    img->greencmap = NULL;
  330|    559|    img->bluecmap = NULL;
  331|    559|    img->Map = NULL;
  332|    559|    img->BWmap = NULL;
  333|    559|    img->PALmap = NULL;
  334|    559|    img->ycbcr = NULL;
  335|    559|    img->cielab = NULL;
  336|    559|    img->UaToAa = NULL;
  337|    559|    img->Bitdepth16To8 = NULL;
  338|    559|    img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
  ------------------
  |  |  252|    559|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  339|       |
  340|    559|    img->tif = tif;
  341|    559|    img->stoponerr = stop;
  342|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
  ------------------
  |  |  180|    559|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
  343|    559|    switch (img->bitspersample)
  344|    559|    {
  345|     22|        case 1:
  ------------------
  |  Branch (345:9): [True: 22, False: 537]
  ------------------
  346|     31|        case 2:
  ------------------
  |  Branch (346:9): [True: 9, False: 550]
  ------------------
  347|     32|        case 4:
  ------------------
  |  Branch (347:9): [True: 1, False: 558]
  ------------------
  348|    217|        case 8:
  ------------------
  |  Branch (348:9): [True: 185, False: 374]
  ------------------
  349|    559|        case 16:
  ------------------
  |  Branch (349:9): [True: 342, False: 217]
  ------------------
  350|    559|            break;
  351|      0|        default:
  ------------------
  |  Branch (351:9): [True: 0, False: 559]
  ------------------
  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|    559|    }
  358|    559|    img->alpha = 0;
  359|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
  ------------------
  |  |  257|    559|#define TIFFTAG_SAMPLESPERPIXEL 277        /* samples per pixel */
  ------------------
  360|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples,
  ------------------
  |  |  329|    559|#define TIFFTAG_EXTRASAMPLES 338           /* !info about extra samples */
  ------------------
  361|    559|                          &sampleinfo);
  362|    559|    if (extrasamples >= 1)
  ------------------
  |  Branch (362:9): [True: 383, False: 176]
  ------------------
  363|    383|    {
  364|    383|        switch (sampleinfo[0])
  365|    383|        {
  366|     95|            case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without
  ------------------
  |  |  330|     95|#define EXTRASAMPLE_UNSPECIFIED 0          /* !unspecified data */
  ------------------
  |  Branch (366:13): [True: 95, False: 288]
  ------------------
  367|       |                                           */
  368|     95|                if (img->samplesperpixel >
  ------------------
  |  Branch (368:21): [True: 53, False: 42]
  ------------------
  369|     95|                    3) /* correct info about alpha channel */
  370|     53|                    img->alpha = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|     53|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  371|     95|                break;
  372|      1|            case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
  ------------------
  |  |  331|      1|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (372:13): [True: 1, False: 382]
  ------------------
  373|    288|            case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
  ------------------
  |  |  332|    288|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (373:13): [True: 287, False: 96]
  ------------------
  374|    288|                img->alpha = sampleinfo[0];
  375|    288|                break;
  376|      0|            default:
  ------------------
  |  Branch (376:13): [True: 0, False: 383]
  ------------------
  377|      0|                break;
  378|    383|        }
  379|    383|    }
  380|       |
  381|    559|#ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA
  382|    559|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
  ------------------
  |  |  220|    559|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (382:9): [True: 98, False: 461]
  ------------------
  383|     98|        img->photometric = PHOTOMETRIC_MINISWHITE;
  ------------------
  |  |  221|     98|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  384|       |
  385|    559|    if (extrasamples == 0 && img->samplesperpixel == 4 &&
  ------------------
  |  Branch (385:9): [True: 176, False: 383]
  |  Branch (385:30): [True: 0, False: 176]
  ------------------
  386|      0|        img->photometric == PHOTOMETRIC_RGB)
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (386:9): [True: 0, False: 0]
  ------------------
  387|      0|    {
  388|      0|        img->alpha = EXTRASAMPLE_ASSOCALPHA;
  ------------------
  |  |  331|      0|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  389|      0|        extrasamples = 1;
  390|      0|    }
  391|    559|#endif
  392|       |
  393|    559|    colorchannels = img->samplesperpixel - extrasamples;
  394|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress);
  ------------------
  |  |  181|    559|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  395|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
  ------------------
  |  |  264|    559|#define TIFFTAG_PLANARCONFIG 284           /* storage organization */
  ------------------
  396|    559|    if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
  ------------------
  |  |  220|    559|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (396:9): [True: 98, False: 461]
  ------------------
  397|     98|    {
  398|     98|        switch (colorchannels)
  399|     98|        {
  400|     98|            case 1:
  ------------------
  |  Branch (400:13): [True: 98, False: 0]
  ------------------
  401|     98|                if (isCCITTCompression(tif))
  ------------------
  |  Branch (401:21): [True: 12, False: 86]
  ------------------
  402|     12|                    img->photometric = PHOTOMETRIC_MINISWHITE;
  ------------------
  |  |  221|     12|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  403|     86|                else
  404|     86|                    img->photometric = PHOTOMETRIC_MINISBLACK;
  ------------------
  |  |  222|     86|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  405|     98|                break;
  406|      0|            case 3:
  ------------------
  |  Branch (406:13): [True: 0, False: 98]
  ------------------
  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: 98]
  ------------------
  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|     98|        }
  414|     98|    }
  415|    559|    switch (img->photometric)
  416|    559|    {
  417|      0|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|      0|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (417:9): [True: 0, False: 559]
  ------------------
  418|      0|            if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &red_orig, &green_orig,
  ------------------
  |  |  309|      0|#define TIFFTAG_COLORMAP 320               /* RGB map for palette image */
  ------------------
  |  Branch (418:17): [True: 0, False: 0]
  ------------------
  419|      0|                              &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|      0|            n_color = (uint32_t)(1U << img->bitspersample);
  428|      0|            img->redcmap = (uint16_t *)_TIFFmallocExt(
  429|      0|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  430|      0|            img->greencmap = (uint16_t *)_TIFFmallocExt(
  431|      0|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  432|      0|            img->bluecmap = (uint16_t *)_TIFFmallocExt(
  433|      0|                tif, (tmsize_t)(sizeof(uint16_t) * (size_t)n_color));
  434|      0|            if (!img->redcmap || !img->greencmap || !img->bluecmap)
  ------------------
  |  Branch (434:17): [True: 0, False: 0]
  |  Branch (434:34): [True: 0, False: 0]
  |  Branch (434:53): [True: 0, False: 0]
  ------------------
  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|      0|            _TIFFmemcpy(img->redcmap, red_orig, n_color * 2);
  442|      0|            _TIFFmemcpy(img->greencmap, green_orig, n_color * 2);
  443|      0|            _TIFFmemcpy(img->bluecmap, blue_orig, n_color * 2);
  444|       |
  445|       |            /* fall through... */
  446|     12|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|     12|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (446:9): [True: 12, False: 547]
  ------------------
  447|    171|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    171|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (447:9): [True: 159, False: 400]
  ------------------
  448|    171|            if (planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|    342|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (448:17): [True: 163, False: 8]
  ------------------
  449|    163|                img->samplesperpixel != 1 && img->bitspersample < 8)
  ------------------
  |  Branch (449:17): [True: 112, False: 51]
  |  Branch (449:46): [True: 0, False: 112]
  ------------------
  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|    171|            break;
  461|    373|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    373|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (461:9): [True: 373, False: 186]
  ------------------
  462|       |            /* It would probably be nice to have a reality check here. */
  463|    373|            if (planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|    373|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (463:17): [True: 335, False: 38]
  ------------------
  464|       |                /* can rely on libjpeg to convert to RGB */
  465|       |                /* XXX should restore current state on exit */
  466|    335|                switch (compress)
  467|    335|                {
  468|    285|                    case COMPRESSION_JPEG:
  ------------------
  |  |  190|    285|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
  |  Branch (468:21): [True: 285, False: 50]
  ------------------
  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|    285|                        TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE,
  ------------------
  |  |  706|    285|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  476|    285|                                     JPEGCOLORMODE_RGB);
  ------------------
  |  |  708|    285|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  477|    285|                        img->photometric = PHOTOMETRIC_RGB;
  ------------------
  |  |  223|    285|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  478|    285|                        break;
  479|     50|                    default:
  ------------------
  |  Branch (479:21): [True: 50, False: 285]
  ------------------
  480|     50|                        /* do nothing */;
  481|     50|                        break;
  482|    335|                }
  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|    373|            break;
  490|    373|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (490:9): [True: 0, False: 559]
  ------------------
  491|      0|            if (colorchannels < 3)
  ------------------
  |  Branch (491:17): [True: 0, False: 0]
  ------------------
  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|      0|            break;
  499|      1|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      1|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (499:9): [True: 1, False: 558]
  ------------------
  500|      1|        {
  501|      1|            uint16_t inkset;
  502|      1|            TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
  ------------------
  |  |  322|      1|#define TIFFTAG_INKSET 332                 /* !inks in separated image */
  ------------------
  503|      1|            if (inkset != INKSET_CMYK)
  ------------------
  |  |  323|      1|#define INKSET_CMYK 1                      /* !cyan-magenta-yellow-black color */
  ------------------
  |  Branch (503:17): [True: 0, False: 1]
  ------------------
  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|      1|            if (img->samplesperpixel < 4)
  ------------------
  |  Branch (511:17): [True: 0, False: 1]
  ------------------
  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|      1|        }
  520|      1|        break;
  521|      1|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|      0|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (521:9): [True: 0, False: 559]
  ------------------
  522|      0|            if (compress != COMPRESSION_SGILOG)
  ------------------
  |  |  210|      0|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (522:17): [True: 0, False: 0]
  ------------------
  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|      0|            TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  743|      0|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
                          TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  747|      0|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  530|      0|            img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */
  ------------------
  |  |  222|      0|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  531|      0|            img->bitspersample = 8;
  532|      0|            break;
  533|      1|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|      1|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (533:9): [True: 1, False: 558]
  ------------------
  534|      1|            if (compress != COMPRESSION_SGILOG &&
  ------------------
  |  |  210|      2|#define COMPRESSION_SGILOG 34676   /* SGI Log Luminance RLE */
  ------------------
  |  Branch (534:17): [True: 1, False: 0]
  ------------------
  535|      1|                compress != COMPRESSION_SGILOG24)
  ------------------
  |  |  211|      1|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (535:17): [True: 0, False: 1]
  ------------------
  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|      1|            if (planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|      1|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (543:17): [True: 0, False: 1]
  ------------------
  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|      1|            TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  743|      1|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
                          TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
  ------------------
  |  |  747|      1|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  551|      1|            img->photometric = PHOTOMETRIC_RGB; /* little white lie */
  ------------------
  |  |  223|      1|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  552|      1|            img->bitspersample = 8;
  553|      1|            break;
  554|     13|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|     13|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (554:9): [True: 13, False: 546]
  ------------------
  555|     13|            break;
  556|      0|        default:
  ------------------
  |  Branch (556:9): [True: 0, False: 559]
  ------------------
  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|    559|    }
  562|    559|    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
  ------------------
  |  |  178|    559|#define TIFFTAG_IMAGEWIDTH 256        /* image width in pixels */
  ------------------
  563|    559|    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
  ------------------
  |  |  179|    559|#define TIFFTAG_IMAGELENGTH 257       /* image height in pixels */
  ------------------
  564|    559|    TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
  ------------------
  |  |  248|    559|#define TIFFTAG_ORIENTATION 274            /* +image orientation */
  ------------------
  565|    559|    img->isContig =
  566|    559|        !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1);
  ------------------
  |  |  266|  1.11k|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (566:11): [True: 60, False: 499]
  |  Branch (566:52): [True: 60, False: 0]
  ------------------
  567|    559|    if (img->isContig)
  ------------------
  |  Branch (567:9): [True: 499, False: 60]
  ------------------
  568|    499|    {
  569|    499|        if (!PickContigCase(img))
  ------------------
  |  Branch (569:13): [True: 25, False: 474]
  ------------------
  570|     25|        {
  571|     25|            snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
  ------------------
  |  |   53|     25|#define EMSG_BUF_SIZE 1024
  ------------------
  572|     25|            goto fail_return;
  573|     25|        }
  574|    499|    }
  575|     60|    else
  576|     60|    {
  577|     60|        if (!PickSeparateCase(img))
  ------------------
  |  Branch (577:13): [True: 32, False: 28]
  ------------------
  578|     32|        {
  579|     32|            snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
  ------------------
  |  |   53|     32|#define EMSG_BUF_SIZE 1024
  ------------------
  580|     32|            goto fail_return;
  581|     32|        }
  582|     60|    }
  583|    502|    return 1;
  584|       |
  585|     57|fail_return:
  586|     57|    TIFFRGBAImageEnd(img);
  587|     57|    return 0;
  588|    559|}
TIFFRGBAImageGet:
  592|    502|{
  593|    502|    if (img->get == NULL)
  ------------------
  |  Branch (593:9): [True: 0, False: 502]
  ------------------
  594|      0|    {
  595|      0|        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
  596|      0|                      "No \"get\" routine setup");
  597|      0|        return (0);
  598|      0|    }
  599|    502|    if (img->put.any == NULL)
  ------------------
  |  Branch (599:9): [True: 0, False: 502]
  ------------------
  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|    502|    if (0 <= img->row_offset && (uint32_t)img->row_offset < img->height)
  ------------------
  |  Branch (608:9): [True: 502, False: 0]
  |  Branch (608:33): [True: 502, False: 0]
  ------------------
  609|    502|    {
  610|    502|        uint32_t hx = img->height - (uint32_t)img->row_offset;
  611|    502|        if (h > hx)
  ------------------
  |  Branch (611:13): [True: 0, False: 502]
  ------------------
  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|    502|    }
  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|    502|    return (*img->get)(img, raster, w, h);
  628|    502|}
TIFFReadRGBAImageOriented:
  636|    593|{
  637|    593|    char emsg[EMSG_BUF_SIZE] = "";
  638|    593|    TIFFRGBAImage img;
  639|    593|    int ok;
  640|       |
  641|    593|    if (TIFFRGBAImageBegin(&img, tif, stop, emsg))
  ------------------
  |  Branch (641:9): [True: 502, False: 91]
  ------------------
  642|    502|    {
  643|    502|        img.req_orientation = (uint16_t)orientation;
  644|    502|        ok = TIFFRGBAImageGet(&img, raster, rwidth, rheight);
  645|    502|        TIFFRGBAImageEnd(&img);
  646|    502|    }
  647|     91|    else
  648|     91|    {
  649|     91|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg);
  650|     91|        ok = 0;
  651|     91|    }
  652|    593|    return (ok);
  653|    593|}
tif_getimage.c:isCCITTCompression:
  302|     98|{
  303|     98|    uint16_t compress;
  304|     98|    TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
  ------------------
  |  |  181|     98|#define TIFFTAG_COMPRESSION 259       /* data compression technique */
  ------------------
  305|     98|    return (compress == COMPRESSION_CCITTFAX3 ||
  ------------------
  |  |  184|    196|#define COMPRESSION_CCITTFAX3 3       /* CCITT Group 3 fax encoding */
  ------------------
  |  Branch (305:13): [True: 11, False: 87]
  ------------------
  306|     87|            compress == COMPRESSION_CCITTFAX4 ||
  ------------------
  |  |  186|    185|#define COMPRESSION_CCITTFAX4 4       /* CCITT Group 4 fax encoding */
  ------------------
  |  Branch (306:13): [True: 0, False: 87]
  ------------------
  307|     87|            compress == COMPRESSION_CCITTRLE ||
  ------------------
  |  |  183|    185|#define COMPRESSION_CCITTRLE 2        /* CCITT modified Huffman RLE */
  ------------------
  |  Branch (307:13): [True: 1, False: 86]
  ------------------
  308|     86|            compress == COMPRESSION_CCITTRLEW);
  ------------------
  |  |  194|     86|#define COMPRESSION_CCITTRLEW 32771   /* #1 w/ word alignment */
  ------------------
  |  Branch (308:13): [True: 0, False: 86]
  ------------------
  309|     98|}
tif_getimage.c:PickContigCase:
 3123|    499|{
 3124|    499|    img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig;
  ------------------
  |  Branch (3124:16): [True: 6, False: 493]
  ------------------
 3125|    499|    img->put.contig = NULL;
 3126|    499|    switch (img->photometric)
 3127|    499|    {
 3128|    286|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|    286|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3128:9): [True: 286, False: 213]
  ------------------
 3129|    286|            switch (img->bitspersample)
 3130|    286|            {
 3131|     12|                case 8:
  ------------------
  |  Branch (3131:17): [True: 12, False: 274]
  ------------------
 3132|     12|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
  ------------------
  |  |  331|     24|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3132:25): [True: 0, False: 12]
  ------------------
 3133|      0|                        img->samplesperpixel >= 4)
  ------------------
  |  Branch (3133:25): [True: 0, False: 0]
  ------------------
 3134|      0|                        img->put.contig = putRGBAAcontig8bittile;
 3135|     12|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
  ------------------
  |  |  332|     24|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3135:30): [True: 2, False: 10]
  ------------------
 3136|      2|                             img->samplesperpixel >= 4)
  ------------------
  |  Branch (3136:30): [True: 0, False: 2]
  ------------------
 3137|      0|                    {
 3138|      0|                        if (BuildMapUaToAa(img))
  ------------------
  |  Branch (3138:29): [True: 0, False: 0]
  ------------------
 3139|      0|                            img->put.contig = putRGBUAcontig8bittile;
 3140|      0|                    }
 3141|     12|                    else if (img->samplesperpixel >= 3)
  ------------------
  |  Branch (3141:30): [True: 12, False: 0]
  ------------------
 3142|     12|                        img->put.contig = putRGBcontig8bittile;
 3143|     12|                    break;
 3144|    270|                case 16:
  ------------------
  |  Branch (3144:17): [True: 270, False: 16]
  ------------------
 3145|    270|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
  ------------------
  |  |  331|    540|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3145:25): [True: 0, False: 270]
  ------------------
 3146|      0|                        img->samplesperpixel >= 4)
  ------------------
  |  Branch (3146:25): [True: 0, False: 0]
  ------------------
 3147|      0|                    {
 3148|      0|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3148:29): [True: 0, False: 0]
  ------------------
 3149|      0|                            img->put.contig = putRGBAAcontig16bittile;
 3150|      0|                    }
 3151|    270|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
  ------------------
  |  |  332|    540|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3151:30): [True: 252, False: 18]
  ------------------
 3152|    252|                             img->samplesperpixel >= 4)
  ------------------
  |  Branch (3152:30): [True: 0, False: 252]
  ------------------
 3153|      0|                    {
 3154|      0|                        if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
  ------------------
  |  Branch (3154:29): [True: 0, False: 0]
  |  Branch (3154:59): [True: 0, False: 0]
  ------------------
 3155|      0|                            img->put.contig = putRGBUAcontig16bittile;
 3156|      0|                    }
 3157|    270|                    else if (img->samplesperpixel >= 3)
  ------------------
  |  Branch (3157:30): [True: 270, False: 0]
  ------------------
 3158|    270|                    {
 3159|    270|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3159:29): [True: 270, False: 0]
  ------------------
 3160|    270|                            img->put.contig = putRGBcontig16bittile;
 3161|    270|                    }
 3162|    270|                    break;
 3163|      4|                default:
  ------------------
  |  Branch (3163:17): [True: 4, False: 282]
  ------------------
 3164|      4|                    break;
 3165|    286|            }
 3166|    286|            break;
 3167|    286|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      0|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3167:9): [True: 0, False: 499]
  ------------------
 3168|      0|            if (img->samplesperpixel >= 4 && buildMap(img))
  ------------------
  |  Branch (3168:17): [True: 0, False: 0]
  |  Branch (3168:46): [True: 0, False: 0]
  ------------------
 3169|      0|            {
 3170|      0|                if (img->bitspersample == 8)
  ------------------
  |  Branch (3170:21): [True: 0, False: 0]
  ------------------
 3171|      0|                {
 3172|      0|                    if (!img->Map)
  ------------------
  |  Branch (3172:25): [True: 0, False: 0]
  ------------------
 3173|      0|                        img->put.contig = putRGBcontig8bitCMYKtile;
 3174|      0|                    else
 3175|      0|                        img->put.contig = putRGBcontig8bitCMYKMaptile;
 3176|      0|                }
 3177|      0|            }
 3178|      0|            break;
 3179|      0|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|      0|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (3179:9): [True: 0, False: 499]
  ------------------
 3180|      0|            if (buildMap(img))
  ------------------
  |  Branch (3180:17): [True: 0, False: 0]
  ------------------
 3181|      0|            {
 3182|      0|                switch (img->bitspersample)
 3183|      0|                {
 3184|      0|                    case 8:
  ------------------
  |  Branch (3184:21): [True: 0, False: 0]
  ------------------
 3185|      0|                        img->put.contig = put8bitcmaptile;
 3186|      0|                        break;
 3187|      0|                    case 4:
  ------------------
  |  Branch (3187:21): [True: 0, False: 0]
  ------------------
 3188|      0|                        img->put.contig = put4bitcmaptile;
 3189|      0|                        break;
 3190|      0|                    case 2:
  ------------------
  |  Branch (3190:21): [True: 0, False: 0]
  ------------------
 3191|      0|                        img->put.contig = put2bitcmaptile;
 3192|      0|                        break;
 3193|      0|                    case 1:
  ------------------
  |  Branch (3193:21): [True: 0, False: 0]
  ------------------
 3194|      0|                        img->put.contig = put1bitcmaptile;
 3195|      0|                        break;
 3196|      0|                    default:
  ------------------
  |  Branch (3196:21): [True: 0, False: 0]
  ------------------
 3197|      0|                        break;
 3198|      0|                }
 3199|      0|            }
 3200|      0|            break;
 3201|     12|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|     12|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3201:9): [True: 12, False: 487]
  ------------------
 3202|    163|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    163|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3202:9): [True: 151, False: 348]
  ------------------
 3203|    163|            if (buildMap(img))
  ------------------
  |  Branch (3203:17): [True: 163, False: 0]
  ------------------
 3204|    163|            {
 3205|    163|                switch (img->bitspersample)
 3206|    163|                {
 3207|     63|                    case 16:
  ------------------
  |  Branch (3207:21): [True: 63, False: 100]
  ------------------
 3208|     63|                        img->put.contig = put16bitbwtile;
 3209|     63|                        break;
 3210|     73|                    case 8:
  ------------------
  |  Branch (3210:21): [True: 73, False: 90]
  ------------------
 3211|     73|                        if (img->alpha && img->samplesperpixel == 2)
  ------------------
  |  Branch (3211:29): [True: 49, False: 24]
  |  Branch (3211:43): [True: 1, False: 48]
  ------------------
 3212|      1|                            img->put.contig = putagreytile;
 3213|     72|                        else
 3214|     72|                            img->put.contig = putgreytile;
 3215|     73|                        break;
 3216|      1|                    case 4:
  ------------------
  |  Branch (3216:21): [True: 1, False: 162]
  ------------------
 3217|      1|                        img->put.contig = put4bitbwtile;
 3218|      1|                        break;
 3219|      7|                    case 2:
  ------------------
  |  Branch (3219:21): [True: 7, False: 156]
  ------------------
 3220|      7|                        img->put.contig = put2bitbwtile;
 3221|      7|                        break;
 3222|     19|                    case 1:
  ------------------
  |  Branch (3222:21): [True: 19, False: 144]
  ------------------
 3223|     19|                        img->put.contig = put1bitbwtile;
 3224|     19|                        break;
 3225|      0|                    default:
  ------------------
  |  Branch (3225:21): [True: 0, False: 163]
  ------------------
 3226|      0|                        break;
 3227|    163|                }
 3228|    163|            }
 3229|    163|            break;
 3230|    163|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|     50|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3230:9): [True: 50, False: 449]
  ------------------
 3231|     50|            if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
  ------------------
  |  Branch (3231:17): [True: 43, False: 7]
  |  Branch (3231:46): [True: 43, False: 0]
  ------------------
 3232|     43|            {
 3233|     43|                if (initYCbCrConversion(img) != 0)
  ------------------
  |  Branch (3233:21): [True: 43, False: 0]
  ------------------
 3234|     43|                {
 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|     43|                    uint16_t SubsamplingHor;
 3245|     43|                    uint16_t SubsamplingVer;
 3246|     43|                    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|     43|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 3247|     43|                                          &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|     43|                    if (img->width < SubsamplingHor ||
  ------------------
  |  Branch (3251:25): [True: 14, False: 29]
  ------------------
 3252|     29|                        img->height < SubsamplingVer)
  ------------------
  |  Branch (3252:25): [True: 0, False: 29]
  ------------------
 3253|     14|                    {
 3254|     14|                        TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
 3255|     14|                                      "YCbCr subsampling (%u,%u) incompatible "
 3256|     14|                                      "with image size %ux%u",
 3257|     14|                                      SubsamplingHor, SubsamplingVer,
 3258|     14|                                      img->width, img->height);
 3259|     14|                        return (0);
 3260|     14|                    }
 3261|     29|                    switch ((SubsamplingHor << 4) | SubsamplingVer)
 3262|     29|                    {
 3263|      0|                        case 0x44:
  ------------------
  |  Branch (3263:25): [True: 0, False: 29]
  ------------------
 3264|      0|                            img->put.contig = putcontig8bitYCbCr44tile;
 3265|      0|                            break;
 3266|      0|                        case 0x42:
  ------------------
  |  Branch (3266:25): [True: 0, False: 29]
  ------------------
 3267|      0|                            img->put.contig = putcontig8bitYCbCr42tile;
 3268|      0|                            break;
 3269|      0|                        case 0x41:
  ------------------
  |  Branch (3269:25): [True: 0, False: 29]
  ------------------
 3270|      0|                            img->put.contig = putcontig8bitYCbCr41tile;
 3271|      0|                            break;
 3272|     29|                        case 0x22:
  ------------------
  |  Branch (3272:25): [True: 29, False: 0]
  ------------------
 3273|     29|                            img->put.contig = putcontig8bitYCbCr22tile;
 3274|     29|                            break;
 3275|      0|                        case 0x21:
  ------------------
  |  Branch (3275:25): [True: 0, False: 29]
  ------------------
 3276|      0|                            img->put.contig = putcontig8bitYCbCr21tile;
 3277|      0|                            break;
 3278|      0|                        case 0x12:
  ------------------
  |  Branch (3278:25): [True: 0, False: 29]
  ------------------
 3279|      0|                            img->put.contig = putcontig8bitYCbCr12tile;
 3280|      0|                            break;
 3281|      0|                        case 0x11:
  ------------------
  |  Branch (3281:25): [True: 0, False: 29]
  ------------------
 3282|      0|                            img->put.contig = putcontig8bitYCbCr11tile;
 3283|      0|                            break;
 3284|      0|                        default:
  ------------------
  |  Branch (3284:25): [True: 0, False: 29]
  ------------------
 3285|      0|                            break;
 3286|     29|                    }
 3287|     29|                }
 3288|     43|            }
 3289|     36|            break;
 3290|     36|        case PHOTOMETRIC_CIELAB:
  ------------------
  |  |  228|      0|#define PHOTOMETRIC_CIELAB 8               /* !1976 CIE L*a*b* */
  ------------------
  |  Branch (3290:9): [True: 0, False: 499]
  ------------------
 3291|      0|            if (img->samplesperpixel == 3 && buildMap(img))
  ------------------
  |  Branch (3291:17): [True: 0, False: 0]
  |  Branch (3291:46): [True: 0, False: 0]
  ------------------
 3292|      0|            {
 3293|      0|                if (img->bitspersample == 8 || img->bitspersample == 16)
  ------------------
  |  Branch (3293:21): [True: 0, False: 0]
  |  Branch (3293:48): [True: 0, False: 0]
  ------------------
 3294|      0|                    img->put.contig = initCIELabConversion(img);
 3295|      0|                break;
 3296|      0|            }
 3297|      0|            break;
 3298|      0|        default:
  ------------------
  |  Branch (3298:9): [True: 0, False: 499]
  ------------------
 3299|      0|            break;
 3300|    499|    }
 3301|    485|    return ((img->get != NULL) && (img->put.contig != NULL));
  ------------------
  |  Branch (3301:13): [True: 485, False: 0]
  |  Branch (3301:35): [True: 474, False: 11]
  ------------------
 3302|    499|}
tif_getimage.c:gtTileContig:
  735|      6|{
  736|      6|    TIFF *tif = img->tif;
  737|      6|    tileContigRoutine put = img->put.contig;
  738|      6|    uint32_t col, row, y, rowstoread;
  739|      6|    tmsize_t pos;
  740|      6|    uint32_t tw, th;
  741|      6|    unsigned char *buf = NULL;
  742|      6|    int32_t fromskew, toskew;
  743|      6|    uint32_t nrow;
  744|      6|    int ret = 1, flip;
  745|      6|    uint32_t this_tw, tocol;
  746|      6|    int32_t this_toskew, leftmost_toskew;
  747|      6|    int32_t leftmost_fromskew;
  748|      6|    uint32_t leftmost_tw;
  749|      6|    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|      6|    uint32_t wmin;
  754|       |
  755|      6|    if (0 <= img->col_offset && (uint32_t)img->col_offset < img->width)
  ------------------
  |  Branch (755:9): [True: 6, False: 0]
  |  Branch (755:33): [True: 6, False: 0]
  ------------------
  756|      6|    {
  757|      6|        wmin = TIFFmin(w, img->width - (uint32_t)img->col_offset);
  ------------------
  |  |  337|      6|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 6]
  |  |  ------------------
  ------------------
  758|      6|    }
  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|      6|    bufsize = TIFFTileSize(tif);
  768|      6|    if (bufsize == 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 6]
  ------------------
  769|      0|    {
  770|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s", "No space for tile buffer");
  771|      0|        return (0);
  772|      0|    }
  773|       |
  774|      6|    TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
  ------------------
  |  |  311|      6|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  775|      6|    TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
  ------------------
  |  |  312|      6|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  776|       |
  777|      6|    flip = setorientation(img);
  778|      6|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|      6|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (778:9): [True: 0, False: 6]
  ------------------
  779|      0|    {
  780|      0|        if (((int64_t)tw + w) > INT_MAX)
  ------------------
  |  Branch (780:13): [True: 0, False: 0]
  ------------------
  781|      0|        {
  782|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  783|      0|                          "unsupported tile size (too wide)");
  784|      0|            return (0);
  785|      0|        }
  786|      0|        y = h - 1;
  787|      0|        toskew = -(int32_t)(tw + w);
  788|      0|    }
  789|      6|    else
  790|      6|    {
  791|      6|        if (tw > ((int64_t)INT_MAX + w) || w > ((int64_t)INT_MAX + tw))
  ------------------
  |  Branch (791:13): [True: 0, False: 6]
  |  Branch (791:44): [True: 0, False: 6]
  ------------------
  792|      0|        {
  793|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  794|      0|                          "unsupported tile size (too wide)");
  795|      0|            return (0);
  796|      0|        }
  797|      6|        y = 0;
  798|      6|        toskew = -(int32_t)(tw - w);
  799|      6|    }
  800|       |
  801|      6|    if (tw == 0 || th == 0)
  ------------------
  |  Branch (801:9): [True: 0, False: 6]
  |  Branch (801:20): [True: 0, False: 6]
  ------------------
  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|      6|    leftmost_fromskew = (int32_t)((uint32_t)img->col_offset % tw);
  811|      6|    leftmost_tw = (uint32_t)((int32_t)tw - leftmost_fromskew);
  812|      6|    int64_t skew_i64 = (int64_t)toskew + (int64_t)(int32_t)leftmost_fromskew;
  813|      6|    if (skew_i64 > INT_MAX || skew_i64 < INT_MIN)
  ------------------
  |  Branch (813:9): [True: 0, False: 6]
  |  Branch (813:31): [True: 0, False: 6]
  ------------------
  814|      0|    {
  815|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s %" PRId64, "Invalid skew",
  816|      0|                      skew_i64);
  817|      0|        return (0);
  818|      0|    }
  819|      6|    leftmost_toskew = (int32_t)skew_i64;
  820|     12|    for (row = 0; ret != 0 && row < h; row += nrow)
  ------------------
  |  Branch (820:19): [True: 6, False: 6]
  |  Branch (820:31): [True: 6, False: 0]
  ------------------
  821|      6|    {
  822|      6|        rowstoread = th - ((uint32_t)row + (uint32_t)img->row_offset) % th;
  823|      6|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (823:17): [True: 0, False: 6]
  ------------------
  824|      6|        fromskew = leftmost_fromskew;
  825|      6|        this_tw = leftmost_tw;
  826|      6|        this_toskew = leftmost_toskew;
  827|      6|        tocol = 0;
  828|      6|        col = (uint32_t)img->col_offset;
  829|       |        /* wmin: only write imagewidth if raster is bigger. */
  830|      6|        while (tocol < wmin)
  ------------------
  |  Branch (830:16): [True: 6, False: 0]
  ------------------
  831|      6|        {
  832|      6|            if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize, col,
  ------------------
  |  Branch (832:17): [True: 6, False: 0]
  ------------------
  833|      6|                                            (uint32_t)row +
  834|      6|                                                (uint32_t)img->row_offset,
  835|      6|                                            0, 0) == (tmsize_t)(-1) &&
  836|      6|                (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (836:18): [True: 6, False: 0]
  |  Branch (836:33): [True: 0, False: 0]
  ------------------
  837|      6|            {
  838|      6|                ret = 0;
  839|      6|                break;
  840|      6|            }
  841|      0|            pos = (((uint32_t)row + (uint32_t)img->row_offset) % th) *
  842|      0|                      TIFFTileRowSize(tif) +
  843|      0|                  ((tmsize_t)fromskew * img->samplesperpixel);
  844|      0|            if (tocol + this_tw > wmin)
  ------------------
  |  Branch (844:17): [True: 0, False: 0]
  ------------------
  845|      0|            {
  846|       |                /*
  847|       |                 * Rightmost tile is clipped on right side.
  848|       |                 */
  849|      0|                fromskew = (int32_t)(tw - (wmin - tocol));
  850|      0|                this_tw = (uint32_t)((int32_t)tw - fromskew);
  851|      0|                this_toskew = (int32_t)(toskew + (int32_t)(uint32_t)fromskew);
  852|      0|            }
  853|      0|            tmsize_t roffset = (tmsize_t)y * w + tocol;
  854|      0|            (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
  855|      0|                   this_toskew, buf + pos);
  856|      0|            tocol += this_tw;
  857|      0|            col += this_tw;
  858|       |            /*
  859|       |             * After the leftmost tile, tiles are no longer clipped on left
  860|       |             * side.
  861|       |             */
  862|      0|            fromskew = 0;
  863|      0|            this_tw = tw;
  864|      0|            this_toskew = toskew;
  865|      0|        }
  866|       |
  867|      6|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|      6|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (867:25): [True: 0, False: 6]
  ------------------
  868|      6|                                                 : (int32_t)nrow);
  869|      6|    }
  870|      6|    _TIFFfreeExt(img->tif, buf);
  871|       |
  872|      6|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|      6|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (872:9): [True: 0, False: 6]
  ------------------
  873|      0|    {
  874|      0|        uint32_t line;
  875|       |
  876|      0|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (876:24): [True: 0, False: 0]
  ------------------
  877|      0|        {
  878|      0|            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|      0|            uint32_t *right = left + wmin - 1;
  882|       |
  883|      0|            while (left < right)
  ------------------
  |  Branch (883:20): [True: 0, False: 0]
  ------------------
  884|      0|            {
  885|      0|                uint32_t temp = *left;
  886|      0|                *left = *right;
  887|      0|                *right = temp;
  888|      0|                left++;
  889|      0|                right--;
  890|      0|            }
  891|      0|        }
  892|      0|    }
  893|       |
  894|      6|    return (ret);
  895|      6|}
tif_getimage.c:setorientation:
  667|    502|{
  668|    502|    switch (img->orientation)
  669|    502|    {
  670|    499|        case ORIENTATION_TOPLEFT:
  ------------------
  |  |  249|    499|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (670:9): [True: 499, False: 3]
  ------------------
  671|    501|        case ORIENTATION_LEFTTOP:
  ------------------
  |  |  253|    501|#define ORIENTATION_LEFTTOP 5              /* row 0 lhs, col 0 top */
  ------------------
  |  Branch (671:9): [True: 2, False: 500]
  ------------------
  672|    501|            if (img->req_orientation == ORIENTATION_TOPRIGHT ||
  ------------------
  |  |  250|  1.00k|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (672:17): [True: 0, False: 501]
  ------------------
  673|    501|                img->req_orientation == ORIENTATION_RIGHTTOP)
  ------------------
  |  |  254|    501|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (673:17): [True: 0, False: 501]
  ------------------
  674|      0|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|      0|#define FLIP_HORIZONTALLY 0x02
  ------------------
  675|    501|            else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
  ------------------
  |  |  251|  1.00k|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (675:22): [True: 0, False: 501]
  ------------------
  676|    501|                     img->req_orientation == ORIENTATION_RIGHTBOT)
  ------------------
  |  |  255|    501|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (676:22): [True: 0, False: 501]
  ------------------
  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|    501|            else if (img->req_orientation == ORIENTATION_BOTLEFT ||
  ------------------
  |  |  252|  1.00k|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (678:22): [True: 0, False: 501]
  ------------------
  679|    501|                     img->req_orientation == ORIENTATION_LEFTBOT)
  ------------------
  |  |  256|    501|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (679:22): [True: 0, False: 501]
  ------------------
  680|      0|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#define FLIP_VERTICALLY 0x01
  ------------------
  681|    501|            else
  682|    501|                return 0;
  683|      0|        case ORIENTATION_TOPRIGHT:
  ------------------
  |  |  250|      0|#define ORIENTATION_TOPRIGHT 2             /* row 0 top, col 0 rhs */
  ------------------
  |  Branch (683:9): [True: 0, False: 502]
  ------------------
  684|      0|        case ORIENTATION_RIGHTTOP:
  ------------------
  |  |  254|      0|#define ORIENTATION_RIGHTTOP 6             /* row 0 rhs, col 0 top */
  ------------------
  |  Branch (684:9): [True: 0, False: 502]
  ------------------
  685|      0|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|      0|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (685:17): [True: 0, 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|      0|                return FLIP_HORIZONTALLY;
  ------------------
  |  |   51|      0|#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|      1|        case ORIENTATION_BOTRIGHT:
  ------------------
  |  |  251|      1|#define ORIENTATION_BOTRIGHT 3             /* row 0 bottom, col 0 rhs */
  ------------------
  |  Branch (696:9): [True: 1, False: 501]
  ------------------
  697|      1|        case ORIENTATION_RIGHTBOT:
  ------------------
  |  |  255|      1|#define ORIENTATION_RIGHTBOT 7             /* row 0 rhs, col 0 bottom */
  ------------------
  |  Branch (697:9): [True: 0, False: 502]
  ------------------
  698|      1|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|      2|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (698:17): [True: 1, 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|      1|                return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   51|      1|#define FLIP_HORIZONTALLY 0x02
  ------------------
                              return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
  ------------------
  |  |   50|      1|#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|      0|        case ORIENTATION_BOTLEFT:
  ------------------
  |  |  252|      0|#define ORIENTATION_BOTLEFT 4              /* row 0 bottom, col 0 lhs */
  ------------------
  |  Branch (709:9): [True: 0, False: 502]
  ------------------
  710|      0|        case ORIENTATION_LEFTBOT:
  ------------------
  |  |  256|      0|#define ORIENTATION_LEFTBOT 8              /* row 0 lhs, col 0 bottom */
  ------------------
  |  Branch (710:9): [True: 0, False: 502]
  ------------------
  711|      0|            if (img->req_orientation == ORIENTATION_TOPLEFT ||
  ------------------
  |  |  249|      0|#define ORIENTATION_TOPLEFT 1              /* row 0 top, col 0 lhs */
  ------------------
  |  Branch (711:17): [True: 0, 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|      0|                return FLIP_VERTICALLY;
  ------------------
  |  |   50|      0|#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: 502]
  ------------------
  723|      0|            return 0;
  724|    502|    }
  725|    502|}
tif_getimage.c:gtStripContig:
 1150|    468|{
 1151|    468|    TIFF *tif = img->tif;
 1152|    468|    tileContigRoutine put = img->put.contig;
 1153|    468|    uint32_t row, y, nrow, nrowsub, rowstoread;
 1154|    468|    tmsize_t pos;
 1155|    468|    unsigned char *buf = NULL;
 1156|    468|    uint32_t rowsperstrip;
 1157|    468|    uint16_t subsamplinghor, subsamplingver;
 1158|    468|    uint32_t imagewidth = img->width;
 1159|    468|    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|    468|    int32_t fromskew, toskew;
 1163|    468|    int ret = 1, flip;
 1164|    468|    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|    468|    uint32_t wmin;
 1169|    468|    if (0 <= img->col_offset && (uint32_t)img->col_offset < imagewidth)
  ------------------
  |  Branch (1169:9): [True: 468, False: 0]
  |  Branch (1169:33): [True: 468, False: 0]
  ------------------
 1170|    468|    {
 1171|    468|        wmin = TIFFmin(w, imagewidth - (uint32_t)img->col_offset);
  ------------------
  |  |  337|    468|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 468]
  |  |  ------------------
  ------------------
 1172|    468|    }
 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|    468|    TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor,
  ------------------
  |  |  388|    468|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 1183|    468|                          &subsamplingver);
 1184|    468|    if (subsamplingver == 0)
  ------------------
  |  Branch (1184:9): [True: 0, False: 468]
  ------------------
 1185|      0|    {
 1186|      0|        TIFFErrorExtR(tif, TIFFFileName(tif),
 1187|      0|                      "Invalid vertical YCbCr subsampling");
 1188|      0|        return (0);
 1189|      0|    }
 1190|       |
 1191|    468|    maxstripsize = TIFFStripSize(tif);
 1192|       |
 1193|    468|    flip = setorientation(img);
 1194|    468|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|    468|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1194:9): [True: 0, False: 468]
  ------------------
 1195|      0|    {
 1196|      0|        if (w > INT_MAX / 2)
  ------------------
  |  Branch (1196:13): [True: 0, False: 0]
  ------------------
 1197|      0|        {
 1198|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
 1199|      0|            return (0);
 1200|      0|        }
 1201|      0|        y = h - 1;
 1202|       |        /* Skew back to the raster row before the currently written row
 1203|       |         * -> one raster width plus copied image pixels. */
 1204|      0|        toskew = -(int32_t)(w + wmin);
 1205|      0|    }
 1206|    468|    else
 1207|    468|    {
 1208|    468|        y = 0;
 1209|       |        /* Skew forward to the end of the raster width of the row currently
 1210|       |         * copied. */
 1211|    468|        toskew = (int32_t)(w - wmin);
 1212|    468|    }
 1213|       |
 1214|    468|    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
  ------------------
  |  |  258|    468|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 1215|    468|    if (rowsperstrip == 0)
  ------------------
  |  Branch (1215:9): [True: 0, False: 468]
  ------------------
 1216|      0|    {
 1217|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
 1218|      0|        return (0);
 1219|      0|    }
 1220|       |
 1221|    468|    scanline = TIFFScanlineSize(tif);
 1222|    468|    fromskew = (int32_t)(w < imagewidth ? imagewidth - w : 0);
  ------------------
  |  Branch (1222:26): [True: 0, False: 468]
  ------------------
 1223|    958|    for (row = 0; row < h; row += nrow)
  ------------------
  |  Branch (1223:19): [True: 831, False: 127]
  ------------------
 1224|    831|    {
 1225|    831|        uint32_t temp;
 1226|    831|        rowstoread = rowsperstrip -
 1227|    831|                     (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip;
 1228|    831|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1228:17): [True: 239, False: 592]
  ------------------
 1229|    831|        nrowsub = nrow;
 1230|    831|        if ((nrowsub % subsamplingver) != 0)
  ------------------
  |  Branch (1230:13): [True: 502, False: 329]
  ------------------
 1231|    502|            nrowsub += subsamplingver - nrowsub % subsamplingver;
 1232|    831|        temp =
 1233|    831|            (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip + nrowsub;
 1234|    831|        if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
  ------------------
  |  |   68|    831|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (1234:13): [True: 831, False: 0]
  |  Branch (1234:29): [True: 0, False: 831]
  ------------------
 1235|      0|        {
 1236|      0|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1237|      0|                          "Integer overflow in gtStripContig");
 1238|      0|            return 0;
 1239|      0|        }
 1240|    831|        if (_TIFFReadEncodedStripAndAllocBuffer(
  ------------------
  |  Branch (1240:13): [True: 677, False: 154]
  ------------------
 1241|    831|                tif,
 1242|    831|                TIFFComputeStrip(tif,
 1243|    831|                                 (uint32_t)((int32_t)row + img->row_offset), 0),
 1244|    831|                (void **)(&buf), maxstripsize,
 1245|    831|                (tmsize_t)((size_t)temp * (size_t)scanline)) ==
 1246|    831|                (tmsize_t)(-1) &&
 1247|    677|            (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1247:14): [True: 341, False: 336]
  |  Branch (1247:29): [True: 0, False: 336]
  ------------------
 1248|    341|        {
 1249|    341|            ret = 0;
 1250|    341|            break;
 1251|    341|        }
 1252|       |
 1253|    490|        pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) %
 1254|    490|                         rowsperstrip) *
 1255|    490|                  scanline +
 1256|    490|              ((tmsize_t)img->col_offset * img->samplesperpixel);
 1257|    490|        tmsize_t roffset = (tmsize_t)y * w;
 1258|    490|        (*put)(img, raster + roffset, 0, y, wmin, nrow, fromskew, toskew,
 1259|    490|               buf + pos);
 1260|    490|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|    490|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1260:25): [True: 0, False: 490]
  ------------------
 1261|    490|                                                 : (int32_t)nrow);
 1262|    490|    }
 1263|       |
 1264|    468|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|    468|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1264:9): [True: 0, False: 468]
  ------------------
 1265|      0|    {
 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|      0|        uint32_t line;
 1271|       |
 1272|      0|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1272:24): [True: 0, False: 0]
  ------------------
 1273|      0|        {
 1274|      0|            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|      0|            uint32_t *right = left + wmin - 1;
 1278|       |
 1279|      0|            while (left < right)
  ------------------
  |  Branch (1279:20): [True: 0, False: 0]
  ------------------
 1280|      0|            {
 1281|      0|                uint32_t temp = *left;
 1282|      0|                *left = *right;
 1283|      0|                *right = temp;
 1284|      0|                left++;
 1285|      0|                right--;
 1286|      0|            }
 1287|      0|        }
 1288|      0|    }
 1289|       |
 1290|    468|    _TIFFfreeExt(img->tif, buf);
 1291|    468|    return (ret);
 1292|    468|}
tif_getimage.c:BuildMapUaToAa:
 3390|      7|{
 3391|      7|    static const char module[] = "BuildMapUaToAa";
 3392|      7|    uint8_t *m;
 3393|      7|    uint16_t na, nv;
 3394|      7|    assert(img->UaToAa == NULL);
  ------------------
  |  Branch (3394:5): [True: 0, False: 7]
  |  Branch (3394:5): [True: 7, False: 0]
  ------------------
 3395|      7|    img->UaToAa = (uint8_t *)_TIFFmallocExt(img->tif, 65536);
 3396|      7|    if (img->UaToAa == NULL)
  ------------------
  |  Branch (3396:9): [True: 0, False: 7]
  ------------------
 3397|      0|    {
 3398|      0|        TIFFErrorExtR(img->tif, module, "Out of memory");
 3399|      0|        return (0);
 3400|      0|    }
 3401|      7|    m = img->UaToAa;
 3402|  1.79k|    for (na = 0; na < 256; na++)
  ------------------
  |  Branch (3402:18): [True: 1.79k, False: 7]
  ------------------
 3403|  1.79k|    {
 3404|   460k|        for (nv = 0; nv < 256; nv++)
  ------------------
  |  Branch (3404:22): [True: 458k, False: 1.79k]
  ------------------
 3405|   458k|            *m++ = (uint8_t)((nv * na + 127) / 255);
 3406|  1.79k|    }
 3407|      7|    return (1);
 3408|      7|}
tif_getimage.c:putRGBcontig8bittile:
 1841|      1|{
 1842|      1|    int samplesperpixel = img->samplesperpixel;
 1843|       |
 1844|      1|    (void)x;
 1845|      1|    (void)y;
 1846|      1|    const tmsize_t fromskewLocal =
 1847|      1|        (tmsize_t)fromskew * (tmsize_t)samplesperpixel;
 1848|     17|    for (; h > 0; --h)
  ------------------
  |  Branch (1848:12): [True: 16, False: 1]
  ------------------
 1849|     16|    {
 1850|     16|        UNROLL8(w, NOP, *cp++ = PACK(pp[0], pp[1], pp[2]);
  ------------------
  |  | 1554|     16|    {                                                                          \
  |  | 1555|     16|        uint32_t _x;                                                           \
  |  | 1556|    112|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 96, False: 16]
  |  |  ------------------
  |  | 1557|     96|        {                                                                      \
  |  | 1558|     96|            op1;                                                               \
  |  | 1559|     96|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|     96|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|     96|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     96|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     96|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|     96|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     96|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     96|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|     96|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|     96|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     96|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     96|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|     96|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|     96|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|     96|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|     96|        }                                                                      \
  |  | 1561|     16|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 16, False: 0]
  |  |  ------------------
  |  | 1562|     16|        {                                                                      \
  |  | 1563|     16|            op1;                                                               \
  |  | 1564|     16|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|     16|    switch (x)                                                                 \
  |  |  |  | 1519|     16|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      0|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1523|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      0|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1525|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      0|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1527|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      0|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1529|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|     16|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1531|     16|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|     16|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1533|     16|            op;                                                                \
  |  |  |  | 1534|     16|            break;                                                             \
  |  |  |  | 1535|     16|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|     16|    }
  |  |  ------------------
  |  | 1565|     16|        }                                                                      \
  |  | 1566|     16|    }
  ------------------
 1851|     16|                pp += samplesperpixel);
 1852|     16|        cp += toskew;
 1853|     16|        pp += fromskewLocal;
 1854|     16|    }
 1855|      1|}
tif_getimage.c:BuildMapBitdepth16To8:
 3411|    272|{
 3412|    272|    static const char module[] = "BuildMapBitdepth16To8";
 3413|    272|    uint8_t *m;
 3414|    272|    uint32_t n;
 3415|    272|    assert(img->Bitdepth16To8 == NULL);
  ------------------
  |  Branch (3415:5): [True: 0, False: 272]
  |  Branch (3415:5): [True: 272, False: 0]
  ------------------
 3416|    272|    img->Bitdepth16To8 = (uint8_t *)_TIFFmallocExt(img->tif, 65536);
 3417|    272|    if (img->Bitdepth16To8 == NULL)
  ------------------
  |  Branch (3417:9): [True: 0, False: 272]
  ------------------
 3418|      0|    {
 3419|      0|        TIFFErrorExtR(img->tif, module, "Out of memory");
 3420|      0|        return (0);
 3421|      0|    }
 3422|    272|    m = img->Bitdepth16To8;
 3423|  17.8M|    for (n = 0; n < 65536; n++)
  ------------------
  |  Branch (3423:17): [True: 17.8M, False: 272]
  ------------------
 3424|  17.8M|        *m++ = (uint8_t)((n + 128) / 257);
 3425|    272|    return (1);
 3426|    272|}
tif_getimage.c:buildMap:
 3082|    163|{
 3083|    163|    switch (img->photometric)
 3084|    163|    {
 3085|      0|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|      0|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3085:9): [True: 0, False: 163]
  ------------------
 3086|      0|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|      0|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3086:9): [True: 0, False: 163]
  ------------------
 3087|      0|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      0|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3087:9): [True: 0, False: 163]
  ------------------
 3088|      0|            if (img->bitspersample == 8)
  ------------------
  |  Branch (3088:17): [True: 0, False: 0]
  ------------------
 3089|      0|                break;
 3090|       |            /* fall through... */
 3091|    151|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|    151|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3091:9): [True: 151, False: 12]
  ------------------
 3092|    163|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|    163|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3092:9): [True: 12, False: 151]
  ------------------
 3093|    163|            if (!setupMap(img))
  ------------------
  |  Branch (3093:17): [True: 0, False: 163]
  ------------------
 3094|      0|                return (0);
 3095|    163|            break;
 3096|    163|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|      0|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (3096:9): [True: 0, False: 163]
  ------------------
 3097|       |            /*
 3098|       |             * Convert 16-bit colormap to 8-bit (unless it looks
 3099|       |             * like an old-style 8-bit colormap).
 3100|       |             */
 3101|      0|            if (checkcmap(img) == 16)
  ------------------
  |  Branch (3101:17): [True: 0, False: 0]
  ------------------
 3102|      0|                cvtcmap(img);
 3103|      0|            else
 3104|      0|                TIFFWarningExtR(img->tif, TIFFFileName(img->tif),
 3105|      0|                                "Assuming 8-bit colormap");
 3106|       |            /*
 3107|       |             * Use mapping table and colormap to construct
 3108|       |             * unpacking tables for samples < 8 bits.
 3109|       |             */
 3110|      0|            if (img->bitspersample <= 8 && !makecmap(img))
  ------------------
  |  Branch (3110:17): [True: 0, False: 0]
  |  Branch (3110:44): [True: 0, False: 0]
  ------------------
 3111|      0|                return (0);
 3112|      0|            break;
 3113|      0|        default:
  ------------------
  |  Branch (3113:9): [True: 0, False: 163]
  ------------------
 3114|      0|            break;
 3115|    163|    }
 3116|    163|    return (1);
 3117|    163|}
tif_getimage.c:setupMap:
 2935|    163|{
 2936|    163|    int32_t x, range;
 2937|       |
 2938|    163|    range = (int32_t)((1U << img->bitspersample) - 1U);
 2939|       |
 2940|       |    /* treat 16 bit the same as eight bit */
 2941|    163|    if (img->bitspersample == 16)
  ------------------
  |  Branch (2941:9): [True: 63, False: 100]
  ------------------
 2942|     63|        range = 255;
 2943|       |
 2944|    163|    img->Map = (TIFFRGBValue *)_TIFFmallocExt(
 2945|    163|        img->tif, (tmsize_t)((size_t)(range + 1) * sizeof(TIFFRGBValue)));
 2946|    163|    if (img->Map == NULL)
  ------------------
  |  Branch (2946:9): [True: 0, False: 163]
  ------------------
 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|    163|    if (img->photometric == PHOTOMETRIC_MINISWHITE)
  ------------------
  |  |  221|    163|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (2952:9): [True: 12, False: 151]
  ------------------
 2953|     12|    {
 2954|     36|        for (x = 0; x <= range; x++)
  ------------------
  |  Branch (2954:21): [True: 24, False: 12]
  ------------------
 2955|     24|            img->Map[x] = (TIFFRGBValue)(((range - x) * 255) / range);
 2956|     12|    }
 2957|    151|    else
 2958|    151|    {
 2959|  35.0k|        for (x = 0; x <= range; x++)
  ------------------
  |  Branch (2959:21): [True: 34.8k, False: 151]
  ------------------
 2960|  34.8k|            img->Map[x] = (TIFFRGBValue)((x * 255) / range);
 2961|    151|    }
 2962|    163|    if (img->bitspersample <= 16 &&
  ------------------
  |  Branch (2962:9): [True: 163, False: 0]
  ------------------
 2963|    163|        (img->photometric == PHOTOMETRIC_MINISBLACK ||
  ------------------
  |  |  222|    326|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (2963:10): [True: 151, False: 12]
  ------------------
 2964|     12|         img->photometric == PHOTOMETRIC_MINISWHITE))
  ------------------
  |  |  221|     12|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (2964:10): [True: 12, False: 0]
  ------------------
 2965|    163|    {
 2966|       |        /*
 2967|       |         * Use photometric mapping table to construct
 2968|       |         * unpacking tables for samples <= 8 bits.
 2969|       |         */
 2970|    163|        if (!makebwmap(img))
  ------------------
  |  Branch (2970:13): [True: 0, False: 163]
  ------------------
 2971|      0|            return (0);
 2972|       |        /* no longer need Map, free it */
 2973|    163|        _TIFFfreeExt(img->tif, img->Map);
 2974|    163|        img->Map = NULL;
 2975|    163|    }
 2976|    163|    return (1);
 2977|    163|}
tif_getimage.c:makebwmap:
 2867|    163|{
 2868|    163|    TIFFRGBValue *Map = img->Map;
 2869|    163|    int bitspersample = img->bitspersample;
 2870|    163|    int nsamples = 8 / bitspersample;
 2871|    163|    int i;
 2872|    163|    uint32_t *p;
 2873|       |
 2874|    163|    if (nsamples == 0)
  ------------------
  |  Branch (2874:9): [True: 63, False: 100]
  ------------------
 2875|     63|        nsamples = 1;
 2876|       |
 2877|    163|    img->BWmap = (uint32_t **)_TIFFmallocExt(
 2878|    163|        img->tif,
 2879|    163|        (tmsize_t)((size_t)256 * sizeof(uint32_t *) +
 2880|    163|                   ((size_t)256 * (size_t)nsamples * sizeof(uint32_t))));
 2881|    163|    if (img->BWmap == NULL)
  ------------------
  |  Branch (2881:9): [True: 0, False: 163]
  ------------------
 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|    163|    p = (uint32_t *)(img->BWmap + 256);
 2888|  41.8k|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (2888:17): [True: 41.7k, False: 163]
  ------------------
 2889|  41.7k|    {
 2890|  41.7k|        TIFFRGBValue c;
 2891|  41.7k|        img->BWmap[i] = p;
 2892|  41.7k|        switch (bitspersample)
 2893|  41.7k|        {
 2894|      0|#define GREY(x)                                                                \
 2895|      0|    c = Map[x];                                                                \
 2896|      0|    *p++ = PACK(c, c, c);
 2897|  4.86k|            case 1:
  ------------------
  |  Branch (2897:13): [True: 4.86k, False: 36.8k]
  ------------------
 2898|  4.86k|                GREY(i >> 7);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2899|  4.86k|                GREY((i >> 6) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2900|  4.86k|                GREY((i >> 5) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2901|  4.86k|                GREY((i >> 4) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2902|  4.86k|                GREY((i >> 3) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2903|  4.86k|                GREY((i >> 2) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2904|  4.86k|                GREY((i >> 1) & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2905|  4.86k|                GREY(i & 1);
  ------------------
  |  | 2895|  4.86k|    c = Map[x];                                                                \
  |  | 2896|  4.86k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  4.86k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  4.86k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2906|  4.86k|                break;
 2907|  1.79k|            case 2:
  ------------------
  |  Branch (2907:13): [True: 1.79k, False: 39.9k]
  ------------------
 2908|  1.79k|                GREY(i >> 6);
  ------------------
  |  | 2895|  1.79k|    c = Map[x];                                                                \
  |  | 2896|  1.79k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  1.79k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  1.79k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2909|  1.79k|                GREY((i >> 4) & 3);
  ------------------
  |  | 2895|  1.79k|    c = Map[x];                                                                \
  |  | 2896|  1.79k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  1.79k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  1.79k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2910|  1.79k|                GREY((i >> 2) & 3);
  ------------------
  |  | 2895|  1.79k|    c = Map[x];                                                                \
  |  | 2896|  1.79k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  1.79k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  1.79k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2911|  1.79k|                GREY(i & 3);
  ------------------
  |  | 2895|  1.79k|    c = Map[x];                                                                \
  |  | 2896|  1.79k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  1.79k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  1.79k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2912|  1.79k|                break;
 2913|    256|            case 4:
  ------------------
  |  Branch (2913:13): [True: 256, False: 41.4k]
  ------------------
 2914|    256|                GREY(i >> 4);
  ------------------
  |  | 2895|    256|    c = Map[x];                                                                \
  |  | 2896|    256|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|    256|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|    256|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2915|    256|                GREY(i & 0xf);
  ------------------
  |  | 2895|    256|    c = Map[x];                                                                \
  |  | 2896|    256|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|    256|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|    256|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|    256|                break;
 2917|  18.6k|            case 8:
  ------------------
  |  Branch (2917:13): [True: 18.6k, False: 23.0k]
  ------------------
 2918|  34.8k|            case 16:
  ------------------
  |  Branch (2918:13): [True: 16.1k, False: 25.6k]
  ------------------
 2919|  34.8k|                GREY(i);
  ------------------
  |  | 2895|  34.8k|    c = Map[x];                                                                \
  |  | 2896|  34.8k|    *p++ = PACK(c, c, c);
  |  |  ------------------
  |  |  |  | 1612|  34.8k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1610|  34.8k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|  34.8k|                break;
 2921|      0|            default:
  ------------------
  |  Branch (2921:13): [True: 0, False: 41.7k]
  ------------------
 2922|      0|                break;
 2923|  41.7k|        }
 2924|  41.7k|#undef GREY
 2925|  41.7k|    }
 2926|    163|    return (1);
 2927|    163|}
tif_getimage.c:put16bitbwtile:
 1755|    110|{
 1756|    110|    int samplesperpixel = img->samplesperpixel;
 1757|    110|    uint32_t **BWmap = img->BWmap;
 1758|       |    /* Convert pixel skew to byte skew (16-bit samples) */
 1759|    110|    const tmsize_t fromskewLocal =
 1760|    110|        (tmsize_t)fromskew * (tmsize_t)(2 * samplesperpixel);
 1761|       |
 1762|    110|    (void)y;
 1763|   329k|    for (; h > 0; --h)
  ------------------
  |  Branch (1763:12): [True: 329k, False: 110]
  ------------------
 1764|   329k|    {
 1765|   329k|        uint16_t *wp = (uint16_t *)pp;
 1766|       |
 1767|  11.8M|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1767:21): [True: 11.5M, False: 329k]
  ------------------
 1768|  11.5M|        {
 1769|       |            /* use high order byte of 16bit value */
 1770|       |
 1771|  11.5M|            *cp++ = BWmap[*wp >> 8][0];
 1772|  11.5M|            pp += 2 * samplesperpixel;
 1773|  11.5M|            wp += samplesperpixel;
 1774|  11.5M|        }
 1775|   329k|        cp += toskew;
 1776|   329k|        pp += fromskewLocal;
 1777|   329k|    }
 1778|    110|}
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|    185|{
 1708|    185|    int samplesperpixel = img->samplesperpixel;
 1709|    185|    uint32_t **BWmap = img->BWmap;
 1710|       |    /* Convert pixel skew to byte skew (8-bit samples) */
 1711|    185|    const tmsize_t fromskewLocal =
 1712|    185|        (tmsize_t)fromskew * +(tmsize_t)samplesperpixel;
 1713|       |
 1714|    185|    (void)y;
 1715|   389k|    for (; h > 0; --h)
  ------------------
  |  Branch (1715:12): [True: 389k, False: 185]
  ------------------
 1716|   389k|    {
 1717|  35.2M|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (1717:21): [True: 34.8M, False: 389k]
  ------------------
 1718|  34.8M|        {
 1719|  34.8M|            *cp++ = BWmap[*pp][0];
 1720|  34.8M|            pp += samplesperpixel;
 1721|  34.8M|        }
 1722|   389k|        cp += toskew;
 1723|   389k|        pp += fromskewLocal;
 1724|   389k|    }
 1725|    185|}
tif_getimage.c:put4bitbwtile:
 1822|      1|{
 1823|      1|    uint32_t **BWmap = img->BWmap;
 1824|       |
 1825|      1|    (void)x;
 1826|      1|    (void)y;
 1827|      1|    fromskew /= 2;
 1828|  2.07k|    for (; h > 0; --h)
  ------------------
  |  Branch (1828:12): [True: 2.07k, False: 1]
  ------------------
 1829|  2.07k|    {
 1830|  2.07k|        uint32_t *bw;
 1831|  2.07k|        UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1582|  2.07k|    {                                                                          \
  |  | 1583|  2.07k|        uint32_t _x;                                                           \
  |  | 1584|  67.9M|        for (_x = w; _x >= 2; _x -= 2)                                         \
  |  |  ------------------
  |  |  |  Branch (1584:22): [True: 67.9M, False: 2.07k]
  |  |  ------------------
  |  | 1585|  67.9M|        {                                                                      \
  |  | 1586|  67.9M|            op1;                                                               \
  |  | 1587|  67.9M|            REPEAT2(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1515|  67.9M|    op;                                                                        \
  |  |  |  | 1516|  67.9M|    op
  |  |  ------------------
  |  | 1588|  67.9M|        }                                                                      \
  |  | 1589|  2.07k|        if (_x)                                                                \
  |  |  ------------------
  |  |  |  Branch (1589:13): [True: 0, False: 2.07k]
  |  |  ------------------
  |  | 1590|  2.07k|        {                                                                      \
  |  | 1591|      0|            op1;                                                               \
  |  | 1592|      0|            op2;                                                               \
  |  | 1593|      0|        }                                                                      \
  |  | 1594|  2.07k|    }
  ------------------
 1832|  2.07k|        cp += toskew;
 1833|  2.07k|        pp += fromskew;
 1834|  2.07k|    }
 1835|      1|}
tif_getimage.c:put2bitbwtile:
 1803|      7|{
 1804|      7|    uint32_t **BWmap = img->BWmap;
 1805|       |
 1806|      7|    (void)x;
 1807|      7|    (void)y;
 1808|      7|    fromskew /= 4;
 1809|   184k|    for (; h > 0; --h)
  ------------------
  |  Branch (1809:12): [True: 184k, False: 7]
  ------------------
 1810|   184k|    {
 1811|   184k|        uint32_t *bw;
 1812|   184k|        UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1568|   184k|    {                                                                          \
  |  | 1569|   184k|        uint32_t _x;                                                           \
  |  | 1570|   184k|        for (_x = w; _x >= 4; _x -= 4)                                         \
  |  |  ------------------
  |  |  |  Branch (1570:22): [True: 0, False: 184k]
  |  |  ------------------
  |  | 1571|   184k|        {                                                                      \
  |  | 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|   184k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1575:13): [True: 184k, False: 0]
  |  |  ------------------
  |  | 1576|   184k|        {                                                                      \
  |  | 1577|   184k|            op1;                                                               \
  |  | 1578|   184k|            CASE4(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1539|   184k|    switch (x)                                                                 \
  |  |  |  | 1540|   184k|    {                                                                          \
  |  |  |  | 1541|   184k|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1541:9): [True: 184k, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1542|   184k|            op; /*-fallthrough*/                                               \
  |  |  |  | 1543|   184k|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1543:9): [True: 0, False: 184k]
  |  |  |  |  ------------------
  |  |  |  | 1544|   184k|            op; /*-fallthrough*/                                               \
  |  |  |  | 1545|   184k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1545:9): [True: 0, False: 184k]
  |  |  |  |  ------------------
  |  |  |  | 1546|   184k|            op;                                                                \
  |  |  |  | 1547|   184k|            break;                                                             \
  |  |  |  | 1548|   184k|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1548:9): [True: 0, False: 184k]
  |  |  |  |  ------------------
  |  |  |  | 1549|      0|            break;                                                             \
  |  |  |  | 1550|   184k|    }
  |  |  ------------------
  |  | 1579|   184k|        }                                                                      \
  |  | 1580|   184k|    }
  ------------------
 1813|   184k|        cp += toskew;
 1814|   184k|        pp += fromskew;
 1815|   184k|    }
 1816|      7|}
tif_getimage.c:put1bitbwtile:
 1784|    185|{
 1785|    185|    uint32_t **BWmap = img->BWmap;
 1786|       |
 1787|    185|    (void)x;
 1788|    185|    (void)y;
 1789|    185|    fromskew /= 8;
 1790|  27.8k|    for (; h > 0; --h)
  ------------------
  |  Branch (1790:12): [True: 27.6k, False: 185]
  ------------------
 1791|  27.6k|    {
 1792|  27.6k|        uint32_t *bw;
 1793|  27.6k|        UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++);
  ------------------
  |  | 1554|  27.6k|    {                                                                          \
  |  | 1555|  27.6k|        uint32_t _x;                                                           \
  |  | 1556|  1.13M|        for (_x = w; _x >= 8; _x -= 8)                                         \
  |  |  ------------------
  |  |  |  Branch (1556:22): [True: 1.11M, False: 27.6k]
  |  |  ------------------
  |  | 1557|  1.11M|        {                                                                      \
  |  | 1558|  1.11M|            op1;                                                               \
  |  | 1559|  1.11M|            REPEAT8(op2);                                                      \
  |  |  ------------------
  |  |  |  | 1509|  1.11M|    REPEAT4(op);                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|  1.11M|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.11M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.11M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|  1.11M|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.11M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.11M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  | 1510|  1.11M|    REPEAT4(op)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1512|  1.11M|    REPEAT2(op);                                                               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.11M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.11M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  | 1513|  1.11M|    REPEAT2(op)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1515|  1.11M|    op;                                                                        \
  |  |  |  |  |  |  |  | 1516|  1.11M|    op
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  | 1560|  1.11M|        }                                                                      \
  |  | 1561|  27.6k|        if (_x > 0)                                                            \
  |  |  ------------------
  |  |  |  Branch (1561:13): [True: 6.05k, False: 21.6k]
  |  |  ------------------
  |  | 1562|  27.6k|        {                                                                      \
  |  | 1563|  6.05k|            op1;                                                               \
  |  | 1564|  6.05k|            CASE8(_x, op2);                                                    \
  |  |  ------------------
  |  |  |  | 1518|  6.05k|    switch (x)                                                                 \
  |  |  |  | 1519|  6.05k|    {                                                                          \
  |  |  |  | 1520|      0|        case 7:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1520:9): [True: 0, False: 6.05k]
  |  |  |  |  ------------------
  |  |  |  | 1521|      0|            op; /*-fallthrough*/                                               \
  |  |  |  | 1522|      6|        case 6:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1522:9): [True: 6, False: 6.04k]
  |  |  |  |  ------------------
  |  |  |  | 1523|      6|            op; /*-fallthrough*/                                               \
  |  |  |  | 1524|      6|        case 5:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1524:9): [True: 0, False: 6.05k]
  |  |  |  |  ------------------
  |  |  |  | 1525|      6|            op; /*-fallthrough*/                                               \
  |  |  |  | 1526|      6|        case 4:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1526:9): [True: 0, False: 6.05k]
  |  |  |  |  ------------------
  |  |  |  | 1527|      6|            op; /*-fallthrough*/                                               \
  |  |  |  | 1528|      6|        case 3:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1528:9): [True: 0, False: 6.05k]
  |  |  |  |  ------------------
  |  |  |  | 1529|      6|            op; /*-fallthrough*/                                               \
  |  |  |  | 1530|  2.05k|        case 2:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1530:9): [True: 2.05k, False: 4.00k]
  |  |  |  |  ------------------
  |  |  |  | 1531|  2.05k|            op; /*-fallthrough*/                                               \
  |  |  |  | 1532|  6.05k|        case 1:                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1532:9): [True: 3.99k, False: 2.05k]
  |  |  |  |  ------------------
  |  |  |  | 1533|  6.05k|            op;                                                                \
  |  |  |  | 1534|  6.05k|            break;                                                             \
  |  |  |  | 1535|  2.05k|        default:                                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1535:9): [True: 0, False: 6.05k]
  |  |  |  |  ------------------
  |  |  |  | 1536|      0|            break;                                                             \
  |  |  |  | 1537|  6.05k|    }
  |  |  ------------------
  |  | 1565|  6.05k|        }                                                                      \
  |  | 1566|  27.6k|    }
  ------------------
 1794|  27.6k|        cp += toskew;
 1795|  27.6k|        pp += fromskew;
 1796|  27.6k|    }
 1797|    185|}
tif_getimage.c:initYCbCrConversion:
 2764|     81|{
 2765|     81|    static const char module[] = "initYCbCrConversion";
 2766|       |
 2767|     81|    float *luma, *refBlackWhite;
 2768|       |
 2769|     81|    if (img->ycbcr == NULL)
  ------------------
  |  Branch (2769:9): [True: 81, False: 0]
  ------------------
 2770|     81|    {
 2771|     81|        img->ycbcr = (TIFFYCbCrToRGB *)_TIFFmallocExt(
 2772|     81|            img->tif, TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long)) +
  ------------------
  |  |  322|     81|#define TIFFroundup_32(x, y) ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
  |  |  ------------------
  |  |  |  |  312|     81|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (312:6): [True: 81, Folded]
  |  |  |  |  ------------------
  |  |  |  |  313|     81|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  |  |  314|     81|         : 0U)
  |  |  ------------------
  ------------------
 2773|     81|                          4 * 256 * sizeof(TIFFRGBValue) +
 2774|     81|                          2 * 256 * sizeof(int) + 3 * 256 * sizeof(int32_t));
 2775|     81|        if (img->ycbcr == NULL)
  ------------------
  |  Branch (2775:13): [True: 0, False: 81]
  ------------------
 2776|      0|        {
 2777|      0|            TIFFErrorExtR(img->tif, module,
 2778|      0|                          "No space for YCbCr->RGB conversion state");
 2779|      0|            return (0);
 2780|      0|        }
 2781|     81|    }
 2782|       |
 2783|     81|    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);
  ------------------
  |  |  387|     81|#define TIFFTAG_YCBCRCOEFFICIENTS 529      /* !RGB -> YCbCr transform */
  ------------------
 2784|     81|    TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE,
  ------------------
  |  |  392|     81|#define TIFFTAG_REFERENCEBLACKWHITE 532    /* !colorimetry info */
  ------------------
 2785|     81|                          &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|     81|    if (isnan(luma[0]) || isnan(luma[1]) || TIFF_FLOAT_EQ(luma[1], 0.0f) ||
  ------------------
  |  |  342|    162|#define TIFF_FLOAT_EQ(x, y) (!(fabsf((x) - (y)) > 0.0f))
  |  |  ------------------
  |  |  |  Branch (342:29): [True: 0, False: 81]
  |  |  ------------------
  ------------------
  |  Branch (2789:9): [True: 0, False: 81]
  |  Branch (2789:27): [True: 0, False: 81]
  ------------------
 2790|     81|        isnan(luma[2]))
  ------------------
  |  Branch (2790:9): [True: 0, False: 81]
  ------------------
 2791|      0|    {
 2792|      0|        TIFFErrorExtR(img->tif, module,
 2793|      0|                      "Invalid values for YCbCrCoefficients tag");
 2794|      0|        return (0);
 2795|      0|    }
 2796|       |
 2797|     81|    if (!isInRefBlackWhiteRange(refBlackWhite[0]) ||
  ------------------
  |  Branch (2797:9): [True: 0, False: 81]
  ------------------
 2798|     81|        !isInRefBlackWhiteRange(refBlackWhite[1]) ||
  ------------------
  |  Branch (2798:9): [True: 0, False: 81]
  ------------------
 2799|     81|        !isInRefBlackWhiteRange(refBlackWhite[2]) ||
  ------------------
  |  Branch (2799:9): [True: 0, False: 81]
  ------------------
 2800|     81|        !isInRefBlackWhiteRange(refBlackWhite[3]) ||
  ------------------
  |  Branch (2800:9): [True: 1, False: 80]
  ------------------
 2801|     80|        !isInRefBlackWhiteRange(refBlackWhite[4]) ||
  ------------------
  |  Branch (2801:9): [True: 0, False: 80]
  ------------------
 2802|     80|        !isInRefBlackWhiteRange(refBlackWhite[5]))
  ------------------
  |  Branch (2802:9): [True: 0, False: 80]
  ------------------
 2803|      1|    {
 2804|      1|        TIFFErrorExtR(img->tif, module,
 2805|      1|                      "Invalid values for ReferenceBlackWhite tag");
 2806|      1|        return (0);
 2807|      1|    }
 2808|       |
 2809|     80|    if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0)
  ------------------
  |  Branch (2809:9): [True: 0, False: 80]
  ------------------
 2810|      0|        return (0);
 2811|     80|    return (1);
 2812|     80|}
tif_getimage.c:isInRefBlackWhiteRange:
 2759|    484|{
 2760|    484|    return f > (float)(-0x7FFFFFFF + 128) && f < (float)0x7FFFFFFF;
  ------------------
  |  Branch (2760:12): [True: 484, False: 0]
  |  Branch (2760:46): [True: 483, False: 1]
  ------------------
 2761|    484|}
tif_getimage.c:PickSeparateCase:
 3311|     60|{
 3312|     60|    img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
  ------------------
  |  Branch (3312:16): [True: 57, False: 3]
  ------------------
 3313|     60|    img->put.separate = NULL;
 3314|     60|    switch (img->photometric)
 3315|     60|    {
 3316|      0|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      0|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (3316:9): [True: 0, False: 60]
  ------------------
 3317|      8|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|      8|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (3317:9): [True: 8, False: 52]
  ------------------
 3318|       |            /* greyscale images processed pretty much as RGB by gtTileSeparate
 3319|       |             */
 3320|      8|        case PHOTOMETRIC_RGB:
  ------------------
  |  |  223|      8|#define PHOTOMETRIC_RGB 2                  /* RGB color model */
  ------------------
  |  Branch (3320:9): [True: 0, False: 60]
  ------------------
 3321|      8|            switch (img->bitspersample)
 3322|      8|            {
 3323|      6|                case 8:
  ------------------
  |  Branch (3323:17): [True: 6, False: 2]
  ------------------
 3324|      6|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
  ------------------
  |  |  331|      6|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3324:25): [True: 0, False: 6]
  ------------------
 3325|      0|                        img->put.separate = putRGBAAseparate8bittile;
 3326|      6|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|      6|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3326:30): [True: 5, False: 1]
  ------------------
 3327|      5|                    {
 3328|      5|                        if (BuildMapUaToAa(img))
  ------------------
  |  Branch (3328:29): [True: 5, False: 0]
  ------------------
 3329|      5|                            img->put.separate = putRGBUAseparate8bittile;
 3330|      5|                    }
 3331|      1|                    else
 3332|      1|                        img->put.separate = putRGBseparate8bittile;
 3333|      6|                    break;
 3334|      2|                case 16:
  ------------------
  |  Branch (3334:17): [True: 2, False: 6]
  ------------------
 3335|      2|                    if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
  ------------------
  |  |  331|      2|#define EXTRASAMPLE_ASSOCALPHA 1           /* !associated alpha data */
  ------------------
  |  Branch (3335:25): [True: 0, False: 2]
  ------------------
 3336|      0|                    {
 3337|      0|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3337:29): [True: 0, False: 0]
  ------------------
 3338|      0|                            img->put.separate = putRGBAAseparate16bittile;
 3339|      0|                    }
 3340|      2|                    else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
  ------------------
  |  |  332|      2|#define EXTRASAMPLE_UNASSALPHA 2           /* !unassociated alpha data */
  ------------------
  |  Branch (3340:30): [True: 2, False: 0]
  ------------------
 3341|      2|                    {
 3342|      2|                        if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
  ------------------
  |  Branch (3342:29): [True: 2, False: 0]
  |  Branch (3342:59): [True: 2, False: 0]
  ------------------
 3343|      2|                            img->put.separate = putRGBUAseparate16bittile;
 3344|      2|                    }
 3345|      0|                    else
 3346|      0|                    {
 3347|      0|                        if (BuildMapBitdepth16To8(img))
  ------------------
  |  Branch (3347:29): [True: 0, False: 0]
  ------------------
 3348|      0|                            img->put.separate = putRGBseparate16bittile;
 3349|      0|                    }
 3350|      2|                    break;
 3351|      0|                default:
  ------------------
  |  Branch (3351:17): [True: 0, False: 8]
  ------------------
 3352|      0|                    break;
 3353|      8|            }
 3354|      8|            break;
 3355|      8|        case PHOTOMETRIC_SEPARATED:
  ------------------
  |  |  226|      1|#define PHOTOMETRIC_SEPARATED 5            /* !color separations */
  ------------------
  |  Branch (3355:9): [True: 1, False: 59]
  ------------------
 3356|      1|            if (img->bitspersample == 8 && img->samplesperpixel == 4)
  ------------------
  |  Branch (3356:17): [True: 1, False: 0]
  |  Branch (3356:44): [True: 1, False: 0]
  ------------------
 3357|      1|            {
 3358|       |                /* Not alpha, but seems like the only way to get 4th band */
 3359|      1|                img->alpha = 1;
 3360|      1|                img->put.separate = putCMYKseparate8bittile;
 3361|      1|            }
 3362|      1|            break;
 3363|     38|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|     38|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (3363:9): [True: 38, False: 22]
  ------------------
 3364|     38|            if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
  ------------------
  |  Branch (3364:17): [True: 38, False: 0]
  |  Branch (3364:46): [True: 38, False: 0]
  ------------------
 3365|     38|            {
 3366|     38|                if (initYCbCrConversion(img) != 0)
  ------------------
  |  Branch (3366:21): [True: 37, False: 1]
  ------------------
 3367|     37|                {
 3368|     37|                    uint16_t hs, vs;
 3369|     37|                    TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|     37|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
 3370|     37|                                          &hs, &vs);
 3371|     37|                    switch ((hs << 4) | vs)
 3372|     37|                    {
 3373|     19|                        case 0x11:
  ------------------
  |  Branch (3373:25): [True: 19, False: 18]
  ------------------
 3374|     19|                            img->put.separate = putseparate8bitYCbCr11tile;
 3375|     19|                            break;
 3376|       |                            /* TODO: add other cases here */
 3377|     18|                        default:
  ------------------
  |  Branch (3377:25): [True: 18, False: 19]
  ------------------
 3378|     18|                            break;
 3379|     37|                    }
 3380|     37|                }
 3381|     38|            }
 3382|     38|            break;
 3383|     38|        default:
  ------------------
  |  Branch (3383:9): [True: 13, False: 47]
  ------------------
 3384|     13|            break;
 3385|     60|    }
 3386|     60|    return ((img->get != NULL) && (img->put.separate != NULL));
  ------------------
  |  Branch (3386:13): [True: 60, False: 0]
  |  Branch (3386:35): [True: 28, False: 32]
  ------------------
 3387|     60|}
tif_getimage.c:gtTileSeparate:
  905|     27|{
  906|     27|    TIFF *tif = img->tif;
  907|     27|    tileSeparateRoutine put = img->put.separate;
  908|     27|    uint32_t col, row, y, rowstoread;
  909|     27|    tmsize_t pos;
  910|     27|    uint32_t tw, th;
  911|     27|    unsigned char *buf = NULL;
  912|     27|    unsigned char *p0 = NULL;
  913|     27|    unsigned char *p1 = NULL;
  914|     27|    unsigned char *p2 = NULL;
  915|     27|    unsigned char *pa = NULL;
  916|     27|    tmsize_t tilesize;
  917|     27|    tmsize_t bufsize;
  918|     27|    int32_t fromskew, toskew;
  919|     27|    int alpha = img->alpha;
  920|     27|    uint32_t nrow;
  921|     27|    int ret = 1, flip;
  922|     27|    uint16_t colorchannels;
  923|     27|    uint32_t this_tw, tocol;
  924|     27|    int32_t this_toskew, leftmost_toskew;
  925|     27|    int32_t leftmost_fromskew;
  926|     27|    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|     27|    uint32_t wmin;
  931|     27|    if (0 <= img->col_offset && (uint32_t)img->col_offset < img->width)
  ------------------
  |  Branch (931:9): [True: 27, False: 0]
  |  Branch (931:33): [True: 27, False: 0]
  ------------------
  932|     27|    {
  933|     27|        wmin = TIFFmin(w, img->width - (uint32_t)img->col_offset);
  ------------------
  |  |  337|     27|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 27]
  |  |  ------------------
  ------------------
  934|     27|    }
  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|     27|    tilesize = TIFFTileSize(tif);
  945|     27|    bufsize =
  946|     27|        _TIFFMultiplySSize(tif, alpha ? 4 : 3, tilesize, "gtTileSeparate");
  ------------------
  |  Branch (946:33): [True: 7, False: 20]
  ------------------
  947|     27|    if (bufsize == 0)
  ------------------
  |  Branch (947:9): [True: 0, False: 27]
  ------------------
  948|      0|    {
  949|      0|        return (0);
  950|      0|    }
  951|       |
  952|     27|    TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
  ------------------
  |  |  311|     27|#define TIFFTAG_TILEWIDTH 322              /* !tile width in pixels */
  ------------------
  953|     27|    TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
  ------------------
  |  |  312|     27|#define TIFFTAG_TILELENGTH 323             /* !tile height in pixels */
  ------------------
  954|       |
  955|     27|    flip = setorientation(img);
  956|     27|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|     27|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (956:9): [True: 0, False: 27]
  ------------------
  957|      0|    {
  958|      0|        if (((int64_t)tw + w) > INT_MAX)
  ------------------
  |  Branch (958:13): [True: 0, False: 0]
  ------------------
  959|      0|        {
  960|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  961|      0|                          "unsupported tile size (too wide)");
  962|      0|            return (0);
  963|      0|        }
  964|      0|        y = h - 1;
  965|      0|        toskew = -(int32_t)(tw + w);
  966|      0|    }
  967|     27|    else
  968|     27|    {
  969|     27|        if (tw > ((int64_t)INT_MAX + w) || w > ((int64_t)INT_MAX + tw))
  ------------------
  |  Branch (969:13): [True: 0, False: 27]
  |  Branch (969:44): [True: 0, False: 27]
  ------------------
  970|      0|        {
  971|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
  972|      0|                          "unsupported tile size (too wide)");
  973|      0|            return (0);
  974|      0|        }
  975|     27|        y = 0;
  976|     27|        toskew = -(int32_t)(tw - w);
  977|     27|    }
  978|       |
  979|     27|    switch (img->photometric)
  980|     27|    {
  981|      0|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      0|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (981:9): [True: 0, False: 27]
  ------------------
  982|      8|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|      8|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (982:9): [True: 8, False: 19]
  ------------------
  983|      8|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|      8|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (983:9): [True: 0, False: 27]
  ------------------
  984|      8|            colorchannels = 1;
  985|      8|            break;
  986|       |
  987|     19|        default:
  ------------------
  |  Branch (987:9): [True: 19, False: 8]
  ------------------
  988|     19|            colorchannels = 3;
  989|     19|            break;
  990|     27|    }
  991|       |
  992|     27|    if (tw == 0 || th == 0)
  ------------------
  |  Branch (992:9): [True: 0, False: 27]
  |  Branch (992:20): [True: 0, False: 27]
  ------------------
  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|     27|    leftmost_fromskew = (int32_t)((uint32_t)img->col_offset % tw);
 1002|     27|    leftmost_tw = (uint32_t)((int32_t)tw - leftmost_fromskew);
 1003|     27|    int64_t skew_i64 = (int64_t)toskew + (int64_t)(int32_t)leftmost_fromskew;
 1004|     27|    if (skew_i64 > INT_MAX || skew_i64 < INT_MIN)
  ------------------
  |  Branch (1004:9): [True: 0, False: 27]
  |  Branch (1004:31): [True: 0, False: 27]
  ------------------
 1005|      0|    {
 1006|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "%s %" PRId64, "Invalid skew",
 1007|      0|                      skew_i64);
 1008|      0|        return (0);
 1009|      0|    }
 1010|     27|    leftmost_toskew = (int32_t)skew_i64;
 1011|     54|    for (row = 0; ret != 0 && row < h; row += nrow)
  ------------------
  |  Branch (1011:19): [True: 45, False: 9]
  |  Branch (1011:31): [True: 27, False: 18]
  ------------------
 1012|     27|    {
 1013|     27|        rowstoread = th - ((uint32_t)row + (uint32_t)img->row_offset) % th;
 1014|     27|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1014:17): [True: 24, False: 3]
  ------------------
 1015|     27|        fromskew = leftmost_fromskew;
 1016|     27|        this_tw = leftmost_tw;
 1017|     27|        this_toskew = leftmost_toskew;
 1018|     27|        tocol = 0;
 1019|     27|        col = (uint32_t)img->col_offset;
 1020|       |        /* wmin: only write imagewidth if raster is bigger. */
 1021|    382|        while (tocol < wmin)
  ------------------
  |  Branch (1021:16): [True: 364, False: 18]
  ------------------
 1022|    364|        {
 1023|    364|            if (buf == NULL)
  ------------------
  |  Branch (1023:17): [True: 27, False: 337]
  ------------------
 1024|     27|            {
 1025|     27|                if (_TIFFReadTileAndAllocBuffer(
  ------------------
  |  Branch (1025:21): [True: 9, False: 18]
  ------------------
 1026|     27|                        tif, (void **)&buf, bufsize, col,
 1027|     27|                        (uint32_t)((int32_t)row + img->row_offset), 0,
 1028|     27|                        0) == (tmsize_t)(-1) &&
 1029|      9|                    (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1029:22): [True: 9, False: 0]
  |  Branch (1029:37): [True: 0, False: 0]
  ------------------
 1030|      9|                {
 1031|      9|                    ret = 0;
 1032|      9|                    break;
 1033|      9|                }
 1034|     18|                p0 = buf;
 1035|     18|                if (colorchannels == 1)
  ------------------
  |  Branch (1035:21): [True: 2, False: 16]
  ------------------
 1036|      2|                {
 1037|      2|                    p2 = p1 = p0;
 1038|      2|                    pa = (alpha ? (p0 + 3 * tilesize) : NULL);
  ------------------
  |  Branch (1038:27): [True: 2, False: 0]
  ------------------
 1039|      2|                }
 1040|     16|                else
 1041|     16|                {
 1042|     16|                    p1 = p0 + tilesize;
 1043|     16|                    p2 = p1 + tilesize;
 1044|     16|                    pa = (alpha ? (p2 + tilesize) : NULL);
  ------------------
  |  Branch (1044:27): [True: 0, False: 16]
  ------------------
 1045|     16|                }
 1046|     18|            }
 1047|    337|            else if (TIFFReadTile(tif, p0, col,
  ------------------
  |  Branch (1047:22): [True: 0, False: 337]
  ------------------
 1048|    337|                                  (uint32_t)((int32_t)row + img->row_offset), 0,
 1049|    337|                                  0) == (tmsize_t)(-1) &&
 1050|      0|                     img->stoponerr)
  ------------------
  |  Branch (1050:22): [True: 0, False: 0]
  ------------------
 1051|      0|            {
 1052|      0|                ret = 0;
 1053|      0|                break;
 1054|      0|            }
 1055|    355|            if (colorchannels > 1 &&
  ------------------
  |  Branch (1055:17): [True: 165, False: 190]
  ------------------
 1056|    165|                TIFFReadTile(tif, p1, col,
  ------------------
  |  Branch (1056:17): [True: 6, False: 159]
  ------------------
 1057|    165|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1058|    165|                             (uint16_t)1) == (tmsize_t)(-1) &&
 1059|      6|                img->stoponerr)
  ------------------
  |  Branch (1059:17): [True: 0, False: 6]
  ------------------
 1060|      0|            {
 1061|      0|                ret = 0;
 1062|      0|                break;
 1063|      0|            }
 1064|    355|            if (colorchannels > 1 &&
  ------------------
  |  Branch (1064:17): [True: 165, False: 190]
  ------------------
 1065|    165|                TIFFReadTile(tif, p2, col,
  ------------------
  |  Branch (1065:17): [True: 105, False: 60]
  ------------------
 1066|    165|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1067|    165|                             (uint16_t)2) == (tmsize_t)(-1) &&
 1068|    105|                img->stoponerr)
  ------------------
  |  Branch (1068:17): [True: 0, False: 105]
  ------------------
 1069|      0|            {
 1070|      0|                ret = 0;
 1071|      0|                break;
 1072|      0|            }
 1073|    355|            if (alpha &&
  ------------------
  |  Branch (1073:17): [True: 190, False: 165]
  ------------------
 1074|    190|                TIFFReadTile(tif, pa, col,
  ------------------
  |  Branch (1074:17): [True: 0, False: 190]
  ------------------
 1075|    190|                             (uint32_t)((int32_t)row + img->row_offset), 0,
 1076|    190|                             (uint16_t)colorchannels) == (tmsize_t)(-1) &&
 1077|      0|                img->stoponerr)
  ------------------
  |  Branch (1077:17): [True: 0, False: 0]
  ------------------
 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|    355|            pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) % th) *
 1086|    355|                      TIFFTileRowSize(tif) +
 1087|    355|                  (tmsize_t)fromskew;
 1088|    355|            if (tocol + this_tw > wmin)
  ------------------
  |  Branch (1088:17): [True: 8, False: 347]
  ------------------
 1089|      8|            {
 1090|       |                /*
 1091|       |                 * Rightmost tile is clipped on right side.
 1092|       |                 */
 1093|      8|                fromskew = (int32_t)(tw - (wmin - tocol));
 1094|      8|                this_tw = (uint32_t)((int32_t)tw - fromskew);
 1095|      8|                this_toskew = (int32_t)(toskew + (int32_t)(uint32_t)fromskew);
 1096|      8|            }
 1097|    355|            tmsize_t roffset = (tmsize_t)y * w + tocol;
 1098|    355|            (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
 1099|    355|                   this_toskew, p0 + pos, p1 + pos, p2 + pos,
 1100|    355|                   (alpha ? (pa + pos) : NULL));
  ------------------
  |  Branch (1100:21): [True: 190, False: 165]
  ------------------
 1101|    355|            tocol += this_tw;
 1102|    355|            col += this_tw;
 1103|       |            /*
 1104|       |             * After the leftmost tile, tiles are no longer clipped on left
 1105|       |             * side.
 1106|       |             */
 1107|    355|            fromskew = 0;
 1108|    355|            this_tw = tw;
 1109|    355|            this_toskew = toskew;
 1110|    355|        }
 1111|       |
 1112|     27|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|     27|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1112:25): [True: 0, False: 27]
  ------------------
 1113|     27|                                                 : (int32_t)nrow);
 1114|     27|    }
 1115|       |
 1116|     27|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|     27|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1116:9): [True: 0, False: 27]
  ------------------
 1117|      0|    {
 1118|      0|        uint32_t line;
 1119|       |
 1120|      0|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1120:24): [True: 0, False: 0]
  ------------------
 1121|      0|        {
 1122|      0|            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|      0|            uint32_t *right = left + wmin - 1;
 1126|       |
 1127|      0|            while (left < right)
  ------------------
  |  Branch (1127:20): [True: 0, False: 0]
  ------------------
 1128|      0|            {
 1129|      0|                uint32_t temp = *left;
 1130|      0|                *left = *right;
 1131|      0|                *right = temp;
 1132|      0|                left++;
 1133|      0|                right--;
 1134|      0|            }
 1135|      0|        }
 1136|      0|    }
 1137|       |
 1138|     27|    _TIFFfreeExt(img->tif, buf);
 1139|     27|    return (ret);
 1140|     27|}
tif_getimage.c:gtStripSeparate:
 1302|      1|{
 1303|      1|    TIFF *tif = img->tif;
 1304|      1|    tileSeparateRoutine put = img->put.separate;
 1305|      1|    unsigned char *buf = NULL;
 1306|      1|    unsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL;
 1307|      1|    uint32_t row, y, nrow, rowstoread;
 1308|      1|    tmsize_t pos;
 1309|      1|    tmsize_t scanline;
 1310|      1|    uint32_t rowsperstrip, offset_row;
 1311|      1|    uint32_t imagewidth = img->width;
 1312|      1|    tmsize_t stripsize;
 1313|      1|    tmsize_t bufsize;
 1314|      1|    int32_t fromskew, toskew;
 1315|      1|    int alpha = img->alpha;
 1316|      1|    int ret = 1, flip;
 1317|      1|    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|      1|    uint32_t wmin;
 1322|      1|    if (0 <= img->col_offset && (uint32_t)img->col_offset < imagewidth)
  ------------------
  |  Branch (1322:9): [True: 1, False: 0]
  |  Branch (1322:33): [True: 1, False: 0]
  ------------------
 1323|      1|    {
 1324|      1|        wmin = TIFFmin(w, imagewidth - (uint32_t)img->col_offset);
  ------------------
  |  |  337|      1|#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
  |  |  ------------------
  |  |  |  Branch (337:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1325|      1|    }
 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|      1|    stripsize = TIFFStripSize(tif);
 1336|      1|    bufsize =
 1337|      1|        _TIFFMultiplySSize(tif, alpha ? 4 : 3, stripsize, "gtStripSeparate");
  ------------------
  |  Branch (1337:33): [True: 1, False: 0]
  ------------------
 1338|      1|    if (bufsize == 0)
  ------------------
  |  Branch (1338:9): [True: 0, False: 1]
  ------------------
 1339|      0|    {
 1340|      0|        return (0);
 1341|      0|    }
 1342|       |
 1343|      1|    flip = setorientation(img);
 1344|      1|    if (flip & FLIP_VERTICALLY)
  ------------------
  |  |   50|      1|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1344:9): [True: 1, False: 0]
  ------------------
 1345|      1|    {
 1346|      1|        if (w > INT_MAX / 2)
  ------------------
  |  Branch (1346:13): [True: 0, False: 1]
  ------------------
 1347|      0|        {
 1348|      0|            TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
 1349|      0|            return (0);
 1350|      0|        }
 1351|      1|        y = h - 1;
 1352|       |        /* Skew back to the raster row before the currently written row
 1353|       |         * -> one raster width plus one image width. */
 1354|      1|        toskew = -(int32_t)(w + wmin);
 1355|      1|    }
 1356|      0|    else
 1357|      0|    {
 1358|      0|        y = 0;
 1359|       |        /* Skew forward to the end of the raster width of the row currently
 1360|       |         * written. */
 1361|      0|        toskew = (int32_t)(w - wmin);
 1362|      0|    }
 1363|       |
 1364|      1|    switch (img->photometric)
 1365|      1|    {
 1366|      0|        case PHOTOMETRIC_MINISWHITE:
  ------------------
  |  |  221|      0|#define PHOTOMETRIC_MINISWHITE 0           /* min value is white */
  ------------------
  |  Branch (1366:9): [True: 0, False: 1]
  ------------------
 1367|      0|        case PHOTOMETRIC_MINISBLACK:
  ------------------
  |  |  222|      0|#define PHOTOMETRIC_MINISBLACK 1           /* min value is black */
  ------------------
  |  Branch (1367:9): [True: 0, False: 1]
  ------------------
 1368|      0|        case PHOTOMETRIC_PALETTE:
  ------------------
  |  |  224|      0|#define PHOTOMETRIC_PALETTE 3              /* color map indexed */
  ------------------
  |  Branch (1368:9): [True: 0, False: 1]
  ------------------
 1369|      0|            colorchannels = 1;
 1370|      0|            break;
 1371|       |
 1372|      1|        default:
  ------------------
  |  Branch (1372:9): [True: 1, False: 0]
  ------------------
 1373|      1|            colorchannels = 3;
 1374|      1|            break;
 1375|      1|    }
 1376|       |
 1377|      1|    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
  ------------------
  |  |  258|      1|#define TIFFTAG_ROWSPERSTRIP 278           /* rows per strip of data */
  ------------------
 1378|      1|    if (rowsperstrip == 0)
  ------------------
  |  Branch (1378:9): [True: 0, False: 1]
  ------------------
 1379|      0|    {
 1380|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
 1381|      0|        return (0);
 1382|      0|    }
 1383|       |
 1384|      1|    scanline = TIFFScanlineSize(tif);
 1385|      1|    fromskew = (int32_t)(w < imagewidth ? imagewidth - w : 0);
  ------------------
  |  Branch (1385:26): [True: 0, False: 1]
  ------------------
 1386|      2|    for (row = 0; row < h; row += nrow)
  ------------------
  |  Branch (1386:19): [True: 1, False: 1]
  ------------------
 1387|      1|    {
 1388|      1|        uint32_t temp;
 1389|      1|        rowstoread =
 1390|      1|            rowsperstrip -
 1391|      1|            ((uint32_t)((int32_t)row + img->row_offset) % rowsperstrip);
 1392|      1|        nrow = (row + rowstoread > h ? h - row : rowstoread);
  ------------------
  |  Branch (1392:17): [True: 1, False: 0]
  ------------------
 1393|      1|        offset_row = (uint32_t)((int32_t)row + img->row_offset);
 1394|      1|        temp = (uint32_t)((int32_t)row + img->row_offset) % rowsperstrip + nrow;
 1395|      1|        if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
  ------------------
  |  |   68|      1|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (1395:13): [True: 1, False: 0]
  |  Branch (1395:29): [True: 0, False: 1]
  ------------------
 1396|      0|        {
 1397|      0|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1398|      0|                          "Integer overflow in gtStripSeparate");
 1399|      0|            return 0;
 1400|      0|        }
 1401|      1|        if (buf == NULL)
  ------------------
  |  Branch (1401:13): [True: 1, False: 0]
  ------------------
 1402|      1|        {
 1403|      1|            if (_TIFFReadEncodedStripAndAllocBuffer(
  ------------------
  |  Branch (1403:17): [True: 1, False: 0]
  ------------------
 1404|      1|                    tif, TIFFComputeStrip(tif, offset_row, 0), (void **)&buf,
 1405|      1|                    bufsize, temp * scanline) == (tmsize_t)(-1) &&
 1406|      1|                (buf == NULL || img->stoponerr))
  ------------------
  |  Branch (1406:18): [True: 0, False: 1]
  |  Branch (1406:33): [True: 0, False: 1]
  ------------------
 1407|      0|            {
 1408|      0|                ret = 0;
 1409|      0|                break;
 1410|      0|            }
 1411|      1|            p0 = buf;
 1412|      1|            if (colorchannels == 1)
  ------------------
  |  Branch (1412:17): [True: 0, False: 1]
  ------------------
 1413|      0|            {
 1414|      0|                p2 = p1 = p0;
 1415|      0|                pa = (alpha ? (p0 + 3 * stripsize) : NULL);
  ------------------
  |  Branch (1415:23): [True: 0, False: 0]
  ------------------
 1416|      0|            }
 1417|      1|            else
 1418|      1|            {
 1419|      1|                p1 = p0 + stripsize;
 1420|      1|                p2 = p1 + stripsize;
 1421|      1|                pa = (alpha ? (p2 + stripsize) : NULL);
  ------------------
  |  Branch (1421:23): [True: 1, False: 0]
  ------------------
 1422|      1|            }
 1423|      1|        }
 1424|      0|        else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),
  ------------------
  |  Branch (1424:18): [True: 0, False: 0]
  ------------------
 1425|      0|                                      p0, temp * scanline) == (tmsize_t)(-1) &&
 1426|      0|                 img->stoponerr)
  ------------------
  |  Branch (1426:18): [True: 0, False: 0]
  ------------------
 1427|      0|        {
 1428|      0|            ret = 0;
 1429|      0|            break;
 1430|      0|        }
 1431|      1|        if (colorchannels > 1 &&
  ------------------
  |  Branch (1431:13): [True: 1, False: 0]
  ------------------
 1432|      1|            TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), p1,
  ------------------
  |  Branch (1432:13): [True: 0, False: 1]
  ------------------
 1433|      1|                                 temp * scanline) == (tmsize_t)(-1) &&
 1434|      0|            img->stoponerr)
  ------------------
  |  Branch (1434:13): [True: 0, False: 0]
  ------------------
 1435|      0|        {
 1436|      0|            ret = 0;
 1437|      0|            break;
 1438|      0|        }
 1439|      1|        if (colorchannels > 1 &&
  ------------------
  |  Branch (1439:13): [True: 1, False: 0]
  ------------------
 1440|      1|            TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), p2,
  ------------------
  |  Branch (1440:13): [True: 0, False: 1]
  ------------------
 1441|      1|                                 temp * scanline) == (tmsize_t)(-1) &&
 1442|      0|            img->stoponerr)
  ------------------
  |  Branch (1442:13): [True: 0, False: 0]
  ------------------
 1443|      0|        {
 1444|      0|            ret = 0;
 1445|      0|            break;
 1446|      0|        }
 1447|      1|        if (alpha)
  ------------------
  |  Branch (1447:13): [True: 1, False: 0]
  ------------------
 1448|      1|        {
 1449|      1|            if (TIFFReadEncodedStrip(
  ------------------
  |  Branch (1449:17): [True: 0, False: 1]
  ------------------
 1450|      1|                    tif, TIFFComputeStrip(tif, offset_row, colorchannels), pa,
 1451|      1|                    temp * scanline) == (tmsize_t)(-1) &&
 1452|      0|                img->stoponerr)
  ------------------
  |  Branch (1452:17): [True: 0, False: 0]
  ------------------
 1453|      0|            {
 1454|      0|                ret = 0;
 1455|      0|                break;
 1456|      0|            }
 1457|      1|        }
 1458|       |
 1459|       |        /* For SEPARATE the pos-offset is per sample and should not be
 1460|       |         * multiplied by img->samplesperpixel. */
 1461|      1|        pos = (tmsize_t)((uint32_t)((int32_t)row + img->row_offset) %
 1462|      1|                         rowsperstrip) *
 1463|      1|                  scanline +
 1464|      1|              (tmsize_t)img->col_offset;
 1465|      1|        tmsize_t roffset = (tmsize_t)y * w;
 1466|      1|        (*put)(img, raster + roffset, 0, y, wmin, nrow, fromskew, toskew,
 1467|      1|               p0 + pos, p1 + pos, p2 + pos, (alpha ? (pa + pos) : NULL));
  ------------------
  |  Branch (1467:47): [True: 1, False: 0]
  ------------------
 1468|      1|        y += (uint32_t)((flip & FLIP_VERTICALLY) ? -(int32_t)nrow
  ------------------
  |  |   50|      1|#define FLIP_VERTICALLY 0x01
  ------------------
  |  Branch (1468:25): [True: 1, False: 0]
  ------------------
 1469|      1|                                                 : (int32_t)nrow);
 1470|      1|    }
 1471|       |
 1472|      1|    if (flip & FLIP_HORIZONTALLY)
  ------------------
  |  |   51|      1|#define FLIP_HORIZONTALLY 0x02
  ------------------
  |  Branch (1472:9): [True: 1, False: 0]
  ------------------
 1473|      1|    {
 1474|      1|        uint32_t line;
 1475|       |
 1476|      3|        for (line = 0; line < h; line++)
  ------------------
  |  Branch (1476:24): [True: 2, False: 1]
  ------------------
 1477|      2|        {
 1478|      2|            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|      2|            uint32_t *right = left + wmin - 1;
 1482|       |
 1483|  65.5k|            while (left < right)
  ------------------
  |  Branch (1483:20): [True: 65.5k, False: 2]
  ------------------
 1484|  65.5k|            {
 1485|  65.5k|                uint32_t temp = *left;
 1486|  65.5k|                *left = *right;
 1487|  65.5k|                *right = temp;
 1488|  65.5k|                left++;
 1489|  65.5k|                right--;
 1490|  65.5k|            }
 1491|      2|        }
 1492|      1|    }
 1493|       |
 1494|      1|    _TIFFfreeExt(img->tif, buf);
 1495|      1|    return (ret);
 1496|      1|}
tif_getimage.c:putRGBUAseparate16bittile:
 2173|    190|{
 2174|    190|    uint16_t *wr = (uint16_t *)r;
 2175|    190|    uint16_t *wg = (uint16_t *)g;
 2176|    190|    uint16_t *wb = (uint16_t *)b;
 2177|    190|    uint16_t *wa = (uint16_t *)a;
 2178|    190|    (void)img;
 2179|    190|    (void)y;
 2180|    570|    for (; h > 0; --h)
  ------------------
  |  Branch (2180:12): [True: 380, False: 190]
  ------------------
 2181|    380|    {
 2182|    380|        uint32_t r2, g2, b2, a2;
 2183|    380|        uint8_t *m;
 2184|  63.8k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2184:21): [True: 63.5k, False: 380]
  ------------------
 2185|  63.5k|        {
 2186|  63.5k|            a2 = img->Bitdepth16To8[*wa++];
 2187|  63.5k|            m = img->UaToAa + ((size_t)a2 << 8);
 2188|  63.5k|            r2 = m[img->Bitdepth16To8[*wr++]];
 2189|  63.5k|            g2 = m[img->Bitdepth16To8[*wg++]];
 2190|  63.5k|            b2 = m[img->Bitdepth16To8[*wb++]];
 2191|  63.5k|            *cp++ = PACK4(r2, g2, b2, a2);
  ------------------
  |  | 1614|  63.5k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|  63.5k|     ((uint32_t)(a) << 24))
  ------------------
 2192|  63.5k|        }
 2193|    380|        SKEW4(wr, wg, wb, wa, fromskew);
  ------------------
  |  | 1603|    380|    {                                                                          \
  |  | 1604|    380|        r += skew;                                                             \
  |  | 1605|    380|        g += skew;                                                             \
  |  | 1606|    380|        b += skew;                                                             \
  |  | 1607|    380|        a += skew;                                                             \
  |  | 1608|    380|    }
  ------------------
 2194|    380|        cp += toskew;
 2195|    380|    }
 2196|    190|}
tif_getimage.c:putCMYKseparate8bittile:
 2083|      1|{
 2084|      1|    (void)img;
 2085|      1|    (void)y;
 2086|      3|    for (; h > 0; --h)
  ------------------
  |  Branch (2086:12): [True: 2, False: 1]
  ------------------
 2087|      2|    {
 2088|      2|        unsigned int rv, gv, bv, kv;
 2089|   131k|        for (x = w; x > 0; --x)
  ------------------
  |  Branch (2089:21): [True: 131k, False: 2]
  ------------------
 2090|   131k|        {
 2091|   131k|            kv = 255U - *a++;
 2092|   131k|            rv = (kv * (255U - *r++)) / 255U;
 2093|   131k|            gv = (kv * (255U - *g++)) / 255U;
 2094|   131k|            bv = (kv * (255U - *b++)) / 255U;
 2095|   131k|            *cp++ = PACK4(rv, gv, bv, 255);
  ------------------
  |  | 1614|   131k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) |            \
  |  | 1615|   131k|     ((uint32_t)(a) << 24))
  ------------------
 2096|   131k|        }
 2097|      2|        SKEW4(r, g, b, a, fromskew);
  ------------------
  |  | 1603|      2|    {                                                                          \
  |  | 1604|      2|        r += skew;                                                             \
  |  | 1605|      2|        g += skew;                                                             \
  |  | 1606|      2|        b += skew;                                                             \
  |  | 1607|      2|        a += skew;                                                             \
  |  | 1608|      2|    }
  ------------------
 2098|      2|        cp += toskew;
 2099|      2|    }
 2100|      1|}
tif_getimage.c:putseparate8bitYCbCr11tile:
 2738|    165|{
 2739|    165|    (void)y;
 2740|    165|    (void)a;
 2741|       |    /* TODO: naming of input vars is still off, change obfuscating declaration
 2742|       |     * inside define, or resolve obfuscation */
 2743|  5.44k|    for (; h > 0; --h)
  ------------------
  |  Branch (2743:12): [True: 5.28k, False: 165]
  ------------------
 2744|  5.28k|    {
 2745|  5.28k|        x = w;
 2746|  5.28k|        do
 2747|  36.0k|        {
 2748|  36.0k|            uint32_t dr, dg, db;
 2749|  36.0k|            TIFFYCbCrtoRGB(img->ycbcr, *r++, *g++, *b++, &dr, &dg, &db);
 2750|  36.0k|            *cp++ = PACK(dr, dg, db);
  ------------------
  |  | 1612|  36.0k|    ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
  |  |  ------------------
  |  |  |  | 1610|  36.0k|#define A1 (((uint32_t)0xffL) << 24)
  |  |  ------------------
  ------------------
 2751|  36.0k|        } while (--x);
  ------------------
  |  Branch (2751:18): [True: 30.8k, False: 5.28k]
  ------------------
 2752|  5.28k|        SKEW(r, g, b, fromskew);
  ------------------
  |  | 1597|  5.28k|    {                                                                          \
  |  | 1598|  5.28k|        r += skew;                                                             \
  |  | 1599|  5.28k|        g += skew;                                                             \
  |  | 1600|  5.28k|        b += skew;                                                             \
  |  | 1601|  5.28k|    }
  ------------------
 2753|  5.28k|        cp += toskew;
 2754|  5.28k|    }
 2755|    165|}

TIFFHashSetNew:
  141|    796|{
  142|    796|    TIFFHashSet *set = (TIFFHashSet *)malloc(sizeof(TIFFHashSet));
  143|    796|    if (set == NULL)
  ------------------
  |  Branch (143:9): [True: 0, False: 796]
  ------------------
  144|      0|        return NULL;
  145|    796|    set->fnHashFunc = fnHashFunc ? fnHashFunc : TIFFHashSetHashPointer;
  ------------------
  |  Branch (145:23): [True: 796, False: 0]
  ------------------
  146|    796|    set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer;
  ------------------
  |  Branch (146:24): [True: 796, False: 0]
  ------------------
  147|    796|    set->fnFreeEltFunc = fnFreeEltFunc;
  148|    796|    set->nSize = 0;
  149|    796|    set->tabList = (TIFFList **)(calloc(53, sizeof(TIFFList *)));
  150|    796|    if (set->tabList == NULL)
  ------------------
  |  Branch (150:9): [True: 0, False: 796]
  ------------------
  151|      0|    {
  152|      0|        free(set);
  153|      0|        return NULL;
  154|      0|    }
  155|    796|    set->nIndiceAllocatedSize = 0;
  156|    796|    set->nAllocatedSize = 53;
  157|    796|    set->psRecyclingList = NULL;
  158|    796|    set->nRecyclingListSize = 0;
  159|    796|    set->bRehash = false;
  160|       |#ifdef HASH_DEBUG
  161|       |    set->nCollisions = 0;
  162|       |#endif
  163|    796|    return set;
  164|    796|}
TIFFHashSetSize:
  181|    961|{
  182|    961|    assert(set != NULL);
  ------------------
  |  Branch (182:5): [True: 0, False: 961]
  |  Branch (182:5): [True: 961, False: 0]
  ------------------
  183|    961|    return set->nSize;
  184|    961|}
TIFFHashSetDestroy:
  286|    796|{
  287|    796|    if (set)
  ------------------
  |  Branch (287:9): [True: 796, False: 0]
  ------------------
  288|    796|    {
  289|       |        TIFFHashSetClearInternal(set, true);
  290|    796|        free(set->tabList);
  291|    796|        TIFFListDestroy(set->psRecyclingList);
  292|    796|        free(set);
  293|    796|    }
  294|    796|}
TIFFHashSetInsert:
  442|  1.92k|{
  443|  1.92k|    assert(set != NULL);
  ------------------
  |  Branch (443:5): [True: 0, False: 1.92k]
  |  Branch (443:5): [True: 1.92k, False: 0]
  ------------------
  444|  1.92k|    void **pElt = TIFFHashSetFindPtr(set, elt);
  445|  1.92k|    if (pElt)
  ------------------
  |  Branch (445:9): [True: 0, False: 1.92k]
  ------------------
  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|  1.92k|    if (set->nSize >= 2 * set->nAllocatedSize / 3 ||
  ------------------
  |  Branch (454:9): [True: 0, False: 1.92k]
  ------------------
  455|  1.92k|        (set->bRehash && set->nIndiceAllocatedSize > 0 &&
  ------------------
  |  Branch (455:10): [True: 0, False: 1.92k]
  |  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|  1.92k|    const unsigned long nHashVal =
  469|  1.92k|        set->fnHashFunc(elt) % (unsigned long)set->nAllocatedSize;
  470|       |#ifdef HASH_DEBUG
  471|       |    if (set->tabList[nHashVal])
  472|       |        set->nCollisions++;
  473|       |#endif
  474|       |
  475|  1.92k|    TIFFList *new_elt = TIFFHashSetGetNewListElt(set);
  476|  1.92k|    if (new_elt == NULL)
  ------------------
  |  Branch (476:9): [True: 0, False: 1.92k]
  ------------------
  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|  1.92k|    new_elt->pData = elt;
  483|  1.92k|    new_elt->psNext = set->tabList[nHashVal];
  484|  1.92k|    set->tabList[nHashVal] = new_elt;
  485|  1.92k|    set->nSize++;
  486|       |
  487|       |    return true;
  488|  1.92k|}
TIFFHashSetLookup:
  505|  1.92k|{
  506|  1.92k|    assert(set != NULL);
  ------------------
  |  Branch (506:5): [True: 0, False: 1.92k]
  |  Branch (506:5): [True: 1.92k, False: 0]
  ------------------
  507|  1.92k|    void **pElt = TIFFHashSetFindPtr(set, elt);
  508|  1.92k|    if (pElt)
  ------------------
  |  Branch (508:9): [True: 2, False: 1.92k]
  ------------------
  509|      2|        return *pElt;
  510|       |
  511|  1.92k|    return NULL;
  512|  1.92k|}
tif_hash_set.c:TIFFHashSetClearInternal:
  227|    796|{
  228|    796|    assert(set != NULL);
  ------------------
  |  Branch (228:5): [True: 0, False: 796]
  |  Branch (228:5): [True: 796, False: 0]
  ------------------
  229|  42.9k|    for (int i = 0; i < set->nAllocatedSize; i++)
  ------------------
  |  Branch (229:21): [True: 42.1k, False: 796]
  ------------------
  230|  42.1k|    {
  231|  42.1k|        TIFFList *cur = set->tabList[i];
  232|  44.1k|        while (cur)
  ------------------
  |  Branch (232:16): [True: 1.92k, False: 42.1k]
  ------------------
  233|  1.92k|        {
  234|  1.92k|            if (set->fnFreeEltFunc)
  ------------------
  |  Branch (234:17): [True: 961, False: 961]
  ------------------
  235|    961|                set->fnFreeEltFunc(cur->pData);
  236|  1.92k|            TIFFList *psNext = cur->psNext;
  237|  1.92k|            if (bFinalize)
  ------------------
  |  Branch (237:17): [True: 1.92k, False: 0]
  ------------------
  238|  1.92k|                free(cur);
  239|      0|            else
  240|      0|                TIFFHashSetReturnListElt(set, cur);
  241|  1.92k|            cur = psNext;
  242|  1.92k|        }
  243|  42.1k|        set->tabList[i] = NULL;
  244|  42.1k|    }
  245|       |    set->bRehash = false;
  246|    796|}
tif_hash_set.c:TIFFListDestroy:
  261|    796|{
  262|    796|    TIFFList *psCurrent = psList;
  263|       |
  264|    796|    while (psCurrent)
  ------------------
  |  Branch (264:12): [True: 0, False: 796]
  ------------------
  265|      0|    {
  266|      0|        TIFFList *const psNext = psCurrent->psNext;
  267|      0|        free(psCurrent);
  268|      0|        psCurrent = psNext;
  269|      0|    }
  270|    796|}
tif_hash_set.c:TIFFHashSetFindPtr:
  410|  3.84k|{
  411|  3.84k|    const unsigned long nHashVal =
  412|  3.84k|        set->fnHashFunc(elt) % (unsigned long)set->nAllocatedSize;
  413|  3.84k|    TIFFList *cur = set->tabList[nHashVal];
  414|  3.86k|    while (cur)
  ------------------
  |  Branch (414:12): [True: 16, False: 3.84k]
  ------------------
  415|     16|    {
  416|     16|        if (set->fnEqualFunc(cur->pData, elt))
  ------------------
  |  Branch (416:13): [True: 2, False: 14]
  ------------------
  417|      2|            return &cur->pData;
  418|     14|        cur = cur->psNext;
  419|     14|    }
  420|  3.84k|    return NULL;
  421|  3.84k|}
tif_hash_set.c:TIFFHashSetGetNewListElt:
  191|  1.92k|{
  192|  1.92k|    if (set->psRecyclingList)
  ------------------
  |  Branch (192:9): [True: 0, False: 1.92k]
  ------------------
  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|  1.92k|    return (TIFFList *)malloc(sizeof(TIFFList));
  202|  1.92k|}

TIFFInitJPEG:
 3013|    370|{
 3014|    370|    JPEGState *sp;
 3015|       |
 3016|    370|    (void)scheme;
 3017|    370|    assert(scheme == COMPRESSION_JPEG);
  ------------------
  |  Branch (3017:5): [True: 0, False: 370]
  |  Branch (3017:5): [True: 370, False: 0]
  ------------------
 3018|       |
 3019|       |    /*
 3020|       |     * Merge codec-specific tag information.
 3021|       |     */
 3022|    370|    if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields)))
  ------------------
  |  |  339|    370|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (3022:9): [True: 0, False: 370]
  ------------------
 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|    370|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(JPEGState));
 3033|       |
 3034|    370|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (3034:9): [True: 0, False: 370]
  ------------------
 3035|      0|    {
 3036|      0|        TIFFErrorExtR(tif, "TIFFInitJPEG", "No space for JPEG state block");
 3037|      0|        return 0;
 3038|      0|    }
 3039|    370|    _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
 3040|       |
 3041|    370|    sp = JState(tif);
  ------------------
  |  |  208|    370|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 3042|       |    /*
 3043|       |     * Override parent get/set field methods.
 3044|       |     */
 3045|    370|    sp->otherSettings.vgetparent = tif->tif_tagmethods.vgetfield;
 3046|    370|    sp->otherSettings.vsetparent = tif->tif_tagmethods.vsetfield;
 3047|    370|    sp->otherSettings.printdir = tif->tif_tagmethods.printdir;
 3048|       |
 3049|    370|    sp->otherSettings.defsparent = tif->tif_defstripsize;
 3050|    370|    sp->otherSettings.deftparent = tif->tif_deftilesize;
 3051|       |
 3052|    370|    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|    370|    if (tif->tif_diroff == 0)
  ------------------
  |  Branch (3060:9): [True: 0, False: 370]
  ------------------
 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|    370|    return 1;
 3087|    370|}
tif_jpeg.c:TIFFjpeg_create_decompress:
  318|    229|{
  319|       |    /* initialize JPEG error handling */
  320|    229|    sp->cinfo.d.err = jpeg_std_error(&sp->err);
  321|    229|    sp->err.error_exit = TIFFjpeg_error_exit;
  322|    229|    sp->err.output_message = TIFFjpeg_output_message;
  323|       |
  324|       |    /* set client_data to avoid UMR warning from tools like Purify */
  325|    229|    sp->cinfo.d.client_data = NULL;
  326|       |
  327|       |    return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
  ------------------
  |  |  302|    229|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|    229|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    229|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (327:12): [True: 0, False: 229]
  ------------------
  328|    229|}
tif_jpeg.c:TIFFjpeg_error_exit:
  244|  1.14k|{
  245|  1.14k|    JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
  246|  1.14k|    char buffer[JMSG_LENGTH_MAX];
  247|       |
  248|  1.14k|    (*cinfo->err->format_message)(cinfo, buffer);
  249|  1.14k|    TIFFErrorExtR(sp->tif, "JPEGLib", "%s",
  250|  1.14k|                  buffer);       /* display the error message */
  251|  1.14k|    jpeg_abort(cinfo);           /* clean up libjpeg state */
  252|  1.14k|    LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
  ------------------
  |  |  143|  1.14k|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
  253|  1.14k|}
tif_jpeg.c:TIFFjpeg_output_message:
  261|    879|{
  262|    879|    char buffer[JMSG_LENGTH_MAX];
  263|       |
  264|    879|    (*cinfo->err->format_message)(cinfo, buffer);
  265|    879|    TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer);
  266|    879|}
tif_jpeg.c:TIFFjpeg_data_src:
  744|    229|{
  745|    229|    sp->cinfo.d.src = &sp->src;
  746|    229|    sp->src.init_source = std_init_source;
  747|    229|    sp->src.fill_input_buffer = std_fill_input_buffer;
  748|    229|    sp->src.skip_input_data = std_skip_input_data;
  749|    229|    sp->src.resync_to_restart = jpeg_resync_to_restart;
  750|    229|    sp->src.term_source = std_term_source;
  751|    229|    sp->src.bytes_in_buffer = 0; /* for safety */
  752|       |    sp->src.next_input_byte = NULL;
  753|    229|}
tif_jpeg.c:std_init_source:
  674|  1.18k|{
  675|  1.18k|    JPEGState *sp = (JPEGState *)cinfo;
  676|  1.18k|    TIFF *tif = sp->tif;
  677|       |
  678|  1.18k|    sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata;
  679|  1.18k|    sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
  680|  1.18k|}
tif_jpeg.c:std_fill_input_buffer:
  683|    831|{
  684|    831|    JPEGState *sp = (JPEGState *)cinfo;
  685|    831|    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|    831|    WARNMS(cinfo, JWRN_JPEG_EOF);
  712|       |    /* insert a fake EOI marker */
  713|    831|    sp->src.next_input_byte = dummy_EOI;
  714|    831|    sp->src.bytes_in_buffer = 2;
  715|    831|    return (TRUE);
  ------------------
  |  |   71|    831|#define TRUE 1
  ------------------
  716|    831|}
tif_jpeg.c:std_skip_input_data:
  719|  7.21k|{
  720|  7.21k|    JPEGState *sp = (JPEGState *)cinfo;
  721|       |
  722|  7.21k|    if (num_bytes > 0)
  ------------------
  |  Branch (722:9): [True: 7.21k, False: 0]
  ------------------
  723|  7.21k|    {
  724|  7.21k|        if ((size_t)num_bytes > sp->src.bytes_in_buffer)
  ------------------
  |  Branch (724:13): [True: 21, False: 7.19k]
  ------------------
  725|     21|        {
  726|       |            /* oops, buffer overrun */
  727|     21|            (void)std_fill_input_buffer(cinfo);
  728|     21|        }
  729|  7.19k|        else
  730|  7.19k|        {
  731|  7.19k|            sp->src.next_input_byte += (size_t)num_bytes;
  732|  7.19k|            sp->src.bytes_in_buffer -= (size_t)num_bytes;
  733|  7.19k|        }
  734|  7.21k|    }
  735|  7.21k|}
tif_jpeg.c:TIFFjpeg_read_header:
  396|  1.18k|{
  397|       |    return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image));
  ------------------
  |  |  301|  1.18k|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|  1.18k|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (397:12): [True: 1.14k, False: 37]
  ------------------
  398|  1.18k|}
tif_jpeg.c:TIFFjpeg_destroy:
  525|    229|{
  526|       |    return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm));
  ------------------
  |  |  302|    229|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|    229|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    229|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (526:12): [True: 0, False: 229]
  ------------------
  527|    229|}
tif_jpeg.c:TIFFInitJPEGCommon:
 2969|    370|{
 2970|    370|    JPEGState *sp;
 2971|       |
 2972|    370|    sp = JState(tif);
  ------------------
  |  |  208|    370|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2973|    370|    sp->tif = tif; /* back link */
 2974|       |
 2975|       |    /* Default values for codec-specific fields */
 2976|    370|    sp->otherSettings.jpegtables = NULL;
 2977|    370|    sp->otherSettings.jpegtables_length = 0;
 2978|    370|    sp->otherSettings.jpegquality = 75; /* Default IJG quality */
 2979|    370|    sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW;
  ------------------
  |  |  707|    370|#define JPEGCOLORMODE_RAW 0x0000     /* no conversion (default) */
  ------------------
 2980|    370|    sp->otherSettings.jpegtablesmode =
 2981|    370|        JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  710|    370|#define JPEGTABLESMODE_QUANT 0x0001  /* include quantization tbls */
  ------------------
                      JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  711|    370|#define JPEGTABLESMODE_HUFF 0x0002   /* include Huffman tbls */
  ------------------
 2982|    370|    sp->otherSettings.ycbcrsampling_fetched = 0;
 2983|       |
 2984|    370|    tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
 2985|    370|    tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
 2986|    370|    tif->tif_tagmethods.printdir = JPEGPrintDir;   /* hook for codec tags */
 2987|       |
 2988|       |    /*
 2989|       |     * Install codec methods.
 2990|       |     */
 2991|    370|    tif->tif_fixuptags = JPEGFixupTags;
 2992|    370|    tif->tif_setupdecode = JPEGSetupDecode;
 2993|    370|    tif->tif_predecode = JPEGPreDecode;
 2994|    370|    tif->tif_decoderow = JPEGDecode;
 2995|    370|    tif->tif_decodestrip = JPEGDecode;
 2996|    370|    tif->tif_decodetile = JPEGDecode;
 2997|    370|    tif->tif_setupencode = JPEGSetupEncode;
 2998|    370|    tif->tif_preencode = JPEGPreEncode;
 2999|    370|    tif->tif_postencode = JPEGPostEncode;
 3000|    370|    tif->tif_encoderow = JPEGEncode;
 3001|    370|    tif->tif_encodestrip = JPEGEncode;
 3002|    370|    tif->tif_encodetile = JPEGEncode;
 3003|    370|    tif->tif_getmaxcompressionratio = JPEGGetMaxCompressionRatio;
 3004|    370|    tif->tif_cleanup = JPEGCleanup;
 3005|       |
 3006|    370|    tif->tif_defstripsize = JPEGDefaultStripSize;
 3007|    370|    tif->tif_deftilesize = JPEGDefaultTileSize;
 3008|    370|    tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
  ------------------
  |  |  127|    370|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 3009|    370|    sp->cinfo_initialized = FALSE;
  ------------------
  |  |   72|    370|#define FALSE 0
  ------------------
 3010|    370|}
tif_jpeg.c:JPEGVGetField:
 2796|  3.93k|{
 2797|  3.93k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  3.93k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2798|       |
 2799|  3.93k|    assert(sp != NULL);
  ------------------
  |  Branch (2799:5): [True: 0, False: 3.93k]
  |  Branch (2799:5): [True: 3.93k, False: 0]
  ------------------
 2800|       |
 2801|  3.93k|    switch (tag)
 2802|  3.93k|    {
 2803|      0|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|      0|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2803:9): [True: 0, False: 3.93k]
  ------------------
 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: 3.93k]
  ------------------
 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: 3.93k]
  ------------------
 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: 3.93k]
  ------------------
 2814|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode;
 2815|      0|            break;
 2816|  3.93k|        default:
  ------------------
  |  Branch (2816:9): [True: 3.93k, False: 0]
  ------------------
 2817|  3.93k|            return (*sp->otherSettings.vgetparent)(tif, tag, ap);
 2818|  3.93k|    }
 2819|      0|    return (1);
 2820|  3.93k|}
tif_jpeg.c:JPEGVSetField:
 2736|  3.34k|{
 2737|  3.34k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  3.34k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2738|  3.34k|    const TIFFField *fip;
 2739|  3.34k|    uint32_t v32;
 2740|       |
 2741|  3.34k|    assert(sp != NULL);
  ------------------
  |  Branch (2741:5): [True: 0, False: 3.34k]
  |  Branch (2741:5): [True: 3.34k, False: 0]
  ------------------
 2742|       |
 2743|  3.34k|    switch (tag)
 2744|  3.34k|    {
 2745|      2|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|      2|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2745:9): [True: 2, False: 3.34k]
  ------------------
 2746|      2|            v32 = (uint32_t)va_arg(ap, uint32_t);
 2747|      2|            if (v32 == 0)
  ------------------
  |  Branch (2747:17): [True: 0, False: 2]
  ------------------
 2748|      0|            {
 2749|       |                /* XXX */
 2750|      0|                return (0);
 2751|      0|            }
 2752|      2|            _TIFFsetByteArrayExt(tif, &sp->otherSettings.jpegtables,
 2753|      2|                                 va_arg(ap, void *), v32);
 2754|      2|            sp->otherSettings.jpegtables_length = v32;
 2755|      2|            TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
  ------------------
  |  |  249|      2|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|      2|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|      2|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 2756|      2|            break;
 2757|      0|        case TIFFTAG_JPEGQUALITY:
  ------------------
  |  |  704|      0|#define TIFFTAG_JPEGQUALITY 65537    /* Compression quality level */
  ------------------
  |  Branch (2757:9): [True: 0, False: 3.34k]
  ------------------
 2758|      0|            sp->otherSettings.jpegquality = (int)va_arg(ap, int);
 2759|      0|            return (1); /* pseudo tag */
 2760|    285|        case TIFFTAG_JPEGCOLORMODE:
  ------------------
  |  |  706|    285|#define TIFFTAG_JPEGCOLORMODE 65538  /* Auto RGB<=>YCbCr convert? */
  ------------------
  |  Branch (2760:9): [True: 285, False: 3.06k]
  ------------------
 2761|    285|            sp->otherSettings.jpegcolormode = (int)va_arg(ap, int);
 2762|    285|            JPEGResetUpsampled(tif);
 2763|    285|            return (1); /* pseudo tag */
 2764|    343|        case TIFFTAG_PHOTOMETRIC:
  ------------------
  |  |  220|    343|#define TIFFTAG_PHOTOMETRIC 262            /* photometric interpretation */
  ------------------
  |  Branch (2764:9): [True: 343, False: 3.00k]
  ------------------
 2765|    343|        {
 2766|    343|            int ret_value = (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2767|    343|            JPEGResetUpsampled(tif);
 2768|    343|            return ret_value;
 2769|      2|        }
 2770|      0|        case TIFFTAG_JPEGTABLESMODE:
  ------------------
  |  |  709|      0|#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
  ------------------
  |  Branch (2770:9): [True: 0, False: 3.34k]
  ------------------
 2771|      0|            sp->otherSettings.jpegtablesmode = (int)va_arg(ap, int);
 2772|      0|            return (1); /* pseudo tag */
 2773|      0|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|      0|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (2773:9): [True: 0, False: 3.34k]
  ------------------
 2774|       |            /* mark the fact that we have a real ycbcrsubsampling! */
 2775|      0|            sp->otherSettings.ycbcrsampling_fetched = 1;
 2776|       |            /* should we be recomputing upsampling info here? */
 2777|      0|            return (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2778|  2.71k|        default:
  ------------------
  |  Branch (2778:9): [True: 2.71k, False: 630]
  ------------------
 2779|  2.71k|            return (*sp->otherSettings.vsetparent)(tif, tag, ap);
 2780|  3.34k|    }
 2781|       |
 2782|      2|    if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
  ------------------
  |  Branch (2782:9): [True: 2, False: 0]
  ------------------
 2783|      2|    {
 2784|      2|        TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|      2|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|      2|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|      2|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 2785|      2|    }
 2786|      0|    else
 2787|      0|    {
 2788|      0|        return (0);
 2789|      0|    }
 2790|       |
 2791|      2|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|      2|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 2792|      2|    return (1);
 2793|      2|}
tif_jpeg.c:JPEGResetUpsampled:
 2697|    628|{
 2698|    628|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    628|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2699|    628|    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|    628|    tif->tif_flags &= ~TIFF_UPSAMPLED;
  ------------------
  |  |  133|    628|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  ------------------
 2707|    628|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|    628|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (2707:9): [True: 625, False: 3]
  ------------------
 2708|    625|    {
 2709|    625|        if (td->td_photometric == PHOTOMETRIC_YCBCR &&
  ------------------
  |  |  227|  1.25k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (2709:13): [True: 621, False: 4]
  ------------------
 2710|    621|            sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
  ------------------
  |  |  708|    621|#define JPEGCOLORMODE_RGB 0x0001     /* do auto conversion */
  ------------------
  |  Branch (2710:13): [True: 285, False: 336]
  ------------------
 2711|    285|        {
 2712|    285|            tif->tif_flags |= TIFF_UPSAMPLED;
  ------------------
  |  |  133|    285|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  ------------------
 2713|    285|        }
 2714|    340|        else
 2715|    340|        {
 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|    340|        }
 2722|    625|    }
 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|    628|    if (tif->tif_dir.td_tilesize > 0)
  ------------------
  |  Branch (2728:9): [True: 1, False: 627]
  ------------------
 2729|      1|        tif->tif_dir.td_tilesize =
 2730|      1|            isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1);
  ------------------
  |  |  278|      1|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      1|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 2731|    628|    if (tif->tif_dir.td_scanlinesize > 0)
  ------------------
  |  Branch (2731:9): [True: 285, False: 343]
  ------------------
 2732|    285|        tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 2733|    628|}
tif_jpeg.c:JPEGFixupTags:
  849|    333|{
  850|    333|#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
  851|    333|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    333|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
  852|    333|    if ((tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|    333|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (852:9): [True: 312, False: 21]
  ------------------
  853|    312|        (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|    312|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (853:9): [True: 312, False: 0]
  ------------------
  854|    312|        (tif->tif_dir.td_samplesperpixel == 3) &&
  ------------------
  |  Branch (854:9): [True: 312, False: 0]
  ------------------
  855|    312|        !sp->otherSettings.ycbcrsampling_fetched)
  ------------------
  |  Branch (855:9): [True: 312, False: 0]
  ------------------
  856|    312|        JPEGFixupTagsSubsampling(tif);
  857|    333|#endif
  858|       |
  859|    333|    return (1);
  860|    333|}
tif_jpeg.c:JPEGFixupTagsSubsampling:
  865|    312|{
  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|    312|    static const char module[] = "JPEGFixupTagsSubsampling";
  887|    312|    struct JPEGFixupTagsSubsamplingData m;
  888|    312|    uint64_t fileoffset = TIFFGetStrileOffset(tif, 0);
  889|       |
  890|    312|    if (fileoffset == 0)
  ------------------
  |  Branch (890:9): [True: 0, False: 312]
  ------------------
  891|      0|    {
  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|      0|        return;
  896|      0|    }
  897|       |
  898|    312|    m.tif = tif;
  899|    312|    m.buffersize = 2048;
  900|    312|    m.buffer = _TIFFmallocExt(tif, m.buffersize);
  901|    312|    if (m.buffer == NULL)
  ------------------
  |  Branch (901:9): [True: 0, False: 312]
  ------------------
  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|    312|    m.buffercurrentbyte = NULL;
  909|    312|    m.bufferbytesleft = 0;
  910|    312|    m.fileoffset = fileoffset;
  911|    312|    m.filepositioned = 0;
  912|    312|    m.filebytesleft = TIFFGetStrileByteCount(tif, 0);
  913|    312|    if (!JPEGFixupTagsSubsamplingSec(&m))
  ------------------
  |  Branch (913:9): [True: 226, False: 86]
  ------------------
  914|    226|        TIFFWarningExtR(
  915|    226|            tif, module,
  916|    226|            "Unable to auto-correct subsampling values, likely corrupt JPEG "
  917|    226|            "compressed data in first strip/tile; auto-correcting skipped");
  918|    312|    _TIFFfreeExt(tif, m.buffer);
  919|    312|}
tif_jpeg.c:JPEGFixupTagsSubsamplingSec:
  923|    312|{
  924|    312|    static const char module[] = "JPEGFixupTagsSubsamplingSec";
  925|    312|    uint8_t m;
  926|  37.0k|    while (1)
  ------------------
  |  Branch (926:12): [True: 37.0k, Folded]
  ------------------
  927|  37.0k|    {
  928|  4.70M|        while (1)
  ------------------
  |  Branch (928:16): [True: 4.70M, Folded]
  ------------------
  929|  4.70M|        {
  930|  4.70M|            if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
  ------------------
  |  Branch (930:17): [True: 69, False: 4.70M]
  ------------------
  931|     69|                return (0);
  932|  4.70M|            if (m == 255)
  ------------------
  |  Branch (932:17): [True: 36.9k, False: 4.67M]
  ------------------
  933|  36.9k|                break;
  934|  4.70M|        }
  935|  45.9k|        while (1)
  ------------------
  |  Branch (935:16): [True: 45.9k, Folded]
  ------------------
  936|  45.9k|        {
  937|  45.9k|            if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
  ------------------
  |  Branch (937:17): [True: 0, False: 45.9k]
  ------------------
  938|      0|                return (0);
  939|  45.9k|            if (m != 255)
  ------------------
  |  Branch (939:17): [True: 36.9k, False: 8.98k]
  ------------------
  940|  36.9k|                break;
  941|  45.9k|        }
  942|  36.9k|        switch (m)
  943|  36.9k|        {
  944|    734|            case JPEG_MARKER_SOI:
  ------------------
  |  |  816|    734|#define JPEG_MARKER_SOI 0xD8
  ------------------
  |  Branch (944:13): [True: 734, False: 36.2k]
  ------------------
  945|       |                /* this type of marker has no data and should be skipped */
  946|    734|                break;
  947|    213|            case JPEG_MARKER_COM:
  ------------------
  |  |  821|    213|#define JPEG_MARKER_COM 0xFE
  ------------------
  |  Branch (947:13): [True: 213, False: 36.7k]
  ------------------
  948|  2.95k|            case JPEG_MARKER_APP0:
  ------------------
  |  |  820|  2.95k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (948:13): [True: 2.74k, False: 34.2k]
  ------------------
  949|  19.2k|            case JPEG_MARKER_APP0 + 1:
  ------------------
  |  |  820|  19.2k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (949:13): [True: 16.3k, False: 20.6k]
  ------------------
  950|  21.0k|            case JPEG_MARKER_APP0 + 2:
  ------------------
  |  |  820|  21.0k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (950:13): [True: 1.72k, False: 35.2k]
  ------------------
  951|  21.0k|            case JPEG_MARKER_APP0 + 3:
  ------------------
  |  |  820|  21.0k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (951:13): [True: 10, False: 36.9k]
  ------------------
  952|  22.2k|            case JPEG_MARKER_APP0 + 4:
  ------------------
  |  |  820|  22.2k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (952:13): [True: 1.17k, False: 35.8k]
  ------------------
  953|  22.8k|            case JPEG_MARKER_APP0 + 5:
  ------------------
  |  |  820|  22.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (953:13): [True: 628, False: 36.3k]
  ------------------
  954|  26.8k|            case JPEG_MARKER_APP0 + 6:
  ------------------
  |  |  820|  26.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (954:13): [True: 4.01k, False: 32.9k]
  ------------------
  955|  27.1k|            case JPEG_MARKER_APP0 + 7:
  ------------------
  |  |  820|  27.1k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (955:13): [True: 286, False: 36.6k]
  ------------------
  956|  27.6k|            case JPEG_MARKER_APP0 + 8:
  ------------------
  |  |  820|  27.6k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (956:13): [True: 553, False: 36.4k]
  ------------------
  957|  31.9k|            case JPEG_MARKER_APP0 + 9:
  ------------------
  |  |  820|  31.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (957:13): [True: 4.29k, False: 32.6k]
  ------------------
  958|  32.0k|            case JPEG_MARKER_APP0 + 10:
  ------------------
  |  |  820|  32.0k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (958:13): [True: 111, False: 36.8k]
  ------------------
  959|  32.8k|            case JPEG_MARKER_APP0 + 11:
  ------------------
  |  |  820|  32.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (959:13): [True: 759, False: 36.2k]
  ------------------
  960|  32.8k|            case JPEG_MARKER_APP0 + 12:
  ------------------
  |  |  820|  32.8k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (960:13): [True: 18, False: 36.9k]
  ------------------
  961|  32.9k|            case JPEG_MARKER_APP0 + 13:
  ------------------
  |  |  820|  32.9k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (961:13): [True: 115, False: 36.8k]
  ------------------
  962|  33.2k|            case JPEG_MARKER_APP0 + 14:
  ------------------
  |  |  820|  33.2k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (962:13): [True: 300, False: 36.6k]
  ------------------
  963|  33.6k|            case JPEG_MARKER_APP0 + 15:
  ------------------
  |  |  820|  33.6k|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (963:13): [True: 343, False: 36.6k]
  ------------------
  964|  34.0k|            case JPEG_MARKER_DQT:
  ------------------
  |  |  818|  34.0k|#define JPEG_MARKER_DQT 0xDB
  ------------------
  |  Branch (964:13): [True: 379, False: 36.5k]
  ------------------
  965|  34.1k|            case JPEG_MARKER_SOS:
  ------------------
  |  |  817|  34.1k|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (965:13): [True: 169, False: 36.8k]
  ------------------
  966|  35.1k|            case JPEG_MARKER_DHT:
  ------------------
  |  |  815|  35.1k|#define JPEG_MARKER_DHT 0xC4
  ------------------
  |  Branch (966:13): [True: 950, False: 36.0k]
  ------------------
  967|  36.0k|            case JPEG_MARKER_DRI:
  ------------------
  |  |  819|  36.0k|#define JPEG_MARKER_DRI 0xDD
  ------------------
  |  Branch (967:13): [True: 878, False: 36.0k]
  ------------------
  968|       |                /* this type of marker has data, but it has no use to us and
  969|       |                 * should be skipped */
  970|  36.0k|                {
  971|  36.0k|                    uint16_t n;
  972|  36.0k|                    if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
  ------------------
  |  Branch (972:25): [True: 2, False: 36.0k]
  ------------------
  973|      2|                        return (0);
  974|  36.0k|                    if (n < 2)
  ------------------
  |  Branch (974:25): [True: 7, False: 35.9k]
  ------------------
  975|      7|                        return (0);
  976|  35.9k|                    n = (uint16_t)(n - 2);
  977|  35.9k|                    if (n > 0)
  ------------------
  |  Branch (977:25): [True: 16.8k, False: 19.1k]
  ------------------
  978|  16.8k|                        JPEGFixupTagsSubsamplingSkip(data, n);
  979|  35.9k|                }
  980|      0|                break;
  981|     84|            case JPEG_MARKER_SOF0:  /* Baseline sequential Huffman */
  ------------------
  |  |  810|     84|#define JPEG_MARKER_SOF0 0xC0
  ------------------
  |  Branch (981:13): [True: 84, False: 36.8k]
  ------------------
  982|     84|            case JPEG_MARKER_SOF1:  /* Extended sequential Huffman */
  ------------------
  |  |  811|     84|#define JPEG_MARKER_SOF1 0xC1
  ------------------
  |  Branch (982:13): [True: 0, False: 36.9k]
  ------------------
  983|     84|            case JPEG_MARKER_SOF2:  /* Progressive Huffman: normally not allowed
  ------------------
  |  |  812|     84|#define JPEG_MARKER_SOF2 0xC2
  ------------------
  |  Branch (983:13): [True: 0, False: 36.9k]
  ------------------
  984|       |                                       by  TechNote, but that doesn't hurt
  985|       |                                       supporting it */
  986|     86|            case JPEG_MARKER_SOF9:  /* Extended sequential arithmetic */
  ------------------
  |  |  813|     86|#define JPEG_MARKER_SOF9 0xC9
  ------------------
  |  Branch (986:13): [True: 2, False: 36.9k]
  ------------------
  987|     88|            case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not
  ------------------
  |  |  814|     88|#define JPEG_MARKER_SOF10 0xCA
  ------------------
  |  Branch (987:13): [True: 2, False: 36.9k]
  ------------------
  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|     88|                {
  993|     88|                    uint16_t n;
  994|     88|                    uint16_t o;
  995|     88|                    uint8_t p;
  996|     88|                    uint8_t ph, pv;
  997|     88|                    if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
  ------------------
  |  Branch (997:25): [True: 0, False: 88]
  ------------------
  998|      0|                        return (0);
  999|     88|                    if (n != 8 + data->tif->tif_dir.td_samplesperpixel * 3)
  ------------------
  |  Branch (999:25): [True: 2, False: 86]
  ------------------
 1000|      2|                        return (0);
 1001|     86|                    JPEGFixupTagsSubsamplingSkip(data, 7);
 1002|     86|                    if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
  ------------------
  |  Branch (1002:25): [True: 0, False: 86]
  ------------------
 1003|      0|                        return (0);
 1004|     86|                    ph = (p >> 4);
 1005|     86|                    pv = (p & 15);
 1006|     86|                    JPEGFixupTagsSubsamplingSkip(data, 1);
 1007|    224|                    for (o = 1; o < data->tif->tif_dir.td_samplesperpixel; o++)
  ------------------
  |  Branch (1007:33): [True: 158, False: 66]
  ------------------
 1008|    158|                    {
 1009|    158|                        JPEGFixupTagsSubsamplingSkip(data, 1);
 1010|    158|                        if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
  ------------------
  |  Branch (1010:29): [True: 0, False: 158]
  ------------------
 1011|      0|                            return (0);
 1012|    158|                        if (p != 0x11)
  ------------------
  |  Branch (1012:29): [True: 20, False: 138]
  ------------------
 1013|     20|                        {
 1014|     20|                            TIFFWarningExtR(data->tif, module,
 1015|     20|                                            "Subsampling values inside JPEG "
 1016|     20|                                            "compressed data "
 1017|     20|                                            "have no TIFF equivalent, "
 1018|     20|                                            "auto-correction of TIFF "
 1019|     20|                                            "subsampling values failed");
 1020|     20|                            return (1);
 1021|     20|                        }
 1022|    138|                        JPEGFixupTagsSubsamplingSkip(data, 1);
 1023|    138|                    }
 1024|     66|                    if (((ph != 1) && (ph != 2) && (ph != 4)) ||
  ------------------
  |  Branch (1024:26): [True: 4, False: 62]
  |  Branch (1024:39): [True: 4, False: 0]
  |  Branch (1024:52): [True: 4, False: 0]
  ------------------
 1025|     62|                        ((pv != 1) && (pv != 2) && (pv != 4)))
  ------------------
  |  Branch (1025:26): [True: 0, False: 62]
  |  Branch (1025:39): [True: 0, False: 0]
  |  Branch (1025:52): [True: 0, False: 0]
  ------------------
 1026|      4|                    {
 1027|      4|                        TIFFWarningExtR(data->tif, module,
 1028|      4|                                        "Subsampling values inside JPEG "
 1029|      4|                                        "compressed data have no TIFF "
 1030|      4|                                        "equivalent, auto-correction of TIFF "
 1031|      4|                                        "subsampling values failed");
 1032|      4|                        return (1);
 1033|      4|                    }
 1034|     62|                    if ((ph != data->tif->tif_dir.td_ycbcrsubsampling[0]) ||
  ------------------
  |  Branch (1034:25): [True: 62, False: 0]
  ------------------
 1035|      0|                        (pv != data->tif->tif_dir.td_ycbcrsubsampling[1]))
  ------------------
  |  Branch (1035:25): [True: 0, False: 0]
  ------------------
 1036|     62|                    {
 1037|     62|                        TIFFWarningExtR(
 1038|     62|                            data->tif, module,
 1039|     62|                            "Auto-corrected former TIFF subsampling values "
 1040|     62|                            "[%" PRIu16 ",%" PRIu16
 1041|     62|                            "] to match subsampling values inside JPEG "
 1042|     62|                            "compressed data [%" PRIu8 ",%" PRIu8 "]",
 1043|     62|                            data->tif->tif_dir.td_ycbcrsubsampling[0],
 1044|     62|                            data->tif->tif_dir.td_ycbcrsubsampling[1], ph, pv);
 1045|     62|                        data->tif->tif_dir.td_ycbcrsubsampling[0] = ph;
 1046|     62|                        data->tif->tif_dir.td_ycbcrsubsampling[1] = pv;
 1047|     62|                    }
 1048|     62|                }
 1049|      0|                return (1);
 1050|    146|            default:
  ------------------
  |  Branch (1050:13): [True: 146, False: 36.8k]
  ------------------
 1051|    146|                return (0);
 1052|  36.9k|        }
 1053|  36.9k|    }
 1054|    312|}
tif_jpeg.c:JPEGFixupTagsSubsamplingReadByte:
 1059|  4.82M|{
 1060|  4.82M|    if (data->bufferbytesleft == 0)
  ------------------
  |  Branch (1060:9): [True: 3.14k, False: 4.82M]
  ------------------
 1061|  3.14k|    {
 1062|  3.14k|        uint32_t m;
 1063|  3.14k|        if (data->filebytesleft == 0)
  ------------------
  |  Branch (1063:13): [True: 45, False: 3.10k]
  ------------------
 1064|     45|            return (0);
 1065|  3.10k|        if (!data->filepositioned)
  ------------------
  |  Branch (1065:13): [True: 706, False: 2.39k]
  ------------------
 1066|    706|        {
 1067|    706|            if (TIFFSeekFile(data->tif, data->fileoffset, SEEK_SET) ==
  ------------------
  |  |  287|    706|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
  |  Branch (1067:17): [True: 4, False: 702]
  ------------------
 1068|    706|                (toff_t)-1)
 1069|      4|            {
 1070|      4|                return 0;
 1071|      4|            }
 1072|    702|            data->filepositioned = 1;
 1073|    702|        }
 1074|  3.09k|        m = data->buffersize;
 1075|  3.09k|        if ((uint64_t)m > data->filebytesleft)
  ------------------
  |  Branch (1075:13): [True: 53, False: 3.04k]
  ------------------
 1076|     53|            m = (uint32_t)data->filebytesleft;
 1077|  3.09k|        assert(m < 0x80000000UL);
  ------------------
  |  Branch (1077:9): [True: 0, False: 3.09k]
  |  Branch (1077:9): [True: 3.09k, False: 0]
  ------------------
 1078|  3.09k|        if (TIFFReadFile(data->tif, data->buffer, (tmsize_t)m) != (tmsize_t)m)
  ------------------
  |  |  283|  3.09k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  |  Branch (1078:13): [True: 22, False: 3.07k]
  ------------------
 1079|     22|            return (0);
 1080|  3.07k|        data->buffercurrentbyte = (uint8_t *)data->buffer;
 1081|  3.07k|        data->bufferbytesleft = m;
 1082|  3.07k|        data->fileoffset += m;
 1083|  3.07k|        data->filebytesleft -= m;
 1084|  3.07k|    }
 1085|  4.82M|    *result = *data->buffercurrentbyte;
 1086|  4.82M|    data->buffercurrentbyte++;
 1087|  4.82M|    data->bufferbytesleft--;
 1088|  4.82M|    return (1);
 1089|  4.82M|}
tif_jpeg.c:JPEGFixupTagsSubsamplingReadWord:
 1094|  36.0k|{
 1095|  36.0k|    uint8_t ma;
 1096|  36.0k|    uint8_t mb;
 1097|  36.0k|    if (!JPEGFixupTagsSubsamplingReadByte(data, &ma))
  ------------------
  |  Branch (1097:9): [True: 0, False: 36.0k]
  ------------------
 1098|      0|        return (0);
 1099|  36.0k|    if (!JPEGFixupTagsSubsamplingReadByte(data, &mb))
  ------------------
  |  Branch (1099:9): [True: 2, False: 36.0k]
  ------------------
 1100|      2|        return (0);
 1101|  36.0k|    *result = (uint16_t)((ma << 8) | mb);
 1102|  36.0k|    return (1);
 1103|  36.0k|}
tif_jpeg.c:JPEGFixupTagsSubsamplingSkip:
 1108|  17.3k|{
 1109|  17.3k|    if ((uint32_t)skiplength <= data->bufferbytesleft)
  ------------------
  |  Branch (1109:9): [True: 16.9k, False: 420]
  ------------------
 1110|  16.9k|    {
 1111|  16.9k|        data->buffercurrentbyte += skiplength;
 1112|  16.9k|        data->bufferbytesleft -= skiplength;
 1113|  16.9k|    }
 1114|    420|    else
 1115|    420|    {
 1116|    420|        uint16_t m;
 1117|    420|        m = (uint16_t)(skiplength - data->bufferbytesleft);
 1118|    420|        if (m <= data->filebytesleft)
  ------------------
  |  Branch (1118:13): [True: 405, False: 15]
  ------------------
 1119|    405|        {
 1120|    405|            data->bufferbytesleft = 0;
 1121|    405|            data->fileoffset += m;
 1122|    405|            data->filebytesleft -= m;
 1123|    405|            data->filepositioned = 0;
 1124|    405|        }
 1125|     15|        else
 1126|     15|        {
 1127|     15|            data->bufferbytesleft = 0;
 1128|     15|            data->filebytesleft = 0;
 1129|     15|        }
 1130|    420|    }
 1131|  17.3k|}
tif_jpeg.c:JPEGSetupDecode:
 1136|    236|{
 1137|    236|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    236|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1138|    236|    TIFFDirectory *td = &tif->tif_dir;
 1139|       |
 1140|    236|#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
 1141|    236|    if (tif->tif_dir.td_bitspersample == 12)
  ------------------
  |  Branch (1141:9): [True: 7, False: 229]
  ------------------
 1142|      7|    {
 1143|       |        /* We pass a pointer to a copy of otherSettings, since */
 1144|       |        /* TIFFReInitJPEG_12() will clear sp */
 1145|      7|        JPEGOtherSettings savedOtherSettings = sp->otherSettings;
 1146|      7|        return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 0);
  ------------------
  |  |  190|      7|#define COMPRESSION_JPEG 7            /* %JPEG DCT compression */
  ------------------
 1147|      7|    }
 1148|    229|#endif
 1149|       |
 1150|    229|    JPEGInitializeLibJPEG(tif, TRUE);
  ------------------
  |  |   71|    229|#define TRUE 1
  ------------------
 1151|       |
 1152|    229|    assert(sp != NULL);
  ------------------
  |  Branch (1152:5): [True: 0, False: 229]
  |  Branch (1152:5): [True: 229, False: 0]
  ------------------
 1153|    229|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1153:5): [True: 0, False: 229]
  |  Branch (1153:5): [True: 229, False: 0]
  ------------------
 1154|       |
 1155|       |    /* Read JPEGTables if it is present */
 1156|    229|    if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
  ------------------
  |  |  248|    229|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|    229|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|    229|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 0, False: 229]
  |  |  ------------------
  ------------------
 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|    229|    sp->photometric = td->td_photometric;
 1168|    229|    switch (sp->photometric)
 1169|    229|    {
 1170|    211|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|    211|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1170:9): [True: 211, False: 18]
  ------------------
 1171|    211|            sp->h_sampling = td->td_ycbcrsubsampling[0];
 1172|    211|            sp->v_sampling = td->td_ycbcrsubsampling[1];
 1173|    211|            break;
 1174|     18|        default:
  ------------------
  |  Branch (1174:9): [True: 18, False: 211]
  ------------------
 1175|       |            /* TIFF 6.0 forbids subsampling of all other color spaces */
 1176|     18|            sp->h_sampling = 1;
 1177|     18|            sp->v_sampling = 1;
 1178|     18|            break;
 1179|    229|    }
 1180|       |
 1181|       |    /* Set up for reading normal data */
 1182|    229|    TIFFjpeg_data_src(sp);
 1183|    229|    tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
 1184|    229|    return (1);
 1185|    229|}
tif_jpeg.c:JPEGInitializeLibJPEG:
 2883|    229|{
 2884|    229|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    229|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2885|       |
 2886|    229|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2886:9): [True: 0, False: 229]
  ------------------
 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|    229|    if (decompress)
  ------------------
  |  Branch (2901:9): [True: 229, False: 0]
  ------------------
 2902|    229|    {
 2903|    229|        if (!TIFFjpeg_create_decompress(sp))
  ------------------
  |  Branch (2903:13): [True: 0, False: 229]
  ------------------
 2904|      0|            return (0);
 2905|    229|    }
 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|    229|    sp->cinfo_initialized = TRUE;
  ------------------
  |  |   71|    229|#define TRUE 1
  ------------------
 2936|       |
 2937|    229|    return 1;
 2938|    229|}
tif_jpeg.c:JPEGPreDecode:
 1268|  1.18k|{
 1269|  1.18k|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|  1.18k|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1270|  1.18k|    TIFFDirectory *td = &tif->tif_dir;
 1271|  1.18k|    static const char module[] = "JPEGPreDecode";
 1272|  1.18k|    int downsampled_output;
 1273|  1.18k|    int ci;
 1274|       |
 1275|  1.18k|    assert(sp != NULL);
  ------------------
  |  Branch (1275:5): [True: 0, False: 1.18k]
  |  Branch (1275:5): [True: 1.18k, False: 0]
  ------------------
 1276|       |
 1277|  1.18k|    if (sp->cinfo.comm.is_decompressor == 0)
  ------------------
  |  Branch (1277:9): [True: 0, False: 1.18k]
  ------------------
 1278|      0|    {
 1279|      0|        tif->tif_setupdecode(tif);
 1280|      0|    }
 1281|       |
 1282|  1.18k|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1282:5): [True: 0, False: 1.18k]
  |  Branch (1282:5): [True: 1.18k, False: 0]
  ------------------
 1283|       |    /*
 1284|       |     * Reset decoder state from any previous strip/tile,
 1285|       |     * in case application didn't read the whole strip.
 1286|       |     */
 1287|  1.18k|    if (!TIFFjpeg_abort(sp))
  ------------------
  |  Branch (1287:9): [True: 0, False: 1.18k]
  ------------------
 1288|      0|        return (0);
 1289|       |    /*
 1290|       |     * Read the header for this strip/tile.
 1291|       |     */
 1292|       |
 1293|  1.18k|    if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
  ------------------
  |  |   71|  1.18k|#define TRUE 1
  ------------------
  |  Branch (1293:9): [True: 1.14k, False: 37]
  ------------------
 1294|  1.14k|        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: 35, False: 2]
  ------------------
 1303|      2|        sp->cinfo.d.image_height < sp->strile_height)
  ------------------
  |  Branch (1303:9): [True: 2, False: 0]
  ------------------
 1304|     37|    {
 1305|     37|        TIFFWarningExtR(tif, module,
 1306|     37|                        "Improper JPEG strip/tile size, "
 1307|     37|                        "expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1308|     37|                        sp->strile_width, sp->strile_height,
 1309|     37|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1310|     37|    }
 1311|     37|    if (sp->cinfo.d.image_width == sp->strile_width &&
  ------------------
  |  Branch (1311:9): [True: 2, False: 35]
  ------------------
 1312|      2|        sp->cinfo.d.image_height > sp->strile_height &&
  ------------------
  |  Branch (1312:9): [True: 0, False: 2]
  ------------------
 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|     37|    else if (sp->cinfo.d.image_width > sp->strile_width ||
  ------------------
  |  Branch (1326:14): [True: 0, False: 37]
  ------------------
 1327|     37|             sp->cinfo.d.image_height > sp->strile_height)
  ------------------
  |  Branch (1327:14): [True: 35, False: 2]
  ------------------
 1328|     35|    {
 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|     35|        TIFFErrorExtR(tif, module,
 1336|     35|                      "JPEG strip/tile size exceeds expected dimensions,"
 1337|     35|                      " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1338|     35|                      sp->strile_width, sp->strile_height,
 1339|     35|                      sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1340|     35|        return (0);
 1341|     35|    }
 1342|      2|    if (sp->cinfo.d.num_components !=
  ------------------
  |  Branch (1342:9): [True: 2, False: 0]
  ------------------
 1343|      2|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|      2|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1343:10): [True: 2, False: 0]
  ------------------
 1344|      2|                                                    : 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|      0|    if (td->td_bitspersample != BITS_IN_JSAMPLE ||
  ------------------
  |  |  108|      0|#define BITS_IN_JSAMPLE 8
  ------------------
  |  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.c:TIFFjpeg_abort:
  520|  1.18k|{
  521|       |    return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm));
  ------------------
  |  |  302|  1.18k|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|  1.18k|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|  1.18k|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (521:12): [True: 0, False: 1.18k]
  ------------------
  522|  1.18k|}
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: 2, False: 35]
  |  |  ------------------
  ------------------
 1232|      2|    {
 1233|      2|        sp->strile_width = td->td_tilewidth;
 1234|      2|        sp->strile_height = td->td_tilelength;
 1235|      2|        sp->bytesperline = TIFFTileRowSize(tif);
 1236|      2|    }
 1237|     35|    else
 1238|     35|    {
 1239|     35|        sp->strile_width = td->td_imagewidth;
 1240|     35|        sp->strile_height = td->td_imagelength - tif->tif_dir.td_row;
 1241|     35|        if (sp->strile_height > td->td_rowsperstrip)
  ------------------
  |  Branch (1241:13): [True: 0, False: 35]
  ------------------
 1242|      0|            sp->strile_height = td->td_rowsperstrip;
 1243|     35|        sp->bytesperline = TIFFScanlineSize(tif);
 1244|     35|    }
 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:JPEGCleanup:
 2678|    363|{
 2679|    363|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    363|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2680|       |
 2681|    363|    assert(sp != 0);
  ------------------
  |  Branch (2681:5): [True: 0, False: 363]
  |  Branch (2681:5): [True: 363, False: 0]
  ------------------
 2682|       |
 2683|    363|    tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent;
 2684|    363|    tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent;
 2685|    363|    tif->tif_tagmethods.printdir = sp->otherSettings.printdir;
 2686|    363|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2686:9): [True: 229, False: 134]
  ------------------
 2687|    229|        TIFFjpeg_destroy(sp);         /* release libjpeg resources */
 2688|    363|    if (sp->otherSettings.jpegtables) /* tag value */
  ------------------
  |  Branch (2688:9): [True: 0, False: 363]
  ------------------
 2689|      0|        _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
 2690|    363|    _TIFFfreeExt(tif, tif->tif_data); /* release local state */
 2691|    363|    tif->tif_data = NULL;
 2692|       |
 2693|    363|    _TIFFSetDefaultCompressionState(tif);
 2694|    363|}
tif_jpeg_12.c:TIFFjpeg_create_decompress:
  318|      7|{
  319|       |    /* initialize JPEG error handling */
  320|      7|    sp->cinfo.d.err = jpeg_std_error(&sp->err);
  321|      7|    sp->err.error_exit = TIFFjpeg_error_exit;
  322|      7|    sp->err.output_message = TIFFjpeg_output_message;
  323|       |
  324|       |    /* set client_data to avoid UMR warning from tools like Purify */
  325|      7|    sp->cinfo.d.client_data = NULL;
  326|       |
  327|       |    return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
  ------------------
  |  |  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 (327:12): [True: 0, False: 7]
  ------------------
  328|      7|}
tif_jpeg_12.c:TIFFjpeg_error_exit:
  244|    166|{
  245|    166|    JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
  246|    166|    char buffer[JMSG_LENGTH_MAX];
  247|       |
  248|    166|    (*cinfo->err->format_message)(cinfo, buffer);
  249|    166|    TIFFErrorExtR(sp->tif, "JPEGLib", "%s",
  250|    166|                  buffer);       /* display the error message */
  251|    166|    jpeg_abort(cinfo);           /* clean up libjpeg state */
  252|    166|    LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
  ------------------
  |  |  143|    166|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
  253|    166|}
tif_jpeg_12.c:TIFFjpeg_output_message:
  261|     38|{
  262|     38|    char buffer[JMSG_LENGTH_MAX];
  263|       |
  264|     38|    (*cinfo->err->format_message)(cinfo, buffer);
  265|     38|    TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer);
  266|     38|}
tif_jpeg_12.c:TIFFjpeg_data_src:
  744|      7|{
  745|      7|    sp->cinfo.d.src = &sp->src;
  746|      7|    sp->src.init_source = std_init_source;
  747|      7|    sp->src.fill_input_buffer = std_fill_input_buffer;
  748|      7|    sp->src.skip_input_data = std_skip_input_data;
  749|      7|    sp->src.resync_to_restart = jpeg_resync_to_restart;
  750|      7|    sp->src.term_source = std_term_source;
  751|      7|    sp->src.bytes_in_buffer = 0; /* for safety */
  752|       |    sp->src.next_input_byte = NULL;
  753|      7|}
tif_jpeg_12.c:std_init_source:
  674|    164|{
  675|    164|    JPEGState *sp = (JPEGState *)cinfo;
  676|    164|    TIFF *tif = sp->tif;
  677|       |
  678|    164|    sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata;
  679|    164|    sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
  680|    164|}
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|    272|{
  720|    272|    JPEGState *sp = (JPEGState *)cinfo;
  721|       |
  722|    272|    if (num_bytes > 0)
  ------------------
  |  Branch (722:9): [True: 272, False: 0]
  ------------------
  723|    272|    {
  724|    272|        if ((size_t)num_bytes > sp->src.bytes_in_buffer)
  ------------------
  |  Branch (724:13): [True: 0, False: 272]
  ------------------
  725|      0|        {
  726|       |            /* oops, buffer overrun */
  727|      0|            (void)std_fill_input_buffer(cinfo);
  728|      0|        }
  729|    272|        else
  730|    272|        {
  731|    272|            sp->src.next_input_byte += (size_t)num_bytes;
  732|    272|            sp->src.bytes_in_buffer -= (size_t)num_bytes;
  733|    272|        }
  734|    272|    }
  735|    272|}
tif_jpeg_12.c:TIFFjpeg_read_header:
  396|    166|{
  397|       |    return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image));
  ------------------
  |  |  301|    166|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|    166|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (397:12): [True: 134, False: 32]
  ------------------
  398|    166|}
tif_jpeg_12.c:TIFFjpeg_destroy:
  525|      7|{
  526|       |    return CALLVJPEG(sp, jpeg_destroy(&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 (526:12): [True: 0, False: 7]
  ------------------
  527|      7|}
tif_jpeg_12.c:TIFFjpeg_has_multiple_scans:
  401|     32|{
  402|       |    return CALLJPEG(sp, 0, jpeg_has_multiple_scans(&sp->cinfo.d));
  ------------------
  |  |  301|     32|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  ------------------
  |  |  |  |  142|     32|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  ------------------
  ------------------
  |  Branch (402:12): [True: 0, False: 32]
  ------------------
  403|     32|}
tif_jpeg_12.c:TIFFInitJPEGCommon:
 2969|      7|{
 2970|      7|    JPEGState *sp;
 2971|       |
 2972|      7|    sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2973|      7|    sp->tif = tif; /* back link */
 2974|       |
 2975|       |    /* Default values for codec-specific fields */
 2976|      7|    sp->otherSettings.jpegtables = NULL;
 2977|      7|    sp->otherSettings.jpegtables_length = 0;
 2978|      7|    sp->otherSettings.jpegquality = 75; /* Default IJG quality */
 2979|      7|    sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW;
  ------------------
  |  |  707|      7|#define JPEGCOLORMODE_RAW 0x0000     /* no conversion (default) */
  ------------------
 2980|      7|    sp->otherSettings.jpegtablesmode =
 2981|      7|        JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  710|      7|#define JPEGTABLESMODE_QUANT 0x0001  /* include quantization tbls */
  ------------------
                      JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
  ------------------
  |  |  711|      7|#define JPEGTABLESMODE_HUFF 0x0002   /* include Huffman tbls */
  ------------------
 2982|      7|    sp->otherSettings.ycbcrsampling_fetched = 0;
 2983|       |
 2984|      7|    tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
 2985|      7|    tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
 2986|      7|    tif->tif_tagmethods.printdir = JPEGPrintDir;   /* hook for codec tags */
 2987|       |
 2988|       |    /*
 2989|       |     * Install codec methods.
 2990|       |     */
 2991|      7|    tif->tif_fixuptags = JPEGFixupTags;
 2992|      7|    tif->tif_setupdecode = JPEGSetupDecode;
 2993|      7|    tif->tif_predecode = JPEGPreDecode;
 2994|      7|    tif->tif_decoderow = JPEGDecode;
 2995|      7|    tif->tif_decodestrip = JPEGDecode;
 2996|      7|    tif->tif_decodetile = JPEGDecode;
 2997|      7|    tif->tif_setupencode = JPEGSetupEncode;
 2998|      7|    tif->tif_preencode = JPEGPreEncode;
 2999|      7|    tif->tif_postencode = JPEGPostEncode;
 3000|      7|    tif->tif_encoderow = JPEGEncode;
 3001|      7|    tif->tif_encodestrip = JPEGEncode;
 3002|      7|    tif->tif_encodetile = JPEGEncode;
 3003|      7|    tif->tif_getmaxcompressionratio = JPEGGetMaxCompressionRatio;
 3004|      7|    tif->tif_cleanup = JPEGCleanup;
 3005|       |
 3006|      7|    tif->tif_defstripsize = JPEGDefaultStripSize;
 3007|      7|    tif->tif_deftilesize = JPEGDefaultTileSize;
 3008|      7|    tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
  ------------------
  |  |  127|      7|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
 3009|      7|    sp->cinfo_initialized = FALSE;
  ------------------
  |  |   72|      7|#define FALSE 0
  ------------------
 3010|      7|}
tif_jpeg_12.c:JPEGVGetField:
 2796|     14|{
 2797|     14|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|     14|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2798|       |
 2799|     14|    assert(sp != NULL);
  ------------------
  |  Branch (2799:5): [True: 0, False: 14]
  |  Branch (2799:5): [True: 14, False: 0]
  ------------------
 2800|       |
 2801|     14|    switch (tag)
 2802|     14|    {
 2803|      0|        case TIFFTAG_JPEGTABLES:
  ------------------
  |  |  346|      0|#define TIFFTAG_JPEGTABLES 347             /* %JPEG table stream */
  ------------------
  |  Branch (2803:9): [True: 0, False: 14]
  ------------------
 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: 14]
  ------------------
 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: 14]
  ------------------
 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: 14]
  ------------------
 2814|      0|            *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode;
 2815|      0|            break;
 2816|     14|        default:
  ------------------
  |  Branch (2816:9): [True: 14, False: 0]
  ------------------
 2817|     14|            return (*sp->otherSettings.vgetparent)(tif, tag, ap);
 2818|     14|    }
 2819|      0|    return (1);
 2820|     14|}
tif_jpeg_12.c:JPEGPreDecode:
 1268|    164|{
 1269|    164|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|    164|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1270|    164|    TIFFDirectory *td = &tif->tif_dir;
 1271|    164|    static const char module[] = "JPEGPreDecode";
 1272|    164|    int downsampled_output;
 1273|    164|    int ci;
 1274|       |
 1275|    164|    assert(sp != NULL);
  ------------------
  |  Branch (1275:5): [True: 0, False: 164]
  |  Branch (1275:5): [True: 164, False: 0]
  ------------------
 1276|       |
 1277|    164|    if (sp->cinfo.comm.is_decompressor == 0)
  ------------------
  |  Branch (1277:9): [True: 0, False: 164]
  ------------------
 1278|      0|    {
 1279|      0|        tif->tif_setupdecode(tif);
 1280|      0|    }
 1281|       |
 1282|    164|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1282:5): [True: 0, False: 164]
  |  Branch (1282:5): [True: 164, False: 0]
  ------------------
 1283|       |    /*
 1284|       |     * Reset decoder state from any previous strip/tile,
 1285|       |     * in case application didn't read the whole strip.
 1286|       |     */
 1287|    164|    if (!TIFFjpeg_abort(sp))
  ------------------
  |  Branch (1287:9): [True: 0, False: 164]
  ------------------
 1288|      0|        return (0);
 1289|       |    /*
 1290|       |     * Read the header for this strip/tile.
 1291|       |     */
 1292|       |
 1293|    164|    if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
  ------------------
  |  |   71|    164|#define TRUE 1
  ------------------
  |  Branch (1293:9): [True: 132, False: 32]
  ------------------
 1294|    132|        return (0);
 1295|       |
 1296|     32|    tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
 1297|     32|    tif->tif_rawcc = (tmsize_t)sp->src.bytes_in_buffer;
 1298|       |
 1299|     32|    if (!JPEGComputeStrileWidthHeightBytesPerLine(tif, s))
  ------------------
  |  Branch (1299:9): [True: 0, False: 32]
  ------------------
 1300|      0|        return 0;
 1301|       |
 1302|     32|    if (sp->cinfo.d.image_width < sp->strile_width ||
  ------------------
  |  Branch (1302:9): [True: 0, False: 32]
  ------------------
 1303|     32|        sp->cinfo.d.image_height < sp->strile_height)
  ------------------
  |  Branch (1303:9): [True: 32, False: 0]
  ------------------
 1304|     32|    {
 1305|     32|        TIFFWarningExtR(tif, module,
 1306|     32|                        "Improper JPEG strip/tile size, "
 1307|     32|                        "expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
 1308|     32|                        sp->strile_width, sp->strile_height,
 1309|     32|                        sp->cinfo.d.image_width, sp->cinfo.d.image_height);
 1310|     32|    }
 1311|     32|    if (sp->cinfo.d.image_width == sp->strile_width &&
  ------------------
  |  Branch (1311:9): [True: 32, False: 0]
  ------------------
 1312|     32|        sp->cinfo.d.image_height > sp->strile_height &&
  ------------------
  |  Branch (1312:9): [True: 0, False: 32]
  ------------------
 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|     32|    else if (sp->cinfo.d.image_width > sp->strile_width ||
  ------------------
  |  Branch (1326:14): [True: 0, False: 32]
  ------------------
 1327|     32|             sp->cinfo.d.image_height > sp->strile_height)
  ------------------
  |  Branch (1327:14): [True: 0, False: 32]
  ------------------
 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|     32|    if (sp->cinfo.d.num_components !=
  ------------------
  |  Branch (1342:9): [True: 0, False: 32]
  ------------------
 1343|     32|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|     32|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1343:10): [True: 32, False: 0]
  ------------------
 1344|     32|                                                    : 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|     32|    if (td->td_bitspersample != BITS_IN_JSAMPLE ||
  ------------------
  |  |  102|     64|#define BITS_IN_JSAMPLE 12
  ------------------
  |  Branch (1358:9): [True: 0, False: 32]
  ------------------
 1359|     32|        sp->cinfo.d.data_precision != td->td_bitspersample)
  ------------------
  |  Branch (1359:9): [True: 0, False: 32]
  ------------------
 1360|      0|    {
 1361|      0|        TIFFErrorExtR(tif, module, "Improper JPEG data precision");
 1362|      0|        return (0);
 1363|      0|    }
 1364|     32|#endif
 1365|       |
 1366|     32|    if (sp->cinfo.d.progressive_mode &&
  ------------------
  |  Branch (1366:9): [True: 32, False: 0]
  ------------------
 1367|     32|        !sp->otherSettings.has_warned_about_progressive_mode)
  ------------------
  |  Branch (1367:9): [True: 1, False: 31]
  ------------------
 1368|      1|    {
 1369|      1|        TIFFWarningExtR(tif, module,
 1370|      1|                        "The JPEG strip/tile is encoded with progressive mode, "
 1371|      1|                        "which is normally not legal for JPEG-in-TIFF.\n"
 1372|      1|                        "libtiff should be able to decode it, but it might "
 1373|      1|                        "cause compatibility issues with other readers");
 1374|      1|        sp->otherSettings.has_warned_about_progressive_mode = TRUE;
  ------------------
  |  |   71|      1|#define TRUE 1
  ------------------
 1375|      1|    }
 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|     32|    if (TIFFjpeg_has_multiple_scans(sp))
  ------------------
  |  Branch (1380:9): [True: 32, False: 0]
  ------------------
 1381|     32|    {
 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|     32|        toff_t nRequiredMemory = 1024 * 1024;
 1389|       |
 1390|    128|        for (ci = 0; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1390:22): [True: 96, False: 32]
  ------------------
 1391|     96|        {
 1392|     96|            const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]);
 1393|     96|            if (compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0)
  ------------------
  |  Branch (1393:17): [True: 96, False: 0]
  |  Branch (1393:47): [True: 96, False: 0]
  ------------------
 1394|     96|            {
 1395|     96|                nRequiredMemory +=
 1396|     96|                    (toff_t)((JDIMENSION)(((int)compptr->width_in_blocks +
 1397|     96|                                           compptr->h_samp_factor - 1) /
 1398|     96|                                          compptr->h_samp_factor)) *
 1399|     96|                    (JDIMENSION)(((int)compptr->height_in_blocks +
 1400|     96|                                  compptr->v_samp_factor - 1) /
 1401|     96|                                 compptr->v_samp_factor) *
 1402|     96|                    sizeof(JBLOCK);
 1403|     96|            }
 1404|     96|        }
 1405|       |
 1406|     32|        if (sp->cinfo.d.mem->max_memory_to_use > 0 &&
  ------------------
  |  Branch (1406:13): [True: 0, False: 32]
  ------------------
 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|     32|    }
 1425|       |
 1426|     32|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|     32|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1426:9): [True: 32, False: 0]
  ------------------
 1427|     32|    {
 1428|       |        /* Component 0 should have expected sampling factors */
 1429|     32|        if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
  ------------------
  |  Branch (1429:13): [True: 0, False: 32]
  ------------------
 1430|     32|            sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling)
  ------------------
  |  Branch (1430:13): [True: 0, False: 32]
  ------------------
 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|     96|        for (ci = 1; ci < sp->cinfo.d.num_components; ci++)
  ------------------
  |  Branch (1441:22): [True: 64, False: 32]
  ------------------
 1442|     64|        {
 1443|     64|            if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 ||
  ------------------
  |  Branch (1443:17): [True: 0, False: 64]
  ------------------
 1444|     64|                sp->cinfo.d.comp_info[ci].v_samp_factor != 1)
  ------------------
  |  Branch (1444:17): [True: 0, False: 64]
  ------------------
 1445|      0|            {
 1446|      0|                TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
 1447|      0|                return (0);
 1448|      0|            }
 1449|     64|        }
 1450|     32|    }
 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|     32|    downsampled_output = FALSE;
  ------------------
  |  |   72|     32|#define FALSE 0
  ------------------
 1462|     32|    if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|     64|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1462:9): [True: 32, False: 0]
  ------------------
 1463|     32|        sp->photometric == PHOTOMETRIC_YCBCR &&
  ------------------
  |  |  227|     64|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1463:9): [True: 0, False: 32]
  ------------------
 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|     32|    else
 1471|     32|    {
 1472|       |        /* Suppress colorspace handling */
 1473|     32|        sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
 1474|     32|        sp->cinfo.d.out_color_space = JCS_UNKNOWN;
 1475|     32|        if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
  ------------------
  |  |  265|     64|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1475:13): [True: 32, False: 0]
  ------------------
 1476|     32|            (sp->h_sampling != 1 || sp->v_sampling != 1))
  ------------------
  |  Branch (1476:14): [True: 0, False: 32]
  |  Branch (1476:37): [True: 0, False: 32]
  ------------------
 1477|      0|            downsampled_output = TRUE;
  ------------------
  |  |   71|      0|#define TRUE 1
  ------------------
 1478|       |        /* XXX what about up-sampling? */
 1479|     32|    }
 1480|     32|    if (downsampled_output)
  ------------------
  |  Branch (1480:9): [True: 0, False: 32]
  ------------------
 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|     32|    else
 1492|     32|    {
 1493|       |        /* Use normal interface to libjpeg */
 1494|     32|        sp->cinfo.d.raw_data_out = FALSE;
  ------------------
  |  |   72|     32|#define FALSE 0
  ------------------
 1495|     32|        tif->tif_decoderow = JPEGDecode;
 1496|     32|        tif->tif_decodestrip = JPEGDecode;
 1497|     32|        tif->tif_decodetile = JPEGDecode;
 1498|     32|    }
 1499|       |    /* Start JPEG decompressor */
 1500|     32|    if (!TIFFjpeg_start_decompress(sp))
  ------------------
  |  Branch (1500:9): [True: 32, False: 0]
  ------------------
 1501|     32|        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|    164|{
  521|       |    return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm));
  ------------------
  |  |  302|    164|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|    164|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    164|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (521:12): [True: 0, False: 164]
  ------------------
  522|    164|}
tif_jpeg_12.c:JPEGComputeStrileWidthHeightBytesPerLine:
 1224|     32|{
 1225|     32|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|     32|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1226|     32|    TIFFDirectory *td = &tif->tif_dir;
 1227|       |
 1228|       |    /*
 1229|       |     * Check image parameters and set decompression parameters.
 1230|       |     */
 1231|     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: 0, False: 32]
  |  |  ------------------
  ------------------
 1232|      0|    {
 1233|      0|        sp->strile_width = td->td_tilewidth;
 1234|      0|        sp->strile_height = td->td_tilelength;
 1235|      0|        sp->bytesperline = TIFFTileRowSize(tif);
 1236|      0|    }
 1237|     32|    else
 1238|     32|    {
 1239|     32|        sp->strile_width = td->td_imagewidth;
 1240|     32|        sp->strile_height = td->td_imagelength - tif->tif_dir.td_row;
 1241|     32|        if (sp->strile_height > td->td_rowsperstrip)
  ------------------
  |  Branch (1241:13): [True: 32, False: 0]
  ------------------
 1242|     32|            sp->strile_height = td->td_rowsperstrip;
 1243|     32|        sp->bytesperline = TIFFScanlineSize(tif);
 1244|     32|    }
 1245|     32|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0)
  ------------------
  |  |  266|     64|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (1245:9): [True: 0, False: 32]
  |  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|     32|    return 1;
 1262|     32|}
tif_jpeg_12.c:TIFFjpeg_start_decompress:
  406|     32|{
  407|     32|    const char *sz_max_allowed_scan_number;
  408|       |    /* progress monitor */
  409|     32|    sp->cinfo.d.progress = &sp->progress;
  410|     32|    sp->progress.progress_monitor = TIFFjpeg_progress_monitor;
  411|     32|    sp->otherSettings.max_allowed_scan_number = 100;
  412|     32|    sz_max_allowed_scan_number = getenv("LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER");
  413|     32|    if (sz_max_allowed_scan_number)
  ------------------
  |  Branch (413:9): [True: 0, False: 32]
  ------------------
  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|     32|#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
  |  |  ------------------
  |  |  |  |  301|     32|#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|     32|#define SETJMP(jbuf) setjmp(jbuf)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (417:12): [True: 32, False: 0]
  ------------------
  418|     32|}
tif_jpeg_12.c:JPEGCleanup:
 2678|      7|{
 2679|      7|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2680|       |
 2681|      7|    assert(sp != 0);
  ------------------
  |  Branch (2681:5): [True: 0, False: 7]
  |  Branch (2681:5): [True: 7, False: 0]
  ------------------
 2682|       |
 2683|      7|    tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent;
 2684|      7|    tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent;
 2685|      7|    tif->tif_tagmethods.printdir = sp->otherSettings.printdir;
 2686|      7|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2686:9): [True: 7, False: 0]
  ------------------
 2687|      7|        TIFFjpeg_destroy(sp);         /* release libjpeg resources */
 2688|      7|    if (sp->otherSettings.jpegtables) /* tag value */
  ------------------
  |  Branch (2688:9): [True: 2, False: 5]
  ------------------
 2689|      2|        _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
 2690|      7|    _TIFFfreeExt(tif, tif->tif_data); /* release local state */
 2691|      7|    tif->tif_data = NULL;
 2692|       |
 2693|      7|    _TIFFSetDefaultCompressionState(tif);
 2694|      7|}
tif_jpeg_12.c:JPEGInitializeLibJPEG:
 2883|      7|{
 2884|      7|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 2885|       |
 2886|      7|    if (sp->cinfo_initialized)
  ------------------
  |  Branch (2886:9): [True: 0, False: 7]
  ------------------
 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|      7|    if (decompress)
  ------------------
  |  Branch (2901:9): [True: 7, False: 0]
  ------------------
 2902|      7|    {
 2903|      7|        if (!TIFFjpeg_create_decompress(sp))
  ------------------
  |  Branch (2903:13): [True: 0, False: 7]
  ------------------
 2904|      0|            return (0);
 2905|      7|    }
 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|      7|    sp->cinfo_initialized = TRUE;
  ------------------
  |  |   71|      7|#define TRUE 1
  ------------------
 2936|       |
 2937|      7|    return 1;
 2938|      7|}
tif_jpeg_12.c:JPEGSetupDecode:
 1136|      7|{
 1137|      7|    JPEGState *sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
 1138|      7|    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|      7|    JPEGInitializeLibJPEG(tif, TRUE);
  ------------------
  |  |   71|      7|#define TRUE 1
  ------------------
 1151|       |
 1152|      7|    assert(sp != NULL);
  ------------------
  |  Branch (1152:5): [True: 0, False: 7]
  |  Branch (1152:5): [True: 7, False: 0]
  ------------------
 1153|      7|    assert(sp->cinfo.comm.is_decompressor);
  ------------------
  |  Branch (1153:5): [True: 0, False: 7]
  |  Branch (1153:5): [True: 7, False: 0]
  ------------------
 1154|       |
 1155|       |    /* Read JPEGTables if it is present */
 1156|      7|    if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
  ------------------
  |  |  248|      7|#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  247|      7|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
  |  |  ------------------
  |  |  |  |  246|      7|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  |  |  |  Branch (248:34): [True: 2, False: 5]
  |  |  ------------------
  ------------------
 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|      5|    sp->photometric = td->td_photometric;
 1168|      5|    switch (sp->photometric)
 1169|      5|    {
 1170|      4|        case PHOTOMETRIC_YCBCR:
  ------------------
  |  |  227|      4|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1170:9): [True: 4, False: 1]
  ------------------
 1171|      4|            sp->h_sampling = td->td_ycbcrsubsampling[0];
 1172|      4|            sp->v_sampling = td->td_ycbcrsubsampling[1];
 1173|      4|            break;
 1174|      1|        default:
  ------------------
  |  Branch (1174:9): [True: 1, False: 4]
  ------------------
 1175|       |            /* TIFF 6.0 forbids subsampling of all other color spaces */
 1176|      1|            sp->h_sampling = 1;
 1177|      1|            sp->v_sampling = 1;
 1178|      1|            break;
 1179|      5|    }
 1180|       |
 1181|       |    /* Set up for reading normal data */
 1182|      5|    TIFFjpeg_data_src(sp);
 1183|      5|    tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
 1184|      5|    return (1);
 1185|      5|}
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|      7|{
   33|      7|    JPEGState *sp;
   34|      7|    uint8_t *new_tif_data;
   35|       |
   36|      7|    (void)scheme;
   37|      7|    assert(scheme == COMPRESSION_JPEG);
  ------------------
  |  Branch (37:5): [True: 0, False: 7]
  |  Branch (37:5): [True: 7, False: 0]
  ------------------
   38|       |
   39|      7|    new_tif_data =
   40|      7|        (uint8_t *)_TIFFreallocExt(tif, tif->tif_data, sizeof(JPEGState));
   41|       |
   42|      7|    if (new_tif_data == NULL)
  ------------------
  |  Branch (42:9): [True: 0, False: 7]
  ------------------
   43|      0|    {
   44|      0|        TIFFErrorExtR(tif, "TIFFReInitJPEG_12",
   45|      0|                      "No space for JPEG state block");
   46|      0|        return 0;
   47|      0|    }
   48|       |
   49|      7|    tif->tif_data = new_tif_data;
   50|      7|    _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
   51|       |
   52|      7|    TIFFInitJPEGCommon(tif);
   53|       |
   54|      7|    sp = JState(tif);
  ------------------
  |  |  208|      7|#define JState(tif) ((JPEGState *)(tif)->tif_data)
  ------------------
   55|      7|    sp->otherSettings = *otherSettings;
   56|       |
   57|      7|    if (is_encode)
  ------------------
  |  Branch (57:9): [True: 0, False: 7]
  ------------------
   58|      0|        return JPEGSetupEncode(tif);
   59|      7|    else
   60|      7|        return JPEGSetupDecode(tif);
   61|      7|}

XYZtoRGB24:
  945|    800|{
  946|    800|    double r, g, b;
  947|       |    /* assume CCIR-709 primaries */
  948|    800|    r = 2.690 * (double)xyz[0] + -1.276 * (double)xyz[1] +
  949|    800|        -0.414 * (double)xyz[2];
  950|    800|    g = -1.022 * (double)xyz[0] + 1.978 * (double)xyz[1] +
  951|    800|        0.044 * (double)xyz[2];
  952|    800|    b = 0.061 * (double)xyz[0] + -0.224 * (double)xyz[1] +
  953|    800|        1.163 * (double)xyz[2];
  954|       |    /* assume 2.0 gamma for speed */
  955|       |    /* could use integer sqrt approx., but this is probably faster */
  956|    800|    rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r)));
  ------------------
  |  Branch (956:24): [True: 42, False: 758]
  |  Branch (956:40): [True: 689, False: 69]
  ------------------
  957|    800|    rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g)));
  ------------------
  |  Branch (957:24): [True: 96, False: 704]
  |  Branch (957:40): [True: 680, False: 24]
  ------------------
  958|    800|    rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b)));
  ------------------
  |  Branch (958:24): [True: 715, False: 85]
  |  Branch (958:40): [True: 27, False: 58]
  ------------------
  959|    800|}
LogL10toY:
  965|    800|{
  966|    800|    if (p10 == 0)
  ------------------
  |  Branch (966:9): [True: 34, False: 766]
  ------------------
  967|     34|        return (0.);
  968|    766|    return (exp(M_LN2 / 64. * (p10 + .5) - M_LN2 * 12.));
  969|    800|}
uv_decode:
 1080|    766|{
 1081|    766|    unsigned int upper, lower;
 1082|    766|    int ui;
 1083|    766|    unsigned int vi;
 1084|       |
 1085|    766|    if (c < 0 || c >= UV_NDIVS)
  ------------------
  |  |    3|    766|#define UV_NDIVS 16289
  ------------------
  |  Branch (1085:9): [True: 0, False: 766]
  |  Branch (1085:18): [True: 3, False: 763]
  ------------------
 1086|      3|        return (-1);
 1087|    763|    lower = 0; /* binary search */
 1088|    763|    upper = UV_NVS;
  ------------------
  |  |    5|    763|#define UV_NVS 163
  ------------------
 1089|  6.80k|    while (upper - lower > 1)
  ------------------
  |  Branch (1089:12): [True: 6.03k, False: 763]
  ------------------
 1090|  6.03k|    {
 1091|  6.03k|        vi = (lower + upper) >> 1;
 1092|  6.03k|        ui = c - uv_row[vi].ncum;
 1093|  6.03k|        if (ui > 0)
  ------------------
  |  Branch (1093:13): [True: 4.94k, False: 1.09k]
  ------------------
 1094|  4.94k|            lower = vi;
 1095|  1.09k|        else if (ui < 0)
  ------------------
  |  Branch (1095:18): [True: 1.09k, False: 0]
  ------------------
 1096|  1.09k|            upper = vi;
 1097|      0|        else
 1098|      0|        {
 1099|      0|            lower = vi;
 1100|      0|            break;
 1101|      0|        }
 1102|  6.03k|    }
 1103|    763|    vi = lower;
 1104|    763|    ui = c - uv_row[vi].ncum;
 1105|    763|    *up = (double)uv_row[vi].ustart + ((double)ui + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    2|    763|#define UV_SQSIZ (float)0.003500
  ------------------
 1106|    763|    *vp = (double)UV_VSTART + ((double)vi + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    4|    763|#define UV_VSTART (float)0.016940
  ------------------
                  *vp = (double)UV_VSTART + ((double)vi + .5) * (double)UV_SQSIZ;
  ------------------
  |  |    2|    763|#define UV_SQSIZ (float)0.003500
  ------------------
 1107|    763|    return (0);
 1108|    766|}
LogLuv24toXYZ:
 1114|    800|{
 1115|    800|    int Ce;
 1116|    800|    double L, u, v, s, x, y;
 1117|       |    /* decode luminance */
 1118|    800|    L = LogL10toY(p >> 14 & 0x3ff);
 1119|    800|    if (L <= 0.)
  ------------------
  |  Branch (1119:9): [True: 34, False: 766]
  ------------------
 1120|     34|    {
 1121|     34|        XYZ[0] = XYZ[1] = XYZ[2] = 0.;
 1122|     34|        return;
 1123|     34|    }
 1124|       |    /* decode color */
 1125|    766|    Ce = p & 0x3fff;
 1126|    766|    if (uv_decode(&u, &v, Ce) < 0)
  ------------------
  |  Branch (1126:9): [True: 3, False: 763]
  ------------------
 1127|      3|    {
 1128|      3|        u = U_NEU;
  ------------------
  |  |  613|      3|#define U_NEU 0.210526316
  ------------------
 1129|      3|        v = V_NEU;
  ------------------
  |  |  614|      3|#define V_NEU 0.473684211
  ------------------
 1130|      3|    }
 1131|    766|    s = 1. / (6. * u - 16. * v + 12.);
 1132|    766|    x = 9. * u * s;
 1133|    766|    y = 4. * v * s;
 1134|       |    /* convert to XYZ */
 1135|    766|    XYZ[0] = (float)(x / y * L);
 1136|    766|    XYZ[1] = (float)L;
 1137|    766|    XYZ[2] = (float)((1. - x - y) / y * L);
 1138|    766|}
TIFFInitSGILog:
 1917|      1|{
 1918|      1|    static const char module[] = "TIFFInitSGILog";
 1919|      1|    LogLuvState *sp;
 1920|       |
 1921|      1|    assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
  ------------------
  |  Branch (1921:5): [True: 1, False: 0]
  |  Branch (1921:5): [True: 0, False: 0]
  |  Branch (1921:5): [True: 1, False: 0]
  |  Branch (1921:5): [True: 0, False: 0]
  ------------------
 1922|       |
 1923|       |    /*
 1924|       |     * Merge codec-specific tag information.
 1925|       |     */
 1926|      1|    if (!_TIFFMergeFields(tif, LogLuvFields, TIFFArrayCount(LogLuvFields)))
  ------------------
  |  |  339|      1|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1926:9): [True: 0, False: 1]
  ------------------
 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|      1|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LogLuvState));
 1936|      1|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1936:9): [True: 0, False: 1]
  ------------------
 1937|      0|        goto bad;
 1938|      1|    sp = (LogLuvState *)tif->tif_data;
 1939|      1|    _TIFFmemset((void *)sp, 0, sizeof(*sp));
 1940|      1|    sp->user_datafmt = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      1|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1941|      1|    sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
  ------------------
  |  |  211|      1|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
                  sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
  ------------------
  |  |  750|      1|#define SGILOGENCODE_RANDITHER 1       /* randomly dither encd values */
  ------------------
  |  Branch (1941:23): [True: 1, False: 0]
  ------------------
 1942|      1|                                                       : SGILOGENCODE_NODITHER;
  ------------------
  |  |  749|      1|#define SGILOGENCODE_NODITHER 0        /* do not dither encoded values*/
  ------------------
 1943|      1|    sp->tfunc = _logLuvNop;
 1944|       |
 1945|       |    /*
 1946|       |     * Install codec methods.
 1947|       |     * NB: tif_decoderow & tif_encoderow are filled
 1948|       |     *     in at setup time.
 1949|       |     */
 1950|      1|    tif->tif_fixuptags = LogLuvFixupTags;
 1951|      1|    tif->tif_setupdecode = LogLuvSetupDecode;
 1952|      1|    tif->tif_decodestrip = LogLuvDecodeStrip;
 1953|      1|    tif->tif_decodetile = LogLuvDecodeTile;
 1954|      1|    tif->tif_setupencode = LogLuvSetupEncode;
 1955|      1|    tif->tif_encodestrip = LogLuvEncodeStrip;
 1956|      1|    tif->tif_encodetile = LogLuvEncodeTile;
 1957|      1|    tif->tif_close = LogLuvClose;
 1958|      1|    tif->tif_cleanup = LogLuvCleanup;
 1959|       |
 1960|       |    /*
 1961|       |     * Override parent get/set field methods.
 1962|       |     */
 1963|      1|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1964|      1|    tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */
 1965|      1|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1966|      1|    tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */
 1967|       |
 1968|      1|    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|      1|}
tif_luv.c:LogLuvFixupTags:
 1630|      1|{
 1631|      1|    (void)tif;
 1632|      1|    return (1);
 1633|      1|}
tif_luv.c:LogLuvSetupDecode:
 1636|      2|{
 1637|      2|    static const char module[] = "LogLuvSetupDecode";
 1638|      2|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|      2|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1639|      2|    TIFFDirectory *td = &tif->tif_dir;
 1640|       |
 1641|      2|    tif->tif_postdecode = _TIFFNoPostDecode;
 1642|      2|    switch (td->td_photometric)
 1643|      2|    {
 1644|      2|        case PHOTOMETRIC_LOGLUV:
  ------------------
  |  |  233|      2|#define PHOTOMETRIC_LOGLUV 32845           /* CIE Log2(L) (u',v') */
  ------------------
  |  Branch (1644:9): [True: 2, False: 0]
  ------------------
 1645|      2|            if (!LogLuvInitState(tif))
  ------------------
  |  Branch (1645:17): [True: 1, False: 1]
  ------------------
 1646|      1|                break;
 1647|      1|            if (td->td_compression == COMPRESSION_SGILOG24)
  ------------------
  |  |  211|      1|#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
  ------------------
  |  Branch (1647:17): [True: 1, False: 0]
  ------------------
 1648|      1|            {
 1649|      1|                tif->tif_decoderow = LogLuvDecode24;
 1650|      1|                switch (sp->user_datafmt)
 1651|      1|                {
 1652|      0|                    case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1652:21): [True: 0, False: 1]
  ------------------
 1653|      0|                        sp->tfunc = Luv24toXYZ;
 1654|      0|                        break;
 1655|      0|                    case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1655:21): [True: 0, False: 1]
  ------------------
 1656|      0|                        sp->tfunc = Luv24toLuv48;
 1657|      0|                        break;
 1658|      1|                    case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      1|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1658:21): [True: 1, False: 0]
  ------------------
 1659|      1|                        sp->tfunc = Luv24toRGB;
 1660|      1|                        break;
 1661|      0|                    default:
  ------------------
  |  Branch (1661:21): [True: 0, False: 1]
  ------------------
 1662|      0|                        break;
 1663|      1|                }
 1664|      1|            }
 1665|      0|            else
 1666|      0|            {
 1667|      0|                tif->tif_decoderow = LogLuvDecode32;
 1668|      0|                switch (sp->user_datafmt)
 1669|      0|                {
 1670|      0|                    case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1670:21): [True: 0, False: 0]
  ------------------
 1671|      0|                        sp->tfunc = Luv32toXYZ;
 1672|      0|                        break;
 1673|      0|                    case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1673:21): [True: 0, False: 0]
  ------------------
 1674|      0|                        sp->tfunc = Luv32toLuv48;
 1675|      0|                        break;
 1676|      0|                    case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      0|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1676:21): [True: 0, False: 0]
  ------------------
 1677|      0|                        sp->tfunc = Luv32toRGB;
 1678|      0|                        break;
 1679|      0|                    default:
  ------------------
  |  Branch (1679:21): [True: 0, False: 0]
  ------------------
 1680|      0|                        break;
 1681|      0|                }
 1682|      0|            }
 1683|      1|            return (1);
 1684|      0|        case PHOTOMETRIC_LOGL:
  ------------------
  |  |  232|      0|#define PHOTOMETRIC_LOGL 32844             /* CIE Log2(L) */
  ------------------
  |  Branch (1684:9): [True: 0, False: 2]
  ------------------
 1685|      0|            if (!LogL16InitState(tif))
  ------------------
  |  Branch (1685:17): [True: 0, False: 0]
  ------------------
 1686|      0|                break;
 1687|      0|            tif->tif_decoderow = LogL16Decode;
 1688|      0|            switch (sp->user_datafmt)
 1689|      0|            {
 1690|      0|                case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1690:17): [True: 0, False: 0]
  ------------------
 1691|      0|                    sp->tfunc = L16toY;
 1692|      0|                    break;
 1693|      0|                case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      0|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1693:17): [True: 0, False: 0]
  ------------------
 1694|      0|                    sp->tfunc = L16toGry;
 1695|      0|                    break;
 1696|      0|                default:
  ------------------
  |  Branch (1696:17): [True: 0, False: 0]
  ------------------
 1697|      0|                    break;
 1698|      0|            }
 1699|      0|            return (1);
 1700|      0|        default:
  ------------------
  |  Branch (1700:9): [True: 0, False: 2]
  ------------------
 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|      2|    }
 1707|      1|    return (0);
 1708|      2|}
tif_luv.c:LogLuvInitState:
 1576|      2|{
 1577|      2|    static const char module[] = "LogLuvInitState";
 1578|      2|    TIFFDirectory *td = &tif->tif_dir;
 1579|      2|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|      2|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1580|       |
 1581|      2|    assert(sp != NULL);
  ------------------
  |  Branch (1581:5): [True: 0, False: 2]
  |  Branch (1581:5): [True: 2, False: 0]
  ------------------
 1582|      2|    assert(td->td_photometric == PHOTOMETRIC_LOGLUV);
  ------------------
  |  Branch (1582:5): [True: 0, False: 2]
  |  Branch (1582:5): [True: 2, False: 0]
  ------------------
 1583|       |
 1584|       |    /* for some reason, we can't do this in TIFFInitLogLuv */
 1585|      2|    if (td->td_planarconfig != PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|      2|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1585:9): [True: 0, False: 2]
  ------------------
 1586|      0|    {
 1587|      0|        TIFFErrorExtR(tif, module,
 1588|      0|                      "SGILog compression cannot handle non-contiguous data");
 1589|      0|        return (0);
 1590|      0|    }
 1591|      2|    if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
  ------------------
  |  |  178|      2|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (1591:9): [True: 1, False: 1]
  ------------------
 1592|      1|        sp->user_datafmt = LogLuvGuessDataFmt(td);
 1593|      2|    switch (sp->user_datafmt)
 1594|      2|    {
 1595|      0|        case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1595:9): [True: 0, False: 2]
  ------------------
 1596|      0|            sp->pixel_size = 3 * sizeof(float);
 1597|      0|            break;
 1598|      0|        case SGILOGDATAFMT_16BIT:
  ------------------
  |  |  745|      0|#define SGILOGDATAFMT_16BIT 1          /* 16-bit samples */
  ------------------
  |  Branch (1598:9): [True: 0, False: 2]
  ------------------
 1599|      0|            sp->pixel_size = 3 * sizeof(int16_t);
 1600|      0|            break;
 1601|      0|        case SGILOGDATAFMT_RAW:
  ------------------
  |  |  746|      0|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1601:9): [True: 0, False: 2]
  ------------------
 1602|      0|            sp->pixel_size = sizeof(uint32_t);
 1603|      0|            break;
 1604|      1|        case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      1|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1604:9): [True: 1, False: 1]
  ------------------
 1605|      1|            sp->pixel_size = 3 * sizeof(uint8_t);
 1606|      1|            break;
 1607|      1|        default:
  ------------------
  |  Branch (1607:9): [True: 1, False: 1]
  ------------------
 1608|      1|            TIFFErrorExtR(
 1609|      1|                tif, module,
 1610|      1|                "No support for converting user data format to LogLuv");
 1611|      1|            return (0);
 1612|      2|    }
 1613|      1|    if (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 (278:22): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1614|      0|        sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
 1615|      1|    else if (td->td_rowsperstrip < td->td_imagelength)
  ------------------
  |  Branch (1615:14): [True: 0, False: 1]
  ------------------
 1616|      0|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
 1617|      1|    else
 1618|      1|        sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
 1619|      1|    if (multiply_ms(sp->tbuflen, sizeof(uint32_t)) == 0 ||
  ------------------
  |  Branch (1619:9): [True: 0, False: 1]
  ------------------
 1620|      1|        (sp->tbuf = (uint8_t *)_TIFFmallocExt(
  ------------------
  |  Branch (1620:9): [True: 0, False: 1]
  ------------------
 1621|      1|             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|      1|    return (1);
 1627|      1|}
tif_luv.c:LogLuvGuessDataFmt:
 1523|      1|{
 1524|      1|    int guess;
 1525|       |
 1526|       |    /*
 1527|       |     * If the user didn't tell us their datafmt,
 1528|       |     * take our best guess from the bitspersample.
 1529|       |     */
 1530|      1|#define PACK(a, b) (((a) << 3) | (b))
 1531|      1|    switch (PACK(td->td_bitspersample, td->td_sampleformat))
  ------------------
  |  | 1530|      1|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
 1532|      1|    {
 1533|      0|        case PACK(32, SAMPLEFORMAT_IEEEFP):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1533:9): [True: 0, False: 1]
  ------------------
 1534|      0|            guess = SGILOGDATAFMT_FLOAT;
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
 1535|      0|            break;
 1536|      0|        case PACK(32, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1536:9): [True: 0, False: 1]
  ------------------
 1537|      0|        case PACK(32, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1537:9): [True: 0, False: 1]
  ------------------
 1538|      0|        case PACK(32, SAMPLEFORMAT_INT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1538:9): [True: 0, False: 1]
  ------------------
 1539|      0|            guess = SGILOGDATAFMT_RAW;
  ------------------
  |  |  746|      0|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
 1540|      0|            break;
 1541|      0|        case PACK(16, SAMPLEFORMAT_VOID):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1541:9): [True: 0, False: 1]
  ------------------
 1542|      0|        case PACK(16, SAMPLEFORMAT_INT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1542:9): [True: 0, False: 1]
  ------------------
 1543|      0|        case PACK(16, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1543:9): [True: 0, False: 1]
  ------------------
 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: 1]
  ------------------
 1547|      0|        case PACK(8, SAMPLEFORMAT_UINT):
  ------------------
  |  | 1530|      0|#define PACK(a, b) (((a) << 3) | (b))
  ------------------
  |  Branch (1547:9): [True: 0, False: 1]
  ------------------
 1548|      0|            guess = SGILOGDATAFMT_8BIT;
  ------------------
  |  |  747|      0|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
 1549|      0|            break;
 1550|      1|        default:
  ------------------
  |  Branch (1550:9): [True: 1, False: 0]
  ------------------
 1551|      1|            guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      1|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1552|      1|            break;
 1553|      1|#undef PACK
 1554|      1|    }
 1555|       |    /*
 1556|       |     * Double-check samples per pixel.
 1557|       |     */
 1558|      1|    switch (td->td_samplesperpixel)
 1559|      1|    {
 1560|      0|        case 1:
  ------------------
  |  Branch (1560:9): [True: 0, False: 1]
  ------------------
 1561|      0|            if (guess != SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|      0|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1561:17): [True: 0, False: 0]
  ------------------
 1562|      0|                guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      0|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1563|      0|            break;
 1564|      1|        case 3:
  ------------------
  |  Branch (1564:9): [True: 1, False: 0]
  ------------------
 1565|      1|            if (guess == SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|      1|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (1565:17): [True: 0, False: 1]
  ------------------
 1566|      0|                guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      0|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1567|      1|            break;
 1568|      0|        default:
  ------------------
  |  Branch (1568:9): [True: 0, False: 1]
  ------------------
 1569|      0|            guess = SGILOGDATAFMT_UNKNOWN;
  ------------------
  |  |  178|      0|#define SGILOGDATAFMT_UNKNOWN -1
  ------------------
 1570|      0|            break;
 1571|      1|    }
 1572|      1|    return (guess);
 1573|      1|}
tif_luv.c:multiply_ms:
 1466|      2|{
 1467|      2|    return _TIFFMultiplySSize(NULL, m1, m2, NULL);
 1468|      2|}
tif_luv.c:LogLuvDecode24:
  265|     16|{
  266|     16|    static const char module[] = "LogLuvDecode24";
  267|     16|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     16|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
  268|     16|    tmsize_t cc;
  269|     16|    tmsize_t i;
  270|     16|    tmsize_t npixels;
  271|     16|    unsigned char *bp;
  272|     16|    uint32_t *tp;
  273|       |
  274|     16|    (void)s;
  275|     16|    assert(s == 0);
  ------------------
  |  Branch (275:5): [True: 0, False: 16]
  |  Branch (275:5): [True: 16, False: 0]
  ------------------
  276|     16|    assert(sp != NULL);
  ------------------
  |  Branch (276:5): [True: 0, False: 16]
  |  Branch (276:5): [True: 16, False: 0]
  ------------------
  277|       |
  278|     16|    npixels = occ / sp->pixel_size;
  279|       |
  280|     16|    if (sp->tbuflen < npixels)
  ------------------
  |  Branch (280:9): [True: 0, False: 16]
  ------------------
  281|      0|    {
  282|      0|        TIFFErrorExtR(tif, module, "Translation buffer too short");
  283|      0|        return (0);
  284|      0|    }
  285|     16|    tp = (uint32_t *)sp->tbuf;
  286|       |    /* copy to array of uint32_t */
  287|     16|    bp = (unsigned char *)tif->tif_rawcp;
  288|     16|    cc = tif->tif_rawcc;
  289|    816|    for (i = 0; i < npixels && cc >= 3; i++)
  ------------------
  |  Branch (289:17): [True: 800, False: 16]
  |  Branch (289:32): [True: 800, False: 0]
  ------------------
  290|    800|    {
  291|    800|        tp[i] = (uint32_t)bp[0] << 16 | (uint32_t)bp[1] << 8 | bp[2];
  292|    800|        bp += 3;
  293|    800|        cc -= 3;
  294|    800|    }
  295|     16|    tif->tif_rawcp = (uint8_t *)bp;
  296|     16|    tif->tif_rawcc = cc;
  297|     16|    if (i != npixels)
  ------------------
  |  Branch (297:9): [True: 0, False: 16]
  ------------------
  298|      0|    {
  299|      0|        TIFFErrorExtR(tif, module,
  300|      0|                      "Not enough data at row %" PRIu32
  301|      0|                      " (short %" TIFF_SSIZE_FORMAT " pixels)",
  302|      0|                      tif->tif_dir.td_row, npixels - i);
  303|      0|        return (0);
  304|      0|    }
  305|     16|    if (sp->user_datafmt == SGILOGDATAFMT_RAW)
  ------------------
  |  |  746|     16|#define SGILOGDATAFMT_RAW 2            /* uninterpreted data */
  ------------------
  |  Branch (305:9): [True: 0, False: 16]
  ------------------
  306|      0|        LuvRawToRaw(sp, op, npixels);
  307|     16|    else
  308|     16|        (*sp->tfunc)(sp, op, npixels);
  309|     16|    return (1);
  310|     16|}
tif_luv.c:Luv24toRGB:
 1212|     16|{
 1213|     16|    uint32_t *luv = (uint32_t *)sp->tbuf;
 1214|     16|    uint8_t *rgb = (uint8_t *)op;
 1215|       |
 1216|    816|    while (n-- > 0)
  ------------------
  |  Branch (1216:12): [True: 800, False: 16]
  ------------------
 1217|    800|    {
 1218|    800|        float xyz[3];
 1219|       |
 1220|    800|        LogLuv24toXYZ(*luv++, xyz);
 1221|    800|        XYZtoRGB24(xyz, rgb);
 1222|    800|        rgb += 3;
 1223|    800|    }
 1224|     16|}
tif_luv.c:LogLuvDecodeStrip:
  393|      1|{
  394|      1|    tmsize_t rowlen = TIFFScanlineSize(tif);
  395|       |
  396|      1|    if (rowlen == 0)
  ------------------
  |  Branch (396:9): [True: 0, False: 1]
  ------------------
  397|      0|        return 0;
  398|       |
  399|      1|    assert(cc % rowlen == 0);
  ------------------
  |  Branch (399:5): [True: 0, False: 1]
  |  Branch (399:5): [True: 1, False: 0]
  ------------------
  400|     17|    while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
  ------------------
  |  Branch (400:12): [True: 16, False: 1]
  |  Branch (400:18): [True: 16, False: 0]
  ------------------
  401|     16|    {
  402|     16|        bp += rowlen;
  403|     16|        cc -= rowlen;
  404|     16|    }
  405|      1|    return (cc == 0);
  406|      1|}
tif_luv.c:LogLuvCleanup:
 1813|      1|{
 1814|      1|    LogLuvState *sp = (LogLuvState *)tif->tif_data;
 1815|       |
 1816|      1|    assert(sp != 0);
  ------------------
  |  Branch (1816:5): [True: 0, False: 1]
  |  Branch (1816:5): [True: 1, False: 0]
  ------------------
 1817|       |
 1818|      1|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1819|      1|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1820|       |
 1821|      1|    if (sp->tbuf)
  ------------------
  |  Branch (1821:9): [True: 1, False: 0]
  ------------------
 1822|      1|        _TIFFfreeExt(tif, sp->tbuf);
 1823|      1|    _TIFFfreeExt(tif, sp);
 1824|      1|    tif->tif_data = NULL;
 1825|       |
 1826|      1|    _TIFFSetDefaultCompressionState(tif);
 1827|      1|}
tif_luv.c:LogLuvVGetField:
 1897|     12|{
 1898|     12|    LogLuvState *sp = (LogLuvState *)tif->tif_data;
 1899|       |
 1900|     12|    switch (tag)
 1901|     12|    {
 1902|      0|        case TIFFTAG_SGILOGDATAFMT:
  ------------------
  |  |  743|      0|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
  |  Branch (1902:9): [True: 0, False: 12]
  ------------------
 1903|      0|            *va_arg(ap, int *) = sp->user_datafmt;
 1904|      0|            return (1);
 1905|     12|        default:
  ------------------
  |  Branch (1905:9): [True: 12, False: 0]
  ------------------
 1906|     12|            return (*sp->vgetparent)(tif, tag, ap);
 1907|     12|    }
 1908|     12|}
tif_luv.c:LogLuvVSetField:
 1830|     10|{
 1831|     10|    static const char module[] = "LogLuvVSetField";
 1832|     10|    LogLuvState *sp = DecoderState(tif);
  ------------------
  |  |  175|     10|#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
  ------------------
 1833|     10|    int bps, fmt;
 1834|       |
 1835|     10|    switch (tag)
 1836|     10|    {
 1837|      1|        case TIFFTAG_SGILOGDATAFMT:
  ------------------
  |  |  743|      1|#define TIFFTAG_SGILOGDATAFMT 65560    /* SGILog user data format */
  ------------------
  |  Branch (1837:9): [True: 1, False: 9]
  ------------------
 1838|      1|            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|      1|            switch (sp->user_datafmt)
 1846|      1|            {
 1847|      0|                case SGILOGDATAFMT_FLOAT:
  ------------------
  |  |  744|      0|#define SGILOGDATAFMT_FLOAT 0          /* IEEE float samples */
  ------------------
  |  Branch (1847:17): [True: 0, False: 1]
  ------------------
 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: 1]
  ------------------
 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: 1]
  ------------------
 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|      1|                case SGILOGDATAFMT_8BIT:
  ------------------
  |  |  747|      1|#define SGILOGDATAFMT_8BIT 3           /* 8-bit RGB monitor values */
  ------------------
  |  Branch (1860:17): [True: 1, False: 0]
  ------------------
 1861|      1|                    bps = 8;
 1862|      1|                    fmt = SAMPLEFORMAT_UINT;
  ------------------
  |  |  334|      1|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
 1863|      1|                    break;
 1864|      0|                default:
  ------------------
  |  Branch (1864:17): [True: 0, False: 1]
  ------------------
 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|      1|            }
 1871|      1|            TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
  ------------------
  |  |  180|      1|#define TIFFTAG_BITSPERSAMPLE 258     /* bits per channel (sample) */
  ------------------
 1872|      1|            TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt);
  ------------------
  |  |  333|      1|#define TIFFTAG_SAMPLEFORMAT 339           /* !data sample format */
  ------------------
 1873|       |            /*
 1874|       |             * Must recalculate sizes should bits/sample change.
 1875|       |             */
 1876|      1|            tif->tif_dir.td_tilesize =
 1877|      1|                isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)-1;
  ------------------
  |  |  278|      1|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|      1|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1878|      1|            tif->tif_dir.td_scanlinesize = TIFFScanlineSize(tif);
 1879|      1|            return (1);
 1880|      0|        case TIFFTAG_SGILOGENCODE:
  ------------------
  |  |  748|      0|#define TIFFTAG_SGILOGENCODE 65561     /* SGILog data encoding control*/
  ------------------
  |  Branch (1880:9): [True: 0, False: 10]
  ------------------
 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|      9|        default:
  ------------------
  |  Branch (1891:9): [True: 9, False: 1]
  ------------------
 1892|      9|            return (*sp->vsetparent)(tif, tag, ap);
 1893|     10|    }
 1894|     10|}

TIFFInitLZW:
 1411|     94|{
 1412|     94|    static const char module[] = "TIFFInitLZW";
 1413|     94|    (void)scheme;
 1414|     94|    assert(scheme == COMPRESSION_LZW);
  ------------------
  |  Branch (1414:5): [True: 0, False: 94]
  |  Branch (1414:5): [True: 94, False: 0]
  ------------------
 1415|       |    /*
 1416|       |     * Allocate state block so tag methods have storage to record values.
 1417|       |     */
 1418|     94|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState));
 1419|     94|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1419:9): [True: 0, False: 94]
  ------------------
 1420|      0|        goto bad;
 1421|     94|    LZWDecoderState(tif)->dec_codetab = NULL;
  ------------------
  |  |  164|     94|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1422|     94|    LZWDecoderState(tif)->dec_decode = NULL;
  ------------------
  |  |  164|     94|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1423|     94|    LZWEncoderState(tif)->enc_hashtab = NULL;
  ------------------
  |  |  165|     94|#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1424|     94|    LZWState(tif)->rw_mode = tif->tif_mode;
  ------------------
  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  ------------------
 1425|       |
 1426|       |    /*
 1427|       |     * Install codec methods.
 1428|       |     */
 1429|     94|    tif->tif_fixuptags = LZWFixupTags;
 1430|     94|    tif->tif_setupdecode = LZWSetupDecode;
 1431|     94|    tif->tif_predecode = LZWPreDecode;
 1432|     94|    tif->tif_decoderow = LZWDecode;
 1433|     94|    tif->tif_decodestrip = LZWDecode;
 1434|     94|    tif->tif_decodetile = LZWDecode;
 1435|     94|#ifndef LZW_READ_ONLY
 1436|     94|    tif->tif_setupencode = LZWSetupEncode;
 1437|     94|    tif->tif_preencode = LZWPreEncode;
 1438|     94|    tif->tif_postencode = LZWPostEncode;
 1439|     94|    tif->tif_encoderow = LZWEncode;
 1440|     94|    tif->tif_encodestrip = LZWEncode;
 1441|     94|    tif->tif_encodetile = LZWEncode;
 1442|     94|#endif
 1443|     94|    tif->tif_getmaxcompressionratio = LZWGetMaxCompressionRatio;
 1444|     94|    tif->tif_cleanup = LZWCleanup;
 1445|       |    /*
 1446|       |     * Setup predictor setup.
 1447|       |     */
 1448|     94|    (void)TIFFPredictorInit(tif);
 1449|     94|    return (1);
 1450|      0|bad:
 1451|      0|    TIFFErrorExtR(tif, module, "No space for LZW state block");
 1452|      0|    return (0);
 1453|     94|}
tif_lzw.c:LZWFixupTags:
  177|     82|{
  178|     82|    (void)tif;
  179|     82|    return (1);
  180|     82|}
tif_lzw.c:LZWSetupDecode:
  183|    104|{
  184|    104|    static const char module[] = "LZWSetupDecode";
  185|    104|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    104|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    104|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  186|    104|    int code;
  187|       |
  188|    104|    if (sp == NULL)
  ------------------
  |  Branch (188:9): [True: 0, False: 104]
  ------------------
  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|    104|    if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (211:9): [True: 73, False: 31]
  ------------------
  212|     73|    {
  213|     73|        sp->dec_codetab = (code_t *)_TIFFmallocExt(tif, CSIZE * sizeof(code_t));
  ------------------
  |  |   79|     73|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|     73|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  214|     73|        if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (214:13): [True: 0, False: 73]
  ------------------
  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|     73|        code = 255;
  223|     73|        do
  224|  18.6k|        {
  225|  18.6k|            sp->dec_codetab[code].firstchar = (unsigned char)code;
  226|  18.6k|            sp->dec_codetab[code].value = (unsigned char)code;
  227|  18.6k|            sp->dec_codetab[code].repeated = true;
  228|  18.6k|            sp->dec_codetab[code].length = 1;
  229|  18.6k|            sp->dec_codetab[code].next = NULL;
  230|  18.6k|        } while (code--);
  ------------------
  |  Branch (230:18): [True: 18.6k, False: 73]
  ------------------
  231|       |        /*
  232|       |         * Zero-out the unused entries  */
  233|       |        /* Silence false positive */
  234|       |        /* coverity[overrun-buffer-arg] */
  235|     73|        memset(&sp->dec_codetab[CODE_CLEAR], 0,
  ------------------
  |  |   71|     73|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  236|     73|               (CODE_FIRST - CODE_CLEAR) * sizeof(code_t));
  ------------------
  |  |   73|     73|#define CODE_FIRST 258 /* first free code entry */
  ------------------
                             (CODE_FIRST - CODE_CLEAR) * sizeof(code_t));
  ------------------
  |  |   71|     73|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  237|     73|    }
  238|    104|    return (1);
  239|    104|}
tif_lzw.c:LZWPreDecode:
  245|    190|{
  246|    190|    static const char module[] = "LZWPreDecode";
  247|    190|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    190|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    190|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  248|       |
  249|    190|    (void)s;
  250|    190|    assert(sp != NULL);
  ------------------
  |  Branch (250:5): [True: 0, False: 190]
  |  Branch (250:5): [True: 190, False: 0]
  ------------------
  251|    190|    if (sp->dec_codetab == NULL)
  ------------------
  |  Branch (251:9): [True: 0, False: 190]
  ------------------
  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|    190|    if (tif->tif_rawcc >= 2 && tif->tif_rawdata[0] == 0 &&
  ------------------
  |  Branch (261:9): [True: 178, False: 12]
  |  Branch (261:32): [True: 44, False: 134]
  ------------------
  262|     44|        (tif->tif_rawdata[1] & 0x1))
  ------------------
  |  Branch (262:9): [True: 42, False: 2]
  ------------------
  263|     42|    {
  264|     42|#ifdef LZW_COMPAT
  265|     42|        if (!sp->dec_decode)
  ------------------
  |  Branch (265:13): [True: 31, False: 11]
  ------------------
  266|     31|        {
  267|     31|            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|     31|            tif->tif_decoderow = LZWDecodeCompat;
  276|     31|            tif->tif_decodestrip = LZWDecodeCompat;
  277|     31|            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|     31|            (*tif->tif_setupdecode)(tif);
  284|     31|            sp->dec_decode = LZWDecodeCompat;
  285|     31|        }
  286|     42|        sp->lzw_maxcode = MAXCODE(BITS_MIN);
  ------------------
  |  |  103|     42|#define lzw_maxcode base.maxcode
  ------------------
                      sp->lzw_maxcode = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|     42|#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|     42|    }
  296|    148|    else
  297|    148|    {
  298|    148|        sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1;
  ------------------
  |  |  103|    148|#define lzw_maxcode base.maxcode
  ------------------
                      sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1;
  ------------------
  |  |   63|    148|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  299|    148|        sp->dec_decode = LZWDecode;
  300|    148|    }
  301|    190|    sp->lzw_nbits = BITS_MIN;
  ------------------
  |  |  102|    190|#define lzw_nbits base.nbits
  ------------------
                  sp->lzw_nbits = BITS_MIN;
  ------------------
  |  |   68|    190|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  302|    190|    sp->lzw_nextbits = 0;
  ------------------
  |  |  106|    190|#define lzw_nextbits base.nextbits
  ------------------
  303|    190|    sp->lzw_nextdata = 0;
  ------------------
  |  |  105|    190|#define lzw_nextdata base.nextdata
  ------------------
  304|       |
  305|    190|    sp->dec_restart = 0;
  306|    190|    sp->dec_nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|    190|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  307|    190|    sp->dec_bitsleft = 0;
  308|    190|    sp->old_tif_rawcc = 0;
  309|    190|    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|    190|    sp->dec_oldcodep = &sp->dec_codetab[0];
  318|    190|    sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask - 1];
  319|    190|    sp->read_error = 0;
  320|    190|    return (1);
  321|    190|}
tif_lzw.c:LZWDecodeCompat:
  800|     39|{
  801|     39|    static const char module[] = "LZWDecodeCompat";
  802|     39|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|     39|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     39|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  803|     39|    uint8_t *op = (uint8_t *)op0;
  804|     39|    tmsize_t occ = occ0;
  805|     39|    uint8_t *tp;
  806|     39|    uint8_t *bp;
  807|     39|    int code, nbits;
  808|     39|    int len;
  809|     39|    long nextbits, nbitsmask;
  810|     39|    WordType nextdata;
  811|     39|    code_t *codep, *free_entp, *maxcodep, *oldcodep;
  812|       |
  813|     39|    (void)s;
  814|     39|    assert(sp != NULL);
  ------------------
  |  Branch (814:5): [True: 0, False: 39]
  |  Branch (814:5): [True: 39, False: 0]
  ------------------
  815|       |
  816|       |    /*
  817|       |     * Restart interrupted output operation.
  818|       |     */
  819|     39|    if (sp->dec_restart)
  ------------------
  |  Branch (819:9): [True: 0, False: 39]
  ------------------
  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|     39|    bp = (uint8_t *)tif->tif_rawcp;
  861|       |
  862|     39|    sp->dec_bitsleft +=
  863|     39|        (((uint64_t)tif->tif_rawcc - (uint64_t)sp->old_tif_rawcc) << 3);
  864|     39|    uint64_t dec_bitsleft = sp->dec_bitsleft;
  865|       |
  866|     39|    nbits = sp->lzw_nbits;
  ------------------
  |  |  102|     39|#define lzw_nbits base.nbits
  ------------------
  867|     39|    nextdata = sp->lzw_nextdata;
  ------------------
  |  |  105|     39|#define lzw_nextdata base.nextdata
  ------------------
  868|     39|    nextbits = sp->lzw_nextbits;
  ------------------
  |  |  106|     39|#define lzw_nextbits base.nextbits
  ------------------
  869|     39|    nbitsmask = sp->dec_nbitsmask;
  870|     39|    oldcodep = sp->dec_oldcodep;
  871|     39|    free_entp = sp->dec_free_entp;
  872|     39|    maxcodep = sp->dec_maxcodep;
  873|       |
  874|  32.0k|    while (occ > 0)
  ------------------
  |  Branch (874:12): [True: 32.0k, False: 7]
  ------------------
  875|  32.0k|    {
  876|  32.0k|        NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  ------------------
  |  |  766|  32.0k|    {                                                                          \
  |  |  767|  32.0k|        if (dec_bitsleft < (uint64_t)nbits)                                    \
  |  |  ------------------
  |  |  |  Branch (767:13): [True: 3, False: 32.0k]
  |  |  ------------------
  |  |  768|  32.0k|        {                                                                      \
  |  |  769|      3|            TIFFWarningExtR(_tif, module,                                      \
  |  |  770|      3|                            "LZWDecode: Strip %" PRIu32                        \
  |  |  771|      3|                            " not terminated with EOI code",                   \
  |  |  772|      3|                            _tif->tif_dir.td_curstrip);                        \
  |  |  773|      3|            _code = CODE_EOI;                                                  \
  |  |  ------------------
  |  |  |  |   72|      3|#define CODE_EOI 257   /* end-of-information code */
  |  |  ------------------
  |  |  774|      3|        }                                                                      \
  |  |  775|  32.0k|        else                                                                   \
  |  |  776|  32.0k|        {                                                                      \
  |  |  777|  32.0k|            _get(_sp, _bp, _code);                                             \
  |  |  ------------------
  |  |  |  |  876|  32.0k|        NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  |  |  |  |  ------------------
  |  |  |  |  |  |  786|  32.0k|    {                                                                          \
  |  |  |  |  |  |  787|  32.0k|        nextdata |= (unsigned long)*(bp)++ << nextbits;                        \
  |  |  |  |  |  |  788|  32.0k|        nextbits += 8;                                                         \
  |  |  |  |  |  |  789|  32.0k|        if (nextbits < nbits)                                                  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (789:13): [True: 11.4k, False: 20.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  790|  32.0k|        {                                                                      \
  |  |  |  |  |  |  791|  11.4k|            nextdata |= (unsigned long)*(bp)++ << nextbits;                    \
  |  |  |  |  |  |  792|  11.4k|            nextbits += 8;                                                     \
  |  |  |  |  |  |  793|  11.4k|        }                                                                      \
  |  |  |  |  |  |  794|  32.0k|        code = (hcode_t)(nextdata & (unsigned long)nbitsmask);                 \
  |  |  |  |  |  |  795|  32.0k|        nextdata >>= nbits;                                                    \
  |  |  |  |  |  |  796|  32.0k|        nextbits -= nbits;                                                     \
  |  |  |  |  |  |  797|  32.0k|    }
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  778|  32.0k|            dec_bitsleft -= (uint64_t)nbits;                                   \
  |  |  779|  32.0k|        }                                                                      \
  |  |  780|  32.0k|    }
  ------------------
  877|  32.0k|        if (code == CODE_EOI)
  ------------------
  |  |   72|  32.0k|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (877:13): [True: 3, False: 32.0k]
  ------------------
  878|      3|            break;
  879|  32.0k|        if (code == CODE_CLEAR)
  ------------------
  |  |   71|  32.0k|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (879:13): [True: 64, False: 31.9k]
  ------------------
  880|     64|        {
  881|     64|            do
  882|     64|            {
  883|     64|                free_entp = sp->dec_codetab + CODE_FIRST;
  ------------------
  |  |   73|     64|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  884|     64|                _TIFFmemset(free_entp, 0,
  885|     64|                            (CSIZE - CODE_FIRST) * sizeof(code_t));
  ------------------
  |  |   79|     64|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|     64|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
                                          (CSIZE - CODE_FIRST) * sizeof(code_t));
  ------------------
  |  |   73|     64|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  886|     64|                nbits = BITS_MIN;
  ------------------
  |  |   68|     64|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  887|     64|                nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|     64|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  888|     64|                maxcodep = sp->dec_codetab + nbitsmask;
  889|     64|                NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  ------------------
  |  |  766|     64|    {                                                                          \
  |  |  767|     64|        if (dec_bitsleft < (uint64_t)nbits)                                    \
  |  |  ------------------
  |  |  |  Branch (767:13): [True: 0, False: 64]
  |  |  ------------------
  |  |  768|     64|        {                                                                      \
  |  |  769|      0|            TIFFWarningExtR(_tif, module,                                      \
  |  |  770|      0|                            "LZWDecode: Strip %" PRIu32                        \
  |  |  771|      0|                            " not terminated with EOI code",                   \
  |  |  772|      0|                            _tif->tif_dir.td_curstrip);                        \
  |  |  773|      0|            _code = CODE_EOI;                                                  \
  |  |  ------------------
  |  |  |  |   72|      0|#define CODE_EOI 257   /* end-of-information code */
  |  |  ------------------
  |  |  774|      0|        }                                                                      \
  |  |  775|     64|        else                                                                   \
  |  |  776|     64|        {                                                                      \
  |  |  777|     64|            _get(_sp, _bp, _code);                                             \
  |  |  ------------------
  |  |  |  |  889|     64|                NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
  |  |  |  |  ------------------
  |  |  |  |  |  |  786|     64|    {                                                                          \
  |  |  |  |  |  |  787|     64|        nextdata |= (unsigned long)*(bp)++ << nextbits;                        \
  |  |  |  |  |  |  788|     64|        nextbits += 8;                                                         \
  |  |  |  |  |  |  789|     64|        if (nextbits < nbits)                                                  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (789:13): [True: 13, False: 51]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  790|     64|        {                                                                      \
  |  |  |  |  |  |  791|     13|            nextdata |= (unsigned long)*(bp)++ << nextbits;                    \
  |  |  |  |  |  |  792|     13|            nextbits += 8;                                                     \
  |  |  |  |  |  |  793|     13|        }                                                                      \
  |  |  |  |  |  |  794|     64|        code = (hcode_t)(nextdata & (unsigned long)nbitsmask);                 \
  |  |  |  |  |  |  795|     64|        nextdata >>= nbits;                                                    \
  |  |  |  |  |  |  796|     64|        nextbits -= nbits;                                                     \
  |  |  |  |  |  |  797|     64|    }
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  778|     64|            dec_bitsleft -= (uint64_t)nbits;                                   \
  |  |  779|     64|        }                                                                      \
  |  |  780|     64|    }
  ------------------
  890|     64|            } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
  ------------------
  |  |   71|     64|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (890:22): [True: 0, False: 64]
  ------------------
  891|     64|            if (code == CODE_EOI)
  ------------------
  |  |   72|     64|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (891:17): [True: 9, False: 55]
  ------------------
  892|      9|                break;
  893|     55|            if (code > CODE_CLEAR)
  ------------------
  |  |   71|     55|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (893:17): [True: 2, False: 53]
  ------------------
  894|      2|            {
  895|      2|                TIFFErrorExtR(
  896|      2|                    tif, tif->tif_name,
  897|      2|                    "LZWDecode: Corrupted LZW table at scanline %" PRIu32,
  898|      2|                    tif->tif_dir.td_row);
  899|      2|                return (0);
  900|      2|            }
  901|     53|            *op++ = (uint8_t)code;
  902|     53|            occ--;
  903|     53|            oldcodep = sp->dec_codetab + code;
  904|     53|            continue;
  905|     55|        }
  906|  31.9k|        codep = sp->dec_codetab + code;
  907|       |
  908|       |        /*
  909|       |         * Add the new entry to the code table.
  910|       |         */
  911|  31.9k|        if (free_entp < &sp->dec_codetab[0] ||
  ------------------
  |  Branch (911:13): [True: 0, False: 31.9k]
  ------------------
  912|  31.9k|            free_entp >= &sp->dec_codetab[CSIZE])
  ------------------
  |  |   79|  31.9k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  31.9k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (912:13): [True: 1, False: 31.9k]
  ------------------
  913|      1|        {
  914|      1|            TIFFErrorExtR(tif, module,
  915|      1|                          "Corrupted LZW table at scanline %" PRIu32,
  916|      1|                          tif->tif_dir.td_row);
  917|      1|            return (0);
  918|      1|        }
  919|       |
  920|  31.9k|        free_entp->next = oldcodep;
  921|  31.9k|        if (free_entp->next < &sp->dec_codetab[0] ||
  ------------------
  |  Branch (921:13): [True: 0, False: 31.9k]
  ------------------
  922|  31.9k|            free_entp->next >= &sp->dec_codetab[CSIZE])
  ------------------
  |  |   79|  31.9k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  31.9k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (922:13): [True: 0, False: 31.9k]
  ------------------
  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|  31.9k|        free_entp->firstchar = free_entp->next->firstchar;
  930|  31.9k|        free_entp->length = (uint16_t)(free_entp->next->length + 1);
  931|  31.9k|        free_entp->value =
  932|  31.9k|            (codep < free_entp) ? codep->firstchar : free_entp->firstchar;
  ------------------
  |  Branch (932:13): [True: 31.9k, False: 17]
  ------------------
  933|  31.9k|        if (++free_entp > maxcodep)
  ------------------
  |  Branch (933:13): [True: 2.87k, False: 29.1k]
  ------------------
  934|  2.87k|        {
  935|  2.87k|            if (++nbits > BITS_MAX) /* should not happen */
  ------------------
  |  |   69|  2.87k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (935:17): [True: 2.84k, False: 29]
  ------------------
  936|  2.84k|                nbits = BITS_MAX;
  ------------------
  |  |   69|  2.84k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  937|  2.87k|            nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|  2.87k|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  938|  2.87k|            maxcodep = sp->dec_codetab + nbitsmask;
  939|  2.87k|        }
  940|  31.9k|        oldcodep = codep;
  941|  31.9k|        if (code >= 256)
  ------------------
  |  Branch (941:13): [True: 1.35k, False: 30.6k]
  ------------------
  942|  1.35k|        {
  943|       |            /*
  944|       |             * Code maps to a string, copy string
  945|       |             * value to output (written in reverse).
  946|       |             */
  947|  1.35k|            if (codep->length == 0)
  ------------------
  |  Branch (947:17): [True: 17, False: 1.33k]
  ------------------
  948|     17|            {
  949|     17|                TIFFErrorExtR(
  950|     17|                    tif, module,
  951|     17|                    "Wrong length of decoded "
  952|     17|                    "string: data probably corrupted at scanline %" PRIu32,
  953|     17|                    tif->tif_dir.td_row);
  954|     17|                return (0);
  955|     17|            }
  956|  1.33k|            if (codep->length > occ)
  ------------------
  |  Branch (956:17): [True: 0, False: 1.33k]
  ------------------
  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|  1.33k|            len = codep->length;
  979|  1.33k|            tp = op + len;
  980|  1.33k|            do
  981|  2.67k|            {
  982|  2.67k|                *--tp = codep->value;
  983|  2.67k|                codep = codep->next;
  984|  2.67k|            } while (codep && tp > op);
  ------------------
  |  Branch (984:22): [True: 1.34k, False: 1.33k]
  |  Branch (984:31): [True: 1.34k, False: 0]
  ------------------
  985|  1.33k|            assert(occ >= len);
  ------------------
  |  Branch (985:13): [True: 0, False: 1.33k]
  |  Branch (985:13): [True: 1.33k, False: 0]
  ------------------
  986|  1.33k|            op += len;
  987|  1.33k|            occ -= len;
  988|  1.33k|        }
  989|  30.6k|        else
  990|  30.6k|        {
  991|  30.6k|            *op++ = (uint8_t)code;
  992|  30.6k|            occ--;
  993|  30.6k|        }
  994|  31.9k|    }
  995|       |
  996|     19|    tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
  997|     19|    tif->tif_rawcp = (uint8_t *)bp;
  998|       |
  999|     19|    sp->old_tif_rawcc = tif->tif_rawcc;
 1000|     19|    sp->dec_bitsleft = dec_bitsleft;
 1001|       |
 1002|     19|    sp->lzw_nbits = (unsigned short)nbits;
  ------------------
  |  |  102|     19|#define lzw_nbits base.nbits
  ------------------
 1003|     19|    sp->lzw_nextdata = nextdata;
  ------------------
  |  |  105|     19|#define lzw_nextdata base.nextdata
  ------------------
 1004|     19|    sp->lzw_nextbits = nextbits;
  ------------------
  |  |  106|     19|#define lzw_nextbits base.nextbits
  ------------------
 1005|     19|    sp->dec_nbitsmask = nbitsmask;
 1006|     19|    sp->dec_oldcodep = oldcodep;
 1007|     19|    sp->dec_free_entp = free_entp;
 1008|     19|    sp->dec_maxcodep = maxcodep;
 1009|       |
 1010|     19|    if (occ > 0)
  ------------------
  |  Branch (1010:9): [True: 12, False: 7]
  ------------------
 1011|     12|    {
 1012|     12|        TIFFErrorExtR(tif, module,
 1013|     12|                      "Not enough data at scanline %" PRIu32 " (short %" PRIu64
 1014|     12|                      " bytes)",
 1015|     12|                      tif->tif_dir.td_row, (uint64_t)occ);
 1016|     12|        return (0);
 1017|     12|    }
 1018|      7|    return (1);
 1019|     19|}
tif_lzw.c:LZWDecode:
  403|    151|{
  404|    151|    static const char module[] = "LZWDecode";
  405|    151|    LZWCodecState *sp = LZWDecoderState(tif);
  ------------------
  |  |  164|    151|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|    151|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  406|    151|    uint8_t *op = (uint8_t *)op0;
  407|    151|    tmsize_t occ = occ0;
  408|    151|    uint8_t *bp;
  409|    151|    long nbits, nextbits, nbitsmask;
  410|    151|    WordType nextdata;
  411|    151|    code_t *free_entp, *maxcodep, *oldcodep;
  412|       |
  413|    151|    (void)s;
  414|    151|    assert(sp != NULL);
  ------------------
  |  Branch (414:5): [True: 0, False: 151]
  |  Branch (414:5): [True: 151, False: 0]
  ------------------
  415|    151|    assert(sp->dec_codetab != NULL);
  ------------------
  |  Branch (415:5): [True: 0, False: 151]
  |  Branch (415:5): [True: 151, False: 0]
  ------------------
  416|       |
  417|    151|    if (sp->read_error)
  ------------------
  |  Branch (417:9): [True: 0, False: 151]
  ------------------
  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|    151|    if (sp->dec_restart)
  ------------------
  |  Branch (430:9): [True: 0, False: 151]
  ------------------
  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|    151|    bp = (uint8_t *)tif->tif_rawcp;
  475|    151|    sp->dec_bitsleft +=
  476|    151|        (((uint64_t)tif->tif_rawcc - (uint64_t)sp->old_tif_rawcc) << 3);
  477|    151|    uint64_t dec_bitsleft = sp->dec_bitsleft;
  478|    151|    nbits = sp->lzw_nbits;
  ------------------
  |  |  102|    151|#define lzw_nbits base.nbits
  ------------------
  479|    151|    nextdata = sp->lzw_nextdata;
  ------------------
  |  |  105|    151|#define lzw_nextdata base.nextdata
  ------------------
  480|    151|    nextbits = sp->lzw_nextbits;
  ------------------
  |  |  106|    151|#define lzw_nextbits base.nextbits
  ------------------
  481|    151|    nbitsmask = sp->dec_nbitsmask;
  482|    151|    oldcodep = sp->dec_oldcodep;
  483|    151|    free_entp = sp->dec_free_entp;
  484|    151|    maxcodep = sp->dec_maxcodep;
  485|    151|    code_t *const dec_codetab = sp->dec_codetab;
  486|    151|    code_t *codep;
  487|       |
  488|    151|    if (occ == 0)
  ------------------
  |  Branch (488:9): [True: 0, False: 151]
  ------------------
  489|      0|    {
  490|      0|        goto after_loop;
  491|      0|    }
  492|       |
  493|   151k|begin:
  494|   151k|{
  495|   151k|    WordType code;
  496|   151k|    GetNextCodeLZW();
  ------------------
  |  |  362|   151k|    do                                                                         \
  |  |  363|   151k|    {                                                                          \
  |  |  364|   151k|        nextbits -= nbits;                                                     \
  |  |  365|   151k|        if (nextbits < 0)                                                      \
  |  |  ------------------
  |  |  |  Branch (365:13): [True: 26.3k, False: 124k]
  |  |  ------------------
  |  |  366|   151k|        {                                                                      \
  |  |  367|  26.3k|            if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE)                           \
  |  |  ------------------
  |  |  |  |   45|  26.3k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  26.3k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (367:17): [True: 26.2k, False: 36]
  |  |  ------------------
  |  |  368|  26.3k|            {                                                                  \
  |  |  369|  26.2k|                unsigned codetmp = (unsigned)(nextdata << (-nextbits));        \
  |  |  370|  26.2k|                GetNextData(nextdata, bp);                                     \
  |  |  ------------------
  |  |  |  |  335|  26.2k|    memcpy(&nextdata, bp, sizeof(nextdata));                                   \
  |  |  |  |  336|  26.2k|    nextdata = __builtin_bswap64(nextdata)
  |  |  ------------------
  |  |  371|  26.2k|                bp += SIZEOF_WORDTYPE;                                         \
  |  |  ------------------
  |  |  |  |   45|  26.2k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  26.2k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  26.2k|                nextbits += 8 * SIZEOF_WORDTYPE;                               \
  |  |  ------------------
  |  |  |  |   45|  26.2k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  26.2k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  373|  26.2k|                dec_bitsleft -= 8 * SIZEOF_WORDTYPE;                           \
  |  |  ------------------
  |  |  |  |   45|  26.2k|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|  26.2k|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  374|  26.2k|                code = (WordType)((codetmp | (nextdata >> nextbits)) &         \
  |  |  375|  26.2k|                                  (WordType)nbitsmask);                        \
  |  |  376|  26.2k|                break;                                                         \
  |  |  377|  26.2k|            }                                                                  \
  |  |  378|  26.3k|            else                                                               \
  |  |  379|  26.3k|            {                                                                  \
  |  |  380|     36|                if (dec_bitsleft < 8)                                          \
  |  |  ------------------
  |  |  |  Branch (380:21): [True: 5, False: 31]
  |  |  ------------------
  |  |  381|     36|                {                                                              \
  |  |  382|      5|                    goto no_eoi;                                               \
  |  |  383|      5|                }                                                              \
  |  |  384|     36|                nextdata = (nextdata << 8) | *(bp)++;                          \
  |  |  385|     31|                nextbits += 8;                                                 \
  |  |  386|     31|                dec_bitsleft -= 8;                                             \
  |  |  387|     31|                if (nextbits < 0)                                              \
  |  |  ------------------
  |  |  |  Branch (387:21): [True: 20, False: 11]
  |  |  ------------------
  |  |  388|     31|                {                                                              \
  |  |  389|     20|                    if (dec_bitsleft < 8)                                      \
  |  |  ------------------
  |  |  |  Branch (389:25): [True: 13, False: 7]
  |  |  ------------------
  |  |  390|     20|                    {                                                          \
  |  |  391|     13|                        goto no_eoi;                                           \
  |  |  392|     13|                    }                                                          \
  |  |  393|     20|                    nextdata = (nextdata << 8) | *(bp)++;                      \
  |  |  394|      7|                    nextbits += 8;                                             \
  |  |  395|      7|                    dec_bitsleft -= 8;                                         \
  |  |  396|      7|                }                                                              \
  |  |  397|     31|            }                                                                  \
  |  |  398|  26.3k|        }                                                                      \
  |  |  399|   151k|        code = (WordType)((nextdata >> nextbits) & (WordType)nbitsmask);       \
  |  |  400|   124k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (400:14): [Folded, False: 124k]
  |  |  ------------------
  ------------------
  497|   150k|    codep = dec_codetab + (unsigned long)code;
  498|   150k|    if (code >= CODE_FIRST)
  ------------------
  |  |   73|   150k|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  |  Branch (498:9): [True: 3.50k, False: 147k]
  ------------------
  499|  3.50k|        goto code_above_or_equal_to_258;
  500|   147k|    if (code < 256)
  ------------------
  |  Branch (500:9): [True: 147k, False: 106]
  ------------------
  501|   147k|        goto code_below_256;
  502|    106|    if (code == CODE_EOI)
  ------------------
  |  |   72|    106|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (502:9): [True: 0, False: 106]
  ------------------
  503|      0|        goto after_loop;
  504|    106|    goto code_clear;
  505|       |
  506|   147k|code_below_256:
  507|   147k|{
  508|   147k|    if (codep > free_entp)
  ------------------
  |  Branch (508:9): [True: 92, False: 147k]
  ------------------
  509|     92|        goto error_code;
  510|   147k|    free_entp->next = oldcodep;
  511|   147k|    free_entp->firstchar = oldcodep->firstchar;
  512|   147k|    free_entp->length = (uint16_t)(oldcodep->length + 1);
  513|   147k|    free_entp->value = (uint8_t)code;
  514|   147k|    free_entp->repeated =
  515|   147k|        (bool)(oldcodep->repeated & (oldcodep->value == code));
  516|   147k|    if (++free_entp > maxcodep)
  ------------------
  |  Branch (516:9): [True: 19.3k, False: 127k]
  ------------------
  517|  19.3k|    {
  518|  19.3k|        if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
  ------------------
  |  |   69|  19.3k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (518:13): [True: 19.2k, False: 134]
  ------------------
  519|  19.2k|            nbits = BITS_MAX;
  ------------------
  |  |   69|  19.2k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  520|  19.3k|        nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|  19.3k|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  521|  19.3k|        maxcodep = dec_codetab + nbitsmask - 1;
  522|  19.3k|        if (free_entp >= &dec_codetab[CSIZE])
  ------------------
  |  |   79|  19.3k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  19.3k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (522:13): [True: 11, False: 19.3k]
  ------------------
  523|     11|        {
  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|     11|            free_entp = dec_codetab - 1;
  529|     11|        }
  530|  19.3k|    }
  531|   147k|    oldcodep = codep;
  532|   147k|    *op++ = (uint8_t)code;
  533|   147k|    occ--;
  534|   147k|    if (occ == 0)
  ------------------
  |  Branch (534:9): [True: 0, False: 147k]
  ------------------
  535|      0|        goto after_loop;
  536|   147k|    goto begin;
  537|   147k|}
  538|       |
  539|   147k|code_above_or_equal_to_258:
  540|  3.50k|{
  541|       |    /*
  542|       |     * Add the new entry to the code table.
  543|       |     */
  544|       |
  545|  3.50k|    if (codep >= free_entp)
  ------------------
  |  Branch (545:9): [True: 88, False: 3.41k]
  ------------------
  546|     88|    {
  547|     88|        if (codep != free_entp)
  ------------------
  |  Branch (547:13): [True: 29, False: 59]
  ------------------
  548|     29|            goto error_code;
  549|     59|        free_entp->value = oldcodep->firstchar;
  550|     59|    }
  551|  3.41k|    else
  552|  3.41k|    {
  553|  3.41k|        free_entp->value = codep->firstchar;
  554|  3.41k|    }
  555|  3.47k|    free_entp->repeated =
  556|  3.47k|        (bool)(oldcodep->repeated & (oldcodep->value == free_entp->value));
  557|  3.47k|    free_entp->next = oldcodep;
  558|       |
  559|  3.47k|    free_entp->firstchar = oldcodep->firstchar;
  560|  3.47k|    free_entp->length = (uint16_t)(oldcodep->length + 1);
  561|  3.47k|    if (++free_entp > maxcodep)
  ------------------
  |  Branch (561:9): [True: 1.10k, False: 2.36k]
  ------------------
  562|  1.10k|    {
  563|  1.10k|        if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
  ------------------
  |  |   69|  1.10k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  |  Branch (563:13): [True: 1.10k, False: 0]
  ------------------
  564|  1.10k|            nbits = BITS_MAX;
  ------------------
  |  |   69|  1.10k|#define BITS_MAX 12 /* max of 12 bit strings */
  ------------------
  565|  1.10k|        nbitsmask = MAXCODE(nbits);
  ------------------
  |  |   63|  1.10k|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  566|  1.10k|        maxcodep = dec_codetab + nbitsmask - 1;
  567|  1.10k|        if (free_entp >= &dec_codetab[CSIZE])
  ------------------
  |  |   79|  1.10k|#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
  |  |  ------------------
  |  |  |  |   63|  1.10k|#define MAXCODE(n) ((1 << (n)) - 1)
  |  |  ------------------
  ------------------
  |  Branch (567:13): [True: 6, False: 1.10k]
  ------------------
  568|      6|        {
  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|      6|            free_entp = dec_codetab - 1;
  574|      6|        }
  575|  1.10k|    }
  576|  3.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|  3.47k|    unsigned short len = codep->length;
  584|       |
  585|  3.47k|    if (len < 3) /* equivalent to len == 2 given all other conditions */
  ------------------
  |  Branch (585:9): [True: 3.12k, False: 348]
  ------------------
  586|  3.12k|    {
  587|  3.12k|        if (occ <= 2)
  ------------------
  |  Branch (587:13): [True: 0, False: 3.12k]
  ------------------
  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|  3.12k|        memcpy(op, &(codep->firstchar), 2);
  600|  3.12k|        op += 2;
  601|  3.12k|        occ -= 2;
  602|  3.12k|        goto begin; /* we can save the comparison occ > 0 */
  603|  3.12k|    }
  604|       |
  605|    348|    if (len == 3)
  ------------------
  |  Branch (605:9): [True: 130, False: 218]
  ------------------
  606|    130|    {
  607|    130|        if (occ <= 3)
  ------------------
  |  Branch (607:13): [True: 0, False: 130]
  ------------------
  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|    130|        op[0] = codep->firstchar;
  622|    130|        op[1] = codep->next->value;
  623|    130|        op[2] = codep->value;
  624|    130|        op += 3;
  625|    130|        occ -= 3;
  626|    130|        goto begin; /* we can save the comparison occ > 0 */
  627|    130|    }
  628|       |
  629|    218|    if (len > occ)
  ------------------
  |  Branch (629:9): [True: 0, False: 218]
  ------------------
  630|      0|    {
  631|      0|        goto too_short_buffer;
  632|      0|    }
  633|       |
  634|    218|    if (codep->repeated)
  ------------------
  |  Branch (634:9): [True: 144, False: 74]
  ------------------
  635|    144|    {
  636|    144|        memset(op, codep->value, len);
  637|    144|        op += len;
  638|    144|        occ -= len;
  639|    144|        if (occ == 0)
  ------------------
  |  Branch (639:13): [True: 0, False: 144]
  ------------------
  640|      0|            goto after_loop;
  641|    144|        goto begin;
  642|    144|    }
  643|       |
  644|     74|    uint8_t *tp = op + len;
  645|       |
  646|     74|    assert(len >= 4);
  ------------------
  |  Branch (646:5): [True: 0, False: 74]
  |  Branch (646:5): [True: 74, False: 0]
  ------------------
  647|       |
  648|     74|    *--tp = codep->value;
  649|     74|    codep = codep->next;
  650|     74|    *--tp = codep->value;
  651|     74|    codep = codep->next;
  652|     74|    *--tp = codep->value;
  653|     74|    codep = codep->next;
  654|     74|    *--tp = codep->value;
  655|     74|    if (tp > op)
  ------------------
  |  Branch (655:9): [True: 60, False: 14]
  ------------------
  656|     60|    {
  657|     60|        do
  658|    162|        {
  659|    162|            codep = codep->next;
  660|    162|            *--tp = codep->value;
  661|    162|        } while (tp > op);
  ------------------
  |  Branch (661:18): [True: 102, False: 60]
  ------------------
  662|     60|    }
  663|       |
  664|     74|    assert(occ >= len);
  ------------------
  |  Branch (664:5): [True: 0, False: 74]
  |  Branch (664:5): [True: 74, False: 0]
  ------------------
  665|     74|    op += len;
  666|     74|    occ -= len;
  667|     74|    if (occ == 0)
  ------------------
  |  Branch (667:9): [True: 0, False: 74]
  ------------------
  668|      0|        goto after_loop;
  669|     74|    goto begin;
  670|     74|}
  671|       |
  672|    106|code_clear:
  673|    106|{
  674|    106|    free_entp = dec_codetab + CODE_FIRST;
  ------------------
  |  |   73|    106|#define CODE_FIRST 258 /* first free code entry */
  ------------------
  675|    106|    nbits = BITS_MIN;
  ------------------
  |  |   68|    106|#define BITS_MIN 9  /* start with 9 bits */
  ------------------
  676|    106|    nbitsmask = MAXCODE(BITS_MIN);
  ------------------
  |  |   63|    106|#define MAXCODE(n) ((1 << (n)) - 1)
  ------------------
  677|    106|    maxcodep = dec_codetab + (unsigned long)nbitsmask - 1;
  678|    106|    do
  679|    106|    {
  680|    106|        GetNextCodeLZW();
  ------------------
  |  |  362|    106|    do                                                                         \
  |  |  363|    106|    {                                                                          \
  |  |  364|    106|        nextbits -= nbits;                                                     \
  |  |  365|    106|        if (nextbits < 0)                                                      \
  |  |  ------------------
  |  |  |  Branch (365:13): [True: 15, False: 91]
  |  |  ------------------
  |  |  366|    106|        {                                                                      \
  |  |  367|     15|            if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE)                           \
  |  |  ------------------
  |  |  |  |   45|     15|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|     15|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (367:17): [True: 15, False: 0]
  |  |  ------------------
  |  |  368|     15|            {                                                                  \
  |  |  369|     15|                unsigned codetmp = (unsigned)(nextdata << (-nextbits));        \
  |  |  370|     15|                GetNextData(nextdata, bp);                                     \
  |  |  ------------------
  |  |  |  |  335|     15|    memcpy(&nextdata, bp, sizeof(nextdata));                                   \
  |  |  |  |  336|     15|    nextdata = __builtin_bswap64(nextdata)
  |  |  ------------------
  |  |  371|     15|                bp += SIZEOF_WORDTYPE;                                         \
  |  |  ------------------
  |  |  |  |   45|     15|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|     15|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|     15|                nextbits += 8 * SIZEOF_WORDTYPE;                               \
  |  |  ------------------
  |  |  |  |   45|     15|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|     15|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  373|     15|                dec_bitsleft -= 8 * SIZEOF_WORDTYPE;                           \
  |  |  ------------------
  |  |  |  |   45|     15|#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
  |  |  |  |  ------------------
  |  |  |  |  |  |  116|     15|#define SIZEOF_SIZE_T 8
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  374|     15|                code = (WordType)((codetmp | (nextdata >> nextbits)) &         \
  |  |  375|     15|                                  (WordType)nbitsmask);                        \
  |  |  376|     15|                break;                                                         \
  |  |  377|     15|            }                                                                  \
  |  |  378|     15|            else                                                               \
  |  |  379|     15|            {                                                                  \
  |  |  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|     15|        }                                                                      \
  |  |  399|    106|        code = (WordType)((nextdata >> nextbits) & (WordType)nbitsmask);       \
  |  |  400|     91|    } while (0)
  |  |  ------------------
  |  |  |  Branch (400:14): [Folded, False: 91]
  |  |  ------------------
  ------------------
  681|    106|    } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
  ------------------
  |  |   71|    106|#define CODE_CLEAR 256 /* code to clear string table */
  ------------------
  |  Branch (681:14): [True: 0, False: 106]
  ------------------
  682|    106|    if (code == CODE_EOI)
  ------------------
  |  |   72|    106|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (682:9): [True: 0, False: 106]
  ------------------
  683|      0|        goto after_loop;
  684|    106|    if (code > CODE_EOI)
  ------------------
  |  |   72|    106|#define CODE_EOI 257   /* end-of-information code */
  ------------------
  |  Branch (684:9): [True: 12, False: 94]
  ------------------
  685|     12|    {
  686|     12|        goto error_code;
  687|     12|    }
  688|     94|    *op++ = (uint8_t)code;
  689|     94|    occ--;
  690|     94|    oldcodep = dec_codetab + code;
  691|     94|    if (occ == 0)
  ------------------
  |  Branch (691:9): [True: 0, False: 94]
  ------------------
  692|      0|        goto after_loop;
  693|     94|    goto begin;
  694|     94|}
  695|     94|}
  696|       |
  697|     94|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|      0|after_loop:
  721|      0|    tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
  722|      0|    tif->tif_rawcp = (uint8_t *)bp;
  723|      0|    sp->old_tif_rawcc = tif->tif_rawcc;
  724|      0|    sp->dec_bitsleft = dec_bitsleft;
  725|      0|    sp->lzw_nbits = (unsigned short)nbits;
  ------------------
  |  |  102|      0|#define lzw_nbits base.nbits
  ------------------
  726|      0|    sp->lzw_nextdata = nextdata;
  ------------------
  |  |  105|      0|#define lzw_nextdata base.nextdata
  ------------------
  727|      0|    sp->lzw_nextbits = nextbits;
  ------------------
  |  |  106|      0|#define lzw_nextbits base.nextbits
  ------------------
  728|      0|    sp->dec_nbitsmask = nbitsmask;
  729|      0|    sp->dec_oldcodep = oldcodep;
  730|      0|    sp->dec_free_entp = free_entp;
  731|      0|    sp->dec_maxcodep = maxcodep;
  732|       |
  733|      0|    if (occ > 0)
  ------------------
  |  Branch (733:9): [True: 0, False: 0]
  ------------------
  734|      0|    {
  735|      0|        memset(op, 0, (size_t)occ);
  736|      0|        sp->read_error = 1;
  737|      0|        TIFFErrorExtR(tif, module,
  738|      0|                      "Not enough data at scanline %" PRIu32 " (short %" PRIu64
  739|      0|                      " bytes)",
  740|      0|                      tif->tif_dir.td_row, (uint64_t)occ);
  741|      0|        return (0);
  742|      0|    }
  743|      0|    return (1);
  744|       |
  745|     18|no_eoi:
  746|     18|    memset(op, 0, (size_t)occ);
  747|     18|    sp->read_error = 1;
  748|     18|    TIFFErrorExtR(tif, module,
  749|     18|                  "LZWDecode: Strip %" PRIu32 " not terminated with EOI code",
  750|     18|                  tif->tif_dir.td_curstrip);
  751|     18|    return 0;
  752|    133|error_code:
  753|    133|    memset(op, 0, (size_t)occ);
  754|    133|    sp->read_error = 1;
  755|    133|    TIFFErrorExtR(tif, tif->tif_name, "Using code not yet in table");
  756|    133|    return 0;
  757|      0|}
tif_lzw.c:LZWGetMaxCompressionRatio:
 1396|     53|{
 1397|     53|    (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|     53|    return 1400;
 1408|     53|}
tif_lzw.c:LZWCleanup:
 1378|     94|{
 1379|     94|    (void)TIFFPredictorCleanup(tif);
 1380|       |
 1381|     94|    assert(tif->tif_data != NULL);
  ------------------
  |  Branch (1381:5): [True: 0, False: 94]
  |  Branch (1381:5): [True: 94, False: 0]
  ------------------
 1382|       |
 1383|     94|    if (LZWDecoderState(tif)->dec_codetab)
  ------------------
  |  |  164|     94|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  |  Branch (1383:9): [True: 73, False: 21]
  ------------------
 1384|     73|        _TIFFfreeExt(tif, LZWDecoderState(tif)->dec_codetab);
  ------------------
  |  |  164|     73|#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     73|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
 1385|       |
 1386|     94|    if (LZWEncoderState(tif)->enc_hashtab)
  ------------------
  |  |  165|     94|#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
  |  |  ------------------
  |  |  |  |  163|     94|#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  |  Branch (1386:9): [True: 0, False: 94]
  ------------------
 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|     94|    _TIFFfreeExt(tif, tif->tif_data);
 1390|     94|    tif->tif_data = NULL;
 1391|       |
 1392|     94|    _TIFFSetDefaultCompressionState(tif);
 1393|     94|}

TIFFInitNeXT:
  187|      7|{
  188|      7|    (void)scheme;
  189|      7|    tif->tif_predecode = NeXTPreDecode;
  190|      7|    tif->tif_decoderow = NeXTDecode;
  191|      7|    tif->tif_decodestrip = NeXTDecode;
  192|      7|    tif->tif_decodetile = NeXTDecode;
  193|      7|    return (1);
  194|      7|}
tif_next.c:NeXTPreDecode:
  172|      7|{
  173|      7|    static const char module[] = "NeXTPreDecode";
  174|      7|    TIFFDirectory *td = &tif->tif_dir;
  175|      7|    (void)s;
  176|       |
  177|      7|    if (td->td_bitspersample != 2)
  ------------------
  |  Branch (177:9): [True: 0, False: 7]
  ------------------
  178|      0|    {
  179|      0|        TIFFErrorExtR(tif, module, "Unsupported BitsPerSample = %" PRIu16,
  180|      0|                      td->td_bitspersample);
  181|      0|        return (0);
  182|      0|    }
  183|      7|    return (1);
  184|      7|}
tif_next.c:NeXTDecode:
   59|      7|{
   60|      7|    static const char module[] = "NeXTDecode";
   61|      7|    unsigned char *bp, *op;
   62|      7|    tmsize_t cc;
   63|      7|    uint8_t *row;
   64|      7|    tmsize_t scanline, n;
   65|       |
   66|      7|    (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|   184k|    for (op = (unsigned char *)buf, cc = occ; cc-- > 0;)
  ------------------
  |  Branch (72:47): [True: 184k, False: 7]
  ------------------
   73|   184k|        *op++ = 0xff;
   74|       |
   75|      7|    bp = (unsigned char *)tif->tif_rawcp;
   76|      7|    cc = tif->tif_rawcc;
   77|      7|    scanline = tif->tif_dir.td_scanlinesize;
   78|      7|    if (occ % scanline)
  ------------------
  |  Branch (78:9): [True: 0, False: 7]
  ------------------
   79|      0|    {
   80|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
   81|      0|        return (0);
   82|      0|    }
   83|   108k|    for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline)
  ------------------
  |  Branch (83:21): [True: 108k, False: 0]
  |  Branch (83:31): [True: 108k, False: 3]
  ------------------
   84|   108k|    {
   85|   108k|        n = *bp++;
   86|   108k|        cc--;
   87|   108k|        switch (n)
   88|   108k|        {
   89|  62.8k|            case LITERALROW:
  ------------------
  |  |   55|  62.8k|#define LITERALROW 0x00
  ------------------
  |  Branch (89:13): [True: 62.8k, False: 45.2k]
  ------------------
   90|       |                /*
   91|       |                 * The entire scanline is given as literal values.
   92|       |                 */
   93|  62.8k|                if (cc < scanline)
  ------------------
  |  Branch (93:21): [True: 0, False: 62.8k]
  ------------------
   94|      0|                    goto bad;
   95|  62.8k|                _TIFFmemcpy(row, bp, scanline);
   96|  62.8k|                bp += scanline;
   97|  62.8k|                cc -= scanline;
   98|  62.8k|                break;
   99|     19|            case LITERALSPAN:
  ------------------
  |  |   56|     19|#define LITERALSPAN 0x40
  ------------------
  |  Branch (99:13): [True: 19, False: 108k]
  ------------------
  100|     19|            {
  101|     19|                tmsize_t off;
  102|       |                /*
  103|       |                 * The scanline has a literal span that begins at some
  104|       |                 * offset.
  105|       |                 */
  106|     19|                if (cc < 4)
  ------------------
  |  Branch (106:21): [True: 0, False: 19]
  ------------------
  107|      0|                    goto bad;
  108|     19|                off = (bp[0] * 256) + bp[1];
  109|     19|                n = (bp[2] * 256) + bp[3];
  110|     19|                if (cc < 4 + n || off + n > scanline)
  ------------------
  |  Branch (110:21): [True: 0, False: 19]
  |  Branch (110:35): [True: 4, False: 15]
  ------------------
  111|      4|                    goto bad;
  112|     15|                _TIFFmemcpy(row + off, bp + 4, n);
  113|     15|                bp += 4 + n;
  114|     15|                cc -= 4 + n;
  115|     15|                break;
  116|     19|            }
  117|  45.2k|            default:
  ------------------
  |  Branch (117:13): [True: 45.2k, False: 62.8k]
  ------------------
  118|  45.2k|            {
  119|  45.2k|                uint32_t npixels = 0, grey;
  120|  45.2k|                tmsize_t op_offset = 0;
  121|  45.2k|                uint32_t imagewidth = tif->tif_dir.td_imagewidth;
  122|  45.2k|                if (isTiled(tif))
  ------------------
  |  |  278|  45.2k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  45.2k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 0, False: 45.2k]
  |  |  ------------------
  ------------------
  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|  45.2k|                op = row;
  132|  45.2k|                for (;;)
  133|  49.7k|                {
  134|  49.7k|                    grey = (uint32_t)((n >> 6) & 0x3);
  135|  49.7k|                    n &= 0x3f;
  136|       |                    /*
  137|       |                     * Ensure the run does not exceed the scanline
  138|       |                     * bounds, potentially resulting in a security
  139|       |                     * issue.
  140|       |                     */
  141|   185k|                    while (n-- > 0 && npixels < imagewidth &&
  ------------------
  |  Branch (141:28): [True: 180k, False: 4.82k]
  |  Branch (141:39): [True: 135k, False: 44.8k]
  ------------------
  142|   135k|                           op_offset < scanline)
  ------------------
  |  Branch (142:28): [True: 135k, False: 0]
  ------------------
  143|   135k|                        SETPIXEL(op, grey);
  ------------------
  |  |   34|   135k|    {                                                                          \
  |  |   35|   135k|        switch (npixels++ & 3)                                                 \
  |  |   36|   135k|        {                                                                      \
  |  |   37|  45.2k|            case 0:                                                            \
  |  |  ------------------
  |  |  |  Branch (37:13): [True: 45.2k, False: 90.5k]
  |  |  ------------------
  |  |   38|  45.2k|                op[0] = (unsigned char)((v) << 6);                             \
  |  |   39|  45.2k|                break;                                                         \
  |  |   40|  45.2k|            case 1:                                                            \
  |  |  ------------------
  |  |  |  Branch (40:13): [True: 45.2k, False: 90.5k]
  |  |  ------------------
  |  |   41|  45.2k|                op[0] |= (unsigned char)((v) << 4);                            \
  |  |   42|  45.2k|                break;                                                         \
  |  |   43|  45.2k|            case 2:                                                            \
  |  |  ------------------
  |  |  |  Branch (43:13): [True: 45.2k, False: 90.5k]
  |  |  ------------------
  |  |   44|  45.2k|                op[0] |= (unsigned char)((v) << 2);                            \
  |  |   45|  45.2k|                break;                                                         \
  |  |   46|      0|            case 3:                                                            \
  |  |  ------------------
  |  |  |  Branch (46:13): [True: 0, False: 135k]
  |  |  ------------------
  |  |   47|      0|                *op++ |= (unsigned char)(v);                                   \
  |  |   48|      0|                op_offset++;                                                   \
  |  |   49|      0|                break;                                                         \
  |  |   50|      0|            default:                                                           \
  |  |  ------------------
  |  |  |  Branch (50:13): [True: 0, False: 135k]
  |  |  ------------------
  |  |   51|      0|                break;                                                         \
  |  |   52|   135k|        }                                                                      \
  |  |   53|   135k|    }
  ------------------
  144|  49.7k|                    if (npixels >= imagewidth)
  ------------------
  |  Branch (144:25): [True: 45.2k, False: 4.44k]
  ------------------
  145|  45.2k|                        break;
  146|  4.44k|                    if (op_offset >= scanline)
  ------------------
  |  Branch (146:25): [True: 0, False: 4.44k]
  ------------------
  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|  4.44k|                    if (cc == 0)
  ------------------
  |  Branch (153:25): [True: 0, False: 4.44k]
  ------------------
  154|      0|                        goto bad;
  155|  4.44k|                    n = *bp++;
  156|  4.44k|                    cc--;
  157|  4.44k|                }
  158|  45.2k|                break;
  159|  45.2k|            }
  160|   108k|        }
  161|   108k|    }
  162|      3|    tif->tif_rawcp = (uint8_t *)bp;
  163|      3|    tif->tif_rawcc = cc;
  164|      3|    return (1);
  165|      4|bad:
  166|       |    TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
  167|      4|                  tif->tif_dir.td_row);
  168|      4|    return (0);
  169|      7|}

TIFFInitOJPEG:
  454|    138|{
  455|    138|    static const char module[] = "TIFFInitOJPEG";
  456|    138|    OJPEGState *sp;
  457|       |
  458|    138|    (void)scheme;
  459|    138|    assert(scheme == COMPRESSION_OJPEG);
  ------------------
  |  Branch (459:5): [True: 0, False: 138]
  |  Branch (459:5): [True: 138, False: 0]
  ------------------
  460|       |
  461|       |    /*
  462|       |     * Merge codec-specific tag information.
  463|       |     */
  464|    138|    if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields)))
  ------------------
  |  |  339|    138|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (464:9): [True: 0, False: 138]
  ------------------
  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|    138|    sp = (OJPEGState *)_TIFFmallocExt(tif, sizeof(OJPEGState));
  473|    138|    if (sp == NULL)
  ------------------
  |  Branch (473:9): [True: 0, False: 138]
  ------------------
  474|      0|    {
  475|      0|        TIFFErrorExtR(tif, module, "No space for OJPEG state block");
  476|      0|        return (0);
  477|      0|    }
  478|    138|    _TIFFmemset(sp, 0, sizeof(OJPEGState));
  479|    138|    sp->tif = tif;
  480|    138|    sp->jpeg_proc = 1;
  481|    138|    sp->subsampling_hor = 2;
  482|    138|    sp->subsampling_ver = 2;
  483|    138|    TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, 2, 2);
  ------------------
  |  |  388|    138|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  484|       |    /* tif codec methods */
  485|    138|    tif->tif_fixuptags = OJPEGFixupTags;
  486|    138|    tif->tif_setupdecode = OJPEGSetupDecode;
  487|    138|    tif->tif_predecode = OJPEGPreDecode;
  488|    138|    tif->tif_postdecode = OJPEGPostDecode;
  489|    138|    tif->tif_decoderow = OJPEGDecode;
  490|    138|    tif->tif_decodestrip = OJPEGDecode;
  491|    138|    tif->tif_decodetile = OJPEGDecode;
  492|    138|    tif->tif_setupencode = OJPEGSetupEncode;
  493|    138|    tif->tif_preencode = OJPEGPreEncode;
  494|    138|    tif->tif_postencode = OJPEGPostEncode;
  495|    138|    tif->tif_encoderow = OJPEGEncode;
  496|    138|    tif->tif_encodestrip = OJPEGEncode;
  497|    138|    tif->tif_encodetile = OJPEGEncode;
  498|    138|    tif->tif_cleanup = OJPEGCleanup;
  499|    138|    tif->tif_data = (uint8_t *)sp;
  500|       |    /* tif tag methods */
  501|    138|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
  502|    138|    tif->tif_tagmethods.vgetfield = OJPEGVGetField;
  503|    138|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
  504|    138|    tif->tif_tagmethods.vsetfield = OJPEGVSetField;
  505|    138|    sp->printdir = tif->tif_tagmethods.printdir;
  506|    138|    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|    138|    tif->tif_flags |= TIFF_NOREADRAW;
  ------------------
  |  |  138|    138|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  514|    138|    return (1);
  515|    138|}
tif_ojpeg.c:OJPEGVGetField:
  518|  3.28k|{
  519|  3.28k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  520|  3.28k|    switch (tag)
  521|  3.28k|    {
  522|      0|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|      0|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (522:9): [True: 0, False: 3.28k]
  ------------------
  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: 3.28k]
  ------------------
  526|      0|            *va_arg(ap, uint64_t *) =
  527|      0|                (uint64_t)sp->jpeg_interchange_format_length;
  528|      0|            break;
  529|  1.49k|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|  1.49k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (529:9): [True: 1.49k, False: 1.78k]
  ------------------
  530|  1.49k|            if (sp->subsamplingcorrect_done == 0)
  ------------------
  |  Branch (530:17): [True: 47, False: 1.44k]
  ------------------
  531|     47|                OJPEGSubsamplingCorrect(tif);
  532|  1.49k|            *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_hor;
  533|  1.49k|            *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_ver;
  534|  1.49k|            break;
  535|      0|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|      0|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (535:9): [True: 0, False: 3.28k]
  ------------------
  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: 3.28k]
  ------------------
  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: 3.28k]
  ------------------
  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: 3.28k]
  ------------------
  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: 3.28k]
  ------------------
  551|      0|            *va_arg(ap, uint16_t *) = sp->restart_interval;
  552|      0|            break;
  553|  1.78k|        default:
  ------------------
  |  Branch (553:9): [True: 1.78k, False: 1.49k]
  ------------------
  554|  1.78k|            return (*sp->vgetparent)(tif, tag, ap);
  555|  3.28k|    }
  556|  1.49k|    return (1);
  557|  3.28k|}
tif_ojpeg.c:OJPEGSubsamplingCorrect:
 1082|    132|{
 1083|    132|    static const char module[] = "OJPEGSubsamplingCorrect";
 1084|    132|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1085|    132|    uint8_t mh;
 1086|    132|    uint8_t mv;
 1087|       |
 1088|    132|    assert(sp->subsamplingcorrect_done == 0);
  ------------------
  |  Branch (1088:5): [True: 0, False: 132]
  |  Branch (1088:5): [True: 132, False: 0]
  ------------------
 1089|    132|    if ((tif->tif_dir.td_samplesperpixel != 3) ||
  ------------------
  |  Branch (1089:9): [True: 23, False: 109]
  ------------------
 1090|    109|        ((tif->tif_dir.td_photometric != PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|    109|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (1090:10): [True: 17, False: 92]
  ------------------
 1091|     17|         (tif->tif_dir.td_photometric != PHOTOMETRIC_ITULAB)))
  ------------------
  |  |  230|     17|#define PHOTOMETRIC_ITULAB 10              /* ITU L*a*b* */
  ------------------
  |  Branch (1091:10): [True: 17, False: 0]
  ------------------
 1092|     40|    {
 1093|     40|        if (sp->subsampling_tag != 0)
  ------------------
  |  Branch (1093:13): [True: 0, False: 40]
  ------------------
 1094|      0|            TIFFWarningExtR(tif, module,
 1095|      0|                            "Subsampling tag not appropriate for this "
 1096|      0|                            "Photometric and/or SamplesPerPixel");
 1097|     40|        sp->subsampling_hor = 1;
 1098|     40|        sp->subsampling_ver = 1;
 1099|     40|        sp->subsampling_force_desubsampling_inside_decompression = 0;
 1100|     40|    }
 1101|     92|    else
 1102|     92|    {
 1103|     92|        sp->subsamplingcorrect_done = 1;
 1104|     92|        mh = sp->subsampling_hor;
 1105|     92|        mv = sp->subsampling_ver;
 1106|     92|        sp->subsamplingcorrect = 1;
 1107|     92|        OJPEGReadHeaderInfoSec(tif);
 1108|     92|        if (sp->subsampling_force_desubsampling_inside_decompression != 0)
  ------------------
  |  Branch (1108:13): [True: 0, False: 92]
  ------------------
 1109|      0|        {
 1110|      0|            sp->subsampling_hor = 1;
 1111|      0|            sp->subsampling_ver = 1;
 1112|      0|        }
 1113|     92|        sp->subsamplingcorrect = 0;
 1114|     92|        if (((sp->subsampling_hor != mh) || (sp->subsampling_ver != mv)) &&
  ------------------
  |  Branch (1114:14): [True: 0, False: 92]
  |  Branch (1114:45): [True: 0, False: 92]
  ------------------
 1115|      0|            (sp->subsampling_force_desubsampling_inside_decompression == 0))
  ------------------
  |  Branch (1115:13): [True: 0, False: 0]
  ------------------
 1116|      0|        {
 1117|      0|            if (sp->subsampling_tag == 0)
  ------------------
  |  Branch (1117:17): [True: 0, False: 0]
  ------------------
 1118|      0|                TIFFWarningExtR(
 1119|      0|                    tif, module,
 1120|      0|                    "Subsampling tag is not set, yet subsampling inside JPEG "
 1121|      0|                    "data [%" PRIu8 ",%" PRIu8
 1122|      0|                    "] does not match default values [2,2]; assuming "
 1123|      0|                    "subsampling inside JPEG data is correct",
 1124|      0|                    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|      0|        }
 1134|     92|        if (sp->subsampling_force_desubsampling_inside_decompression != 0)
  ------------------
  |  Branch (1134:13): [True: 0, False: 92]
  ------------------
 1135|      0|        {
 1136|      0|            if (sp->subsampling_tag == 0)
  ------------------
  |  Branch (1136:17): [True: 0, False: 0]
  ------------------
 1137|      0|                TIFFWarningExtR(
 1138|      0|                    tif, module,
 1139|      0|                    "Subsampling tag is not set, yet subsampling inside JPEG "
 1140|      0|                    "data does not match default values [2,2] (nor any other "
 1141|      0|                    "values allowed in TIFF); assuming subsampling inside JPEG "
 1142|      0|                    "data is correct and desubsampling inside JPEG "
 1143|      0|                    "decompression");
 1144|      0|            else
 1145|      0|                TIFFWarningExtR(
 1146|      0|                    tif, module,
 1147|      0|                    "Subsampling inside JPEG data does not match subsampling "
 1148|      0|                    "tag values [%" PRIu8 ",%" PRIu8
 1149|      0|                    "] (nor any other values allowed in TIFF); assuming "
 1150|      0|                    "subsampling inside JPEG data is correct and desubsampling "
 1151|      0|                    "inside JPEG decompression",
 1152|      0|                    mh, mv);
 1153|      0|        }
 1154|     92|        if (sp->subsampling_force_desubsampling_inside_decompression == 0)
  ------------------
  |  Branch (1154:13): [True: 92, False: 0]
  ------------------
 1155|     92|        {
 1156|     92|            if (sp->subsampling_hor < sp->subsampling_ver)
  ------------------
  |  Branch (1156:17): [True: 0, False: 92]
  ------------------
 1157|      0|                TIFFWarningExtR(tif, module,
 1158|      0|                                "Subsampling values [%" PRIu8 ",%" PRIu8
 1159|      0|                                "] are not allowed in TIFF",
 1160|      0|                                sp->subsampling_hor, sp->subsampling_ver);
 1161|     92|        }
 1162|     92|    }
 1163|    132|    sp->subsamplingcorrect_done = 1;
 1164|    132|}
tif_ojpeg.c:OJPEGReadHeaderInfoSec:
 1536|  1.36k|{
 1537|  1.36k|    static const char module[] = "OJPEGReadHeaderInfoSec";
 1538|  1.36k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1539|  1.36k|    uint8_t m;
 1540|  1.36k|    uint16_t n;
 1541|  1.36k|    uint8_t o;
 1542|  1.36k|    if (sp->file_size == 0)
  ------------------
  |  Branch (1542:9): [True: 129, False: 1.23k]
  ------------------
 1543|    129|        sp->file_size = TIFFGetFileSize(tif);
  ------------------
  |  |  289|    129|#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
  ------------------
 1544|  1.36k|    if (sp->jpeg_interchange_format != 0)
  ------------------
  |  Branch (1544:9): [True: 1, False: 1.36k]
  ------------------
 1545|      1|    {
 1546|      1|        if (sp->jpeg_interchange_format >= sp->file_size)
  ------------------
  |  Branch (1546:13): [True: 0, False: 1]
  ------------------
 1547|      0|        {
 1548|      0|            sp->jpeg_interchange_format = 0;
 1549|      0|            sp->jpeg_interchange_format_length = 0;
 1550|      0|        }
 1551|      1|        else
 1552|      1|        {
 1553|      1|            if ((sp->jpeg_interchange_format_length == 0) ||
  ------------------
  |  Branch (1553:17): [True: 1, False: 0]
  ------------------
 1554|      0|                (sp->jpeg_interchange_format >
  ------------------
  |  Branch (1554:17): [True: 0, False: 0]
  ------------------
 1555|      0|                 UINT64_MAX - sp->jpeg_interchange_format_length) ||
 1556|      0|                (sp->jpeg_interchange_format +
  ------------------
  |  Branch (1556:17): [True: 0, False: 0]
  ------------------
 1557|      0|                     sp->jpeg_interchange_format_length >
 1558|      0|                 sp->file_size))
 1559|      1|                sp->jpeg_interchange_format_length =
 1560|      1|                    sp->file_size - sp->jpeg_interchange_format;
 1561|      1|        }
 1562|      1|    }
 1563|  1.36k|    sp->in_buffer_source = osibsNotSetYet;
 1564|  1.36k|    sp->in_buffer_next_strile = 0;
 1565|  1.36k|    sp->in_buffer_strile_count = tif->tif_dir.td_nstrips;
 1566|  1.36k|    sp->in_buffer_file_togo = 0;
 1567|  1.36k|    sp->in_buffer_togo = 0;
 1568|  1.36k|    do
 1569|  1.54k|    {
 1570|  1.54k|        if (OJPEGReadBytePeek(sp, &m) == 0)
  ------------------
  |  Branch (1570:13): [True: 109, False: 1.43k]
  ------------------
 1571|    109|            return (0);
 1572|  1.43k|        if (m != 255)
  ------------------
  |  Branch (1572:13): [True: 199, False: 1.23k]
  ------------------
 1573|    199|            break;
 1574|  1.23k|        OJPEGReadByteAdvance(sp);
 1575|  1.23k|        do
 1576|  1.45k|        {
 1577|  1.45k|            if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1577:17): [True: 0, False: 1.45k]
  ------------------
 1578|      0|                return (0);
 1579|  1.45k|        } while (m == 255);
  ------------------
  |  Branch (1579:18): [True: 219, False: 1.23k]
  ------------------
 1580|  1.23k|        switch (m)
 1581|  1.23k|        {
 1582|      2|            case JPEG_MARKER_SOI:
  ------------------
  |  |  163|      2|#define JPEG_MARKER_SOI 0xD8
  ------------------
  |  Branch (1582:13): [True: 2, False: 1.23k]
  ------------------
 1583|       |                /* this type of marker has no data, and should be skipped */
 1584|      2|                break;
 1585|      0|            case JPEG_MARKER_COM:
  ------------------
  |  |  169|      0|#define JPEG_MARKER_COM 0xFE
  ------------------
  |  Branch (1585:13): [True: 0, False: 1.23k]
  ------------------
 1586|      0|            case JPEG_MARKER_APP0:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1586:13): [True: 0, False: 1.23k]
  ------------------
 1587|      0|            case JPEG_MARKER_APP0 + 1:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1587:13): [True: 0, False: 1.23k]
  ------------------
 1588|      0|            case JPEG_MARKER_APP0 + 2:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1588:13): [True: 0, False: 1.23k]
  ------------------
 1589|      0|            case JPEG_MARKER_APP0 + 3:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1589:13): [True: 0, False: 1.23k]
  ------------------
 1590|      0|            case JPEG_MARKER_APP0 + 4:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1590:13): [True: 0, False: 1.23k]
  ------------------
 1591|      0|            case JPEG_MARKER_APP0 + 5:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1591:13): [True: 0, False: 1.23k]
  ------------------
 1592|      0|            case JPEG_MARKER_APP0 + 6:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1592:13): [True: 0, False: 1.23k]
  ------------------
 1593|      0|            case JPEG_MARKER_APP0 + 7:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1593:13): [True: 0, False: 1.23k]
  ------------------
 1594|      0|            case JPEG_MARKER_APP0 + 8:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1594:13): [True: 0, False: 1.23k]
  ------------------
 1595|      0|            case JPEG_MARKER_APP0 + 9:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1595:13): [True: 0, False: 1.23k]
  ------------------
 1596|      0|            case JPEG_MARKER_APP0 + 10:
  ------------------
  |  |  168|      0|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1596:13): [True: 0, False: 1.23k]
  ------------------
 1597|    168|            case JPEG_MARKER_APP0 + 11:
  ------------------
  |  |  168|    168|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1597:13): [True: 168, False: 1.06k]
  ------------------
 1598|    168|            case JPEG_MARKER_APP0 + 12:
  ------------------
  |  |  168|    168|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1598:13): [True: 0, False: 1.23k]
  ------------------
 1599|    168|            case JPEG_MARKER_APP0 + 13:
  ------------------
  |  |  168|    168|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1599:13): [True: 0, False: 1.23k]
  ------------------
 1600|    168|            case JPEG_MARKER_APP0 + 14:
  ------------------
  |  |  168|    168|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1600:13): [True: 0, False: 1.23k]
  ------------------
 1601|    168|            case JPEG_MARKER_APP0 + 15:
  ------------------
  |  |  168|    168|#define JPEG_MARKER_APP0 0xE0
  ------------------
  |  Branch (1601:13): [True: 0, False: 1.23k]
  ------------------
 1602|       |                /* this type of marker has data, but it has no use to us (and no
 1603|       |                 * place here) and should be skipped */
 1604|    168|                if (OJPEGReadWord(sp, &n) == 0)
  ------------------
  |  Branch (1604:21): [True: 0, False: 168]
  ------------------
 1605|      0|                    return (0);
 1606|    168|                if (n < 2)
  ------------------
  |  Branch (1606:21): [True: 0, False: 168]
  ------------------
 1607|      0|                {
 1608|      0|                    if (sp->subsamplingcorrect == 0)
  ------------------
  |  Branch (1608:25): [True: 0, False: 0]
  ------------------
 1609|      0|                        TIFFErrorExtR(tif, module, "Corrupt JPEG data");
 1610|      0|                    return (0);
 1611|      0|                }
 1612|    168|                if (n > 2)
  ------------------
  |  Branch (1612:21): [True: 168, False: 0]
  ------------------
 1613|    168|                    OJPEGReadSkip(sp, (uint16_t)(n - 2));
 1614|    168|                break;
 1615|      0|            case JPEG_MARKER_DRI:
  ------------------
  |  |  167|      0|#define JPEG_MARKER_DRI 0xDD
  ------------------
  |  Branch (1615:13): [True: 0, False: 1.23k]
  ------------------
 1616|      0|                if (OJPEGReadHeaderInfoSecStreamDri(tif) == 0)
  ------------------
  |  Branch (1616:21): [True: 0, False: 0]
  ------------------
 1617|      0|                    return (0);
 1618|      0|                break;
 1619|  1.06k|            case JPEG_MARKER_DQT:
  ------------------
  |  |  166|  1.06k|#define JPEG_MARKER_DQT 0xDB
  ------------------
  |  Branch (1619:13): [True: 1.06k, False: 172]
  ------------------
 1620|  1.06k|                if (OJPEGReadHeaderInfoSecStreamDqt(tif) == 0)
  ------------------
  |  Branch (1620:21): [True: 1.05k, False: 10]
  ------------------
 1621|  1.05k|                    return (0);
 1622|     10|                break;
 1623|     10|            case JPEG_MARKER_DHT:
  ------------------
  |  |  161|      0|#define JPEG_MARKER_DHT 0xC4
  ------------------
  |  Branch (1623:13): [True: 0, False: 1.23k]
  ------------------
 1624|      0|                if (OJPEGReadHeaderInfoSecStreamDht(tif) == 0)
  ------------------
  |  Branch (1624:21): [True: 0, False: 0]
  ------------------
 1625|      0|                    return (0);
 1626|      0|                break;
 1627|      0|            case JPEG_MARKER_SOF0:
  ------------------
  |  |  158|      0|#define JPEG_MARKER_SOF0 0xC0
  ------------------
  |  Branch (1627:13): [True: 0, False: 1.23k]
  ------------------
 1628|      0|            case JPEG_MARKER_SOF1:
  ------------------
  |  |  159|      0|#define JPEG_MARKER_SOF1 0xC1
  ------------------
  |  Branch (1628:13): [True: 0, False: 1.23k]
  ------------------
 1629|      0|            case JPEG_MARKER_SOF3:
  ------------------
  |  |  160|      0|#define JPEG_MARKER_SOF3 0xC3
  ------------------
  |  Branch (1629:13): [True: 0, False: 1.23k]
  ------------------
 1630|      0|                if (OJPEGReadHeaderInfoSecStreamSof(tif, m) == 0)
  ------------------
  |  Branch (1630:21): [True: 0, False: 0]
  ------------------
 1631|      0|                    return (0);
 1632|      0|                if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1632:21): [True: 0, False: 0]
  ------------------
 1633|      0|                    return (1);
 1634|      0|                break;
 1635|      0|            case JPEG_MARKER_SOS:
  ------------------
  |  |  165|      0|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1635:13): [True: 0, False: 1.23k]
  ------------------
 1636|      0|                if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1636:21): [True: 0, False: 0]
  ------------------
 1637|      0|                    return (1);
 1638|      0|                assert(sp->plane_sample_offset == 0);
  ------------------
  |  Branch (1638:17): [True: 0, False: 0]
  |  Branch (1638:17): [True: 0, False: 0]
  ------------------
 1639|      0|                if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
  ------------------
  |  Branch (1639:21): [True: 0, False: 0]
  ------------------
 1640|      0|                    return (0);
 1641|      0|                break;
 1642|      2|            default:
  ------------------
  |  Branch (1642:13): [True: 2, False: 1.23k]
  ------------------
 1643|      2|                TIFFErrorExtR(tif, module,
 1644|      2|                              "Unknown marker type %" PRIu8 " in JPEG data", m);
 1645|      2|                return (0);
 1646|  1.23k|        }
 1647|  1.23k|    } while (m != JPEG_MARKER_SOS);
  ------------------
  |  |  165|    180|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1647:14): [True: 180, False: 0]
  ------------------
 1648|    199|    if (sp->subsamplingcorrect)
  ------------------
  |  Branch (1648:9): [True: 55, False: 144]
  ------------------
 1649|     55|        return (1);
 1650|    144|    if (sp->sof_log == 0)
  ------------------
  |  Branch (1650:9): [True: 84, False: 60]
  ------------------
 1651|     84|    {
 1652|     84|        if (OJPEGReadHeaderInfoSecTablesQTable(tif) == 0)
  ------------------
  |  Branch (1652:13): [True: 1, False: 83]
  ------------------
 1653|      1|            return (0);
 1654|     83|        sp->sof_marker_id = JPEG_MARKER_SOF0;
  ------------------
  |  |  158|     83|#define JPEG_MARKER_SOF0 0xC0
  ------------------
 1655|    292|        for (o = 0; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1655:21): [True: 209, False: 83]
  ------------------
 1656|    209|            sp->sof_c[o] = (uint8_t)o;
 1657|     83|        sp->sof_hv[0] =
 1658|     83|            (uint8_t)((sp->subsampling_hor << 4) | sp->subsampling_ver);
 1659|    209|        for (o = 1; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1659:21): [True: 126, False: 83]
  ------------------
 1660|    126|            sp->sof_hv[o] = 17;
 1661|     83|        sp->sof_x = sp->strile_width;
 1662|     83|        sp->sof_y = sp->strile_length_total;
 1663|     83|        sp->sof_log = 1;
 1664|     83|        if (OJPEGReadHeaderInfoSecTablesDcTable(tif) == 0)
  ------------------
  |  Branch (1664:13): [True: 62, False: 21]
  ------------------
 1665|     62|            return (0);
 1666|     21|        if (OJPEGReadHeaderInfoSecTablesAcTable(tif) == 0)
  ------------------
  |  Branch (1666:13): [True: 2, False: 19]
  ------------------
 1667|      2|            return (0);
 1668|     19|        for (o = 1; o < sp->samples_per_pixel; o++)
  ------------------
  |  Branch (1668:21): [True: 0, False: 19]
  ------------------
 1669|      0|            sp->sos_cs[o] = o;
 1670|     19|    }
 1671|     79|    return (1);
 1672|    144|}
tif_ojpeg.c:OJPEGReadBytePeek:
 2364|  1.54k|{
 2365|  1.54k|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2365:9): [True: 1.54k, False: 2]
  ------------------
 2366|  1.54k|    {
 2367|  1.54k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2367:13): [True: 109, False: 1.43k]
  ------------------
 2368|    109|            return (0);
 2369|  1.54k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2369:9): [True: 0, False: 1.43k]
  |  Branch (2369:9): [True: 1.43k, False: 0]
  ------------------
 2370|  1.43k|    }
 2371|  1.43k|    *byte = *(sp->in_buffer_cur);
 2372|  1.43k|    return (1);
 2373|  1.54k|}
tif_ojpeg.c:OJPEGReadBufferFill:
 2256|  25.7k|{
 2257|  25.7k|    uint16_t m;
 2258|  25.7k|    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|  25.7k|    do
 2263|   118k|    {
 2264|   118k|        if (sp->in_buffer_file_togo != 0)
  ------------------
  |  Branch (2264:13): [True: 25.3k, False: 93.1k]
  ------------------
 2265|  25.3k|        {
 2266|  25.3k|            if (sp->in_buffer_file_pos_log == 0)
  ------------------
  |  Branch (2266:17): [True: 6.36k, False: 19.0k]
  ------------------
 2267|  6.36k|            {
 2268|  6.36k|                TIFFSeekFile(sp->tif, sp->in_buffer_file_pos, SEEK_SET);
  ------------------
  |  |  287|  6.36k|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2269|  6.36k|                sp->in_buffer_file_pos_log = 1;
 2270|  6.36k|            }
 2271|  25.3k|            m = OJPEG_BUFFER;
  ------------------
  |  |  155|  25.3k|#define OJPEG_BUFFER 2048
  ------------------
 2272|  25.3k|            if ((uint64_t)m > sp->in_buffer_file_togo)
  ------------------
  |  Branch (2272:17): [True: 4.63k, False: 20.7k]
  ------------------
 2273|  4.63k|                m = (uint16_t)sp->in_buffer_file_togo;
 2274|  25.3k|            n = TIFFReadFile(sp->tif, sp->in_buffer, (tmsize_t)m);
  ------------------
  |  |  283|  25.3k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2275|  25.3k|            if (n <= 0)
  ------------------
  |  Branch (2275:17): [True: 5, False: 25.3k]
  ------------------
 2276|      5|                return (0);
 2277|  25.3k|            assert(n > 0);
  ------------------
  |  Branch (2277:13): [True: 0, False: 25.3k]
  |  Branch (2277:13): [True: 25.3k, False: 0]
  ------------------
 2278|  25.3k|            assert(n <= OJPEG_BUFFER);
  ------------------
  |  Branch (2278:13): [True: 0, False: 25.3k]
  |  Branch (2278:13): [True: 25.3k, False: 0]
  ------------------
 2279|  25.3k|            assert(n < 65536);
  ------------------
  |  Branch (2279:13): [True: 0, False: 25.3k]
  |  Branch (2279:13): [True: 25.3k, False: 0]
  ------------------
 2280|  25.3k|            assert((uint64_t)n <= sp->in_buffer_file_togo);
  ------------------
  |  Branch (2280:13): [True: 0, False: 25.3k]
  |  Branch (2280:13): [True: 25.3k, False: 0]
  ------------------
 2281|  25.3k|            m = (uint16_t)n;
 2282|  25.3k|            sp->in_buffer_togo = m;
 2283|  25.3k|            sp->in_buffer_cur = sp->in_buffer;
 2284|  25.3k|            sp->in_buffer_file_togo -= m;
 2285|  25.3k|            sp->in_buffer_file_pos += m;
 2286|  25.3k|            break;
 2287|  25.3k|        }
 2288|  93.1k|        sp->in_buffer_file_pos_log = 0;
 2289|  93.1k|        switch (sp->in_buffer_source)
 2290|  93.1k|        {
 2291|  1.36k|            case osibsNotSetYet:
  ------------------
  |  Branch (2291:13): [True: 1.36k, False: 91.7k]
  ------------------
 2292|  1.36k|                if (sp->jpeg_interchange_format != 0)
  ------------------
  |  Branch (2292:21): [True: 1, False: 1.36k]
  ------------------
 2293|      1|                {
 2294|      1|                    sp->in_buffer_file_pos = sp->jpeg_interchange_format;
 2295|      1|                    sp->in_buffer_file_togo =
 2296|      1|                        sp->jpeg_interchange_format_length;
 2297|      1|                }
 2298|  1.36k|                sp->in_buffer_source = osibsJpegInterchangeFormat;
 2299|  1.36k|                break;
 2300|  1.36k|            case osibsJpegInterchangeFormat:
  ------------------
  |  Branch (2300:13): [True: 1.36k, False: 91.7k]
  ------------------
 2301|  1.36k|                sp->in_buffer_source = osibsStrile;
 2302|  1.36k|                break;
 2303|  90.1k|            case osibsStrile:
  ------------------
  |  Branch (2303:13): [True: 90.1k, False: 3.02k]
  ------------------
 2304|  90.1k|                if (sp->in_buffer_next_strile == sp->in_buffer_strile_count)
  ------------------
  |  Branch (2304:21): [True: 294, False: 89.8k]
  ------------------
 2305|    294|                    sp->in_buffer_source = osibsEof;
 2306|  89.8k|                else
 2307|  89.8k|                {
 2308|  89.8k|                    int err = 0;
 2309|  89.8k|                    sp->in_buffer_file_pos = TIFFGetStrileOffsetWithErr(
 2310|  89.8k|                        sp->tif, sp->in_buffer_next_strile, &err);
 2311|  89.8k|                    if (err)
  ------------------
  |  Branch (2311:25): [True: 102, False: 89.7k]
  ------------------
 2312|    102|                        return 0;
 2313|  89.7k|                    if (sp->in_buffer_file_pos != 0)
  ------------------
  |  Branch (2313:25): [True: 54.5k, False: 35.2k]
  ------------------
 2314|  54.5k|                    {
 2315|  54.5k|                        uint64_t bytecount = TIFFGetStrileByteCountWithErr(
 2316|  54.5k|                            sp->tif, sp->in_buffer_next_strile, &err);
 2317|  54.5k|                        if (err)
  ------------------
  |  Branch (2317:29): [True: 0, False: 54.5k]
  ------------------
 2318|      0|                            return 0;
 2319|  54.5k|                        if (sp->in_buffer_file_pos >= sp->file_size)
  ------------------
  |  Branch (2319:29): [True: 49.4k, False: 5.03k]
  ------------------
 2320|  49.4k|                            sp->in_buffer_file_pos = 0;
 2321|  5.03k|                        else if (bytecount == 0)
  ------------------
  |  Branch (2321:34): [True: 201, False: 4.82k]
  ------------------
 2322|    201|                            sp->in_buffer_file_togo =
 2323|    201|                                sp->file_size - sp->in_buffer_file_pos;
 2324|  4.82k|                        else
 2325|  4.82k|                        {
 2326|  4.82k|                            sp->in_buffer_file_togo = bytecount;
 2327|  4.82k|                            if (sp->in_buffer_file_togo == 0)
  ------------------
  |  Branch (2327:33): [True: 0, False: 4.82k]
  ------------------
 2328|      0|                                sp->in_buffer_file_pos = 0;
 2329|  4.82k|                            else if (sp->in_buffer_file_pos >
  ------------------
  |  Branch (2329:38): [True: 0, False: 4.82k]
  ------------------
 2330|  4.82k|                                         UINT64_MAX - sp->in_buffer_file_togo ||
 2331|  4.82k|                                     sp->in_buffer_file_pos +
  ------------------
  |  Branch (2331:38): [True: 2.90k, False: 1.92k]
  ------------------
 2332|  4.82k|                                             sp->in_buffer_file_togo >
 2333|  4.82k|                                         sp->file_size)
 2334|  2.90k|                                sp->in_buffer_file_togo =
 2335|  2.90k|                                    sp->file_size - sp->in_buffer_file_pos;
 2336|  4.82k|                        }
 2337|  54.5k|                    }
 2338|  89.7k|                    sp->in_buffer_next_strile++;
 2339|  89.7k|                }
 2340|  90.0k|                break;
 2341|  90.0k|            case osibsEof:
  ------------------
  |  Branch (2341:13): [True: 294, False: 92.8k]
  ------------------
 2342|    294|            default:
  ------------------
  |  Branch (2342:13): [True: 0, False: 93.1k]
  ------------------
 2343|    294|                return (0);
 2344|  93.1k|        }
 2345|  93.1k|    } while (1);
  ------------------
  |  Branch (2345:14): [True: 92.7k, Folded]
  ------------------
 2346|  25.3k|    return (1);
 2347|  25.7k|}
tif_ojpeg.c:OJPEGReadByteAdvance:
 2376|  1.23k|{
 2377|  1.23k|    assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2377:5): [True: 0, False: 1.23k]
  |  Branch (2377:5): [True: 1.23k, False: 0]
  ------------------
 2378|  1.23k|    sp->in_buffer_cur++;
 2379|  1.23k|    sp->in_buffer_togo--;
 2380|  1.23k|}
tif_ojpeg.c:OJPEGReadByte:
 2350|  27.1M|{
 2351|  27.1M|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2351:9): [True: 16.3k, False: 27.1M]
  ------------------
 2352|  16.3k|    {
 2353|  16.3k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2353:13): [True: 292, False: 16.1k]
  ------------------
 2354|    292|            return (0);
 2355|  16.3k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2355:9): [True: 0, False: 16.1k]
  |  Branch (2355:9): [True: 16.1k, False: 0]
  ------------------
 2356|  16.1k|    }
 2357|  27.1M|    *byte = *(sp->in_buffer_cur);
 2358|  27.1M|    sp->in_buffer_cur++;
 2359|  27.1M|    sp->in_buffer_togo--;
 2360|  27.1M|    return (1);
 2361|  27.1M|}
tif_ojpeg.c:OJPEGReadWord:
 2383|  1.55k|{
 2384|  1.55k|    uint8_t m;
 2385|  1.55k|    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (2385:9): [True: 0, False: 1.55k]
  ------------------
 2386|      0|        return (0);
 2387|  1.55k|    *word = (uint16_t)(m << 8);
 2388|  1.55k|    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (2388:9): [True: 0, False: 1.55k]
  ------------------
 2389|      0|        return (0);
 2390|  1.55k|    *word |= m;
 2391|  1.55k|    return (1);
 2392|  1.55k|}
tif_ojpeg.c:OJPEGReadSkip:
 2423|    260|{
 2424|    260|    uint16_t m;
 2425|    260|    uint16_t n;
 2426|    260|    m = len;
 2427|    260|    n = m;
 2428|    260|    if (n > sp->in_buffer_togo)
  ------------------
  |  Branch (2428:9): [True: 198, False: 62]
  ------------------
 2429|    198|        n = sp->in_buffer_togo;
 2430|    260|    sp->in_buffer_cur += n;
 2431|    260|    sp->in_buffer_togo = (uint16_t)(sp->in_buffer_togo - n);
 2432|    260|    m = (uint16_t)(m - n);
 2433|    260|    if (m > 0)
  ------------------
  |  Branch (2433:9): [True: 198, False: 62]
  ------------------
 2434|    198|    {
 2435|    198|        assert(sp->in_buffer_togo == 0);
  ------------------
  |  Branch (2435:9): [True: 0, False: 198]
  |  Branch (2435:9): [True: 198, False: 0]
  ------------------
 2436|    198|        n = m;
 2437|    198|        if ((uint64_t)n > sp->in_buffer_file_togo)
  ------------------
  |  Branch (2437:13): [True: 162, False: 36]
  ------------------
 2438|    162|            n = (uint16_t)sp->in_buffer_file_togo;
 2439|    198|        sp->in_buffer_file_pos += n;
 2440|    198|        sp->in_buffer_file_togo -= n;
 2441|    198|        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|    198|    }
 2449|    260|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamDqt:
 1695|  1.06k|{
 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|  1.06k|    static const char module[] = "OJPEGReadHeaderInfoSecStreamDqt";
 1699|  1.06k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1700|  1.06k|    uint16_t m;
 1701|  1.06k|    uint32_t na;
 1702|  1.06k|    uint8_t *nb;
 1703|  1.06k|    uint8_t o;
 1704|  1.06k|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (1704:9): [True: 0, False: 1.06k]
  ------------------
 1705|      0|        return (0);
 1706|  1.06k|    if (m <= 2)
  ------------------
  |  Branch (1706:9): [True: 0, False: 1.06k]
  ------------------
 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|  1.06k|    if (sp->subsamplingcorrect != 0)
  ------------------
  |  Branch (1712:9): [True: 10, False: 1.05k]
  ------------------
 1713|     10|        OJPEGReadSkip(sp, (uint16_t)(m - 2));
 1714|  1.05k|    else
 1715|  1.05k|    {
 1716|  1.05k|        m = (uint16_t)(m - 2);
 1717|  1.05k|        do
 1718|  1.16k|        {
 1719|  1.16k|            if (m < 65)
  ------------------
  |  Branch (1719:17): [True: 0, False: 1.16k]
  ------------------
 1720|      0|            {
 1721|      0|                TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
 1722|      0|                return (0);
 1723|      0|            }
 1724|  1.16k|            na = sizeof(uint32_t) + 69;
 1725|  1.16k|            nb = (uint8_t *)_TIFFmallocExt(tif, na);
 1726|  1.16k|            if (nb == 0)
  ------------------
  |  Branch (1726:17): [True: 0, False: 1.16k]
  ------------------
 1727|      0|            {
 1728|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1729|      0|                return (0);
 1730|      0|            }
 1731|  1.16k|            *(uint32_t *)nb = na;
 1732|  1.16k|            nb[sizeof(uint32_t)] = 255;
 1733|  1.16k|            nb[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
  ------------------
  |  |  166|  1.16k|#define JPEG_MARKER_DQT 0xDB
  ------------------
 1734|  1.16k|            nb[sizeof(uint32_t) + 2] = 0;
 1735|  1.16k|            nb[sizeof(uint32_t) + 3] = 67;
 1736|  1.16k|            if (OJPEGReadBlock(sp, 65, &nb[sizeof(uint32_t) + 4]) == 0)
  ------------------
  |  Branch (1736:17): [True: 0, False: 1.16k]
  ------------------
 1737|      0|            {
 1738|      0|                _TIFFfreeExt(tif, nb);
 1739|      0|                return (0);
 1740|      0|            }
 1741|  1.16k|            o = nb[sizeof(uint32_t) + 4] & 15;
 1742|  1.16k|            if (3 < o)
  ------------------
  |  Branch (1742:17): [True: 1.05k, False: 112]
  ------------------
 1743|  1.05k|            {
 1744|  1.05k|                TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
 1745|  1.05k|                _TIFFfreeExt(tif, nb);
 1746|  1.05k|                return (0);
 1747|  1.05k|            }
 1748|    112|            if (sp->qtable[o] != 0)
  ------------------
  |  Branch (1748:17): [True: 91, False: 21]
  ------------------
 1749|     91|                _TIFFfreeExt(tif, sp->qtable[o]);
 1750|    112|            sp->qtable[o] = nb;
 1751|    112|            m = (uint16_t)(m - 65);
 1752|    112|        } while (m > 0);
  ------------------
  |  Branch (1752:18): [True: 112, False: 0]
  ------------------
 1753|  1.05k|    }
 1754|     10|    return (1);
 1755|  1.06k|}
tif_ojpeg.c:OJPEGReadBlock:
 2395|  1.16k|{
 2396|  1.16k|    uint16_t mlen;
 2397|  1.16k|    uint8_t *mmem;
 2398|  1.16k|    uint16_t n;
 2399|  1.16k|    assert(len > 0);
  ------------------
  |  Branch (2399:5): [True: 0, False: 1.16k]
  |  Branch (2399:5): [True: 1.16k, False: 0]
  ------------------
 2400|  1.16k|    mlen = len;
 2401|  1.16k|    mmem = (uint8_t *)mem;
 2402|  1.16k|    do
 2403|  1.16k|    {
 2404|  1.16k|        if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2404:13): [True: 0, False: 1.16k]
  ------------------
 2405|      0|        {
 2406|      0|            if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2406:17): [True: 0, False: 0]
  ------------------
 2407|      0|                return (0);
 2408|      0|            assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2408:13): [True: 0, False: 0]
  |  Branch (2408:13): [True: 0, False: 0]
  ------------------
 2409|      0|        }
 2410|  1.16k|        n = mlen;
 2411|  1.16k|        if (n > sp->in_buffer_togo)
  ------------------
  |  Branch (2411:13): [True: 0, False: 1.16k]
  ------------------
 2412|      0|            n = sp->in_buffer_togo;
 2413|  1.16k|        _TIFFmemcpy(mmem, sp->in_buffer_cur, n);
 2414|  1.16k|        sp->in_buffer_cur += n;
 2415|  1.16k|        sp->in_buffer_togo = (uint16_t)(sp->in_buffer_togo - n);
 2416|  1.16k|        mlen = (uint16_t)(mlen - n);
 2417|  1.16k|        mmem += n;
 2418|  1.16k|    } while (mlen > 0);
  ------------------
  |  Branch (2418:14): [True: 0, False: 1.16k]
  ------------------
 2419|  1.16k|    return (1);
 2420|  1.16k|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecStreamSos:
 2008|    320|{
 2009|       |    /* this marker needs to be checked, and part of its data needs to be saved
 2010|       |     * for regeneration later on */
 2011|    320|    static const char module[] = "OJPEGReadHeaderInfoSecStreamSos";
 2012|    320|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2013|    320|    uint16_t m;
 2014|    320|    uint8_t n;
 2015|    320|    uint8_t o;
 2016|    320|    assert(sp->subsamplingcorrect == 0);
  ------------------
  |  Branch (2016:5): [True: 0, False: 320]
  |  Branch (2016:5): [True: 320, False: 0]
  ------------------
 2017|    320|    if (sp->sof_log == 0)
  ------------------
  |  Branch (2017:9): [True: 0, False: 320]
  ------------------
 2018|      0|    {
 2019|      0|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2020|      0|        return (0);
 2021|      0|    }
 2022|       |    /* Ls */
 2023|    320|    if (OJPEGReadWord(sp, &m) == 0)
  ------------------
  |  Branch (2023:9): [True: 0, False: 320]
  ------------------
 2024|      0|        return (0);
 2025|    320|    if (m != 6 + sp->samples_per_pixel_per_plane * 2)
  ------------------
  |  Branch (2025:9): [True: 238, False: 82]
  ------------------
 2026|    238|    {
 2027|    238|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2028|    238|        return (0);
 2029|    238|    }
 2030|       |    /* Ns */
 2031|     82|    if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2031:9): [True: 0, False: 82]
  ------------------
 2032|      0|        return (0);
 2033|     82|    if (n != sp->samples_per_pixel_per_plane)
  ------------------
  |  Branch (2033:9): [True: 0, False: 82]
  ------------------
 2034|      0|    {
 2035|      0|        TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
 2036|      0|        return (0);
 2037|      0|    }
 2038|       |    /* Cs, Td, and Ta */
 2039|    164|    for (o = 0; o < sp->samples_per_pixel_per_plane; o++)
  ------------------
  |  Branch (2039:17): [True: 82, False: 82]
  ------------------
 2040|     82|    {
 2041|       |        /* Cs */
 2042|     82|        if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2042:13): [True: 0, False: 82]
  ------------------
 2043|      0|            return (0);
 2044|     82|        sp->sos_cs[sp->plane_sample_offset + o] = n;
 2045|       |        /* Td and Ta */
 2046|     82|        if (OJPEGReadByte(sp, &n) == 0)
  ------------------
  |  Branch (2046:13): [True: 0, False: 82]
  ------------------
 2047|      0|            return (0);
 2048|     82|        sp->sos_tda[sp->plane_sample_offset + o] = n;
 2049|     82|    }
 2050|       |    /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as
 2051|       |     * per LibJpeg source */
 2052|     82|    OJPEGReadSkip(sp, 3);
 2053|     82|    return (1);
 2054|     82|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesQTable:
 2057|     84|{
 2058|     84|    static const char module[] = "OJPEGReadHeaderInfoSecTablesQTable";
 2059|     84|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2060|     84|    uint8_t m;
 2061|     84|    uint8_t n;
 2062|     84|    uint32_t oa;
 2063|     84|    uint8_t *ob;
 2064|     84|    uint32_t p;
 2065|     84|    if (sp->qtable_offset[0] == 0)
  ------------------
  |  Branch (2065:9): [True: 0, False: 84]
  ------------------
 2066|      0|    {
 2067|      0|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2068|      0|        return (0);
 2069|      0|    }
 2070|     84|    sp->in_buffer_file_pos_log = 0;
 2071|    293|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2071:17): [True: 210, False: 83]
  ------------------
 2072|    210|    {
 2073|    210|        if ((sp->qtable_offset[m] != 0) &&
  ------------------
  |  Branch (2073:13): [True: 84, False: 126]
  ------------------
 2074|     84|            ((m == 0) || (sp->qtable_offset[m] != sp->qtable_offset[m - 1])))
  ------------------
  |  Branch (2074:14): [True: 84, False: 0]
  |  Branch (2074:26): [True: 0, False: 0]
  ------------------
 2075|     84|        {
 2076|     84|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2076:25): [True: 0, False: 84]
  ------------------
 2077|      0|            {
 2078|      0|                if (sp->qtable_offset[m] == sp->qtable_offset[n])
  ------------------
  |  Branch (2078:21): [True: 0, False: 0]
  ------------------
 2079|      0|                {
 2080|      0|                    TIFFErrorExtR(tif, module, "Corrupt JpegQTables tag value");
 2081|      0|                    return (0);
 2082|      0|                }
 2083|      0|            }
 2084|     84|            oa = sizeof(uint32_t) + 69;
 2085|     84|            ob = (uint8_t *)_TIFFmallocExt(tif, oa);
 2086|     84|            if (ob == 0)
  ------------------
  |  Branch (2086:17): [True: 0, False: 84]
  ------------------
 2087|      0|            {
 2088|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2089|      0|                return (0);
 2090|      0|            }
 2091|     84|            *(uint32_t *)ob = oa;
 2092|     84|            ob[sizeof(uint32_t)] = 255;
 2093|     84|            ob[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
  ------------------
  |  |  166|     84|#define JPEG_MARKER_DQT 0xDB
  ------------------
 2094|     84|            ob[sizeof(uint32_t) + 2] = 0;
 2095|     84|            ob[sizeof(uint32_t) + 3] = 67;
 2096|     84|            ob[sizeof(uint32_t) + 4] = m;
 2097|     84|            TIFFSeekFile(tif, sp->qtable_offset[m], SEEK_SET);
  ------------------
  |  |  287|     84|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2098|     84|            p = (uint32_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64);
  ------------------
  |  |  283|     84|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2099|     84|            if (p != 64)
  ------------------
  |  Branch (2099:17): [True: 1, False: 83]
  ------------------
 2100|      1|            {
 2101|      1|                _TIFFfreeExt(tif, ob);
 2102|      1|                return (0);
 2103|      1|            }
 2104|     83|            if (sp->qtable[m] != 0)
  ------------------
  |  Branch (2104:17): [True: 0, False: 83]
  ------------------
 2105|      0|                _TIFFfreeExt(tif, sp->qtable[m]);
 2106|     83|            sp->qtable[m] = ob;
 2107|     83|            sp->sof_tq[m] = m;
 2108|     83|        }
 2109|    126|        else
 2110|    126|            sp->sof_tq[m] = sp->sof_tq[m - 1];
 2111|    210|    }
 2112|     83|    return (1);
 2113|     84|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesDcTable:
 2116|     83|{
 2117|     83|    static const char module[] = "OJPEGReadHeaderInfoSecTablesDcTable";
 2118|     83|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2119|     83|    uint8_t m;
 2120|     83|    uint8_t n;
 2121|     83|    uint8_t o[16];
 2122|     83|    uint32_t p;
 2123|     83|    uint32_t q;
 2124|     83|    uint32_t ra;
 2125|     83|    uint8_t *rb;
 2126|     83|    if (sp->dctable_offset[0] == 0)
  ------------------
  |  Branch (2126:9): [True: 62, False: 21]
  ------------------
 2127|     62|    {
 2128|     62|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2129|     62|        return (0);
 2130|     62|    }
 2131|     21|    sp->in_buffer_file_pos_log = 0;
 2132|     46|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2132:17): [True: 25, False: 21]
  ------------------
 2133|     25|    {
 2134|     25|        if ((sp->dctable_offset[m] != 0) &&
  ------------------
  |  Branch (2134:13): [True: 23, False: 2]
  ------------------
 2135|     23|            ((m == 0) || (sp->dctable_offset[m] != sp->dctable_offset[m - 1])))
  ------------------
  |  Branch (2135:14): [True: 21, False: 2]
  |  Branch (2135:26): [True: 2, False: 0]
  ------------------
 2136|     23|        {
 2137|     25|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2137:25): [True: 2, False: 23]
  ------------------
 2138|      2|            {
 2139|      2|                if (sp->dctable_offset[m] == sp->dctable_offset[n])
  ------------------
  |  Branch (2139:21): [True: 0, False: 2]
  ------------------
 2140|      0|                {
 2141|      0|                    TIFFErrorExtR(tif, module,
 2142|      0|                                  "Corrupt JpegDcTables tag value");
 2143|      0|                    return (0);
 2144|      0|                }
 2145|      2|            }
 2146|     23|            TIFFSeekFile(tif, sp->dctable_offset[m], SEEK_SET);
  ------------------
  |  |  287|     23|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2147|     23|            p = (uint32_t)TIFFReadFile(tif, o, 16);
  ------------------
  |  |  283|     23|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2148|     23|            if (p != 16)
  ------------------
  |  Branch (2148:17): [True: 0, False: 23]
  ------------------
 2149|      0|                return (0);
 2150|     23|            q = 0;
 2151|    391|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2151:25): [True: 368, False: 23]
  ------------------
 2152|    368|                q += o[n];
 2153|     23|            ra = (uint32_t)(sizeof(uint32_t) + 21 + q);
 2154|     23|            rb = (uint8_t *)_TIFFmallocExt(tif, ra);
 2155|     23|            if (rb == 0)
  ------------------
  |  Branch (2155:17): [True: 0, False: 23]
  ------------------
 2156|      0|            {
 2157|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2158|      0|                return (0);
 2159|      0|            }
 2160|     23|            *(uint32_t *)rb = ra;
 2161|     23|            rb[sizeof(uint32_t)] = 255;
 2162|     23|            rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
  ------------------
  |  |  161|     23|#define JPEG_MARKER_DHT 0xC4
  ------------------
 2163|     23|            rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
 2164|     23|            rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
 2165|     23|            rb[sizeof(uint32_t) + 4] = m;
 2166|    391|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2166:25): [True: 368, False: 23]
  ------------------
 2167|    368|                rb[sizeof(uint32_t) + 5 + n] = o[n];
 2168|     23|            p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
  ------------------
  |  |  283|     23|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2169|     23|            if (p != q)
  ------------------
  |  Branch (2169:17): [True: 0, False: 23]
  ------------------
 2170|      0|            {
 2171|      0|                _TIFFfreeExt(tif, rb);
 2172|      0|                return (0);
 2173|      0|            }
 2174|     23|            if (sp->dctable[m] != 0)
  ------------------
  |  Branch (2174:17): [True: 0, False: 23]
  ------------------
 2175|      0|                _TIFFfreeExt(tif, sp->dctable[m]);
 2176|     23|            sp->dctable[m] = rb;
 2177|     23|            sp->sos_tda[m] = (uint8_t)(m << 4);
 2178|     23|        }
 2179|      2|        else
 2180|      2|            sp->sos_tda[m] = sp->sos_tda[m - 1];
 2181|     25|    }
 2182|     21|    return (1);
 2183|     21|}
tif_ojpeg.c:OJPEGReadHeaderInfoSecTablesAcTable:
 2186|     21|{
 2187|     21|    static const char module[] = "OJPEGReadHeaderInfoSecTablesAcTable";
 2188|     21|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2189|     21|    uint8_t m;
 2190|     21|    uint8_t n;
 2191|     21|    uint8_t o[16];
 2192|     21|    uint32_t p;
 2193|     21|    uint32_t q;
 2194|     21|    uint32_t ra;
 2195|     21|    uint8_t *rb;
 2196|     21|    if (sp->actable_offset[0] == 0)
  ------------------
  |  Branch (2196:9): [True: 2, False: 19]
  ------------------
 2197|      2|    {
 2198|      2|        TIFFErrorExtR(tif, module, "Missing JPEG tables");
 2199|      2|        return (0);
 2200|      2|    }
 2201|     19|    sp->in_buffer_file_pos_log = 0;
 2202|     38|    for (m = 0; m < sp->samples_per_pixel; m++)
  ------------------
  |  Branch (2202:17): [True: 19, False: 19]
  ------------------
 2203|     19|    {
 2204|     19|        if ((sp->actable_offset[m] != 0) &&
  ------------------
  |  Branch (2204:13): [True: 19, False: 0]
  ------------------
 2205|     19|            ((m == 0) || (sp->actable_offset[m] != sp->actable_offset[m - 1])))
  ------------------
  |  Branch (2205:14): [True: 19, False: 0]
  |  Branch (2205:26): [True: 0, False: 0]
  ------------------
 2206|     19|        {
 2207|     19|            for (n = 0; n < m - 1; n++)
  ------------------
  |  Branch (2207:25): [True: 0, False: 19]
  ------------------
 2208|      0|            {
 2209|      0|                if (sp->actable_offset[m] == sp->actable_offset[n])
  ------------------
  |  Branch (2209:21): [True: 0, False: 0]
  ------------------
 2210|      0|                {
 2211|      0|                    TIFFErrorExtR(tif, module,
 2212|      0|                                  "Corrupt JpegAcTables tag value");
 2213|      0|                    return (0);
 2214|      0|                }
 2215|      0|            }
 2216|     19|            TIFFSeekFile(tif, sp->actable_offset[m], SEEK_SET);
  ------------------
  |  |  287|     19|    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
  ------------------
 2217|     19|            p = (uint32_t)TIFFReadFile(tif, o, 16);
  ------------------
  |  |  283|     19|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2218|     19|            if (p != 16)
  ------------------
  |  Branch (2218:17): [True: 0, False: 19]
  ------------------
 2219|      0|                return (0);
 2220|     19|            q = 0;
 2221|    323|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2221:25): [True: 304, False: 19]
  ------------------
 2222|    304|                q += o[n];
 2223|     19|            ra = (uint32_t)(sizeof(uint32_t) + 21 + q);
 2224|     19|            rb = (uint8_t *)_TIFFmallocExt(tif, ra);
 2225|     19|            if (rb == 0)
  ------------------
  |  Branch (2225:17): [True: 0, False: 19]
  ------------------
 2226|      0|            {
 2227|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 2228|      0|                return (0);
 2229|      0|            }
 2230|     19|            *(uint32_t *)rb = ra;
 2231|     19|            rb[sizeof(uint32_t)] = 255;
 2232|     19|            rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
  ------------------
  |  |  161|     19|#define JPEG_MARKER_DHT 0xC4
  ------------------
 2233|     19|            rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
 2234|     19|            rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
 2235|     19|            rb[sizeof(uint32_t) + 4] = (16 | m);
 2236|    323|            for (n = 0; n < 16; n++)
  ------------------
  |  Branch (2236:25): [True: 304, False: 19]
  ------------------
 2237|    304|                rb[sizeof(uint32_t) + 5 + n] = o[n];
 2238|     19|            p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
  ------------------
  |  |  283|     19|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
 2239|     19|            if (p != q)
  ------------------
  |  Branch (2239:17): [True: 0, False: 19]
  ------------------
 2240|      0|            {
 2241|      0|                _TIFFfreeExt(tif, rb);
 2242|      0|                return (0);
 2243|      0|            }
 2244|     19|            if (sp->actable[m] != 0)
  ------------------
  |  Branch (2244:17): [True: 0, False: 19]
  ------------------
 2245|      0|                _TIFFfreeExt(tif, sp->actable[m]);
 2246|     19|            sp->actable[m] = rb;
 2247|     19|            sp->sos_tda[m] = (sp->sos_tda[m] | m);
 2248|     19|        }
 2249|      0|        else
 2250|      0|            sp->sos_tda[m] = (sp->sos_tda[m] | (sp->sos_tda[m - 1] & 15));
 2251|     19|    }
 2252|     19|    return (1);
 2253|     19|}
tif_ojpeg.c:OJPEGVSetField:
  560|  1.96k|{
  561|  1.96k|    static const char module[] = "OJPEGVSetField";
  562|  1.96k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  563|  1.96k|    uint32_t ma;
  564|  1.96k|    uint64_t *mb;
  565|  1.96k|    uint32_t n;
  566|  1.96k|    const TIFFField *fip;
  567|       |
  568|  1.96k|    switch (tag)
  569|  1.96k|    {
  570|      1|        case TIFFTAG_JPEGIFOFFSET:
  ------------------
  |  |  379|      1|#define TIFFTAG_JPEGIFOFFSET 513           /* !pointer to SOI marker */
  ------------------
  |  Branch (570:9): [True: 1, False: 1.96k]
  ------------------
  571|      1|            sp->jpeg_interchange_format = (uint64_t)va_arg(ap, uint64_t);
  572|      1|            break;
  573|      0|        case TIFFTAG_JPEGIFBYTECOUNT:
  ------------------
  |  |  380|      0|#define TIFFTAG_JPEGIFBYTECOUNT 514        /* !JFIF stream length */
  ------------------
  |  Branch (573:9): [True: 0, False: 1.96k]
  ------------------
  574|      0|            sp->jpeg_interchange_format_length = (uint64_t)va_arg(ap, uint64_t);
  575|      0|            break;
  576|     20|        case TIFFTAG_YCBCRSUBSAMPLING:
  ------------------
  |  |  388|     20|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  |  Branch (576:9): [True: 20, False: 1.94k]
  ------------------
  577|     20|            sp->subsampling_tag = 1;
  578|     20|            sp->subsampling_hor = (uint8_t)va_arg(ap, uint16_vap);
  579|     20|            sp->subsampling_ver = (uint8_t)va_arg(ap, uint16_vap);
  580|     20|            tif->tif_dir.td_ycbcrsubsampling[0] = sp->subsampling_hor;
  581|     20|            tif->tif_dir.td_ycbcrsubsampling[1] = sp->subsampling_ver;
  582|     20|            break;
  583|     99|        case TIFFTAG_JPEGQTABLES:
  ------------------
  |  |  384|     99|#define TIFFTAG_JPEGQTABLES 519            /* !Q matrix offsets */
  ------------------
  |  Branch (583:9): [True: 99, False: 1.86k]
  ------------------
  584|     99|            ma = (uint32_t)va_arg(ap, uint32_t);
  585|     99|            if (ma != 0)
  ------------------
  |  Branch (585:17): [True: 99, False: 0]
  ------------------
  586|     99|            {
  587|     99|                if (ma > 3)
  ------------------
  |  Branch (587:21): [True: 0, False: 99]
  ------------------
  588|      0|                {
  589|      0|                    TIFFErrorExtR(tif, module,
  590|      0|                                  "JpegQTables tag has incorrect count");
  591|      0|                    return (0);
  592|      0|                }
  593|     99|                sp->qtable_offset_count = (uint8_t)ma;
  594|     99|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  595|    214|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (595:29): [True: 115, False: 99]
  ------------------
  596|    115|                    sp->qtable_offset[n] = mb[n];
  597|     99|            }
  598|     99|            break;
  599|     99|        case TIFFTAG_JPEGDCTABLES:
  ------------------
  |  |  385|     90|#define TIFFTAG_JPEGDCTABLES 520           /* !DCT table offsets */
  ------------------
  |  Branch (599:9): [True: 90, False: 1.87k]
  ------------------
  600|     90|            ma = (uint32_t)va_arg(ap, uint32_t);
  601|     90|            if (ma != 0)
  ------------------
  |  Branch (601:17): [True: 90, False: 0]
  ------------------
  602|     90|            {
  603|     90|                if (ma > 3)
  ------------------
  |  Branch (603:21): [True: 68, False: 22]
  ------------------
  604|     68|                {
  605|     68|                    TIFFErrorExtR(tif, module,
  606|     68|                                  "JpegDcTables tag has incorrect count");
  607|     68|                    return (0);
  608|     68|                }
  609|     22|                sp->dctable_offset_count = (uint8_t)ma;
  610|     22|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  611|     88|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (611:29): [True: 66, False: 22]
  ------------------
  612|     66|                    sp->dctable_offset[n] = mb[n];
  613|     22|            }
  614|     22|            break;
  615|     25|        case TIFFTAG_JPEGACTABLES:
  ------------------
  |  |  386|     25|#define TIFFTAG_JPEGACTABLES 521           /* !AC coefficient offsets */
  ------------------
  |  Branch (615:9): [True: 25, False: 1.94k]
  ------------------
  616|     25|            ma = (uint32_t)va_arg(ap, uint32_t);
  617|     25|            if (ma != 0)
  ------------------
  |  Branch (617:17): [True: 25, False: 0]
  ------------------
  618|     25|            {
  619|     25|                if (ma > 3)
  ------------------
  |  Branch (619:21): [True: 0, False: 25]
  ------------------
  620|      0|                {
  621|      0|                    TIFFErrorExtR(tif, module,
  622|      0|                                  "JpegAcTables tag has incorrect count");
  623|      0|                    return (0);
  624|      0|                }
  625|     25|                sp->actable_offset_count = (uint8_t)ma;
  626|     25|                mb = (uint64_t *)va_arg(ap, uint64_t *);
  627|    100|                for (n = 0; n < ma; n++)
  ------------------
  |  Branch (627:29): [True: 75, False: 25]
  ------------------
  628|     75|                    sp->actable_offset[n] = mb[n];
  629|     25|            }
  630|     25|            break;
  631|     25|        case TIFFTAG_JPEGPROC:
  ------------------
  |  |  376|      7|#define TIFFTAG_JPEGPROC 512               /* !JPEG processing algorithm */
  ------------------
  |  Branch (631:9): [True: 7, False: 1.96k]
  ------------------
  632|      7|            sp->jpeg_proc = (uint8_t)va_arg(ap, uint16_vap);
  633|      7|            break;
  634|      0|        case TIFFTAG_JPEGRESTARTINTERVAL:
  ------------------
  |  |  381|      0|#define TIFFTAG_JPEGRESTARTINTERVAL 515    /* !restart interval length */
  ------------------
  |  Branch (634:9): [True: 0, False: 1.96k]
  ------------------
  635|      0|            sp->restart_interval = (uint16_t)va_arg(ap, uint16_vap);
  636|      0|            break;
  637|  1.72k|        default:
  ------------------
  |  Branch (637:9): [True: 1.72k, False: 242]
  ------------------
  638|  1.72k|            return (*sp->vsetparent)(tif, tag, ap);
  639|  1.96k|    }
  640|    174|    fip = TIFFFieldWithTag(tif, tag);
  641|    174|    if (fip == NULL) /* shouldn't happen */
  ------------------
  |  Branch (641:9): [True: 0, False: 174]
  ------------------
  642|      0|        return (0);
  643|    174|    TIFFSetFieldBit(tif, fip->field_bit);
  ------------------
  |  |  249|    174|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|    174|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|    174|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
  644|    174|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|    174|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
  645|    174|    return (1);
  646|    174|}
tif_ojpeg.c:OJPEGFixupTags:
  691|    132|{
  692|    132|    (void)tif;
  693|    132|    return (1);
  694|    132|}
tif_ojpeg.c:OJPEGSetupDecode:
  697|    131|{
  698|    131|    static const char module[] = "OJPEGSetupDecode";
  699|    131|    TIFFWarningExtR(tif, module,
  700|    131|                    "Deprecated and troublesome old-style JPEG compression "
  701|    131|                    "mode, please convert to new-style JPEG compression and "
  702|    131|                    "notify vendor of writing software");
  703|    131|    return (1);
  704|    131|}
tif_ojpeg.c:OJPEGPreDecode:
  707|  16.3k|{
  708|  16.3k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  709|  16.3k|    uint32_t m;
  710|  16.3k|    if (sp->subsamplingcorrect_done == 0)
  ------------------
  |  Branch (710:9): [True: 85, False: 16.3k]
  ------------------
  711|     85|        OJPEGSubsamplingCorrect(tif);
  712|  16.3k|    if (sp->readheader_done == 0)
  ------------------
  |  Branch (712:9): [True: 13.5k, False: 2.82k]
  ------------------
  713|  13.5k|    {
  714|  13.5k|        if (OJPEGReadHeaderInfo(tif) == 0)
  ------------------
  |  Branch (714:13): [True: 13.4k, False: 79]
  ------------------
  715|  13.4k|            return (0);
  716|  13.5k|    }
  717|  2.90k|    if (sp->sos_end[s].log == 0)
  ------------------
  |  Branch (717:9): [True: 612, False: 2.28k]
  ------------------
  718|    612|    {
  719|    612|        if (OJPEGReadSecondarySos(tif, s) == 0)
  ------------------
  |  Branch (719:13): [True: 530, False: 82]
  ------------------
  720|    530|            return (0);
  721|    612|    }
  722|  2.37k|    if (isTiled(tif))
  ------------------
  |  |  278|  2.37k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  2.37k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 2.05k, False: 321]
  |  |  ------------------
  ------------------
  723|  2.05k|        m = tif->tif_dir.td_curtile;
  724|    321|    else
  725|    321|        m = tif->tif_dir.td_curstrip;
  726|  2.37k|    if ((sp->writeheader_done != 0) &&
  ------------------
  |  Branch (726:9): [True: 1.86k, False: 502]
  ------------------
  727|  1.86k|        ((sp->write_cursample != s) || (sp->write_curstrile > m)))
  ------------------
  |  Branch (727:10): [True: 729, False: 1.14k]
  |  Branch (727:40): [True: 1, False: 1.13k]
  ------------------
  728|    730|    {
  729|    730|        if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (729:13): [True: 730, False: 0]
  ------------------
  730|    730|            OJPEGLibjpegSessionAbort(tif);
  731|    730|        sp->writeheader_done = 0;
  732|    730|    }
  733|  2.37k|    if (sp->writeheader_done == 0)
  ------------------
  |  Branch (733:9): [True: 1.23k, False: 1.13k]
  ------------------
  734|  1.23k|    {
  735|  1.23k|        sp->plane_sample_offset = (uint8_t)s;
  736|  1.23k|        sp->write_cursample = s;
  737|  1.23k|        sp->write_curstrile = s * tif->tif_dir.td_stripsperimage;
  738|  1.23k|        if ((sp->in_buffer_file_pos_log == 0) ||
  ------------------
  |  Branch (738:13): [True: 162, False: 1.07k]
  ------------------
  739|  1.07k|            (sp->in_buffer_file_pos - sp->in_buffer_togo !=
  ------------------
  |  Branch (739:13): [True: 688, False: 382]
  ------------------
  740|  1.07k|             sp->sos_end[s].in_buffer_file_pos))
  741|    850|        {
  742|    850|            sp->in_buffer_source = sp->sos_end[s].in_buffer_source;
  743|    850|            sp->in_buffer_next_strile = sp->sos_end[s].in_buffer_next_strile;
  744|    850|            sp->in_buffer_file_pos = sp->sos_end[s].in_buffer_file_pos;
  745|    850|            sp->in_buffer_file_pos_log = 0;
  746|    850|            sp->in_buffer_file_togo = sp->sos_end[s].in_buffer_file_togo;
  747|    850|            sp->in_buffer_togo = 0;
  748|    850|            sp->in_buffer_cur = 0;
  749|    850|        }
  750|  1.23k|        if (OJPEGWriteHeaderInfo(tif) == 0)
  ------------------
  |  Branch (750:13): [True: 344, False: 888]
  ------------------
  751|    344|            return (0);
  752|  1.23k|    }
  753|       |
  754|  2.02k|    sp->subsampling_convert_state = 0;
  755|       |
  756|  26.8k|    while (sp->write_curstrile < m)
  ------------------
  |  Branch (756:12): [True: 25.1k, False: 1.77k]
  ------------------
  757|  25.1k|    {
  758|  25.1k|        if (sp->libjpeg_jpeg_query_style == 0)
  ------------------
  |  Branch (758:13): [True: 0, False: 25.1k]
  ------------------
  759|      0|        {
  760|      0|            if (OJPEGPreDecodeSkipRaw(tif) == 0)
  ------------------
  |  Branch (760:17): [True: 0, False: 0]
  ------------------
  761|      0|                return (0);
  762|      0|        }
  763|  25.1k|        else
  764|  25.1k|        {
  765|  25.1k|            if (OJPEGPreDecodeSkipScanlines(tif) == 0)
  ------------------
  |  Branch (765:17): [True: 249, False: 24.8k]
  ------------------
  766|    249|                return (0);
  767|  25.1k|        }
  768|  24.8k|        sp->write_curstrile++;
  769|  24.8k|    }
  770|  1.77k|    sp->decoder_ok = 1;
  771|  1.77k|    return (1);
  772|  2.02k|}
tif_ojpeg.c:OJPEGReadHeaderInfo:
 1167|  13.5k|{
 1168|  13.5k|    static const char module[] = "OJPEGReadHeaderInfo";
 1169|  13.5k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1170|  13.5k|    assert(sp->readheader_done == 0);
  ------------------
  |  Branch (1170:5): [True: 0, False: 13.5k]
  |  Branch (1170:5): [True: 13.5k, False: 0]
  ------------------
 1171|  13.5k|    sp->image_width = tif->tif_dir.td_imagewidth;
 1172|  13.5k|    sp->image_length = tif->tif_dir.td_imagelength;
 1173|  13.5k|    if (isTiled(tif))
  ------------------
  |  |  278|  13.5k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  13.5k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  |  |  |  Branch (278:22): [True: 12.4k, False: 1.15k]
  |  |  ------------------
  ------------------
 1174|  12.4k|    {
 1175|  12.4k|        sp->strile_width = tif->tif_dir.td_tilewidth;
 1176|  12.4k|        sp->strile_length = tif->tif_dir.td_tilelength;
 1177|  12.4k|        sp->strile_length_total =
 1178|  12.4k|            ((sp->image_length + sp->strile_length - 1) / sp->strile_length) *
 1179|  12.4k|            sp->strile_length;
 1180|  12.4k|    }
 1181|  1.15k|    else
 1182|  1.15k|    {
 1183|  1.15k|        sp->strile_width = sp->image_width;
 1184|  1.15k|        sp->strile_length = tif->tif_dir.td_rowsperstrip;
 1185|  1.15k|        if (sp->strile_length == (uint32_t)-1)
  ------------------
  |  Branch (1185:13): [True: 2, False: 1.15k]
  ------------------
 1186|      2|            sp->strile_length = sp->image_length;
 1187|  1.15k|        sp->strile_length_total = sp->image_length;
 1188|  1.15k|    }
 1189|  13.5k|    if (tif->tif_dir.td_samplesperpixel == 1)
  ------------------
  |  Branch (1189:9): [True: 21, False: 13.5k]
  ------------------
 1190|     21|    {
 1191|     21|        sp->samples_per_pixel = 1;
 1192|     21|        sp->plane_sample_offset = 0;
 1193|     21|        sp->samples_per_pixel_per_plane = sp->samples_per_pixel;
 1194|     21|        sp->subsampling_hor = 1;
 1195|     21|        sp->subsampling_ver = 1;
 1196|     21|    }
 1197|  13.5k|    else
 1198|  13.5k|    {
 1199|  13.5k|        if (tif->tif_dir.td_samplesperpixel != 3)
  ------------------
  |  Branch (1199:13): [True: 12.2k, False: 1.25k]
  ------------------
 1200|  12.2k|        {
 1201|  12.2k|            TIFFErrorExtR(tif, module,
 1202|  12.2k|                          "SamplesPerPixel %" PRIu8
 1203|  12.2k|                          " not supported for this compression scheme",
 1204|  12.2k|                          sp->samples_per_pixel);
 1205|  12.2k|            return (0);
 1206|  12.2k|        }
 1207|  1.25k|        sp->samples_per_pixel = 3;
 1208|  1.25k|        sp->plane_sample_offset = 0;
 1209|  1.25k|        if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|  1.25k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (1209:13): [True: 1.12k, False: 126]
  ------------------
 1210|  1.12k|            sp->samples_per_pixel_per_plane = 3;
 1211|    126|        else
 1212|    126|            sp->samples_per_pixel_per_plane = 1;
 1213|  1.25k|    }
 1214|  1.27k|    if (sp->strile_length < sp->image_length)
  ------------------
  |  Branch (1214:9): [True: 1.10k, False: 166]
  ------------------
 1215|  1.10k|    {
 1216|  1.10k|        if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) &&
  ------------------
  |  Branch (1216:14): [True: 1.07k, False: 28]
  |  Branch (1216:44): [True: 0, False: 1.07k]
  ------------------
 1217|      0|             (sp->subsampling_hor != 4)) ||
  ------------------
  |  Branch (1217:14): [True: 0, False: 0]
  ------------------
 1218|  1.10k|            ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) &&
  ------------------
  |  Branch (1218:14): [True: 1.07k, False: 28]
  |  Branch (1218:44): [True: 0, False: 1.07k]
  ------------------
 1219|      0|             (sp->subsampling_ver != 4)))
  ------------------
  |  Branch (1219:14): [True: 0, False: 0]
  ------------------
 1220|      0|        {
 1221|      0|            TIFFErrorExtR(tif, module, "Invalid subsampling values");
 1222|      0|            return (0);
 1223|      0|        }
 1224|  1.10k|        if (sp->strile_length % ((uint32_t)sp->subsampling_ver * 8) != 0)
  ------------------
  |  Branch (1224:13): [True: 0, False: 1.10k]
  ------------------
 1225|      0|        {
 1226|      0|            TIFFErrorExtR(tif, module,
 1227|      0|                          "Incompatible vertical subsampling and image "
 1228|      0|                          "strip/tile length");
 1229|      0|            return (0);
 1230|      0|        }
 1231|  1.10k|        {
 1232|       |            /* Values were validated above as 1, 2, or 4. */
 1233|  1.10k|            uint32_t mcu_width = (uint32_t)sp->subsampling_hor * 8;
 1234|  1.10k|            uint32_t mcu_height = (uint32_t)sp->subsampling_ver * 8;
 1235|  1.10k|            uint32_t mcu_cols =
 1236|  1.10k|                TIFFhowmany_32_maxuint_compat(sp->strile_width, mcu_width);
  ------------------
  |  |  318|  1.10k|    (((uint32_t)(x) / (uint32_t)(y)) +                                         \
  |  |  319|  1.10k|     ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
  |  |  ------------------
  |  |  |  Branch (319:7): [True: 1.10k, False: 6]
  |  |  ------------------
  ------------------
 1237|  1.10k|            uint32_t mcu_rows = sp->strile_length / mcu_height;
 1238|  1.10k|            if (mcu_cols == 0 || mcu_rows == 0)
  ------------------
  |  Branch (1238:17): [True: 0, False: 1.10k]
  |  Branch (1238:34): [True: 0, False: 1.10k]
  ------------------
 1239|      0|            {
 1240|      0|                sp->restart_interval = 0;
 1241|      0|            }
 1242|  1.10k|            else
 1243|  1.10k|            {
 1244|  1.10k|                uint32_t restart_interval =
 1245|  1.10k|                    _TIFFMultiply32(tif, mcu_cols, mcu_rows, module);
 1246|  1.10k|                if (restart_interval == 0 || restart_interval > UINT16_MAX)
  ------------------
  |  Branch (1246:21): [True: 0, False: 1.10k]
  |  Branch (1246:46): [True: 0, False: 1.10k]
  ------------------
 1247|      0|                {
 1248|      0|                    TIFFErrorExtR(tif, module,
 1249|      0|                                  "Integer overflow in restart interval");
 1250|      0|                    return (0);
 1251|      0|                }
 1252|  1.10k|                sp->restart_interval = (uint16_t)restart_interval;
 1253|  1.10k|            }
 1254|  1.10k|        }
 1255|  1.10k|    }
 1256|  1.27k|    if (OJPEGReadHeaderInfoSec(tif) == 0)
  ------------------
  |  Branch (1256:9): [True: 1.19k, False: 79]
  ------------------
 1257|  1.19k|        return (0);
 1258|     79|    sp->sos_end[0].log = 1;
 1259|     79|    sp->sos_end[0].in_buffer_source = sp->in_buffer_source;
 1260|     79|    sp->sos_end[0].in_buffer_next_strile = sp->in_buffer_next_strile;
 1261|     79|    sp->sos_end[0].in_buffer_file_pos =
 1262|     79|        sp->in_buffer_file_pos - sp->in_buffer_togo;
 1263|     79|    sp->sos_end[0].in_buffer_file_togo =
 1264|     79|        sp->in_buffer_file_togo + sp->in_buffer_togo;
 1265|     79|    sp->readheader_done = 1;
 1266|     79|    return (1);
 1267|  1.27k|}
tif_ojpeg.c:OJPEGReadSecondarySos:
 1270|    612|{
 1271|    612|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1272|    612|    uint8_t m;
 1273|    612|    assert(s > 0);
  ------------------
  |  Branch (1273:5): [True: 0, False: 612]
  |  Branch (1273:5): [True: 612, False: 0]
  ------------------
 1274|    612|    assert(s < 3);
  ------------------
  |  Branch (1274:5): [True: 0, False: 612]
  |  Branch (1274:5): [True: 612, False: 0]
  ------------------
 1275|    612|    assert(sp->sos_end[0].log != 0);
  ------------------
  |  Branch (1275:5): [True: 0, False: 612]
  |  Branch (1275:5): [True: 612, False: 0]
  ------------------
 1276|    612|    assert(sp->sos_end[s].log == 0);
  ------------------
  |  Branch (1276:5): [True: 0, False: 612]
  |  Branch (1276:5): [True: 612, False: 0]
  ------------------
 1277|    612|    sp->plane_sample_offset = (uint8_t)(s - 1);
 1278|    677|    while (sp->sos_end[sp->plane_sample_offset].log == 0)
  ------------------
  |  Branch (1278:12): [True: 65, False: 612]
  ------------------
 1279|     65|        sp->plane_sample_offset--;
 1280|    612|    sp->in_buffer_source =
 1281|    612|        sp->sos_end[sp->plane_sample_offset].in_buffer_source;
 1282|    612|    sp->in_buffer_next_strile =
 1283|    612|        sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile;
 1284|    612|    sp->in_buffer_file_pos =
 1285|    612|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos;
 1286|    612|    sp->in_buffer_file_pos_log = 0;
 1287|    612|    sp->in_buffer_file_togo =
 1288|    612|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo;
 1289|    612|    sp->in_buffer_togo = 0;
 1290|    612|    sp->in_buffer_cur = 0;
 1291|    694|    while (sp->plane_sample_offset < s)
  ------------------
  |  Branch (1291:12): [True: 612, False: 82]
  ------------------
 1292|    612|    {
 1293|    612|        do
 1294|  22.8M|        {
 1295|  22.8M|            if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1295:17): [True: 292, False: 22.8M]
  ------------------
 1296|    292|                return (0);
 1297|  22.8M|            if (m == 255)
  ------------------
  |  Branch (1297:17): [True: 180k, False: 22.6M]
  ------------------
 1298|   180k|            {
 1299|   180k|                do
 1300|  4.24M|                {
 1301|  4.24M|                    if (OJPEGReadByte(sp, &m) == 0)
  ------------------
  |  Branch (1301:25): [True: 0, False: 4.24M]
  ------------------
 1302|      0|                        return (0);
 1303|  4.24M|                    if (m != 255)
  ------------------
  |  Branch (1303:25): [True: 180k, False: 4.05M]
  ------------------
 1304|   180k|                        break;
 1305|  4.24M|                } while (1);
  ------------------
  |  Branch (1305:26): [True: 4.05M, Folded]
  ------------------
 1306|   180k|                if (m == JPEG_MARKER_SOS)
  ------------------
  |  |  165|   180k|#define JPEG_MARKER_SOS 0xDA
  ------------------
  |  Branch (1306:21): [True: 320, False: 180k]
  ------------------
 1307|    320|                    break;
 1308|   180k|            }
 1309|  22.8M|        } while (1);
  ------------------
  |  Branch (1309:18): [True: 22.8M, Folded]
  ------------------
 1310|    320|        sp->plane_sample_offset++;
 1311|    320|        if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
  ------------------
  |  Branch (1311:13): [True: 238, False: 82]
  ------------------
 1312|    238|            return (0);
 1313|     82|        sp->sos_end[sp->plane_sample_offset].log = 1;
 1314|     82|        sp->sos_end[sp->plane_sample_offset].in_buffer_source =
 1315|     82|            sp->in_buffer_source;
 1316|     82|        sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile =
 1317|     82|            sp->in_buffer_next_strile;
 1318|     82|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos =
 1319|     82|            sp->in_buffer_file_pos - sp->in_buffer_togo;
 1320|     82|        sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo =
 1321|     82|            sp->in_buffer_file_togo + sp->in_buffer_togo;
 1322|     82|    }
 1323|     82|    return (1);
 1324|    612|}
tif_ojpeg.c:OJPEGLibjpegSessionAbort:
 1527|    919|{
 1528|    919|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1529|    919|    assert(sp->libjpeg_session_active != 0);
  ------------------
  |  Branch (1529:5): [True: 0, False: 919]
  |  Branch (1529:5): [True: 919, False: 0]
  ------------------
 1530|    919|    jpeg_destroy(
 1531|    919|        (tiff_ojpeg_common_struct *)(&(sp->libjpeg_jpeg_decompress_struct)));
 1532|    919|    sp->libjpeg_session_active = 0;
 1533|    919|}
tif_ojpeg.c:OJPEGWriteHeaderInfo:
 1327|  1.23k|{
 1328|  1.23k|    static const char module[] = "OJPEGWriteHeaderInfo";
 1329|  1.23k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1330|  1.23k|    uint8_t **m;
 1331|  1.23k|    uint32_t n;
 1332|       |    /* if a previous attempt failed, don't try again */
 1333|  1.23k|    if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (1333:9): [True: 313, False: 919]
  ------------------
 1334|    313|        return 0;
 1335|    919|    sp->out_state = ososSoi;
 1336|    919|    sp->restart_index = 0;
 1337|    919|    jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
 1338|    919|    sp->libjpeg_jpeg_error_mgr.output_message =
 1339|    919|        OJPEGLibjpegJpegErrorMgrOutputMessage;
 1340|    919|    sp->libjpeg_jpeg_error_mgr.error_exit = OJPEGLibjpegJpegErrorMgrErrorExit;
 1341|    919|    sp->libjpeg_jpeg_decompress_struct.err = &(sp->libjpeg_jpeg_error_mgr);
 1342|    919|    sp->libjpeg_jpeg_decompress_struct.client_data = (void *)tif;
 1343|    919|    if (jpeg_create_decompress_encap(
  ------------------
  |  Branch (1343:9): [True: 0, False: 919]
  ------------------
 1344|    919|            sp, &(sp->libjpeg_jpeg_decompress_struct)) == 0)
 1345|      0|        return (0);
 1346|    919|    sp->libjpeg_session_active = 1;
 1347|    919|    sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = 0;
 1348|    919|    sp->libjpeg_jpeg_source_mgr.init_source =
 1349|    919|        OJPEGLibjpegJpegSourceMgrInitSource;
 1350|    919|    sp->libjpeg_jpeg_source_mgr.fill_input_buffer =
 1351|    919|        OJPEGLibjpegJpegSourceMgrFillInputBuffer;
 1352|    919|    sp->libjpeg_jpeg_source_mgr.skip_input_data =
 1353|    919|        OJPEGLibjpegJpegSourceMgrSkipInputData;
 1354|    919|    sp->libjpeg_jpeg_source_mgr.resync_to_restart =
 1355|    919|        OJPEGLibjpegJpegSourceMgrResyncToRestart;
 1356|    919|    sp->libjpeg_jpeg_source_mgr.term_source =
 1357|    919|        OJPEGLibjpegJpegSourceMgrTermSource;
 1358|    919|    sp->libjpeg_jpeg_decompress_struct.src = &(sp->libjpeg_jpeg_source_mgr);
 1359|    919|    if (jpeg_read_header_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), 1) ==
  ------------------
  |  Branch (1359:9): [True: 28, False: 891]
  ------------------
 1360|    919|        0)
 1361|     28|        return (0);
 1362|    891|    if ((sp->subsampling_force_desubsampling_inside_decompression == 0) &&
  ------------------
  |  Branch (1362:9): [True: 891, False: 0]
  ------------------
 1363|    891|        (sp->samples_per_pixel_per_plane > 1))
  ------------------
  |  Branch (1363:9): [True: 0, False: 891]
  ------------------
 1364|      0|    {
 1365|      0|        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|      0|        sp->libjpeg_jpeg_query_style = 0;
 1370|      0|        if (sp->subsampling_convert_log == 0)
  ------------------
  |  Branch (1370:13): [True: 0, False: 0]
  ------------------
 1371|      0|        {
 1372|      0|            assert(sp->subsampling_convert_ycbcrbuf == 0);
  ------------------
  |  Branch (1372:13): [True: 0, False: 0]
  |  Branch (1372:13): [True: 0, False: 0]
  ------------------
 1373|      0|            assert(sp->subsampling_convert_ycbcrimage == 0);
  ------------------
  |  Branch (1373:13): [True: 0, False: 0]
  |  Branch (1373:13): [True: 0, False: 0]
  ------------------
 1374|       |            /* Check for division by zero. */
 1375|      0|            if (sp->subsampling_hor == 0 || sp->subsampling_ver == 0)
  ------------------
  |  Branch (1375:17): [True: 0, False: 0]
  |  Branch (1375:45): [True: 0, False: 0]
  ------------------
 1376|      0|                return (0);
 1377|       |            /* Check for potential overflow in subsampling_convert_ylinelen
 1378|       |             * computation.
 1379|       |             */
 1380|      0|            if (sp->strile_width >
  ------------------
  |  Branch (1380:17): [True: 0, False: 0]
  ------------------
 1381|      0|                UINT32_MAX - ((uint32_t)sp->subsampling_hor * 8 - 1))
 1382|      0|                return (0);
 1383|      0|            sp->subsampling_convert_ylinelen =
 1384|      0|                ((sp->strile_width + (uint32_t)sp->subsampling_hor * 8 - 1) /
 1385|      0|                 ((uint32_t)sp->subsampling_hor * 8) *
 1386|      0|                 ((uint32_t)sp->subsampling_hor * 8));
 1387|      0|            sp->subsampling_convert_ylines = (uint32_t)sp->subsampling_ver * 8;
 1388|      0|            sp->subsampling_convert_clinelen =
 1389|      0|                sp->subsampling_convert_ylinelen / sp->subsampling_hor;
 1390|      0|            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|      0|            {
 1396|      0|                uint64_t ybuflen64 =
 1397|      0|                    (uint64_t)sp->subsampling_convert_ylinelen *
 1398|      0|                    sp->subsampling_convert_ylines;
 1399|      0|                uint64_t cbuflen64 =
 1400|      0|                    (uint64_t)sp->subsampling_convert_clinelen *
 1401|      0|                    sp->subsampling_convert_clines;
 1402|      0|                uint64_t ycbcrbuflen64 = ybuflen64 + 2 * cbuflen64;
 1403|      0|                if (ybuflen64 > UINT32_MAX || cbuflen64 > UINT32_MAX ||
  ------------------
  |  Branch (1403:21): [True: 0, False: 0]
  |  Branch (1403:47): [True: 0, False: 0]
  ------------------
 1404|      0|                    ycbcrbuflen64 > UINT32_MAX)
  ------------------
  |  Branch (1404:21): [True: 0, False: 0]
  ------------------
 1405|      0|                {
 1406|      0|                    TIFFErrorExtR(tif, module,
 1407|      0|                                  "Integer overflow in OJPEG buffer size");
 1408|      0|                    return (0);
 1409|      0|                }
 1410|      0|                sp->subsampling_convert_ybuflen = (uint32_t)ybuflen64;
 1411|      0|                sp->subsampling_convert_cbuflen = (uint32_t)cbuflen64;
 1412|      0|                sp->subsampling_convert_ycbcrbuflen = (uint32_t)ycbcrbuflen64;
 1413|      0|            }
 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|      0|                tif, 1, sp->subsampling_convert_ycbcrbuflen);
 1427|      0|            if (sp->subsampling_convert_ycbcrbuf == 0)
  ------------------
  |  Branch (1427:17): [True: 0, False: 0]
  ------------------
 1428|      0|            {
 1429|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1430|      0|                return (0);
 1431|      0|            }
 1432|      0|            sp->subsampling_convert_ybuf = sp->subsampling_convert_ycbcrbuf;
 1433|      0|            sp->subsampling_convert_cbbuf =
 1434|      0|                sp->subsampling_convert_ybuf + sp->subsampling_convert_ybuflen;
 1435|      0|            sp->subsampling_convert_crbuf =
 1436|      0|                sp->subsampling_convert_cbbuf + sp->subsampling_convert_cbuflen;
 1437|      0|            sp->subsampling_convert_ycbcrimagelen =
 1438|      0|                3 + sp->subsampling_convert_ylines +
 1439|      0|                2 * sp->subsampling_convert_clines;
 1440|      0|            sp->subsampling_convert_ycbcrimage = (uint8_t **)_TIFFmallocExt(
 1441|      0|                tif, (tmsize_t)((size_t)sp->subsampling_convert_ycbcrimagelen *
 1442|      0|                                sizeof(uint8_t *)));
 1443|      0|            if (sp->subsampling_convert_ycbcrimage == 0)
  ------------------
  |  Branch (1443:17): [True: 0, False: 0]
  ------------------
 1444|      0|            {
 1445|      0|                TIFFErrorExtR(tif, module, "Out of memory");
 1446|      0|                return (0);
 1447|      0|            }
 1448|      0|            m = sp->subsampling_convert_ycbcrimage;
 1449|      0|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3);
 1450|      0|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
 1451|      0|                               sp->subsampling_convert_ylines);
 1452|      0|            *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
 1453|      0|                               sp->subsampling_convert_ylines +
 1454|      0|                               sp->subsampling_convert_clines);
 1455|      0|            for (n = 0; n < sp->subsampling_convert_ylines; n++)
  ------------------
  |  Branch (1455:25): [True: 0, False: 0]
  ------------------
 1456|      0|                *m++ = sp->subsampling_convert_ybuf +
 1457|      0|                       n * sp->subsampling_convert_ylinelen;
 1458|      0|            for (n = 0; n < sp->subsampling_convert_clines; n++)
  ------------------
  |  Branch (1458:25): [True: 0, False: 0]
  ------------------
 1459|      0|                *m++ = sp->subsampling_convert_cbbuf +
 1460|      0|                       n * sp->subsampling_convert_clinelen;
 1461|      0|            for (n = 0; n < sp->subsampling_convert_clines; n++)
  ------------------
  |  Branch (1461:25): [True: 0, False: 0]
  ------------------
 1462|      0|                *m++ = sp->subsampling_convert_crbuf +
 1463|      0|                       n * sp->subsampling_convert_clinelen;
 1464|      0|            sp->subsampling_convert_clinelenout =
 1465|      0|                sp->strile_width / sp->subsampling_hor +
 1466|      0|                ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0);
  ------------------
  |  Branch (1466:18): [True: 0, False: 0]
  ------------------
 1467|      0|            sp->subsampling_convert_state = 0;
 1468|      0|            sp->error_in_raw_data_decoding = 0;
 1469|       |
 1470|      0|            const uint64_t bpl =
 1471|      0|                (uint64_t)sp->subsampling_convert_clinelenout *
 1472|      0|                ((uint64_t)sp->subsampling_ver * sp->subsampling_hor + 2);
 1473|      0|            if (bpl > UINT32_MAX)
  ------------------
  |  Branch (1473:17): [True: 0, False: 0]
  ------------------
 1474|      0|                return (0);
 1475|      0|            sp->bytes_per_line = (uint32_t)bpl;
 1476|       |
 1477|      0|            sp->lines_per_strile =
 1478|      0|                sp->strile_length / sp->subsampling_ver +
 1479|      0|                ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0);
  ------------------
  |  Branch (1479:18): [True: 0, False: 0]
  ------------------
 1480|      0|            sp->subsampling_convert_log = 1;
 1481|      0|        }
 1482|      0|    }
 1483|    891|    else
 1484|    891|    {
 1485|    891|        sp->libjpeg_jpeg_decompress_struct.jpeg_color_space = JCS_UNKNOWN;
 1486|    891|        sp->libjpeg_jpeg_decompress_struct.out_color_space = JCS_UNKNOWN;
 1487|    891|        sp->libjpeg_jpeg_query_style = 1;
 1488|    891|        sp->bytes_per_line =
 1489|    891|            _TIFFMultiply32(tif, sp->samples_per_pixel_per_plane,
 1490|    891|                            sp->strile_width, "OJPEGWriteHeaderInfo");
 1491|    891|        if (sp->bytes_per_line == 0)
  ------------------
  |  Branch (1491:13): [True: 0, False: 891]
  ------------------
 1492|      0|            return (0);
 1493|    891|        sp->lines_per_strile = sp->strile_length;
 1494|    891|    }
 1495|    891|    if (jpeg_start_decompress_encap(sp,
  ------------------
  |  Branch (1495:9): [True: 3, False: 888]
  ------------------
 1496|    891|                                    &(sp->libjpeg_jpeg_decompress_struct)) == 0)
 1497|      3|        return (0);
 1498|    888|    if (sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width)
  ------------------
  |  Branch (1498:9): [True: 0, False: 888]
  ------------------
 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|    888|    if (sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor !=
  ------------------
  |  Branch (1507:9): [True: 0, False: 888]
  ------------------
 1508|    888|            sp->subsampling_hor ||
 1509|    888|        sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor !=
  ------------------
  |  Branch (1509:9): [True: 0, False: 888]
  ------------------
 1510|    888|            sp->subsampling_ver)
 1511|      0|    {
 1512|      0|        TIFFErrorExtR(tif, module,
 1513|      0|                      "jpeg_start_decompress() returned max_h_samp_factor = %d "
 1514|      0|                      "and max_v_samp_factor = %d, expected %" PRIu8
 1515|      0|                      " and %" PRIu8,
 1516|      0|                      sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
 1517|      0|                      sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
 1518|      0|                      sp->subsampling_hor, sp->subsampling_ver);
 1519|      0|        return 0;
 1520|      0|    }
 1521|       |
 1522|    888|    sp->writeheader_done = 1;
 1523|    888|    return (1);
 1524|    888|}
tif_ojpeg.c:OJPEGLibjpegJpegErrorMgrOutputMessage:
 2803|    888|{
 2804|    888|    char buffer[JMSG_LENGTH_MAX];
 2805|    888|    (*cinfo->err->format_message)(cinfo, buffer);
 2806|    888|    TIFFWarningExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
 2807|    888|}
tif_ojpeg.c:OJPEGLibjpegJpegErrorMgrErrorExit:
 2810|     31|{
 2811|     31|    char buffer[JMSG_LENGTH_MAX];
 2812|     31|    (*cinfo->err->format_message)(cinfo, buffer);
 2813|     31|    TIFFErrorExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
 2814|     31|    jpeg_encap_unwind((TIFF *)(cinfo->client_data));
 2815|     31|}
tif_ojpeg.c:jpeg_encap_unwind:
 2795|    296|{
 2796|    296|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2797|    296|    LONGJMP(sp->exit_jmpbuf, 1);
  ------------------
  |  |  153|    296|#define LONGJMP(jbuf, code) longjmp(jbuf, code)
  ------------------
 2798|    296|}
tif_ojpeg.c:jpeg_create_decompress_encap:
 2723|    919|{
 2724|    919|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|    919|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2724:9): [True: 0, False: 919]
  ------------------
 2725|      0|        return 0;
 2726|    919|    else
 2727|    919|    {
 2728|       |        jpeg_create_decompress(cinfo);
 2729|    919|        return 1;
 2730|    919|    }
 2731|    919|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrInitSource:
 2819|    919|{
 2820|    919|    (void)cinfo;
 2821|    919|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrFillInputBuffer:
 2825|  12.0k|{
 2826|  12.0k|    TIFF *tif = (TIFF *)cinfo->client_data;
 2827|  12.0k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2828|  12.0k|    void *mem = 0;
 2829|  12.0k|    uint32_t len = 0U;
 2830|  12.0k|    if (OJPEGWriteStream(tif, &mem, &len) == 0)
  ------------------
  |  Branch (2830:9): [True: 0, False: 12.0k]
  ------------------
 2831|      0|    {
 2832|      0|        TIFFErrorExtR(tif, "LibJpeg", "Premature end of JPEG data");
 2833|      0|        jpeg_encap_unwind(tif);
 2834|      0|    }
 2835|  12.0k|    sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = len;
 2836|  12.0k|    sp->libjpeg_jpeg_source_mgr.next_input_byte = (const JOCTET *)mem;
 2837|  12.0k|    return (1);
 2838|  12.0k|}
tif_ojpeg.c:OJPEGWriteStream:
 2452|  12.0k|{
 2453|  12.0k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2454|  12.0k|    *len = 0;
 2455|  12.0k|    do
 2456|  22.9k|    {
 2457|  22.9k|        assert(sp->out_state <= ososEoi);
  ------------------
  |  Branch (2457:9): [True: 0, False: 22.9k]
  |  Branch (2457:9): [True: 22.9k, False: 0]
  ------------------
 2458|  22.9k|        switch (sp->out_state)
 2459|  22.9k|        {
 2460|    919|            case ososSoi:
  ------------------
  |  Branch (2460:13): [True: 919, False: 22.0k]
  ------------------
 2461|    919|                OJPEGWriteStreamSoi(tif, mem, len);
 2462|    919|                break;
 2463|    919|            case ososQTable0:
  ------------------
  |  Branch (2463:13): [True: 919, False: 22.0k]
  ------------------
 2464|    919|                OJPEGWriteStreamQTable(tif, 0, mem, len);
 2465|    919|                break;
 2466|    919|            case ososQTable1:
  ------------------
  |  Branch (2466:13): [True: 919, False: 22.0k]
  ------------------
 2467|    919|                OJPEGWriteStreamQTable(tif, 1, mem, len);
 2468|    919|                break;
 2469|    919|            case ososQTable2:
  ------------------
  |  Branch (2469:13): [True: 919, False: 22.0k]
  ------------------
 2470|    919|                OJPEGWriteStreamQTable(tif, 2, mem, len);
 2471|    919|                break;
 2472|    919|            case ososQTable3:
  ------------------
  |  Branch (2472:13): [True: 919, False: 22.0k]
  ------------------
 2473|    919|                OJPEGWriteStreamQTable(tif, 3, mem, len);
 2474|    919|                break;
 2475|    919|            case ososDcTable0:
  ------------------
  |  Branch (2475:13): [True: 919, False: 22.0k]
  ------------------
 2476|    919|                OJPEGWriteStreamDcTable(tif, 0, mem, len);
 2477|    919|                break;
 2478|    919|            case ososDcTable1:
  ------------------
  |  Branch (2478:13): [True: 919, False: 22.0k]
  ------------------
 2479|    919|                OJPEGWriteStreamDcTable(tif, 1, mem, len);
 2480|    919|                break;
 2481|    919|            case ososDcTable2:
  ------------------
  |  Branch (2481:13): [True: 919, False: 22.0k]
  ------------------
 2482|    919|                OJPEGWriteStreamDcTable(tif, 2, mem, len);
 2483|    919|                break;
 2484|    919|            case ososDcTable3:
  ------------------
  |  Branch (2484:13): [True: 919, False: 22.0k]
  ------------------
 2485|    919|                OJPEGWriteStreamDcTable(tif, 3, mem, len);
 2486|    919|                break;
 2487|    919|            case ososAcTable0:
  ------------------
  |  Branch (2487:13): [True: 919, False: 22.0k]
  ------------------
 2488|    919|                OJPEGWriteStreamAcTable(tif, 0, mem, len);
 2489|    919|                break;
 2490|    919|            case ososAcTable1:
  ------------------
  |  Branch (2490:13): [True: 919, False: 22.0k]
  ------------------
 2491|    919|                OJPEGWriteStreamAcTable(tif, 1, mem, len);
 2492|    919|                break;
 2493|    919|            case ososAcTable2:
  ------------------
  |  Branch (2493:13): [True: 919, False: 22.0k]
  ------------------
 2494|    919|                OJPEGWriteStreamAcTable(tif, 2, mem, len);
 2495|    919|                break;
 2496|    919|            case ososAcTable3:
  ------------------
  |  Branch (2496:13): [True: 919, False: 22.0k]
  ------------------
 2497|    919|                OJPEGWriteStreamAcTable(tif, 3, mem, len);
 2498|    919|                break;
 2499|    919|            case ososDri:
  ------------------
  |  Branch (2499:13): [True: 919, False: 22.0k]
  ------------------
 2500|    919|                OJPEGWriteStreamDri(tif, mem, len);
 2501|    919|                break;
 2502|    919|            case ososSof:
  ------------------
  |  Branch (2502:13): [True: 919, False: 22.0k]
  ------------------
 2503|    919|                OJPEGWriteStreamSof(tif, mem, len);
 2504|    919|                break;
 2505|    919|            case ososSos:
  ------------------
  |  Branch (2505:13): [True: 919, False: 22.0k]
  ------------------
 2506|    919|                OJPEGWriteStreamSos(tif, mem, len);
 2507|    919|                break;
 2508|  8.01k|            case ososCompressed:
  ------------------
  |  Branch (2508:13): [True: 8.01k, False: 14.9k]
  ------------------
 2509|  8.01k|                if (OJPEGWriteStreamCompressed(tif, mem, len) == 0)
  ------------------
  |  Branch (2509:21): [True: 0, False: 8.01k]
  ------------------
 2510|      0|                    return (0);
 2511|  8.01k|                break;
 2512|  8.01k|            case ososRst:
  ------------------
  |  Branch (2512:13): [True: 246, False: 22.7k]
  ------------------
 2513|    246|                OJPEGWriteStreamRst(tif, mem, len);
 2514|    246|                break;
 2515|     11|            case ososEoi:
  ------------------
  |  Branch (2515:13): [True: 11, False: 22.9k]
  ------------------
 2516|     11|                OJPEGWriteStreamEoi(tif, mem, len);
 2517|     11|                break;
 2518|      0|            default:
  ------------------
  |  Branch (2518:13): [True: 0, False: 22.9k]
  ------------------
 2519|      0|                break;
 2520|  22.9k|        }
 2521|  22.9k|    } while (*len == 0);
  ------------------
  |  Branch (2521:14): [True: 10.9k, False: 12.0k]
  ------------------
 2522|  12.0k|    return (1);
 2523|  12.0k|}
tif_ojpeg.c:OJPEGWriteStreamSoi:
 2526|    919|{
 2527|    919|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2528|    919|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2528:5): [True: 0, Folded]
  |  Branch (2528:5): [True: 919, Folded]
  ------------------
 2529|    919|    sp->out_buffer[0] = 255;
 2530|    919|    sp->out_buffer[1] = JPEG_MARKER_SOI;
  ------------------
  |  |  163|    919|#define JPEG_MARKER_SOI 0xD8
  ------------------
 2531|    919|    *len = 2;
 2532|    919|    *mem = (void *)sp->out_buffer;
 2533|    919|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2534|    919|}
tif_ojpeg.c:OJPEGWriteStreamQTable:
 2538|  3.67k|{
 2539|  3.67k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2540|  3.67k|    if (sp->qtable[table_index] != 0)
  ------------------
  |  Branch (2540:9): [True: 919, False: 2.75k]
  ------------------
 2541|    919|    {
 2542|    919|        *mem = (void *)(sp->qtable[table_index] + sizeof(uint32_t));
 2543|    919|        *len = (uint32_t)(*((uint32_t *)sp->qtable[table_index]) -
 2544|    919|                          sizeof(uint32_t));
 2545|    919|    }
 2546|  3.67k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2547|  3.67k|}
tif_ojpeg.c:OJPEGWriteStreamDcTable:
 2551|  3.67k|{
 2552|  3.67k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2553|  3.67k|    if (sp->dctable[table_index] != 0)
  ------------------
  |  Branch (2553:9): [True: 38, False: 3.63k]
  ------------------
 2554|     38|    {
 2555|     38|        *mem = (void *)(sp->dctable[table_index] + sizeof(uint32_t));
 2556|     38|        *len = (uint32_t)(*((uint32_t *)sp->dctable[table_index]) -
 2557|     38|                          sizeof(uint32_t));
 2558|     38|    }
 2559|  3.67k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2560|  3.67k|}
tif_ojpeg.c:OJPEGWriteStreamAcTable:
 2564|  3.67k|{
 2565|  3.67k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2566|  3.67k|    if (sp->actable[table_index] != 0)
  ------------------
  |  Branch (2566:9): [True: 38, False: 3.63k]
  ------------------
 2567|     38|    {
 2568|     38|        *mem = (void *)(sp->actable[table_index] + sizeof(uint32_t));
 2569|     38|        *len = (uint32_t)(*((uint32_t *)sp->actable[table_index]) -
 2570|     38|                          sizeof(uint32_t));
 2571|     38|    }
 2572|  3.67k|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2573|  3.67k|}
tif_ojpeg.c:OJPEGWriteStreamDri:
 2576|    919|{
 2577|    919|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2578|    919|    assert(OJPEG_BUFFER >= 6);
  ------------------
  |  Branch (2578:5): [True: 0, Folded]
  |  Branch (2578:5): [True: 919, Folded]
  ------------------
 2579|    919|    if (sp->restart_interval != 0)
  ------------------
  |  Branch (2579:9): [True: 22, False: 897]
  ------------------
 2580|     22|    {
 2581|     22|        sp->out_buffer[0] = 255;
 2582|     22|        sp->out_buffer[1] = JPEG_MARKER_DRI;
  ------------------
  |  |  167|     22|#define JPEG_MARKER_DRI 0xDD
  ------------------
 2583|     22|        sp->out_buffer[2] = 0;
 2584|     22|        sp->out_buffer[3] = 4;
 2585|     22|        sp->out_buffer[4] = (uint8_t)(sp->restart_interval >> 8);
 2586|     22|        sp->out_buffer[5] = (uint8_t)(sp->restart_interval & 255);
 2587|     22|        *len = 6;
 2588|     22|        *mem = (void *)sp->out_buffer;
 2589|     22|    }
 2590|    919|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2591|    919|}
tif_ojpeg.c:OJPEGWriteStreamSof:
 2594|    919|{
 2595|    919|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2596|    919|    uint8_t m;
 2597|    919|    assert(OJPEG_BUFFER >= 2 + 8 + sp->samples_per_pixel_per_plane * 3);
  ------------------
  |  Branch (2597:5): [True: 0, False: 919]
  |  Branch (2597:5): [True: 919, False: 0]
  ------------------
 2598|    919|    assert(255 >= 8 + sp->samples_per_pixel_per_plane * 3);
  ------------------
  |  Branch (2598:5): [True: 0, False: 919]
  |  Branch (2598:5): [True: 919, False: 0]
  ------------------
 2599|    919|    sp->out_buffer[0] = 255;
 2600|    919|    sp->out_buffer[1] = sp->sof_marker_id;
 2601|       |    /* Lf */
 2602|    919|    sp->out_buffer[2] = 0;
 2603|    919|    sp->out_buffer[3] = (uint8_t)(8 + sp->samples_per_pixel_per_plane * 3);
 2604|       |    /* P */
 2605|    919|    sp->out_buffer[4] = 8;
 2606|       |    /* Y */
 2607|    919|    sp->out_buffer[5] = (uint8_t)(sp->sof_y >> 8);
 2608|    919|    sp->out_buffer[6] = (uint8_t)(sp->sof_y & 255);
 2609|       |    /* X */
 2610|    919|    sp->out_buffer[7] = (uint8_t)(sp->sof_x >> 8);
 2611|    919|    sp->out_buffer[8] = (uint8_t)(sp->sof_x & 255);
 2612|       |    /* Nf */
 2613|    919|    sp->out_buffer[9] = sp->samples_per_pixel_per_plane;
 2614|  1.83k|    for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
  ------------------
  |  Branch (2614:17): [True: 919, False: 919]
  ------------------
 2615|    919|    {
 2616|       |        /* C */
 2617|    919|        sp->out_buffer[10 + m * 3] = sp->sof_c[sp->plane_sample_offset + m];
 2618|       |        /* H and V */
 2619|    919|        sp->out_buffer[10 + m * 3 + 1] =
 2620|    919|            sp->sof_hv[sp->plane_sample_offset + m];
 2621|       |        /* Tq */
 2622|    919|        sp->out_buffer[10 + m * 3 + 2] =
 2623|    919|            sp->sof_tq[sp->plane_sample_offset + m];
 2624|    919|    }
 2625|    919|    *len = 10 + (uint32_t)sp->samples_per_pixel_per_plane * 3;
 2626|    919|    *mem = (void *)sp->out_buffer;
 2627|    919|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2628|    919|}
tif_ojpeg.c:OJPEGWriteStreamSos:
 2631|    919|{
 2632|    919|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2633|    919|    uint8_t m;
 2634|    919|    assert(OJPEG_BUFFER >= 2 + 6 + sp->samples_per_pixel_per_plane * 2);
  ------------------
  |  Branch (2634:5): [True: 0, False: 919]
  |  Branch (2634:5): [True: 919, False: 0]
  ------------------
 2635|    919|    assert(255 >= 6 + sp->samples_per_pixel_per_plane * 2);
  ------------------
  |  Branch (2635:5): [True: 0, False: 919]
  |  Branch (2635:5): [True: 919, False: 0]
  ------------------
 2636|    919|    sp->out_buffer[0] = 255;
 2637|    919|    sp->out_buffer[1] = JPEG_MARKER_SOS;
  ------------------
  |  |  165|    919|#define JPEG_MARKER_SOS 0xDA
  ------------------
 2638|       |    /* Ls */
 2639|    919|    sp->out_buffer[2] = 0;
 2640|    919|    sp->out_buffer[3] = (uint8_t)(6 + sp->samples_per_pixel_per_plane * 2);
 2641|       |    /* Ns */
 2642|    919|    sp->out_buffer[4] = sp->samples_per_pixel_per_plane;
 2643|  1.83k|    for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
  ------------------
  |  Branch (2643:17): [True: 919, False: 919]
  ------------------
 2644|    919|    {
 2645|       |        /* Cs */
 2646|    919|        sp->out_buffer[5 + m * 2] = sp->sos_cs[sp->plane_sample_offset + m];
 2647|       |        /* Td and Ta */
 2648|    919|        sp->out_buffer[5 + m * 2 + 1] =
 2649|    919|            sp->sos_tda[sp->plane_sample_offset + m];
 2650|    919|    }
 2651|       |    /* Ss */
 2652|    919|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2] = 0;
 2653|       |    /* Se */
 2654|    919|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 1] = 63;
 2655|       |    /* Ah and Al */
 2656|    919|    sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 2] = 0;
 2657|    919|    *len = 8 + (uint32_t)sp->samples_per_pixel_per_plane * 2;
 2658|    919|    *mem = (void *)sp->out_buffer;
 2659|    919|    sp->out_state = (OJPEGStateOutState)(sp->out_state + 1);
 2660|    919|}
tif_ojpeg.c:OJPEGWriteStreamCompressed:
 2663|  8.01k|{
 2664|  8.01k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2665|  8.01k|    if (sp->in_buffer_togo == 0)
  ------------------
  |  Branch (2665:9): [True: 7.83k, False: 181]
  ------------------
 2666|  7.83k|    {
 2667|  7.83k|        if (OJPEGReadBufferFill(sp) == 0)
  ------------------
  |  Branch (2667:13): [True: 0, False: 7.83k]
  ------------------
 2668|      0|            return (0);
 2669|  7.83k|        assert(sp->in_buffer_togo > 0);
  ------------------
  |  Branch (2669:9): [True: 0, False: 7.83k]
  |  Branch (2669:9): [True: 7.83k, False: 0]
  ------------------
 2670|  7.83k|    }
 2671|  8.01k|    *len = sp->in_buffer_togo;
 2672|  8.01k|    *mem = (void *)sp->in_buffer_cur;
 2673|  8.01k|    sp->in_buffer_togo = 0;
 2674|  8.01k|    if (sp->in_buffer_file_togo == 0)
  ------------------
  |  Branch (2674:9): [True: 535, False: 7.48k]
  ------------------
 2675|    535|    {
 2676|    535|        switch (sp->in_buffer_source)
 2677|    535|        {
 2678|    535|            case osibsStrile:
  ------------------
  |  Branch (2678:13): [True: 535, False: 0]
  ------------------
 2679|    535|                if (sp->in_buffer_next_strile < sp->in_buffer_strile_count)
  ------------------
  |  Branch (2679:21): [True: 493, False: 42]
  ------------------
 2680|    493|                    sp->out_state = ososRst;
 2681|     42|                else
 2682|     42|                    sp->out_state = ososEoi;
 2683|    535|                break;
 2684|      0|            case osibsEof:
  ------------------
  |  Branch (2684:13): [True: 0, False: 535]
  ------------------
 2685|      0|                sp->out_state = ososEoi;
 2686|      0|                break;
 2687|      0|            case osibsNotSetYet:
  ------------------
  |  Branch (2687:13): [True: 0, False: 535]
  ------------------
 2688|      0|            case osibsJpegInterchangeFormat:
  ------------------
  |  Branch (2688:13): [True: 0, False: 535]
  ------------------
 2689|      0|            default:
  ------------------
  |  Branch (2689:13): [True: 0, False: 535]
  ------------------
 2690|      0|                break;
 2691|    535|        }
 2692|    535|    }
 2693|  8.01k|    return (1);
 2694|  8.01k|}
tif_ojpeg.c:OJPEGWriteStreamRst:
 2697|    246|{
 2698|    246|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2699|    246|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2699:5): [True: 0, Folded]
  |  Branch (2699:5): [True: 246, Folded]
  ------------------
 2700|    246|    sp->out_buffer[0] = 255;
 2701|    246|    sp->out_buffer[1] = (uint8_t)(JPEG_MARKER_RST0 + sp->restart_index);
  ------------------
  |  |  162|    246|#define JPEG_MARKER_RST0 0XD0
  ------------------
 2702|    246|    sp->restart_index++;
 2703|    246|    if (sp->restart_index == 8)
  ------------------
  |  Branch (2703:9): [True: 7, False: 239]
  ------------------
 2704|      7|        sp->restart_index = 0;
 2705|    246|    *len = 2;
 2706|    246|    *mem = (void *)sp->out_buffer;
 2707|    246|    sp->out_state = ososCompressed;
 2708|    246|}
tif_ojpeg.c:OJPEGWriteStreamEoi:
 2711|     11|{
 2712|     11|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 2713|     11|    assert(OJPEG_BUFFER >= 2);
  ------------------
  |  Branch (2713:5): [True: 0, Folded]
  |  Branch (2713:5): [True: 11, Folded]
  ------------------
 2714|     11|    sp->out_buffer[0] = 255;
 2715|     11|    sp->out_buffer[1] = JPEG_MARKER_EOI;
  ------------------
  |  |  164|     11|#define JPEG_MARKER_EOI 0xD9
  ------------------
 2716|     11|    *len = 2;
 2717|     11|    *mem = (void *)sp->out_buffer;
 2718|     11|}
tif_ojpeg.c:OJPEGLibjpegJpegSourceMgrResyncToRestart:
 2857|    265|{
 2858|    265|    TIFF *tif = (TIFF *)cinfo->client_data;
 2859|    265|    (void)desired;
 2860|    265|    TIFFErrorExtR(tif, "LibJpeg", "Unexpected error");
 2861|    265|    jpeg_encap_unwind(tif);
 2862|    265|    return (0);
 2863|    265|}
tif_ojpeg.c:jpeg_read_header_encap:
 2738|    919|{
 2739|    919|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|    919|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2739:9): [True: 28, False: 891]
  ------------------
 2740|     28|        return 0;
 2741|    891|    else
 2742|    891|    {
 2743|    891|        jpeg_read_header(cinfo, require_image);
 2744|    891|        return 1;
 2745|    891|    }
 2746|    919|}
tif_ojpeg.c:jpeg_start_decompress_encap:
 2752|    891|{
 2753|    891|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|    891|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2753:9): [True: 3, False: 888]
  ------------------
 2754|      3|        return 0;
 2755|    888|    else
 2756|    888|    {
 2757|    888|        jpeg_start_decompress(cinfo);
 2758|    888|        return 1;
 2759|    888|    }
 2760|    891|}
tif_ojpeg.c:OJPEGPreDecodeSkipScanlines:
  812|  25.1k|{
  813|  25.1k|    static const char module[] = "OJPEGPreDecodeSkipScanlines";
  814|  25.1k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  815|  25.1k|    uint32_t m;
  816|  25.1k|    if (sp->skip_buffer == NULL)
  ------------------
  |  Branch (816:9): [True: 60, False: 25.0k]
  ------------------
  817|     60|    {
  818|     60|        sp->skip_buffer = (uint8_t *)_TIFFmallocExt(tif, sp->bytes_per_line);
  819|     60|        if (sp->skip_buffer == NULL)
  ------------------
  |  Branch (819:13): [True: 0, False: 60]
  ------------------
  820|      0|        {
  821|      0|            TIFFErrorExtR(tif, module, "Out of memory");
  822|      0|            return (0);
  823|      0|        }
  824|     60|    }
  825|  7.69M|    for (m = 0; m < sp->lines_per_strile; m++)
  ------------------
  |  Branch (825:17): [True: 7.66M, False: 24.8k]
  ------------------
  826|  7.66M|    {
  827|  7.66M|        if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
  ------------------
  |  Branch (827:13): [True: 249, False: 7.66M]
  ------------------
  828|  7.66M|                                      &sp->skip_buffer, 1) == 0)
  829|    249|            return (0);
  830|  7.66M|    }
  831|  24.8k|    return (1);
  832|  25.1k|}
tif_ojpeg.c:jpeg_read_scanlines_encap:
 2767|  9.09M|{
 2768|  9.09M|    if (SETJMP(sp->exit_jmpbuf))
  ------------------
  |  |  152|  9.09M|#define SETJMP(jbuf) setjmp(jbuf)
  ------------------
  |  Branch (2768:9): [True: 265, False: 9.09M]
  ------------------
 2769|    265|        return 0;
 2770|  9.09M|    else
 2771|  9.09M|    {
 2772|  9.09M|        jpeg_read_scanlines(cinfo, (JSAMPARRAY)scanlines, max_lines);
 2773|  9.09M|        return 1;
 2774|  9.09M|    }
 2775|  9.09M|}
tif_ojpeg.c:OJPEGDecode:
  835|  1.77k|{
  836|  1.77k|    static const char module[] = "OJPEGDecode";
  837|  1.77k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  838|  1.77k|    (void)s;
  839|  1.77k|    if (!sp->decoder_ok)
  ------------------
  |  Branch (839:9): [True: 0, False: 1.77k]
  ------------------
  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|  1.77k|    if (sp->libjpeg_session_active == 0)
  ------------------
  |  Branch (846:9): [True: 0, False: 1.77k]
  ------------------
  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|  1.77k|    if (sp->error_in_raw_data_decoding)
  ------------------
  |  Branch (860:9): [True: 0, False: 1.77k]
  ------------------
  861|      0|    {
  862|      0|        memset(buf, 0, (size_t)cc);
  863|      0|        return 0;
  864|      0|    }
  865|  1.77k|    if (sp->libjpeg_jpeg_query_style == 0)
  ------------------
  |  Branch (865:9): [True: 0, False: 1.77k]
  ------------------
  866|      0|    {
  867|      0|        if (OJPEGDecodeRaw(tif, buf, cc) == 0)
  ------------------
  |  Branch (867:13): [True: 0, False: 0]
  ------------------
  868|      0|        {
  869|      0|            memset(buf, 0, (size_t)cc);
  870|      0|            return (0);
  871|      0|        }
  872|      0|    }
  873|  1.77k|    else
  874|  1.77k|    {
  875|  1.77k|        if (OJPEGDecodeScanlines(tif, buf, cc) == 0)
  ------------------
  |  Branch (875:13): [True: 58, False: 1.72k]
  ------------------
  876|     58|        {
  877|     58|            memset(buf, 0, (size_t)cc);
  878|     58|            return (0);
  879|     58|        }
  880|  1.77k|    }
  881|  1.72k|    return (1);
  882|  1.77k|}
tif_ojpeg.c:OJPEGDecodeScanlines:
  949|  1.77k|{
  950|  1.77k|    static const char module[] = "OJPEGDecodeScanlines";
  951|  1.77k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  952|  1.77k|    uint8_t *m;
  953|  1.77k|    tmsize_t n;
  954|  1.77k|    if (cc % sp->bytes_per_line != 0)
  ------------------
  |  Branch (954:9): [True: 42, False: 1.73k]
  ------------------
  955|     42|    {
  956|     42|        TIFFErrorExtR(tif, module, "Fractional scanline not read");
  957|     42|        return (0);
  958|     42|    }
  959|  1.77k|    assert(cc > 0);
  ------------------
  |  Branch (959:5): [True: 0, False: 1.73k]
  |  Branch (959:5): [True: 1.73k, False: 0]
  ------------------
  960|  1.73k|    m = buf;
  961|  1.73k|    n = cc;
  962|  1.73k|    do
  963|  1.42M|    {
  964|  1.42M|        if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
  ------------------
  |  Branch (964:13): [True: 16, False: 1.42M]
  ------------------
  965|  1.42M|                                      &m, 1) == 0)
  966|     16|            return (0);
  967|  1.42M|        m += sp->bytes_per_line;
  968|  1.42M|        n -= sp->bytes_per_line;
  969|  1.42M|    } while (n > 0);
  ------------------
  |  Branch (969:14): [True: 1.42M, False: 1.72k]
  ------------------
  970|  1.72k|    return (1);
  971|  1.73k|}
tif_ojpeg.c:OJPEGPostDecode:
  974|  1.72k|{
  975|  1.72k|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
  976|  1.72k|    (void)buf;
  977|  1.72k|    (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|  1.72k|    sp->write_curstrile++;
  987|  1.72k|    if (sp->write_curstrile % tif->tif_dir.td_stripsperimage == 0)
  ------------------
  |  Branch (987:9): [True: 149, False: 1.57k]
  ------------------
  988|    149|    {
  989|    149|        assert(sp->libjpeg_session_active != 0);
  ------------------
  |  Branch (989:9): [True: 0, False: 149]
  |  Branch (989:9): [True: 149, False: 0]
  ------------------
  990|    149|        OJPEGLibjpegSessionAbort(tif);
  991|    149|        sp->writeheader_done = 0;
  992|    149|    }
  993|  1.72k|}
tif_ojpeg.c:OJPEGCleanup:
 1036|    138|{
 1037|    138|    OJPEGState *sp = (OJPEGState *)tif->tif_data;
 1038|    138|    if (sp != 0)
  ------------------
  |  Branch (1038:9): [True: 138, False: 0]
  ------------------
 1039|    138|    {
 1040|    138|        tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1041|    138|        tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1042|    138|        tif->tif_tagmethods.printdir = sp->printdir;
 1043|    138|        if (sp->qtable[0] != 0)
  ------------------
  |  Branch (1043:13): [True: 90, False: 48]
  ------------------
 1044|     90|            _TIFFfreeExt(tif, sp->qtable[0]);
 1045|    138|        if (sp->qtable[1] != 0)
  ------------------
  |  Branch (1045:13): [True: 7, False: 131]
  ------------------
 1046|      7|            _TIFFfreeExt(tif, sp->qtable[1]);
 1047|    138|        if (sp->qtable[2] != 0)
  ------------------
  |  Branch (1047:13): [True: 0, False: 138]
  ------------------
 1048|      0|            _TIFFfreeExt(tif, sp->qtable[2]);
 1049|    138|        if (sp->qtable[3] != 0)
  ------------------
  |  Branch (1049:13): [True: 7, False: 131]
  ------------------
 1050|      7|            _TIFFfreeExt(tif, sp->qtable[3]);
 1051|    138|        if (sp->dctable[0] != 0)
  ------------------
  |  Branch (1051:13): [True: 21, False: 117]
  ------------------
 1052|     21|            _TIFFfreeExt(tif, sp->dctable[0]);
 1053|    138|        if (sp->dctable[1] != 0)
  ------------------
  |  Branch (1053:13): [True: 0, False: 138]
  ------------------
 1054|      0|            _TIFFfreeExt(tif, sp->dctable[1]);
 1055|    138|        if (sp->dctable[2] != 0)
  ------------------
  |  Branch (1055:13): [True: 2, False: 136]
  ------------------
 1056|      2|            _TIFFfreeExt(tif, sp->dctable[2]);
 1057|    138|        if (sp->dctable[3] != 0)
  ------------------
  |  Branch (1057:13): [True: 0, False: 138]
  ------------------
 1058|      0|            _TIFFfreeExt(tif, sp->dctable[3]);
 1059|    138|        if (sp->actable[0] != 0)
  ------------------
  |  Branch (1059:13): [True: 19, False: 119]
  ------------------
 1060|     19|            _TIFFfreeExt(tif, sp->actable[0]);
 1061|    138|        if (sp->actable[1] != 0)
  ------------------
  |  Branch (1061:13): [True: 0, False: 138]
  ------------------
 1062|      0|            _TIFFfreeExt(tif, sp->actable[1]);
 1063|    138|        if (sp->actable[2] != 0)
  ------------------
  |  Branch (1063:13): [True: 0, False: 138]
  ------------------
 1064|      0|            _TIFFfreeExt(tif, sp->actable[2]);
 1065|    138|        if (sp->actable[3] != 0)
  ------------------
  |  Branch (1065:13): [True: 0, False: 138]
  ------------------
 1066|      0|            _TIFFfreeExt(tif, sp->actable[3]);
 1067|    138|        if (sp->libjpeg_session_active != 0)
  ------------------
  |  Branch (1067:13): [True: 40, False: 98]
  ------------------
 1068|     40|            OJPEGLibjpegSessionAbort(tif);
 1069|    138|        if (sp->subsampling_convert_ycbcrbuf != 0)
  ------------------
  |  Branch (1069:13): [True: 0, False: 138]
  ------------------
 1070|      0|            _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrbuf);
 1071|    138|        if (sp->subsampling_convert_ycbcrimage != 0)
  ------------------
  |  Branch (1071:13): [True: 0, False: 138]
  ------------------
 1072|      0|            _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrimage);
 1073|    138|        if (sp->skip_buffer != 0)
  ------------------
  |  Branch (1073:13): [True: 60, False: 78]
  ------------------
 1074|     60|            _TIFFfreeExt(tif, sp->skip_buffer);
 1075|    138|        _TIFFfreeExt(tif, sp);
 1076|       |        tif->tif_data = NULL;
 1077|    138|        _TIFFSetDefaultCompressionState(tif);
 1078|    138|    }
 1079|    138|}

_TIFFgetMode:
   57|    402|{
   58|    402|    int m = -1;
   59|       |
   60|    402|    switch (mode[0])
   61|    402|    {
   62|    402|        case 'r':
  ------------------
  |  Branch (62:9): [True: 402, False: 0]
  ------------------
   63|    402|            m = O_RDONLY;
   64|    402|            if (mode[1] == '+')
  ------------------
  |  Branch (64:17): [True: 0, False: 402]
  ------------------
   65|      0|                m = O_RDWR;
   66|    402|            break;
   67|      0|        case 'w':
  ------------------
  |  Branch (67:9): [True: 0, False: 402]
  ------------------
   68|      0|        case 'a':
  ------------------
  |  Branch (68:9): [True: 0, False: 402]
  ------------------
   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: 402]
  ------------------
   74|      0|            _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode);
   75|      0|            break;
   76|    402|    }
   77|    402|    return (m);
   78|    402|}
_TIFFmallocExt:
  174|  66.1k|{
  175|  66.1k|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (175:9): [True: 65.7k, False: 402]
  |  Branch (175:24): [True: 0, False: 65.7k]
  ------------------
  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|  66.1k|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (181:9): [True: 65.7k, False: 402]
  |  Branch (181:24): [True: 0, False: 65.7k]
  ------------------
  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|  66.1k|    return _TIFFmalloc(s);
  198|  66.1k|}
_TIFFcallocExt:
  202|    261|{
  203|    261|    if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz)
  ------------------
  |  |   68|    261|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (203:9): [True: 0, False: 261]
  |  Branch (203:23): [True: 0, False: 261]
  |  Branch (203:35): [True: 0, False: 261]
  ------------------
  204|      0|        return NULL;
  205|    261|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0)
  ------------------
  |  Branch (205:9): [True: 261, False: 0]
  |  Branch (205:24): [True: 0, False: 261]
  ------------------
  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|    261|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (214:9): [True: 261, False: 0]
  |  Branch (214:24): [True: 0, False: 261]
  ------------------
  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|    261|    return _TIFFcalloc(nmemb, siz);
  232|    261|}
_TIFFreallocExt:
  236|  40.8k|{
  237|  40.8k|    if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (237:9): [True: 40.8k, False: 0]
  |  Branch (237:24): [True: 0, False: 40.8k]
  ------------------
  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|  40.8k|    if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (243:9): [True: 40.8k, False: 0]
  |  Branch (243:24): [True: 0, False: 40.8k]
  ------------------
  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|  40.8k|    return _TIFFrealloc(p, s);
  272|  40.8k|}
_TIFFfreeExt:
  276|  75.4k|{
  277|  75.4k|    if (p != NULL && tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
  ------------------
  |  Branch (277:9): [True: 74.8k, False: 567]
  |  Branch (277:22): [True: 74.4k, False: 402]
  |  Branch (277:37): [True: 0, False: 74.4k]
  ------------------
  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|  75.4k|    _TIFFfree(p);
  287|  75.4k|}
TIFFClientOpen:
  294|    402|{
  295|    402|    return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc,
  296|    402|                             seekproc, closeproc, sizeproc, mapproc, unmapproc,
  297|       |                             NULL);
  298|    402|}
TIFFClientOpenExt:
  306|    402|{
  307|    402|    static const char module[] = "TIFFClientOpenExt";
  308|    402|    TIFF *tif;
  309|    402|    int m;
  310|    402|    const char *cp;
  311|    402|    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|    402|    assert(sizeof(uint8_t) == 1);
  ------------------
  |  Branch (317:5): [True: 0, Folded]
  |  Branch (317:5): [True: 402, Folded]
  ------------------
  318|    402|    assert(sizeof(int8_t) == 1);
  ------------------
  |  Branch (318:5): [True: 0, Folded]
  |  Branch (318:5): [True: 402, Folded]
  ------------------
  319|    402|    assert(sizeof(uint16_t) == 2);
  ------------------
  |  Branch (319:5): [True: 0, Folded]
  |  Branch (319:5): [True: 402, Folded]
  ------------------
  320|    402|    assert(sizeof(int16_t) == 2);
  ------------------
  |  Branch (320:5): [True: 0, Folded]
  |  Branch (320:5): [True: 402, Folded]
  ------------------
  321|    402|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (321:5): [True: 0, Folded]
  |  Branch (321:5): [True: 402, Folded]
  ------------------
  322|    402|    assert(sizeof(int32_t) == 4);
  ------------------
  |  Branch (322:5): [True: 0, Folded]
  |  Branch (322:5): [True: 402, Folded]
  ------------------
  323|    402|    assert(sizeof(uint64_t) == 8);
  ------------------
  |  Branch (323:5): [True: 0, Folded]
  |  Branch (323:5): [True: 402, Folded]
  ------------------
  324|    402|    assert(sizeof(int64_t) == 8);
  ------------------
  |  Branch (324:5): [True: 0, Folded]
  |  Branch (324:5): [True: 402, Folded]
  ------------------
  325|    402|    {
  326|    402|        union
  327|    402|        {
  328|    402|            uint8_t a8[2];
  329|    402|            uint16_t a16;
  330|    402|        } n;
  331|    402|        n.a8[0] = 1;
  332|    402|        n.a8[1] = 0;
  333|    402|        (void)n;
  334|       |#if WORDS_BIGENDIAN
  335|       |        assert(n.a16 == 256);
  336|       |#else
  337|    402|        assert(n.a16 == 1);
  ------------------
  |  Branch (337:9): [True: 0, False: 402]
  |  Branch (337:9): [True: 402, False: 0]
  ------------------
  338|    402|#endif
  339|    402|    }
  340|       |
  341|    402|    m = _TIFFgetMode(opts, clientdata, mode, module);
  342|    402|    if (m == -1)
  ------------------
  |  Branch (342:9): [True: 0, False: 402]
  ------------------
  343|      0|        goto bad2;
  344|    402|    size_to_alloc = (tmsize_t)(sizeof(TIFF) + strlen(name) + 1);
  345|    402|    if (opts && opts->max_single_mem_alloc > 0 &&
  ------------------
  |  Branch (345:9): [True: 0, False: 402]
  |  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|    402|    if (opts && opts->max_cumulated_mem_alloc > 0 &&
  ------------------
  |  Branch (356:9): [True: 0, False: 402]
  |  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|    402|    tif = (TIFF *)_TIFFmallocExt(NULL, size_to_alloc);
  368|    402|    if (tif == NULL)
  ------------------
  |  Branch (368:9): [True: 0, False: 402]
  ------------------
  369|      0|    {
  370|      0|        _TIFFErrorEarly(opts, clientdata, module,
  371|      0|                        "%s: Out of memory (TIFF structure)", name);
  372|      0|        goto bad2;
  373|      0|    }
  374|    402|    _TIFFmemset(tif, 0, sizeof(*tif));
  375|    402|    tif->tif_name = (char *)tif + sizeof(TIFF);
  376|    402|    strcpy(tif->tif_name, name);
  377|    402|    tif->tif_mode = m & ~(O_CREAT | O_TRUNC);
  378|    402|    tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; /* non-existent directory */
  ------------------
  |  |   65|    402|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  379|    402|    tif->tif_curdircount = TIFF_NON_EXISTENT_DIR_NUMBER;
  ------------------
  |  |   65|    402|#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
  ------------------
  380|    402|    tif->tif_curoff = 0;
  381|    402|    tif->tif_clientdata = clientdata;
  382|    402|    tif->tif_readproc = readproc;
  383|    402|    tif->tif_writeproc = writeproc;
  384|    402|    tif->tif_seekproc = seekproc;
  385|    402|    tif->tif_closeproc = closeproc;
  386|    402|    tif->tif_sizeproc = sizeproc;
  387|    402|    tif->tif_mapproc = mapproc ? mapproc : _tiffDummyMapProc;
  ------------------
  |  Branch (387:24): [True: 402, False: 0]
  ------------------
  388|    402|    tif->tif_unmapproc = unmapproc ? unmapproc : _tiffDummyUnmapProc;
  ------------------
  |  Branch (388:26): [True: 402, False: 0]
  ------------------
  389|    402|    if (opts)
  ------------------
  |  Branch (389:9): [True: 0, False: 402]
  ------------------
  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|    402|    _TIFFResetTifDirAndInitStrileCounters(&tif->tif_dir);
  403|       |
  404|    402|    if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc)
  ------------------
  |  Branch (404:9): [True: 0, False: 402]
  |  Branch (404:22): [True: 0, False: 402]
  |  Branch (404:36): [True: 0, False: 402]
  |  Branch (404:49): [True: 0, False: 402]
  |  Branch (404:63): [True: 0, False: 402]
  ------------------
  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|    402|    _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|    402|    tif->tif_flags = FILLORDER_MSB2LSB;
  ------------------
  |  |  241|    402|#define FILLORDER_MSB2LSB 1                /* most significant -> least */
  ------------------
  419|    402|    if (m == O_RDONLY)
  ------------------
  |  Branch (419:9): [True: 402, False: 0]
  ------------------
  420|    402|        tif->tif_flags |= TIFF_MAPPED;
  ------------------
  |  |  130|    402|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  421|       |
  422|    402|#ifdef STRIPCHOP_DEFAULT
  423|    402|    if (m == O_RDONLY || m == O_RDWR)
  ------------------
  |  Branch (423:9): [True: 402, False: 0]
  |  Branch (423:26): [True: 0, False: 0]
  ------------------
  424|    402|        tif->tif_flags |= STRIPCHOP_DEFAULT;
  ------------------
  |  |  113|    402|#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
  |  |  ------------------
  |  |  |  |  134|    402|#define TIFF_STRIPCHOP 0x08000U   /* enable strip chopping support */
  |  |  ------------------
  ------------------
  425|    402|#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|  1.20k|    for (cp = mode; *cp; cp++)
  ------------------
  |  Branch (482:21): [True: 804, False: 402]
  ------------------
  483|    804|        switch (*cp)
  484|    804|        {
  485|      0|            case 'b':
  ------------------
  |  Branch (485:13): [True: 0, False: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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|    402|            case 'm':
  ------------------
  |  Branch (517:13): [True: 402, False: 402]
  ------------------
  518|    402|                if (m == O_RDONLY)
  ------------------
  |  Branch (518:21): [True: 402, False: 0]
  ------------------
  519|    402|                    tif->tif_flags &= ~TIFF_MAPPED;
  ------------------
  |  |  130|    402|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  520|    402|                break;
  521|      0|            case 'C':
  ------------------
  |  Branch (521:13): [True: 0, False: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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: 804]
  ------------------
  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|    402|            default:
  ------------------
  |  Branch (544:13): [True: 402, False: 402]
  ------------------
  545|    402|                break;
  546|    804|        }
  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|    402|    if ((m & O_TRUNC) ||
  ------------------
  |  Branch (558:9): [True: 0, False: 402]
  ------------------
  559|    402|        !ReadOK(tif, &tif->tif_header, sizeof(TIFFHeaderClassic)))
  ------------------
  |  |  300|    402|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|    402|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (559:9): [True: 0, False: 402]
  ------------------
  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|    402|    if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN &&
  ------------------
  |  |   51|    804|#define TIFF_BIGENDIAN 0x4d4d
  ------------------
  |  Branch (635:9): [True: 401, False: 1]
  ------------------
  636|    401|        tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN
  ------------------
  |  |   52|    803|#define TIFF_LITTLEENDIAN 0x4949
  ------------------
  |  Branch (636:9): [True: 3, False: 398]
  ------------------
  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|    402|#endif
  644|    402|    )
  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|    399|    if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN)
  ------------------
  |  |   51|    399|#define TIFF_BIGENDIAN 0x4d4d
  ------------------
  |  Branch (660:9): [True: 1, False: 398]
  ------------------
  661|      1|    {
  662|      1|#if !WORDS_BIGENDIAN
  663|      1|        tif->tif_flags |= TIFF_SWAB;
  ------------------
  |  |  126|      1|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  664|      1|#endif
  665|      1|    }
  666|    398|    else
  667|    398|    {
  668|       |#if WORDS_BIGENDIAN
  669|       |        tif->tif_flags |= TIFF_SWAB;
  670|       |#endif
  671|    398|    }
  672|    399|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    399|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (672:9): [True: 1, False: 398]
  ------------------
  673|      1|        TIFFSwabShort(&tif->tif_header.common.tiff_version);
  674|    399|    if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC) &&
  ------------------
  |  |   48|    399|#define TIFF_VERSION_CLASSIC 42
  ------------------
  |  Branch (674:9): [True: 12, False: 387]
  ------------------
  675|     12|        (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG))
  ------------------
  |  |   49|     12|#define TIFF_VERSION_BIG 43
  ------------------
  |  Branch (675:9): [True: 1, False: 11]
  ------------------
  676|      1|    {
  677|      1|        TIFFErrorExtR(tif, name,
  678|      1|                      "Not a TIFF file, bad version number %" PRIu16
  679|      1|                      " (0x%" PRIx16 ")",
  680|      1|                      tif->tif_header.common.tiff_version,
  681|      1|                      tif->tif_header.common.tiff_version);
  682|      1|        goto bad;
  683|      1|    }
  684|    398|    if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC)
  ------------------
  |  |   48|    398|#define TIFF_VERSION_CLASSIC 42
  ------------------
  |  Branch (684:9): [True: 387, False: 11]
  ------------------
  685|    387|    {
  686|    387|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    387|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (686:13): [True: 1, False: 386]
  ------------------
  687|      1|            TIFFSwabLong(&tif->tif_header.classic.tiff_diroff);
  688|    387|        tif->tif_header_size = sizeof(TIFFHeaderClassic);
  689|    387|    }
  690|     11|    else
  691|     11|    {
  692|     11|        if (!ReadOK(tif,
  ------------------
  |  |  300|     11|    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
  |  |  ------------------
  |  |  |  |  283|     11|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  |  |  ------------------
  ------------------
  |  Branch (692:13): [True: 0, False: 11]
  ------------------
  693|     11|                    ((uint8_t *)(&tif->tif_header) + sizeof(TIFFHeaderClassic)),
  694|     11|                    (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic))))
  695|      0|        {
  696|      0|            TIFFErrorExtR(tif, name, "Cannot read TIFF header");
  697|      0|            goto bad;
  698|      0|        }
  699|     11|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|     11|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (699:13): [True: 0, False: 11]
  ------------------
  700|      0|        {
  701|      0|            TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
  702|      0|            TIFFSwabLong8(&tif->tif_header.big.tiff_diroff);
  703|      0|        }
  704|     11|        if (tif->tif_header.big.tiff_offsetsize != 8)
  ------------------
  |  Branch (704:13): [True: 0, False: 11]
  ------------------
  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|     11|        if (tif->tif_header.big.tiff_unused != 0)
  ------------------
  |  Branch (713:13): [True: 0, False: 11]
  ------------------
  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|     11|        tif->tif_header_size = sizeof(TIFFHeaderBig);
  723|     11|        tif->tif_flags |= TIFF_BIGTIFF;
  ------------------
  |  |  140|     11|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  724|     11|    }
  725|    398|    tif->tif_flags |= TIFF_MYBUFFER;
  ------------------
  |  |  128|    398|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  726|    398|    tif->tif_rawcp = tif->tif_rawdata = 0;
  727|    398|    tif->tif_rawdatasize = 0;
  728|    398|    tif->tif_rawdataoff = 0;
  729|    398|    tif->tif_rawdataloaded = 0;
  730|       |
  731|    398|    switch (mode[0])
  732|    398|    {
  733|    398|        case 'r':
  ------------------
  |  Branch (733:9): [True: 398, False: 0]
  ------------------
  734|    398|            if (!(tif->tif_flags & TIFF_BIGTIFF))
  ------------------
  |  |  140|    398|#define TIFF_BIGTIFF 0x80000U     /* read/write bigtiff */
  ------------------
  |  Branch (734:17): [True: 387, False: 11]
  ------------------
  735|    387|                tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff;
  736|     11|            else
  737|     11|                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|    398|            if (tif->tif_flags & TIFF_MAPPED)
  ------------------
  |  |  130|    398|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  ------------------
  |  Branch (743:17): [True: 0, False: 398]
  ------------------
  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|    398|            if (tif->tif_flags & TIFF_HEADERONLY)
  ------------------
  |  |  136|    398|    0x10000U /* read header only, do not process the first directory */
  ------------------
  |  Branch (764:17): [True: 0, False: 398]
  ------------------
  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|    398|            if (TIFFReadDirectory(tif))
  ------------------
  |  Branch (774:17): [True: 367, False: 31]
  ------------------
  775|    367|            {
  776|    367|                return (tif);
  777|    367|            }
  778|     31|            break;
  779|     31|        case 'a':
  ------------------
  |  Branch (779:9): [True: 0, False: 398]
  ------------------
  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: 398]
  ------------------
  789|      0|            break;
  790|    398|    }
  791|     35|bad:
  792|     35|    tif->tif_mode = O_RDONLY; /* XXX avoid flush */
  793|     35|    TIFFCleanup(tif);
  794|     35|bad2:
  795|     35|    return ((TIFF *)0);
  796|     35|}
TIFFFileName:
  805|    110|const char *TIFFFileName(TIFF *tif) { return (tif->tif_name); }
TIFFIsTiled:
  866|  1.15k|int TIFFIsTiled(TIFF *tif) { return (isTiled(tif)); }
  ------------------
  |  |  278|  1.15k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  1.15k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------

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

TIFFInitPixarLog:
 1804|      1|{
 1805|      1|    static const char module[] = "TIFFInitPixarLog";
 1806|       |
 1807|      1|    PixarLogState *sp;
 1808|       |
 1809|      1|    (void)scheme;
 1810|      1|    assert(scheme == COMPRESSION_PIXARLOG);
  ------------------
  |  Branch (1810:5): [True: 0, False: 1]
  |  Branch (1810:5): [True: 1, False: 0]
  ------------------
 1811|       |
 1812|       |    /*
 1813|       |     * Merge codec-specific tag information.
 1814|       |     */
 1815|      1|    if (!_TIFFMergeFields(tif, pixarlogFields, TIFFArrayCount(pixarlogFields)))
  ------------------
  |  |  339|      1|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1815:9): [True: 0, False: 1]
  ------------------
 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|      1|    tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(PixarLogState));
 1826|      1|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (1826:9): [True: 0, False: 1]
  ------------------
 1827|      0|        goto bad;
 1828|      1|    sp = (PixarLogState *)tif->tif_data;
 1829|      1|    _TIFFmemset(sp, 0, sizeof(*sp));
 1830|      1|    sp->stream.data_type = Z_BINARY;
 1831|      1|    sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN;
  ------------------
  |  |  765|      1|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
 1832|       |
 1833|       |    /*
 1834|       |     * Install codec methods.
 1835|       |     */
 1836|      1|    tif->tif_fixuptags = PixarLogFixupTags;
 1837|      1|    tif->tif_setupdecode = PixarLogSetupDecode;
 1838|      1|    tif->tif_predecode = PixarLogPreDecode;
 1839|      1|    tif->tif_decoderow = PixarLogDecode;
 1840|      1|    tif->tif_decodestrip = PixarLogDecode;
 1841|      1|    tif->tif_decodetile = PixarLogDecode;
 1842|      1|    tif->tif_setupencode = PixarLogSetupEncode;
 1843|      1|    tif->tif_preencode = PixarLogPreEncode;
 1844|      1|    tif->tif_postencode = PixarLogPostEncode;
 1845|      1|    tif->tif_encoderow = PixarLogEncode;
 1846|      1|    tif->tif_encodestrip = PixarLogEncode;
 1847|      1|    tif->tif_encodetile = PixarLogEncode;
 1848|      1|    tif->tif_close = PixarLogClose;
 1849|      1|    tif->tif_cleanup = PixarLogCleanup;
 1850|      1|    tif->tif_getmaxcompressionratio = PixarLogGetMaxCompressionRatio;
 1851|       |
 1852|       |    /* Override SetField so we can handle our private pseudo-tag */
 1853|      1|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1854|      1|    tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */
 1855|      1|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1856|      1|    tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */
 1857|       |
 1858|       |    /* Default values for codec-specific fields */
 1859|      1|    sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */
 1860|      1|    sp->state = 0;
 1861|       |
 1862|       |    /* we don't wish to use the predictor,
 1863|       |     * the default is none, which predictor value 1
 1864|       |     */
 1865|      1|    (void)TIFFPredictorInit(tif);
 1866|       |
 1867|       |    /*
 1868|       |     * build the companding tables
 1869|       |     */
 1870|      1|    PixarLogMakeTables(tif, sp);
 1871|       |
 1872|      1|    return (1);
 1873|      0|bad:
 1874|      0|    TIFFErrorExtR(tif, module, "No space for PixarLog state block");
 1875|      0|    return (0);
 1876|      1|}
tif_pixarlog.c:PixarLogFixupTags:
  822|      1|{
  823|      1|    (void)tif;
  824|      1|    return (1);
  825|      1|}
tif_pixarlog.c:PixarLogSetupDecode:
  828|      1|{
  829|      1|    static const char module[] = "PixarLogSetupDecode";
  830|      1|    TIFFDirectory *td = &tif->tif_dir;
  831|      1|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|      1|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  832|      1|    tmsize_t tbuf_size;
  833|      1|    uint32_t strip_height;
  834|       |
  835|      1|    assert(sp != NULL);
  ------------------
  |  Branch (835:5): [True: 0, False: 1]
  |  Branch (835:5): [True: 1, False: 0]
  ------------------
  836|       |
  837|       |    /* This function can possibly be called several times by */
  838|       |    /* PredictorSetupDecode() if this function succeeds but */
  839|       |    /* PredictorSetup() fails */
  840|      1|    if ((sp->state & PLSTATE_INIT) != 0)
  ------------------
  |  |  615|      1|#define PLSTATE_INIT 1
  ------------------
  |  Branch (840:9): [True: 0, False: 1]
  ------------------
  841|      0|        return 1;
  842|       |
  843|      1|    strip_height = td->td_rowsperstrip;
  844|      1|    if (strip_height > td->td_imagelength)
  ------------------
  |  Branch (844:9): [True: 0, False: 1]
  ------------------
  845|      0|        strip_height = td->td_imagelength;
  846|       |
  847|       |    /* Make sure no byte swapping happens on the data
  848|       |     * after decompression. */
  849|      1|    tif->tif_postdecode = _TIFFNoPostDecode;
  850|       |
  851|       |    /* for some reason, we can't do this in TIFFInitPixarLog */
  852|       |
  853|      1|    sp->stride =
  854|      1|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|      1|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (854:10): [True: 1, False: 0]
  ------------------
  855|      1|                                                    : 1);
  856|      1|    tbuf_size = multiply_ms(
  857|      1|        multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), strip_height),
  858|      1|        sizeof(uint16_t));
  859|       |    /* add one more stride in case input ends mid-stride */
  860|      1|    tbuf_size =
  861|      1|        add_ms(tbuf_size, (tmsize_t)(sizeof(uint16_t) * (size_t)sp->stride));
  862|      1|    if (tbuf_size == 0)
  ------------------
  |  Branch (862:9): [True: 0, False: 1]
  ------------------
  863|      0|        return (0); /* TODO: this is an error return without error report
  864|       |                       through TIFFErrorExt */
  865|      1|    sp->tbuf = (uint16_t *)_TIFFmallocExt(tif, tbuf_size);
  866|      1|    if (sp->tbuf == NULL)
  ------------------
  |  Branch (866:9): [True: 0, False: 1]
  ------------------
  867|      0|        return (0);
  868|      1|    sp->tbuf_size = tbuf_size;
  869|      1|    if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
  ------------------
  |  |  765|      1|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (869:9): [True: 1, False: 0]
  ------------------
  870|      1|        sp->user_datafmt = PixarLogGuessDataFmt(td);
  871|      1|    if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
  ------------------
  |  |  765|      1|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  |  Branch (871:9): [True: 0, False: 1]
  ------------------
  872|      0|    {
  873|      0|        _TIFFfreeExt(tif, sp->tbuf);
  874|      0|        sp->tbuf = NULL;
  875|      0|        sp->tbuf_size = 0;
  876|      0|        TIFFErrorExtR(tif, module,
  877|      0|                      "PixarLog compression can't handle bits depth/data "
  878|      0|                      "format combination (depth: %" PRIu16 ")",
  879|      0|                      td->td_bitspersample);
  880|      0|        return (0);
  881|      0|    }
  882|       |
  883|      1|    if (inflateInit(&sp->stream) != Z_OK)
  ------------------
  |  Branch (883:9): [True: 0, False: 1]
  ------------------
  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|      1|    else
  893|      1|    {
  894|      1|        sp->state |= PLSTATE_INIT;
  ------------------
  |  |  615|      1|#define PLSTATE_INIT 1
  ------------------
  895|      1|        return (1);
  896|      1|    }
  897|      1|}
tif_pixarlog.c:multiply_ms:
  805|      3|{
  806|      3|    return _TIFFMultiplySSize(NULL, m1, m2, NULL);
  807|      3|}
tif_pixarlog.c:add_ms:
  810|      1|{
  811|      1|    assert(m1 >= 0 && m2 >= 0);
  ------------------
  |  Branch (811:5): [True: 0, False: 1]
  |  Branch (811:5): [True: 0, False: 0]
  |  Branch (811:5): [True: 1, False: 0]
  |  Branch (811:5): [True: 1, False: 0]
  ------------------
  812|       |    /* if either input is zero, assume overflow already occurred */
  813|      1|    if (m1 == 0 || m2 == 0)
  ------------------
  |  Branch (813:9): [True: 0, False: 1]
  |  Branch (813:20): [True: 0, False: 1]
  ------------------
  814|      0|        return 0;
  815|      1|    else if (m1 > TIFF_TMSIZE_T_MAX - m2)
  ------------------
  |  |   68|      1|#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  ------------------
  |  Branch (815:14): [True: 0, False: 1]
  ------------------
  816|      0|        return 0;
  817|       |
  818|      1|    return m1 + m2;
  819|      1|}
tif_pixarlog.c:PixarLogGuessDataFmt:
  768|      1|{
  769|      1|    int guess = PIXARLOGDATAFMT_UNKNOWN;
  ------------------
  |  |  765|      1|#define PIXARLOGDATAFMT_UNKNOWN -1
  ------------------
  770|      1|    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|      1|    switch (td->td_bitspersample)
  776|      1|    {
  777|      0|        case 32:
  ------------------
  |  Branch (777:9): [True: 0, False: 1]
  ------------------
  778|      0|            if (format == SAMPLEFORMAT_IEEEFP)
  ------------------
  |  |  336|      0|#define SAMPLEFORMAT_IEEEFP 3              /* !IEEE floating point data */
  ------------------
  |  Branch (778:17): [True: 0, False: 0]
  ------------------
  779|      0|                guess = PIXARLOGDATAFMT_FLOAT;
  ------------------
  |  |  720|      0|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  780|      0|            break;
  781|      0|        case 16:
  ------------------
  |  Branch (781:9): [True: 0, False: 1]
  ------------------
  782|      0|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|      0|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (782:17): [True: 0, False: 0]
  |  Branch (782:48): [True: 0, False: 0]
  ------------------
  783|      0|                guess = PIXARLOGDATAFMT_16BIT;
  ------------------
  |  |  719|      0|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  784|      0|            break;
  785|      1|        case 12:
  ------------------
  |  Branch (785:9): [True: 1, False: 0]
  ------------------
  786|      1|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT)
  ------------------
  |  |  337|      2|#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: 1, False: 0]
  |  Branch (786:48): [True: 0, False: 0]
  ------------------
  787|      1|                guess = PIXARLOGDATAFMT_12BITPICIO;
  ------------------
  |  |  718|      1|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  788|      1|            break;
  789|      0|        case 11:
  ------------------
  |  Branch (789:9): [True: 0, False: 1]
  ------------------
  790|      0|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|      0|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (790:17): [True: 0, False: 0]
  |  Branch (790:48): [True: 0, False: 0]
  ------------------
  791|      0|                guess = PIXARLOGDATAFMT_11BITLOG;
  ------------------
  |  |  717|      0|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  792|      0|            break;
  793|      0|        case 8:
  ------------------
  |  Branch (793:9): [True: 0, False: 1]
  ------------------
  794|      0|            if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  337|      0|#define SAMPLEFORMAT_VOID 4                /* !untyped data */
  ------------------
                          if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
  ------------------
  |  |  334|      0|#define SAMPLEFORMAT_UINT 1                /* !unsigned integer data */
  ------------------
  |  Branch (794:17): [True: 0, False: 0]
  |  Branch (794:48): [True: 0, False: 0]
  ------------------
  795|      0|                guess = PIXARLOGDATAFMT_8BIT;
  ------------------
  |  |  715|      0|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  796|      0|            break;
  797|      0|        default:
  ------------------
  |  Branch (797:9): [True: 0, False: 1]
  ------------------
  798|      0|            break;
  799|      1|    }
  800|       |
  801|      1|    return guess;
  802|      1|}
tif_pixarlog.c:PixarLogPreDecode:
  903|    512|{
  904|    512|    static const char module[] = "PixarLogPreDecode";
  905|    512|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|    512|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  906|       |
  907|    512|    (void)s;
  908|    512|    assert(sp != NULL);
  ------------------
  |  Branch (908:5): [True: 0, False: 512]
  |  Branch (908:5): [True: 512, False: 0]
  ------------------
  909|    512|    sp->stream.next_in = tif->tif_rawdata;
  910|    512|    assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (910:5): [True: 0, Folded]
  |  Branch (910:5): [True: 512, 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|    512|    sp->stream.avail_in = (uInt)tif->tif_rawcc;
  915|    512|    if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
  ------------------
  |  Branch (915:9): [True: 0, False: 512]
  ------------------
  916|      0|    {
  917|      0|        TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
  918|      0|        return (0);
  919|      0|    }
  920|    512|    return (inflateReset(&sp->stream) == Z_OK);
  921|    512|}
tif_pixarlog.c:PixarLogDecode:
  924|    512|{
  925|    512|    static const char module[] = "PixarLogDecode";
  926|    512|    TIFFDirectory *td = &tif->tif_dir;
  927|    512|    PixarLogState *sp = PixarLogDecoderState(tif);
  ------------------
  |  |  759|    512|#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
  ------------------
  928|    512|    tmsize_t i;
  929|    512|    tmsize_t nsamples;
  930|    512|    tmsize_t llen;
  931|    512|    uint16_t *up;
  932|       |
  933|    512|    switch (sp->user_datafmt)
  934|    512|    {
  935|      0|        case PIXARLOGDATAFMT_FLOAT:
  ------------------
  |  |  720|      0|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  |  Branch (935:9): [True: 0, False: 512]
  ------------------
  936|      0|            nsamples = (tmsize_t)((uint64_t)occ /
  937|      0|                                  sizeof(float)); /* XXX float == 32 bits */
  938|      0|            break;
  939|      0|        case PIXARLOGDATAFMT_16BIT:
  ------------------
  |  |  719|      0|#define PIXARLOGDATAFMT_16BIT 4       /* signed short samples */
  ------------------
  |  Branch (939:9): [True: 0, False: 512]
  ------------------
  940|    512|        case PIXARLOGDATAFMT_12BITPICIO:
  ------------------
  |  |  718|    512|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  |  Branch (940:9): [True: 512, False: 0]
  ------------------
  941|    512|        case PIXARLOGDATAFMT_11BITLOG:
  ------------------
  |  |  717|    512|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  |  Branch (941:9): [True: 0, False: 512]
  ------------------
  942|    512|            nsamples =
  943|    512|                (tmsize_t)((uint64_t)occ /
  944|    512|                           sizeof(uint16_t)); /* XXX uint16_t == 16 bits */
  945|    512|            break;
  946|      0|        case PIXARLOGDATAFMT_8BIT:
  ------------------
  |  |  715|      0|#define PIXARLOGDATAFMT_8BIT 0        /* regular u_char samples */
  ------------------
  |  Branch (946:9): [True: 0, False: 512]
  ------------------
  947|      0|        case PIXARLOGDATAFMT_8BITABGR:
  ------------------
  |  |  716|      0|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (947:9): [True: 0, False: 512]
  ------------------
  948|      0|            nsamples = occ;
  949|      0|            break;
  950|      0|        default:
  ------------------
  |  Branch (950:9): [True: 0, False: 512]
  ------------------
  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|    512|    }
  957|       |
  958|       |    /* stride (≤ td_samplesperpixel, max 65535) × imagewidth: fits tmsize_t */
  959|    512|    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|    512|    if (sp->user_datafmt == PIXARLOGDATAFMT_8BITABGR && sp->stride == 3)
  ------------------
  |  |  716|  1.02k|#define PIXARLOGDATAFMT_8BITABGR 1    /* ABGR-order u_chars */
  ------------------
  |  Branch (962:9): [True: 0, False: 512]
  |  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|    512|    (void)s;
 1011|    512|    assert(sp != NULL);
  ------------------
  |  Branch (1011:5): [True: 0, False: 512]
  |  Branch (1011:5): [True: 512, False: 0]
  ------------------
 1012|       |
 1013|    512|    sp->stream.next_in = tif->tif_rawcp;
 1014|    512|    sp->stream.avail_in = (uInt)tif->tif_rawcc;
 1015|       |
 1016|    512|    sp->stream.next_out = (unsigned char *)sp->tbuf;
 1017|    512|    assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (1017:5): [True: 0, Folded]
  |  Branch (1017:5): [True: 512, 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|    512|    sp->stream.avail_out = (uInt)((unsigned long)nsamples * sizeof(uint16_t));
 1022|    512|    if (sp->stream.avail_out != (unsigned long)nsamples * sizeof(uint16_t))
  ------------------
  |  Branch (1022:9): [True: 0, False: 512]
  ------------------
 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|    512|    if ((tmsize_t)sp->stream.avail_out > sp->tbuf_size)
  ------------------
  |  Branch (1029:9): [True: 0, False: 512]
  ------------------
 1030|      0|    {
 1031|      0|        TIFFErrorExtR(tif, module, "sp->stream.avail_out > sp->tbuf_size");
 1032|      0|        memset(op, 0, (size_t)occ);
 1033|      0|        return (0);
 1034|      0|    }
 1035|    512|    do
 1036|    559|    {
 1037|    559|        int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
 1038|    559|        if (state == Z_STREAM_END)
  ------------------
  |  Branch (1038:13): [True: 0, False: 559]
  ------------------
 1039|      0|        {
 1040|      0|            break; /* XXX */
 1041|      0|        }
 1042|    559|        if (state == Z_DATA_ERROR)
  ------------------
  |  Branch (1042:13): [True: 249, False: 310]
  ------------------
 1043|    249|        {
 1044|    249|            TIFFErrorExtR(tif, module,
 1045|    249|                          "Decoding error at scanline %" PRIu32 ", %s",
 1046|    249|                          tif->tif_dir.td_row,
 1047|    249|                          sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (1047:27): [True: 249, False: 0]
  ------------------
 1048|    249|            memset(op, 0, (size_t)occ);
 1049|    249|            return (0);
 1050|    249|        }
 1051|    310|        if (state != Z_OK)
  ------------------
  |  Branch (1051:13): [True: 47, False: 263]
  ------------------
 1052|     47|        {
 1053|     47|            TIFFErrorExtR(tif, module, "ZLib error: %s",
 1054|     47|                          sp->stream.msg ? sp->stream.msg : "(null)");
  ------------------
  |  Branch (1054:27): [True: 0, False: 47]
  ------------------
 1055|     47|            memset(op, 0, (size_t)occ);
 1056|     47|            return (0);
 1057|     47|        }
 1058|    310|    } while (sp->stream.avail_out > 0);
  ------------------
  |  Branch (1058:14): [True: 47, False: 216]
  ------------------
 1059|       |
 1060|       |    /* hopefully, we got all the bytes we needed */
 1061|    216|    if (sp->stream.avail_out != 0)
  ------------------
  |  Branch (1061:9): [True: 0, False: 216]
  ------------------
 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|    216|    tif->tif_rawcp = sp->stream.next_in;
 1072|    216|    tif->tif_rawcc = sp->stream.avail_in;
 1073|       |
 1074|    216|    up = sp->tbuf;
 1075|       |    /* Swap bytes in the data if from a different endian machine. */
 1076|    216|    if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|    216|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (1076:9): [True: 0, False: 216]
  ------------------
 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|    216|    if (nsamples % llen)
  ------------------
  |  Branch (1084:9): [True: 216, False: 0]
  ------------------
 1085|    216|    {
 1086|    216|        TIFFWarningExtR(tif, module,
 1087|    216|                        "stride %" TIFF_SSIZE_FORMAT
 1088|    216|                        " is not a multiple of sample count, "
 1089|    216|                        "%" TIFF_SSIZE_FORMAT ", data truncated.",
 1090|    216|                        llen, nsamples);
 1091|    216|        nsamples -= nsamples % llen;
 1092|    216|    }
 1093|       |
 1094|    647|    for (i = 0; i < nsamples; i += llen, up += llen)
  ------------------
  |  Branch (1094:17): [True: 431, False: 216]
  ------------------
 1095|    431|    {
 1096|    431|        switch (sp->user_datafmt)
 1097|    431|        {
 1098|      0|            case PIXARLOGDATAFMT_FLOAT:
  ------------------
  |  |  720|      0|#define PIXARLOGDATAFMT_FLOAT 5       /* IEEE float samples */
  ------------------
  |  Branch (1098:13): [True: 0, False: 431]
  ------------------
 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: 431]
  ------------------
 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|    431|            case PIXARLOGDATAFMT_12BITPICIO:
  ------------------
  |  |  718|    431|#define PIXARLOGDATAFMT_12BITPICIO 3  /* as per PICIO (1.0==2048) */
  ------------------
  |  Branch (1107:13): [True: 431, False: 0]
  ------------------
 1108|    431|                horizontalAccumulate12(up, llen, sp->stride, op, sp->ToLinearF);
 1109|    431|                op += (unsigned long)llen * sizeof(int16_t);
 1110|    431|                break;
 1111|      0|            case PIXARLOGDATAFMT_11BITLOG:
  ------------------
  |  |  717|      0|#define PIXARLOGDATAFMT_11BITLOG 2    /* 11-bit log-encoded (raw) */
  ------------------
  |  Branch (1111:13): [True: 0, False: 431]
  ------------------
 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: 431]
  ------------------
 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: 431]
  ------------------
 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: 431]
  ------------------
 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|    431|        }
 1137|    431|    }
 1138|       |
 1139|    216|    return (1);
 1140|    216|}
tif_pixarlog.c:PixarLogStore16NativeUnaligned:
  147|  9.05k|{
  148|  9.05k|    memcpy(cp, &v, sizeof(v));
  149|  9.05k|}
tif_pixarlog.c:horizontalAccumulate12:
  228|    431|{
  229|    431|    unsigned int cr, cg, cb, ca, mask;
  230|    431|    float t0, t1, t2, t3;
  231|       |
  232|    431|#define SCALE12 2048.0f
  233|    431|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  234|       |
  235|    431|    if (n >= stride)
  ------------------
  |  Branch (235:9): [True: 431, False: 0]
  ------------------
  236|    431|    {
  237|    431|        mask = CODE_MASK;
  ------------------
  |  |  104|    431|#define CODE_MASK 0x7ff /* 11 bits. */
  ------------------
  238|    431|        if (stride == 3)
  ------------------
  |  Branch (238:13): [True: 431, False: 0]
  ------------------
  239|    431|        {
  240|    431|            t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
  ------------------
  |  |  232|    431|#define SCALE12 2048.0f
  ------------------
  241|    431|            t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
  ------------------
  |  |  232|    431|#define SCALE12 2048.0f
  ------------------
  242|    431|            t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
  ------------------
  |  |  232|    431|#define SCALE12 2048.0f
  ------------------
  243|    431|            PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  ------------------
  |  |  233|    431|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 215, False: 216]
  |  |  ------------------
  ------------------
  244|    431|            PixarLogStore16NativeUnaligned(op + sizeof(uint16_t),
  245|    431|                                           (uint16_t)CLAMP12(t1));
  ------------------
  |  |  233|    431|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 215, False: 216]
  |  |  ------------------
  ------------------
  246|    431|            PixarLogStore16NativeUnaligned(op + 2 * sizeof(uint16_t),
  247|    431|                                           (uint16_t)CLAMP12(t2));
  ------------------
  |  |  233|    431|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 215, False: 216]
  |  |  ------------------
  ------------------
  248|    431|            n -= 3;
  249|  3.01k|            while (n > 0)
  ------------------
  |  Branch (249:20): [True: 2.58k, False: 431]
  ------------------
  250|  2.58k|            {
  251|  2.58k|                wp += 3;
  252|  2.58k|                op += 3 * sizeof(uint16_t);
  253|  2.58k|                n -= 3;
  254|  2.58k|                t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12;
  ------------------
  |  |  232|  2.58k|#define SCALE12 2048.0f
  ------------------
  255|  2.58k|                t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12;
  ------------------
  |  |  232|  2.58k|#define SCALE12 2048.0f
  ------------------
  256|  2.58k|                t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12;
  ------------------
  |  |  232|  2.58k|#define SCALE12 2048.0f
  ------------------
  257|  2.58k|                PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  ------------------
  |  |  233|  2.58k|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 1.93k, False: 648]
  |  |  ------------------
  ------------------
  258|  2.58k|                PixarLogStore16NativeUnaligned(op + sizeof(uint16_t),
  259|  2.58k|                                               (uint16_t)CLAMP12(t1));
  ------------------
  |  |  233|  2.58k|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 1.72k, False: 864]
  |  |  ------------------
  ------------------
  260|  2.58k|                PixarLogStore16NativeUnaligned(op + 2 * sizeof(uint16_t),
  261|  2.58k|                                               (uint16_t)CLAMP12(t2));
  ------------------
  |  |  233|  2.58k|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 1.72k, False: 864]
  |  |  ------------------
  ------------------
  262|  2.58k|            }
  263|    431|        }
  264|      0|        else if (stride == 4)
  ------------------
  |  Branch (264:18): [True: 0, False: 0]
  ------------------
  265|      0|        {
  266|      0|            t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  267|      0|            t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  268|      0|            t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  269|      0|            t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  270|      0|            PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  271|      0|            PixarLogStore16NativeUnaligned(op + sizeof(uint16_t),
  272|      0|                                           (uint16_t)CLAMP12(t1));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  273|      0|            PixarLogStore16NativeUnaligned(op + 2 * sizeof(uint16_t),
  274|      0|                                           (uint16_t)CLAMP12(t2));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  275|      0|            PixarLogStore16NativeUnaligned(op + 3 * sizeof(uint16_t),
  276|      0|                                           (uint16_t)CLAMP12(t3));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  277|      0|            n -= 4;
  278|      0|            while (n > 0)
  ------------------
  |  Branch (278:20): [True: 0, False: 0]
  ------------------
  279|      0|            {
  280|      0|                wp += 4;
  281|      0|                op += 4 * sizeof(uint16_t);
  282|      0|                n -= 4;
  283|      0|                t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  284|      0|                t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  285|      0|                t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  286|      0|                t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12;
  ------------------
  |  |  232|      0|#define SCALE12 2048.0f
  ------------------
  287|      0|                PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  288|      0|                PixarLogStore16NativeUnaligned(op + sizeof(uint16_t),
  289|      0|                                               (uint16_t)CLAMP12(t1));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  290|      0|                PixarLogStore16NativeUnaligned(op + 2 * sizeof(uint16_t),
  291|      0|                                               (uint16_t)CLAMP12(t2));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  292|      0|                PixarLogStore16NativeUnaligned(op + 3 * sizeof(uint16_t),
  293|      0|                                               (uint16_t)CLAMP12(t3));
  ------------------
  |  |  233|      0|#define CLAMP12(t) (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
  |  |  ------------------
  |  |  |  Branch (233:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  294|      0|            }
  295|      0|        }
  296|      0|        else
  297|      0|        {
  298|      0|            REPEAT(stride, t0 = ToLinearF[*wp & mask] * SCALE12;
  ------------------
  |  |  110|      0|    {                                                                          \
  |  |  111|      0|        int i;                                                                 \
  |  |  112|      0|        i = n;                                                                 \
  |  |  113|      0|        do                                                                     \
  |  |  114|      0|        {                                                                      \
  |  |  115|      0|            i--;                                                               \
  |  |  116|      0|            op;                                                                \
  |  |  ------------------
  |  |  |  Branch (116:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  117|      0|        } while (i > 0);                                                       \
  |  |  ------------------
  |  |  |  Branch (117:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  118|      0|    }
  ------------------
  299|      0|                   PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  300|      0|                   wp++; op += sizeof(uint16_t))
  301|      0|            n -= stride;
  302|      0|            while (n > 0)
  ------------------
  |  Branch (302:20): [True: 0, False: 0]
  ------------------
  303|      0|            {
  304|      0|                REPEAT(
  ------------------
  |  |  110|      0|    {                                                                          \
  |  |  111|      0|        int i;                                                                 \
  |  |  112|      0|        i = n;                                                                 \
  |  |  113|      0|        do                                                                     \
  |  |  114|      0|        {                                                                      \
  |  |  115|      0|            i--;                                                               \
  |  |  116|      0|            op;                                                                \
  |  |  ------------------
  |  |  |  Branch (116:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  117|      0|        } while (i > 0);                                                       \
  |  |  ------------------
  |  |  |  Branch (117:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  118|      0|    }
  ------------------
  305|      0|                    stride, *wp = (uint16_t)(*wp + wp[-stride]);
  306|      0|                    t0 = ToLinearF[*wp & mask] * SCALE12;
  307|      0|                    PixarLogStore16NativeUnaligned(op, (uint16_t)CLAMP12(t0));
  308|      0|                    wp++; op += sizeof(uint16_t))
  309|      0|                n -= stride;
  310|      0|            }
  311|      0|        }
  312|    431|    }
  313|    431|}
tif_pixarlog.c:PixarLogCleanup:
 1663|      1|{
 1664|      1|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1665|       |
 1666|      1|    assert(sp != 0);
  ------------------
  |  Branch (1666:5): [True: 0, False: 1]
  |  Branch (1666:5): [True: 1, False: 0]
  ------------------
 1667|       |
 1668|      1|    (void)TIFFPredictorCleanup(tif);
 1669|       |
 1670|      1|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1671|      1|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1672|       |
 1673|      1|    if (sp->FromLT2)
  ------------------
  |  Branch (1673:9): [True: 1, False: 0]
  ------------------
 1674|      1|        _TIFFfreeExt(tif, sp->FromLT2);
 1675|      1|    if (sp->From14)
  ------------------
  |  Branch (1675:9): [True: 1, False: 0]
  ------------------
 1676|      1|        _TIFFfreeExt(tif, sp->From14);
 1677|      1|    if (sp->From8)
  ------------------
  |  Branch (1677:9): [True: 1, False: 0]
  ------------------
 1678|      1|        _TIFFfreeExt(tif, sp->From8);
 1679|      1|    if (sp->ToLinearF)
  ------------------
  |  Branch (1679:9): [True: 1, False: 0]
  ------------------
 1680|      1|        _TIFFfreeExt(tif, sp->ToLinearF);
 1681|      1|    if (sp->ToLinear16)
  ------------------
  |  Branch (1681:9): [True: 1, False: 0]
  ------------------
 1682|      1|        _TIFFfreeExt(tif, sp->ToLinear16);
 1683|      1|    if (sp->ToLinear8)
  ------------------
  |  Branch (1683:9): [True: 1, False: 0]
  ------------------
 1684|      1|        _TIFFfreeExt(tif, sp->ToLinear8);
 1685|      1|    if (sp->state & PLSTATE_INIT)
  ------------------
  |  |  615|      1|#define PLSTATE_INIT 1
  ------------------
  |  Branch (1685:9): [True: 1, False: 0]
  ------------------
 1686|      1|    {
 1687|      1|        if (tif->tif_mode == O_RDONLY)
  ------------------
  |  Branch (1687:13): [True: 1, False: 0]
  ------------------
 1688|      1|            inflateEnd(&sp->stream);
 1689|      0|        else
 1690|      0|            deflateEnd(&sp->stream);
 1691|      1|    }
 1692|      1|    if (sp->tbuf)
  ------------------
  |  Branch (1692:9): [True: 1, False: 0]
  ------------------
 1693|      1|        _TIFFfreeExt(tif, sp->tbuf);
 1694|      1|    _TIFFfreeExt(tif, sp);
 1695|      1|    tif->tif_data = NULL;
 1696|       |
 1697|      1|    _TIFFSetDefaultCompressionState(tif);
 1698|      1|}
tif_pixarlog.c:PixarLogVGetField:
 1770|      3|{
 1771|      3|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1772|       |
 1773|      3|    switch (tag)
 1774|      3|    {
 1775|      0|        case TIFFTAG_PIXARLOGQUALITY:
  ------------------
  |  |  740|      0|#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
  ------------------
  |  Branch (1775:9): [True: 0, False: 3]
  ------------------
 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: 3]
  ------------------
 1779|      0|            *va_arg(ap, int *) = sp->user_datafmt;
 1780|      0|            break;
 1781|      3|        default:
  ------------------
  |  Branch (1781:9): [True: 3, False: 0]
  ------------------
 1782|      3|            return (*sp->vgetparent)(tif, tag, ap);
 1783|      3|    }
 1784|      0|    return (1);
 1785|      3|}
tif_pixarlog.c:PixarLogVSetField:
 1701|      8|{
 1702|      8|    static const char module[] = "PixarLogVSetField";
 1703|      8|    PixarLogState *sp = (PixarLogState *)tif->tif_data;
 1704|      8|    int result;
 1705|       |
 1706|      8|    switch (tag)
 1707|      8|    {
 1708|      0|        case TIFFTAG_PIXARLOGQUALITY:
  ------------------
  |  |  740|      0|#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
  ------------------
  |  Branch (1708:9): [True: 0, False: 8]
  ------------------
 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: 8]
  ------------------
 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|      8|        default:
  ------------------
  |  Branch (1763:9): [True: 8, False: 0]
  ------------------
 1764|      8|            result = (*sp->vsetparent)(tif, tag, ap);
 1765|      8|    }
 1766|      8|    return (result);
 1767|      8|}
tif_pixarlog.c:PixarLogMakeTables:
  630|      1|{
  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|      1|    int nlin, lt2size;
  644|      1|    int i, j;
  645|      1|    double b, c, linstep, v;
  646|      1|    float *ToLinearF;
  647|      1|    uint16_t *ToLinear16;
  648|      1|    unsigned char *ToLinear8;
  649|      1|    uint16_t *FromLT2;
  650|      1|    uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */
  651|      1|    uint16_t *From8;
  652|       |
  653|      1|    c = log(RATIO);
  ------------------
  |  |  102|      1|#define RATIO 1.004  /* nominal ratio for log part */
  ------------------
  654|      1|    nlin = (int)(1. / c); /* nlin must be an integer */
  655|      1|    c = 1. / nlin;
  656|      1|    b = exp(-c * ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */
  ------------------
  |  |  101|      1|#define ONE 1250     /* token value of 1.0 exactly */
  ------------------
  657|      1|    linstep = b * c * exp(1.);
  658|       |
  659|      1|    LogK1 = (float)(1. / c); /* if (v >= 2)  token = k1*log(v*k2) */
  660|      1|    LogK2 = (float)(1. / b);
  661|      1|    lt2size = (int)(2. / linstep) + 1;
  662|      1|    FromLT2 = (uint16_t *)_TIFFmallocExt(
  663|      1|        tif, (tmsize_t)((size_t)lt2size * sizeof(uint16_t)));
  664|      1|    From14 = (uint16_t *)_TIFFmallocExt(tif, 16384 * sizeof(uint16_t));
  665|      1|    From8 = (uint16_t *)_TIFFmallocExt(tif, 256 * sizeof(uint16_t));
  666|      1|    ToLinearF = (float *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(float));
  ------------------
  |  |  100|      1|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  667|      1|    ToLinear16 = (uint16_t *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(uint16_t));
  ------------------
  |  |  100|      1|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  668|      1|    ToLinear8 =
  669|      1|        (unsigned char *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(unsigned char));
  ------------------
  |  |  100|      1|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  670|      1|    if (FromLT2 == NULL || From14 == NULL || From8 == NULL ||
  ------------------
  |  Branch (670:9): [True: 0, False: 1]
  |  Branch (670:28): [True: 0, False: 1]
  |  Branch (670:46): [True: 0, False: 1]
  ------------------
  671|      1|        ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL)
  ------------------
  |  Branch (671:9): [True: 0, False: 1]
  |  Branch (671:30): [True: 0, False: 1]
  |  Branch (671:52): [True: 0, False: 1]
  ------------------
  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|      1|    j = 0;
  695|       |
  696|    251|    for (i = 0; i < nlin; i++)
  ------------------
  |  Branch (696:17): [True: 250, False: 1]
  ------------------
  697|    250|    {
  698|    250|        v = i * linstep;
  699|    250|        ToLinearF[j++] = (float)v;
  700|    250|    }
  701|       |
  702|  1.79k|    for (i = nlin; i < TSIZE; i++)
  ------------------
  |  |   99|  1.79k|#define TSIZE 2048   /* decode table size (11-bit tokens) */
  ------------------
  |  Branch (702:20): [True: 1.79k, False: 1]
  ------------------
  703|  1.79k|        ToLinearF[j++] = (float)(b * exp(c * i));
  704|       |
  705|      1|    ToLinearF[2048] = ToLinearF[2047];
  706|       |
  707|  2.05k|    for (i = 0; i < TSIZEP1; i++)
  ------------------
  |  |  100|  2.05k|#define TSIZEP1 2049 /* Plus one for slop */
  ------------------
  |  Branch (707:17): [True: 2.04k, False: 1]
  ------------------
  708|  2.04k|    {
  709|  2.04k|        v = (double)ToLinearF[i] * 65535.0 + 0.5;
  710|  2.04k|        ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16_t)v;
  ------------------
  |  Branch (710:25): [True: 799, False: 1.25k]
  ------------------
  711|  2.04k|        v = (double)ToLinearF[i] * 255.0 + 0.5;
  712|  2.04k|        ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v;
  ------------------
  |  Branch (712:24): [True: 799, False: 1.25k]
  ------------------
  713|  2.04k|    }
  714|       |
  715|      1|    j = 0;
  716|  27.3k|    for (i = 0; i < lt2size; i++)
  ------------------
  |  Branch (716:17): [True: 27.3k, False: 1]
  ------------------
  717|  27.3k|    {
  718|  27.3k|        if ((i * linstep) * (i * linstep) >
  ------------------
  |  Branch (718:13): [True: 1.42k, False: 25.8k]
  ------------------
  719|  27.3k|            (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  720|  1.42k|            j++;
  721|  27.3k|        FromLT2[i] = (uint16_t)j;
  722|  27.3k|    }
  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|      1|    j = 0;
  730|  16.3k|    for (i = 0; i < 16384; i++)
  ------------------
  |  Branch (730:17): [True: 16.3k, False: 1]
  ------------------
  731|  16.3k|    {
  732|  17.6k|        while ((i / 16383.) * (i / 16383.) >
  ------------------
  |  Branch (732:16): [True: 1.25k, False: 16.3k]
  ------------------
  733|  17.6k|               (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  734|  1.25k|            j++;
  735|  16.3k|        From14[i] = (uint16_t)j;
  736|  16.3k|    }
  737|       |
  738|      1|    j = 0;
  739|    257|    for (i = 0; i < 256; i++)
  ------------------
  |  Branch (739:17): [True: 256, False: 1]
  ------------------
  740|    256|    {
  741|  1.50k|        while ((i / 255.) * (i / 255.) >
  ------------------
  |  Branch (741:16): [True: 1.25k, False: 256]
  ------------------
  742|  1.50k|               (double)ToLinearF[j] * (double)ToLinearF[j + 1])
  743|  1.25k|            j++;
  744|    256|        From8[i] = (uint16_t)j;
  745|    256|    }
  746|       |
  747|      1|    Fltsize = (float)(lt2size / 2);
  748|       |
  749|      1|    sp->ToLinearF = ToLinearF;
  750|      1|    sp->ToLinear16 = ToLinear16;
  751|      1|    sp->ToLinear8 = ToLinear8;
  752|      1|    sp->FromLT2 = FromLT2;
  753|      1|    sp->From14 = From14;
  754|      1|    sp->From8 = From8;
  755|       |
  756|      1|    return 1;
  757|      1|}

TIFFPredictorInit:
 1205|     97|{
 1206|     97|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|     97|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1207|       |
 1208|     97|    assert(sp != 0);
  ------------------
  |  Branch (1208:5): [True: 0, False: 97]
  |  Branch (1208:5): [True: 97, False: 0]
  ------------------
 1209|       |
 1210|       |    /*
 1211|       |     * Merge codec-specific tag information.
 1212|       |     */
 1213|     97|    if (!_TIFFMergeFields(tif, predictFields, TIFFArrayCount(predictFields)))
  ------------------
  |  |  339|     97|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (1213:9): [True: 0, False: 97]
  ------------------
 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|     97|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
 1224|     97|    tif->tif_tagmethods.vgetfield =
 1225|     97|        PredictorVGetField; /* hook for predictor tag */
 1226|     97|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
 1227|     97|    tif->tif_tagmethods.vsetfield =
 1228|     97|        PredictorVSetField; /* hook for predictor tag */
 1229|     97|    sp->printdir = tif->tif_tagmethods.printdir;
 1230|     97|    tif->tif_tagmethods.printdir =
 1231|     97|        PredictorPrintDir; /* hook for predictor tag */
 1232|       |
 1233|     97|    sp->setupdecode = tif->tif_setupdecode;
 1234|     97|    tif->tif_setupdecode = PredictorSetupDecode;
 1235|     97|    sp->setupencode = tif->tif_setupencode;
 1236|     97|    tif->tif_setupencode = PredictorSetupEncode;
 1237|       |
 1238|     97|    sp->predictor = 1;      /* default value */
 1239|     97|    sp->encodepfunc = NULL; /* no predictor routine */
 1240|       |    sp->decodepfunc = NULL; /* no predictor routine */
 1241|     97|    return 1;
 1242|     97|}
TIFFPredictorCleanup:
 1245|     97|{
 1246|     97|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|     97|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1247|       |
 1248|     97|    assert(sp != 0);
  ------------------
  |  Branch (1248:5): [True: 0, False: 97]
  |  Branch (1248:5): [True: 97, False: 0]
  ------------------
 1249|       |
 1250|     97|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
 1251|     97|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
 1252|     97|    tif->tif_tagmethods.printdir = sp->printdir;
 1253|     97|    tif->tif_setupdecode = sp->setupdecode;
 1254|     97|    tif->tif_setupencode = sp->setupencode;
 1255|       |
 1256|     97|    return 1;
 1257|     97|}
tif_predict.c:PredictorVGetField:
 1159|    929|{
 1160|    929|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    929|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1161|       |
 1162|    929|    assert(sp != NULL);
  ------------------
  |  Branch (1162:5): [True: 0, False: 929]
  |  Branch (1162:5): [True: 929, False: 0]
  ------------------
 1163|    929|    assert(sp->vgetparent != NULL);
  ------------------
  |  Branch (1163:5): [True: 0, False: 929]
  |  Branch (1163:5): [True: 929, False: 0]
  ------------------
 1164|       |
 1165|    929|    switch (tag)
 1166|    929|    {
 1167|      0|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1167:9): [True: 0, False: 929]
  ------------------
 1168|      0|            *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor;
 1169|      0|            break;
 1170|    929|        default:
  ------------------
  |  Branch (1170:9): [True: 929, False: 0]
  ------------------
 1171|    929|            return (*sp->vgetparent)(tif, tag, ap);
 1172|    929|    }
 1173|      0|    return 1;
 1174|    929|}
tif_predict.c:PredictorVSetField:
 1139|    656|{
 1140|    656|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    656|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
 1141|       |
 1142|    656|    assert(sp != NULL);
  ------------------
  |  Branch (1142:5): [True: 0, False: 656]
  |  Branch (1142:5): [True: 656, False: 0]
  ------------------
 1143|    656|    assert(sp->vsetparent != NULL);
  ------------------
  |  Branch (1143:5): [True: 0, False: 656]
  |  Branch (1143:5): [True: 656, False: 0]
  ------------------
 1144|       |
 1145|    656|    switch (tag)
 1146|    656|    {
 1147|      0|        case TIFFTAG_PREDICTOR:
  ------------------
  |  |  303|      0|#define TIFFTAG_PREDICTOR 317              /* prediction scheme w/ LZW */
  ------------------
  |  Branch (1147:9): [True: 0, False: 656]
  ------------------
 1148|      0|            sp->predictor = (uint16_t)va_arg(ap, uint16_vap);
 1149|      0|            TIFFSetFieldBit(tif, FIELD_PREDICTOR);
  ------------------
  |  |  249|      0|#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  247|      0|#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
  |  |  ------------------
  |  |               #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
  |  |  ------------------
  |  |  |  |  246|      0|#define BITn(n) (1U << ((n) & 0x1f))
  |  |  ------------------
  ------------------
 1150|      0|            break;
 1151|    656|        default:
  ------------------
  |  Branch (1151:9): [True: 656, False: 0]
  ------------------
 1152|    656|            return (*sp->vsetparent)(tif, tag, ap);
 1153|    656|    }
 1154|      0|    tif->tif_flags |= TIFF_DIRTYDIRECT;
  ------------------
  |  |  122|      0|#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
  ------------------
 1155|      0|    return 1;
 1156|    656|}
tif_predict.c:PredictorSetupDecode:
  128|    107|{
  129|    107|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    107|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
  130|    107|    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|    107|    if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
  ------------------
  |  Branch (135:9): [True: 0, False: 107]
  |  Branch (135:37): [True: 0, False: 107]
  ------------------
  136|      0|        return 0;
  137|       |
  138|    107|    if (sp->predictor == 2)
  ------------------
  |  Branch (138:9): [True: 0, False: 107]
  ------------------
  139|      0|    {
  140|      0|        switch (td->td_bitspersample)
  141|      0|        {
  142|      0|            case 8:
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|                sp->decodepfunc = horAcc8;
  144|      0|                break;
  145|      0|            case 16:
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      0|                sp->decodepfunc = horAcc16;
  147|      0|                break;
  148|      0|            case 32:
  ------------------
  |  Branch (148:13): [True: 0, False: 0]
  ------------------
  149|      0|                sp->decodepfunc = horAcc32;
  150|      0|                break;
  151|      0|            case 64:
  ------------------
  |  Branch (151:13): [True: 0, False: 0]
  ------------------
  152|      0|                sp->decodepfunc = horAcc64;
  153|      0|                break;
  154|      0|            default:
  ------------------
  |  Branch (154:13): [True: 0, False: 0]
  ------------------
  155|      0|                break;
  156|      0|        }
  157|       |        /*
  158|       |         * Override default decoding method with one that does the
  159|       |         * predictor stuff.
  160|       |         */
  161|      0|        if (tif->tif_decoderow != PredictorDecodeRow)
  ------------------
  |  Branch (161:13): [True: 0, False: 0]
  ------------------
  162|      0|        {
  163|      0|            sp->decoderow = tif->tif_decoderow;
  164|      0|            tif->tif_decoderow = PredictorDecodeRow;
  165|      0|            sp->decodestrip = tif->tif_decodestrip;
  166|      0|            tif->tif_decodestrip = PredictorDecodeTile;
  167|      0|            sp->decodetile = tif->tif_decodetile;
  168|      0|            tif->tif_decodetile = PredictorDecodeTile;
  169|      0|        }
  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|      0|        if (tif->tif_flags & TIFF_SWAB)
  ------------------
  |  |  126|      0|#define TIFF_SWAB 0x00080U        /* byte swap file information */
  ------------------
  |  Branch (178:13): [True: 0, False: 0]
  ------------------
  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|      0|    }
  197|       |
  198|    107|    else if (sp->predictor == 3)
  ------------------
  |  Branch (198:14): [True: 0, False: 107]
  ------------------
  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|    107|    return 1;
  226|    107|}
tif_predict.c:PredictorSetup:
   64|    107|{
   65|    107|    static const char module[] = "PredictorSetup";
   66|       |
   67|    107|    TIFFPredictorState *sp = PredictorState(tif);
  ------------------
  |  |   37|    107|#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
  ------------------
   68|    107|    TIFFDirectory *td = &tif->tif_dir;
   69|       |
   70|    107|    switch (sp->predictor) /* no differencing */
   71|    107|    {
   72|    107|        case PREDICTOR_NONE:
  ------------------
  |  |  304|    107|#define PREDICTOR_NONE 1                   /* no prediction scheme used */
  ------------------
  |  Branch (72:9): [True: 107, False: 0]
  ------------------
   73|    107|            return 1;
   74|      0|        case PREDICTOR_HORIZONTAL:
  ------------------
  |  |  305|      0|#define PREDICTOR_HORIZONTAL 2             /* horizontal differencing */
  ------------------
  |  Branch (74:9): [True: 0, False: 107]
  ------------------
   75|      0|            if (td->td_bitspersample != 8 && td->td_bitspersample != 16 &&
  ------------------
  |  Branch (75:17): [True: 0, False: 0]
  |  Branch (75:46): [True: 0, False: 0]
  ------------------
   76|      0|                td->td_bitspersample != 32 && td->td_bitspersample != 64)
  ------------------
  |  Branch (76:17): [True: 0, False: 0]
  |  Branch (76:47): [True: 0, False: 0]
  ------------------
   77|      0|            {
   78|      0|                TIFFErrorExtR(tif, module,
   79|      0|                              "Horizontal differencing \"Predictor\" not "
   80|      0|                              "supported with %" PRIu16 "-bit samples",
   81|      0|                              td->td_bitspersample);
   82|      0|                return 0;
   83|      0|            }
   84|      0|            break;
   85|      0|        case PREDICTOR_FLOATINGPOINT:
  ------------------
  |  |  306|      0|#define PREDICTOR_FLOATINGPOINT 3          /* floating point predictor */
  ------------------
  |  Branch (85:9): [True: 0, False: 107]
  ------------------
   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: 107]
  ------------------
  107|      0|            TIFFErrorExtR(tif, module, "\"Predictor\" value %d not supported",
  108|      0|                          sp->predictor);
  109|      0|            return 0;
  110|    107|    }
  111|      0|    sp->stride =
  112|      0|        (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
  ------------------
  |  |  265|      0|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (112:10): [True: 0, False: 0]
  ------------------
  113|      0|                                                    : 1);
  114|       |    /*
  115|       |     * Calculate the scanline/tile-width size in bytes.
  116|       |     */
  117|      0|    if (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 (278:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  118|      0|        sp->rowsize = TIFFTileRowSize(tif);
  119|      0|    else
  120|      0|        sp->rowsize = TIFFScanlineSize(tif);
  121|      0|    if (sp->rowsize == 0)
  ------------------
  |  Branch (121:9): [True: 0, False: 0]
  ------------------
  122|      0|        return 0;
  123|       |
  124|      0|    return 1;
  125|      0|}

TIFFReadEncodedStrip:
  572|  6.58k|{
  573|  6.58k|    static const char module[] = "TIFFReadEncodedStrip";
  574|  6.58k|    TIFFDirectory *td = &tif->tif_dir;
  575|  6.58k|    tmsize_t stripsize;
  576|  6.58k|    uint16_t plane;
  577|       |
  578|  6.58k|    stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
  579|  6.58k|    if (stripsize == ((tmsize_t)(-1)))
  ------------------
  |  Branch (579:9): [True: 0, False: 6.58k]
  ------------------
  580|      0|        return ((tmsize_t)(-1));
  581|       |
  582|       |    /* shortcut to avoid an extra memcpy() */
  583|  6.58k|    if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
  ------------------
  |  |  182|  13.1k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (583:9): [True: 44, False: 6.53k]
  |  Branch (583:51): [True: 3, False: 41]
  ------------------
  584|      3|        size >= stripsize && !isMapped(tif) &&
  ------------------
  |  |  279|  6.58k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|      3|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (584:9): [True: 3, False: 0]
  |  Branch (584:30): [True: 3, False: 0]
  ------------------
  585|      3|        ((tif->tif_flags & TIFF_NOREADRAW) == 0))
  ------------------
  |  |  138|      3|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (585:9): [True: 3, False: 0]
  ------------------
  586|      3|    {
  587|      3|        if (TIFFReadRawStrip1(tif, strip, buf, stripsize, module) != stripsize)
  ------------------
  |  Branch (587:13): [True: 0, False: 3]
  ------------------
  588|      0|            return ((tmsize_t)(-1));
  589|       |
  590|      3|        if (!isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|      6|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (590:13): [True: 0, False: 3]
  ------------------
  591|      0|            (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (591:13): [True: 0, False: 0]
  ------------------
  592|      0|            TIFFReverseBits((uint8_t *)buf, stripsize);
  593|       |
  594|      3|        (*tif->tif_postdecode)(tif, (uint8_t *)buf, stripsize);
  595|      3|        return (stripsize);
  596|      3|    }
  597|       |
  598|  6.57k|    if ((size != (tmsize_t)(-1)) && (size < stripsize))
  ------------------
  |  Branch (598:9): [True: 363, False: 6.21k]
  |  Branch (598:37): [True: 0, False: 363]
  ------------------
  599|      0|        stripsize = size;
  600|  6.57k|    if (!TIFFFillStrip(tif, strip))
  ------------------
  |  Branch (600:9): [True: 5.66k, False: 916]
  ------------------
  601|  5.66k|    {
  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|  5.66k|        if (buf)
  ------------------
  |  Branch (604:13): [True: 5.66k, False: 0]
  ------------------
  605|  5.66k|            memset(buf, 0, (size_t)stripsize);
  606|  5.66k|        return ((tmsize_t)(-1));
  607|  5.66k|    }
  608|    916|    if ((*tif->tif_decodestrip)(tif, (uint8_t *)buf, stripsize, plane) <= 0)
  ------------------
  |  Branch (608:9): [True: 430, False: 486]
  ------------------
  609|    430|        return ((tmsize_t)(-1));
  610|    486|    (*tif->tif_postdecode)(tif, (uint8_t *)buf, stripsize);
  611|    486|    return (stripsize);
  612|    916|}
_TIFFReadEncodedStripAndAllocBuffer:
  624|    832|{
  625|    832|    tmsize_t this_stripsize;
  626|    832|    uint16_t plane;
  627|       |
  628|    832|    if (*buf != NULL)
  ------------------
  |  Branch (628:9): [True: 363, False: 469]
  ------------------
  629|    363|    {
  630|    363|        return TIFFReadEncodedStrip(tif, strip, *buf, size_to_read);
  631|    363|    }
  632|       |
  633|    469|    this_stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
  634|    469|    if (this_stripsize == ((tmsize_t)(-1)))
  ------------------
  |  Branch (634:9): [True: 0, False: 469]
  ------------------
  635|      0|        return ((tmsize_t)(-1));
  636|       |
  637|    469|    if ((size_to_read != (tmsize_t)(-1)) && (size_to_read < this_stripsize))
  ------------------
  |  Branch (637:9): [True: 469, False: 0]
  |  Branch (637:45): [True: 0, False: 469]
  ------------------
  638|      0|        this_stripsize = size_to_read;
  639|    469|    if (!TIFFFillStrip(tif, strip))
  ------------------
  |  Branch (639:9): [True: 341, False: 128]
  ------------------
  640|    341|        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|    128|    if (bufsizetoalloc > 100 * 1024 * 1024)
  ------------------
  |  Branch (647:9): [True: 25, False: 103]
  ------------------
  648|     25|    {
  649|     25|        const uint64_t maxCompressionRatio = TIFFGetMaxCompressionRatio(tif);
  650|     25|        if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (650:13): [True: 24, False: 1]
  ------------------
  651|     24|            (uint64_t)tif->tif_rawdatasize <
  ------------------
  |  Branch (651:13): [True: 0, False: 24]
  ------------------
  652|     24|                (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|     25|    }
  663|       |
  664|    128|    *buf = _TIFFcallocExt(tif, 1, bufsizetoalloc);
  665|    128|    if (*buf == NULL)
  ------------------
  |  Branch (665:9): [True: 0, False: 128]
  ------------------
  666|      0|    {
  667|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
  668|      0|        return ((tmsize_t)(-1));
  669|      0|    }
  670|       |
  671|    128|    if ((*tif->tif_decodestrip)(tif, (uint8_t *)*buf, this_stripsize, plane) <=
  ------------------
  |  Branch (671:9): [True: 90, False: 38]
  ------------------
  672|    128|        0)
  673|     90|        return ((tmsize_t)(-1));
  674|     38|    (*tif->tif_postdecode)(tif, (uint8_t *)*buf, this_stripsize);
  675|     38|    return (this_stripsize);
  676|    128|}
TIFFFillStrip:
  818|  7.04k|{
  819|  7.04k|    static const char module[] = "TIFFFillStrip";
  820|  7.04k|    TIFFDirectory *td = &tif->tif_dir;
  821|       |
  822|  7.04k|    if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
  ------------------
  |  |  138|  7.04k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (822:9): [True: 5.54k, False: 1.50k]
  ------------------
  823|  5.54k|    {
  824|  5.54k|        uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
  825|  5.54k|        if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
  ------------------
  |  |   49|  4.27k|#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
  ------------------
  |  Branch (825:13): [True: 1.26k, False: 4.27k]
  |  Branch (825:31): [True: 213, False: 4.06k]
  ------------------
  826|  1.47k|        {
  827|  1.47k|            TIFFErrorExtR(tif, module,
  828|  1.47k|                          "Invalid strip byte count %" PRIu64
  829|  1.47k|                          ", strip %" PRIu32,
  830|  1.47k|                          bytecount, strip);
  831|  1.47k|            return (0);
  832|  1.47k|        }
  833|       |
  834|       |        /* To avoid excessive memory allocations: */
  835|  4.06k|        const tmsize_t stripsize = TIFFStripSize(tif);
  836|  4.06k|        if (stripsize > 0)
  ------------------
  |  Branch (836:13): [True: 4.06k, False: 0]
  ------------------
  837|  4.06k|        {
  838|  4.06k|            if (bytecount > 1024 * 1024 &&
  ------------------
  |  Branch (838:17): [True: 394, False: 3.67k]
  ------------------
  839|    394|                (bytecount - 4096) / 10 > (uint64_t)stripsize)
  ------------------
  |  Branch (839:17): [True: 358, False: 36]
  ------------------
  840|    358|            {
  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|    358|                uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
  852|    358|                TIFFWarningExtR(tif, module,
  853|    358|                                "Too large strip byte count %" PRIu64
  854|    358|                                ", strip %" PRIu32 ". Limiting to %" PRIu64,
  855|    358|                                bytecount, strip, newbytecount);
  856|    358|                bytecount = newbytecount;
  857|    358|            }
  858|  3.70k|            else if (stripsize > 100 * 1024 * 1024)
  ------------------
  |  Branch (858:22): [True: 31, False: 3.67k]
  ------------------
  859|     31|            {
  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|     31|                const uint64_t maxCompressionRatio =
  866|     31|                    TIFFGetMaxCompressionRatio(tif);
  867|     31|                if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (867:21): [True: 30, False: 1]
  ------------------
  868|     30|                    bytecount < (uint64_t)stripsize / maxCompressionRatio)
  ------------------
  |  Branch (868:21): [True: 5, False: 25]
  ------------------
  869|      5|                {
  870|      5|                    TIFFErrorExtR(
  871|      5|                        tif, module,
  872|      5|                        "Likely invalid strip byte count for strip %u. "
  873|      5|                        "Uncompressed strip size is %" PRIu64 ", "
  874|      5|                        "compressed one is %" PRIu64,
  875|      5|                        strip, (uint64_t)stripsize, bytecount);
  876|      5|                    return 0;
  877|      5|                }
  878|     31|            }
  879|  4.06k|        }
  880|       |
  881|  4.06k|        if (isMapped(tif))
  ------------------
  |  |  279|  4.06k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  4.06k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 4.06k]
  |  |  ------------------
  ------------------
  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|  4.06k|        if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  279|  8.12k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  4.06k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 4.06k]
  |  |  ------------------
  ------------------
                      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|  4.06k|        else
  952|  4.06k|        {
  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|  4.06k|            tmsize_t bytecountm;
  959|  4.06k|            bytecountm = (tmsize_t)bytecount;
  960|  4.06k|            if ((uint64_t)bytecountm != bytecount)
  ------------------
  |  Branch (960:17): [True: 0, False: 4.06k]
  ------------------
  961|      0|            {
  962|      0|                TIFFErrorExtR(tif, module, "Integer overflow");
  963|      0|                return (0);
  964|      0|            }
  965|  4.06k|            if (bytecountm > tif->tif_rawdatasize)
  ------------------
  |  Branch (965:17): [True: 680, False: 3.38k]
  ------------------
  966|    680|            {
  967|    680|                tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|    680|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
  968|    680|                if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
  ------------------
  |  |  128|    680|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (968:21): [True: 0, False: 680]
  ------------------
  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|    680|            }
  976|  4.06k|            if (tif->tif_flags & TIFF_BUFFERMMAP)
  ------------------
  |  |  145|  4.06k|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  |  Branch (976:17): [True: 0, False: 4.06k]
  ------------------
  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|  4.06k|            if (isMapped(tif))
  ------------------
  |  |  279|  4.06k|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|  4.06k|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 4.06k]
  |  |  ------------------
  ------------------
  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|  4.06k|            else
  998|  4.06k|            {
  999|  4.06k|                if (TIFFReadRawStripOrTile2(tif, strip, 1, bytecountm,
  ------------------
  |  Branch (999:21): [True: 1.73k, False: 2.32k]
  ------------------
 1000|  4.06k|                                            module) != bytecountm)
 1001|  1.73k|                {
 1002|  1.73k|                    return (0);
 1003|  1.73k|                }
 1004|  4.06k|            }
 1005|       |
 1006|  2.32k|            tif->tif_rawdataoff = 0;
 1007|  2.32k|            tif->tif_rawdataloaded = bytecountm;
 1008|       |
 1009|  2.32k|            if (!isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|  4.64k|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (1009:17): [True: 0, False: 2.32k]
  ------------------
 1010|      0|                (tif->tif_flags & TIFF_NOBITREV) == 0)
  ------------------
  |  |  127|      0|#define TIFF_NOBITREV 0x00100U    /* inhibit bit reversal logic */
  ------------------
  |  Branch (1010:17): [True: 0, False: 0]
  ------------------
 1011|      0|                TIFFReverseBits(tif->tif_rawdata, bytecountm);
 1012|  2.32k|        }
 1013|  4.06k|    }
 1014|  3.82k|    return (TIFFStartStrip(tif, strip));
 1015|  7.04k|}
TIFFReadTile:
 1028|    857|{
 1029|    857|    if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
  ------------------
  |  Branch (1029:9): [True: 0, False: 857]
  |  Branch (1029:35): [True: 0, False: 857]
  ------------------
 1030|      0|        return ((tmsize_t)(-1));
 1031|    857|    return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf,
 1032|    857|                                (tmsize_t)(-1)));
 1033|    857|}
TIFFReadEncodedTile:
 1040|  14.8k|{
 1041|  14.8k|    static const char module[] = "TIFFReadEncodedTile";
 1042|  14.8k|    TIFFDirectory *td = &tif->tif_dir;
 1043|  14.8k|    tmsize_t tilesize = tif->tif_dir.td_tilesize;
 1044|       |
 1045|  14.8k|    if (!TIFFCheckRead(tif, 1))
  ------------------
  |  Branch (1045:9): [True: 0, False: 14.8k]
  ------------------
 1046|      0|        return ((tmsize_t)(-1));
 1047|  14.8k|    if (tile >= td->td_nstrips)
  ------------------
  |  Branch (1047:9): [True: 0, False: 14.8k]
  ------------------
 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|  14.8k|    if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
  ------------------
  |  |  182|  29.7k|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (1056:9): [True: 27, False: 14.8k]
  |  Branch (1056:51): [True: 0, False: 27]
  ------------------
 1057|      0|        size >= tilesize && !isMapped(tif) &&
  ------------------
  |  |  279|  14.8k|#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|  14.8k|    if (size == (tmsize_t)(-1))
  ------------------
  |  Branch (1071:9): [True: 14.8k, False: 0]
  ------------------
 1072|  14.8k|        size = tilesize;
 1073|      0|    else if (size > tilesize)
  ------------------
  |  Branch (1073:14): [True: 0, False: 0]
  ------------------
 1074|      0|        size = tilesize;
 1075|  14.8k|    if (!TIFFFillTile(tif, tile))
  ------------------
  |  Branch (1075:9): [True: 13.2k, False: 1.69k]
  ------------------
 1076|  13.2k|    {
 1077|       |        /* See TIFFReadEncodedStrip comment regarding TIFFTAG_FAXFILLFUNC. */
 1078|  13.2k|        if (buf)
  ------------------
  |  Branch (1078:13): [True: 13.2k, False: 0]
  ------------------
 1079|  13.2k|            memset(buf, 0, (size_t)size);
 1080|  13.2k|        return ((tmsize_t)(-1));
 1081|  13.2k|    }
 1082|  1.69k|    else if ((*tif->tif_decodetile)(tif, (uint8_t *)buf, size,
  ------------------
  |  Branch (1082:14): [True: 1.63k, False: 60]
  ------------------
 1083|  1.69k|                                    (uint16_t)(tile / td->td_stripsperimage)))
 1084|  1.63k|    {
 1085|  1.63k|        (*tif->tif_postdecode)(tif, (uint8_t *)buf, size);
 1086|  1.63k|        return (size);
 1087|  1.63k|    }
 1088|     60|    else
 1089|     60|        return ((tmsize_t)(-1));
 1090|  14.8k|}
_TIFFReadTileAndAllocBuffer:
 1101|     33|{
 1102|     33|    if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
  ------------------
  |  Branch (1102:9): [True: 0, False: 33]
  |  Branch (1102:35): [True: 0, False: 33]
  ------------------
 1103|      0|        return ((tmsize_t)(-1));
 1104|     33|    return (_TIFFReadEncodedTileAndAllocBuffer(
 1105|     33|        tif, TIFFComputeTile(tif, x, y, z, s), buf, bufsizetoalloc,
 1106|     33|        (tmsize_t)(-1)));
 1107|     33|}
_TIFFReadEncodedTileAndAllocBuffer:
 1118|     33|{
 1119|     33|    static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer";
 1120|     33|    TIFFDirectory *td = &tif->tif_dir;
 1121|     33|    tmsize_t tilesize = tif->tif_dir.td_tilesize;
 1122|       |
 1123|     33|    if (*buf != NULL)
  ------------------
  |  Branch (1123:9): [True: 0, False: 33]
  ------------------
 1124|      0|    {
 1125|      0|        return TIFFReadEncodedTile(tif, tile, *buf, size_to_read);
 1126|      0|    }
 1127|       |
 1128|     33|    if (!TIFFCheckRead(tif, 1))
  ------------------
  |  Branch (1128:9): [True: 0, False: 33]
  ------------------
 1129|      0|        return ((tmsize_t)(-1));
 1130|     33|    if (tile >= td->td_nstrips)
  ------------------
  |  Branch (1130:9): [True: 0, False: 33]
  ------------------
 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|     33|    if (!TIFFFillTile(tif, tile))
  ------------------
  |  Branch (1138:9): [True: 10, False: 23]
  ------------------
 1139|     10|        return ((tmsize_t)(-1));
 1140|       |
 1141|       |    /* Sanity checks to avoid excessive memory allocation */
 1142|       |    /* Cf https://gitlab.com/libtiff/libtiff/-/issues/479 */
 1143|     23|    if (td->td_compression == COMPRESSION_NONE)
  ------------------
  |  |  182|     23|#define COMPRESSION_NONE 1            /* dump mode */
  ------------------
  |  Branch (1143:9): [True: 5, False: 18]
  ------------------
 1144|      5|    {
 1145|      5|        if (tif->tif_rawdatasize != tilesize)
  ------------------
  |  Branch (1145:13): [True: 5, False: 0]
  ------------------
 1146|      5|        {
 1147|      5|            TIFFErrorExtR(tif, TIFFFileName(tif),
 1148|      5|                          "Invalid tile byte count for tile %u. "
 1149|      5|                          "Expected %" PRIu64 ", got %" PRIu64,
 1150|      5|                          tile, (uint64_t)tilesize,
 1151|      5|                          (uint64_t)tif->tif_rawdatasize);
 1152|      5|            return ((tmsize_t)(-1));
 1153|      5|        }
 1154|      5|    }
 1155|     18|    else
 1156|     18|    {
 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|     18|        if (bufsizetoalloc > 100 * 1024 * 1024)
  ------------------
  |  Branch (1161:13): [True: 0, False: 18]
  ------------------
 1162|      0|        {
 1163|      0|            const uint64_t maxCompressionRatio =
 1164|      0|                TIFFGetMaxCompressionRatio(tif);
 1165|      0|            if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (1165:17): [True: 0, False: 0]
  ------------------
 1166|      0|                (uint64_t)tif->tif_rawdatasize <
  ------------------
  |  Branch (1166:17): [True: 0, False: 0]
  ------------------
 1167|      0|                    (uint64_t)tilesize / maxCompressionRatio)
 1168|      0|            {
 1169|      0|                TIFFErrorExtR(tif, TIFFFileName(tif),
 1170|      0|                              "Likely invalid tile byte count for tile %u. "
 1171|      0|                              "Uncompressed tile size is %" PRIu64 ", "
 1172|      0|                              "compressed one is %" PRIu64,
 1173|      0|                              tile, (uint64_t)tilesize,
 1174|      0|                              (uint64_t)tif->tif_rawdatasize);
 1175|      0|                return ((tmsize_t)(-1));
 1176|      0|            }
 1177|      0|        }
 1178|     18|    }
 1179|       |
 1180|     18|    *buf = _TIFFmallocExt(tif, bufsizetoalloc);
 1181|     18|    if (*buf == NULL)
  ------------------
  |  Branch (1181:9): [True: 0, False: 18]
  ------------------
 1182|      0|    {
 1183|      0|        TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
 1184|      0|        return ((tmsize_t)(-1));
 1185|      0|    }
 1186|     18|    _TIFFmemset(*buf, 0, bufsizetoalloc);
 1187|       |
 1188|     18|    if (size_to_read == (tmsize_t)(-1))
  ------------------
  |  Branch (1188:9): [True: 18, False: 0]
  ------------------
 1189|     18|        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|     18|    if ((*tif->tif_decodetile)(tif, (uint8_t *)*buf, size_to_read,
  ------------------
  |  Branch (1192:9): [True: 18, False: 0]
  ------------------
 1193|     18|                               (uint16_t)(tile / td->td_stripsperimage)))
 1194|     18|    {
 1195|     18|        (*tif->tif_postdecode)(tif, (uint8_t *)*buf, size_to_read);
 1196|     18|        return (size_to_read);
 1197|     18|    }
 1198|      0|    else
 1199|      0|        return ((tmsize_t)(-1));
 1200|     18|}
TIFFFillTile:
 1300|  14.9k|{
 1301|  14.9k|    static const char module[] = "TIFFFillTile";
 1302|  14.9k|    TIFFDirectory *td = &tif->tif_dir;
 1303|       |
 1304|  14.9k|    if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
  ------------------
  |  |  138|  14.9k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1304:9): [True: 50, False: 14.8k]
  ------------------
 1305|     50|    {
 1306|     50|        uint64_t bytecount = TIFFGetStrileByteCount(tif, tile);
 1307|     50|        if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
  ------------------
  |  |   49|     14|#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
  ------------------
  |  Branch (1307:13): [True: 36, False: 14]
  |  Branch (1307:31): [True: 0, False: 14]
  ------------------
 1308|     36|        {
 1309|     36|            TIFFErrorExtR(tif, module,
 1310|     36|                          "%" PRIu64 ": Invalid tile byte count, tile %" PRIu32,
 1311|     36|                          bytecount, tile);
 1312|     36|            return (0);
 1313|     36|        }
 1314|       |
 1315|       |        /* To avoid excessive memory allocations: */
 1316|     14|        const tmsize_t tilesize = TIFFTileSize(tif);
 1317|     14|        if (tilesize > 0)
  ------------------
  |  Branch (1317:13): [True: 14, False: 0]
  ------------------
 1318|     14|        {
 1319|     14|            if (bytecount > 1024 * 1024 &&
  ------------------
  |  Branch (1319:17): [True: 2, False: 12]
  ------------------
 1320|      2|                (bytecount - 4096) / 10 > (uint64_t)tilesize)
  ------------------
  |  Branch (1320:17): [True: 2, False: 0]
  ------------------
 1321|      2|            {
 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|      2|                uint64_t newbytecount = (uint64_t)tilesize * 10 + 4096;
 1333|      2|                TIFFWarningExtR(tif, module,
 1334|      2|                                "Too large tile byte count %" PRIu64
 1335|      2|                                ", tile %" PRIu32 ". Limiting to %" PRIu64,
 1336|      2|                                bytecount, tile, newbytecount);
 1337|      2|                bytecount = newbytecount;
 1338|      2|            }
 1339|     12|            else if (tilesize > 100 * 1024 * 1024)
  ------------------
  |  Branch (1339:22): [True: 0, False: 12]
  ------------------
 1340|      0|            {
 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|      0|                const uint64_t maxCompressionRatio =
 1347|      0|                    TIFFGetMaxCompressionRatio(tif);
 1348|      0|                if (maxCompressionRatio > 0 &&
  ------------------
  |  Branch (1348:21): [True: 0, False: 0]
  ------------------
 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|      0|            }
 1359|     14|        }
 1360|       |
 1361|     14|        if (isMapped(tif))
  ------------------
  |  |  279|     14|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|     14|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 14]
  |  |  ------------------
  ------------------
 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|     14|        if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
  ------------------
  |  |  279|     28|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|     14|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 14]
  |  |  ------------------
  ------------------
                      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|     14|        else
 1411|     14|        {
 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|     14|            tmsize_t bytecountm;
 1418|     14|            bytecountm = (tmsize_t)bytecount;
 1419|     14|            if ((uint64_t)bytecountm != bytecount)
  ------------------
  |  Branch (1419:17): [True: 0, False: 14]
  ------------------
 1420|      0|            {
 1421|      0|                TIFFErrorExtR(tif, module, "Integer overflow");
 1422|      0|                return (0);
 1423|      0|            }
 1424|     14|            if (bytecountm > tif->tif_rawdatasize)
  ------------------
  |  Branch (1424:17): [True: 1, False: 13]
  ------------------
 1425|      1|            {
 1426|      1|                tif->tif_dir.td_curtile = NOTILE;
  ------------------
  |  |  116|      1|#define NOTILE ((uint32_t)(-1)) /* undefined state */
  ------------------
 1427|      1|                if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
  ------------------
  |  |  128|      1|#define TIFF_MYBUFFER 0x00200U    /* my raw data buffer; free on close */
  ------------------
  |  Branch (1427:21): [True: 0, False: 1]
  ------------------
 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|            }
 1435|     14|            if (tif->tif_flags & TIFF_BUFFERMMAP)
  ------------------
  |  |  145|     14|    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
  ------------------
  |  Branch (1435:17): [True: 0, False: 14]
  ------------------
 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|     14|            if (isMapped(tif))
  ------------------
  |  |  279|     14|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|     14|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  |  |  |  Branch (279:23): [True: 0, False: 14]
  |  |  ------------------
  ------------------
 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|     14|            else
 1457|     14|            {
 1458|     14|                if (TIFFReadRawStripOrTile2(tif, tile, 0, bytecountm, module) !=
  ------------------
  |  Branch (1458:21): [True: 2, False: 12]
  ------------------
 1459|     14|                    bytecountm)
 1460|      2|                {
 1461|      2|                    return (0);
 1462|      2|                }
 1463|     14|            }
 1464|       |
 1465|     12|            tif->tif_rawdataoff = 0;
 1466|     12|            tif->tif_rawdataloaded = bytecountm;
 1467|       |
 1468|     12|            if (tif->tif_rawdata != NULL &&
  ------------------
  |  Branch (1468:17): [True: 12, False: 0]
  ------------------
 1469|     12|                !isFillOrder(tif, td->td_fillorder) &&
  ------------------
  |  |  280|     24|#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
  ------------------
  |  Branch (1469:17): [True: 0, False: 12]
  ------------------
 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|     12|        }
 1473|     14|    }
 1474|  14.8k|    return (TIFFStartTile(tif, tile));
 1475|  14.9k|}
_TIFFNoPostDecode:
 1799|    458|{
 1800|    458|    (void)tif;
 1801|    458|    (void)buf;
 1802|    458|    (void)cc;
 1803|    458|}
tif_read.c:TIFFReadAndRealloc:
   56|  2.37k|{
   57|  2.37k|#if SIZEOF_SIZE_T == 8
   58|  2.37k|    tmsize_t threshold = INITIAL_THRESHOLD;
  ------------------
  |  |   43|  2.37k|#define INITIAL_THRESHOLD (1024 * 1024)
  ------------------
   59|  2.37k|#endif
   60|  2.37k|    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|  4.70k|    while (already_read < size)
  ------------------
  |  Branch (83:12): [True: 2.37k, False: 2.33k]
  ------------------
   84|  2.37k|    {
   85|  2.37k|        tmsize_t bytes_read;
   86|  2.37k|        tmsize_t to_read = size - already_read;
   87|  2.37k|#if SIZEOF_SIZE_T == 8
   88|  2.37k|        if (to_read >= threshold && threshold < MAX_THRESHOLD &&
  ------------------
  |  |   46|  2.37k|    (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      7|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      7|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |                   (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER *      \
  |  |  ------------------
  |  |  |  |   44|      7|#define THRESHOLD_MULTIPLIER 10
  |  |  ------------------
  |  |   47|  2.37k|     INITIAL_THRESHOLD)
  |  |  ------------------
  |  |  |  |   43|      7|#define INITIAL_THRESHOLD (1024 * 1024)
  |  |  ------------------
  ------------------
  |  Branch (88:13): [True: 7, False: 2.36k]
  |  Branch (88:37): [True: 7, False: 0]
  ------------------
   89|      7|            already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
  ------------------
  |  Branch (89:13): [True: 7, False: 0]
  ------------------
   90|      7|        {
   91|      7|            to_read = threshold;
   92|      7|            threshold *= THRESHOLD_MULTIPLIER;
  ------------------
  |  |   44|      7|#define THRESHOLD_MULTIPLIER 10
  ------------------
   93|      7|        }
   94|  2.37k|#endif
   95|  2.37k|        if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
  ------------------
  |  Branch (95:13): [True: 348, False: 2.02k]
  ------------------
   96|    348|        {
   97|    348|            uint8_t *new_rawdata;
   98|    348|            assert((tif->tif_flags & TIFF_MYBUFFER) != 0);
  ------------------
  |  Branch (98:13): [True: 0, False: 348]
  |  Branch (98:13): [True: 348, False: 0]
  ------------------
   99|    348|            tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64(
  ------------------
  |  |  327|    348|#define TIFFroundup_64(x, y) ((uint64_t)(TIFFhowmany_64(x, y) * (uint64_t)(y)))
  |  |  ------------------
  |  |  |  |  324|    348|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  |  |  ------------------
  ------------------
  100|    348|                (uint64_t)already_read + (uint64_t)to_read +
  101|    348|                    (uint64_t)rawdata_offset,
  102|    348|                1024);
  103|    348|            if (tif->tif_rawdatasize == 0)
  ------------------
  |  Branch (103:17): [True: 0, False: 348]
  ------------------
  104|      0|            {
  105|      0|                TIFFErrorExtR(tif, module, "Invalid buffer size");
  106|      0|                return 0;
  107|      0|            }
  108|    348|            new_rawdata = (uint8_t *)_TIFFreallocExt(tif, tif->tif_rawdata,
  109|    348|                                                     tif->tif_rawdatasize);
  110|    348|            if (new_rawdata == 0)
  ------------------
  |  Branch (110:17): [True: 0, False: 348]
  ------------------
  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|    348|            tif->tif_rawdata = new_rawdata;
  121|    348|        }
  122|  2.37k|        if (tif->tif_rawdata == NULL)
  ------------------
  |  Branch (122:13): [True: 0, False: 2.37k]
  ------------------
  123|      0|        {
  124|       |            /* should not happen in practice but helps CoverityScan */
  125|      0|            return 0;
  126|      0|        }
  127|       |
  128|  2.37k|        bytes_read = TIFFReadFile(
  ------------------
  |  |  283|  2.37k|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  129|  2.37k|            tif, tif->tif_rawdata + rawdata_offset + already_read, to_read);
  130|  2.37k|        if (bytes_read < 0)
  ------------------
  |  Branch (130:13): [True: 0, False: 2.37k]
  ------------------
  131|       |            /* Treat read errors as short reads before updating offsets. */
  132|      0|            bytes_read = 0;
  133|  2.37k|        already_read += bytes_read;
  134|  2.37k|        if (bytes_read != to_read)
  ------------------
  |  Branch (134:13): [True: 38, False: 2.33k]
  ------------------
  135|     38|        {
  136|     38|            memset(
  137|     38|                tif->tif_rawdata + rawdata_offset + already_read, 0,
  138|     38|                (size_t)(tif->tif_rawdatasize - rawdata_offset - already_read));
  139|     38|            if (is_strip)
  ------------------
  |  Branch (139:17): [True: 38, False: 0]
  ------------------
  140|     38|            {
  141|     38|                TIFFErrorExtR(tif, module,
  142|     38|                              "Read error at scanline %" PRIu32
  143|     38|                              "; got %" TIFF_SSIZE_FORMAT " bytes, "
  144|     38|                              "expected %" TIFF_SSIZE_FORMAT,
  ------------------
  |  |  142|     38|#  define TIFF_SSIZE_FORMAT PRId64
  ------------------
  145|     38|                              tif->tif_dir.td_row, already_read, size);
  146|     38|            }
  147|      0|            else
  148|      0|            {
  149|      0|                TIFFErrorExtR(tif, module,
  150|      0|                              "Read error at row %" PRIu32 ", col %" PRIu32
  151|      0|                              ", tile %" PRIu32 "; "
  152|      0|                              "got %" TIFF_SSIZE_FORMAT
  153|      0|                              " bytes, expected %" TIFF_SSIZE_FORMAT "",
  154|      0|                              tif->tif_dir.td_row, tif->tif_dir.td_col,
  155|      0|                              strip_or_tile, already_read, size);
  156|      0|            }
  157|     38|            return 0;
  158|     38|        }
  159|  2.37k|    }
  160|  2.33k|    return 1;
  161|  2.37k|}
tif_read.c:TIFFReadEncodedStripGetStripSize:
  526|  7.05k|{
  527|  7.05k|    static const char module[] = "TIFFReadEncodedStrip";
  528|  7.05k|    TIFFDirectory *td = &tif->tif_dir;
  529|  7.05k|    uint32_t rowsperstrip;
  530|  7.05k|    uint32_t stripsperplane;
  531|  7.05k|    uint32_t stripinplane;
  532|  7.05k|    uint32_t rows;
  533|  7.05k|    tmsize_t stripsize;
  534|  7.05k|    if (!TIFFCheckRead(tif, 0))
  ------------------
  |  Branch (534:9): [True: 0, False: 7.05k]
  ------------------
  535|      0|        return ((tmsize_t)(-1));
  536|  7.05k|    if (strip >= td->td_nstrips)
  ------------------
  |  Branch (536:9): [True: 0, False: 7.05k]
  ------------------
  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|  7.05k|    rowsperstrip = td->td_rowsperstrip;
  545|  7.05k|    if (rowsperstrip > td->td_imagelength)
  ------------------
  |  Branch (545:9): [True: 474, False: 6.57k]
  ------------------
  546|    474|        rowsperstrip = td->td_imagelength;
  547|  7.05k|    if (rowsperstrip == 0)
  ------------------
  |  Branch (547:9): [True: 0, False: 7.05k]
  ------------------
  548|      0|    {
  549|      0|        TIFFErrorExtR(tif, module, "rowsperstrip is zero");
  550|      0|        return ((tmsize_t)(-1));
  551|      0|    }
  552|  7.05k|    stripsperplane =
  553|  7.05k|        TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
  ------------------
  |  |  318|  7.05k|    (((uint32_t)(x) / (uint32_t)(y)) +                                         \
  |  |  319|  7.05k|     ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
  |  |  ------------------
  |  |  |  Branch (319:7): [True: 2.87k, False: 4.17k]
  |  |  ------------------
  ------------------
  554|  7.05k|    stripinplane = (strip % stripsperplane);
  555|  7.05k|    if (pplane)
  ------------------
  |  Branch (555:9): [True: 7.05k, False: 0]
  ------------------
  556|  7.05k|        *pplane = (uint16_t)(strip / stripsperplane);
  557|  7.05k|    rows = td->td_imagelength - stripinplane * rowsperstrip;
  558|  7.05k|    if (rows > rowsperstrip)
  ------------------
  |  Branch (558:9): [True: 6.31k, False: 740]
  ------------------
  559|  6.31k|        rows = rowsperstrip;
  560|  7.05k|    stripsize = TIFFVStripSize(tif, rows);
  561|  7.05k|    if (stripsize == 0)
  ------------------
  |  Branch (561:9): [True: 0, False: 7.05k]
  ------------------
  562|      0|        return ((tmsize_t)(-1));
  563|  7.05k|    return stripsize;
  564|  7.05k|}
tif_read.c:TIFFReadRawStrip1:
  680|      3|{
  681|      3|    assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
  ------------------
  |  Branch (681:5): [True: 0, False: 3]
  |  Branch (681:5): [True: 3, False: 0]
  ------------------
  682|      3|    if (!isMapped(tif))
  ------------------
  |  |  279|      3|#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
  |  |  ------------------
  |  |  |  |  130|      3|#define TIFF_MAPPED 0x00800U      /* file is mapped into memory */
  |  |  ------------------
  ------------------
  |  Branch (682:9): [True: 3, False: 0]
  ------------------
  683|      3|    {
  684|      3|        tmsize_t cc;
  685|       |
  686|      3|        if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip)))
  ------------------
  |  |  303|      3|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (686:13): [True: 0, False: 3]
  ------------------
  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|      3|        cc = TIFFReadFile(tif, buf, size);
  ------------------
  |  |  283|      3|    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
  ------------------
  694|      3|        if (cc != size)
  ------------------
  |  Branch (694:13): [True: 0, False: 3]
  ------------------
  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|      3|    }
  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|      3|    return (size);
  737|      3|}
tif_read.c:TIFFReadRawStripOrTile2:
  742|  4.07k|{
  743|  4.07k|    assert(!isMapped(tif));
  ------------------
  |  Branch (743:5): [True: 0, False: 4.07k]
  |  Branch (743:5): [True: 4.07k, False: 0]
  ------------------
  744|  4.07k|    assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
  ------------------
  |  Branch (744:5): [True: 0, False: 4.07k]
  |  Branch (744:5): [True: 4.07k, False: 0]
  ------------------
  745|       |
  746|  4.07k|    if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile)))
  ------------------
  |  |  303|  4.07k|#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
  ------------------
  |  Branch (746:9): [True: 1.70k, False: 2.37k]
  ------------------
  747|  1.70k|    {
  748|  1.70k|        if (is_strip)
  ------------------
  |  Branch (748:13): [True: 1.70k, False: 2]
  ------------------
  749|  1.70k|        {
  750|  1.70k|            TIFFErrorExtR(tif, module,
  751|  1.70k|                          "Seek error at scanline %" PRIu32 ", strip %" PRIu32,
  752|  1.70k|                          tif->tif_dir.td_row, strip_or_tile);
  753|  1.70k|        }
  754|      2|        else
  755|      2|        {
  756|      2|            TIFFErrorExtR(
  757|      2|                tif, module,
  758|      2|                "Seek error at row %" PRIu32 ", col %" PRIu32 ", tile %" PRIu32,
  759|      2|                tif->tif_dir.td_row, tif->tif_dir.td_col, strip_or_tile);
  760|      2|        }
  761|  1.70k|        return ((tmsize_t)(-1));
  762|  1.70k|    }
  763|       |
  764|  2.37k|    if (!TIFFReadAndRealloc(tif, size, 0, is_strip, strip_or_tile, module))
  ------------------
  |  Branch (764:9): [True: 38, False: 2.33k]
  ------------------
  765|     38|    {
  766|     38|        return ((tmsize_t)(-1));
  767|     38|    }
  768|       |
  769|  2.33k|    return (size);
  770|  2.37k|}
tif_read.c:TIFFStartStrip:
 1542|  3.82k|{
 1543|  3.82k|    TIFFDirectory *td = &tif->tif_dir;
 1544|       |
 1545|  3.82k|    if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
  ------------------
  |  |  124|  3.82k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  |  Branch (1545:9): [True: 418, False: 3.40k]
  ------------------
 1546|    418|    {
 1547|    418|        if (!(*tif->tif_setupdecode)(tif))
  ------------------
  |  Branch (1547:13): [True: 3, False: 415]
  ------------------
 1548|      3|            return (0);
 1549|    415|        tif->tif_flags |= TIFF_CODERSETUP;
  ------------------
  |  |  124|    415|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
 1550|    415|    }
 1551|  3.82k|    if (td->td_stripsperimage == 0)
  ------------------
  |  Branch (1551:9): [True: 0, False: 3.82k]
  ------------------
 1552|      0|    {
 1553|      0|        TIFFErrorExtR(tif, "TIFFStartStrip", "Zero strips per image");
 1554|      0|        return 0;
 1555|      0|    }
 1556|  3.82k|    tif->tif_dir.td_curstrip = strip;
 1557|  3.82k|    tif->tif_dir.td_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
 1558|  3.82k|    tif->tif_flags &= ~TIFF_BUF4WRITE;
  ------------------
  |  |  141|  3.82k|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 1559|       |
 1560|  3.82k|    if (tif->tif_flags & TIFF_NOREADRAW)
  ------------------
  |  |  138|  3.82k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1560:9): [True: 1.50k, False: 2.31k]
  ------------------
 1561|  1.50k|    {
 1562|  1.50k|        tif->tif_rawcp = NULL;
 1563|  1.50k|        tif->tif_rawcc = 0;
 1564|  1.50k|    }
 1565|  2.31k|    else
 1566|  2.31k|    {
 1567|  2.31k|        tif->tif_rawcp = tif->tif_rawdata;
 1568|  2.31k|        if (tif->tif_rawdataloaded > 0)
  ------------------
  |  Branch (1568:13): [True: 2.31k, False: 0]
  ------------------
 1569|  2.31k|            tif->tif_rawcc = tif->tif_rawdataloaded;
 1570|      0|        else
 1571|      0|            tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip);
 1572|  2.31k|    }
 1573|  3.82k|    if ((*tif->tif_predecode)(tif, (uint16_t)(strip / td->td_stripsperimage)) ==
  ------------------
  |  Branch (1573:9): [True: 2.77k, False: 1.04k]
  ------------------
 1574|  3.82k|        0)
 1575|  2.77k|    {
 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|  2.77k|        tif->tif_dir.td_curstrip = NOSTRIP;
  ------------------
  |  |  111|  2.77k|#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
  ------------------
 1582|  2.77k|        return 0;
 1583|  2.77k|    }
 1584|  1.04k|    return 1;
 1585|  3.82k|}
tif_read.c:TIFFStartTile:
 1592|  14.8k|{
 1593|  14.8k|    static const char module[] = "TIFFStartTile";
 1594|  14.8k|    TIFFDirectory *td = &tif->tif_dir;
 1595|  14.8k|    uint32_t howmany32;
 1596|  14.8k|    uint32_t tilemod;
 1597|       |
 1598|  14.8k|    if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
  ------------------
  |  |  124|  14.8k|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
  |  Branch (1598:9): [True: 64, False: 14.8k]
  ------------------
 1599|     64|    {
 1600|     64|        if (!(*tif->tif_setupdecode)(tif))
  ------------------
  |  Branch (1600:13): [True: 0, False: 64]
  ------------------
 1601|      0|            return (0);
 1602|     64|        tif->tif_flags |= TIFF_CODERSETUP;
  ------------------
  |  |  124|     64|#define TIFF_CODERSETUP 0x00020U  /* encoder/decoder setup done */
  ------------------
 1603|     64|    }
 1604|  14.8k|    tif->tif_dir.td_curtile = tile;
 1605|  14.8k|    if (td->td_tilewidth == 0)
  ------------------
  |  Branch (1605:9): [True: 0, False: 14.8k]
  ------------------
 1606|      0|    {
 1607|      0|        TIFFErrorExtR(tif, module, "Zero tilewidth");
 1608|      0|        return 0;
 1609|      0|    }
 1610|  14.8k|    howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
  ------------------
  |  |  312|  14.8k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 14.8k, False: 0]
  |  |  ------------------
  |  |  313|  14.8k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  14.8k|         : 0U)
  ------------------
 1611|  14.8k|    if (howmany32 == 0)
  ------------------
  |  Branch (1611:9): [True: 0, False: 14.8k]
  ------------------
 1612|      0|    {
 1613|      0|        TIFFErrorExtR(tif, module, "Zero tiles");
 1614|      0|        return 0;
 1615|      0|    }
 1616|  14.8k|    tilemod = tile % howmany32;
 1617|  14.8k|    if (td->td_tilelength == 0)
  ------------------
  |  Branch (1617:9): [True: 0, False: 14.8k]
  ------------------
 1618|      0|    {
 1619|      0|        TIFFErrorExtR(tif, module, "Zero tilelength");
 1620|      0|        return 0;
 1621|      0|    }
 1622|  14.8k|    if (tilemod == 0)
  ------------------
  |  Branch (1622:9): [True: 1.65k, False: 13.2k]
  ------------------
 1623|  1.65k|    {
 1624|  1.65k|        tif->tif_dir.td_row = 0;
 1625|  1.65k|    }
 1626|  13.2k|    else
 1627|  13.2k|    {
 1628|  13.2k|        tif->tif_dir.td_row =
 1629|  13.2k|            _TIFFMultiply32(tif, tilemod, td->td_tilelength, module);
 1630|  13.2k|        if (tif->tif_dir.td_row == 0)
  ------------------
  |  Branch (1630:13): [True: 0, False: 13.2k]
  ------------------
 1631|      0|            return 0;
 1632|  13.2k|    }
 1633|  14.8k|    howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
  ------------------
  |  |  312|  14.8k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 14.8k, False: 0]
  |  |  ------------------
  |  |  313|  14.8k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  14.8k|         : 0U)
  ------------------
 1634|  14.8k|    if (howmany32 == 0)
  ------------------
  |  Branch (1634:9): [True: 0, False: 14.8k]
  ------------------
 1635|      0|    {
 1636|      0|        TIFFErrorExtR(tif, module, "Zero tiles");
 1637|      0|        return 0;
 1638|      0|    }
 1639|  14.8k|    tilemod = tile % howmany32;
 1640|  14.8k|    if (tilemod == 0)
  ------------------
  |  Branch (1640:9): [True: 14.8k, False: 39]
  ------------------
 1641|  14.8k|    {
 1642|  14.8k|        tif->tif_dir.td_col = 0;
 1643|  14.8k|    }
 1644|     39|    else
 1645|     39|    {
 1646|     39|        tif->tif_dir.td_col =
 1647|     39|            _TIFFMultiply32(tif, tilemod, td->td_tilewidth, module);
 1648|     39|        if (tif->tif_dir.td_col == 0)
  ------------------
  |  Branch (1648:13): [True: 0, False: 39]
  ------------------
 1649|      0|            return 0;
 1650|     39|    }
 1651|  14.8k|    tif->tif_flags &= ~TIFF_BUF4WRITE;
  ------------------
  |  |  141|  14.8k|#define TIFF_BUF4WRITE 0x100000U  /* rawcc bytes are for writing */
  ------------------
 1652|  14.8k|    if (tif->tif_flags & TIFF_NOREADRAW)
  ------------------
  |  |  138|  14.8k|    0x20000U /* skip reading of raw uncompressed image data */
  ------------------
  |  Branch (1652:9): [True: 14.8k, False: 12]
  ------------------
 1653|  14.8k|    {
 1654|  14.8k|        tif->tif_rawcp = NULL;
 1655|  14.8k|        tif->tif_rawcc = 0;
 1656|  14.8k|    }
 1657|     12|    else
 1658|     12|    {
 1659|     12|        tif->tif_rawcp = tif->tif_rawdata;
 1660|     12|        if (tif->tif_rawdataloaded > 0)
  ------------------
  |  Branch (1660:13): [True: 12, False: 0]
  ------------------
 1661|     12|            tif->tif_rawcc = tif->tif_rawdataloaded;
 1662|      0|        else
 1663|      0|            tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile);
 1664|     12|    }
 1665|  14.8k|    return (
 1666|  14.8k|        (*tif->tif_predecode)(tif, (uint16_t)(tile / td->td_stripsperimage)));
 1667|  14.8k|}
tif_read.c:TIFFCheckRead:
 1670|  22.8k|{
 1671|  22.8k|    if (tif->tif_mode == O_WRONLY)
  ------------------
  |  Branch (1671:9): [True: 0, False: 22.8k]
  ------------------
 1672|      0|    {
 1673|      0|        TIFFErrorExtR(tif, tif->tif_name, "File not open for reading");
 1674|      0|        return (0);
 1675|      0|    }
 1676|  22.8k|    if (tiles ^ isTiled(tif))
  ------------------
  |  |  278|  22.8k|#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
  |  |  ------------------
  |  |  |  |  129|  22.8k|#define TIFF_ISTILED 0x00400U     /* file is tile, not strip- based */
  |  |  ------------------
  ------------------
  |  Branch (1676:9): [True: 0, False: 22.8k]
  ------------------
 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|  22.8k|    return (1);
 1684|  22.8k|}

_Z14TIFFStreamOpenPKcPNSt3__113basic_istreamIcNS1_11char_traitsIcEEEE:
  456|    402|{
  457|       |    // NB: We don't support mapped files with streams so add 'm'
  458|    402|    return _tiffStreamOpen(name, "rm", is);
  459|    402|}
tif_stream.cxx:_ZL15_tiffStreamOpenPKcS0_Pv:
  399|    402|    {
  400|    402|        TIFF *tif;
  401|       |
  402|    402|        if (strchr(mode, 'w'))
  ------------------
  |  Branch (402:13): [True: 0, False: 402]
  ------------------
  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|    402|        else
  419|    402|        {
  420|    402|            tiffis_data *data = new tiffis_data;
  421|    402|            data->stream = reinterpret_cast<istream *>(fd);
  422|    402|            data->start_pos = data->stream->tellg();
  423|       |            // Open for reading.
  424|    402|            tif = TIFFClientOpen(
  425|    402|                name, mode, reinterpret_cast<thandle_t>(data), _tiffisReadProc,
  426|    402|                _tiffisWriteProc, _tiffisSeekProc, _tiffisCloseProc,
  427|    402|                _tiffisSizeProc, _tiffDummyMapProcCxx, _tiffDummyUnmapProcCxx);
  428|    402|            if (!tif)
  ------------------
  |  Branch (428:17): [True: 35, False: 367]
  ------------------
  429|     35|            {
  430|     35|                delete data;
  431|     35|            }
  432|    402|        }
  433|       |
  434|    402|        return (tif);
  435|    402|    }
tif_stream.cxx:_ZL15_tiffisReadProcPvS_l:
  109|  35.1k|    {
  110|  35.1k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  111|       |
  112|       |        // Verify that type does not overflow.
  113|  35.1k|        streamsize request_size = size;
  114|  35.1k|        if (static_cast<tmsize_t>(request_size) != size)
  ------------------
  |  Branch (114:13): [True: 0, False: 35.1k]
  ------------------
  115|      0|            return static_cast<tmsize_t>(-1);
  116|       |
  117|  35.1k|        data->stream->read((char *)buf, request_size);
  118|       |
  119|  35.1k|        return static_cast<tmsize_t>(data->stream->gcount());
  120|  35.1k|    }
tif_stream.cxx:_ZL15_tiffisSeekProcPvmi:
  242|  14.0k|    {
  243|  14.0k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  244|       |
  245|  14.0k|        if (data->start_pos == ios::pos_type(-1))
  ------------------
  |  Branch (245:13): [True: 0, False: 14.0k]
  ------------------
  246|      0|            return static_cast<uint64_t>(-1);
  247|       |
  248|  14.0k|        switch (whence)
  ------------------
  |  Branch (248:17): [True: 14.0k, False: 0]
  ------------------
  249|  14.0k|        {
  250|  14.0k|            case SEEK_SET:
  ------------------
  |  Branch (250:13): [True: 14.0k, False: 0]
  ------------------
  251|  14.0k|            {
  252|       |                // Compute 64-bit offset
  253|  14.0k|                uint64_t new_offset =
  254|  14.0k|                    static_cast<uint64_t>(data->start_pos) + off;
  255|       |
  256|       |                // Verify that value does not overflow
  257|  14.0k|                ios::off_type offset = static_cast<ios::off_type>(new_offset);
  258|  14.0k|                if (static_cast<uint64_t>(offset) != new_offset)
  ------------------
  |  Branch (258:21): [True: 0, False: 14.0k]
  ------------------
  259|      0|                    return static_cast<uint64_t>(-1);
  260|       |
  261|  14.0k|                data->stream->seekg(offset, ios::beg);
  262|  14.0k|                break;
  263|  14.0k|            }
  264|      0|            case SEEK_CUR:
  ------------------
  |  Branch (264:13): [True: 0, False: 14.0k]
  ------------------
  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: 14.0k]
  ------------------
  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|  14.0k|        }
  285|       |
  286|  14.0k|        ios::pos_type pos = data->stream->tellg();
  287|  14.0k|        if (pos == ios::pos_type(-1))
  ------------------
  |  Branch (287:13): [True: 2.16k, False: 11.8k]
  ------------------
  288|  2.16k|            return static_cast<uint64_t>(-1);
  289|       |
  290|  11.8k|        ios::off_type relative_pos = pos - data->start_pos;
  291|  11.8k|        if (relative_pos < 0)
  ------------------
  |  Branch (291:13): [True: 0, False: 11.8k]
  ------------------
  292|      0|            return static_cast<uint64_t>(-1);
  293|       |
  294|  11.8k|        return static_cast<uint64_t>(relative_pos);
  295|  11.8k|    }
tif_stream.cxx:_ZL16_tiffisCloseProcPv:
  376|    367|    {
  377|       |        // Our stream was not allocated by us, so it shouldn't be closed by us.
  378|    367|        delete reinterpret_cast<tiffis_data *>(fd);
  379|    367|        return 0;
  380|    367|    }
tif_stream.cxx:_ZL15_tiffisSizeProcPv:
  334|  1.01k|    {
  335|  1.01k|        tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
  336|  1.01k|        ios::pos_type pos = data->stream->tellg();
  337|  1.01k|        ios::pos_type len;
  338|       |
  339|       |        // Failed stream positions must not be converted to unsigned sizes.
  340|  1.01k|        if (pos == ios::pos_type(-1))
  ------------------
  |  Branch (340:13): [True: 56, False: 958]
  ------------------
  341|     56|            return 0;
  342|       |
  343|    958|        data->stream->seekg(0, ios::end);
  344|    958|        if (data->stream->fail())
  ------------------
  |  Branch (344:13): [True: 0, False: 958]
  ------------------
  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|    958|        len = data->stream->tellg();
  354|    958|        if (len == ios::pos_type(-1))
  ------------------
  |  Branch (354:13): [True: 0, False: 958]
  ------------------
  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|    958|        data->stream->seekg(pos);
  364|       |
  365|    958|        return static_cast<uint64_t>(len);
  366|    958|    }

TIFFComputeStrip:
   36|    835|{
   37|    835|    static const char module[] = "TIFFComputeStrip";
   38|    835|    TIFFDirectory *td = &tif->tif_dir;
   39|    835|    uint32_t strip;
   40|       |
   41|    835|    if (td->td_rowsperstrip == 0)
  ------------------
  |  Branch (41:9): [True: 0, False: 835]
  ------------------
   42|      0|    {
   43|      0|        TIFFErrorExtR(tif, module,
   44|      0|                      "Cannot compute strip: RowsPerStrip is zero");
   45|      0|        return 0;
   46|      0|    }
   47|    835|    strip = row / td->td_rowsperstrip;
   48|    835|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    835|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (48:9): [True: 4, False: 831]
  ------------------
   49|      4|    {
   50|      4|        uint64_t sample_offset;
   51|      4|        uint64_t strip64;
   52|      4|        if (sample >= td->td_samplesperpixel)
  ------------------
  |  Branch (52:13): [True: 0, False: 4]
  ------------------
   53|      0|        {
   54|      0|            TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu",
   55|      0|                          (unsigned long)sample,
   56|      0|                          (unsigned long)td->td_samplesperpixel);
   57|      0|            return (0);
   58|      0|        }
   59|      4|        sample_offset = _TIFFMultiply64(tif, sample, td->td_stripsperimage,
   60|      4|                                        "TIFFComputeStrip");
   61|      4|        if (sample_offset == 0 && sample != 0 && td->td_stripsperimage != 0)
  ------------------
  |  Branch (61:13): [True: 1, False: 3]
  |  Branch (61:35): [True: 0, False: 1]
  |  Branch (61:50): [True: 0, False: 0]
  ------------------
   62|      0|            return (0);
   63|      4|        strip64 = _TIFFAdd64(tif, sample_offset, strip, "TIFFComputeStrip");
   64|      4|        if (strip64 == 0 && (sample_offset != 0 || strip != 0))
  ------------------
  |  Branch (64:13): [True: 1, False: 3]
  |  Branch (64:30): [True: 0, False: 1]
  |  Branch (64:52): [True: 0, False: 1]
  ------------------
   65|      0|            return (0);
   66|      4|        strip = _TIFFCastUInt64ToUInt32(tif, strip64, "TIFFComputeStrip");
   67|      4|        if (strip == 0 && strip64 != 0)
  ------------------
  |  Branch (67:13): [True: 1, False: 3]
  |  Branch (67:27): [True: 0, False: 1]
  ------------------
   68|      0|            return (0);
   69|      4|    }
   70|    835|    return (strip);
   71|    835|}
TIFFNumberOfStrips:
   77|    866|{
   78|    866|    TIFFDirectory *td = &tif->tif_dir;
   79|    866|    uint32_t nstrips;
   80|       |
   81|    866|    if (td->td_rowsperstrip == 0)
  ------------------
  |  Branch (81:9): [True: 0, False: 866]
  ------------------
   82|      0|    {
   83|      0|        TIFFWarningExtR(tif, "TIFFNumberOfStrips", "RowsPerStrip is zero");
   84|      0|        return 0;
   85|      0|    }
   86|    866|    nstrips = (td->td_rowsperstrip == (uint32_t)-1
  ------------------
  |  Branch (86:16): [True: 245, False: 621]
  ------------------
   87|    866|                   ? 1
   88|    866|                   : TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  ------------------
  |  |  312|    621|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 621, False: 0]
  |  |  ------------------
  |  |  313|    621|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|    621|         : 0U)
  ------------------
   89|    866|    if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  ------------------
  |  |  266|    866|#define PLANARCONFIG_SEPARATE 2            /* separate planes of data */
  ------------------
  |  Branch (89:9): [True: 9, False: 857]
  ------------------
   90|      9|        nstrips =
   91|      9|            _TIFFMultiply32(tif, nstrips, (uint32_t)td->td_samplesperpixel,
   92|      9|                            "TIFFNumberOfStrips");
   93|    866|    return (nstrips);
   94|    866|}
_TIFFStrileSize64:
  101|  13.1k|{
  102|  13.1k|    static const char module[] = "_TIFFStrileSize64";
  103|  13.1k|    TIFFDirectory *td = &tif->tif_dir;
  104|  13.1k|    if (isStrip)
  ------------------
  |  Branch (104:9): [True: 12.9k, False: 198]
  ------------------
  105|  12.9k|    {
  106|  12.9k|        if (nrows == (uint32_t)(-1))
  ------------------
  |  Branch (106:13): [True: 0, False: 12.9k]
  ------------------
  107|      0|            nrows = td->td_imagelength;
  108|  12.9k|    }
  109|    198|    else
  110|    198|    {
  111|    198|        if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
  ------------------
  |  Branch (111:13): [True: 0, False: 198]
  |  Branch (111:39): [True: 2, False: 196]
  ------------------
  112|    196|            td->td_tiledepth == 0)
  ------------------
  |  Branch (112:13): [True: 0, False: 196]
  ------------------
  113|      2|            return (0);
  114|    198|    }
  115|  13.1k|    if ((td->td_planarconfig == PLANARCONFIG_CONTIG) &&
  ------------------
  |  |  265|  13.1k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (115:9): [True: 12.8k, False: 258]
  ------------------
  116|  12.8k|        (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  227|  12.8k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
                      (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
  ------------------
  |  |  281|  3.34k|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|  3.34k|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (116:9): [True: 3.34k, False: 9.52k]
  |  Branch (116:54): [True: 2.54k, False: 801]
  ------------------
  117|  2.54k|    {
  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|  2.54k|        uint16_t ycbcrsubsampling[2];
  127|  2.54k|        uint16_t samplingblock_samples;
  128|  2.54k|        uint32_t samplingblocks_hor;
  129|  2.54k|        uint32_t samplingblocks_ver;
  130|  2.54k|        uint64_t samplingrow_samples;
  131|  2.54k|        uint64_t samplingrow_size;
  132|  2.54k|        if (td->td_samplesperpixel != 3)
  ------------------
  |  Branch (132:13): [True: 0, False: 2.54k]
  ------------------
  133|      0|        {
  134|      0|            TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
  135|      0|            return 0;
  136|      0|        }
  137|  2.54k|        TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|  2.54k|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  138|  2.54k|                              ycbcrsubsampling + 0, ycbcrsubsampling + 1);
  139|  2.54k|        if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 &&
  ------------------
  |  Branch (139:14): [True: 2.29k, False: 249]
  |  Branch (139:42): [True: 0, False: 2.29k]
  ------------------
  140|      0|             ycbcrsubsampling[0] != 4) ||
  ------------------
  |  Branch (140:14): [True: 0, False: 0]
  ------------------
  141|  2.54k|            (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 &&
  ------------------
  |  Branch (141:14): [True: 2.29k, False: 249]
  |  Branch (141:42): [True: 0, False: 2.29k]
  ------------------
  142|      0|             ycbcrsubsampling[1] != 4) ||
  ------------------
  |  Branch (142:14): [True: 0, False: 0]
  ------------------
  143|  2.54k|            (ycbcrsubsampling[0] == 0 || ycbcrsubsampling[1] == 0))
  ------------------
  |  Branch (143:14): [True: 0, False: 2.54k]
  |  Branch (143:42): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|        samplingblock_samples =
  150|  2.54k|            (uint16_t)(ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2);
  151|  2.54k|        const uint32_t width = isStrip ? td->td_imagewidth : td->td_tilewidth;
  ------------------
  |  Branch (151:32): [True: 2.53k, False: 7]
  ------------------
  152|  2.54k|        samplingblocks_hor = TIFFhowmany_32(width, ycbcrsubsampling[0]);
  ------------------
  |  |  312|  2.54k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 2.54k, False: 0]
  |  |  ------------------
  |  |  313|  2.54k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  2.54k|         : 0U)
  ------------------
  153|  2.54k|        samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]);
  ------------------
  |  |  312|  2.54k|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 2.54k, False: 0]
  |  |  ------------------
  |  |  313|  2.54k|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|  2.54k|         : 0U)
  ------------------
  154|  2.54k|        samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor,
  155|  2.54k|                                              samplingblock_samples, module);
  156|  2.54k|        samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64(
  ------------------
  |  |  326|  2.54k|    (((x) & 0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
  |  |  ------------------
  |  |  |  Branch (326:6): [True: 55, False: 2.48k]
  |  |  ------------------
  ------------------
  157|  2.54k|            tif, samplingrow_samples, td->td_bitspersample, module));
  158|  2.54k|        return (
  159|  2.54k|            _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module));
  160|  2.54k|    }
  161|  10.5k|    else
  162|  10.5k|        return (_TIFFMultiply64(tif, nrows,
  163|  10.5k|                                isStrip ? TIFFScanlineSize64(tif)
  ------------------
  |  Branch (163:33): [True: 10.3k, False: 189]
  ------------------
  164|  10.5k|                                        : TIFFTileRowSize64(tif),
  165|  10.5k|                                module));
  166|  13.1k|}
TIFFVStripSize64:
  172|  12.9k|{
  173|  12.9k|    return _TIFFStrileSize64(tif, nrows, /* isStrip = */ TRUE);
  ------------------
  |  |   71|  12.9k|#define TRUE 1
  ------------------
  174|  12.9k|}
TIFFVStripSize:
  177|  7.05k|{
  178|  7.05k|    static const char module[] = "TIFFVStripSize";
  179|  7.05k|    uint64_t m;
  180|  7.05k|    m = TIFFVStripSize64(tif, nrows);
  181|  7.05k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  182|  7.05k|}
TIFFStripSize64:
  231|  5.87k|{
  232|  5.87k|    TIFFDirectory *td = &tif->tif_dir;
  233|  5.87k|    uint32_t rps = td->td_rowsperstrip;
  234|  5.87k|    if (rps > td->td_imagelength)
  ------------------
  |  Branch (234:9): [True: 1.28k, False: 4.59k]
  ------------------
  235|  1.28k|        rps = td->td_imagelength;
  236|  5.87k|    return (TIFFVStripSize64(tif, rps));
  237|  5.87k|}
TIFFStripSize:
  239|  5.86k|{
  240|  5.86k|    static const char module[] = "TIFFStripSize";
  241|  5.86k|    uint64_t m;
  242|  5.86k|    m = TIFFStripSize64(tif);
  243|  5.86k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  244|  5.86k|}
TIFFScanlineSize64:
  292|  11.8k|{
  293|  11.8k|    static const char module[] = "TIFFScanlineSize64";
  294|  11.8k|    TIFFDirectory *td = &tif->tif_dir;
  295|  11.8k|    uint64_t scanline_size;
  296|  11.8k|    if (td->td_planarconfig == PLANARCONFIG_CONTIG)
  ------------------
  |  |  265|  11.8k|#define PLANARCONFIG_CONTIG 1              /* single image plane */
  ------------------
  |  Branch (296:9): [True: 11.6k, False: 169]
  ------------------
  297|  11.6k|    {
  298|  11.6k|        if ((td->td_photometric == PHOTOMETRIC_YCBCR) &&
  ------------------
  |  |  227|  11.6k|#define PHOTOMETRIC_YCBCR 6                /* !CCIR 601 */
  ------------------
  |  Branch (298:13): [True: 1.79k, False: 9.88k]
  ------------------
  299|  1.79k|            (td->td_samplesperpixel == 3) && (!isUpSampled(tif)))
  ------------------
  |  |  281|  1.79k|#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
  |  |  ------------------
  |  |  |  |  133|  1.79k|#define TIFF_UPSAMPLED 0x04000U   /* library is doing data up-sampling */
  |  |  ------------------
  ------------------
  |  Branch (299:13): [True: 1.79k, False: 0]
  |  Branch (299:46): [True: 408, False: 1.38k]
  ------------------
  300|    408|        {
  301|    408|            uint16_t ycbcrsubsampling[2];
  302|    408|            uint16_t samplingblock_samples;
  303|    408|            uint32_t samplingblocks_hor;
  304|    408|            uint64_t samplingrow_samples;
  305|    408|            uint64_t samplingrow_size;
  306|    408|            if (td->td_samplesperpixel != 3)
  ------------------
  |  Branch (306:17): [True: 0, False: 408]
  ------------------
  307|      0|            {
  308|      0|                TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
  309|      0|                return 0;
  310|      0|            }
  311|    408|            TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
  ------------------
  |  |  388|    408|#define TIFFTAG_YCBCRSUBSAMPLING 530       /* !YCbCr subsampling factors */
  ------------------
  312|    408|                                  ycbcrsubsampling + 0, ycbcrsubsampling + 1);
  313|    408|            if (((ycbcrsubsampling[0] != 1) && (ycbcrsubsampling[0] != 2) &&
  ------------------
  |  Branch (313:18): [True: 346, False: 62]
  |  Branch (313:48): [True: 0, False: 346]
  ------------------
  314|      0|                 (ycbcrsubsampling[0] != 4)) ||
  ------------------
  |  Branch (314:18): [True: 0, False: 0]
  ------------------
  315|    408|                ((ycbcrsubsampling[1] != 1) && (ycbcrsubsampling[1] != 2) &&
  ------------------
  |  Branch (315:18): [True: 346, False: 62]
  |  Branch (315:48): [True: 0, False: 346]
  ------------------
  316|      0|                 (ycbcrsubsampling[1] != 4)) ||
  ------------------
  |  Branch (316:18): [True: 0, False: 0]
  ------------------
  317|    408|                ((ycbcrsubsampling[0] == 0) || (ycbcrsubsampling[1] == 0)))
  ------------------
  |  Branch (317:18): [True: 0, False: 408]
  |  Branch (317:48): [True: 0, False: 408]
  ------------------
  318|      0|            {
  319|      0|                TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling");
  320|      0|                return 0;
  321|      0|            }
  322|    408|            samplingblock_samples =
  323|    408|                (uint16_t)(ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2);
  324|    408|            samplingblocks_hor =
  325|    408|                TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]);
  ------------------
  |  |  312|    408|    (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1)))                          \
  |  |  ------------------
  |  |  |  Branch (312:6): [True: 408, False: 0]
  |  |  ------------------
  |  |  313|    408|         ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y)))       \
  |  |  314|    408|         : 0U)
  ------------------
  326|    408|            samplingrow_samples = _TIFFMultiply64(
  327|    408|                tif, samplingblocks_hor, samplingblock_samples, module);
  328|    408|            samplingrow_size =
  329|    408|                TIFFhowmany_64(_TIFFMultiply64(tif, samplingrow_samples,
  ------------------
  |  |  324|    408|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  330|    408|                                               td->td_bitspersample, module),
  331|    408|                               8);
  332|    408|            scanline_size = (samplingrow_size / ycbcrsubsampling[1]);
  333|    408|        }
  334|  11.2k|        else
  335|  11.2k|        {
  336|  11.2k|            uint64_t scanline_samples;
  337|  11.2k|            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|  11.2k|            scanline_samples = _TIFFMultiply64(tif, scanline_width,
  356|  11.2k|                                               td->td_samplesperpixel, module);
  357|  11.2k|            scanline_size =
  358|  11.2k|                TIFFhowmany_64(_TIFFMultiply64(tif, scanline_samples,
  ------------------
  |  |  324|  11.2k|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  359|  11.2k|                                               td->td_bitspersample, module),
  360|  11.2k|                               8);
  361|  11.2k|        }
  362|  11.6k|    }
  363|    169|    else
  364|    169|    {
  365|    169|        scanline_size =
  366|    169|            TIFFhowmany_64(_TIFFMultiply64(tif, td->td_imagewidth,
  ------------------
  |  |  324|    169|    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
  ------------------
  367|    169|                                           td->td_bitspersample, module),
  368|    169|                           8);
  369|    169|    }
  370|  11.8k|    if (scanline_size == 0)
  ------------------
  |  Branch (370:9): [True: 9, False: 11.8k]
  ------------------
  371|      9|    {
  372|      9|        TIFFErrorExtR(tif, module, "Computed scanline size is zero");
  373|      9|        return 0;
  374|      9|    }
  375|  11.8k|    return (scanline_size);
  376|  11.8k|}
TIFFScanlineSize:
  378|  1.43k|{
  379|  1.43k|    static const char module[] = "TIFFScanlineSize";
  380|  1.43k|    uint64_t m;
  381|  1.43k|    m = TIFFScanlineSize64(tif);
  382|  1.43k|    return _TIFFCastUInt64ToSSize(tif, m, module);
  383|  1.43k|}

TIFFSwabShort:
   34|    987|{
   35|    987|    unsigned char *cp = (unsigned char *)wp;
   36|    987|    unsigned char t;
   37|    987|    assert(sizeof(uint16_t) == 2);
  ------------------
  |  Branch (37:5): [True: 0, Folded]
  |  Branch (37:5): [True: 987, Folded]
  ------------------
   38|    987|    t = cp[1];
   39|    987|    cp[1] = cp[0];
   40|    987|    cp[0] = t;
   41|    987|}
TIFFSwabLong:
   46|     34|{
   47|     34|    unsigned char *cp = (unsigned char *)lp;
   48|     34|    unsigned char t;
   49|     34|    assert(sizeof(uint32_t) == 4);
  ------------------
  |  Branch (49:5): [True: 0, Folded]
  |  Branch (49:5): [True: 34, Folded]
  ------------------
   50|     34|    t = cp[3];
   51|     34|    cp[3] = cp[0];
   52|     34|    cp[0] = t;
   53|     34|    t = cp[2];
   54|     34|    cp[2] = cp[1];
   55|     34|    cp[1] = t;
   56|     34|}
TIFFGetBitRevTable:
  306|    231|{
  307|    231|    return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
  ------------------
  |  Branch (307:13): [True: 231, False: 0]
  ------------------
  308|    231|}

TIFFInitThunderScan:
  196|      1|{
  197|      1|    (void)scheme;
  198|       |
  199|      1|    tif->tif_setupdecode = ThunderSetupDecode;
  200|      1|    tif->tif_decoderow = ThunderDecodeRow;
  201|      1|    tif->tif_decodestrip = ThunderDecodeRow;
  202|      1|    return (1);
  203|      1|}
tif_thunder.c:ThunderSetupDecode:
   70|      1|{
   71|      1|    static const char module[] = "ThunderSetupDecode";
   72|       |
   73|      1|    if (tif->tif_dir.td_bitspersample != 4)
  ------------------
  |  Branch (73:9): [True: 0, False: 1]
  ------------------
   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|      1|    return (1);
   83|      1|}
tif_thunder.c:ThunderDecodeRow:
  175|      1|{
  176|      1|    static const char module[] = "ThunderDecodeRow";
  177|      1|    uint8_t *row = buf;
  178|       |
  179|      1|    (void)s;
  180|      1|    if (occ % tif->tif_dir.td_scanlinesize)
  ------------------
  |  Branch (180:9): [True: 0, False: 1]
  ------------------
  181|      0|    {
  182|      0|        TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
  183|      0|        return (0);
  184|      0|    }
  185|      1|    while (occ > 0)
  ------------------
  |  Branch (185:12): [True: 1, False: 0]
  ------------------
  186|      1|    {
  187|      1|        if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
  ------------------
  |  Branch (187:13): [True: 1, False: 0]
  ------------------
  188|      1|            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|      1|}
tif_thunder.c:ThunderDecode:
   86|      1|{
   87|      1|    static const char module[] = "ThunderDecode";
   88|      1|    unsigned char *bp;
   89|      1|    tmsize_t cc;
   90|      1|    unsigned int lastpixel;
   91|      1|    tmsize_t npixels;
   92|      1|    uint8_t *op = op0;
   93|       |
   94|      1|    bp = (unsigned char *)tif->tif_rawcp;
   95|      1|    cc = tif->tif_rawcc;
   96|      1|    lastpixel = 0;
   97|      1|    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: 1]
  ------------------
   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.95k|            case THUNDER_RUN: /* pixel run */
  ------------------
  |  |   47|  6.95k|#define THUNDER_RUN 0x00        /* run of pixels w/ encoded count */
  ------------------
  |  Branch (106:13): [True: 6.95k, False: 3.24k]
  ------------------
  107|       |                /*
  108|       |                 * Replicate the last pixel n times,
  109|       |                 * where n is the lower-order 6 bits.
  110|       |                 */
  111|  6.95k|                if (n == 0)
  ------------------
  |  Branch (111:21): [True: 3.38k, False: 3.57k]
  ------------------
  112|  3.38k|                    break;
  113|  3.57k|                if (npixels & 1)
  ------------------
  |  Branch (113:21): [True: 1.79k, False: 1.77k]
  ------------------
  114|  1.79k|                {
  115|  1.79k|                    op[0] |= (uint8_t)lastpixel;
  116|  1.79k|                    lastpixel = *op++;
  117|  1.79k|                    npixels++;
  118|  1.79k|                    n--;
  119|  1.79k|                }
  120|  1.77k|                else
  121|  1.77k|                    lastpixel |= lastpixel << 4;
  122|  3.57k|                npixels += n;
  123|  3.57k|                if (npixels > maxpixels)
  ------------------
  |  Branch (123:21): [True: 1, False: 3.57k]
  ------------------
  124|      1|                    break;
  125|  33.6k|                for (; n > 0; n -= 2)
  ------------------
  |  Branch (125:24): [True: 30.0k, False: 3.57k]
  ------------------
  126|  30.0k|                    *op++ = (uint8_t)lastpixel;
  127|  3.57k|                if (n == -1)
  ------------------
  |  Branch (127:21): [True: 1.78k, False: 1.78k]
  ------------------
  128|  1.78k|                    *--op &= 0xf0;
  129|  3.57k|                lastpixel &= 0xf;
  130|  3.57k|                break;
  131|    824|            case THUNDER_2BITDELTAS: /* 2-bit deltas */
  ------------------
  |  |   48|    824|#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */
  ------------------
  |  Branch (131:13): [True: 824, False: 9.38k]
  ------------------
  132|    824|                if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    824|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (132:21): [True: 728, False: 96]
  ------------------
  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|    824|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  135|    824|                if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    824|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (135:21): [True: 653, False: 171]
  ------------------
  136|    653|                    SETPIXEL(op,
  ------------------
  |  |   58|    653|    {                                                                          \
  |  |   59|    653|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    653|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 653, False: 0]
  |  |  ------------------
  |  |   61|    653|        {                                                                      \
  |  |   62|    653|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 337, False: 316]
  |  |  ------------------
  |  |   63|    653|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    653|            else                                                               \
  |  |   65|    653|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    653|        }                                                                      \
  |  |   67|    653|    }
  ------------------
  137|    824|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  138|    824|                if ((delta = (n & 3)) != DELTA2_SKIP)
  ------------------
  |  |   49|    824|#define DELTA2_SKIP 2           /* skip code for 2-bit deltas */
  ------------------
  |  Branch (138:21): [True: 765, False: 59]
  ------------------
  139|    765|                    SETPIXEL(op,
  ------------------
  |  |   58|    765|    {                                                                          \
  |  |   59|    765|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    765|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 765, False: 0]
  |  |  ------------------
  |  |   61|    765|        {                                                                      \
  |  |   62|    765|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 371, False: 394]
  |  |  ------------------
  |  |   63|    765|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    765|            else                                                               \
  |  |   65|    765|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    765|        }                                                                      \
  |  |   67|    765|    }
  ------------------
  140|    824|                             (unsigned)((int)lastpixel + twobitdeltas[delta]));
  141|    824|                break;
  142|    978|            case THUNDER_3BITDELTAS: /* 3-bit deltas */
  ------------------
  |  |   50|    978|#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */
  ------------------
  |  Branch (142:13): [True: 978, False: 9.22k]
  ------------------
  143|    978|                if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
  ------------------
  |  |   51|    978|#define DELTA3_SKIP 4           /* skip code for 3-bit deltas */
  ------------------
  |  Branch (143:21): [True: 849, False: 129]
  ------------------
  144|    849|                    SETPIXEL(
  ------------------
  |  |   58|    849|    {                                                                          \
  |  |   59|    849|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    849|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 849, False: 0]
  |  |  ------------------
  |  |   61|    849|        {                                                                      \
  |  |   62|    849|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 437, False: 412]
  |  |  ------------------
  |  |   63|    849|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    849|            else                                                               \
  |  |   65|    849|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    849|        }                                                                      \
  |  |   67|    849|    }
  ------------------
  145|    978|                        op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
  146|    978|                if ((delta = (n & 7)) != DELTA3_SKIP)
  ------------------
  |  |   51|    978|#define DELTA3_SKIP 4           /* skip code for 3-bit deltas */
  ------------------
  |  Branch (146:21): [True: 884, False: 94]
  ------------------
  147|    884|                    SETPIXEL(
  ------------------
  |  |   58|    884|    {                                                                          \
  |  |   59|    884|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|    884|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 884, False: 0]
  |  |  ------------------
  |  |   61|    884|        {                                                                      \
  |  |   62|    884|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 433, False: 451]
  |  |  ------------------
  |  |   63|    884|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|    884|            else                                                               \
  |  |   65|    884|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|    884|        }                                                                      \
  |  |   67|    884|    }
  ------------------
  148|    978|                        op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
  149|    978|                break;
  150|  1.44k|            case THUNDER_RAW: /* raw data */
  ------------------
  |  |   52|  1.44k|#define THUNDER_RAW 0xc0        /* raw data encoded */
  ------------------
  |  Branch (150:13): [True: 1.44k, False: 8.75k]
  ------------------
  151|  1.44k|                SETPIXEL(op, n);
  ------------------
  |  |   58|  1.44k|    {                                                                          \
  |  |   59|  1.44k|        lastpixel = (v) & 0xf;                                                 \
  |  |   60|  1.44k|        if (npixels < maxpixels)                                               \
  |  |  ------------------
  |  |  |  Branch (60:13): [True: 1.44k, False: 0]
  |  |  ------------------
  |  |   61|  1.44k|        {                                                                      \
  |  |   62|  1.44k|            if (npixels++ & 1)                                                 \
  |  |  ------------------
  |  |  |  Branch (62:17): [True: 716, False: 731]
  |  |  ------------------
  |  |   63|  1.44k|                *op++ |= (uint8_t)lastpixel;                                   \
  |  |   64|  1.44k|            else                                                               \
  |  |   65|  1.44k|                op[0] = (uint8_t)(lastpixel << 4);                             \
  |  |   66|  1.44k|        }                                                                      \
  |  |   67|  1.44k|    }
  ------------------
  152|  1.44k|                break;
  153|      0|            default:
  ------------------
  |  Branch (153:13): [True: 0, False: 10.2k]
  ------------------
  154|      0|                break;
  155|  10.2k|        }
  156|  10.2k|    }
  157|      1|    tif->tif_rawcp = (uint8_t *)bp;
  158|      1|    tif->tif_rawcc = cc;
  159|      1|    if (npixels != maxpixels)
  ------------------
  |  Branch (159:9): [True: 1, False: 0]
  ------------------
  160|      1|    {
  161|      1|        uint8_t *op_end = op0 + (maxpixels + 1) / 2;
  162|      1|        memset(op, 0, (size_t)(op_end - op));
  163|      1|        TIFFErrorExtR(tif, module,
  164|      1|                      "%s data at scanline %lu (%" PRIu64 " != %" PRIu64 ")",
  165|      1|                      npixels < maxpixels ? "Not enough" : "Too much",
  ------------------
  |  Branch (165:23): [True: 0, False: 1]
  ------------------
  166|      1|                      (unsigned long)tif->tif_dir.td_row, (uint64_t)npixels,
  167|      1|                      (uint64_t)maxpixels);
  168|      1|        return (0);
  169|      1|    }
  170|       |
  171|      0|    return (1);
  172|      1|}

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

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

TIFFSetWarningHandler:
   33|    402|{
   34|    402|    TIFFErrorHandler prev = _TIFFwarningHandler;
   35|    402|    _TIFFwarningHandler = handler;
   36|    402|    return (prev);
   37|    402|}
TIFFWarningExtR:
   81|  42.1k|{
   82|  42.1k|    va_list ap;
   83|  42.1k|    if (tif && tif->tif_warnhandler)
  ------------------
  |  Branch (83:9): [True: 42.1k, False: 0]
  |  Branch (83:16): [True: 0, False: 42.1k]
  ------------------
   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|  42.1k|    if (_TIFFwarningHandler)
  ------------------
  |  Branch (92:9): [True: 42.1k, False: 0]
  ------------------
   93|  42.1k|    {
   94|  42.1k|        va_start(ap, fmt);
   95|  42.1k|        (*_TIFFwarningHandler)(module, fmt, ap);
   96|  42.1k|        va_end(ap);
   97|  42.1k|    }
   98|  42.1k|    if (_TIFFwarningHandlerExt)
  ------------------
  |  Branch (98:9): [True: 0, False: 42.1k]
  ------------------
   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|  42.1k|}

TIFFInitZIP:
  711|      2|{
  712|      2|    static const char module[] = "TIFFInitZIP";
  713|      2|    ZIPState *sp;
  714|       |
  715|      2|    assert((scheme == COMPRESSION_DEFLATE) ||
  ------------------
  |  Branch (715:5): [True: 2, False: 0]
  |  Branch (715:5): [True: 0, False: 0]
  |  Branch (715:5): [True: 0, False: 2]
  |  Branch (715:5): [True: 2, False: 0]
  ------------------
  716|      2|           (scheme == COMPRESSION_ADOBE_DEFLATE));
  717|       |#ifdef NDEBUG
  718|       |    (void)scheme;
  719|       |#endif
  720|       |
  721|       |    /*
  722|       |     * Merge codec-specific tag information.
  723|       |     */
  724|      2|    if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields)))
  ------------------
  |  |  339|      2|#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
  ------------------
  |  Branch (724:9): [True: 0, False: 2]
  ------------------
  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|      2|    tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, sizeof(ZIPState), 1);
  735|      2|    if (tif->tif_data == NULL)
  ------------------
  |  Branch (735:9): [True: 0, False: 2]
  ------------------
  736|      0|        goto bad;
  737|      2|    sp = GetZIPState(tif);
  ------------------
  |  |   88|      2|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  738|      2|    sp->stream.zalloc = TIFF_zalloc;
  739|      2|    sp->stream.zfree = TIFF_zfree;
  740|      2|    sp->stream.opaque = tif;
  741|      2|    sp->stream.data_type = Z_BINARY;
  742|       |
  743|       |    /*
  744|       |     * Override parent get/set field methods.
  745|       |     */
  746|      2|    sp->vgetparent = tif->tif_tagmethods.vgetfield;
  747|      2|    tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
  748|      2|    sp->vsetparent = tif->tif_tagmethods.vsetfield;
  749|      2|    tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */
  750|       |
  751|       |    /* Default values for codec-specific fields */
  752|      2|    sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
  753|      2|    sp->state = 0;
  754|       |#if LIBDEFLATE_SUPPORT
  755|       |    sp->subcodec = DEFLATE_SUBCODEC_LIBDEFLATE;
  756|       |#else
  757|      2|    sp->subcodec = DEFLATE_SUBCODEC_ZLIB;
  ------------------
  |  |  767|      2|#define DEFLATE_SUBCODEC_ZLIB 0
  ------------------
  758|      2|#endif
  759|       |
  760|       |    /*
  761|       |     * Install codec methods.
  762|       |     */
  763|      2|    tif->tif_fixuptags = ZIPFixupTags;
  764|      2|    tif->tif_setupdecode = ZIPSetupDecode;
  765|      2|    tif->tif_predecode = ZIPPreDecode;
  766|      2|    tif->tif_decoderow = ZIPDecode;
  767|      2|    tif->tif_decodestrip = ZIPDecode;
  768|      2|    tif->tif_decodetile = ZIPDecode;
  769|      2|    tif->tif_setupencode = ZIPSetupEncode;
  770|      2|    tif->tif_preencode = ZIPPreEncode;
  771|      2|    tif->tif_postencode = ZIPPostEncode;
  772|      2|    tif->tif_encoderow = ZIPEncode;
  773|      2|    tif->tif_encodestrip = ZIPEncode;
  774|      2|    tif->tif_encodetile = ZIPEncode;
  775|      2|    tif->tif_cleanup = ZIPCleanup;
  776|      2|    tif->tif_getmaxcompressionratio = ZIPGetMaxCompressionRatio;
  777|       |    /*
  778|       |     * Setup predictor setup.
  779|       |     */
  780|      2|    (void)TIFFPredictorInit(tif);
  781|      2|    return (1);
  782|      0|bad:
  783|      0|    TIFFErrorExtR(tif, module, "No space for ZIP state block");
  784|      0|    return (0);
  785|      2|}
tif_zip.c:TIFF_zalloc:
  685|      2|{
  686|      2|    static const char module[] = "TIFF_zalloc";
  687|      2|    TIFF *tif = (TIFF *)opaque;
  688|       |
  689|      2|    if (items > ~(size_t)0 / size)
  ------------------
  |  Branch (689:9): [True: 0, False: 2]
  ------------------
  690|      0|    {
  691|      0|        TIFFErrorExtR(tif, module, "Overflow");
  692|      0|        return NULL;
  693|      0|    }
  694|       |
  695|      2|    return _TIFFmallocExt(tif, items * size);
  696|      2|}
tif_zip.c:TIFF_zfree:
  699|      2|{
  700|      2|    _TIFFfreeExt((TIFF *)opaque, ptr);
  701|      2|}
tif_zip.c:ZIPVGetField:
  658|     14|{
  659|     14|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|     14|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  660|       |
  661|     14|    switch (tag)
  662|     14|    {
  663|      0|        case TIFFTAG_ZIPQUALITY:
  ------------------
  |  |  739|      0|#define TIFFTAG_ZIPQUALITY 65557      /* compression quality level */
  ------------------
  |  Branch (663:9): [True: 0, False: 14]
  ------------------
  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: 14]
  ------------------
  668|      0|            *va_arg(ap, int *) = sp->subcodec;
  669|      0|            break;
  670|       |
  671|     14|        default:
  ------------------
  |  Branch (671:9): [True: 14, False: 0]
  ------------------
  672|     14|            return (*sp->vgetparent)(tif, tag, ap);
  673|     14|    }
  674|      0|    return (1);
  675|     14|}
tif_zip.c:ZIPVSetField:
  591|      4|{
  592|      4|    static const char module[] = "ZIPVSetField";
  593|      4|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|      4|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  594|       |
  595|      4|    switch (tag)
  596|      4|    {
  597|      0|        case TIFFTAG_ZIPQUALITY:
  ------------------
  |  |  739|      0|#define TIFFTAG_ZIPQUALITY 65557      /* compression quality level */
  ------------------
  |  Branch (597:9): [True: 0, False: 4]
  ------------------
  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: 4]
  ------------------
  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|      4|        default:
  ------------------
  |  Branch (651:9): [True: 4, False: 0]
  ------------------
  652|      4|            return (*sp->vsetparent)(tif, tag, ap);
  653|      4|    }
  654|       |    /*NOTREACHED*/
  655|      4|}
tif_zip.c:ZIPFixupTags:
   96|      2|{
   97|      2|    (void)tif;
   98|      2|    return (1);
   99|      2|}
tif_zip.c:ZIPSetupDecode:
  102|      2|{
  103|      2|    static const char module[] = "ZIPSetupDecode";
  104|      2|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|      2|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|      2|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  105|       |
  106|      2|    assert(sp != NULL);
  ------------------
  |  Branch (106:5): [True: 0, False: 2]
  |  Branch (106:5): [True: 2, False: 0]
  ------------------
  107|       |
  108|       |    /* if we were last encoding, terminate this mode */
  109|      2|    if (sp->state & ZSTATE_INIT_ENCODE)
  ------------------
  |  |   82|      2|#define ZSTATE_INIT_ENCODE 0x02
  ------------------
  |  Branch (109:9): [True: 0, False: 2]
  ------------------
  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|      2|    if ((sp->state & ZSTATE_INIT_DECODE) == 0 &&
  ------------------
  |  |   81|      2|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (118:9): [True: 2, False: 0]
  ------------------
  119|      2|        inflateInit(&sp->stream) != Z_OK)
  ------------------
  |  Branch (119:9): [True: 0, False: 2]
  ------------------
  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|      2|    else
  125|      2|    {
  126|      2|        sp->state |= ZSTATE_INIT_DECODE;
  ------------------
  |  |   81|      2|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  127|      2|        return (1);
  128|      2|    }
  129|      2|}
tif_zip.c:ZIPPreDecode:
  145|      2|{
  146|      2|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|      2|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|      2|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  147|       |
  148|      2|    (void)s;
  149|      2|    assert(sp != NULL);
  ------------------
  |  Branch (149:5): [True: 0, False: 2]
  |  Branch (149:5): [True: 2, False: 0]
  ------------------
  150|       |
  151|      2|    if ((sp->state & ZSTATE_INIT_DECODE) == 0)
  ------------------
  |  |   81|      2|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (151:9): [True: 0, False: 2]
  ------------------
  152|      0|        tif->tif_setupdecode(tif);
  153|       |
  154|       |#if LIBDEFLATE_SUPPORT
  155|       |    sp->libdeflate_state = -1;
  156|       |#endif
  157|      2|    sp->stream.next_in = tif->tif_rawdata;
  158|      2|    assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (158:5): [True: 0, Folded]
  |  Branch (158:5): [True: 2, 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|      2|    sp->stream.avail_in =
  163|      2|        TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)tif->tif_rawcc);
  164|      2|    if (inflateReset(&sp->stream) == Z_OK)
  ------------------
  |  Branch (164:9): [True: 2, False: 0]
  ------------------
  165|      2|    {
  166|      2|        sp->read_error = 0;
  167|      2|        return 1;
  168|      2|    }
  169|      0|    return 0;
  170|      2|}
tif_zip.c:TIFF_CLAMP_UINT64_TO_INT32_MAX:
  137|      6|{
  138|       |    return (uInt)TIFF_MIN_UINT64(v, INT32_MAX);
  139|      6|}
tif_zip.c:TIFF_MIN_UINT64:
  132|      6|{
  133|      6|    return a < b ? a : b;
  ------------------
  |  Branch (133:12): [True: 6, False: 0]
  ------------------
  134|      6|}
tif_zip.c:ZIPDecode:
  173|      2|{
  174|      2|    static const char module[] = "ZIPDecode";
  175|      2|    ZIPState *sp = ZIPDecoderState(tif);
  ------------------
  |  |   89|      2|#define ZIPDecoderState(tif) GetZIPState(tif)
  |  |  ------------------
  |  |  |  |   88|      2|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  |  |  ------------------
  ------------------
  176|       |
  177|      2|    (void)s;
  178|      2|    assert(sp != NULL);
  ------------------
  |  Branch (178:5): [True: 0, False: 2]
  |  Branch (178:5): [True: 2, False: 0]
  ------------------
  179|      2|    assert(sp->state == ZSTATE_INIT_DECODE);
  ------------------
  |  Branch (179:5): [True: 0, False: 2]
  |  Branch (179:5): [True: 2, False: 0]
  ------------------
  180|       |
  181|      2|    if (sp->read_error)
  ------------------
  |  Branch (181:9): [True: 0, False: 2]
  ------------------
  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|      2|    sp->stream.next_in = tif->tif_rawcp;
  270|       |
  271|      2|    sp->stream.next_out = op;
  272|      2|    assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
  ------------------
  |  Branch (272:5): [True: 0, Folded]
  |  Branch (272:5): [True: 2, 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|      2|    do
  277|      2|    {
  278|      2|        int state;
  279|      2|        uInt avail_in_before =
  280|      2|            TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)tif->tif_rawcc);
  281|      2|        uInt avail_out_before = TIFF_CLAMP_UINT64_TO_INT32_MAX((uint64_t)occ);
  282|      2|        sp->stream.avail_in = avail_in_before;
  283|      2|        sp->stream.avail_out = avail_out_before;
  284|      2|        state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
  285|      2|        tif->tif_rawcc -= (avail_in_before - sp->stream.avail_in);
  286|      2|        occ -= (avail_out_before - sp->stream.avail_out);
  287|      2|        if (state == Z_STREAM_END)
  ------------------
  |  Branch (287:13): [True: 0, False: 2]
  ------------------
  288|      0|            break;
  289|      2|        if (state == Z_DATA_ERROR)
  ------------------
  |  Branch (289:13): [True: 2, False: 0]
  ------------------
  290|      2|        {
  291|      2|            memset(sp->stream.next_out, 0, (size_t)occ);
  292|      2|            TIFFErrorExtR(tif, module, "Decoding error at scanline %lu, %s",
  293|      2|                          (unsigned long)tif->tif_dir.td_row, SAFE_MSG(sp));
  ------------------
  |  |   60|      2|#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  294|      2|            sp->read_error = 1;
  295|      2|            return (0);
  296|      2|        }
  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|      2|{
  557|      2|    ZIPState *sp = GetZIPState(tif);
  ------------------
  |  |   88|      2|#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
  ------------------
  558|       |
  559|      2|    assert(sp != 0);
  ------------------
  |  Branch (559:5): [True: 0, False: 2]
  |  Branch (559:5): [True: 2, False: 0]
  ------------------
  560|       |
  561|      2|    (void)TIFFPredictorCleanup(tif);
  562|       |
  563|      2|    tif->tif_tagmethods.vgetfield = sp->vgetparent;
  564|      2|    tif->tif_tagmethods.vsetfield = sp->vsetparent;
  565|       |
  566|      2|    if (sp->state & ZSTATE_INIT_ENCODE)
  ------------------
  |  |   82|      2|#define ZSTATE_INIT_ENCODE 0x02
  ------------------
  |  Branch (566:9): [True: 0, False: 2]
  ------------------
  567|      0|    {
  568|      0|        deflateEnd(&sp->stream);
  569|      0|        sp->state = 0;
  570|      0|    }
  571|      2|    else if (sp->state & ZSTATE_INIT_DECODE)
  ------------------
  |  |   81|      2|#define ZSTATE_INIT_DECODE 0x01
  ------------------
  |  Branch (571:14): [True: 2, False: 0]
  ------------------
  572|      2|    {
  573|      2|        inflateEnd(&sp->stream);
  574|      2|        sp->state = 0;
  575|      2|    }
  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|      2|    _TIFFfreeExt(tif, sp);
  585|      2|    tif->tif_data = NULL;
  586|       |
  587|      2|    _TIFFSetDefaultCompressionState(tif);
  588|      2|}

adler32_z:
   61|    436|uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
   62|    436|    unsigned long sum2;
   63|    436|    unsigned n;
   64|       |
   65|       |    /* split Adler-32 into component sums */
   66|    436|    sum2 = (adler >> 16) & 0xffff;
   67|    436|    adler &= 0xffff;
   68|       |
   69|       |    /* in case user likes doing a byte at a time, keep it fast */
   70|    436|    if (len == 1) {
  ------------------
  |  Branch (70:9): [True: 0, False: 436]
  ------------------
   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|    436|    if (buf == Z_NULL)
  ------------------
  |  |  216|    436|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (81:9): [True: 219, False: 217]
  ------------------
   82|    219|        return 1L;
   83|       |
   84|       |    /* in case short lengths are provided, keep it somewhat fast */
   85|    217|    if (len < 16) {
  ------------------
  |  Branch (85:9): [True: 1, False: 216]
  ------------------
   86|     15|        while (len--) {
  ------------------
  |  Branch (86:16): [True: 14, False: 1]
  ------------------
   87|     14|            adler += *buf++;
   88|     14|            sum2 += adler;
   89|     14|        }
   90|      1|        if (adler >= BASE)
  ------------------
  |  |   10|      1|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  |  Branch (90:13): [True: 0, False: 1]
  ------------------
   91|      0|            adler -= BASE;
  ------------------
  |  |   10|      0|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
   92|      1|        MOD28(sum2);            /* only added so many BASE's */
  ------------------
  |  |   56|      1|#  define MOD28(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|      1|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
   93|      1|        return adler | (sum2 << 16);
   94|      1|    }
   95|       |
   96|       |    /* do length NMAX blocks -- requires just one modulo operation */
   97|    216|    while (len >= NMAX) {
  ------------------
  |  |   11|    216|#define NMAX 5552
  ------------------
  |  Branch (97:12): [True: 0, False: 216]
  ------------------
   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|    216|    if (len) {                  /* avoid modulos if none remaining */
  ------------------
  |  Branch (109:9): [True: 216, False: 0]
  ------------------
  110|  1.51k|        while (len >= 16) {
  ------------------
  |  Branch (110:16): [True: 1.29k, False: 216]
  ------------------
  111|  1.29k|            len -= 16;
  112|  1.29k|            DO16(buf);
  ------------------
  |  |   18|  1.29k|#define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|  1.29k|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|  1.29k|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|  1.29k|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DO16(buf)   DO8(buf,0); DO8(buf,8);
  |  |  ------------------
  |  |  |  |   17|  1.29k|#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|  1.29k|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
  |  |  |  |  ------------------
  |  |  |  |  |  |   16|  1.29k|#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   15|  1.29k|#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   14|  1.29k|#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|  1.29k|            buf += 16;
  114|  1.29k|        }
  115|    216|        while (len--) {
  ------------------
  |  Branch (115:16): [True: 0, False: 216]
  ------------------
  116|      0|            adler += *buf++;
  117|      0|            sum2 += adler;
  118|      0|        }
  119|    216|        MOD(adler);
  ------------------
  |  |   55|    216|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|    216|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  120|    216|        MOD(sum2);
  ------------------
  |  |   55|    216|#  define MOD(a) a %= BASE
  |  |  ------------------
  |  |  |  |   10|    216|#define BASE 65521U     /* largest prime smaller than 65536 */
  |  |  ------------------
  ------------------
  121|    216|    }
  122|       |
  123|       |    /* return recombined sums */
  124|    216|    return adler | (sum2 << 16);
  125|    217|}
adler32:
  128|    436|uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
  129|    436|    return adler32_z(adler, buf, len);
  130|    436|}

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

inflate_table:
   48|      2|                                unsigned FAR *bits, unsigned short FAR *work) {
   49|      2|    unsigned len;               /* a code's length in bits */
   50|      2|    unsigned sym;               /* index of code symbols */
   51|      2|    unsigned min, max;          /* minimum and maximum code lengths */
   52|      2|    unsigned root;              /* number of index bits for root table */
   53|      2|    unsigned curr;              /* number of index bits for current table */
   54|      2|    unsigned drop;              /* code bits to drop for sub-table */
   55|      2|    int left;                   /* number of prefix codes available */
   56|      2|    unsigned used;              /* code entries in table used */
   57|      2|    unsigned huff;              /* Huffman code */
   58|      2|    unsigned incr;              /* for incrementing code, index */
   59|      2|    unsigned fill;              /* index for replicating entries */
   60|      2|    unsigned low;               /* low bits for current root entry */
   61|      2|    unsigned mask;              /* mask for low root bits */
   62|      2|    code here;                  /* table entry for duplication */
   63|      2|    code FAR *next;             /* next available space in table */
   64|      2|    const unsigned short FAR *base = NULL;  /* base value table to use */
   65|      2|    const unsigned short FAR *extra = NULL; /* extra bits table to use */
   66|      2|    unsigned match = 0;         /* use base and extra for symbol >= match */
   67|      2|    unsigned short count[MAXBITS+1];    /* number of codes of each length */
   68|      2|    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
   69|      2|    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
   70|      2|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
   71|      2|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
   72|      2|    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
   73|      2|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
   74|      2|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 68, 193};
   75|      2|    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
   76|      2|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
   77|      2|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
   78|      2|        8193, 12289, 16385, 24577, 0, 0};
   79|      2|    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
   80|      2|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
   81|      2|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
   82|      2|        28, 28, 29, 29, 64, 64};
   83|       |
   84|       |    /*
   85|       |       Process a set of code lengths to create a canonical Huffman code.  The
   86|       |       code lengths are lens[0..codes-1].  Each length corresponds to the
   87|       |       symbols 0..codes-1.  The Huffman code is generated by first sorting the
   88|       |       symbols by length from short to long, and retaining the symbol order
   89|       |       for codes with equal lengths.  Then the code starts with all zero bits
   90|       |       for the first code of the shortest length, and the codes are integer
   91|       |       increments for the same length, and zeros are appended as the length
   92|       |       increases.  For the deflate format, these bits are stored backwards
   93|       |       from their more natural integer increment ordering, and so when the
   94|       |       decoding tables are built in the large loop below, the integer codes
   95|       |       are incremented backwards.
   96|       |
   97|       |       This routine assumes, but does not check, that all of the entries in
   98|       |       lens[] are in the range 0..MAXBITS.  The caller must assure this.
   99|       |       1..MAXBITS is interpreted as that code length.  zero means that that
  100|       |       symbol does not occur in this code.
  101|       |
  102|       |       The codes are sorted by computing a count of codes for each length,
  103|       |       creating from that a table of starting indices for each length in the
  104|       |       sorted table, and then entering the symbols in order in the sorted
  105|       |       table.  The sorted table is work[], with that space being provided by
  106|       |       the caller.
  107|       |
  108|       |       The length counts are used for other purposes as well, i.e. finding
  109|       |       the minimum and maximum length codes, determining if there are any
  110|       |       codes at all, checking for a valid set of lengths, and looking ahead
  111|       |       at length counts to determine sub-table sizes when building the
  112|       |       decoding tables.
  113|       |     */
  114|       |
  115|       |    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
  116|     34|    for (len = 0; len <= MAXBITS; len++)
  ------------------
  |  |   23|     34|#define MAXBITS 15
  ------------------
  |  Branch (116:19): [True: 32, False: 2]
  ------------------
  117|     32|        count[len] = 0;
  118|     40|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (118:19): [True: 38, False: 2]
  ------------------
  119|     38|        count[lens[sym]]++;
  120|       |
  121|       |    /* bound code lengths, force root to be within code lengths */
  122|      2|    root = *bits;
  123|     18|    for (max = MAXBITS; max >= 1; max--)
  ------------------
  |  |   23|      2|#define MAXBITS 15
  ------------------
  |  Branch (123:25): [True: 18, False: 0]
  ------------------
  124|     18|        if (count[max] != 0) break;
  ------------------
  |  Branch (124:13): [True: 2, False: 16]
  ------------------
  125|      2|    if (root > max) root = max;
  ------------------
  |  Branch (125:9): [True: 0, False: 2]
  ------------------
  126|      2|    if (max == 0) {                     /* no symbols to code at all */
  ------------------
  |  Branch (126:9): [True: 0, False: 2]
  ------------------
  127|      0|        here.op = (unsigned char)64;    /* invalid code marker */
  128|      0|        here.bits = (unsigned char)1;
  129|      0|        here.val = (unsigned short)0;
  130|      0|        *(*table)++ = here;             /* make a table to force an error */
  131|      0|        *(*table)++ = here;
  132|      0|        *bits = 1;
  133|      0|        return 0;     /* no symbols, but wait for decoding to report error */
  134|      0|    }
  135|      4|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (135:19): [True: 4, False: 0]
  ------------------
  136|      4|        if (count[min] != 0) break;
  ------------------
  |  Branch (136:13): [True: 2, False: 2]
  ------------------
  137|      2|    if (root < min) root = min;
  ------------------
  |  Branch (137:9): [True: 0, False: 2]
  ------------------
  138|       |
  139|       |    /* check for an over-subscribed or incomplete set of lengths */
  140|      2|    left = 1;
  141|     32|    for (len = 1; len <= MAXBITS; len++) {
  ------------------
  |  |   23|     32|#define MAXBITS 15
  ------------------
  |  Branch (141:19): [True: 30, False: 2]
  ------------------
  142|     30|        left <<= 1;
  143|     30|        left -= count[len];
  144|     30|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (144:13): [True: 0, False: 30]
  ------------------
  145|     30|    }
  146|      2|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (146:9): [True: 0, False: 2]
  |  Branch (146:22): [True: 0, False: 0]
  |  Branch (146:39): [True: 0, False: 0]
  ------------------
  147|      0|        return -1;                      /* incomplete set */
  148|       |
  149|       |    /* generate offsets into symbol table for each length for sorting */
  150|      2|    offs[1] = 0;
  151|     30|    for (len = 1; len < MAXBITS; len++)
  ------------------
  |  |   23|     30|#define MAXBITS 15
  ------------------
  |  Branch (151:19): [True: 28, False: 2]
  ------------------
  152|     28|        offs[len + 1] = offs[len] + count[len];
  153|       |
  154|       |    /* sort symbols by length, by symbol order within each length */
  155|     40|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (155:19): [True: 38, False: 2]
  ------------------
  156|     38|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
  ------------------
  |  Branch (156:13): [True: 36, False: 2]
  ------------------
  157|       |
  158|       |    /*
  159|       |       Create and fill in decoding tables.  In this loop, the table being
  160|       |       filled is at next and has curr index bits.  The code being used is huff
  161|       |       with length len.  That code is converted to an index by dropping drop
  162|       |       bits off of the bottom.  For codes where len is less than drop + curr,
  163|       |       those top drop + curr - len bits are incremented through all values to
  164|       |       fill the table with replicated entries.
  165|       |
  166|       |       root is the number of index bits for the root table.  When len exceeds
  167|       |       root, sub-tables are created pointed to by the root entry with an index
  168|       |       of the low root bits of huff.  This is saved in low to check for when a
  169|       |       new sub-table should be started.  drop is zero when the root table is
  170|       |       being filled, and drop is root when sub-tables are being filled.
  171|       |
  172|       |       When a new sub-table is needed, it is necessary to look ahead in the
  173|       |       code lengths to determine what size sub-table is needed.  The length
  174|       |       counts are used for this, and so count[] is decremented as codes are
  175|       |       entered in the tables.
  176|       |
  177|       |       used keeps track of how many table entries have been allocated from the
  178|       |       provided *table space.  It is checked for LENS and DIST tables against
  179|       |       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
  180|       |       the initial root table size constants.  See the comments in inftrees.h
  181|       |       for more information.
  182|       |
  183|       |       sym increments through all symbols, and the loop terminates when
  184|       |       all codes of length max, i.e. all codes, have been processed.  This
  185|       |       routine permits incomplete codes, so another loop after this one fills
  186|       |       in the rest of the decoding tables with invalid code markers.
  187|       |     */
  188|       |
  189|       |    /* set up for code type */
  190|      2|    switch (type) {
  ------------------
  |  Branch (190:13): [True: 2, False: 0]
  ------------------
  191|      2|    case CODES:
  ------------------
  |  Branch (191:5): [True: 2, False: 0]
  ------------------
  192|      2|        match = 20;
  193|      2|        break;
  194|      0|    case LENS:
  ------------------
  |  Branch (194:5): [True: 0, False: 2]
  ------------------
  195|      0|        base = lbase;
  196|      0|        extra = lext;
  197|      0|        match = 257;
  198|      0|        break;
  199|      0|    case DISTS:
  ------------------
  |  Branch (199:5): [True: 0, False: 2]
  ------------------
  200|      0|        base = dbase;
  201|      0|        extra = dext;
  202|      2|    }
  203|       |
  204|       |    /* initialize state for loop */
  205|      2|    huff = 0;                   /* starting code */
  206|      2|    sym = 0;                    /* starting code symbol */
  207|      2|    len = min;                  /* starting code length */
  208|      2|    next = *table;              /* current table to fill in */
  209|      2|    curr = root;                /* current table index bits */
  210|      2|    drop = 0;                   /* current bits to drop from code for index */
  211|      2|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  212|      2|    used = 1U << root;          /* use root table entries */
  213|      2|    mask = used - 1;            /* mask for comparing low */
  214|       |
  215|       |    /* check available table space */
  216|      2|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   50|      0|#  define ENOUGH_LENS 852
  ------------------
  |  Branch (216:10): [True: 0, False: 2]
  |  Branch (216:26): [True: 0, False: 0]
  ------------------
  217|      2|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   51|      0|#  define ENOUGH_DISTS 592
  ------------------
  |  Branch (217:10): [True: 0, False: 2]
  |  Branch (217:27): [True: 0, False: 0]
  ------------------
  218|      0|        return 1;
  219|       |
  220|       |    /* process all codes and make table entries */
  221|     36|    for (;;) {
  222|       |        /* create table entry */
  223|     36|        here.bits = (unsigned char)(len - drop);
  224|     36|        if (work[sym] + 1U < match) {
  ------------------
  |  Branch (224:13): [True: 36, False: 0]
  ------------------
  225|     36|            here.op = (unsigned char)0;
  226|     36|            here.val = work[sym];
  227|     36|        }
  228|      0|        else if (work[sym] >= match) {
  ------------------
  |  Branch (228:18): [True: 0, False: 0]
  ------------------
  229|      0|            here.op = (unsigned char)(extra[work[sym] - match]);
  230|      0|            here.val = base[work[sym] - match];
  231|      0|        }
  232|      0|        else {
  233|      0|            here.op = (unsigned char)(32 + 64);         /* end of block */
  234|      0|            here.val = 0;
  235|      0|        }
  236|       |
  237|       |        /* replicate for those indices with low len bits equal to huff */
  238|     36|        incr = 1U << (len - drop);
  239|     36|        fill = 1U << curr;
  240|     36|        min = fill;                 /* save offset to next table */
  241|    256|        do {
  242|    256|            fill -= incr;
  243|    256|            next[(huff >> drop) + fill] = here;
  244|    256|        } while (fill != 0);
  ------------------
  |  Branch (244:18): [True: 220, False: 36]
  ------------------
  245|       |
  246|       |        /* backwards increment the len-bit code huff */
  247|     36|        incr = 1U << (len - 1);
  248|     70|        while (huff & incr)
  ------------------
  |  Branch (248:16): [True: 34, False: 36]
  ------------------
  249|     34|            incr >>= 1;
  250|     36|        if (incr != 0) {
  ------------------
  |  Branch (250:13): [True: 34, False: 2]
  ------------------
  251|     34|            huff &= incr - 1;
  252|     34|            huff += incr;
  253|     34|        }
  254|      2|        else
  255|      2|            huff = 0;
  256|       |
  257|       |        /* go to next symbol, update count, len */
  258|     36|        sym++;
  259|     36|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (259:13): [True: 8, False: 28]
  ------------------
  260|      8|            if (len == max) break;
  ------------------
  |  Branch (260:17): [True: 2, False: 6]
  ------------------
  261|      6|            len = lens[work[sym]];
  262|      6|        }
  263|       |
  264|       |        /* create new sub-table if needed */
  265|     34|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (265:13): [True: 0, False: 34]
  |  Branch (265:27): [True: 0, False: 0]
  ------------------
  266|       |            /* if first time, transition to sub-tables */
  267|      0|            if (drop == 0)
  ------------------
  |  Branch (267:17): [True: 0, False: 0]
  ------------------
  268|      0|                drop = root;
  269|       |
  270|       |            /* increment past last table */
  271|      0|            next += min;            /* here min is 1 << curr */
  272|       |
  273|       |            /* determine length of next table */
  274|      0|            curr = len - drop;
  275|      0|            left = (int)(1 << curr);
  276|      0|            while (curr + drop < max) {
  ------------------
  |  Branch (276:20): [True: 0, False: 0]
  ------------------
  277|      0|                left -= count[curr + drop];
  278|      0|                if (left <= 0) break;
  ------------------
  |  Branch (278:21): [True: 0, False: 0]
  ------------------
  279|      0|                curr++;
  280|      0|                left <<= 1;
  281|      0|            }
  282|       |
  283|       |            /* check for enough space */
  284|      0|            used += 1U << curr;
  285|      0|            if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   50|      0|#  define ENOUGH_LENS 852
  ------------------
  |  Branch (285:18): [True: 0, False: 0]
  |  Branch (285:34): [True: 0, False: 0]
  ------------------
  286|      0|                (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   51|      0|#  define ENOUGH_DISTS 592
  ------------------
  |  Branch (286:18): [True: 0, False: 0]
  |  Branch (286:35): [True: 0, False: 0]
  ------------------
  287|      0|                return 1;
  288|       |
  289|       |            /* point entry in root table to sub-table */
  290|      0|            low = huff & mask;
  291|      0|            (*table)[low].op = (unsigned char)curr;
  292|      0|            (*table)[low].bits = (unsigned char)root;
  293|      0|            (*table)[low].val = (unsigned short)(next - *table);
  294|      0|        }
  295|     34|    }
  296|       |
  297|       |    /* fill in remaining table entry if code is incomplete (guaranteed to have
  298|       |       at most one remaining entry, since if the code is incomplete, the
  299|       |       maximum code length that was allowed to get this far is one bit) */
  300|      2|    if (huff != 0) {
  ------------------
  |  Branch (300:9): [True: 0, False: 2]
  ------------------
  301|      0|        here.op = (unsigned char)64;            /* invalid code marker */
  302|      0|        here.bits = (unsigned char)(len - drop);
  303|      0|        here.val = (unsigned short)0;
  304|      0|        next[huff] = here;
  305|      0|    }
  306|       |
  307|       |    /* set return parameters */
  308|      2|    *table += used;
  309|      2|    *bits = root;
  310|      2|    return 0;
  311|      2|}
inflate_fixed:
  364|    217|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|    217|    state->lencode = lenfix;
  369|    217|    state->lenbits = 9;
  370|    217|    state->distcode = distfix;
  371|    217|    state->distbits = 5;
  372|    217|}

zcalloc:
  303|      2|voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
  304|      2|    (void)opaque;
  305|      2|    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
  ------------------
  |  Branch (305:12): [True: 2, Folded]
  ------------------
  306|      2|                              (voidpf)calloc(items, size);
  307|      2|}
zcfree:
  309|      2|void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
  310|      2|    (void)opaque;
  311|      2|    free(ptr);
  312|      2|}

